/* ─────────────────────────────────────────────────────────────
   Secret Santa — Design System
   Direction: Atelier · craft paper · trustworthy & universal
   Light + Dark + Optional Christmas sub-theme (per-game)
   ───────────────────────────────────────────────────────────── */

/* ─── Light (default, year-round) ─── */
:root,
[data-theme="light"] {
  /* Surface */
  --bg:           #fbf6ea;   /* warm paper background */
  --bg-elev:     #fffdf6;   /* card / panel */
  --bg-sunken:   #f3ead4;   /* sunken / hover surface */
  --surface-tonal:#efe4c8;  /* badge bg, subtle blocks */

  /* Ink */
  --ink:          #1a1a1a;
  --ink-2:        #3d342a;
  --ink-muted:    #7a6a55;
  --ink-subtle:   #a89c80;

  /* Lines */
  --line:         #e6d9b8;
  --line-strong:  #d4c596;
  --line-dashed:  rgba(122,106,85,.35);

  /* Brand & semantic */
  --pine:         #2d5240;   /* primary — trustworthy, year-round */
  --pine-hover:   #25432f;
  --pine-soft:    #e6efe7;
  --cherry:       #b5443a;   /* accent — sparingly, festive when needed */
  --cherry-hover: #97362d;
  --cherry-soft:  #f4e2dd;
  --twine:        #a47551;   /* secondary / decorative */
  --twine-soft:   #f0e1cc;
  --butter:       #e6b85a;   /* warning / highlight */
  --butter-soft:  #fbecc5;
  --success:      #4f7d5c;
  --success-soft: #e3eee2;
  --info:         #4a6b80;
  --info-soft:    #e1eaf0;
  --danger:       #b5443a;
  --danger-soft:  #f4e2dd;

  /* Effects */
  --shadow-sm:    0 1px 2px rgba(40,30,20,.06), 0 1px 0 rgba(40,30,20,.04);
  --shadow:       0 2px 6px rgba(40,30,20,.08), 0 1px 2px rgba(40,30,20,.06);
  --shadow-md:    0 8px 24px rgba(40,30,20,.10), 0 2px 6px rgba(40,30,20,.06);
  --shadow-lg:    0 18px 48px rgba(40,30,20,.14), 0 4px 12px rgba(40,30,20,.08);
  --shadow-press: 0 3px 0 var(--ink);        /* chunky atelier press shadow */
  --shadow-press-pine: 0 3px 0 #1f3a2b;
  --shadow-press-cherry: 0 3px 0 #862e26;

  --noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.6  0 0 0 0 0.5  0 0 0 0 0.35  0 0 0 0.05 0'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
}

/* ─── Dark (also year-round) ─── */
[data-theme="dark"] {
  --bg:           #161311;
  --bg-elev:     #1f1c18;
  --bg-sunken:   #110e0c;
  --surface-tonal:#2a251f;

  --ink:          #f6efde;
  --ink-2:        #d8cdb3;
  --ink-muted:    #9a8e74;
  --ink-subtle:   #6a604e;

  --line:         #322c24;
  --line-strong:  #463d31;
  --line-dashed:  rgba(216,205,179,.18);

  --pine:         #6ea884;
  --pine-hover:   #82b797;
  --pine-soft:    #1e2e25;
  --cherry:       #d76b5e;
  --cherry-hover: #e07f73;
  --cherry-soft:  #2e1e1c;
  --twine:        #c89a73;
  --twine-soft:   #2a221a;
  --butter:       #efc97a;
  --butter-soft:  #2c2616;
  --success:      #76b08a;
  --success-soft: #1c2922;
  --info:         #88a8bd;
  --info-soft:    #1c252c;
  --danger:       #d76b5e;
  --danger-soft:  #2e1e1c;

  --shadow-sm:    0 1px 2px rgba(0,0,0,.4);
  --shadow:       0 2px 6px rgba(0,0,0,.5);
  --shadow-md:    0 8px 24px rgba(0,0,0,.55);
  --shadow-lg:    0 18px 48px rgba(0,0,0,.65);
  --shadow-press: 0 3px 0 #000;
  --shadow-press-pine: 0 3px 0 #1e2e25;
  --shadow-press-cherry: 0 3px 0 #5a2722;
}

