/* The design values, in one file, for the whole page: a style sheet that needs a colour or a size takes a token from here.

   1. The page's own: its colours by theme, its type scale, its sizes, and the phone-size layout's values under the same two tests the page's
      style uses (a frame's layout takes them too). The page links this file before its own style, which writes no :root block of its own.
   2. The interface's, from "The scale" on: type, space, touch, radii, layers, the glass material, the sheet. Sizes, spaces, radii and layers
      are named there and nowhere else for the interface (tests/tokens.test.mjs). Colours: one block a theme (dark is what the page offers;
      light is a second block of values, its switch off). web/layout.js reads the sheet's tokens once (the half's share of the map, the
      chart's least and most), so the script and the style sheet cannot disagree.

   A token set on another element (the panel's own inks, a state's --map-h) stays with that element's rule in the page. */

/* ---- 1. The page as it stands ---- */

/* Light theme: paper ground, ink type. --accent is interface chrome only
(focus rings, the playhead, the selection outline, the selected place);
no data on the map is drawn in it. Every colour the interface uses is a
token here; the dark block below redefines them all. The map's own
colours (ramp, ground, context) are the JavaScript constants checked by
pipeline/build_year_ramp.py. The type scale is the metro map's (How
close is Delhi?), so the two Delhi pieces read as one family: title 22,
year 44, caption 14, body 13, small 11. */
:root {
  --bg: #f1ede4;
  --panel: rgba(246, 243, 236, 0.95);
  /* the pane's surfaces, lowest to highest: the pane, a card (a section), a control
  (a switch's track, a number box), a pressed control. Light: white cards on a
  warm grey pane, tracks set in. */
  --pane: rgba(236, 232, 224, 0.97);
  --pane-solid: #ece8e0;
  --card: #f8f6f1;
  --ctl: #e9e5dc;
  --ctl-on: #ffffff;
  --card-edge: rgba(255, 255, 255, 0.8);
  --ink: #26282c;
  --ink-2: #3b3d42;
  --dim: #68635a;
  --never-band: #b4ae9f; /* the land never built up, in the chart of people by build period */
  --rule: rgba(38, 40, 44, 0.16);
  --accent: #c9502a;
  --accent-text: #a8401c;
  --shape-warn: #d4122a;
  /* the areas' colours, one per number (web/pane.js), the same in both themes since the panel is dark in both: each at least 7.7:1 on the
  panel and the dark ground, its number at least 8:1 on it, CIEDE2000 at least 19 from every build-year colour of either theme and 14 from
  each other, light to lighter (L* 70 to 94); checked by tests/palette.test.mjs. The number on the badge carries the identity too. */
  --s0: #f2efe8;
  --s1: #2fcfb4;
  --s2: #86d957;
  --s3: #79c3ff;
  --s4: #cfc0a0;
  --s5: #ab9fff;
  --s6: #bff3e3;
  --s7: #f0bdf5;
  --mark-on: #000000; /* the number on a badge, and the ring round a badge on the map */
  --s0-on: var(--mark-on);
  --s1-on: var(--mark-on);
  --s2-on: var(--mark-on);
  --s3-on: var(--mark-on);
  --s4-on: var(--mark-on);
  --s5-on: var(--mark-on);
  --s6-on: var(--mark-on);
  --s7-on: var(--mark-on);
  /* two groups, A against B: blue and sand, a pair colour-vision deficiency keeps apart */
  --gA: var(--s3);
  --gB: var(--s4);
  --gA-on: var(--mark-on);
  --gB-on: var(--mark-on);
  /* the panel, docked at the right on a wide screen (web/winlayout.js, panelWidth: the same rule), and folded to its strip */
  --panel-w: clamp(360px, 28vw, 400px);
  --strip-w: 48px;
  --panel-now: var(--panel-w);
  --pn-bg: #17191c;
  --pn-menu: #202326;
  --pn-field: #101215;
  --pn-field-rule: rgba(244, 241, 234, 0.3);
  --mode-bg: #ece9e2;
  --mode-ink: #121416;
  --mode-dim: #4a4d52;
  --rd-bg: rgba(17, 19, 21, 0.97);
  /* the card is dark in both themes, so its keyline is light in both: an edge over dark and mid ground */
  --rd-edge: rgba(255, 255, 255, 0.75);
  --rd-ring: rgba(17, 19, 21, 0.9);
  --pn-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  --surface: #f7f4ee;
  --field: #f7f4ee;
  --field-rule: rgba(38, 40, 44, 0.28);
  --press: rgba(38, 40, 44, 0.08);
  --hover: rgba(38, 40, 44, 0.05);
  --backdrop: rgba(38, 40, 44, 0.35);
  --shadow: 0 2px 10px rgba(60, 45, 20, 0.16);
  --shadow-big: 0 18px 60px rgba(0, 0, 0, 0.25);
  --halo: 0 0 6px rgba(241, 237, 228, 0.95), 0 0 2px rgba(241, 237, 228, 0.95);
  --series-l: 38%;
  --fs-title: 22px;
  --fs-year: 44px;
  --fs-caption: 14px;
  --fs-body: 13px;
  --fs-small: 12px;
  /* the panel's colours, dark in both themes: it reads them as its own --ink, --rule, --ctl and so on (#panel) */
  /* how opaque the panels are, by measurement: text on them holds at least 4.5:1 over white or black from .885 up (the bar's
  dim text needs a token of its own), but what shows through is still up to 1.54:1 there; at .97 it is 1.11:1 at most. */
  --bar-bg: color-mix(in srgb, var(--pane-solid) 97%, transparent);
  --float-bg: rgba(20, 22, 26, 0.97);
  --float-ink: #f4f1ea;
  --float-ink-2: #dcd8cf;
  --float-dim: #b9b4ab;
  --float-rule: rgba(244, 241, 234, 0.2);
  --float-ctl: rgba(244, 241, 234, 0.13);
  --float-ctl-on: rgba(244, 241, 234, 0.28);
  --float-accent: #f0926a;
  --float-casing: rgba(244, 241, 234, 0.92);
  --float-solid: #14161a;
  --float-plot: rgba(244, 241, 234, 0.94);
  --gutter: 16px;
  --map-share: 0.44; /* how much of an upright narrow frame's height its map takes, above the comparison window (the page's interface sets its own map's box) */
  --drawer-w: min(440px, 46vw);
  --imprint-ink: #5f5c57;
  --imprint-bg: rgba(241, 237, 228, 0.93);
  color-scheme: light;
}
/* Dark theme: night page, light type. Measured contrast
on --bg: ink 13.9:1, dim 6.3:1, accent 6.1:1. */
:root[data-theme='dark'] {
  --bg: #171a1d;
  --panel: rgba(30, 33, 37, 0.95);
  /* dark: each surface lighter than the one under it, about 4-5 L* a step */
  --pane: rgba(22, 25, 29, 0.97);
  --pane-solid: #16191d;
  --card: #1e2227;
  --ctl: #272c32;
  --ctl-on: #343a41;
  --card-edge: rgba(255, 255, 255, 0.055);
  --ink: #e9e5de;
  --ink-2: #cdc8bf;
  --dim: #a19a92;
  --never-band: #6e6a62;
  --rule: rgba(233, 229, 222, 0.16);
  --accent: #e8794f;
  --accent-text: #ef8a5f;
  --shape-warn: #ff5c52;
  --surface: #1e2125;
  --field: #24282c;
  --field-rule: rgba(233, 229, 222, 0.24);
  --press: rgba(233, 229, 222, 0.1);
  --hover: rgba(233, 229, 222, 0.06);
  --float-bg: rgba(34, 38, 43, 0.97);
  --float-casing: rgba(20, 22, 26, 0);
  --float-plot: rgba(20, 22, 26, 0);
  --imprint-ink: #969696;
  --imprint-bg: rgba(23, 26, 29, 0.94);
  --backdrop: rgba(0, 0, 0, 0.55);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  --shadow-big: 0 18px 60px rgba(0, 0, 0, 0.6);
  --halo: 0 0 6px rgba(23, 26, 29, 0.95), 0 0 2px rgba(23, 26, 29, 0.95);
  --series-l: 68%;
  color-scheme: dark;
}
/* The phone-size layout: under 1200 px wide or under 600 px tall, on any device (PHONE_LAYOUT, the same test). Every height comes from these. */
@media (max-width: 1199px), (max-height: 599px) {
  :root,
  :root[data-theme='dark'] {
    --fs-title: 18px;
    --gutter: 8px;
    --drawer-w: 100%;
    --bar-h: calc(44px + env(safe-area-inset-top, 0px));
    --time-h: 48px;
    --tabs-h: 44px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-l: env(safe-area-inset-left, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
    --shape-h: calc(96px + var(--safe-b));
    --full: 100vh;
    --thumb-r: 11px;
    /* upright; side by side changes these */
    --map-w: 100vw;
    --map-h: calc(var(--full) * var(--map-share));
    --panel-top: calc(var(--bar-h) + var(--map-h) + var(--time-h));
    --panel-left: 0px;
    /* the panel stands still in the page's colours */
    --float-bg: var(--bg);
    --float-ink: var(--ink);
    --float-ink-2: var(--ink-2);
    --float-dim: var(--dim);
    --float-rule: var(--rule);
    --float-ctl: var(--ctl);
    --float-ctl-on: var(--ctl-on);
    --float-accent: var(--accent-text);
    --float-solid: var(--surface);
    --float-casing: color-mix(in srgb, var(--bg) 92%, transparent);
    --float-plot: color-mix(in srgb, var(--bg) 94%, transparent);
    /* the imprint's ink is the wide screen's here too (4.5:1): the phone's own, lighter, was 3.38:1 */
  }
  @supports (height: 100dvh) {
    :root,
    :root[data-theme='dark'] {
      --full: 100dvh;
    }
  }
  /* the panel there: in the page's colours */
  :root,
  :root[data-theme='dark'] {
    --pn-bg: var(--bg);
    --pn-menu: var(--surface);
    --pn-field: var(--field);
    --pn-field-rule: var(--field-rule);
    --panel-now: 0px;
  }
}
/* Side by side: the bar across the top; the map and time at the left; the panel at the right */
@media (max-width: 1199px) and (min-aspect-ratio: 1201/1000),
  (max-height: 599px) and (min-aspect-ratio: 1201/1000) {
  :root,
  :root[data-theme='dark'] {
    --side-w: clamp(360px, 38vw, 420px);
    --map-w: calc(100vw - var(--side-w));
    --map-h: calc(var(--full) - var(--bar-h) - var(--time-h) - var(--safe-b));
    --panel-top: var(--bar-h);
    --panel-left: calc(100vw - var(--side-w));
  }
}

/* ---- 2. The scale, and the interface's values ---- */

:root {
  /* type: four sizes, none under 12 */
  --t-12: 12px;
  --t-14: 14px;
  --t-16: 16px;
  --t-20: 20px;
  /* space */
  --s-2: 2px;
  --s-4: 4px;
  --s-8: 8px;
  --s-12: 12px;
  --s-16: 16px;
  --s-24: 24px;
  /* the least size of anything a finger presses, and the sizes a control is drawn at inside it */
  --touch: 44px;
  --v-28: 28px;
  --v-32: 32px;
  --v-40: 40px;
  /* radii */
  --r-8: 8px;
  --r-14: 14px;
  --r-full: 999px;
  /* layers, by role */
  --z-map: 0;
  --z-onmap: 4;
  --z-sheet: 5;
  --z-bar: 6;
  --z-card: 7;
  --z-dialog: 40;
  --z-toast: 41;
  /* the glass material: a tint over a blur of the map. The tint is the floor for 4.5 to 1 of every text token over the brightest ground. */
  --glass-tint: 90%;
  --glass-blur: 20px;
  --glass-sat: 1.3;
  /* the sheet */
  --grab-band: 20px; /* the grabber's strip at the sheet's top */
  --line-20: 20px; /* one line of 14 px type */
  --grab-w: 36px;
  --grab-h: 4px;
  --track-h: 5px;
  --stops-max: 360px;
  --knob: 14px;
  --sheet-half-free: 0.46; /* the share of the screen under the bar that the free map keeps at half */
  --sheet-least-free: 200px; /* under this much free map, there is no half */
  --chart-least: 120px;
  --chart-most: 200px;
  --sheet-fling: 500px; /* a release faster than this, a second, carries the sheet to the next height */
  --sheet-omega: 20; /* the settle's spring, 1/s: critically damped */
  --sheet-ease-in: 80ms; /* a settle that starts from rest takes this long to come to the spring's full pull */
  --pin-margin: 28px; /* clear ground kept between a pinned place and the free map's edge */
  /* motion: one set, for the phone and the desktop. A press answers in the frame it lands, with no time of its own; a piece that comes or
     goes fades; a piece that moves takes the longer time on the one easing. The sheet's spring is its own (--sheet-omega). */
  --press-dim: 0.7; /* a control while it is pressed: its opacity */
  --fade-ms: 120ms; /* a piece coming or going */
  --fly-ms: 280ms; /* a piece moving: the pin's outline into its chip, the panel unfolding */
  --ease-move: cubic-bezier(0.3, 0, 0.2, 1);
  --swipe: 48px; /* a sideways move on the answer longer than this steps the measure */
  --focus: 2px; /* a focus ring's width, and its gap */
}
:root,
:root[data-theme='dark'] {
  --sheet-solid: #16191d;
  --sheet-ink: #e9e5de;
  --sheet-ink-2: #cdc8bf;
  --sheet-dim: #b3ada5; /* 4.5 to 1 on the glass over white at its tint */
  --sheet-rule: rgba(233, 229, 222, 0.16);
  --sheet-ctl: #272c32;
  --sheet-ctl-on: #e9e5de;
  --sheet-ctl-on-ink: #16191d;
  --sheet-accent: #e8794f;
  --sheet-accent-ink: #16191d;
  --glass-rgb: 22, 25, 29;
  /* a light keyline: the dark glass's edge over dark and mid ground (tests/legible.test.mjs) */
  --glass-edge: rgba(255, 255, 255, 0.75);
  --glass-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}
:root[data-theme='light'] {
  --sheet-solid: #f4f0e8;
  --sheet-ink: #1d1c1a;
  --sheet-ink-2: #3a3834;
  --sheet-dim: #5c5953;
  --sheet-rule: rgba(29, 28, 26, 0.16);
  --sheet-ctl: #e6e1d6;
  --sheet-ctl-on: #1d1c1a;
  --sheet-ctl-on-ink: #f4f0e8;
  --sheet-accent: #b6481f;
  --sheet-accent-ink: #ffffff;
  --glass-rgb: 244, 240, 232;
  /* a dark keyline: the light glass's edge over bright and mid ground */
  --glass-edge: rgba(0, 0, 0, 0.78);
  --glass-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}
