/* ============================================================
   Food Decider — visual design

   Palette (kept as CSS variables so it's easy to tweak in one
   place): kopitiam-marble cream background, terracotta primary
   action, deep teal-green outline as secondary, tactile-paving
   yellow as the focus-ring accent. Type: Fraunces (warm serif)
   for headings and the dish-name hero, Inter (clean sans) for
   body & buttons.

   The brighter footbridge-green (--green) is reserved for
   non-interactive accents (text headings, success toast, the
   kopi-cup stripe). The deep teal MRT signage greens belong to
   the .mrt-sign band and the secondary outline button — never
   the primary CTA.

   Mobile-first: portrait phone is the design target. Each
   screen is sized to fit comfortably in an iPhone-SE viewport
   without scrolling.
   ============================================================ */


/* --- Reset --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}


/* --- Design tokens --- */
:root {
  /* Surfaces */
  --bg-cream:        #F5F0E6;  /* page bg — kopitiam marble tone */
  --card:            #FFFFFF;  /* the centred container */
  --pill-bg:         #F4EFE5;  /* unselected filter pill */
  --pill-bg-hover:   #ECE5D5;
  --border:          #E0DCD5;  /* soft beige dividers/borders */

  /* Accents */
  --green:           #1B5E3F;  /* footbridge / void-deck railing green — non-interactive accents only (text headings, success toast, kopi-cup stripe) */
  --green-deep:      #154A31;  /* darker --green, currently used by ate-toast border at low opacity */
  --green-tint:      rgba(27, 94, 63, 0.10);

  /* MRT signage greens — deeper and cooler than the now-deprecated brighter
     button green, to match the actual teal-leaning forest green of Singapore
     station signs. Used by the .mrt-sign band, the EW67 badge, the secondary
     outline button, and selected filter pills — anchoring the
     "signage / selection" colour family. */
  --mrt-green:       #0B4332;  /* MRT sign band — deeper, slight teal lean */
  --mrt-green-deep:  #082F23;  /* EW67 badge — slightly darker still */

  --yellow:          #E8B940;  /* tactile-paving yellow — used for focus ring */

  --terracotta:      #B85C3A;  /* clay/satay accent */
  --terracotta-deep: #9A4A2D;
  --terracotta-soft: #DDB7A5;  /* disabled-state terracotta */

  /* Text */
  --text:            #2A1F18;  /* warm dark brown, not pure black */
  --text-muted:      #7A6A5C;

  /* Effects */
  --shadow-card:     0 4px 16px rgba(42, 31, 24, 0.08);
  --shadow-btn-2:    0 2px 6px rgba(184, 92, 58, 0.18);  /* terracotta-tinted, used by primary button */

  /* Type */
  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}


/* --- Page background ---
   The body fills the viewport with a warm cream and a very subtle
   Peranakan-tile-inspired lattice: two crossed diagonal hairlines
   form a diamond grid with a small terracotta dot at the centre of
   each cell. All layered at ~5% opacity so it reads as atmosphere,
   not decoration. On mobile the white card mostly covers it; you
   mainly see the pattern in the page margins around the card. */
body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg-cream);
  background-image:
    linear-gradient(45deg,
      transparent 48%,
      rgba(27, 94, 63, 0.05) 49%,
      rgba(27, 94, 63, 0.05) 51%,
      transparent 52%),
    linear-gradient(-45deg,
      transparent 48%,
      rgba(27, 94, 63, 0.05) 49%,
      rgba(27, 94, 63, 0.05) 51%,
      transparent 52%),
    radial-gradient(circle at 50% 50%,
      rgba(184, 92, 58, 0.07) 1.5px,
      transparent 2px);
  background-size: 38px 38px, 38px 38px, 38px 38px;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1.25rem;
  /* Prevents the kopi cup's negative-right offset from causing a
     horizontal scrollbar on narrow viewports. */
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


/* --- Card stack ---
   Positioning context that holds the card AND any decorations layered
   behind/in-front (currently the kopi cup). The body's flex centring
   centres the whole stack, so the card stays perfectly centred while
   the cup is allowed to peek asymmetrically. */
.card-stack {
  position: relative;
  width: 100%;
  max-width: 420px;
}


