/* menu.css — the restaurant menu card (menu.js). A round button with a
   hand-drawn list icon in the top-right corner; a parchment card with a gold
   double rule, a serif display face and courses with dotted leaders. The
   card unfolds from the button (transform-origin set by menu.js); reduced
   motion = short fade. Desktop (.docked, set by menu.js from DOCK_QUERY): a
   narrower non-modal side card on the right without scrim; the highlight
   banner and the thread nav slide left by --menu-dock-shift.
   Keep OPEN_MS / CLOSE_MS / FADE_MS in menu.js in step with the animations. */

:root {
  --menu-paper: #f4ead3;
  --menu-paper-deep: #e8d8b4;
  --menu-ink: #3a2a1a;
  --menu-ink-soft: #6b5338;
  --menu-gold: #b08d3c;
  --menu-gold-light: #d9bd73;
  --menu-serif: "Cormorant Garamond", "Playfair Display", "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --menu-top: calc(env(safe-area-inset-top, 0px) + 0.75rem);
  --menu-right: calc(env(safe-area-inset-right, 0px) + 0.75rem);
}

/* Keep the desktop hint clear of the button. */
.titlebar { padding-right: calc(var(--menu-right) + 48px + 0.9rem); }

/* --- button --- */
.menu-btn {
  position: fixed;
  top: var(--menu-top);
  right: var(--menu-right);
  z-index: 10;
  width: 48px;
  height: 48px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--menu-gold-light);
  background: radial-gradient(circle at 35% 30%, #fffaf0 0%, var(--menu-paper) 55%, var(--menu-paper-deep) 100%);
  color: var(--menu-ink);
  box-shadow: 0 0 0 3px rgba(176, 141, 60, 0.25), 0 6px 22px rgba(4, 3, 14, 0.55);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.menu-btn:hover { transform: scale(1.06); }
.menu-btn:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px var(--accent, #ff5c5c), 0 6px 22px rgba(4, 3, 14, 0.55);
}
.menu-btn[aria-expanded="true"] { transform: rotate(-12deg); }
.menu-icon { width: 24px; height: 24px; overflow: visible; }

/* --- outside-click layer --- */
.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 11;
  background: rgba(8, 6, 22, 0.35);
}

/* --- card --- */
.menu-card {
  position: fixed;
  z-index: 12;
  top: calc(var(--menu-top) + 48px + 0.6rem);
  right: var(--menu-right);
  width: min(440px, calc(100vw - 1.5rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  max-height: calc(100dvh - var(--menu-top) - 48px - 1.6rem - env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  color: var(--menu-ink);
  font-family: var(--menu-serif);
  border-radius: 6px;
  /* Paper: warm vignette, faint fibres and fractal noise (inline SVG). */
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.25 0 0 0 0 0.1 0 0 0 0.09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    repeating-linear-gradient(97deg, rgba(120, 90, 40, 0.025) 0 2px, transparent 2px 7px),
    radial-gradient(ellipse at 50% 40%, #fbf4e2 0%, var(--menu-paper) 55%, var(--menu-paper-deep) 100%);
  box-shadow: 0 24px 60px rgba(4, 3, 14, 0.6), 0 2px 0 rgba(255, 255, 255, 0.4) inset;
  outline: none;
}
.menu-card[hidden], .menu-backdrop[hidden] { display: none; }
/* Thin gold double rule, inset like the cards' gold-leaf frames. */
.menu-card::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 3px double var(--menu-gold);
  border-radius: 3px;
  pointer-events: none;
}
.menu-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.6rem 1.8rem 1.2rem;
  margin: 14px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--menu-gold) transparent;
}
.menu-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--menu-ink-soft);
  font: 1.6rem/1 var(--menu-serif);
  cursor: pointer;
}
.menu-close:hover { color: var(--menu-ink); }
.menu-close:focus-visible { outline: 2px solid var(--menu-gold); outline-offset: -4px; }

