/* Front end: the shell and skin (frontend-v4 §2; F1 #185), built on tokens.css, the Friend direction
   (docs/design/direction/directions/b2/). Tokens only: no hex values here. Layers as b2: the page,
   the sky (the Today block), opaque cards. Phone first; one column of --page-max. Widget styles
   live beside their widget (public/app/widgets/<name>/<name>.css); the skeleton components that
   have not moved yet are styled below. */
:root {
  --t-display: var(--text-display);
  --t-number: var(--text-number);
  --t-head: var(--text-head);
  --t-body: var(--text-body);
  --t-sub: var(--text-sub);
  --t-small: var(--text-small);
  color-scheme: light;
}
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }
@media (min-width: 1024px) {
  :root {
    --t-display: var(--text-display-wide);
    --t-number: var(--text-number-wide);
    --t-head: var(--text-head-wide);
    --t-body: var(--text-body-wide);
    --t-sub: var(--text-sub-wide);
    --t-small: var(--text-small-wide);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); overflow-x: clip;
  font-family: var(--font-sans); font-size: var(--t-body); font-weight: var(--weight-regular); line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
[hidden] { display: none !important; }
a { color: var(--action); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 2px var(--focus-halo); }
h1, h2 { overflow-wrap: anywhere; }
h1 { font-size: var(--text-h1); font-weight: var(--weight-heavy); line-height: var(--leading-tight); margin: 0; }
h2 { font-size: var(--t-small); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-small); text-transform: uppercase; line-height: 1.3; color: var(--text-muted); margin: 0 0 var(--space-3); }
p { margin: 0 0 var(--space-3); max-width: var(--measure); }
.meta { font-size: var(--t-sub); color: var(--text-muted); }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.btn, button { display: inline-flex; align-items: center; justify-content: center; font: inherit; font-weight: var(--weight-bold); min-height: var(--tap); padding: 0 var(--space-4); border-radius: var(--radius-m); border: var(--rule) solid var(--line-strong); background: var(--surface); color: var(--action); text-decoration: none; cursor: pointer; }

/* Staging / preview banner (decision 0012): slate, never a level colour. */
.env-banner { background: var(--slate-700); color: var(--white); text-align: center; font-size: var(--t-sub); font-weight: var(--weight-bold); padding: var(--space-2) var(--gutter); }

/* The column. The masthead's own rules are in widgets/masthead/masthead.css. */
.mast, main { max-width: var(--page-max); margin: 0 auto; }
main { padding: 0 var(--gutter) var(--space-8); }
.fresh { padding: var(--space-2) var(--gutter) 0; max-width: var(--page-max); margin: 0 auto; }
.fresh p { margin: 0 0 var(--space-1); }
.noscript { max-width: var(--page-max); margin: var(--space-5) auto; padding: 0 var(--gutter); }

/* The slots, in the order of v4 §2.1. Every widget card fills one; each keeps a gap above it. */
.slot-storm { margin-top: var(--space-3); }

/* The sky (b2 layer 0): the Today block's ground, full width of the column. The dawn set is the
   default; data-sky="rain" draws the rain set (F3 #187, from the today widget's skyState, or from
   `now.falling`); data-sky="night" the night set (F9 #193, `now.is_day` false). Its text tokens
   are not redefined for dark: the sky stays a sky, the page around it dims (b2 system.md repair 1). It never moves: no animation, and reduced motion keeps it so. */