/* --- Container card ---
   Centred white card with a soft warm shadow and a 1px beige border.
   Stays comfortable on a phone (max-width 420px). position: relative
   anchors the ::before vintage-menu inner border. z-index above the
   kopi cup so the card visually overlaps it on its left side. */
.container {
  position: relative;
  z-index: 1;
  width: 100%;
  text-align: center;
  background-color: var(--card);
  padding: 2rem 1.5rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

/* Vintage menu-style inner border — thin warm-brown line inset 7px
   from the card edge, following the card's rounded corners with a
   slightly tighter radius so the curves stay parallel. The card's
   own beige border provides the outer line, giving the double-line
   effect without stacking borders on the same element. */
.container::before {
  content: "";
  position: absolute;
  inset: 7px;                                 /* shorthand: top/right/bottom/left */
  border: 1px solid rgba(42, 31, 24, 0.22);   /* --text at 22% opacity */
  border-radius: 11px;                        /* 16px outer − 5px = parallel curves */
  pointer-events: none;                       /* never blocks clicks */
}


/* --- Headings (serif) --- */
h1 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 2.25rem;
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: var(--green);
  margin-bottom: 0.5rem;
}

/* --- MRT-style title sign (landing screen) ---
   Faux MRT station signage: deep teal-green landscape band with four
   zones, separated by faint white vertical hairline dividers:
     .mrt-logo    — abstracted train-bars logo on the left
     .mrt-code    — "EW67" station-code badge (landscape rounded rect)
     .mrt-name    — "Food Decider" station-name (largest text)
     .mrt-icon    — fork-and-spoon pictogram in a white-bordered box
   Uses --mrt-green (deeper, slight teal lean) to match real Singapore
   station signage — distinct from the brighter --green which is reserved
   for non-interactive accents. `display: flex; width: 100%` makes the
   sign fill the card content area, giving it proper landscape proportions
   instead of pill-shaped. */
.mrt-sign {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
  background-color: var(--mrt-green);
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 1.25rem;
  box-shadow: 0 2px 6px rgba(11, 67, 50, 0.22);
}

/* Vertical divider hairline between zones — faint white line that
   stretches the full inner height of the sign. */
.mrt-divider {
  flex: 0 0 auto;
  width: 1px;
  align-self: stretch;
  background-color: rgba(255, 255, 255, 0.28);
  margin: 2px 0;
}

/* Logo zone (leftmost) — abstracted MRT-system mark in white. */
.mrt-logo {
  flex: 0 0 auto;
  width: 26px;
  height: 18px;
  display: inline-flex;
  align-items: center;
}
.mrt-logo svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Station code badge — small landscape rounded rectangle (NOT a circle).
   Real Singapore station codes (e.g. NS22 on Orchard) are displayed in
   small pill-shaped badges, not circles. Background is slightly darker
   than the sign band for subtle differentiation, with a thin low-opacity
   white border for definition. */
.mrt-code {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 4px;
  background-color: var(--mrt-green-deep);
  color: #ffffff;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
}

/* Station name — the visually dominant element. flex: 1 takes whatever
   space is left after the fixed-width zones. */
.mrt-name {
  flex: 1 1 auto;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.005em;
  color: #ffffff;
  text-align: left;
  line-height: 1.1;
}

/* Pictogram zone (rightmost) — small white-bordered square containing
   the fork-and-spoon SVG. Mirrors how real MRT signs use bordered
   boxes for bus/MRT/wheelchair pictograms. */
.mrt-icon {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
}
.mrt-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.screen-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.625rem;
  letter-spacing: -0.01em;
  color: var(--green);
  margin-bottom: 0.5rem;
}

.tagline {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}


/* --- Screens ---
   Every <section class="screen"> is hidden by default; the one with
   "active" added is the only one shown. app.js toggles this class. */
.screen { display: none; }
.screen.active { display: block; }


/* --- Buttons ---
   Three tiers, used consistently across screens:
     .primary-btn   — filled terracotta, the main CTA on each screen
     .secondary-btn — deep teal-green outline, a quieter alternate action
     .ghost-btn     — text-only with a faint border, the quietest "abandon"
   All three are sized at ~78% of the card content width (max 320px) and
   centred — refined "deliberate button" feel rather than full-width banner.
   All three keep min-height 44px to be tap-comfortable on mobile. */

