/* ============================================================
   tokens.css — single source of truth for Baby Match's app pages
   (index / swipe / tournament / duel / ranking).

   Per-page theming is one knob: put accent-pink | accent-gold |
   accent-violet on <html>. Everything else — primary colour,
   ghost/pill tints, body gradient, shadow — derives from --accent*.
   The legal/doc pages (privacy/terms/pricing/delete-account) use a
   separate document style and intentionally do NOT load this file.
   ============================================================ */

:root {
  color-scheme: light;
  /* fixed palette (used regardless of the page accent) */
  --pink: #ff6b8b;   --pink-dark: #e84d6f;   --pink-soft: #ffd9e2;  --pink-tint: #fff5f8;  --pink-grad: #fff0f4;  --pink-rgb: 232,77,111;
  --gold: #f6b73c;   --gold-dark: #d99a1b;   --gold-soft: #ffe1a8;  --gold-tint: #fffaf0;  --gold-grad: #fff7e8;  --gold-rgb: 246,183,60;
  --violet: #8a7bf4; --violet-dark: #5b49d6; --violet-soft: #ddd6ff; --violet-tint: #f6f3ff; --violet-grad: #f3f0ff; --violet-rgb: 138,123,244;
  --mint: #4dd6b8;   --mint-dark: #2bbd9c;
  --mint-text: #157a63;       /* mint used as TEXT (WCAG AA on the mint tag/tint surfaces) */
  --on-accent: #241b20;       /* text on any accent/mint FILL — passes on all accents, both themes */

  --ink: #3a2e33;
  --grey: #7c7077;            /* muted text — darkened from #9b8e93 to clear WCAG AA (~4.6:1 on white) */
  --cream: #fff7f2;
  --error: #c0392b;           /* the one semantic error colour, tokenized */
  --warn-bg: #fff3cd; --warn-border: #ffe08a; --warn-ink: #7a5d00;

  /* surfaces — tokenised so the night theme can repaint them in one place */
  --card: #ffffff;                         /* opaque card face */
  --card-2: rgba(255,255,255,0.65);        /* translucent panel */
  --page-bg: linear-gradient(160deg, var(--accent-grad) 0%, #fef6ef 60%, #eafaf5 100%);
  --toast-bg: #3a2e33; --toast-ink: #ffffff;
  --tag-adv-bg: #dff7ef; --tag-out-bg: #f3eaed; --rule: #e4d7db;

  /* type — Baloo 2 (warm rounded display) names the things you love;
     Nunito (friendly rounded sans) runs everything else. */
  --font-display: 'Baloo 2', 'Trebuchet MS', system-ui, sans-serif;
  --font-body: 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;

  /* shadow scale */
  --shadow-sm: 0 4px 12px rgba(0,0,0,0.05);
  --shadow-lg: 0 18px 50px rgba(0,0,0,0.25);

  /* default accent = pink (index / swipe / tournament) */
  --accent: var(--pink); --accent-deep: var(--pink-dark); --accent-soft: var(--pink-soft);
  --accent-tint: var(--pink-tint); --accent-grad: var(--pink-grad); --accent-rgb: var(--pink-rgb);
  --accent-text: #bd2f52;     /* accent used as TEXT — deep enough for WCAG AA on card/tint */
  --winner-1: #c08a00;        /* first stop of the champion-name gradient (day-safe gold) */
  --winner-2: var(--pink);    /* second stop of the champion-name gradient */
}
:root, html.accent-pink { /* explicit pink (same as default) */ }
html.accent-gold {
  --accent: var(--gold); --accent-deep: var(--gold-dark); --accent-soft: var(--gold-soft);
  --accent-tint: var(--gold-tint); --accent-grad: var(--gold-grad); --accent-rgb: var(--gold-rgb);
  --accent-text: #8a6100;
  --winner-2: var(--pink);
}
html.accent-violet {
  --accent: var(--violet); --accent-deep: var(--violet-dark); --accent-soft: var(--violet-soft);
  --accent-tint: var(--violet-tint); --accent-grad: var(--violet-grad); --accent-rgb: var(--violet-rgb);
  --accent-text: #5b49d6;
  --winner-2: var(--violet);
}

/* --shadow follows the accent (standardised at .18 alpha everywhere) */
:root { --shadow: 0 12px 30px rgba(var(--accent-rgb), 0.18); }

/* ============================================================
   NIGHT THEME
   <html data-theme="night"> (set by theme.js / the boot snippet).
   Selector specificity (0,1,1) matches the accent classes and is
   placed AFTER them, so it wins ties and repaints the accent-derived
   surface tokens. The per-page cards (defined as literal #fff in each
   page's <style>) are repainted by class below — higher specificity
   than the page rule, so day stays untouched and only night flips.
   ============================================================ */
html[data-theme="night"] {
  color-scheme: dark;
  --ink: #f2eaf1; --grey: #b4a6ad; --cream: #241f2e;
  --card: #2b2436; --card-2: rgba(43,36,54,0.74);
  --page-bg: linear-gradient(160deg, #2a2335 0%, #201a2b 55%, #19202f 100%);
  --accent-deep: var(--accent);                       /* the brighter accent reads better on dark */
  --accent-text: var(--accent);                       /* the bright accents pass as text on dark */
  --mint-text: #4dd6b8;
  --winner-1: #f6b73c;                                /* bright gold reads fine on the dark card */
  --accent-soft: rgba(255,255,255,0.16);              /* neutral subtle border (drops the light tint) */
  --accent-tint: rgba(var(--accent-rgb), 0.22);       /* selected/tint surfaces */
  --shadow: 0 14px 34px rgba(0,0,0,0.5);
  --shadow-sm: 0 4px 14px rgba(0,0,0,0.38);
  --shadow-lg: 0 18px 50px rgba(0,0,0,0.6);
  --toast-bg: #0e0a15; --toast-ink: #f2eaf1;
  --tag-adv-bg: rgba(77,214,184,0.20); --tag-out-bg: rgba(255,255,255,0.08); --rule: rgba(255,255,255,0.12);
  --warn-bg: #3a3320; --warn-border: #6e5f2c; --warn-ink: #ffdf8a;
  --error: #ff8b7b;
}
/* night violet as text needs a lighter step than the base violet to clear AA */
html[data-theme="night"].accent-violet { --accent-text: #8e80f4; }
/* night: repaint card faces that pages hardcode as #fff. NOTE the selector
   intentionally omits `html` so its specificity (0,2,0) ties — and thus yields
   to (it loads first) — two-class modifiers like .chip.hi and .optchip.sel,
   which keep their accent fills/gradients; it still beats the single-class
   base rules it's meant to darken. */
[data-theme="night"] :is(.mode-card, .optchip, .summary, .resume, .install-banner, .sess-row,
  .suite-link, .swipe-card, .action-btn, .score-card, .chip, .duel-card, .vs, .rank-item, .veto-mini) {
  background: var(--card);
}
/* night: light accent-tint surfaces (selected states, progress tracks, numeral chips) */
[data-theme="night"] :is(.mode-card.sel, .rank-item.picked, .rank-num, .progwrap, .chip:hover, .veto-mini.armed) {
  background: var(--accent-tint);
}
/* night: accent-as-text fails on the accent-tint numeral chip — use ink there.
   (.rank-item.picked .rank-num, an 0,2,0 page rule, still wins with --on-accent.) */
[data-theme="night"] .rank-num { color: var(--ink); }
/* night: borders that were light accent tints */
[data-theme="night"] :is(.optchip, .summary, .resume, .vs, .veto-mini, .duel-card:hover, .chip) { border-color: var(--accent-soft); }
/* night: white hover flashes on the home header chips */
[data-theme="night"] .acct-chip:hover { background: var(--card); }

/* ---- reset & base ---- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--page-bg);
  color: var(--ink);
  display: flex; justify-content: center; min-height: 100%; overflow-x: hidden;
  transition: background .4s ease, color .25s ease;
}

/* functional line icons (icons.js) align with adjacent text */
.ic { display: inline-block; vertical-align: -0.16em; flex: none; }
.app { width: 100%; max-width: 460px; padding: 18px 18px 36px; display: flex; flex-direction: column; min-height: 100vh; }

header { text-align: center; margin: 6px 0 14px; }
header h1 { font-family: var(--font-display); font-size: 1.7rem; margin: 0; font-weight: 700; letter-spacing: -0.5px; }
header h1 .heart, header h1 .accent { color: var(--accent); }
/* gold-on-white is too light for a heading — use the text-safe tone for that wordmark */
html.accent-gold header h1 .accent { color: var(--accent-text); }
header p { margin: 4px 0 0; color: var(--grey); font-size: 0.9rem; }

/* ---- buttons ---- */
.btn { border: none; border-radius: 16px; padding: 14px 18px; font-size: 1rem; font-weight: 800;
  cursor: pointer; font-family: inherit; transition: transform .08s ease, box-shadow .2s; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow); }
.btn-ghost { background: var(--card); color: var(--accent-deep); border: 2px solid var(--accent-soft); }
.btn-mint { background: var(--mint); color: var(--on-accent); box-shadow: var(--shadow); }

/* ---- inputs ---- */
.input { width: 100%; padding: 14px 16px; border-radius: 16px; border: 2px solid var(--accent-soft);
  background: var(--card); font-size: 1rem; font-family: inherit; color: var(--ink); margin-bottom: 12px;
  text-align: center; font-weight: 700; }
.input:focus { outline: none; border-color: var(--accent); }
.input.code { letter-spacing: 6px; text-transform: uppercase; font-size: 1.4rem; }
::placeholder { color: var(--grey); opacity: 1; }

/* ---- surfaces & text ---- */
.panel { background: var(--card-2); border-radius: 24px; padding: 22px; box-shadow: var(--shadow); backdrop-filter: blur(4px); }
.muted { color: var(--grey); font-size: 0.85rem; font-weight: 500; text-align: center; }
.divider { text-align: center; color: var(--grey); margin: 16px 0; font-weight: 700; font-size: 0.8rem; }
.hidden { display: none !important; }
.setup-warn { background: var(--warn-bg); border: 2px solid var(--warn-border); color: var(--warn-ink); border-radius: 16px;
  padding: 14px; font-size: 0.85rem; font-weight: 700; margin-bottom: 14px; line-height: 1.4; }
.backbtn { background: none; border: none; color: var(--grey); font-weight: 800; font-family: inherit;
  cursor: pointer; font-size: .9rem; padding: 6px 0; margin-bottom: 6px; text-align: left; }

/* ---- toast ---- */
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(40px);
  background: var(--toast-bg); color: var(--toast-ink); padding: 12px 20px; border-radius: 16px; font-weight: 800;
  box-shadow: var(--shadow); opacity: 0; transition: opacity .3s, transform .3s; z-index: 250; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- game chrome shared by the mode pages ---- */
.pill { background: var(--card); border: 2px solid var(--accent-soft); border-radius: 20px; padding: 7px 13px;
  font-weight: 700; font-size: 0.85rem; color: var(--accent-text); display: inline-flex; align-items: center; gap: 6px; }
/* interactive pills (share / recap) get a comfortable tap target */
button.pill { min-height: 40px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; }
/* partner status must shrink/ellipsis, not crowd the pills */
.topbar .muted { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.backlink { text-align: center; margin-top: 14px; }
.backlink a { color: var(--grey); font-weight: 700; font-size: .85rem; text-decoration: none; }
.center-btns { display: flex; gap: 10px; margin-top: 10px; }
.center-btns .btn { flex: 1; }

/* ---- leaderboard rows (tournament / ranking / duel / swipe) ---- */
.board { margin-top: 6px; }
.lb-row { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 14px;
  padding: 11px 14px; margin-bottom: 8px; box-shadow: var(--shadow-sm); }
.lb-row.adv { border-left: 6px solid var(--mint); }
.lb-row.out { opacity: .55; border-left: 6px solid var(--rule); }
.lb-rank { font-weight: 800; color: var(--grey); width: 24px; text-align: center; }
.lb-name { font-weight: 800; flex: 1; }
.lb-score { font-weight: 800; color: var(--accent-text); }
.lb-split { font-size: .72rem; color: var(--grey); font-weight: 700; }
.lb-tag { font-size: .72rem; font-weight: 800; padding: 2px 8px; border-radius: 10px; }
.lb-tag.adv { background: var(--tag-adv-bg); color: var(--mint-text); }
.lb-tag.out { background: var(--tag-out-bg); color: var(--grey); }
/* scores/ranks/codes use aligned figures so they don't reflow as values change */
.lb-rank, .lb-score, .lb-split, .input.code { font-variant-numeric: tabular-nums; }

/* ---- champion screen ---- */
.champion { text-align: center; padding: 16px 6px; }
.champion .crown { font-size: 3.4rem; }
.champion .winner { font-family: var(--font-display); font-size: clamp(2.4rem, 11vw, 3.2rem); font-weight: 800;
  letter-spacing: -0.01em; line-height: 1.05; margin: 6px 0;
  background: linear-gradient(135deg, var(--winner-1), var(--winner-2));
  color: var(--accent-deep);                 /* fallback if background-clip:text is unsupported */
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
  .champion .winner { -webkit-text-fill-color: var(--accent-deep); color: var(--accent-deep); }
}
.final-list { margin-top: 16px; text-align: left; }

/* ---- shareable result card (share-card.js) ---- */
.sharecard-head { font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; color: var(--accent-deep);
  margin: 4px 0 12px; text-align: center; }
.sharecard-frame { position: relative; border-radius: 22px; overflow: hidden; box-shadow: var(--shadow);
  border: 3px solid var(--card); background: var(--card); line-height: 0;
  animation: sc-pop .45s cubic-bezier(.2,.9,.3,1.2) both; }
.sharecard-canvas { display: block; width: 100%; height: auto; border-radius: 20px; }
.sc-confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.sharecard-btns { display: flex; gap: 10px; margin-top: 16px; }

/* invite call-to-action (stage 1) */
.sc-invite { margin-top: 20px; }
.sc-cta { width: 100%; display: flex; align-items: center; gap: 14px; text-align: left; cursor: pointer;
  font-family: inherit; color: #fff; border: none; border-radius: 20px; padding: 16px 20px;
  background: linear-gradient(120deg, var(--accent), var(--accent-deep));
  box-shadow: var(--shadow); position: relative; overflow: hidden;
  animation: sc-breathe 2.8s ease-in-out infinite; }
.sc-cta::after { content: ""; position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,0.35), transparent);
  transform: skewX(-18deg); animation: sc-shimmer 2.8s ease-in-out infinite; }
.sc-cta--gold { background: linear-gradient(120deg, #f6b73c, #c8891a); }
/* Reveal CTA is the primary/hero action — pin it to the pink gradient so it stays
   visually distinct from the gold share-card CTA on every page accent (the duel
   page's gold accent would otherwise make the two buttons near-identical). */
.sc-cta.rv-cta { background: linear-gradient(120deg, var(--pink), var(--pink-dark)); }
.sc-close { background: none; border: none; cursor: pointer; color: var(--grey); font-weight: 900;
  font-size: 1.05rem; padding: 4px 10px; border-radius: 10px; font-family: inherit; }
.sc-close:hover { color: var(--ink); background: var(--card); }
.sc-cta:active { transform: scale(0.98); }
.sc-cta-text { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.sc-cta-text b { font-size: 1.05rem; font-weight: 800; }
.sc-cta-text small { font-size: 0.76rem; opacity: 0.92; font-weight: 600; }
.sc-cta-emoji { font-size: 1.5rem; animation: sc-float 2.4s ease-in-out infinite; }
.sc-cta-emoji:last-child { animation-delay: .5s; }
@keyframes sc-breathe { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-2px) scale(1.015); } }
@keyframes sc-shimmer { 0% { left: -60%; } 55%,100% { left: 130%; } }
@keyframes sc-float { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-4px) rotate(6deg); } }

