/*
  SNAFFLE — ART DIRECTION: "TORCHLIGHT"

  The idea. A cheeky night raid, caught in a warm torch beam. The table is a deep plum
  stage; everything you play with glows on it: butter-cream tiles, a gold torch, bright
  player colours. Brightness and warmth come from the pieces, not from a pale page, which
  is also what keeps forty small tiles readable at a glance.

  Palette. Plum (stage), butter (tiles), gold "sun" (the one primary action, the torch,
  and the brand), coral (steals, warnings), mint (good news). No greys: shadows and
  borders are darker or lighter plum, tile edges are toffee. Gold, coral and mint carry
  meaning and are never a player's colour; the four player colours (lime, violet, pink,
  sky) are never used to mean anything else.

  Shape and depth. Chunky, rounded, pressable. Depth is a solid "lip" under a piece (the
  tile's thickness) plus one soft plum shadow; never an outline, a bevel, a texture or a
  gradient sheen. Anything you can press has a lip and sinks onto it when pressed. Flat
  things (text buttons, captions) have none.

  Type. One family, Fredoka (bundled, OFL): rounded terminals that echo the tile corners,
  wide open capitals that stay legible at 16 px on a 24 px tile. Bold for tile letters and
  buttons, semi-bold for labels, medium for sentences. Sentence case everywhere; capitals
  are for tile letters and for words from the game.

  Character. The mascot is a plum raccoon-ish thief in a bandit mask, usually caught in
  the act with a tile. It appears on a torch-coloured disc or dome; so do the three
  practice bots (Pip, Nib, Vix), drawn on the same squarish, tile-like head. Faces are
  flat shapes, no outlines, eyes that look at what they are after.

  Motion. Quick and physical: pieces pop, press and land with a small overshoot; nothing
  drifts or loops for decoration. Reduced motion keeps the fades and drops the travel.

  Voice. Plain, short, a little cheeky. Say what a button does.

  Rules for later screens.
  - Every colour, radius, shadow, size of type and timing comes from this file.
  - Ownership is never colour alone: each player colour has a matching mark (a shape) and
    is shown with a name. Use --player-N on the stage, --player-N-strong against a tile,
    --player-N-face as a tinted tile face (tile ink on top).
  - Gold "sun" means "the main thing to press here"; one per screen. Coral means a
    warning or a loss, mint means good news; say it in words or an icon as well, because
    to someone with red-green colour blindness gold, coral and lime are all yellows.

  Two places repeat colours from this file because they cannot read tokens. Change them
  together with the token:
  - public/icon.svg (the app icon): --sun, --fur, --fur-deep, --fur-pale, --blush, --ink,
    --eye, and the mascot's drawing, which is a copy of #face-snaffle in index.html.
  - <meta name="theme-color"> in public/index.html: --stage.
*/

