/*
  Sports Party Bingo — brand tokens
  DRAFT until Chuck clears it. See BRAND.md at the repo root.

  The house look is dark (forest felt, gold, cream ticket). It is the default.
  Light is cream paper with forest ink, for print-like pages, docs and email.

  Theme selection:
    - No preference or dark preference  -> dark
    - prefers-color-scheme: light        -> light, unless [data-theme="dark"] is set
    - [data-theme="light" | "dark"]      -> forced, on :root or on any section

  Contrast ratios (WCAG 2.x) are noted next to each text/fill pair.
  AA needs 4.5:1 for body text, 3:1 for large text and UI edges.
*/

:root {
  /* ---------- Raw palette (do not use directly in components) ---------- */
  --spb-forest-950: #142C21;  /* sunken: fields, secondary buttons */
  --spb-forest-900: #1A3A2B;  /* the house background */
  --spb-forest-800: #244C3A;  /* panels */
  --spb-felt:       #0B3D2E;  /* dauber ink, marked squares */
  --spb-felt-disc:  #124B39;  /* the daub blot inside a marked square */
  --spb-sage-600:   #77987F;  /* strong borders on dark */
  --spb-sage-500:   #6F877A;  /* strong borders on light */
  --spb-sage-450:   #56705F;  /* subtle text on light */
  --spb-sage-400:   #8AA398;  /* placeholder on dark (sunken only) */
  --spb-sage-300:   #AEC4B8;  /* subtle text on dark */
  --spb-sage-100:   #D4E2D9;  /* muted text on dark */
  --spb-moss-700:   #3F5A4C;  /* muted text on light */
  --spb-foam:       #F4F7F4;  /* text on dark */
  --spb-cream:      #FFF8EA;  /* the ticket, light background */
  --spb-cream-200:  #F6EEDB;  /* sunken on light */
  --spb-cream-label:#FFF2C4;  /* eyebrow labels on dark */
  --spb-cell-line:  #EDE3CC;  /* empty squares drawn on cream (decorative) */
  --spb-gold:       #F0C53A;  /* the accent, the stub, the win */
  --spb-gold-disc:  #F5D25A;  /* the daub blot inside a winning square */
  --spb-gold-glow:  #FFE08A;  /* focus ring on dark */
  --spb-brass:      #7A5600;  /* gold that can be read on cream */
  --spb-gold-ink:   #1A1500;  /* text on gold */
  --spb-ink:        #141414;  /* text on the ticket */
  --spb-white:      #FFFFFF;
  --spb-brick:      #8B1515;  /* destructive fill */

  /* Card-room pattern tiles (120px, same art as elements/pattern-*.svg). */
  --spb-pattern-size: 120px;
  --spb-pattern-on-dark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23FFF8EA' stroke-opacity='0.07' stroke-width='1.25'%3E%3Crect x='2' y='2' width='20' height='20' rx='3'/%3E%3Crect x='26' y='2' width='20' height='20' rx='3'/%3E%3Crect x='50' y='2' width='20' height='20' rx='3'/%3E%3Crect x='74' y='2' width='20' height='20' rx='3'/%3E%3Crect x='98' y='2' width='20' height='20' rx='3'/%3E%3Crect x='2' y='26' width='20' height='20' rx='3'/%3E%3Crect x='26' y='26' width='20' height='20' rx='3'/%3E%3Crect x='50' y='26' width='20' height='20' rx='3'/%3E%3Crect x='74' y='26' width='20' height='20' rx='3'/%3E%3Crect x='98' y='26' width='20' height='20' rx='3'/%3E%3Crect x='2' y='50' width='20' height='20' rx='3'/%3E%3Crect x='26' y='50' width='20' height='20' rx='3'/%3E%3Crect x='50' y='50' width='20' height='20' rx='3'/%3E%3Crect x='74' y='50' width='20' height='20' rx='3'/%3E%3Crect x='98' y='50' width='20' height='20' rx='3'/%3E%3Crect x='2' y='74' width='20' height='20' rx='3'/%3E%3Crect x='26' y='74' width='20' height='20' rx='3'/%3E%3Crect x='50' y='74' width='20' height='20' rx='3'/%3E%3Crect x='74' y='74' width='20' height='20' rx='3'/%3E%3Crect x='98' y='74' width='20' height='20' rx='3'/%3E%3Crect x='2' y='98' width='20' height='20' rx='3'/%3E%3Crect x='26' y='98' width='20' height='20' rx='3'/%3E%3Crect x='50' y='98' width='20' height='20' rx='3'/%3E%3Crect x='74' y='98' width='20' height='20' rx='3'/%3E%3Crect x='98' y='98' width='20' height='20' rx='3'/%3E%3C/g%3E%3Cpath fill-opacity='0.09' fill='%23FFF8EA' transform='translate(36 12) rotate(0) scale(7.5)' d='M1 0C1 .58.56 1.04-.04 1-.6.96-1.02.54-.98-.03-.94-.6-.52-1 .06-.98.62-.96 1-.54 1 0z'/%3E%3Cpath fill-opacity='0.09' fill='%23FFF8EA' transform='translate(84 36) rotate(70) scale(7.5)' d='M1 0C1 .58.56 1.04-.04 1-.6.96-1.02.54-.98-.03-.94-.6-.52-1 .06-.98.62-.96 1-.54 1 0z'/%3E%3Cpath fill-opacity='0.09' fill='%23FFF8EA' transform='translate(12 60) rotate(140) scale(7.5)' d='M1 0C1 .58.56 1.04-.04 1-.6.96-1.02.54-.98-.03-.94-.6-.52-1 .06-.98.62-.96 1-.54 1 0z'/%3E%3Cpath fill-opacity='0.09' fill='%23FFF8EA' transform='translate(108 84) rotate(210) scale(7.5)' d='M1 0C1 .58.56 1.04-.04 1-.6.96-1.02.54-.98-.03-.94-.6-.52-1 .06-.98.62-.96 1-.54 1 0z'/%3E%3Cpath fill-opacity='0.09' fill='%23FFF8EA' transform='translate(60 108) rotate(280) scale(7.5)' d='M1 0C1 .58.56 1.04-.04 1-.6.96-1.02.54-.98-.03-.94-.6-.52-1 .06-.98.62-.96 1-.54 1 0z'/%3E%3Cpath fill-opacity='0.09' fill='%23FFF8EA' transform='translate(60 60) rotate(0) scale(7.5)' d='M1 0C1 .58.56 1.04-.04 1-.6.96-1.02.54-.98-.03-.94-.6-.52-1 .06-.98.62-.96 1-.54 1 0z'/%3E%3C/svg%3E");
  --spb-pattern-on-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%2310231A' stroke-opacity='0.08' stroke-width='1.25'%3E%3Crect x='2' y='2' width='20' height='20' rx='3'/%3E%3Crect x='26' y='2' width='20' height='20' rx='3'/%3E%3Crect x='50' y='2' width='20' height='20' rx='3'/%3E%3Crect x='74' y='2' width='20' height='20' rx='3'/%3E%3Crect x='98' y='2' width='20' height='20' rx='3'/%3E%3Crect x='2' y='26' width='20' height='20' rx='3'/%3E%3Crect x='26' y='26' width='20' height='20' rx='3'/%3E%3Crect x='50' y='26' width='20' height='20' rx='3'/%3E%3Crect x='74' y='26' width='20' height='20' rx='3'/%3E%3Crect x='98' y='26' width='20' height='20' rx='3'/%3E%3Crect x='2' y='50' width='20' height='20' rx='3'/%3E%3Crect x='26' y='50' width='20' height='20' rx='3'/%3E%3Crect x='50' y='50' width='20' height='20' rx='3'/%3E%3Crect x='74' y='50' width='20' height='20' rx='3'/%3E%3Crect x='98' y='50' width='20' height='20' rx='3'/%3E%3Crect x='2' y='74' width='20' height='20' rx='3'/%3E%3Crect x='26' y='74' width='20' height='20' rx='3'/%3E%3Crect x='50' y='74' width='20' height='20' rx='3'/%3E%3Crect x='74' y='74' width='20' height='20' rx='3'/%3E%3Crect x='98' y='74' width='20' height='20' rx='3'/%3E%3Crect x='2' y='98' width='20' height='20' rx='3'/%3E%3Crect x='26' y='98' width='20' height='20' rx='3'/%3E%3Crect x='50' y='98' width='20' height='20' rx='3'/%3E%3Crect x='74' y='98' width='20' height='20' rx='3'/%3E%3Crect x='98' y='98' width='20' height='20' rx='3'/%3E%3C/g%3E%3Cpath fill-opacity='0.07' fill='%2310231A' transform='translate(36 12) rotate(0) scale(7.5)' d='M1 0C1 .58.56 1.04-.04 1-.6.96-1.02.54-.98-.03-.94-.6-.52-1 .06-.98.62-.96 1-.54 1 0z'/%3E%3Cpath fill-opacity='0.07' fill='%2310231A' transform='translate(84 36) rotate(70) scale(7.5)' d='M1 0C1 .58.56 1.04-.04 1-.6.96-1.02.54-.98-.03-.94-.6-.52-1 .06-.98.62-.96 1-.54 1 0z'/%3E%3Cpath fill-opacity='0.07' fill='%2310231A' transform='translate(12 60) rotate(140) scale(7.5)' d='M1 0C1 .58.56 1.04-.04 1-.6.96-1.02.54-.98-.03-.94-.6-.52-1 .06-.98.62-.96 1-.54 1 0z'/%3E%3Cpath fill-opacity='0.07' fill='%2310231A' transform='translate(108 84) rotate(210) scale(7.5)' d='M1 0C1 .58.56 1.04-.04 1-.6.96-1.02.54-.98-.03-.94-.6-.52-1 .06-.98.62-.96 1-.54 1 0z'/%3E%3Cpath fill-opacity='0.07' fill='%2310231A' transform='translate(60 108) rotate(280) scale(7.5)' d='M1 0C1 .58.56 1.04-.04 1-.6.96-1.02.54-.98-.03-.94-.6-.52-1 .06-.98.62-.96 1-.54 1 0z'/%3E%3Cpath fill-opacity='0.07' fill='%2310231A' transform='translate(60 60) rotate(0) scale(7.5)' d='M1 0C1 .58.56 1.04-.04 1-.6.96-1.02.54-.98-.03-.94-.6-.52-1 .06-.98.62-.96 1-.54 1 0z'/%3E%3C/svg%3E");
  --spb-blush:      #FFC9B8;  /* error text on dark */

  /* ---------- Type ---------- */
  --spb-font-ui: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* Rounded where the platform has it (SF Pro Rounded on Apple). Echoes the wordmark. */
  --spb-font-display: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  /* Room codes and anything that must line up. */
  --spb-font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Roboto Mono", monospace;

  /* Scale: 17px base, ~1.25 steps. Hero and Bingo sizes flex with the viewport. */
  --spb-text-xs:    0.75rem;    /* 12  labels, uppercase, tracked */
  --spb-text-sm:    0.875rem;   /* 14  hints, footnotes */
  --spb-text-base:  1.0625rem;  /* 17  body */
  --spb-text-lg:    1.3125rem;  /* 21  lede */
  --spb-text-xl:    1.625rem;   /* 26  section heads */
  --spb-text-2xl:   2.0625rem;  /* 33  page heads */
  --spb-text-3xl:   clamp(2.25rem, 1.6rem + 3vw, 3.25rem);  /* hero */
  --spb-text-bingo: clamp(3rem, 1.75rem + 8vw, 6rem);       /* the BINGO moment */
  --spb-text-code:  clamp(1.75rem, 1.4rem + 2vw, 2.25rem);  /* room code */

  --spb-weight-regular: 400;
  --spb-weight-medium: 600;
  --spb-weight-bold: 750;
  --spb-weight-heavy: 850;
  --spb-weight-black: 900;

  --spb-leading-body: 1.55;
  --spb-leading-tight: 1.15;
  --spb-leading-flat: 1;

  --spb-tracking-label: 0.06em;  /* ADMIT ONE, eyebrows */
  --spb-tracking-bingo: 0.5em;   /* B I N G O header: letters sit in columns */
  --spb-tracking-code: 0.25em;   /* room code */
  --spb-tracking-head: -0.02em;

  /* ---------- Space, shape, depth ---------- */
  --spb-space-1: 0.25rem;
  --spb-space-2: 0.5rem;
  --spb-space-3: 0.75rem;
  --spb-space-4: 1rem;
  --spb-space-5: 1.5rem;
  --spb-space-6: 2rem;
  --spb-space-7: 3rem;
  --spb-space-8: 4rem;
  --spb-gutter: clamp(1rem, 4vw, 2.5rem);
  --spb-measure: 42rem;

  --spb-radius-cell: 4px;     /* a square on the card */
  --spb-radius-field: 12px;
  --spb-radius-ticket: 12px;
  --spb-radius-button: 14px;
  --spb-radius-panel: 18px;
  --spb-radius-pill: 999px;

  --spb-ticket-notch: 10px;   /* radius of the tear-line notches and corner cuts */
  --spb-stub-width: clamp(2.25rem, 1.5rem + 3vw, 3.25rem);  /* width of the ADMIT ONE stub */
  --spb-hit: 44px;            /* minimum touch target */
  --spb-button-height: 48px;

  --spb-focus-width: 3px;
  --spb-focus-offset: 3px;

  /* ---------- Motion ---------- */
  --spb-dur-instant: 0ms;
  --spb-dur-tap: 90ms;        /* press feedback */
  --spb-dur-fade: 140ms;      /* crossfades; survives reduced motion */
  --spb-dur-daub: 180ms;      /* a daub lands */
  --spb-dur-base: 220ms;      /* most state changes */
  --spb-dur-sheet: 320ms;     /* sheets, popups */
  --spb-dur-bingo-step: 70ms; /* stagger between the five winning squares */
  --spb-dur-stamp: 260ms;     /* the BINGO stamp lands */
  --spb-dur-hold: 1200ms;     /* how long the moment holds before the sheet */

  --spb-ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --spb-ease-in: cubic-bezier(0.4, 0, 1, 1);
  --spb-ease-inout: cubic-bezier(0.65, 0, 0.35, 1);
  --spb-ease-stamp: cubic-bezier(0.3, 1.45, 0.55, 1);  /* small overshoot, like a rubber stamp */
  --spb-stamp-scale: 1.18;    /* how big a daub or stamp starts before it lands */
  --spb-stamp-tilt: -6deg;

  /* ---------- Semantic: DARK (house default) ---------- */
  color-scheme: dark;
  --spb-bg: var(--spb-forest-900);
  --spb-bg-sunken: var(--spb-forest-950);
  --spb-surface: var(--spb-forest-800);
  --spb-text: var(--spb-foam);                 /* 11.55 on bg, 8.97 on surface, 13.78 on sunken */
  --spb-text-muted: var(--spb-sage-100);       /* 9.31 on bg, 7.23 on surface */
  --spb-text-subtle: var(--spb-sage-300);      /* 6.76 on bg, 5.25 on surface, 8.07 on sunken */
  --spb-placeholder: var(--spb-sage-400);      /* 5.50 on sunken (fields only; 3.58 on surface, avoid) */
  --spb-label: var(--spb-cream-label);         /* 8.64 on surface */
  --spb-accent: var(--spb-gold);               /* as text: 7.57 on bg, 5.88 on surface */
  --spb-accent-edge: transparent;
  --spb-on-accent: var(--spb-gold-ink);        /* 11.08 on gold */
  --spb-link: var(--spb-gold);                 /* 7.57 on bg */
  --spb-border: rgba(255, 255, 255, 0.22);     /* decorative dividers */
  --spb-border-strong: var(--spb-sage-600);    /* UI edges: 3.91 on bg, 3.03 on surface, 4.66 on sunken */
  --spb-focus: var(--spb-gold-glow);           /* 9.67 on bg, 7.50 on surface */
  --spb-danger-text: var(--spb-blush);         /* 8.49 on bg, 6.59 on surface */
  --spb-danger: var(--spb-brick);
  --spb-on-danger: var(--spb-white);           /* 9.48 on brick */
  --spb-pattern: var(--spb-pattern-on-dark);

  /* The ticket is the same paper in both themes. */
  --spb-ticket: var(--spb-cream);
  --spb-on-ticket: var(--spb-ink);             /* 17.43 on cream */
  --spb-ticket-edge: var(--spb-forest-900);    /* 15.55 against cream */
  --spb-ticket-stub: var(--spb-gold);
  --spb-on-stub: var(--spb-gold-ink);          /* 11.08 on gold */
  --spb-cell: var(--spb-white);
  --spb-on-cell: var(--spb-ink);               /* 18.42 on white */
  --spb-dauber: var(--spb-felt);
  --spb-dauber-disc: var(--spb-felt-disc);
  --spb-on-dauber: var(--spb-cream);           /* 11.54 on felt, 9.50 on the disc */
  --spb-win: var(--spb-gold);
  --spb-win-disc: var(--spb-gold-disc);
  --spb-on-win: var(--spb-gold-ink);           /* 11.08 on gold, 12.38 on the disc */

  --spb-shadow-paper: 0 1px 0 rgba(0, 0, 0, 0.25), 0 10px 24px -12px rgba(0, 0, 0, 0.6);
  --spb-shadow-sheet: 0 -8px 32px rgba(0, 0, 0, 0.45);
}

