/*
 * Gustly styles: the tokens, the base and the map freeze. Race livery: navy ink bodywork, electric
 * yellow for everything you press, heavy italic condensed type for what shouts, sharp cut corners.
 *
 *   tokens      every colour, size, step and duration the app uses, dark first, then the sunlit
 *               light theme under :root[data-theme="light"] (and on .dock, the forecast table). Gustly
 *               follows the phone until the rider picks Light or Dark (js/theme.js); every page's
 *               head script sets data-theme before first paint, so no flash. Light rules in
 *               other sheets are scoped `:where(:root[data-theme="light"]) <selector>`, which adds
 *               no specificity. Nothing outside the two token blocks and the map freeze writes a
 *               colour or a font size literal (tests/design-tokens.test.mjs lists every offence).
 *   base        body type, selection, the two-tone focus ring, scrollbars, reduced motion.
 *   map freeze  the map pane keeps exactly the look it had before the overhaul, in both
 *               themes (e2e/map-freeze.spec.js). Never restyle the map from here.
 *
 * Rules: yellow means "press here" or "this one", never a warning. Red is only SEND IT. The three
 * call colours are frozen (tests/verdicts.test.mjs). Components live in components.css.
 */

/* tokens:begin */
:root {
  color-scheme: dark;

  /* ground, panes and rows (dark, the reference): night navy, never pure black */
  --bg: #070e1c; /* the page ground */
  --pane: #0c1629; /* panes, inputs, secondary button fill */
  --raise: #13213b; /* cards and raised bands on a pane */
  --row: #0f1b32; /* every other row, chip fill */
  --line: rgba(170, 190, 225, 0.16); /* decorative hairline only, never a control's only edge */
  --line-strong: #6b7c9c; /* control edges: 3:1 or better on every ground */
  --line-2: var(--line-strong); /* old name: a control's edge */

  /* text on the grounds; the faint step still clears 4.5:1 on --raise */
  --text: #f2f5fa; /* body text */
  --muted: #aebbd0; /* secondary text, labels */
  --faint: #8e9cb5; /* hints, footnotes, placeholders */

  /* electric yellow: actions, focus, selection. Never a status, never a warning */
  --volt: #ffe500; /* the yellow fill */
  --volt-hover: #fff04a; /* the fill under a hovering pointer */
  --volt-press: #e3cb00; /* the fill while pressed */
  --on-volt: #050d1f; /* text and icons on a yellow fill */
  --accent: var(--volt); /* old name: the primary action fill */
  --accent-hover: var(--volt-hover); /* old name: the primary fill on hover */
  --accent-ink: var(--on-volt); /* old name: text on the accent fill */
  --accent-text: var(--volt); /* the accent as text or a link on a ground: 4.5:1 in both themes */
  --btn-edge: transparent; /* edge of a yellow fill: none needed on navy */
  --selection: var(--volt); /* selected text ground, with --on-volt text */

  /* the three calls, frozen in both themes; their words are always --ink on the plate */
  --call-send: #ff5a70; /* SEND IT, the only red in the app */
  --call-soft: #3ccf8e; /* GREEN LIGHT */
  --call-sit: #8d999f; /* SIT IT OUT */
  --ink: #050d1f; /* text on a call plate */
  --call-ink: var(--ink); /* the same, by its job */

  /* status: never yellow, never the SEND IT red. Warn and danger are one orange-to-rust family;
   * an icon and the words tell them apart, never colour alone */
  --ok: #3ccf8e; /* saved, live, done */
  --warn: #ff9a3c; /* an honest data caveat: stale, missing, partial */
  --badge-low: #ff9a3c; /* a Live badge fill for less wind than forecast or a dropping trend: one orange in every theme (the light --warn is a text brown) */
  --danger: #ff7a45; /* an error or a destructive confirm, as text or an edge, never a fill */
  --send: var(--ok); /* old name: success (not the SEND IT call) */
  --soft: var(--accent-text); /* old name: stars and highlights (not the GREEN LIGHT call) */
  --sit: #8d999f; /* old name: a neutral status bar */

  /* the livery band (top bar, landing hero, toasts): navy in both themes */
  --band: #0b1a36; /* the band itself */
  --band-2: #13264a; /* a raised item on the band, the user's message */
  --band-text: #f4f7fc; /* text on the band */
  --band-muted: #b9c5da; /* secondary text on the band */

  /* the top bar's full height: 56 px, plus the notch above it in an installed app (0 in a tab) */
  --topbar-h: calc(56px + env(safe-area-inset-top, 0px));

  /* states */
  --focus: var(--volt); /* the focus ring */
  --focus-w: 3px; /* its width */
  --focus-halo: transparent; /* the second tone around the ring (light theme only) */
  --press: rgba(255, 255, 255, 0.08); /* the pressed tint over any fill */
  --disabled-bg: #1d2a42; /* a disabled control's fill */
  --disabled-text: #8e9cb5; /* a disabled control's label */
  --elev-1: 0 1px 0 rgba(0, 0, 0, 0.5); /* a card resting on the ground */
  --elev-2: 6px 6px 0 rgba(0, 0, 0, 0.45); /* a hard offset: toasts, floating sheets */
  --stripe: var(--volt); /* the livery stripes and the quiet button's bar */
  --google-tile: #ffffff; /* Google's G always sits on white (their branding rule) */

  /* type: display is Saira italic condensed, text is Barlow (fonts.css). Never below --t-xs */
  --t-xs: 13px; /* the floor: tags, badges, tiny meta; smaller is unreadable in sun */
  --t-meta: 14px; /* labels, meta, secondary buttons */
  --t-body: 16px; /* body text, inputs */
  --t-lead: 18px; /* a lead line, a spot's name */
  --t-d0: 20px; /* display: the primary button label */
  --t-d1: 22px; /* display: card and section heads, rank numerals */
  --t-d2: 30px; /* display: page titles, the wordmark, wind numbers */
  --t-d3: 40px; /* display: big numbers */
  --t-d4: 54px; /* display: landing headline */
  --t-d5: clamp(64px, 14vw, 120px); /* display: the hero wordmark */
  --t-call: clamp(50px, 6vw + 20px, 64px); /* the call on its plate: the loudest word on screen */
  --lh-tight: 0.92; /* display line height */
  --lh-snug: 1.2; /* labels, buttons, tight UI */
  --lh-ui: 1.5; /* running text */
  --track-display: 0.01em; /* display tracking */

  /* geometry: no radius anywhere; one cut corner and one skew instead */
  --cut-s: 8px; /* small cut: icon buttons */
  --cut: 12px; /* button cut */
  --cut-l: 22px; /* card cut */
  --skew: -14deg; /* every slanted accent leans the same way, like the italic */
  --stripe-w: 3px; /* a livery stripe */
  --stripe-gap: 4px; /* the gap between stripes */
  --tap: 44px; /* minimum tap target */
  --bar: 4px; /* an accent bar down a row's edge: the call, the caveat */
  --bar-l: 6px; /* the same bar on the one row that is the pick */
  /* spacing: these steps only. 0 and a 1 px hairline overlap are not steps */
  --s-0: 2px; /* a line and its own meta line, a tag's inner pad */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;

  /* layout */
  --map: minmax(340px, 38vw);

  /* motion: only in answer to an action */
  --dur-fast: 120ms; /* a press, a hover */
  --dur: 180ms; /* a toggle, a bar sliding in */
  --dur-slow: 240ms; /* a plate or a toast arriving */
  --dur-loop: 1.2s; /* one period of a running loader (stripes, a pulse); stopped under reduced motion */
  --ease: cubic-bezier(0.2, 0.9, 0.2, 1);
}