.primary-btn {
  display: block;
  width: 78%;
  max-width: 320px;
  margin: 0 auto;
  padding: 0.7rem 1.25rem;
  min-height: 44px;
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  font-weight: 600;
  color: #ffffff;
  background-color: var(--terracotta);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: var(--shadow-btn-2);
  transition: background-color 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}
.primary-btn:hover {
  background-color: var(--terracotta-deep);
  box-shadow: 0 3px 10px rgba(184, 92, 58, 0.25);
}
.primary-btn:active {
  transform: scale(0.98);
}
.primary-btn:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}
.primary-btn:disabled {
  background-color: var(--terracotta-soft);
  color: #ffffff;
  box-shadow: none;
  cursor: not-allowed;
}

/* Secondary action: outline button using the deep teal MRT-signage green.
   Transparent fill with a 1.5px border — flat, no shadow. The colour
   choice ties this action visually to the MRT sign band so it reads as
   a related-but-quieter alternative to the terracotta primary. */
.secondary-btn {
  display: block;
  width: 78%;
  max-width: 320px;
  margin: 0.65rem auto 0;
  padding: 0.6rem 1.25rem;
  min-height: 44px;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  color: var(--mrt-green);
  background-color: transparent;
  border: 1.5px solid var(--mrt-green);
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.secondary-btn:hover {
  background-color: rgba(11, 67, 50, 0.08);
  color: var(--mrt-green-deep);
  border-color: var(--mrt-green-deep);
}
.secondary-btn:active {
  transform: scale(0.98);
}
.secondary-btn:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}
.secondary-btn:disabled {
  color: rgba(11, 67, 50, 0.35);
  border-color: rgba(11, 67, 50, 0.25);
  background-color: transparent;
  cursor: not-allowed;
}

.ghost-btn {
  display: block;
  width: 78%;
  max-width: 320px;
  margin: 0.65rem auto 0;
  padding: 0.5rem 1rem;
  min-height: 44px;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-muted);
  background-color: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.ghost-btn:hover {
  background-color: var(--bg-cream);
  color: var(--text);
  border-color: var(--text-muted);
}
.ghost-btn:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}


/* --- Reroll note (shown when re-roll is disabled) --- */
.reroll-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}


/* --- Generic utility --- */
.hidden {
  display: none;
}


/* --- Filter screen: question groups and option pills --- */
.filter-group {
  margin-bottom: 1.5rem;
  text-align: left;
}

.filter-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.option-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.option-btn {
  flex: 1 1 auto;
  min-width: 4rem;
  min-height: 44px;          /* tap-friendly on phones */
  padding: 0.5rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  background-color: var(--pill-bg);
  border: 1.5px solid transparent;
  border-radius: 999px;       /* fully rounded "pill" */
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.option-btn:hover {
  background-color: var(--pill-bg-hover);
}

.option-btn.selected {
  background-color: var(--mrt-green);
  color: #ffffff;
  border-color: var(--mrt-green);
}

.option-btn:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}


/* --- Verdict screen ---
   The dish name is the visual hero — large warm Fraunces in
   terracotta. The framing phrase above is small, italic, muted.
   min-height on both keeps the layout from jumping when either
   is briefly empty during the shuffle. */
.verdict-phrase {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  min-height: 1.5rem;
}

.verdict-name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 2rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--terracotta-deep);
  margin: 0.25rem 0 1.75rem;
  min-height: 2.5rem;
}


/* --- Landing-screen confirmation toast ---
   Shown briefly after the user taps "We ate this!" on the verdict
   screen. JS unhides it, then adds .fading to trigger the opacity
   transition, then re-hides it once the fade completes. */