/* ---------- Semantic: LIGHT ---------- */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --spb-bg: var(--spb-cream);
    --spb-bg-sunken: var(--spb-cream-200);
    --spb-surface: var(--spb-white);
    --spb-text: var(--spb-forest-900);          /* 11.80 on bg, 12.47 on surface, 10.79 on sunken */
    --spb-text-muted: var(--spb-moss-700);      /* 7.15 on bg, 7.56 on surface, 6.54 on sunken */
    --spb-text-subtle: var(--spb-sage-450);     /* 5.12 on bg, 5.41 on surface, 4.69 on sunken */
    --spb-placeholder: var(--spb-sage-450);     /* 5.41 on white fields */
    --spb-label: var(--spb-brass);              /* 6.29 on bg, 6.65 on surface */
    --spb-accent: var(--spb-gold);              /* fill only on light; never as text (1.56 on cream) */
    --spb-accent-edge: var(--spb-brass);        /* 6.29 on bg: gives gold buttons an edge */
    --spb-on-accent: var(--spb-gold-ink);       /* 11.08 */
    --spb-link: var(--spb-felt);                /* 11.54 on bg, 12.20 on surface */
    --spb-border: rgba(16, 35, 26, 0.16);
    --spb-border-strong: var(--spb-sage-500);   /* 3.66 on bg, 3.87 on surface, 3.35 on sunken */
    --spb-focus: var(--spb-felt);               /* 11.54 on bg */
    --spb-danger-text: var(--spb-brick);        /* 8.97 on bg, 9.48 on surface */
    --spb-pattern: var(--spb-pattern-on-light);
    --spb-shadow-paper: 0 1px 0 rgba(16, 35, 26, 0.12), 0 10px 22px -14px rgba(16, 35, 26, 0.45);
    --spb-shadow-sheet: 0 -8px 28px rgba(16, 35, 26, 0.18);
  }
}

