/* ===================================================================
   MAPLE SOCIAL CLUB — VINO & VINYL
   Light · editorial · hard-edged tasting app
   =================================================================== */
:root {
  --paper: #F1EAE1;         /* warm bone ground */
  --paper-2: #E8DFD2;       /* deeper bone panel */
  --panel: #ECE4D8;
  --ink: #17130E;           /* warm near-black */
  --ink-soft: #4C453B;
  --muted: #8E867A;         /* warm taupe */
  --pink: #F23C97;          /* maple pink — the accent */
  --red: #E01420;           /* maple red  */
  --line: rgba(23,19,14,.20);
  --line-2: rgba(23,19,14,.34);
  --good: #1F8A5B;
  --bad: #E01420;
  --r: 0px;                 /* hard edges */
  --font: "Helvetica Neue", Helvetica, Arial, "Segoe UI", sans-serif;
  --script: "Snell Roundhand", "Segoe Script", "Bradley Hand", "Brush Script MT", cursive;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: var(--paper); }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* backdrops ------------------------------------------------------- */
.grid-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(23,19,14,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23,19,14,.045) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: radial-gradient(95% 80% at 50% 20%, #000 0%, transparent 90%);
}
.noise { display: none; }

/* screens --------------------------------------------------------- */
#app { position: relative; z-index: 1; min-height: 100dvh; }
.screen {
  display: none;
  min-height: 100dvh;
  padding: max(24px, env(safe-area-inset-top)) 22px calc(26px + env(safe-area-inset-bottom));
  max-width: 660px; margin: 0 auto;
  animation: screenIn 0.45s cubic-bezier(.2,.7,.2,1);
}
.screen[data-active] { display: flex; flex-direction: column; }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* shared type ----------------------------------------------------- */
.eyebrow {
  font-size: 11px; letter-spacing: .28em; text-transform: uppercase;
  font-weight: 600; color: var(--ink);
}
.eyebrow.small { letter-spacing: .2em; font-size: 10px; color: var(--muted); }
.brand-script {
  font-family: var(--script); color: var(--pink); font-weight: 700;
  -webkit-text-stroke: 2px var(--red);
  font-size: clamp(52px, 15vw, 96px); line-height: .7;
}
/* real Maple Social Club wordmark (ink on bone) */
.brand-logo { display: block; width: clamp(210px, 66vw, 300px); height: auto; }
.hub-logo { width: clamp(150px, 44vw, 190px); margin-bottom: 6px; }
.wordmark {
  font-family: var(--font); font-weight: 800; text-transform: uppercase;
  font-size: clamp(34px, 11vw, 74px); letter-spacing: -.03em; line-height: .9;
  margin: 6px 0 4px; color: var(--ink); text-wrap: balance;
}

/* editorial corner meta (enter hero) ------------------------------ */
.hero-meta { position: absolute; left: 22px; right: 22px; display: flex; justify-content: space-between; }
.hero-meta.top { top: max(22px, env(safe-area-inset-top)); }
.hero-meta.bottom { bottom: calc(24px + env(safe-area-inset-bottom)); }
.hero-meta .meta { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; font-weight: 600; color: var(--muted); }
.hero-meta .meta b { color: var(--ink); }

/* ENTER ----------------------------------------------------------- */
#screen-enter { justify-content: center; align-items: center; text-align: center; position: relative; }
.enter-wrap { width: 100%; max-width: 400px; display: flex; flex-direction: column; align-items: center; }
.enter-wrap .brand-script { margin-bottom: 2px; }
.enter-lede { color: var(--ink-soft); font-size: 14.5px; line-height: 1.5; margin: 10px 0 30px; max-width: 320px; }
.field-stack { display: flex; flex-direction: column; gap: 14px; text-align: left; width: 100%; }
.field span { display: block; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 7px; font-weight: 600; }
.field span em { color: var(--ink-soft); font-style: normal; }
.field input {
  width: 100%; padding: 15px 16px; border-radius: 0;
  background: transparent; border: 1px solid var(--line-2); color: var(--ink);
  font-size: 16px; font-family: var(--font); outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.field input::placeholder { color: var(--muted); }
.field input:focus { border-color: var(--pink); box-shadow: inset 0 0 0 1px var(--pink); }
.ig-input { position: relative; display: flex; align-items: center; }
.ig-input i { position: absolute; left: 16px; font-style: normal; color: var(--muted); font-size: 16px; pointer-events: none; }
.ig-input input { padding-left: 32px; }
.form-error { color: var(--red); font-size: 12.5px; margin: 2px 2px 0; font-weight: 600; }

/* buttons --------------------------------------------------------- */
.btn {
  position: relative; border: none; cursor: pointer; font-family: var(--font);
  font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--paper); background: var(--ink);
  padding: 16px 20px; border-radius: 0; overflow: hidden;
  transition: transform .1s ease, background .18s, color .18s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--ink); color: var(--paper); margin-top: 4px; }