/* ─── Christmas sub-theme (per-game opt-in) ───
   Stacks on top of light or dark. Adds saturation + cherry accents. */
[data-subtheme="christmas"] {
  --pine:         #2d5240;
  --cherry:       #b5443a;
  --butter:       #e6b85a;
  --xmas-active:  1;     /* presence flag for JS / animations */
}
[data-theme="dark"][data-subtheme="christmas"] {
  --pine:         #6ea884;
  --cherry:       #d76b5e;
  --butter:       #efc97a;
}

/* ─────────────────────────────────────────────────────────────
   Type scale & tokens
   ───────────────────────────────────────────────────────────── */
:root {
  --font-display: 'Caprasimo', 'Newsreader', Georgia, serif;
  --font-body:    'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-hand:    'Caveat', 'Bradley Hand', cursive;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  --text-xs:   12px;
  --text-sm:   13px;
  --text-base: 15px;
  --text-md:   17px;
  --text-lg:   20px;
  --text-xl:   24px;
  --text-2xl:  32px;
  --text-3xl:  44px;
  --text-4xl:  60px;
  --text-5xl:  80px;

  --leading-tight: 1.05;
  --leading-snug:  1.25;
  --leading-body:  1.55;
  --leading-loose: 1.7;

  /* Spacing scale (4-based) */
  --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;
  --s-20: 80px;

  /* Radii — small everywhere (atelier paper feel, not pillowy) */
  --r-xs: 3px;
  --r-sm: 4px;
  --r:    6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 999px;

  /* Motion */
  --ease-out: cubic-bezier(.2,.7,.3,1);
  --ease-in-out: cubic-bezier(.5,.1,.3,1);
  --t-fast: 120ms;
  --t:      180ms;
  --t-slow: 280ms;
}

/* ─────────────────────────────────────────────────────────────
   Base
   ───────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
}

/* Subtle paper grain on body — light only */
[data-theme="light"] body::before,
:root:not([data-theme]) body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: var(--noise);
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
  mix-blend-mode: multiply;
}

/* Typography helpers */
.display { font-family: var(--font-display); font-weight: 400; line-height: var(--leading-tight); letter-spacing: -0.01em; }
.hand    { font-family: var(--font-hand);    font-weight: 600; letter-spacing: 0; }
.mono    { font-family: var(--font-mono); }

.eyebrow {
  font-family: var(--font-body);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  color: var(--ink-muted);
}

a { color: var(--pine); text-decoration: none; }
a:hover { color: var(--pine-hover); text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }

/* Focus ring (consistent across components) */
:where(button, a, input, textarea, select, [tabindex]):focus-visible {
  outline: 2px solid var(--pine);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ─────────────────────────────────────────────────────────────
   Components
   ───────────────────────────────────────────────────────────── */

/* Buttons */
.btn {
  --_bg: var(--bg-elev);
  --_fg: var(--ink);
  --_bd: var(--line-strong);
  --_press: transparent;

  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 10px 18px;
  border-radius: var(--r);
  border: 1.5px solid var(--_bd);
  background: var(--_bg);
  color: var(--_fg);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease-out),
              box-shadow var(--t-fast) var(--ease-out),
              background var(--t) var(--ease-out);
  box-shadow: 0 2px 0 var(--_press);
  user-select: none;
  line-height: 1.2;
}
/* Re-assert the button's own foreground colour and strip the underline
   that the global `a:hover` rule (line ~211) would otherwise apply when
   the button is rendered as <a class="btn …">. Without this, dark
   buttons (--_bg = var(--pine|cherry)) get their text repainted to
   --pine-hover, which is near-identical to the background and renders
   the label invisible. .btn:hover specificity (0,2,0) wins over
   a:hover (0,1,1). Applies across light/dark/christmas themes since
   --_fg is set per modifier. */