.ate-toast {
  font-size: 0.9375rem;
  color: var(--green);
  background-color: var(--green-tint);
  border: 1px solid rgba(27, 94, 63, 0.18);
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  margin-bottom: 1.25rem;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.ate-toast.fading {
  opacity: 0;
}


/* --- Footer easter egg ---
   Fixed to the bottom of the viewport so it persists across
   every screen. The OUTER container keeps pointer-events: none
   so it never accidentally blocks taps near the bottom of the
   card. The INNER span re-enables pointer-events on just the
   text so it can be the tap target for the capyjonny easter egg
   (five taps within 3 seconds — see app.js). user-select: none
   stops a flurry of rapid taps from selecting the text. */
.app-footer {
  position: fixed;
  bottom: 0.6rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  opacity: 0.65;
  pointer-events: none;
  white-space: nowrap;
}
.app-footer-text {
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  /* No cursor: pointer — the easter egg is intentionally hidden,
     so we don't want a tappable-affordance cue on hover. */
}


/* --- Capyjonny first-time speech bubble (FOOD-DECIDER ONLY) ---
   This bubble is the "origin marker" for the capyjonny signature
   — it appears only on the first ever capybara summon on a device.
   It is intentionally NOT part of the portable signature pattern;
   future projects will use the silent nametag-only capybara and
   should NOT carry this CSS block over. If porting capyjonny.js
   to another project, leave everything in this block behind.

   The bubble is appended as a child of .capyjonny-container via
   the Capyjonny.summon({ extra }) hook, so it inherits the
   container's slide-in motion and drift-out fade for free.

   Timing coupling: the bubble's fade-in is delayed until the
   capybara has finished its amble AND paused for 500ms to
   "look around" — so the capybara settles first, takes a beat,
   then decides to say something. The 3300ms delay below =
   ENTER_MS (2800ms) in capyjonny.js + the 500ms settle pause.
   If ENTER_MS changes there, update this delay to match. */
.capy-speech-bubble {
  position: absolute;
  left: 100%;
  /* `top` is tuned so the bubble's tail points at the capybara's
     head in the side-profile pixel-art pose. The SVG (24×14
     viewBox, 240×140 rendered on desktop) starts just below the
     ~28px-tall nametag, and the head pixels occupy roughly
     container y=38-88 on desktop. top: 48px puts the bubble's
     vertical centre at y=64, near the middle of the head/snout. */
  top: 48px;
  margin-left: 14px;
  padding: 8px 12px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(42, 31, 24, 0.10);
  pointer-events: none;
  opacity: 0;
  animation: capy-bubble-fade-in 400ms ease-out 3300ms forwards;
}
@keyframes capy-bubble-fade-in {
  to { opacity: 1; }
}
@media (max-width: 480px) {
  /* Mobile shrinks the SVG (180px wide → ~105px tall), so the
     head sits proportionally higher within the container. Pull
     the bubble up so its tail still points at the head. */
  .capy-speech-bubble {
    top: 38px;
  }
}
@media (prefers-reduced-motion: reduce) {
  /* Reduced-motion users get the bubble visible from the moment
     the capybara fades in — no delayed reveal flourish. */
  .capy-speech-bubble {
    animation: none;
    opacity: 1;
  }
}
/* Tail pointing left from the bubble toward the capybara. Two
   triangles stacked: the back one (::after) acts as the border
   outline; the front one (::before) is the matching fill. */
.capy-speech-bubble::before {
  content: '';
  position: absolute;
  left: -7px;
  top: 50%;
  width: 0;
  height: 0;
  transform: translateY(-50%);
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-right: 7px solid var(--card);
}
.capy-speech-bubble::after {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  width: 0;
  height: 0;
  transform: translateY(-50%);
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 8px solid var(--border);
  z-index: -1;
}


/* --- Kopi cup peeking from behind the card ---
   Inline SVG positioned absolute inside .card-stack, extending above
   and to the right of the card. z-index 0 keeps it BEHIND the card
   (which is z-index 1), so the card naturally overlaps the cup's
   left side. Offsets are tuned so the iconic THICK green stripe sits
   just above the card's top edge — that stripe is the most recognisable
   feature of a Singapore kopitiam cup, so it must be visible.
   Persists across every screen — atmospheric continuity. */
.kopi-cup {
  position: absolute;
  top: -45px;
  right: -55px;
  width: 100px;
  height: auto;
  z-index: 0;
  pointer-events: none;
  /* A small drop shadow grounds the cup as a 3D object on the table. */
  filter: drop-shadow(0 3px 6px rgba(42, 31, 24, 0.18));
}

/* On small phones the cup scales down and pulls in closer to the card
   so it doesn't get clipped too aggressively by the viewport edge. */
@media (max-width: 480px) {
  .kopi-cup {
    width: 72px;
    top: -32px;
    right: -32px;
  }
}


/* --- Small phones --- */
@media (max-width: 360px) {
  h1 { font-size: 1.875rem; }
  .screen-title { font-size: 1.375rem; }
  .verdict-name { font-size: 1.625rem; }
  .container { padding: 1.5rem 1.25rem; }
}