.btn-primary:active { background: #000; }
.btn-primary span { position: relative; z-index: 1; }
.btn-ghost {
  background: transparent; border: 1px solid var(--line-2); color: var(--ink); font-weight: 600;
}
.btn-ghost:active { background: var(--paper-2); }
.back-btn {
  align-self: flex-start; background: none; border: none; color: var(--muted);
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase; font-weight: 600;
  padding: 2px 0 18px; cursor: pointer; display: flex; align-items: center; gap: 6px;
}
.back-btn span { font-size: 18px; line-height: 1; }

/* HUB ------------------------------------------------------------- */
.hub-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-bottom: 4px; }
.hub-head > div:first-child { min-width: 0; flex: 1; }
.hub-head .brand-script { font-size: clamp(38px, 11vw, 54px); margin-bottom: 2px; -webkit-text-stroke: 1.5px var(--red); }
.hub-title { font-family: var(--font); font-weight: 800; text-transform: uppercase; font-size: clamp(15px, 5vw, 20px); margin: 2px 0 0; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hub-you { text-align: right; flex: none; }
.you-score { font-size: 30px; font-weight: 800; line-height: 1; white-space: nowrap; font-variant-numeric: tabular-nums; }
.you-score b { color: var(--pink); }
.you-score span { font-size: 11px; color: var(--muted); margin-left: 3px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; }
.you-name { font-size: 11px; color: var(--muted); margin-top: 5px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switch-link { background: none; border: none; cursor: pointer; color: var(--pink); font-family: var(--font); font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; padding: 4px 0 0; margin-left: auto; display: block; }
.switch-link:active { opacity: .6; }
.hub-hint { color: var(--muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; margin: 16px 0 14px; border-top: 1px solid var(--line); padding-top: 16px; }

.bottle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bottle-card {
  position: relative; border-radius: 0; overflow: hidden; cursor: pointer;
  background: var(--paper); border: 1px solid var(--line-2); padding: 15px 14px 14px;
  min-height: 212px; display: flex; flex-direction: column; justify-content: space-between;
  transition: transform .12s ease, border-color .2s, background .2s;
}
.bottle-card:active { transform: scale(.985); background: var(--paper-2); }
.bottle-card .num { font-family: var(--font); font-weight: 700; font-size: 12px; color: var(--muted); letter-spacing: .12em; }
.bottle-card .thumb { flex: 1; display: flex; align-items: center; justify-content: center; margin: 4px 0; }
.bottle-card .thumb img { height: 120px; border-radius: 0; transition: transform .35s ease; }
.bottle-card:active .thumb img { transform: translateY(-2px); }
.bottle-card .bc-name { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.bottle-card .bc-grape { font-size: 10px; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: .08em; }
.bottle-card .bc-status {
  position: absolute; top: 12px; right: 12px; font-size: 9px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700;
  padding: 4px 7px; border-radius: 0; background: var(--paper); border: 1px solid var(--line-2); color: var(--muted);
}
.bottle-card.done { border-color: var(--pink); }
.bottle-card.done .bc-status { color: var(--paper); background: var(--pink); border-color: var(--pink); }

.hub-actions { display: flex; gap: 12px; margin-top: 20px; }
.hub-actions .btn { flex: 1; }

/* BOTTLE STAGE ---------------------------------------------------- */
.stage-wrap { position: relative; }
.stage {
  position: relative; width: 100%; height: 48vh; min-height: 330px; max-height: 480px;
  border-radius: 0;
  background: var(--paper);
  border: 1px solid var(--line-2); overflow: hidden;
}
.stage canvas { display: block; width: 100% !important; height: 100% !important; }
.stage-caption {
  text-align: center; margin-top: 10px; font-size: 10px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--muted); font-weight: 600;
}

.bottle-panel { margin-top: 18px; }
.bp-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.bp-name { font-family: var(--font); font-weight: 800; font-size: 24px; letter-spacing: -.02em; text-transform: uppercase; }
.bp-meta { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; text-align: right; }
/* locked / unlocked tasting notes */
.notes-locked { border: 1px solid var(--line-2); padding: 22px 18px; margin: 18px 0 20px; text-align: center; }
.notes-locked .nl-lock { font-size: 22px; color: var(--muted); line-height: 1; margin-bottom: 10px; }
.notes-locked .nl-title { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; font-weight: 700; color: var(--ink); }
.notes-locked .nl-sub { font-size: 13px; color: var(--ink-soft); line-height: 1.5; margin: 8px auto 0; max-width: 36ch; }

.notes-reveal { margin: 18px 0 20px; animation: reveal .5s cubic-bezier(.2,.7,.2,1); }
.nr-head { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); padding-top: 14px; margin-bottom: 4px; }
.nr-head > span:first-child { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; font-weight: 700; color: var(--ink); }
.nr-unlocked { font-size: 9px; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; color: var(--paper); background: var(--pink); padding: 3px 8px; }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.bp-notes { display: flex; flex-wrap: wrap; gap: 7px; margin: 16px 0 20px; }
.note-chip {
  font-size: 11px; padding: 6px 11px; border-radius: 0;
  background: transparent; border: 1px solid var(--line-2); color: var(--ink); letter-spacing: .02em;
}
.bp-prose { display: grid; gap: 11px; margin-bottom: 22px; }
.bp-prose div { font-size: 13px; line-height: 1.5; color: var(--ink-soft); }
.bp-prose div b { color: var(--ink); font-weight: 700; text-transform: uppercase; font-size: 9.5px; letter-spacing: .14em; margin-right: 10px; }

/* trivia ---------------------------------------------------------- */
.trivia { display: none; }
.trivia[data-active] { display: block; animation: screenIn .35s ease; }
.trivia-progress { display: flex; gap: 5px; margin-bottom: 18px; }
.trivia-progress i { flex: 1; height: 3px; border-radius: 0; background: var(--line-2); transition: background .3s; }
.trivia-progress i.on { background: var(--pink); }
.trivia-q { font-size: 19px; font-weight: 700; line-height: 1.3; margin-bottom: 18px; letter-spacing: -.01em; }
.opts { display: grid; gap: 10px; }
.opt {
  text-align: left; padding: 15px 16px; border-radius: 0; cursor: pointer;
  background: transparent; border: 1px solid var(--line-2); color: var(--ink);
  font-size: 15px; font-family: var(--font); transition: all .16s;
  display: flex; align-items: center; gap: 12px;
}
.opt .dot { width: 16px; height: 16px; border-radius: 0; border: 1.5px solid var(--muted); flex: none; transition: all .16s; }
.opt:active { background: var(--paper-2); }
.opt.correct { border-color: var(--good); background: rgba(31,138,91,.08); }
.opt.correct .dot { border-color: var(--good); background: var(--good); }
.opt.wrong { border-color: var(--bad); background: rgba(224,20,32,.06); }
.opt.wrong .dot { border-color: var(--bad); background: var(--bad); }
.opt.disabled { pointer-events: none; opacity: .5; }
.opt.locked { pointer-events: none; }

/* rating ---------------------------------------------------------- */
.rating-block { text-align: center; border-top: 1px solid var(--line); padding-top: 22px; }
.rating-block h3 { font-family: var(--font); font-weight: 800; text-transform: uppercase; font-size: 18px; letter-spacing: -.01em; margin: 0 0 6px; }
.rating-block p { color: var(--muted); font-size: 12px; margin: 0 0 20px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.orbs { display: flex; justify-content: center; gap: 10px; margin-bottom: 22px; }
.orb {
  width: 48px; height: 48px; border-radius: 0; cursor: pointer;
  background: transparent; border: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; color: var(--muted);
  transition: all .14s;
}
.orb.on { background: var(--pink); color: var(--paper); border-color: var(--pink); }
.finish-note { text-align: center; color: var(--pink); font-size: 12px; margin-top: 14px; min-height: 18px; text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }

/* LEADERBOARD ----------------------------------------------------- */
.section-title { font-family: var(--font); font-weight: 800; text-transform: uppercase; font-size: 28px; letter-spacing: -.02em; margin: 0 0 20px; }
.lb-list { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.lb-row {
  display: flex; align-items: center; gap: 14px; padding: 13px 15px; border-radius: 0;
  background: transparent; border: 1px solid var(--line-2);
}
.lb-row.you { border-color: var(--pink); background: rgba(242,60,151,.06); }
.lb-rank { font-family: var(--font); font-weight: 800; font-size: 18px; width: 30px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-row.top1 .lb-rank, .lb-row.top2 .lb-rank, .lb-row.top3 .lb-rank { color: var(--pink); }
.lb-main { flex: 1; min-width: 0; }
.lb-name { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-ig { font-size: 11px; color: var(--muted); }
.lb-score { text-align: right; }
.lb-score b { font-size: 18px; color: var(--pink); font-variant-numeric: tabular-nums; }
.lb-score span { display: block; font-size: 9px; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; font-weight: 600; }
.lb-foot { text-align: center; color: var(--muted); font-size: 10px; margin-top: 16px; letter-spacing: .16em; text-transform: uppercase; font-weight: 600; }
.lb-empty { text-align: center; color: var(--muted); padding: 40px 0; text-transform: uppercase; letter-spacing: .1em; font-size: 12px; font-weight: 600; }

/* RESULTS --------------------------------------------------------- */
.card-preview {
  border-radius: 0; overflow: hidden; border: 1px solid var(--line-2);
  margin-bottom: 20px; background: var(--paper);
}
.card-preview canvas { width: 100%; height: auto; display: block; }
.results-actions { display: flex; gap: 12px; }
.results-actions .btn { flex: 1; }

/* SELECT WINES ---------------------------------------------------- */
.select-head { margin-bottom: 18px; }
.select-head .section-title { margin: 6px 0 0; }
.select-sub { color: var(--ink-soft); font-size: 13.5px; line-height: 1.5; margin: 10px 0 0; }
.select-sub b { color: var(--ink); }
.select-grid { display: flex; flex-direction: column; gap: 9px; flex: 1; }
.select-card {
  position: relative; display: flex; align-items: center; gap: 14px;
  padding: 12px 44px 12px 12px; border: 1px solid var(--line-2); cursor: pointer;
  background: transparent; transition: border-color .16s, background .16s;
}
.select-card:active { background: var(--paper-2); }
.select-card.on { border-color: var(--pink); background: rgba(242,60,151,.05); }
.sc-check {
  position: absolute; top: 50%; right: 12px; transform: translateY(-50%);
  width: 22px; height: 22px; border: 1px solid var(--line-2);
  display: grid; place-items: center; font-size: 12px; color: transparent;
}
.select-card.on .sc-check { background: var(--pink); border-color: var(--pink); color: var(--paper); }
.sc-thumb { width: 60px; flex: none; display: grid; place-items: center; }
.sc-thumb img { width: 60px; height: auto; display: block; }
.sc-info { min-width: 0; }
.sc-name { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.sc-grape { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-top: 3px; }
.select-foot { position: sticky; bottom: 0; padding: 14px 0 calc(2px + env(safe-area-inset-bottom)); margin-top: 12px; display: flex; flex-direction: column; gap: 10px; background: linear-gradient(transparent, var(--paper) 34%); }
.select-count { text-align: center; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; font-weight: 700; color: var(--muted); }
.select-foot .btn { width: 100%; }
.btn:disabled { opacity: .4; cursor: default; }
.btn:disabled:active { transform: none; }

/* toast ----------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); border: 1px solid var(--ink); color: var(--paper);
  padding: 12px 20px; border-radius: 0; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  z-index: 50; animation: toastIn .28s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }

/* utility --------------------------------------------------------- */
.spin-mini { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .screen, .trivia[data-active], .toast, .notes-reveal { animation: none; }
  .spin-mini { animation: none; }
}