.btn:hover, .btn:focus, .btn:active { color: var(--_fg); text-decoration: none; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 3px 0 var(--_press); }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--_press); }
.btn--lg { padding: 14px 24px; font-size: var(--text-base); }
.btn--sm { padding: 6px 12px; font-size: var(--text-xs); }
.btn--icon { padding: 8px; aspect-ratio: 1; }
.btn--block { width: 100%; justify-content: center; }

.btn--primary { --_bg: var(--pine); --_fg: var(--bg-elev); --_bd: var(--pine-hover); --_press: var(--pine-hover); }
.btn--primary:hover { --_bg: var(--pine-hover); }

.btn--cherry { --_bg: var(--cherry); --_fg: var(--bg-elev); --_bd: var(--cherry-hover); --_press: var(--cherry-hover); }
.btn--cherry:hover { --_bg: var(--cherry-hover); }

.btn--ghost { --_bg: transparent; --_bd: var(--line-strong); }
.btn--quiet { --_bg: transparent; --_bd: transparent; box-shadow: none; }
.btn--quiet:hover { --_bg: var(--bg-sunken); }

/* Cards (paper) */
.card {
  background: var(--bg-elev);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-6);
  position: relative;
  transition: border-color var(--t) var(--ease-out), transform var(--t) var(--ease-out), box-shadow var(--t) var(--ease-out);
}
.card--hover:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow); }
.card--sunken { background: var(--bg-sunken); }
.card--quiet { background: transparent; border-style: dashed; }
.card--ribbon::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--pine); border-radius: var(--r-md) 0 0 var(--r-md);
}
.card--ribbon-cherry::before { background: var(--cherry); }
.card--ribbon-butter::before { background: var(--butter); }
.card--ribbon-twine::before  { background: var(--twine); }

/* Tape (decorative element for special cards / Christmas mode) */
.tape {
  position: absolute;
  background: rgba(230,184,90,.55);
  border: 1px solid rgba(164,117,81,.25);
  border-radius: 1px;
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
  pointer-events: none;
}
.tape--top    { top: -10px; left: 24px; width: 80px; height: 22px; transform: rotate(-4deg); }
.tape--right  { top: 14px; right: -12px; width: 70px; height: 18px; transform: rotate(35deg); }

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  background: var(--bg-elev);
  color: var(--ink-2);
  border: 1px solid var(--line);
  line-height: 1.4;
}
.chip--pine    { background: var(--pine-soft);    color: var(--pine);    border-color: transparent; }
.chip--cherry  { background: var(--cherry-soft);  color: var(--cherry);  border-color: transparent; }
.chip--butter  { background: var(--butter-soft);  color: #6b4f1a;        border-color: transparent; }
[data-theme="dark"] .chip--butter { color: var(--butter); }
.chip--twine   { background: var(--twine-soft);   color: var(--twine);   border-color: transparent; }
.chip--success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.chip--info    { background: var(--info-soft);    color: var(--info);    border-color: transparent; }
.chip--solid-pine   { background: var(--pine);    color: var(--bg-elev); border-color: transparent; font-weight: 600; }
.chip--solid-cherry { background: var(--cherry);  color: var(--bg-elev); border-color: transparent; font-weight: 600; }

/* Stamp — used for status, special calls, scellé */
.stamp {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 5px 12px;
  border: 2px solid currentColor;
  color: var(--cherry);
  font-family: var(--font-body);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  transform: rotate(-3deg);
  background: var(--cherry-soft);
  border-radius: var(--r-sm);
  position: relative;
}
.stamp--pine   { color: var(--pine);   background: var(--pine-soft); }
.stamp--twine  { color: var(--twine);  background: var(--twine-soft); }
.stamp--butter { color: #6b4f1a;       background: var(--butter-soft); }

/* Inputs */
.input, .textarea, .select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-elev);
  color: var(--ink);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r);
  font-family: var(--font-body);
  font-size: var(--text-base);
  transition: border-color var(--t) var(--ease-out), background var(--t) var(--ease-out);
}
.input:hover, .textarea:hover, .select:hover { border-color: var(--ink-muted); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--pine);
  background: var(--bg-elev);
  box-shadow: 0 0 0 3px var(--pine-soft);
}
.label { display: block; font-weight: 600; font-size: var(--text-sm); margin-bottom: 6px; color: var(--ink-2); }
.help  { font-size: var(--text-xs); color: var(--ink-muted); margin-top: 4px; }