.sky {
  --on-sky: var(--sky-text); --on-sky-muted: var(--sky-text-muted); --on-sky-rule: var(--sky-rule); --on-sky-link: var(--sky-link);
  position: relative; margin: var(--space-3) calc(-1 * var(--gutter)) 0; padding: var(--space-5) var(--gutter) var(--space-6);
  color: var(--on-sky); text-shadow: var(--sky-shadow);
  background:
    radial-gradient(150% 38% at 78% 100%, var(--sky-band) 0%, transparent 72%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 52%, var(--sky-bottom) 100%);
}
.sky[data-sky="rain"] {
  --on-sky: var(--sky-rain-text); --on-sky-muted: var(--sky-rain-text-muted); --on-sky-rule: var(--sky-rain-rule); --on-sky-link: var(--sky-rain-link);
  text-shadow: var(--sky-rain-shadow);
  background: linear-gradient(180deg, var(--sky-rain-top) 0%, var(--sky-rain-mid) 50%, var(--sky-rain-bottom) 100%);
}
.sky[data-sky="rain"] .is-loading { background: var(--sky-rain-wash); }
.sky[data-sky="night"] {
  --on-sky: var(--sky-night-text); --on-sky-muted: var(--sky-night-text-muted); --on-sky-rule: var(--sky-night-rule); --on-sky-link: var(--sky-night-link);
  text-shadow: none;
  background: linear-gradient(180deg, var(--sky-night-top) 0%, var(--sky-night-mid) 50%, var(--sky-night-bottom) 100%);
}
.sky[data-sky="night"] .is-loading { background: var(--sky-night-wash); }
@media (prefers-reduced-motion: reduce) { .sky, .sky * { animation: none !important; transition: none !important; } }
.sky a { color: var(--on-sky-link); }
.sky :focus-visible { outline-color: var(--sky-focus); box-shadow: 0 0 0 2px var(--sky-focus-halo); }
.sky-in { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
.sky .meta, .sky h2 { color: var(--on-sky-muted); }

/* Cards (b2 layer 2): opaque, below the sky. */
.cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); margin-top: calc(var(--space-6) * -1); position: relative; z-index: 1; }
.sky { padding-bottom: calc(var(--space-6) + var(--space-2)); }
.cards > .slot:not(.is-loading):not(.is-error) { background: var(--surface); border-radius: var(--radius-xl); box-shadow: var(--shadow-card), 0 0 0 1px var(--card-edge); padding: var(--space-4) var(--space-4) var(--space-3); }

/* The drop-down (b2 repair 2): an icon, the words, a chevron and a one-line explainer; the panel
   opens in place under it. */
.dropdown { display: grid; gap: var(--space-3); }
.drop { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr); align-items: center; column-gap: var(--space-3); width: 100%; min-height: 3.5rem; padding: 0; border: 0; border-radius: 0; background: none; text-align: left; font-weight: var(--weight-regular); color: inherit; justify-content: stretch; }
.drop-ic { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 50%; background: var(--action-soft); color: var(--action); }
.drop-t { display: grid; gap: 1px; min-width: 0; overflow-wrap: anywhere; }
.drop-l { font-size: 1rem; font-weight: var(--weight-heavy); color: var(--action); line-height: 1.3; }
.drop-x { font-size: var(--t-sub); font-weight: var(--weight-medium); color: var(--text-muted); line-height: 1.35; }
.drop .chev { font-size: 0.85em; }
.drop-sky { padding: var(--space-2) var(--space-3) var(--space-2) var(--space-2); border-radius: 18px; background: var(--sky-pill-bg); box-shadow: inset 0 0 0 1px var(--sky-pill-edge); text-shadow: none; }
.drop-sky .drop-ic { background: var(--sky-pill-soft); color: var(--sky-pill-text); }
.drop-sky .drop-l { color: var(--sky-pill-text); }
.drop-sky .drop-x { color: var(--sky-pill-text-muted); }

/* Weather icons (components/wxicon.mjs, #264; b2 direction.css): monochrome, one stroke, a soft
   cloud; rain marks in the rain colour, pellets in the ice colour, the bolt in the pin amber. */
.wx { display: block; width: 28px; height: 28px; flex: none; overflow: visible; }
.wx .ic-cloud { fill: var(--icon-cloud); stroke: var(--icon-stroke); stroke-width: 1.4; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.wx .ic-back { opacity: 0.75; }
.wx .ic-sun circle, .wx .ic-moon { fill: var(--surface); stroke: var(--icon-stroke); stroke-width: 1.4; stroke-linejoin: round; }
.wx .ic-sun path, .wx .ic-line { fill: none; stroke: var(--icon-stroke); stroke-width: 1.4; stroke-linecap: round; }
.wx .ic-drop { fill: none; stroke: var(--precip-rain); stroke-width: 2; stroke-linecap: round; }
.wx .ic-flake { fill: none; stroke: var(--icon-stroke); stroke-width: 1.3; stroke-linecap: round; }
.wx .ic-pellet { fill: var(--precip-ice); }
.wx .ic-bolt { fill: var(--pin); stroke: var(--icon-stroke); stroke-width: 0.8; stroke-linejoin: round; }

/* Level chip and fills (system.md "Levels"): always edged, always with number and name. */
.chip { display: inline-flex; align-items: center; gap: var(--space-1); min-height: var(--tap); padding: 0 var(--space-3); border-radius: var(--radius-m); border: var(--rule) solid var(--level-edge); font-weight: var(--weight-bold); white-space: nowrap; }
.chip .n { font-weight: var(--weight-heavy); }
.l1 { background: var(--level-1); color: var(--level-1-label); }
.l2 { background: var(--level-2); color: var(--level-2-label); }
.l3 { background: var(--level-3); color: var(--level-3-label); }
.l4 { background: var(--level-4); color: var(--level-4-label); }



/* Next 24 hours. */
.next { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(4.5rem, 1fr)); gap: var(--space-2); }
.next li { display: flex; flex-direction: column; align-items: center; background: var(--surface); border: var(--rule) solid var(--line); border-radius: var(--radius-m); padding: var(--space-2) var(--space-1); text-align: center; font-variant-numeric: tabular-nums; }
.next li b { font-size: var(--text-h3); }