[data-theme="light"] {
  color-scheme: light;
  --spb-bg: var(--spb-cream);
  --spb-bg-sunken: var(--spb-cream-200);
  --spb-surface: var(--spb-white);
  --spb-text: var(--spb-forest-900);
  --spb-text-muted: var(--spb-moss-700);
  --spb-text-subtle: var(--spb-sage-450);
  --spb-placeholder: var(--spb-sage-450);
  --spb-label: var(--spb-brass);
  --spb-accent: var(--spb-gold);
  --spb-accent-edge: var(--spb-brass);
  --spb-on-accent: var(--spb-gold-ink);
  --spb-link: var(--spb-felt);
  --spb-border: rgba(16, 35, 26, 0.16);
  --spb-border-strong: var(--spb-sage-500);
  --spb-focus: var(--spb-felt);
  --spb-danger-text: var(--spb-brick);
  --spb-pattern: var(--spb-pattern-on-light);
  --spb-shadow-paper: 0 1px 0 rgba(16, 35, 26, 0.12), 0 10px 22px -14px rgba(16, 35, 26, 0.45);
  --spb-shadow-sheet: 0 -8px 28px rgba(16, 35, 26, 0.18);
}

[data-theme="dark"] {
  color-scheme: dark;
  --spb-bg: var(--spb-forest-900);
  --spb-bg-sunken: var(--spb-forest-950);
  --spb-surface: var(--spb-forest-800);
  --spb-text: var(--spb-foam);
  --spb-text-muted: var(--spb-sage-100);
  --spb-text-subtle: var(--spb-sage-300);
  --spb-placeholder: var(--spb-sage-400);
  --spb-label: var(--spb-cream-label);
  --spb-accent: var(--spb-gold);
  --spb-accent-edge: transparent;
  --spb-on-accent: var(--spb-gold-ink);
  --spb-link: var(--spb-gold);
  --spb-border: rgba(255, 255, 255, 0.22);
  --spb-border-strong: var(--spb-sage-600);
  --spb-focus: var(--spb-gold-glow);
  --spb-danger-text: var(--spb-blush);
  --spb-pattern: var(--spb-pattern-on-dark);
  --spb-shadow-paper: 0 1px 0 rgba(0, 0, 0, 0.25), 0 10px 24px -12px rgba(0, 0, 0, 0.6);
  --spb-shadow-sheet: 0 -8px 32px rgba(0, 0, 0, 0.45);
}

/* ---------- Reduced motion ----------
   Nothing moves, scales or tilts. State still changes, and short crossfades stay
   so a daub or a win is not a jump cut. The Bingo hold stays so people can read it. */
@media (prefers-reduced-motion: reduce) {
  :root {
    --spb-dur-tap: 0ms;
    --spb-dur-daub: 0ms;
    --spb-dur-base: 0ms;
    --spb-dur-sheet: var(--spb-dur-fade);
    --spb-dur-bingo-step: 0ms;
    --spb-dur-stamp: var(--spb-dur-fade);
    --spb-ease-stamp: linear;
    --spb-stamp-scale: 1;
    --spb-stamp-tilt: -6deg;
  }
}