/* customizer panel (stage 2) */
.sc-panel { margin-top: 20px; animation: sc-pop .4s cubic-bezier(.2,.9,.3,1.2) both; }
.sc-opts { margin-top: 16px; display: flex; flex-direction: column; gap: 13px; }
.sc-optrow { display: flex; align-items: center; gap: 12px; }
.sc-label { font-weight: 800; font-size: .82rem; color: var(--grey); width: 54px; flex: none;
  text-transform: uppercase; letter-spacing: .5px; }
.sc-swatches { display: flex; gap: 10px; }
.sc-swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--card); cursor: pointer;
  background: var(--c); box-shadow: 0 0 0 1px rgba(0,0,0,.06); transition: transform .12s; padding: 0; }
.sc-swatch:active { transform: scale(.92); }
.sc-swatch.sel { box-shadow: 0 0 0 3px var(--c); }
.sc-segs { display: flex; gap: 8px; flex: 1; }
.sc-seg { flex: 1; border: 2px solid var(--accent-soft); background: var(--card); color: var(--grey);
  border-radius: 12px; padding: 9px 6px; font-family: inherit; font-weight: 800; font-size: .82rem;
  cursor: pointer; transition: .12s; }
.sc-seg.sel { border-color: var(--accent); color: var(--accent-text); background: var(--accent-tint); }
.sc-checks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
/* flex-basis lets toggles pack as many as fit per row and grow to fill —
   so every applicable toggle stays visible on any phone width (never clipped). */
