/*
 * Design tokens: the only place raw values live.
 *
 * Every colour, size, radius, border, shadow and timing used by the game is named here,
 * and the other stylesheets refer to these names only. To restyle the game, change a
 * token; to add a style, add a token first. The style guide (/styleguide.html) shows them.
 *
 * The look: a bold sticker poster. Flat primary colour blocks, thick black outlines and
 * hard offset shadows with no blur, chunky rounded type, and hand-drawn stickers.
 *
 * Two themes share every token name:
 *   :root          "poster" (phones): a saturated blue stage with a black wavy band
 *   .theme-cream   "cream" (the big screen): a warm paper stage, easy to read across a room
 * A page picks a theme with a class on <body>; any element can switch theme for its
 * subtree the same way (the style guide shows both side by side).
 *
 * Layers
 *   1. Palette   raw brand colours, never used directly by components
 *   2. Roles     what a colour means: stage, card, ink, outline, action, match, mine…
 *   3. Scales    space, radius, borders, shadows, type, control sizes, motion, layers
 */

:root {
  /* 1. Palette ------------------------------------------------------------------------ */
  --palette-blue: #1d5cff;
  --palette-blue-deep: #1247d1;
  --palette-blue-pale: #d6e2ff;
  --palette-black: #111;
  --palette-ink-soft: #4a4a55;
  --palette-cream: #fff8ee;
  --palette-paper: #f5eedf;
  --palette-sand: #ebe1cc;
  --palette-yellow: #ffd23f;
  --palette-green: #2bd47d;
  --palette-red: #ff4d4d;
  --palette-white: #fff;

  /* 2. Roles (poster theme, the default) ---------------------------------------------- */

  /* The stage everything sits on */
  --color-bg: var(--palette-blue);
  --color-bg-raised: var(--palette-blue-deep);
  --color-on-bg: var(--palette-white);
  --color-on-bg-soft: var(--palette-blue-pale);
  --color-band: var(--palette-black); /* the wavy band along the bottom of the stage */

  /* Cards on the stage */
  --color-surface: var(--palette-cream);
  --color-surface-sunken: var(--palette-sand);
  --color-field: var(--palette-white);
  --color-ink: var(--palette-black);
  --color-ink-soft: var(--palette-ink-soft);

  /* Every outline and every hard shadow */
  --color-line: var(--palette-black);

  /* Meaning */
  --color-accent: var(--palette-yellow); /* the main action to take */
  --color-on-accent: var(--palette-black);
  --color-highlight: var(--palette-yellow); /* a pair match (+3), the leader, the winner */
  --color-success: var(--palette-green); /* answered, a crowd match (+1), online */
  --color-danger: var(--palette-red); /* errors, removing a player, offline */
  --color-blank: var(--palette-red); /* the blank in the phrase */
  --color-mine: var(--palette-blue); /* my own row */
  --color-on-mine: var(--palette-white);
  --color-quiet: var(--palette-white); /* a neutral block: no match, chips, the timer track */
  --color-link: var(--palette-yellow); /* text links on the stage */

  /* Translucent layers */
  --tint-highlight-wash: rgb(255 210 63 / 35%);
  --scrim: rgb(17 17 17 / 60%);

  /* Confetti, read by js/ui/celebrate.js. A comma-separated list of colours. */
  --confetti-colors:
    var(--palette-yellow), var(--palette-green), var(--palette-red), var(--palette-white),
    var(--palette-blue);

  /* 3. Scales ------------------------------------------------------------------------- */

  /* Space */
  --space-1: 4px;
  --space-2: 6px;
  --space-3: 8px;
  --space-4: 10px;
  --space-5: 12px;
  --space-6: 14px;
  --space-7: 16px;
  --space-8: 18px;
  --space-9: 22px;
  --space-10: 28px;
  --space-11: 40px;

  /* Corners */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --radius-2xl: 30px;
  --radius-pill: 999px;

  /* Outlines: chunky and black, like a sticker */
  --border-sm: 2px;
  --border: 3px;
  --border-lg: 4px;

  /* Hard shadows: an offset block of the outline colour, never blurred */
  --shadow-offset-sm: 3px;
  --shadow-offset: 6px;
  --shadow-offset-lg: 9px;
  --shadow-sm: var(--shadow-offset-sm) var(--shadow-offset-sm) 0 var(--color-line);
  --shadow: var(--shadow-offset) var(--shadow-offset) 0 var(--color-line);
  --shadow-lg: var(--shadow-offset-lg) var(--shadow-offset-lg) 0 var(--color-line);
  --shadow-mine: var(--shadow-offset) var(--shadow-offset) 0 var(--color-mine);
  --ring-mine: 0 0 0 var(--border-lg) var(--color-mine);

  /* A slight tilt, so banners and badges look stuck on by hand */
  --tilt-sm: -1.5deg;
  --tilt: -4deg;
  --tilt-lg: -8deg;

  /* Type: Playpen Sans Arabic, rounded and playful, with system fallbacks */
  --font-body: 'Playpen Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Playpen Sans Arabic', system-ui, sans-serif;
  --font-mono: ui-monospace, sfmono-regular, menlo, monospace;
  --font-size-base: 17px;
  --font-size-field: 18px;
  --font-size-answer: 20px;
  --line-height: 1.5;
  --line-height-tight: 1.25;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-bold: 700;
  --weight-heavy: 800;

  /* Controls: big enough for thumbs */
  --control-height: 50px;
  --control-height-sm: 40px;
  --field-height: 52px;
  --tap-min: 44px;

  /* Motion. CSS timings here; the springs and staggers live in js/ui/motion.js (MOTION). */
  --duration-press: 0.08s;
  --duration-quick: 0.15s;
  --duration-base: 0.25s;
  --duration-float: 6s; /* one slow bob of an idle sticker */
  --duration-spin: 18s; /* one full turn of a spinning sticker */
  --duration-look: 5s; /* the cartoon eyes looking around */
  --ease: ease;
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --float-distance: 10px;

  /* Layers */
  --z-stage: 0; /* the wavy band and the stickers, behind everything */
  --z-content: 1;
  --z-bar: 5;
  --z-toast: 50;
  --z-confetti: 100;

  /* Fixed sizes of small parts */
  --logo-width: 84px; /* the two overlapping circles */
  --logo-height: 60px;
  --logo-dot: 50px;
  --logo-dot-top: 4px;
  --logo-width-sm: 40px; /* the small logo in a bar */
  --logo-height-sm: 28px;
  --logo-dot-sm: 24px;
  --logo-dot-top-sm: 2px;
  --status-dot: 14px; /* the connection dot */
  --timer-track-height: 18px;
  --points-badge: 54px; /* the round +3 / +1 badge on an answer card */
  --row-min-height: 48px; /* a scoreboard row */
  --sticker-text: 34px; /* text inside a sticker's 0-200 SVG box, scaled with the sticker */

  /* Sticker sizes on a phone (the big screen sizes them from the viewport, in tv.css) */
  --sticker-xs: 44px;
  --sticker-sm: 50px;
  --sticker-md: 60px;
  --sticker-lg: 72px;
  --sticker-xl: 100px;
  --sticker-2xl: 130px;
  --sticker-bleed: -20px; /* how far an edge sticker hangs off the screen */

  /* The big screen. Text is sized by the smaller of width and height, so a wide TV and a
     16:10 laptop both fit the whole game on one screen; everything else there is in em. */
  --tv-font: clamp(12px, min(1.6vw, 2.85vh), 34px);
  --tv-board-width: minmax(14em, 26vw); /* the scoreboard column, up to 12 players */
  --tv-board-width-wide: minmax(24em, 40vw); /* two columns of rows, 13 players and up */

  /* Layout */
  --page-max: 560px;
  --page-gutter: var(--space-7);
  --band-height: 26vh;
  --wave-height: 22px;
}

/* The cream theme: the big screen. Only roles change; scales stay the same. */
.theme-cream {
  --color-bg: var(--palette-paper);
  --color-bg-raised: var(--palette-sand);
  --color-on-bg: var(--palette-black);
  --color-on-bg-soft: var(--palette-ink-soft);
  --color-band: transparent;
  --color-surface: var(--palette-white);
  --color-quiet: var(--palette-white);
  --color-link: var(--palette-blue);
}