/* Field group with a "label tag" feel */
.field-tag {
  display: inline-block;
  padding: 2px 10px;
  background: var(--surface-tonal);
  color: var(--ink-2);
  border-radius: var(--r-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* Toast */
.toast {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px 12px 16px;
  background: var(--bg-elev);
  color: var(--ink);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  min-width: 280px;
  max-width: 420px;
  position: relative;
  overflow: hidden;
}
.toast::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--pine);
}
.toast--success::before { background: var(--success); }
.toast--info::before    { background: var(--info); }
.toast--warning::before { background: var(--butter); }
.toast--error::before, .toast--danger::before { background: var(--danger); }
.toast__icon { flex: 0 0 auto; width: 22px; height: 22px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; font-size: 14px; }
.toast__body { flex: 1; min-width: 0; }
.toast__title { font-weight: 700; font-size: var(--text-sm); }
.toast__msg { font-size: var(--text-xs); color: var(--ink-muted); margin-top: 2px; }
.toast__close { background: none; border: none; color: var(--ink-muted); cursor: pointer; padding: 4px; border-radius: var(--r-sm); }
.toast__close:hover { background: var(--bg-sunken); color: var(--ink); }

/* Navbar */
.app-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 32px;
  background: var(--bg);
  border-bottom: 1.5px dashed var(--line-dashed);
  position: sticky; top: 0; z-index: 10;
}

/* Divider */
.divider { height: 1px; background: var(--line); border: 0; margin: var(--s-6) 0; }
.divider--dashed { background: transparent; border-top: 1.5px dashed var(--line-dashed); }

/* Avatar (gift-tag shape) */
.avatar {
  position: relative;
  width: 44px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--bg-elev);
}
.avatar svg { position: absolute; inset: 0; }
.avatar > span { position: relative; padding-left: 8px; }

/* ─────────────────────────────────────────────────────────────
   Christmas — additive layer, only when [data-subtheme="christmas"]
   ───────────────────────────────────────────────────────────── */
[data-subtheme="christmas"] .xmas-decor { display: block; }
.xmas-decor { display: none; }

@keyframes snowfall {
  0%   { transform: translateY(-10px); opacity: 0; }
  10%  { opacity: 0.9; }
  100% { transform: translateY(120vh); opacity: 0; }
}
.xmas-snow {
  position: fixed; inset: 0; pointer-events: none; z-index: 9999;
  overflow: hidden;
}
.xmas-snow span {
  position: absolute; top: -20px;
  width: 8px; height: 8px;
  color: var(--ink-2);
  opacity: 0.65;
  animation: snowfall linear infinite;
  font-size: 10px;
}

/* Reveal card animation (santee) */
@keyframes seal-pop {
  0%   { transform: scale(0.6) rotate(-12deg); opacity: 0; }
  60%  { transform: scale(1.06) rotate(-3deg); opacity: 1; }
  100% { transform: scale(1) rotate(-3deg); opacity: 1; }
}
.seal-pop { animation: seal-pop 480ms var(--ease-out) both; }

@keyframes card-flip-in {
  0%   { transform: perspective(900px) rotateY(180deg); }
  100% { transform: perspective(900px) rotateY(0); }
}
.card-flip-in { animation: card-flip-in 700ms var(--ease-out) both; backface-visibility: hidden; }

/* Micro-interactions */
@keyframes underline-grow {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}
.hl-underline { background: linear-gradient(transparent 60%, var(--butter-soft) 60%); padding: 0 .1em; }