.menu-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  color: var(--menu-gold);
  margin: 0.2rem 1.4rem 0.6rem;
}
.menu-flourish { width: 72px; height: 20px; flex: 0 1 72px; }
.menu-flourish.mirrored { transform: scaleX(-1); }
.menu-title {
  margin: 0;
  font-family: var(--menu-serif);
  font-weight: 600;
  font-size: 2.1rem;
  letter-spacing: 0.06em;
  color: var(--menu-ink);
}

.menu-section {
  margin: 1rem 0 0.3rem;
  text-align: center;
  font: italic 600 1.05rem/1.2 var(--menu-serif);
  letter-spacing: 0.12em;
  color: var(--menu-gold);
}
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-list li + li { border-top: 1px solid rgba(176, 141, 60, 0.22); }
.course {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.5rem;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: inherit;
  font-family: var(--menu-serif);
  text-align: left;
  cursor: pointer;
}
.course:hover { background: rgba(176, 141, 60, 0.1); }
.course:focus-visible { outline: 2px solid var(--menu-gold); outline-offset: -2px; background: rgba(176, 141, 60, 0.12); }
.course-row { display: flex; align-items: baseline; gap: 0.35rem; }
.course-name {
  font-variant: small-caps;
  font-weight: 600;
  font-size: 1.18rem;
  letter-spacing: 0.05em;
}
.course-leader {
  flex: 1 1 auto;
  min-width: 1rem;
  border-bottom: 2px dotted rgba(58, 42, 26, 0.45);
  transform: translateY(-0.3em);
}
.course-no { font-style: italic; font-size: 0.95rem; color: var(--menu-ink-soft); white-space: nowrap; }
.course-line {
  display: block;
  margin-top: 0.1rem;
  font-style: italic;
  font-size: 0.98rem;
  line-height: 1.3;
  color: var(--menu-ink-soft);
}
.course.current .course-name::before { content: "\2766\00a0"; color: var(--menu-gold); font-variant: normal; }
.course.current { background: rgba(176, 141, 60, 0.14); }
.course.current .course-no { color: var(--menu-gold); font-weight: 600; }
.menu-divider, .menu-foot {
  margin: 0.6rem 0 0;
  text-align: center;
  color: var(--menu-gold);
  font-size: 1.1rem;
}

/* --- animation: handed over from the button, folded back to it --- */
.menu-card.opening { animation: menu-unfold 520ms cubic-bezier(0.2, 0.85, 0.25, 1) both; }
.menu-card.closing { animation: menu-fold 380ms cubic-bezier(0.55, 0, 0.75, 0.2) both; pointer-events: none; }
@keyframes menu-unfold {
  0%   { opacity: 0; transform: perspective(900px) scale(0.12) rotate(-14deg) rotateX(60deg); }
  55%  { opacity: 1; transform: perspective(900px) scale(1.02) rotate(1.5deg) rotateX(-4deg); }
  100% { opacity: 1; transform: perspective(900px); }
}
@keyframes menu-fold {
  0%   { opacity: 1; transform: perspective(900px); }
  100% { opacity: 0; transform: perspective(900px) scale(0.1) rotate(-12deg) rotateX(55deg); }
}
/* --- desktop: docked side card (non-modal, no scrim) --- */
.menu-card.docked {
  width: clamp(300px, 30vw, 380px);
  box-shadow: 0 18px 44px rgba(4, 3, 14, 0.5), 0 0 0 1px rgba(217, 189, 115, 0.35), 0 2px 0 rgba(255, 255, 255, 0.4) inset;
}
.menu-card.docked .menu-body { padding: 1.3rem 1.2rem 1rem; }
.menu-card.docked .menu-title { font-size: 1.8rem; }
.menu-card.docked .menu-flourish { width: 52px; flex-basis: 52px; }
.menu-card.docked .course-name { font-size: 1.08rem; }
html.menu-docked .highlight,
html.menu-docked .thread-nav { margin-left: calc(-1 * var(--menu-dock-shift, 0px)); }
.highlight, .thread-nav { transition: margin-left 320ms ease; }

