/* tokens.css
 *
 * The design contract for the Bangkok flood map. Instrument register: people
 * trying to get something done, fast, on a phone, stressed, maybe standing in
 * water. The map is the app; every other surface is dark chrome that floats
 * over satellite imagery and has to stay readable on it.
 *
 * House law: once this file exists, no component may contain a raw hex, rgb(),
 * hsl(), oklch(), or a bare z-index. Map paint colours are read from these
 * custom properties at runtime (map.js cssVar), so this file stays the only
 * place a colour is written down. Enforced by token-gate.mjs.
 */

:root {
  color-scheme: dark;

  /* ------------------------------------------------------------------------
   * 1. SURFACES: night water
   *
   * Dark chrome, tinted toward deep canal green, never pure black. Dark
   * chrome keeps the map (bright imagery, bright severity colours) as the
   * brightest thing on the screen, which is where the eye should go.
   * --glass is the floating chrome over the map (search pill, map buttons);
   * it is translucent so the map keeps its context behind it.
   * ---------------------------------------------------------------------- */
  --paper:     #0E1618;
  --paper-2:   #152124;
  --surface-2: #1C2A2E;
  --card:      #132024;
  --glass:     rgba(14, 22, 24, .88);
  --scrim:     rgba(4, 8, 9, .6);
  --map-bg:    #1A2629;

  /* ------------------------------------------------------------------------
   * 2. LINE RAMP, THREE STEPS
   * Each value deliberately unequal to every surface above.
   * ---------------------------------------------------------------------- */
  --line:        #29393D;
  --line-mid:    #36494E;
  --line-strong: #6A8388;

  /* ------------------------------------------------------------------------
   * 3. INK RAMP, tinted toward the ground
   * ---------------------------------------------------------------------- */
  --ink:   #EEF5F3;
  --ink-2: #BAC9C7;
  --ink-3: #93A7A6;

  /* ------------------------------------------------------------------------
   * 4. SIGNAL: the one thing to do next
   *
   * Clear sky blue, water you can see through. It is the report button and
   * the primary button in a sheet, and nothing else.
   * ---------------------------------------------------------------------- */
  --signal:       #5CC8FF;
  --signal-hover: #86D8FF;
  --signal-wash:  #173645;
  --signal-ink:   #03131B;

  /* ------------------------------------------------------------------------
   * 5. STATE AS PRODUCT FACTS
   *
   * --live      data arrived recently and every feed answered
   * --stale     data is older than it should be
   * --err       a feed or our own server failed (the ERR badge)
   * --rising    water going up (worse)
   * --falling   water going down (better)
   * Every one is a text colour on the dark surfaces, so each clears 4.5:1 on
   * --surface-2, the lightest surface. Direction never relies on colour
   * alone: arrows and words always travel with it.
   * ---------------------------------------------------------------------- */
  --live:     #4FDB94;
  --stale:    #FFBE5C;
  --err:      #FF7A6E;
  --err-wash: #3B1916;
  --rising:   #FF9270;
  --falling:  #62D8AE;
  --ok:       #4FDB94;

  /* ------------------------------------------------------------------------
   * 6. SEVERITY RAMP: how deep the water is
   *
   * 0 receded, 1 ankle, 2 shin (cars slow), 3 knee to waist (cars cannot
   * pass), 4 over the waist (danger). A sequential ramp that falls in
   * lightness at every step (pale yellow to deep magenta), so it still reads
   * in order for colour blind users and in greyscale; the level number or
   * word always travels with it too. Each level has an ink for text set on
   * it. Water gone (0) steps out of the ramp as green, the colour people
   * read as "go": the place is good to travel through again (owner,
   * 2026-09-27). On the map a soft green area around the dot marks it as
   * well, so it never relies on the hue alone.
   * ---------------------------------------------------------------------- */
  --sev-0: #4FDB94;  --sev-0-ink: #0E1618;
  --sev-1: #FFE45C;  --sev-1-ink: #0E1618;
  --sev-2: #FFA53D;  --sev-2-ink: #0E1618;
  --sev-3: #F0512F;  --sev-3-ink: #0E1618;
  --sev-4: #A3157A;  --sev-4-ink: #FFF4FB;

  /* The ring around every marker, so a yellow dot survives on a pale roof
   * and a magenta dot survives on dark water. */
  --map-ring: #F7FBFA;
  --map-ring-dark: #0E1618;

  /* ------------------------------------------------------------------------
   * 7. ROUTE, PLACE AND ME
   * ---------------------------------------------------------------------- */
  --route-safe:   #3D8BFF;
  --route-casing: #F4FAFF;
  --route-plain:  #C3CDD0;
  --route-hit:    #FF3B30;
  --me:           #3D8BFF;
  --me-halo:      rgba(61, 139, 255, .18);
  --pin:          #5CC8FF;

  /* ------------------------------------------------------------------------
   * 8. WHY IT FLOODS: ground height (terrain relief) and canal levels
   *
   * Relief runs blue for the lowest ground (floods first) through green to
   * brown for higher ground. Canal and river stations are coloured by how
   * full the bank is.
   * ---------------------------------------------------------------------- */
  --relief-1: #1F4E9C;   /* below sea level */
  --relief-2: #3D86D8;   /* 0 m */
  --relief-3: #8FC8EA;   /* 1.5 m */
  --relief-4: #BADFA2;   /* 3 m */
  --relief-5: #6FB35A;   /* 6 m */
  --relief-6: #CBB36B;   /* 15 m */
  --relief-7: #9C6B3E;   /* 40 m and up */

  --bank-ok:    #62D8AE;  /* under 60 % of bank */
  --bank-watch: #FFE45C;  /* 60 to 85 % */
  --bank-warn:  #FFA53D;  /* 85 to 100 % */
  --bank-over:  #F0512F;  /* over the bank */

  /* Rain in the last 24 h, Thai Meteorological Department bands. */
  --rain-1: #A8DBFF;  /* under 10 mm, light */
  --rain-2: #57A9FF;  /* 10 to 35 mm, moderate */
  --rain-3: #3A5BFF;  /* 35 to 90 mm, heavy */
  --rain-4: #A35CFF;  /* over 90 mm, very heavy */

  /* ------------------------------------------------------------------------
   * 9. ELEVATION: ring plus shadow, deeper on a dark ground
   * ---------------------------------------------------------------------- */
  --lift-1: 0 0 0 1px rgba(0, 0, 0, .25), 0 1px 2px rgba(0, 0, 0, .3);
  --lift-2: 0 0 0 1px rgba(0, 0, 0, .2), 0 6px 18px rgba(0, 0, 0, .38);
  --lift-3: 0 14px 36px rgba(0, 0, 0, .5);
  --focus:  0 0 0 2px var(--paper), 0 0 0 4px var(--signal);

  /* ------------------------------------------------------------------------
   * 10. RADIUS BY ROLE
   * ---------------------------------------------------------------------- */
  --r-control: 10px;
  --r-media:   12px;
  --r-sheet:   20px;
  --r-commit:  999px;

  /* ------------------------------------------------------------------------
   * 11. NAMED Z LADDER
   *
   * Map buttons sit under the sheet, so a sheet dragged to full covers them.
   * The search pill sits above the scrim so it is always reachable, and the
   * menu and suggestions sit above the pill's neighbours.
   * ---------------------------------------------------------------------- */
  --z-float:  40;
  --z-sheet:  44;
  --z-bar:    45;
  --z-scrim:  48;
  --z-header: 50;
  --z-menu:   52;
  --z-viewer: 60;
  --z-toast:  62;

  /* ------------------------------------------------------------------------
   * 12. SEMANTIC TYPE SCALE
   * ---------------------------------------------------------------------- */
  --t-nano:  .6875rem;   /* 11px, map attribution only */
  --t-micro: .8125rem;   /* 13px, chips, badges */
  --t-meta:  .875rem;    /* 14px, row metadata */
  --t-body:  1rem;       /* 16px, and every input, so iOS never zooms */
  --t-lede:  1.125rem;
  --t-card:  1rem;
  --t-sec:   1.25rem;
  --t-h1:    1.625rem;
  --t-big:   2rem;       /* the one number a screen exists for */

  /* ------------------------------------------------------------------------
   * 13. SPACING, 4px BASE
   * ---------------------------------------------------------------------- */
  --s1: 4px;   --s2: 8px;   --s3: 12px;  --s4: 16px;  --s5: 24px;  --s6: 32px;
  --s7: 48px;  --s8: 64px;

  /* ------------------------------------------------------------------------
   * 14. APP CHROME
   *
   * Every floating control and the sheet reference these. If a number
   * appears twice in the code it belongs here.
   * ---------------------------------------------------------------------- */
  --header-h:  48px;   /* the search pill */
  --peek-h:    96px;   /* the sheet at rest */
  --tap:       44px;   /* smallest touch target */
  --fab-h:     56px;   /* the report button */
  --thumb:     52px;   /* list row photo */
  --edge:      12px;   /* gap from the screen edge for floating chrome */
  --sheet-w:   420px;  /* the sheet becomes a side panel on wide screens */

  /* ------------------------------------------------------------------------
   * 15. TYPE ROLE AND MOTION
   *
   * System faces only: the app must paint fast on a mid Android over 4G,
   * and every phone in Thailand already carries a Thai face.
   * ---------------------------------------------------------------------- */
  --ui: 'LINE Seed Sans TH', system-ui, -apple-system, 'Segoe UI', 'Noto Sans Thai', 'Sukhumvit Set', Thonburi, Roboto, sans-serif;

  --ease:    cubic-bezier(.23, 1, .32, 1);
  --t-fast:  .15s;
  --t-state: .25s;
  --t-slow:  .38s;

  --lh-tight: 1.25;
  --lh-body:  1.45;
  --lh-thai:  1.55;
}

:lang(th) { letter-spacing: 0 }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- primitives ---------------------------------------------------------- */

* { margin: 0; padding: 0; box-sizing: border-box }

html, body { height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

img, video { display: block; max-width: 100% }
a { color: inherit }
button, input, textarea, select { font: inherit; color: inherit }
button { cursor: pointer; background: none; border: 0; touch-action: manipulation }
:focus-visible { outline: none; box-shadow: var(--focus) }
[hidden] { display: none !important }
