/* =====================================================================
   Coffee Discovery — Quiz + Results Styles — Fog Theme
   ===================================================================== */

:root {
  /* ── Surface & Ink ──────────────────────────────────────────── */
  --bg:            #F3F5F2;
  --surface:       #FAFBF9;
  --surface-2:     #FAFBF9;
  --surface-sunk:  #EAEDE8;
  --border:        rgba(30, 33, 30, 0.10);
  --border-strong: rgba(30, 33, 30, 0.18);
  --text:          #1E221E;
  --text-muted:    #7A8878;
  --text-subtle:   #9EAA9A;

  /* ── Brand ──────────────────────────────────────────────────── */
  --accent:        #4E7055;
  --accent-hover:  #3D5C44;
  --accent-soft:   #E0EBE1;
  --accent-ink:    #2A4A30;

  /* ── Flavor colors (SCA quiz tile palette — desaturated Fog) ─── */
  --c-fruity:    #C2877A;
  --c-rich:      #C4A97A;
  --c-clean:     #6EA882;
  --c-clean-rich:#D4C475;
  --c-fermented: #A8B870;
  --c-earthy:    #8A6A50;

  /* ── Elevation ──────────────────────────────────────────────── */
  --shadow-1: 0 1px 2px rgba(30,33,30,0.04), 0 1px 1px rgba(30,33,30,0.03);
  --shadow-2: 0 2px 6px rgba(30,33,30,0.06), 0 1px 2px rgba(30,33,30,0.04);
  --shadow-3: 0 8px 24px rgba(30,33,30,0.10), 0 2px 6px rgba(30,33,30,0.05);
  --ring:     0 0 0 3px rgba(78, 112, 85, 0.22);

  /* ── Typography — families ──────────────────────────────────── */
  --font:         'Jost', system-ui, -apple-system, sans-serif;
  --font-display: 'Cormorant Garamond', Georgia, serif;

  /* ── Typography — size scale (px) ───────────────────────────── */
  --fs-micro: 11px;  /* overline, match badge, avatar initials   */
  --fs-xs:    12px;  /* captions, meta, secondary labels, chips  */
  --fs-sm:    13px;  /* secondary body, ghost buttons, bean text */
  --fs-base:  15px;  /* primary body, bean roaster               */
  --fs-md:    17px;  /* emphasis, choice tile label              */
  --fs-lg:    22px;  /* subheadings                              */
  --fs-xl:    28px;  /* h2 / display                             */

  /* ── Typography — line heights ──────────────────────────────── */
  --lh-tight: 1.15;
  --lh-snug:  1.35;
  --lh-base:  1.55;
  --lh-loose: 1.7;

  /* ── Spacing — 4-pt scale ───────────────────────────────────── */
  --s-1:  4px;
  --s-2:  8px;
  --s-3:  12px;
  --s-4:  16px;
  --s-5:  20px;
  --s-6:  24px;
  --s-8:  32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;

  /* ── Radius ─────────────────────────────────────────────────── */
  --r-1:   4px;    /* swatch, thumbnail, tight controls          */
  --r-2:   8px;    /* tooltip, ghost button                      */
  --r-3:   12px;   /* cards                                      */
  --r-4:   16px;   /* prominent cards                            */
  --r-5:   20px;   /* choice tile (legacy quiz roundness)        */
  --r-pill:999px;

  /* ── Motion ─────────────────────────────────────────────────── */
  --dur-1: 120ms;  /* micro: press feedback, icon shifts         */
  --dur-2: 180ms;  /* standard: color, border, opacity           */
  --dur-3: 280ms;  /* relaxed: expand/collapse, swatch swap      */
  --dur-4: 420ms;  /* deliberate: screen transitions             */
  --ease-out:      cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out:   cubic-bezier(0.4, 0, 0.2, 1);
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── Screen shells ─────────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  /* 0.35s sits between dur-3 and dur-4 — intentional screen-transition pacing */
  transition: opacity 0.35s var(--ease-in-out), transform 0.35s var(--ease-in-out);
}
.screen.hidden { opacity: 0; pointer-events: none; }
.screen.active  { opacity: 1; pointer-events: all; }