/* sunlit livery, the rider's choice: cold white, ink text near 19:1. Yellow stays a fill with a
 * 2 px ink edge (yellow on white is 1.2:1); the focus ring turns ink with a yellow halo. The dock
 * (the forecast under the map, inside the map pane) takes the same list: its own tokens below
 * are the dark ones, and this selector outranks them (0,3,0), so the dock reads on white too. */
:root[data-theme="light"],
:root[data-theme="light"] .dock,
:root[data-theme="light"] .map-ctl {
  color-scheme: light;
  --bg: #e8edf4;
  --pane: #ffffff;
  --raise: #ffffff;
  --row: #f1f4f9;
  --line: rgba(5, 13, 31, 0.14);
  --line-strong: #5f6d87;
  --text: #050d1f;
  --muted: #33405a;
  --faint: #3c475c;
  --accent-text: #5c4200; /* deep amber: yellow cannot be text on white */
  --btn-edge: #050d1f;
  --ok: #085131;
  --warn: #773200;
  --danger: #7d2c0e;
  --sit: #3f484e;
  --focus: #050d1f;
  --focus-halo: var(--volt);
  --press: rgba(5, 13, 31, 0.08);
  --disabled-bg: #dfe4ec;
  --disabled-text: #3c475c;
  --elev-1: 0 1px 0 rgba(5, 13, 31, 0.18);
  --elev-2: 4px 4px 0 #050d1f;
  --stripe: #050d1f;
}

/* The map pane in sunlight (owner: "invert all colors including the map"): its own chrome (zoom,
 * the wind card and chip, the legend, the board chip, the night tag, the attribution) reads these
 * tokens, so the map's plates go white with ink type and a 2 px ink edge. The map-freeze block
 * pins the dark tokens on .map-pane (0,1,0); this (0,3,0) wins whatever the order, so the dark
 * picture is untouched. The canvas and the basemap are not styled from here. */
