/* Premium, modern-minimal design system for the customer-facing flow.
   Scoped entirely to body.customer-theme so the admin dashboard (which never
   sets this class) and the shared tokens in base.css are unaffected. */

body.customer-theme {
  /* Background layers */
  --bg-base: #faf9f6;             /* Clean satin cream background */
  --bg-elevated: #f4f4f5;         /* Zinc-100 clean gray */
  --bg-card: #ffffff;
  --bg-card-hover: #faf8f5;

  /* Text tiers */
  --text-primary: #09090b;        /* Zinc-950 off-black */
  --text-secondary: #3f3f46;      /* Zinc-700 gray */
  --text-muted: #71717a;          /* Zinc-500 gray */

  /* Accent */
  --accent: #c69b6d;              /* Bronze/gold accent */
  --accent-hover: #b08558;
  --accent-muted: rgba(198, 155, 109, 0.15);
  --accent-2: #dfb784;            /* Soft gold secondary */

  /* Semantic */
  --success: #2f9e5f;             /* Warm forest green */
  --error: #d94f43;               /* Warm terracotta red */
  --warning: #e8a13c;             /* Warm amber */

  /* Borders */
  --border-subtle: #e4e4e7;        /* Zinc-200 */
  --border-strong: #d4d4d8;        /* Zinc-300 */

  /* Taste radar (distinct gold data-viz palette matching premium aesthetics) */
  --radar-fill: rgba(198, 155, 109, 0.25);
  --radar-stroke: #c69b6d;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;

  /* Radius */
  --radius-sm: 8px;               /* HeroUI rounded-lg */
  --radius-md: 12px;              /* HeroUI rounded-xl */
  --radius-lg: 16px;              /* HeroUI rounded-2xl */

  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
}

/* Header */
body.customer-theme .site-header {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
}
body.customer-theme .site-header .brand {
  color: var(--text-primary);
}

/* Typography */
body.customer-theme h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 var(--space-3); }
body.customer-theme h2 { font-size: 1.25rem; font-weight: 600; margin: var(--space-6) 0 var(--space-3); }
body.customer-theme h3 { font-size: 1.05rem; font-weight: 600; color: var(--text-secondary); margin: var(--space-5) 0 var(--space-2); }
body.customer-theme p, body.customer-theme li { font-size: 0.95rem; line-height: 1.55; color: var(--text-secondary); }
body.customer-theme a { color: var(--accent); }
body.customer-theme .meta, body.customer-theme small { font-size: 0.8rem; color: var(--text-muted); }

/* Flash messages */
body.customer-theme .flash-error { background: #f8717122; color: var(--error); }
body.customer-theme .flash-success { background: #4ade8022; color: var(--success); }
body.customer-theme .flash-info { background: var(--accent-muted); color: var(--accent); }

/* Forms */
body.customer-theme label { color: var(--text-secondary); font-weight: 500; }
body.customer-theme input, body.customer-theme select, body.customer-theme textarea {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
}
body.customer-theme input:focus, body.customer-theme select:focus, body.customer-theme textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

/* Flavor-note checkbox list (WTForms ListWidget renders <ul id="flavor_note_ids">) */
body.customer-theme ul#flavor_note_ids {
  list-style: none;
  margin: 0 0 var(--space-4);
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
body.customer-theme ul#flavor_note_ids li {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}
body.customer-theme ul#flavor_note_ids input[type="checkbox"] { accent-color: var(--accent); margin: 0; }

/* Buttons */
body.customer-theme .btn,
body.customer-theme button {
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.7rem 1.2rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
body.customer-theme .btn:hover, body.customer-theme button:hover { 
  background: var(--accent-hover); 
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(198, 155, 109, 0.2);
}
body.customer-theme .btn:active, body.customer-theme button:active {
  transform: scale(0.97);
}
body.customer-theme .btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 2px solid var(--border-strong);
}
body.customer-theme .btn-secondary:hover { 
  background: var(--bg-card-hover); 
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
body.customer-theme .btn-secondary:active {
  transform: scale(0.97);
}

/* Cards */
body.customer-theme .card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  box-shadow: 0 4px 12px rgba(30, 27, 24, 0.03);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, border-color 0.25s ease;
}
body.customer-theme .card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(30, 27, 24, 0.06);
  border-color: var(--accent);
}

/* Tables */
body.customer-theme table {
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  width: 100%;
}
body.customer-theme th, body.customer-theme td {
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.65rem 0.9rem;
  color: var(--text-primary);
  text-align: left;
}
body.customer-theme th { color: var(--text-secondary); font-weight: 500; width: 40%; background: var(--bg-elevated); }
body.customer-theme tr:last-child td, body.customer-theme tr:last-child th { border-bottom: none; }

/* Sample grid / pins */
body.customer-theme .sample-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
}
body.customer-theme .sample-pin {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-align: center;
  text-decoration: none;
  color: var(--text-primary);
  display: block;
  transition: border-color 0.15s ease, transform 0.1s ease;
}
body.customer-theme .sample-pin:hover { border-color: var(--border-strong); transform: translateY(-2px); }