.screen-results.hidden { transform: translateY(var(--s-6)); }
.screen-results.active  { transform: translateY(0); }


/* ══════════════════════════════════════════════════════════════════════
   QUIZ SCREEN
   ══════════════════════════════════════════════════════════════════════ */

.screen-quiz { background: var(--bg); overflow: hidden; }

/* ── Quiz header ──────────────────────────────────────────────────── */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-6) var(--s-8) 0;
  position: relative;
  z-index: 2;
}

/* ── Quiz main ──────────────────────────────────────────────────── */
.quiz-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s-8) var(--s-6);
  gap: var(--s-10);
  position: relative;
  z-index: 2;
}

.question-wrap {
  width: 100%;
  max-width: 640px;
  position: relative;
}

/* ── Question ───────────────────────────────────────────────────── */
.question {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-10);
}
.question.hidden { display: none; }

.question.entering        { animation: slideInRight 0.32s var(--ease-out)    both; }
.question.exiting         { animation: slideOutLeft 0.24s var(--ease-in-out) both; }
.question.entering-from-right { animation: slideInLeft  0.32s var(--ease-out)    both; }
.question.exiting-to-right    { animation: slideOutRight 0.24s var(--ease-in-out) both; }

@keyframes slideInRight  { from { opacity: 0; transform: translateX(48px);  } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOutLeft  { from { opacity: 1; transform: translateX(0);     } to { opacity: 0; transform: translateX(-48px); } }
@keyframes slideInLeft   { from { opacity: 0; transform: translateX(-48px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOutRight { from { opacity: 1; transform: translateX(0);     } to { opacity: 0; transform: translateX(48px); } }

.question-eyebrow {
  font-family: var(--font-display);
  /* clamp: min=fs-lg, preferred=fluid, max=fs-xl — not expressible as a single token */
  font-size: clamp(var(--fs-lg), 4.5vw, var(--fs-xl));
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.02em;
  text-align: center;
  line-height: var(--lh-snug);
}

/* ── Choice buttons — Fog: flat tile with bottom border ─────────── */
.btn-group {
  display: flex;
  gap: var(--s-6);
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
}

.choice-btn {
  --btn-color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-8) var(--s-6);
  min-width: 190px;
  max-width: 220px;
  flex: 1;
  background: color-mix(in srgb, var(--btn-color) 9%, var(--surface));
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  cursor: pointer;
  transition:
    border-color var(--dur-2) var(--ease-out),
    background   var(--dur-2) var(--ease-out);
  text-align: center;
  font-family: var(--font);
  position: relative;
  overflow: hidden;
}
.choice-btn::before { display: none; }
.choice-btn:hover   { border-bottom-color: var(--btn-color); }
.choice-btn:active  { opacity: 0.85; }

/* Color theming via data-color attribute */
.choice-btn[data-color="fruity"]     { --btn-color: var(--c-fruity); }
.choice-btn[data-color="rich"]       { --btn-color: var(--c-rich); }
.choice-btn[data-color="clean"]      { --btn-color: var(--c-clean); }
.choice-btn[data-color="fermented"]  { --btn-color: var(--c-fermented); }
.choice-btn[data-color="clean-rich"] { --btn-color: var(--c-clean-rich); }
.choice-btn[data-color="earthy"]     { --btn-color: var(--c-earthy); }

.choice-btn.selected {
  border-bottom-color: var(--btn-color);
  background: color-mix(in srgb, var(--btn-color) 12%, var(--surface));
}

.btn-icon  { font-size: var(--fs-xl); line-height: 1; }
.btn-label { font-size: var(--fs-md);  font-weight: 500; color: var(--text); letter-spacing: -0.01em; }
.btn-sub   { font-size: var(--fs-xs);  font-weight: 300; color: var(--text-muted); letter-spacing: 0.01em; }

/* ── Quiz footer ─────────────────────────────────────────────────── */
.quiz-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--s-10);
  width: 100%;
  max-width: 640px;
}

/* Ghost buttons — back, restart, shortcut share the same base style */
.back-btn,
.flavor-shortcut-btn,
.restart-btn {
  background: none;
  border: none;
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-1);
  transition: color var(--dur-1), background var(--dur-1);
  white-space: nowrap;
}
.back-btn:hover,
.restart-btn:hover { color: var(--text); background: rgba(30,33,30,0.05); }