.menu-card.reduced.opening { animation: menu-fade-in 160ms ease-out both; }
.menu-card.reduced.closing { animation: menu-fade-out 160ms ease-in both; }
@keyframes menu-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes menu-fade-out { from { opacity: 1; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion]) .menu-btn, :root:not([data-motion]) .menu-btn[aria-expanded="true"] { transition: none; transform: none; }
  :root:not([data-motion]) .highlight, :root:not([data-motion]) .thread-nav { transition: none; }
}
:root[data-motion="reduced"] .menu-btn, :root[data-motion="reduced"] .menu-btn[aria-expanded="true"] { transition: none; transform: none; }
:root[data-motion="reduced"] .highlight, :root[data-motion="reduced"] .thread-nav { transition: none; }

/* --- phones: nearly full screen --- */
@media (max-width: 520px) {
  .titlebar { padding-right: calc(var(--menu-right) + 48px + 0.6rem); }
  .menu-card {
    top: calc(env(safe-area-inset-top, 0px) + 0.5rem);
    right: calc(env(safe-area-inset-right, 0px) + 0.5rem);
    left: calc(env(safe-area-inset-left, 0px) + 0.5rem);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 0.5rem);
    width: auto;
    max-height: none;
  }
  .menu-body { padding: 1.3rem 1rem 1rem; margin: 12px 10px; }
  .menu-title { font-size: 1.75rem; }
  .menu-flourish { width: 48px; flex-basis: 48px; }
  .course-name { font-size: 1.08rem; }
}

/* --- motion (round 6 A1, motion-ask.js) ---
   The reduced-motion question: a parchment card in the menu's paper over a
   dim scrim, above the loader; two chip-like buttons. The Motion toggle
   sits on the menu card and in the settings panel. */
.motion-ask {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  background: rgba(4, 3, 14, 0.62);
}
.motion-ask-box {
  max-width: 26rem;
  padding: 1.3rem 1.5rem 1.2rem;
  color: var(--menu-ink);
  background: linear-gradient(180deg, #fbf4e2 0%, var(--menu-paper) 60%, var(--menu-paper-deep) 100%);
  border-top: 1px solid var(--menu-gold);
  border-bottom: 1px solid var(--menu-gold);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  font-family: var(--menu-serif);
  text-align: center;
}
.motion-ask-title { margin: 0 0 0.4rem; font-size: 1.25rem; font-weight: 600; font-variant: small-caps; letter-spacing: 0.04em; }
.motion-ask-text { margin: 0 0 1rem; font-size: 1.05rem; color: var(--menu-ink-soft); }
.motion-ask-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.motion-ask-btn, .motion-toggle {
  min-height: 44px;
  padding: 0.3rem 1.3rem;
  color: var(--menu-ink);
  background: linear-gradient(180deg, #fbf4e2 0%, var(--menu-paper) 60%, var(--menu-paper-deep) 100%);
  border: 0;
  border-top: 1px solid var(--menu-gold);
  border-bottom: 1px solid var(--menu-gold);
  font: 600 1rem/1.2 var(--menu-serif);
  font-variant: small-caps;
  letter-spacing: 0.08em;
  cursor: pointer;
  clip-path: polygon(0 0, 100% 0, calc(100% - 0.5rem) 50%, 100% 100%, 0 100%, 0.5rem 50%);
}
.motion-ask-btn[data-motion="reduced"] { background: var(--menu-gold-light); }
.motion-ask-btn:focus-visible, .motion-toggle:focus-visible { outline: 2px solid var(--menu-gold); outline-offset: 3px; clip-path: none; }
.menu-motion { display: flex; justify-content: center; margin-top: 0.6rem; }
.motion-toggle { min-height: 36px; font-size: 0.9rem; }