/* Status badges */
body.customer-theme .badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: var(--space-2);
}
body.customer-theme .badge-not_started { background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border-subtle); }
body.customer-theme .badge-recipe_viewed { background: var(--accent-muted); color: var(--accent); }
body.customer-theme .badge-completed { background: rgba(47, 158, 95, 0.13); color: var(--success); }

/* Trophies / rewards */
body.customer-theme .trophy-grid, body.customer-theme .reward-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: flex-start;
}
body.customer-theme .hexagon {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}
body.customer-theme .hexagon.earned {
  background: linear-gradient(160deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #1c1109;
  font-weight: 700;
  box-shadow: 0 0 18px 2px var(--accent-muted);
  border: none;
}
body.customer-theme .hexagon.locked {
  background: var(--bg-elevated);
  color: var(--text-muted);
  opacity: 0.55;
}

/* Pre-reveal: quiet, desaturated, mysterious */
body.customer-theme.theme-pre-reveal {
  --accent: #8e8d8a;
  --accent-hover: #a3a29f;
  --accent-muted: rgba(142, 141, 138, 0.15);
}

/* Post-reveal: warm payoff without leaving the dark base */
body.customer-theme.theme-post-reveal {
  --accent: #a26c48;
  --accent-2: #c49b5a;
}

body.customer-theme .reveal-stage {
  position: relative;
  text-align: center;
  padding-top: var(--space-6);
}
body.customer-theme .reveal-stage::before {
  content: "";
  position: absolute;
  inset: -40px -20px auto -20px;
  height: 320px;
  background: radial-gradient(ellipse at 50% 0%, var(--accent-2) 0%, transparent 70%);
  opacity: 0.18;
  filter: blur(20px);
  z-index: 0;
  pointer-events: none;
}
body.customer-theme .reveal-stage h1,
body.customer-theme .reveal-stage h2,
body.customer-theme .reveal-stage .card { position: relative; z-index: 1; text-align: left; }
body.customer-theme .reveal-stage h1,
body.customer-theme .reveal-stage h2 { text-align: center; }

/* Reveal entrance animation */
body.customer-theme .reveal-stage .card,
body.customer-theme .reveal-stage h2 {
  opacity: 0;
  transform: scale(0.96) translateY(8px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
body.customer-theme.reveal-in .reveal-stage .card,
body.customer-theme.reveal-in .reveal-stage h2 {
  opacity: 1;
  transform: none;
}

/* Milestone / trophy unlock flash */
body.customer-theme .milestone-flash {
  background: linear-gradient(135deg, var(--accent-muted), transparent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  margin: var(--space-5) 0;
  animation: milestone-pop 0.5s ease;
  text-align: left;
}
body.customer-theme .milestone-flash h3 { color: var(--accent); margin-top: 0; }
@keyframes milestone-pop {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* Tap-to-reveal cover: dark, quiet, one deliberate action before the payoff */
body.customer-theme #reveal-cover {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  transition: opacity 0.6s ease;
}
body.customer-theme #reveal-cover.lifting { opacity: 0; pointer-events: none; }
body.customer-theme #reveal-cover .cover-code {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.05em;
}

/* Guess match score: the shareable number */
body.customer-theme .match-score { text-align: center; }
body.customer-theme .match-percent {
  font-size: 3rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.1;
}
body.customer-theme .match-caption { color: var(--text-secondary); margin-bottom: var(--space-3); }
body.customer-theme .match-parts { display: flex; gap: var(--space-2); justify-content: center; flex-wrap: wrap; }
body.customer-theme .match-part {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Tap pills: WTForms RadioField renders <ul><li><input><label> - hide the
   radio, style the label as a tappable pill, highlight when checked. */
body.customer-theme .tap-pills ul {
  list-style: none;
  margin: 0 0 var(--space-4);
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
body.customer-theme .tap-pills li { display: block; }
body.customer-theme .tap-pills input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
body.customer-theme .tap-pills label {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-primary);
  transition: border-color 0.15s ease, background 0.15s ease;
}
body.customer-theme .tap-pills input[type="radio"]:checked + label {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--accent);
}
body.customer-theme .rating-pills label { letter-spacing: 0.1em; }

/* Brew-method chips on the recipe screen */
body.customer-theme .method-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
body.customer-theme .method-chip {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 0.9rem;
}
body.customer-theme .method-chip.active {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--accent);
}

/* Feedback wizard: one step per screen (progressive enhancement) */
body.customer-theme .wizard-progress {
  display: flex; align-items: center; gap: 0.4rem; margin-bottom: var(--space-4);
}
body.customer-theme .wizard-progress .dot {
  width: 22px; height: 5px; border-radius: 3px; background: var(--border-subtle);
  transition: background 0.2s ease;
}
body.customer-theme .wizard-progress .dot.done { background: var(--accent-muted); }
body.customer-theme .wizard-progress .dot.active { background: var(--accent); }
body.customer-theme .wizard-count { margin-left: auto; font-size: 0.78rem; color: var(--text-muted); }
body.customer-theme .wizard-count b { color: var(--text-secondary); }
body.customer-theme .wizard-step h2 { margin-top: 0; }
/* Only under JS: show one step at a time */
body.customer-theme .js-wizard .wizard-step { display: none; }
body.customer-theme .js-wizard .wizard-step.is-active {
  display: block; animation: wizard-in 0.25s ease;
}
@keyframes wizard-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
body.customer-theme .wizard-nav {
  display: flex; gap: var(--space-3); margin-top: var(--space-5);
}
body.customer-theme .wizard-nav .btn { flex: 1; text-align: center; padding: 0.85rem; font-size: 1rem; }
body.customer-theme .wizard-nav [data-back] { flex: 0 0 auto; }
body.customer-theme .tap-pills.shake { animation: shake 0.35s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Family-first flavor picker (pure-HTML <details>) */
body.customer-theme .field-hint { font-size: 0.8rem; color: var(--text-muted); margin: 0 0 var(--space-3); }
body.customer-theme .flavor-wheel-picker { margin-bottom: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
body.customer-theme .flavor-family {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}
body.customer-theme .flavor-family > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.6rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}
body.customer-theme .flavor-family > summary::-webkit-details-marker { display: none; }
body.customer-theme .fam-check { display: inline-flex; align-items: center; gap: 0.5rem; margin: 0; cursor: pointer; }
body.customer-theme .fam-check input { margin: 0; accent-color: var(--accent); }
body.customer-theme .fam-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
body.customer-theme .fam-caret { margin-left: auto; font-size: 0.72rem; color: var(--text-muted); }
body.customer-theme .flavor-family[open] .fam-caret { color: var(--accent); }
body.customer-theme .fam-notes {
  display: flex; flex-wrap: wrap; gap: var(--space-2);
  padding: 0 0.9rem 0.8rem;
}
body.customer-theme .note-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: var(--bg-elevated); border: 1px solid var(--border-subtle);
  border-radius: 999px; padding: 0.35rem 0.7rem; font-size: 0.82rem; cursor: pointer;
}
body.customer-theme .note-chip input { margin: 0; accent-color: var(--accent); }

/* Flavor-read card on the reveal */
body.customer-theme .flavor-read { text-align: center; }
body.customer-theme .flavor-read .fr-label { font-size: 0.72rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--text-muted); }
body.customer-theme .flavor-read .fr-level { font-size: 1.3rem; font-weight: 700; color: var(--accent); margin: var(--space-1) 0; }
body.customer-theme .flavor-read.level-3 .fr-level { color: var(--accent-2); }
body.customer-theme .flavor-read .fr-note { color: var(--text-secondary); font-size: 0.9rem; }
body.customer-theme .best-read { font-size: 0.8rem; color: var(--text-secondary); margin-top: var(--space-2); }

/* Login splash: animated logo intro */
body.customer-theme .splash {
  text-align: center;
  padding: var(--space-6) 0 var(--space-4);
}
body.customer-theme .splash-logo {
  width: 96px;
  height: auto;
  color: var(--text-primary);
  animation: splash-in 0.9s ease both;
}
body.customer-theme .splash h1 {
  margin-top: var(--space-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 1.3rem;
  animation: splash-in 0.9s ease 0.25s both;
}
body.customer-theme .splash .tagline {
  color: var(--accent);
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  animation: splash-in 0.9s ease 0.5s both;
}
@keyframes splash-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* Profile header: info left, taste radar top-right */
body.customer-theme .profile-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: var(--space-4);
}
body.customer-theme .radar-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  text-align: center;
}
body.customer-theme .radar-card h3 {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
}
body.customer-theme .radar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}
body.customer-theme .radar-level {
  background: linear-gradient(135deg, var(--radar-stroke), var(--accent-2, var(--accent)));
  color: #14100d;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
}
body.customer-theme .radar-level.is-locked {
  background: var(--bg-elevated);
  color: var(--text-muted);
}