.flavor-shortcut-btn { margin-left: auto; }
.flavor-shortcut-btn:hover { color: var(--text); background: rgba(30,33,30,0.05); }

.back-btn.hidden { visibility: hidden; pointer-events: none; }

/* Empty / quirky bean list states */
.bean-list-empty,
.bean-quirky-callout {
  list-style: none;
  padding: var(--s-8) var(--s-4);
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: var(--lh-base);
}
.bean-quirky-callout { font-style: italic; }

/* ── Reveal overlay ─────────────────────────────────────────────── */
.reveal-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg);
  pointer-events: none;
  opacity: 0;
  z-index: 10;
  transition: opacity var(--dur-2) ease;
}
.reveal-overlay.active { opacity: 1; pointer-events: all; }


/* ══════════════════════════════════════════════════════════════════════
   RESULTS SCREEN
   ══════════════════════════════════════════════════════════════════════ */

.screen-results { background: var(--bg); overflow: hidden; }

/* ── Results header ───────────────────────────────────────────── */
.results-header {
  display: flex;
  align-items: center;
  column-gap: var(--s-4);
  row-gap: 0;
  padding: var(--s-4) var(--s-6);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.results-meta {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.results-meta-label { font-size: var(--fs-xs); color: var(--text-muted); }

.results-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: var(--s-1) var(--s-3);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: #fff;
}

.results-wheel-link {
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-1);
  transition: color var(--dur-1), background var(--dur-1);
}
.results-wheel-link:hover { color: var(--text); background: rgba(30,33,30,0.05); }

.chain-sep { font-size: var(--fs-xs); color: var(--text-muted); flex-shrink: 0; }

/* ── Results body ─────────────────────────────────────────────── */
.results-body { flex: 1; display: flex; overflow: hidden; }

/* ── Wheel panel ──────────────────────────────────────────────── */
.results-wheel-panel {
  flex: 0 0 66.667%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s-6);
  border-right: 1px solid var(--border);
  background: var(--bg);
  overflow: hidden;
  gap: var(--s-2);
}

#discover-wheel-container { flex-shrink: 0; }
#discover-wheel-container svg { width: 100%; height: 100%; overflow: visible; }

/* ── Bean list panel ──────────────────────────────────────────── */
.results-list-panel {
  flex: 0 0 33.333%;
  overflow-y: auto;
  padding: var(--s-3);
  background: var(--bg);
}

/* ── Bean list ────────────────────────────────────────────────── */
.bean-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

/* ── Bean card ────────────────────────────────────────────────── */
.bean-card {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: var(--s-3);
  cursor: pointer;
  transition: background var(--dur-1);
  position: relative;
}
.bean-card:hover   { background: rgba(30,33,30,0.025); }
.bean-card.selected { box-shadow: inset 2px 0 0 var(--accent); background: transparent; }

/* Match badge — ::before for backward compat with JS-rendered HTML */
.bean-card[data-match]::before {
  display: block;
  font-size: var(--fs-micro);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: var(--s-1);
  text-align: right;
}
.bean-card[data-match="direct"]::before   { content: 'Best match'; color: var(--accent); }
.bean-card[data-match="indirect"]::before { content: 'Similar';    color: var(--text-muted); }
.bean-card[data-match="loose"]::before    { content: 'Maybe';      color: var(--text-subtle); }

/* Main row */
.bean-row { display: flex; align-items: flex-start; gap: var(--s-3); }

.bean-avatar {
  width: var(--s-10);
  height: var(--s-10);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: var(--fs-micro);
  font-weight: 700;
  color: var(--surface-2);
  letter-spacing: 0.02em;
  overflow: hidden;
}
.bean-avatar img { width: 100%; height: 100%; object-fit: cover; }

.bean-info { flex: 1; min-width: 0; }