.sc-toggle { flex: 1 1 128px; display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; background: var(--card); cursor: pointer; white-space: nowrap;
  border: 2px solid var(--accent-soft); border-radius: 12px; padding: 9px 10px; font-weight: 700;
  font-size: .84rem; color: var(--ink); user-select: none; }
.sc-toggle input { accent-color: var(--accent); width: 17px; height: 17px; cursor: pointer; }

/* option chips (reveal decoy list) — same look as index.html's config picker,
   token-ified so it follows the page's accent instead of a hardcoded pink. */
.optchips { display: flex; flex-wrap: wrap; gap: 8px; }
.optchip { border: 2px solid var(--accent-soft); background: var(--card); color: var(--ink); border-radius: 14px;
  padding: 8px 13px; font-weight: 800; font-size: .85rem; cursor: pointer; font-family: inherit; transition: .12s; }
.optchip.sel { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.optchip:active { transform: scale(.95); }

/* saved-session row (e.g. "your reveal page is live") — same look as
   index.html's session list, token-ified for cross-page accent/night reuse. */
.sess-row { background: var(--card); color: var(--ink); font-family: inherit; border-radius: 14px;
  padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 10px; }
.sess-row .w { font-weight: 800; flex: 1; }
.sess-row .d { color: var(--grey); font-size: .75rem; font-weight: 700; }

/* Baby Suite kit: cross-app link cards (moved from index.html's local style, v1.3) */
.suite-link { display:flex; align-items:center; gap:12px; background:#fff; border-radius:18px; padding:12px 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.06); margin-bottom:10px; text-decoration:none; color:var(--ink); transition:.12s; }
.suite-link:active { transform: scale(.98); }
.suite-link .sic svg { display:block; border-radius:11px; }
.suite-link .st { flex:1; }
.suite-link .st b { font-size:.98rem; display:block; }
.suite-link .st small { color:var(--grey); font-size:.76rem; font-weight:700; }
.suite-link .sgo { color:var(--grey); font-size:1.1rem; font-weight:800; }
@keyframes sc-pop { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .sharecard-frame, .sc-panel { animation: none; }
  .sc-cta, .sc-cta::after, .sc-cta-emoji { animation: none; }
}

/* v1.2 partner-join banner (game pages, duo mode) */
.join-banner { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: var(--accent-tint, #fff5f8); border: 2px dashed var(--accent-soft); color: var(--ink);
  border-radius: 14px; padding: 11px 14px; margin: 10px 0 12px; font-weight: 800; font-size: .92rem;
  cursor: pointer; font-family: inherit; }
.join-banner.joined { border-style: solid; border-color: var(--accent); cursor: default;
  animation: pop .4s ease; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .join-banner.joined { animation: none; } }

/* ---- waiting spinner ---- */
.waiting { text-align: center; padding: 28px 10px; }
.waiting .spin { font-size: 2.4rem; display: inline-block; animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- accessibility: visible keyboard focus (pages can override) ---- */
:where(button, a, input, .mode-card, .duel-card, .rank-item, .swipe-card, .optchip, .chip, .sess-row):focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .waiting .spin { animation: none; }
}

/* ---- analytics consent bar (EU) — theme-aware via toast tokens ---- */
.consent-bar {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 300;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center;
  background: var(--toast-bg); color: var(--toast-ink);
  padding: 12px 16px; border-radius: 14px;
  font-size: 14px; line-height: 1.4; text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.consent-bar .consent-ok {
  padding: 8px 18px; border-radius: 999px; border: none; cursor: pointer;
  background: var(--toast-ink); color: var(--toast-bg); font-weight: 700; font-size: 14px;
}
.consent-bar .consent-no {
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--toast-ink) 40%, transparent);
  background: transparent; color: var(--toast-ink); font-size: 14px;
}
.offline-pill {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 320;
  max-width: calc(100vw - 24px);
  background: var(--toast-bg); color: var(--toast-ink);
  padding: 7px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600; line-height: 1.3;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.offline-pill[hidden] { display: none; }