/* Week. */

/* Foot: freshness. */
.foot { margin-top: var(--space-7); padding-top: var(--space-4); border-top: var(--rule) solid var(--line); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.foot .slot-freshness p { margin: 0 0 var(--space-1); }
.stale { border-top: var(--rule) dashed var(--line-strong); padding-top: var(--space-2); }

/* States (§9). Loading: frames at their final height, --surface-2 fills, no spinner. */
.is-loading { background: var(--surface-2); border-radius: var(--radius-xl); }
.sky .is-loading { background: var(--sky-wash); }
.error { border: var(--rule) solid var(--line-strong); border-radius: var(--radius-m); padding: var(--space-3) var(--space-4); margin-top: var(--space-4); background: var(--surface); }

/* Find a place and settings. */
main > h1 { margin-top: var(--space-5); margin-bottom: var(--space-4); }
input[type="search"] { width: 100%; min-height: var(--tap); font: inherit; padding: 0 var(--space-3); border: var(--rule) solid var(--line-strong); border-radius: var(--radius-s); background: var(--surface); color: var(--text); margin-bottom: var(--space-3); }
.results { list-style: none; padding: 0; margin: 0; }
.result { display: flex; flex-direction: column; justify-content: center; min-height: var(--tap); padding: var(--space-2) 0; border-top: var(--rule) solid var(--line); color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.result .meta { display: block; }
.locate-note { margin: var(--space-3) 0; }
fieldset { border: 0; padding: 0; margin: 0; }
legend h2 { margin-top: var(--space-4); }
.radio { display: flex; align-items: center; gap: var(--space-2); min-height: var(--tap); }
.radio input { width: 1.25rem; height: 1.25rem; margin: 0; }

/* Laptop (F14 #286; b2 `quiet-laptop.png`, `storm-laptop.png`, direction.css "laptop: the sky window
   on the map"). The same slots, placed on a grid: the seven-day strip as a bar at the top, the NWS
   line, then the map ground with the storm frame across it, the Today panel floating at the left
   and the radar panel bottom right (radar.css), then one sheet below with the cards opened out.
   Columns: edge · the Today panel (448 px) · gap · the rest · edge, centred in --page-wide.
   Rows: 1 strip · 2 NWS · 3 storm · 4 the panels · 5–8 the sheet (right: 36 hours in 5, 10 days
   from 6; left: the take across 5–6 so neither column leaves a hole) · 9 the foot. Only the shell
   places slots; each widget's own laptop look stays in its own stylesheet. */
@media (min-width: 1024px) {
  main:has(> .layout) { max-width: none; padding: 0; }
  .layout {
    --edge: max(32px, calc((100% - var(--page-wide)) / 2 + 32px));
    display: grid; overflow-x: clip;
    grid-template-columns: minmax(32px, 1fr) minmax(0, 448px) 32px minmax(0, calc(var(--page-wide) - 448px - 96px)) minmax(32px, 1fr);
    /* row 4 is the flexible one, so the radar's height over rows 3–4 lands beside the Today panel, not
       above it when there is no storm */
    grid-template-rows: auto auto auto 1fr repeat(4, auto);
  }
  .layout > .cards { display: contents; }
  .layout > .slot, .layout > .sky, .layout > .cards > .slot, .layout > .foot { position: relative; z-index: 1; min-width: 0; }
  /* the map ground behind rows 3–4; the radar's picture fills it when the region has a `map` */
  .layout::before { content: ""; grid-column: 1 / -1; grid-row: 3 / 5; margin-bottom: -46px; background: var(--map-land); }
  /* the sheet below the map, its top edge over the ground */
  .layout::after {
    content: ""; grid-column: 2 / 5; grid-row: 5 / 8; margin: -46px -48px 0; z-index: 0;
    border-radius: 32px 32px 0 0; background: var(--surface); border: 1px solid var(--card-edge); border-bottom: 0;
    box-shadow: 0 -14px 40px rgb(12 22 36 / 0.10);
  }
  .layout > .cards > .slot-strip7 { grid-column: 1 / -1; grid-row: 1; }
  .layout > .slot-nws { grid-column: 1 / -1; grid-row: 2; margin: 0; }
  .layout > .slot-storm { grid-column: 2 / 5; grid-row: 3; margin: 28px 0 0; z-index: 2; }
  .layout > .sky {
    grid-column: 2; grid-row: 4; align-self: start; z-index: 2; margin: 28px 0 84px; padding: 26px 28px 24px;
    border-radius: var(--radius-sheet); overflow: hidden; isolation: isolate; box-shadow: var(--shadow-float), 0 0 0 1px var(--card-edge);
  }
  .layout > .cards > .slot-radar { grid-column: 1 / -1; grid-row: 3 / 5; z-index: 0; }
  /* below the map: two columns separated by a hairline, no cards */
  .layout > .cards > .slot:is(.slot-next36, .slot-days10, .slot-discmore):not(.is-loading):not(.is-error) {
    background: none; border-radius: 0; box-shadow: none; padding: 28px 0 0;
  }
  /* Two columns when the discussion continues (#505): its continuation open at the left under the map
     ("The discussion, continued", b2 system.md), 36 hours and 10 days at the right. */
  .layout > .cards > .slot-discmore { grid-column: 2; padding-right: 24px; align-self: start; }
  .layout > .cards > .slot-discmore { grid-row: 5; }
  .layout > .cards > .slot-next36, .layout > .cards > .slot-days10 { grid-column: 4; padding-left: 40px !important; border-left: 1px solid var(--line); }
  .layout > .cards > .slot-next36 { grid-row: 5; }
  .layout > .cards > .slot-days10 { grid-row: 6; }
  /* The continuation is open at this width: its link on the sky is not needed, and the panel is the
     page's own column, not a card. (Specificity beats the [hidden] rule above, which is for the phone.) */
  .layout .slot-discmore .disc-panel, .layout .slot-discmore .disc-panel[hidden] { display: grid !important; }
  .sky .disc-more { display: none; }
  /* No continuation (a template note with nothing past its lead): one column below the map, 36 hours,
     and 10 days at full width, no hairline. */
  .layout:has(> .cards > .slot-discmore[hidden]) > .cards > .slot:is(.slot-next36, .slot-days10) {
    grid-column: 2 / 5; padding-left: 0 !important; padding-right: 0; border-left: 0;
  }
  .layout:has(> .cards > .slot-discmore[hidden]) > .cards > .slot-next36 { grid-row: 5; }
  .layout:has(> .cards > .slot-discmore[hidden]) > .cards > .slot-days10 { grid-row: 6; }
  .layout > .cards > .slot.is-loading { margin-top: 28px; }
  .layout > .cards > .slot-discmore { z-index: 1; min-width: 0; }
  .layout > .foot { grid-column: 2 / 5; grid-row: 8; margin-top: var(--space-6); padding-bottom: var(--space-8); }
}
body:has(#fresh:not([hidden])) { --fresh-h: 2.75rem; } /* the Map tab's height budget (#565) */

/* #/ai-review (#832, staging only): the AI write-up beside the template; stacked on a phone. */
.ai-pair { display: grid; grid-template-columns: 1fr; gap: var(--space-4); }
@media (min-width: 768px) { .ai-pair { grid-template-columns: 1fr 1fr; } }
.ai-card { border: var(--rule) solid var(--line-strong); border-radius: var(--radius-m); padding: var(--space-4); background: var(--surface); }
.ai-label, .ai-meta { color: var(--text-muted); font-size: 0.875em; }