.bean-roaster {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text);
  line-height: var(--lh-snug);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bean-name {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: var(--s-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bean-origin {
  font-size: var(--fs-micro);
  color: var(--text-subtle);
  margin-top: var(--s-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bean-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--s-1);
  flex-shrink: 0;
}
.bean-price {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.bean-thumb {
  width: var(--s-12);
  height: var(--s-12);
  border-radius: var(--r-1);
  overflow: hidden;
  flex-shrink: 0;
}
.bean-thumb img { width: 100%; height: 100%; object-fit: cover; }
.bean-thumb-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--surface-sunk) 0%, #D4D9D0 100%);
}

/* Notes row */
.bean-notes-row {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  flex-wrap: nowrap;
  overflow: hidden;
  margin-top: var(--s-3);
}
.note-more {
  font-size: var(--fs-micro);
  color: var(--text-muted);
  opacity: 0.7;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Note chips */
.note-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  font-size: var(--fs-xs);
  font-weight: 300;
  color: var(--text-muted);
}
.note-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.note-chip--fuzzy { border-bottom: 1px dashed var(--text-subtle); cursor: help; }
.note-chip--overflow { display: none; }

.bean-card.selected .bean-notes-row  { flex-wrap: wrap; overflow: visible; }
.bean-card.selected .note-chip--overflow { display: inline-flex; }
.bean-card.selected .note-more       { display: none; }

/* Expanded detail */
.bean-detail {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition:
    max-height var(--dur-3) var(--ease-out),
    opacity    var(--dur-3) ease,
    margin-top var(--dur-3);
}
.bean-card.selected .bean-detail {
  max-height: 400px;
  opacity: 1;
  margin-top: var(--s-3);
}

.bean-detail-inner {
  padding-top: var(--s-3);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}
.bean-meta-row { display: flex; gap: var(--s-4); flex-wrap: wrap; }
.bean-meta-item { font-size: var(--fs-xs); color: var(--text-muted); }
.bean-meta-item strong { color: var(--text); font-weight: 500; }

.bean-description {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  line-height: var(--lh-base);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.bean-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  margin-top: var(--s-1);
  transition: gap var(--dur-1);
}
.bean-cta:hover { gap: var(--s-2); }
.bean-cta-unavailable { color: var(--text-muted); font-weight: 400; cursor: default; }


#discover-wheel-container [role="button"]:focus { outline: none; }

/* ── Wheel arc labels ────────────────────────────────────────────── */
.arc-label {
  pointer-events: none;
  user-select: none;
  dominant-baseline: middle;
  text-anchor: middle;
}
.arc-label-inner { letter-spacing: 0.06em; text-transform: uppercase; }
.arc-label-mid   { letter-spacing: 0.01em; }
.arc-label-leaf  { letter-spacing: 0.01em; }


/* ══════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════════ */

@media (max-width: 680px) {
  /* Quiz */
  .btn-group  { flex-direction: column; align-items: center; gap: 0; }
  .choice-btn {
    max-width: 320px; width: 100%;
    flex-direction: row; text-align: left; gap: var(--s-4);
    border-bottom: none; border-left: 2px solid transparent;
  }
  .choice-btn:hover   { border-left-color: var(--btn-color); border-bottom-color: transparent; }
  .choice-btn.selected { border-left-color: var(--btn-color); border-bottom-color: transparent; }
  .btn-icon { font-size: var(--fs-lg); }

  /* Results — stack vertically */
  .results-body { flex-direction: column; overflow: hidden; }
  .results-wheel-panel {
    flex-shrink: 0; flex-basis: auto;
    width: 100%; aspect-ratio: 1 / 1;
    padding: 0; border-right: none; border-bottom: 1px solid var(--border);
  }
  #discover-wheel-container { width: 100%; height: 100%; max-width: none; }
  .results-list-panel { flex: 1; min-height: 0; overflow-y: auto; }
  .results-header { padding: var(--s-3) var(--s-4); }
  .results-wheel-link { display: none; }
}


/* ── Wheel tooltip ──────────────────────────────────────────────────── */
.wheel-tooltip {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  padding: var(--s-2) var(--s-3);
  box-shadow: var(--shadow-3);
  opacity: 0;
  transition: opacity var(--dur-1) ease;
  max-width: 220px;
}
.wheel-tooltip.visible { opacity: 1; }
.wheel-tooltip .tooltip-name {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.wheel-tooltip .tooltip-path {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: var(--s-1);
}

/* ══════════════════════════════════════════════════════════════════════
   REDUCED MOTION
   ══════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