@font-face {
  font-family: "Fredoka";
  src: url("../fonts/fredoka-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* --- Colour: stage and surfaces ------------------------------------------------- */
  --stage-glow: #56215f;        /* the lit top of the stage */
  --stage: #3a1543;             /* the page */
  --stage-deep: #32113b;        /* the unlit bottom of the stage */
  --well: #230a2b;              /* sunk into a surface: tracks of meters and switches; darker than any part of the stage */
  --panel: #4e1f5a;             /* raised surfaces on the stage: cards, secondary buttons */
  --panel-lip: #170620;         /* the lip under a panel piece: darker than any part of the stage, so it shows wherever the piece sits */
  --panel-up: #5d2a6a;          /* a panel under the finger, selected rows */
  --panel-edge: #7a418a;        /* hairline separators on a panel */
  --ink: #2a0f33;               /* text and shapes on light surfaces */
  --scrim: rgba(27, 6, 33, 0.66);

  /* --- Colour: text on the stage (contrast on --stage / on --panel) --------------- */
  --text: #fff6e5;              /* 14.3 / 11.7 */
  --text-soft: #d9c2e0;         /* 9.3 / 7.6: captions, secondary lines */
  --text-faint: #b99ac4;        /* 6.2 / 5.1: disabled labels, hints */

  /* --- Colour: tiles -------------------------------------------------------------- */
  --tile-face: #fff4dc;
  --tile-lip: #e2b46c;
  --tile-ink: #2a0f33;          /* 16.1 on the face */
  --tile-slot: rgba(27, 6, 33, 0.45);   /* where a tile was, or will be */

  /* --- Colour: accents ------------------------------------------------------------ */
  --sun: #ffc531;               /* the primary action; 9.7 on the stage, ink on it 10.9 */
  --sun-lip: #c98a12;
  --sun-ink: #2a0f33;
  --torch: #ffe08a;             /* the torch beam and portrait discs */
  --torch-rim: #ffc531;
  --torch-ink: #c98a12;         /* marks drawn on the torch */
  --coral: #ff6652;             /* steals, warnings; 5.3 on the stage */
  --coral-lip: #b3202e;
  --mint: #7be8c4;              /* success; 10.4 on the stage */
  --mint-lip: #1f9a80;
  --focus: #ffffff;

  /* --- Colour: the cast ----------------------------------------------------------- */
  --fur: #7a3b8c;
  --fur-deep: #5a2468;
  --fur-pale: #fff4dc;
  --blush: #ff8a76;
  --eye: #ffffff;
  --pip: #f2b880;               /* Pip, the easy bot */
  --pip-deep: #d9945a;
  --nib: #a3b4f2;               /* Nib, the medium bot */
  --nib-deep: #7f92e0;
  --vix: #ff7f47;               /* Vix, the hard bot */
  --vix-deep: #d95a2b;

  /* --- Colour: players --------------------------------------------------------------
     Lime, violet, pink, sky: four hues kept clear of the colours that carry meaning (gold,
     coral, mint; nearest are lime to gold and lime to mint, OKLab difference 13) and of each other.
     Smallest difference between any two players: 17 with full colour vision, 10 with
     protanopia, 9 with deuteranopia, 13 with tritanopia (Machado simulation); the first
     two, which every two-player game uses, differ by 36 or more in every case except
     tritanopia (19). Hue alone cannot do better for four, so each colour has a mark and
     is shown with a name.
       --player-N          on the stage: tags, bars, lanes (on --stage 11.0 / 5.5 / 6.9 / 8.1,
                           on --panel 9.0 / 4.5 / 5.7 / 6.6)
       --player-N-strong   against a tile face: lips, rings, marks (3.8 / 6.1 / 4.3 / 3.6;
                           apart by 17 full vision, 13 protan, 10 deutan, 8 tritan)
       --player-N-face     a tinted tile face (tile ink on it: 12.5:1 or more)
       --player-N-mark     the shape, as a mask image: circle, diamond, triangle, plus
     Text on --player-N is --ink (12.4 / 6.2 / 7.8 / 9.1).                               */
  --player-1: #b4ec51;          /* lime */
  --player-1-strong: #5c8a00;
  --player-1-face: #e6f7b0;
  --player-1-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7'/%3E%3C/svg%3E");
  --player-2: #a288ff;          /* violet */
  --player-2-strong: #5f3ed6;
  --player-2-face: #e0d6ff;
  --player-2-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 .5 15.5 8 8 15.5.5 8z'/%3E%3C/svg%3E");
  --player-3: #ff86c8;          /* pink */
  --player-3-strong: #c93a8a;
  --player-3-face: #ffd6ec;
  --player-3-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1.5 15.5 14.5H.5z'/%3E%3C/svg%3E");
  --player-4: #52c8ff;          /* sky */
  --player-4-strong: #1c84d8;
  --player-4-face: #cdeaff;
  --player-4-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M5.5 1h5v4.5H15v5h-4.5V15h-5v-4.5H1v-5h4.5z'/%3E%3C/svg%3E");

  /* --- Type ----------------------------------------------------------------------- */
  --font: "Fredoka", ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", system-ui, sans-serif;
  --text-xs: 0.8125rem;         /* 13: captions */
  --text-s: 0.9375rem;          /* 15: secondary lines */
  --text-m: 1.0625rem;          /* 17: sentences, rows */
  --text-l: 1.3125rem;          /* 21: button labels, titles of rows */
  --text-xl: 1.625rem;          /* 26: screen titles */
  --text-2xl: 2.125rem;         /* 34: the primary button */
  --weight-body: 500;
  --weight-prose: 400;          /* running text (the legal pages, Settings' About), a step lighter */
  --weight-label: 600;
  --weight-display: 700;
  --leading-flat: 1;            /* a single letter on a tile */
  --leading-display: 1.05;      /* the largest type */
  --leading-tight: 1.1;         /* titles and button labels */
  --leading-snug: 1.25;         /* captions and second lines */
  --leading-body: 1.4;          /* sentences */
  --text-long: 1rem;            /* 16: long reading (the privacy and support pages) */
  --leading-long: 1.35;         /* its line height */
  /* A tile's letter is this share of the tile's size (16 px on a 24 px tile). */
  --tile-letter: 0.667;

  /* --- Space and size --------------------------------------------------------------- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 28px;
  --space-7: 40px;
  --gutter: 20px;               /* side padding of a screen */
  --column: 440px;              /* widest a phone layout grows on a tablet or desktop */
  --column-tall: 880px;
  --column-wide: 520px;         /* Home and the results on a desk (a mouse, a wide screen) */
  --column-results: 680px;      /* the results on a desk: a wider column, so the recap tiles can grow */
  --column-game: 680px;         /* the game's column on a desk: tiles and top bar grow with it */
  --column-prose: 616px;        /* the privacy and support pages on a wide screen: about 68 characters a line */
  --tap: 44px;                  /* smallest touch target */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  /* --- Shape and depth -------------------------------------------------------------- */
  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 22px;
  --radius-pill: 999px;
  --radius-round: 50%;
  --tile-radius: 0.24;          /* share of the tile's size */
  --tile-lip-depth: 0.13;       /* share of the tile's size */
  --lip-xs: 2px;                /* under a switch's knob */
  --lip-s: 3px;
  --lip-m: 5px;
  --lip-l: 7px;
  --lip-down: 1px;              /* what is left of a lip while its piece is pressed */
  --ring: 3px;                  /* the focus ring, and the ring round a chosen card */
  --rule: 2px;                  /* a dividing line */
  --shadow-soft: 0 10px 22px rgba(20, 4, 26, 0.38);     /* under a piece resting on the stage */
  --shadow-float: 0 -10px 44px rgba(20, 4, 26, 0.55);   /* under a sheet or a piece in flight */
  --shadow-flight: 0 9px 7px rgba(20, 4, 26, 0.45);     /* under a tile in the air (a drop-shadow) */

  /* --- Motion -----------------------------------------------------------------------
     Scripts read these too (the game's fx.js, hud.js, table.js and input.js), so a timing
     lives here even when no stylesheet uses it. Keep them plain times in ms. */
  --motion-press: 40ms;         /* a key or button going down: under 50 ms */
  --motion-tick: 45ms;          /* one step of a score counting up or down */
  --motion-quick: 120ms;        /* small state changes: toggles, fades; the least a key's pop shows for */
  --motion-settle: 220ms;       /* a piece landing, a sheet arriving, your own word snapping into your lane */
  --motion-flip: 250ms;         /* a tile turning over: never longer */
  --motion-claim: 340ms;        /* someone else's word hopping from the pool into their lane */
  --motion-steal: 600ms;        /* the steal flight */
  --motion-flash: 700ms;        /* a score, or a word that has just landed, flashing once */
  --motion-entrance: 520ms;     /* a screen's one opening flourish */
  --motion-stagger: 110ms;      /* the gap between pieces that move one after another */
  --motion-loop: 1100ms;        /* one round of a waiting animation */
  --hold-line: 3000ms;          /* how long the event line and a word's "new" marker stay */
  --hold-ghost: 1700ms;         /* a taken word fading out where it was: gone before the lane tidies */
  --hold-coach: 2600ms;         /* the lesson: how long a passing remark stays before the coach says what to do next */
  --hold-handoff: 4500ms;       /* the lesson: how long its last sheet waits before it moves on by itself */
  --hold-note: 6000ms;          /* a one-line note on Home (a room that ended under the player) */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in: cubic-bezier(0.8, 0, 0.8, 0.2);            /* its mirror: a piece falling back to the table */
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);        /* lands with a small overshoot */
  --travel: 1;                  /* multiply distances by this: 0 under reduced motion */
  --hover-bright: 1.07;         /* how much a pressable thing brightens under a mouse */

  /* --- Layers ----------------------------------------------------------------------- */
  --layer-overlay: 5;           /* over a view's own content, under any sheet: the reconnecting card */
  --layer-sheet: 10;
  --layer-rotate: 20;
}

/* Reduced motion: the system setting, unless Settings says otherwise (data-motion is set by
   app.js to "reduced" or "full"). Travel stops; flights and flips become short fades. */
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) {
    --motion-flip: 120ms;
    --motion-steal: 150ms;
    --motion-claim: 120ms;
    --motion-settle: 120ms;
    --motion-entrance: 1ms;
    --ease-pop: ease-out;
    --travel: 0;
  }
}

:root[data-motion="reduced"] {
  --motion-flip: 120ms;
  --motion-steal: 150ms;
  --motion-claim: 120ms;
  --motion-settle: 120ms;
  --motion-entrance: 1ms;
  --ease-pop: ease-out;
  --travel: 0;
}