:root[data-theme="light"] .map-pane {
  color-scheme: light;
  --bg: #e8edf4;
  --pane: #ffffff;
  --raise: #ffffff;
  --row: #f1f4f9;
  --line: rgba(5, 13, 31, 0.14);
  --line-2: #050d1f;
  --text: #050d1f;
  --muted: #33405a;
  --faint: #3c475c;
  --accent: #050d1f;
  --accent-ink: #ffffff;
  --ok: #085131;
  --warn: #773200;
  --danger: #7d2c0e;
  --sit: #3f484e;
  --press: rgba(5, 13, 31, 0.08);
  --focus: #050d1f;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0ms;
    --dur: 0ms;
    --dur-slow: 0ms;
  }
}

/* The livery band, the toast, the dock and the map's buttons (.map-ctl) keep the dark tokens in
 * both themes; the light block above wins on the dock and .map-ctl, so in sun they are white. */
.band,
.toast,
.dock,
.map-ctl {
  --text: var(--band-text);
  --muted: var(--band-muted);
  --faint: var(--band-muted);
  --pane: var(--band);
  --raise: var(--band-2);
  --row: var(--band-2);
  --line: rgba(170, 190, 225, 0.16);
  --line-strong: #6b7c9c;
  --accent-text: var(--volt);
  --ok: #3ccf8e;
  --warn: #ff9a3c;
  --danger: #ff7a45;
  --btn-edge: transparent;
  --focus: var(--volt);
  --focus-halo: transparent;
  --press: rgba(255, 255, 255, 0.08);
  --stripe: var(--volt);
  color-scheme: dark;
}
/* tokens:end */

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
  border-radius: 0;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow-x: clip;
  /* no pull-to-refresh or rubber band on the page: the map keeps its place (inner panes scroll) */
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--t-body) / var(--lh-ui) var(--font-ui);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Focus: a 3 px ring, yellow on navy; in sun an ink ring with a yellow halo, so it shows on any
 * ground, the yellow button included. Shapes are cut on pseudo-elements, so it is never clipped. */
:focus-visible {
  outline: var(--focus-w) solid var(--focus);
  outline-offset: 2px;
}

:where(:root[data-theme="light"]) :focus-visible:not(.map-pane *, .band *, .toast *) {
  box-shadow: 0 0 0 calc(var(--focus-w) + 5px) var(--focus-halo);
}

::selection {
  background: var(--selection);
  color: var(--on-volt);
}

/* Thin scrollbars in the panes, thumb in the control-edge colour. */
.chat-scroll,
.dock-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}

/* Every bare pressable answers the finger at once; the next screen comes after. A .btn (Copy,
 * Report, Jump to latest) presses inside its own cut shape (components.css), never a square. */
.panel-btn:active {
  background: var(--press);
}

