/* ==========================================================================
   Design tokens: the only place colours, radii, shadows, spacing and type
   sizes are defined. Component stylesheets use var(--…) only; a raw hex
   anywhere else is a bug.

   Contrast ratios (WCAG, measured) are noted next to every text/background
   pair. Anything new gets checked and its number recorded here.
   ========================================================================== */

:root {
  /* Activity presentation. */
  --reading-surface: #fff6de;
  --activity-border: #a8bcd4;
  --activity-surface: #f1f7ff;
  --activity-pressed: #d8e7ff;
  --block-border: #2976aa;
  --block-surface: #c4e6ff;
  --block-large-surface: #e1d0ff;
  --block-large-border: #8554b8;
  --pattern-surface: #edf2f7;
  --pattern-changed-surface: #ffedb9;
  --pattern-changed-border: #b67900;

  /* English activities (css/english.css). Tile text is --color-text:
     13.2:1 on tile, 12.7:1 on placed, 12.9:1 on slot, 12.2:1 on subject-soft;
     "Recording…" (--eng-record) is 6.5:1 on white. */
  --eng-subject: #1f9e8e;          /* the English colour on the map */
  --eng-subject-soft: #d6f3ee;
  --chinese-subject: #d4483b;
  --eng-tile: #fff6dc;
  --eng-tile-border: #e9b949;
  --eng-tile-placed: #e3f6ea;
  --eng-tile-placed-border: #34b36a;
  --eng-row: #ffffff;
  --eng-row-border: #b9c6da;
  --eng-slot: #f6f2ff;
  --eng-slot-border: #8a5cf6;
  --eng-glow: #ffcc29;
  --eng-bubble: #ffffff;
  --eng-record: #b3261e;
  /* Reading. Sound buttons are teal dots and dashes; tricky words are red
     (6.5:1 on white), as many phonics schemes colour them. A passage is on
     cream paper (text 13.9:1); a sentence picked as evidence is
     highlighter yellow (text 12.6:1). */
  --eng-sound-mark: #1f9e8e;
  --eng-tricky: #b3261e;
  --eng-paper: #fffdf5;
  --eng-paper-border: #eadfc4;
  --eng-evidence: #fff09a;
  /* Scene backgrounds: decorative only, no text on them. */
  --eng-sky: #cdeeff;
  --eng-sky-pale: #e8f6ff;
  --eng-grass: #9fdc8a;
  --eng-grass-dark: #7cc576;
  --eng-wall: #fff1dc;
  --eng-wall-cool: #eaf6f2;
  --eng-wall-lilac: #ece4ff;
  --eng-wall-sun: #fff6d6;
  --eng-floor: #e7c9a3;
  --eng-floor-grey: #cfd8e3;
  --eng-sand: #f6dfa6;
  --eng-sea: #6cc4e8;
  --eng-pool: #8fd8f0;
  --eng-snow: #f7fbff;
  --eng-snow-sky: #dbe9fb;
  --eng-rain-sky: #b8c4d4;
  --eng-rain-ground: #a8c49a;
  --eng-night: #1f2a55;
  --eng-night-low: #3d4a85;
  --eng-road: #8d96a3;
  --eng-party: #ffe6f1;
  --eng-party-dot: #ffc4dd;
  --eng-stage: #fff1d9;
  --eng-curtain: #df9fc4;
  --eng-field: #c8e08a;

  /* --- Surfaces ---------------------------------------------------------- */
  --color-sky-top: #bfe6ff;
  --color-sky-bottom: #eaf7ff;
  --color-grass: #7fd37a;
  --color-grass-dark: #5bb85a;
  --color-surface: #ffffff;
  --color-surface-tint: #f4f0ff;
  --color-border: #d9e2ef;
  --color-border-strong: #b9c6da;
  --color-scrim: rgba(31, 42, 68, .55);

  /* --- Text -------------------------------------------------------------- */
  --color-text: #1f2a44;        /* 14.3:1 on surface, 10.9:1 on sky-top */
  --color-text-muted: #4b5873;  /* 7.1:1 on surface, 6.4:1 on surface-tint */
  --color-on-primary: #ffffff;  /* 6.3:1 on primary */

  /* --- Brand ------------------------------------------------------------- */
  --color-primary: #6a3fd9;
  --color-primary-dark: #4c27a8;
  --color-primary-text: #5a32c4; /* 6.5:1 on primary-soft */
  --color-primary-soft: #ede6ff;

  /* --- Status (text colour darkened to clear 4.5:1 on its -soft pair) ---- */
  --color-success: #1c7a43;      /* 4.7:1 on success-soft */
  --color-success-soft: #dcf5e6;
  --color-success-ring: #34b36a;
  --color-warning: #8a5300;      /* 5.6:1 on warning-soft */
  --color-warning-soft: #fff0c7;
  --color-danger: #b3261e;       /* 5.4:1 on danger-soft */
  --color-danger-soft: #fde3e0;

  /* --- Game accents ------------------------------------------------------ */
  --color-sun: #ffcc29;          /* text on sun: 9.5:1 */
  --color-sun-dark: #d99a00;
  --color-stone: #9aa7bd;
  --color-stone-dark: #6f7d96;
  --color-dot: #6a3fd9;
  --color-dot-soft: #cdbfff;
  --frame: #ffffff;

  /* Clara's warm rainbow, from thecreativeclara.com. Decorative (stripes,
     map lands, chart bars); text never sits on these without a white pill. */
  --rainbow-red: #ff6b6b;
  --rainbow-orange: #ff9f43;
  --rainbow-yellow: #ffd166;
  --rainbow-green: #8bd17c;
  --rainbow-blue: #4fc3e8;
  --rainbow-purple: #b98beb;
  --rainbow: linear-gradient(90deg, var(--rainbow-red), var(--rainbow-orange), var(--rainbow-yellow), var(--rainbow-green), var(--rainbow-blue), var(--rainbow-purple));
  --cream: #fff7ec;
  --ink: #4a2c2a;               /* 12.6:1 on cream, 13.6:1 on white */

  /* Map lands (css/map-screen.css): sky and ground of each land. */
  --land-rainbow-1: #dff3ff;
  --land-rainbow-2: #ffe9f3;
  --land-paint-1: #fff1dc;
  --land-paint-2: #ffd9c2;
  --land-piano-1: #e5ecff;
  --land-piano-2: #cfd9ff;
  --land-moon-1: #26326b;
  --land-moon-2: #3d2f73;
  --land-movie-1: #4a2659;
  --land-movie-2: #6b2348;
  --land-paper-1: #fff9d6;
  --land-paper-2: #e6f7d8;
  --land-bricks-1: #dff1ff;
  --land-bricks-2: #c9ecc4;
  --land-corgi-1: #fff3d6;
  --land-corgi-2: #cdeeb6;
  --land-bamboo-1: #e8f8df;
  --land-bamboo-2: #bfe5b0;
  --land-crayon-1: #ffe9d1;
  --land-crayon-2: #f7c9a3;
  --land-lab-1: #e3f4ff;
  --land-lab-2: #d4e4ff;
  --land-story-1: #f2f7dc;
  --land-story-2: #d9ecc0;
  --land-comic-1: #fff6c2;
  --land-comic-2: #ffd9e6;
  --land-sunset-1: #ffd1b8;
  --land-sunset-2: #ffe9b3;
  --land-sea-1: #c9efff;
  --land-sea-2: #7fd3f2;
  --land-castle-1: #e9ddff;
  --land-castle-2: #ffd9f0;
  --land-tea-1: #fff0f5;
  --land-tea-2: #ffe0e9;
  --land-sky-1: #bfe6ff;
  --land-sky-2: #eaf7ff;
  --land-space-1: #1d1b4a;
  --land-space-2: #3a1f5c;
  --land-summit-1: #fff4c7;
  --land-summit-2: #ffe1f0;
  --road: #ffffff;
  --road-done: var(--color-sun);

  /* Method pictures (css/methods.css). Place value columns use the
     classroom colours: thousands, hundreds, tens, ones. */
  --pv-th: #8a5cf6;
  --pv-h: #3ea8ff;
  --pv-t: #34b36a;
  --pv-o: #ff8a3d;
  --method-line: #1f2a44;
  --method-part-a: #cdbfff;
  --method-part-b: #ffe29a;
  --method-part-c: #bdeccb;
  --method-unknown: #ffffff;
  /* Confetti palette, read from JS (js/ui/celebrate.js) so it stays here. */
  --confetti-1: #ff5c8a;
  --confetti-2: #ffcc29;
  --confetti-3: #34b36a;
  --confetti-4: #3ea8ff;
  --confetti-5: #8a5cf6;
  --confetti-6: #ff8a3d;
  /* Overwritten per screen from config.characters[...].color. Decorative
     only (borders, glows), never a text background, because the config
     colour is unchecked for contrast. */
  --player-color: var(--color-primary);

  /* --- Sticker shop (css/shop.css) ----------------------------------------
     Sticker art is decorative: no text sits on these colours, except the
     pairs with a ratio noted. */
  --sticker-edge: #ffffff;               /* the die-cut white border */
  --sticker-shadow: rgba(74, 44, 42, .28);
  --sticker-gloss: rgba(255, 255, 255, .55);
  --sticker-rare: #8a5cf6;               /* ring round a rare sticker */
  /* A narrow rainbow glint (drawn at 300% width and swept across). */
  --holo: linear-gradient(115deg, transparent 43%, rgba(255, 107, 107, .42) 45%, rgba(255, 209, 102, .42) 47.5%, rgba(139, 209, 124, .42) 50%, rgba(79, 195, 232, .42) 52.5%, rgba(185, 139, 235, .42) 55%, transparent 57%);
  --shop-wall-dot: rgba(255, 159, 67, .18);
  --shelf: #e9b97f;
  --shelf-dark: #c98e4f;
  --shelf-back: rgba(255, 255, 255, .55);
  --book-cover: #e8d5bd;
  --book-cover-dot: rgba(74, 44, 42, .08);
  --book-paper: #ffffff;
  --book-dot: rgba(74, 44, 42, .1);
  --book-spine: #d2b48f;
  --book-slot: #cdb79c;
  --ray: rgba(255, 204, 41, .32);
  --gold-1: #ffe27a;
  --gold-2: #f5b82e;
  --gold-3: #c98a0b;
  --gold-shine: rgba(255, 255, 255, .7);
  --gold-ink: #5b3a00;                   /* 8.0:1 on gold-1, 5.7:1 on gold-2 */

  /* Sticker discs, by theme (js/data/shop.js → art.theme). Pale behind the
     drawn characters so they pop; dark only for night-time scenes. */
  --st-mickey-ray-a: #ffe680;
  --st-mickey-ray-b: #ffd447;
  --st-minnie-pink: #ffc6df;
  --st-goofy-sky: #c4ecff;
  --st-goofy-ray: #e2f6ff;
  --st-donald-sky: #cdeeff;
  --st-donald-sea: #7ccbf5;
  --st-daisy-lilac: #eadcff;
  --st-daisy-dot: rgba(255, 255, 255, .75);
  --st-pluto-sky: #d8f3ff;
  --st-pluto-grass: #a8e38c;
  --st-cruise-night: #1d2b64;
  --st-cruise-sea: #2b7fd6;
  --st-pirate: #1e4e5a;
  --st-coaster-sky: #8fd8ff;
  --st-coaster-grass: #9be27f;
  --st-legoland-sky: #a7e0ff;
  --st-legoland-grass: #5dbb63;
  --st-bricks-sky: #e3f4ff;
  --st-bricks-plate: #4caf50;
  --st-mystery: #efe4ff;
  --st-mystery-dot: rgba(155, 108, 240, .16);
  --st-mystery-mark: #b48cf5;
  --st-corgi-mint: #c9f2dc;
  --st-corgi-mint-dot: rgba(46, 158, 91, .18);
  --st-corgi-pink: #ffd6ea;
  --st-corgi-lilac: #e7d8ff;
  --st-corgi-sky: #d9f1ff;
  --st-peppa-sky: #c4ebff;
  --st-peppa-hill: #8fd46a;
  --st-george: #d4efff;
  --st-george-dot: rgba(63, 134, 240, .14);
  --st-puddle-sky: #d6e6f5;
  --st-daddy-ray-a: #ffe9c2;
  --st-daddy-ray-b: #ffdca0;
  --st-gabby-lilac: #f0e2ff;
  --st-gabby-dot: rgba(255, 143, 192, .3);
  --st-cakey-mint: #d2f5e6;
  --st-mercat-sea: #bfeef0;
  --st-mercat-deep: #8fd9e3;
  --st-fairy-pink: #ffe0ef;
  --st-dollhouse: #e9dcff;
  --st-dogman-ray-a: #d9efff;
  --st-dogman-ray-b: #b8e0ff;
  --st-petey: #e6dcf7;
  --st-petey-dot: rgba(120, 90, 180, .18);
  --st-lil-petey: #fff2c4;
  --st-lil-petey-dot: rgba(255, 154, 46, .22);
  --st-robot: #e3ecf7;
  --st-robot-grid: rgba(63, 134, 240, .16);
  --st-mummy-pig: #ffe7cc;
  --st-mummy-dot: rgba(255, 154, 46, .2);
  --st-dino: #e4f7d6;
  --st-dino-dot: rgba(67, 185, 104, .18);
  --st-teddy: #fff0dc;
  --st-teddy-dot: rgba(201, 137, 80, .18);
  --st-gabby-pink: #ffe3f1;
  --st-baby-box: #fff4e0;
  --st-dj-a: #e6dcff;
  --st-dj-b: #d5c6ff;
  --st-chief-a: #ffe2d6;
  --st-chief-b: #ffcdb8;
  --st-flippy-sea: #cfeefa;
  --st-flippy-deep: #9fdaf2;
  --st-zuzu: #ffe6f0;
  --st-molly: #e9f9e4;
  --st-molly-psy: rgba(154, 108, 240, .45);

  /* Drawn stickers (js/ui/stickerDrawings.js): one kawaii palette with a
     soft dark outline, shared by the corgis, Disney friends and adventures. */
  --art-ink: #3b2a28;
  --art-line: 2.3px;                     /* outline, in the 100-unit drawing box */
  --art-white: #ffffff;
  --art-cream: #fff3dc;
  --art-gloss: rgba(255, 255, 255, .6);
  --art-blush: rgba(255, 110, 140, .45);
  --art-mouth: #b2333f;
  --art-tongue: #ff7d96;
  --art-skin: #ffd9b8;
  --art-hair: #4a2f24;
  --art-fur: #f6a24f;
  --art-ear: #ffc4b5;
  --art-pluto: #ffc23d;
  --art-pluto-light: #ffe3a3;
  --art-black: #2f2c36;
  --art-red: #ef3e42;
  --art-pink: #ff8fc0;
  --art-yellow: #ffd23f;
  --art-gold: #ffbc1f;
  --art-orange: #ff9a2e;
  --art-green: #43b968;
  --art-blue: #3f86f0;
  --art-sky: #8fd6ff;
  --art-navy: #253a78;
  --art-purple: #9a6cf0;
  --art-lilac: #d6c2ff;
  --art-grey: #b8bfcc;
  --art-brown: #9a6038;
  --art-wood: #c98950;
  --art-wood-dark: #7a4a2c;
  --art-gem-pink: #ff6fae;
  --art-gem-blue: #4fd1ff;
  --art-moon: #fff1b8;
  --art-track: #ff5a7a;
  --art-track-tie: #8a6a5a;
  --art-pig: #ffb4c8;
  --art-pig-dark: #f27aa0;
  --art-teal: #2dbfa8;
  --art-tabby: #f7c25e;
  --art-bunny: #e9c79f;
  --art-dog: #d9a46b;
  --art-pony: #efd29a;
  --art-poodle: #dcd8e2;

  /* --- Shape ------------------------------------------------------------- */
  /* Rounder than a typical app on purpose: soft shapes read as friendly and
     "tappable" to young children. */
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --radius-pill: 999px;
  --shadow-card: 0 6px 20px rgba(31, 42, 68, .12);
  --shadow-press: 0 6px 0 var(--color-border-strong);

  /* --- Space ------------------------------------------------------------- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* --- Touch ------------------------------------------------------------- */
  /* The brief asks for 60px minimum; small fingers miss less at 72. */
  --tap-min: 72px;
  --tap-small: 60px;

  /* --- Type -------------------------------------------------------------- */
  /* Big on purpose: an 8-year-old at arm's length from an iPad. ui-rounded
     is SF Pro Rounded on Apple devices, which needs no font download (so it
     works offline); other platforms fall back to their system font. */
  --font-body: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  --font-size-sm: 1rem;
  --font-size-base: 1.25rem;
  --font-size-md: 1.6rem;
  --font-size-lg: 2.25rem;
  --font-size-xl: clamp(2.6rem, 8vmin, 5rem);   /* the question */
  --font-size-answer: clamp(2rem, 6vmin, 3.4rem);

  /* --- Motion ------------------------------------------------------------ */
  /* Reduced-motion users get slower, calmer animation rather than none: a
     celebration that silently doesn't happen reads as "nothing happened". */
  --motion-scale: 1;

  /* --- Container units ----------------------------------------------------
     1% of the nearest container's width / height (golden tickets, shop
     shelves). Written as var(--cqw) rather than 1cqw so iOS
     15.3, which lacks these units, can use the px values js/compat.js
     measures instead. Kept as tokens here, so each use resolves against its
     own container. */
  --cqw: 1cqw;
  --cqh: 1cqh;
}

@media (prefers-reduced-motion: reduce) {
  :root { --motion-scale: 2.5; }
}

/* --- Phones ----------------------------------------------------------------
   Every screen has a phone layout at the bottom of its stylesheet, under the
   same two queries: narrow = a phone held upright, short = a phone on its
   side. iPads (744px and up both ways) never match either.
     (max-width: 600px), (max-height: 500px)            any phone
     (max-width: 600px) and (orientation: portrait)     upright
     (max-height: 500px) and (orientation: landscape)   on its side
   A phone is held closer than an iPad, so type and padding shrink. Taps
   stay at Apple's 44pt minimum or above (answers are much bigger). */
@media (max-width: 600px), (max-height: 500px) {
  :root {
    --space-5: 16px;
    --space-6: 20px;
    --space-7: 28px;
    --tap-min: 52px;
    --tap-small: 48px;
    --font-size-sm: .9rem;
    --font-size-base: 1.05rem;
    --font-size-md: 1.3rem;
    --font-size-lg: 1.7rem;
    --font-size-xl: clamp(1.8rem, 8vmin, 2.8rem);
    --font-size-answer: clamp(1.6rem, 8vmin, 2.4rem);
    --radius-lg: 22px;
  }
}