/* ---- Trophy & reward visual themes (admin-picked per definition) ----
   Applied only to EARNED cards; !important wins over the cards' inline
   border/background so a theme is a deliberate override. */
.theme-gold {
  border-color: #d4a017 !important;
  background: linear-gradient(135deg, #fdf6e0, #f7e7b3) !important;
  box-shadow: 0 4px 18px rgba(212, 160, 23, 0.35) !important;
}
.theme-silver {
  border-color: #9aa5b1 !important;
  background: linear-gradient(135deg, #f7f9fb, #dfe5ec) !important;
  box-shadow: 0 4px 18px rgba(154, 165, 177, 0.35) !important;
}
.theme-bronze {
  border-color: #b0713b !important;
  background: linear-gradient(135deg, #faf1e8, #eed3b8) !important;
  box-shadow: 0 4px 18px rgba(176, 113, 59, 0.35) !important;
}
.theme-coffee {
  border-color: #6f4e37 !important;
  background: linear-gradient(135deg, #f4ece5, #e0cfc0) !important;
  box-shadow: 0 4px 18px rgba(111, 78, 55, 0.35) !important;
}
.theme-sunset {
  border-color: #e2694e !important;
  background: linear-gradient(135deg, #fdeee6, #fbd0b9, #f7b0a0) !important;
  box-shadow: 0 4px 18px rgba(226, 105, 78, 0.35) !important;
}
.theme-neon {
  border-color: #22d3ee !important;
  background: linear-gradient(135deg, #ecfeff, #cffafe) !important;
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.55) !important;
}

/* Fresh-reveal celebration: glow + bounce on a strong match score. */
@keyframes match-glow {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(196, 155, 90, 0.4)); }
  50% { filter: drop-shadow(0 0 16px rgba(196, 155, 90, 0.85)); }
}
@keyframes match-bounce {
  0% { transform: scale(0.85); }
  55% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.match-celebrate {
  animation: match-bounce 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.9s backwards,
             match-glow 2.2s ease-in-out 1.6s 3;
}
@media (prefers-reduced-motion: reduce) {
  .match-celebrate { animation: none; }
}