.frame {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  /* landscape notch or rounded corners: the side insets keep the panes off them (0 in a tab) */
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* Map */
.map-pane {
  display: grid;
  grid-template-rows: auto minmax(220px, 1fr) minmax(160px, 40%);
  min-width: 0;
  min-height: 0;
  background: var(--pane);
  border-left: 1px solid var(--line);
}

/* the map element itself (map.css draws the rest) */
.map {
  background: var(--pane);
  font: inherit;
}

@media (max-width: 960px) {
  .map-pane {
    border-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

/* map-freeze:begin
 * The map pane keeps the look it had on 860b09f, in both themes: dark tokens, the system font at
 * 16/1.55, a 2 px teal focus ring, and today's rules for the shared classes it uses (.btn,
 * .verdict, .wp-guide, .gd-pulse). components.css keeps its new buttons out of the map with
 * :where(:not(.map-pane *), .dock *, .map-ctl); the other shared classes are pinned here one step more
 * specific than their owners, with every new property reset. The dock is out of the freeze: it
 * wears the livery on the band's navy in dark (the `.band, .toast, .dock` tokens and `.dock`
 * below) and the light tokens in light (the first block of this file). */
.map-pane {
  color-scheme: dark;
  --bg: #0c1012;
  --pane: #111618;
  --raise: #182023;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.16);
  --text: #e8edef;
  --muted: #a3adb1;
  --faint: #828c91;
  --accent: #4fd1d9;
  --accent-hover: #6ddce3;
  --accent-ink: #051113;
  --send: #3ccf8e;
  --soft: #e6b450;
  --sit: #8d999f;
  --warn: #e39a5b;
  --danger: #ef8a7d;
  --tap: 44px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t-body: 16px;
  --t-meta: 14px;
  --dur-fast: 120ms;
  --dur: 180ms;
  --press: rgba(255, 255, 255, 0.07);
  --focus: #4fd1d9;
  --focus-w: 2px;
  --focus-halo: transparent;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

/* The dock takes back what the pane pins: the ink axis, the yellow, the livery ring and face.
 * In light the first block's `:root[data-theme="light"] .dock` overrides these tokens. */
.dock,
.map-ctl {
  --bg: #070e1c; /* the axis: the page's ink, under the band's navy table */
  --line-2: var(--line-strong);
  --accent: var(--volt);
  --accent-hover: var(--volt-hover);
  --accent-ink: var(--on-volt);
  --send: var(--ok);
  --soft: var(--accent-text);
  --focus-w: 3px;
  --font-ui: var(--font-text);
}

.dock ::selection {
  background: var(--selection);
  color: var(--on-volt);
}

.map-pane {
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--t-body);
  font-weight: 400;
  font-style: normal;
  line-height: 1.55;
  letter-spacing: normal;
}

.map-pane ::selection {
  background: rgba(79, 209, 217, 0.32);
  color: var(--text);
}

/* .btn as it was (styles.css then components.css on 860b09f, same order, same specificity). */
:where(.map-pane) .btn:where(:not(.dock *, .map-ctl, .toast *)):active:not(:disabled) {
  background: var(--press);
}

:where(.map-pane) .btn.primary:where(:not(.dock *)):active:not(:disabled) {
  background: var(--accent-hover);
}

:where(.map-pane) .btn:where(:not(.dock *, .map-ctl, .toast *)) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 16px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--t-meta);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}

:where(.map-pane) .btn.primary:where(:not(.dock *)) {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

:where(.map-pane) .btn.primary:where(:not(.dock *)):disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

:where(.map-pane) .btn.outline:where(:not(.dock *)) {
  border-color: var(--line-2);
}

:where(.map-pane) .btn.quiet:where(:not(.dock *)) {
  color: var(--muted);
}

@media (hover: hover) and (pointer: fine) {
  :where(.map-pane) .btn.quiet:where(:not(.dock *)):hover,
  :where(.map-pane) .btn.outline:where(:not(.dock *)):hover {
    background: var(--raise);
    color: var(--text);
  }

  :where(.map-pane) .btn.primary:where(:not(.dock *)):hover:not(:disabled) {
    background: var(--accent-hover);
  }
}

/* .verdict as chat-card.css drew it; map.css's .dock-title .verdict (later) still sets its size. */
.map-pane .verdict {
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  clip-path: none;
  transform: none;
  animation: none;
  font-family: inherit;
  font-size: var(--t-meta);
  font-weight: 600;
  font-style: normal;
  letter-spacing: normal;
  text-transform: none;
}

.map-pane .verdict::before,
.map-pane .verdict::after {
  content: none;
}

.map-pane .verdict.send {
  color: var(--call-send);
}

.map-pane .verdict.soft {
  color: var(--call-soft);
}

.map-pane .verdict.sit {
  color: var(--call-sit);
}

/* The wind legend's tour link and the Guide's pulse, as guide.css drew them. */
.map-pane .wp-guide {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 12px;
  border-top: 1px solid var(--line);
  color: var(--accent);
  font-size: 13px;
  font-weight: inherit;
  font-style: normal;
  letter-spacing: normal;
  text-transform: none;
}

.map-pane .gd-pulse {
  position: absolute;
  z-index: 2;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border: 2px solid #39ff7a;
  border-radius: 50%;
  background: none;
  box-shadow: none;
  clip-path: none;
  pointer-events: none;
  animation: map-gd-pulse 0.9s var(--ease) 2;
}

@keyframes map-gd-pulse {
  from {
    opacity: 1;
    transform: scale(0.5);
  }
  to {
    opacity: 0;
    transform: scale(1.6);
  }
}

@media (prefers-reduced-motion: reduce) {
  .map-pane .gd-pulse {
    animation: none;
  }
}
/* the dock's smallest labels on a phone (was phone.css): nothing a rider reads is under 12 px */
@media (max-width: 560px), (max-height: 500px) and (pointer: coarse) {
  :is(.map-pane, .dock) :is(.wm-tick, .fc-unit, .fc-sub) {
    font-size: 12px;
  }
}

:is(.map-pane, .dock) .board-dots i {
  background: rgba(228, 234, 237, 0.32);
}

:is(.map-pane, .dock) .board-tip {
  background: rgba(13, 20, 27, 0.92);
  font-size: 12px;
}

/* map-freeze:end */

/* The freeze pins three map pieces with dark literals (the board chip's name tip, its hover and
 * its dots). In sunlight they take the map pane's light tokens instead (the block in the token
 * region above). Only var() values here, so this sheet stays inside the colour rule. */
:root[data-theme="light"] .map-pane .board-tip {
  background: var(--pane);
  box-shadow: 0 0 0 1px var(--line-2);
}

:root[data-theme="light"] .map-pane .board-dots i {
  background: var(--muted);
}
