/* Aurora: the interface. Colours, type sizes, radii and spacing come from tokens.css.
   One set of column rails (--c1, --c2) runs the sheet: the night window's times, the three facts, the board's
   strip and status columns and the Right now table all start on them. */

:root {
  --pad: var(--s-5); /* side padding of the sheet's content */
  --row-inset: var(--s-2); /* rows are buttons that reach this far past the content on both sides */
  --c1: 114px;
  --c2: 228px;
  --kp-rail: 18px; /* numbers in the Kp column end this far before --c2 */
  --moon-col: 22px; /* the moon glyph and the gap after it */
  --dock-pad: var(--s-5);
  --dock-gap: 10px; /* between the sheet and a dock that runs under it */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  /* Written by the interface: the centre of what the panels leave free, and the phone sheet's height. */
  --free-cx: 50vw;
  --free-cy: 50vh;
  --sheet-h: 0px;
  --sheet-full: 0px;

  --t-arrive: 900ms;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --t-arrive: 0ms;
  }
}

/* ------------------------------------------------------------------------------------------------ base */

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

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--space);
  color: var(--snow);
  font: 500 var(--text-md) / 1.35 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
dl,
dt,
dd,
ul,
figure {
  margin: 0;
  padding: 0;
  font: inherit;
}

ul {
  list-style: none;
}

i,
b {
  font: inherit;
}

i {
  display: block;
}

button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration-color: var(--hairline-strong);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

[hidden] {
  display: none !important;
}

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Activity levels colour marks; the status ladder colours the verdict and the board's dots. */
.lv0 { --c: var(--level-0); }
.lv1 { --c: var(--level-1); }
.lv2 { --c: var(--level-2); }
.lv3 { --c: var(--level-3); }
.lv4 { --c: var(--level-4); }
[data-status='0'] { --status: var(--level-0); }
[data-status='1'] { --status: var(--level-1); }
[data-status='2'] { --status: var(--level-2); }
[data-status='3'] { --status: var(--level-3); }

.icon {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.moon {
  flex: none;
}

.moon circle {
  fill: var(--raise-2);
}

.moon path {
  fill: var(--mist);
}

.caption {
  font-size: var(--text-xs);
  color: var(--dusk);
}

.iconbtn {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--mist);
}

.iconbtn:hover {
  background: var(--raise-1);
  color: var(--snow);
}

.textbtn {
  min-height: 44px;
  border-radius: var(--s-2);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--hairline-strong);
  text-underline-offset: 4px;
}

.textbtn:hover {
  text-decoration-color: var(--snow);
}

/* Now, wherever it is marked: a dot inside a ring, on the night's track and on the timeline alike. */
.now-mark {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--snow);
  box-shadow: 0 0 0 1.5px var(--night), 0 0 0 3px var(--snow);
}

/* The best time: on the track, and as the key beside its caption. */
.caret {
  flex: none;
  width: 8px;
  height: 5px;
  background: var(--snow);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

/* ------------------------------------------------------------------------------------------------ globe */

.stage {
  position: fixed;
  inset: 0;
  z-index: var(--z-stage);
  overflow: hidden;
  background: var(--space);
}

.stage__canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* The one page-load moment: the globe fades in as it turns to the place. The page sets data-globe to
   "arriving" when it starts the globe and to "ready" when the first complete picture is drawn. */
.stage :is(.stage__canvas, .globe-overlay) {
  transition: opacity var(--t-arrive) linear;
}

.stage[data-globe='arriving'] :is(.stage__canvas, .globe-overlay) {
  opacity: 0;
}

/* The canvas fills the viewport, so its focus ring is drawn inside its edge. */
.stage__canvas:focus-visible {
  box-shadow: inset 0 0 0 2px var(--snow);
}

.stage__message {
  position: absolute;
  top: var(--free-cy);
  left: var(--free-cx);
  width: min(300px, 100vw - var(--s-8));
  transform: translate(-50%, -50%);
  color: var(--mist);
  font-size: var(--text-sm);
  line-height: 1.45;
}

/* The globe draws its own place marker and outline label (app/globe/globe.css). Over ice and daylight their
   text needs a backing, so here it gets the same small glass as the other chips that sit on the globe. The
   outline can also run under its own label where it slopes; behind glass that reads as a line passing by. */
.stage :is(.globe-marker__name, .globe-outline-label__text) {
  padding: 2px var(--s-2) 3px;
  border-radius: var(--r-full);
  background: var(--night-glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  font-size: var(--text-xs);
  line-height: 1.3;
  text-shadow: none;
}

/* ------------------------------------------------------------------------------------------------ over the globe */

.topbar {
  position: fixed;
  top: calc(var(--edge) + var(--safe-t));
  right: calc(var(--edge) + var(--safe-r));
  z-index: var(--z-chrome);
  display: flex;
  align-items: center;
  height: 44px;
  padding-left: var(--s-4);
  border: 1px solid var(--hairline);
  border-radius: var(--r-full);
  background: var(--night-glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

.wordmark {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topbar .iconbtn {
  margin: -1px;
  color: var(--snow);
}

.timechip {
  position: fixed;
  bottom: calc(var(--edge) * 2 + var(--dock-h));
  left: var(--free-cx);
  z-index: var(--z-chrome);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 6px var(--s-4) 8px;
  transform: translateX(-50%);
  border: 1px solid var(--hairline);
  border-radius: var(--r-group);
  background: var(--night-glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  white-space: nowrap;
}

.timechip__text {
  text-align: center;
}

.timechip strong {
  display: block;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.timechip span {
  display: block;
  color: var(--mist);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.timechip__now {
  position: relative;
  height: 32px;
  margin-right: calc(var(--s-2) * -1);
  padding: 0 var(--s-3);
  border-radius: 10px;
  background: var(--raise-2);
  font-size: var(--text-sm);
  font-weight: 600;
}

/* 44px to the finger, 32px to the eye. */
.timechip__now::after {
  content: '';
  position: absolute;
  inset: -6px -4px;
}

.legend {
  position: fixed;
  right: calc(var(--edge) + var(--s-2) + var(--safe-r));
  bottom: calc(var(--edge) * 2 + var(--dock-h));
  z-index: var(--z-chrome);
  color: var(--mist);
  font-size: var(--text-xs);
}

.legend__scale {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-top: 5px;
  color: var(--dusk);
  font-size: var(--text-2xs);
}

/* The one gradient in the chrome, and it is data: the ramp the globe uses for NOAA's brightness scale. */
.legend__ramp {
  flex: 1;
  height: 4px;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--aurora-faint), var(--aurora-mid) 55%, var(--aurora-bright));
}

/* A point picked on the globe, offered as a place: a ring where it was picked and a chip beside it. The
   element is a point; the page moves it to the tap and the chip hangs off it. */
.offer {
  position: fixed;
  top: 0;
  left: 0;
  z-index: var(--z-chrome);
  width: 0;
  height: 0;
}

/* Drawn like the globe's own place marker, without its dot: this place is not chosen yet. */
.offer__ring {
  position: absolute;
  top: -7px;
  left: -7px;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--snow);
  border-radius: 50%;
  box-shadow:
    0 0 0 1px rgb(0 0 0 / 0.45),
    inset 0 0 0 1px rgb(0 0 0 / 0.45);
  pointer-events: none;
}

.offer__button {
  position: absolute;
  bottom: 14px;
  left: 0;
  min-height: 44px;
  padding: 6px var(--s-4) 8px;
  transform: translateX(calc(-50% + var(--shift, 0px)));
  border: 1px solid var(--hairline);
  border-radius: var(--r-group);
  background: var(--night-glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  text-align: center;
  white-space: nowrap;
}

.offer[data-side='below'] .offer__button {
  top: 14px;
  bottom: auto;
}

.offer__button:hover {
  border-color: var(--hairline-strong);
}

.offer__button strong {
  display: block;
  font-weight: 600;
}

.offer__button span {
  display: block;
  color: var(--mist);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------------------------------------ sheet */

.sheet {
  position: fixed;
  top: var(--edge);
  left: var(--edge);
  z-index: var(--z-panel);
  display: flex;
  flex-direction: column;
  width: var(--panel-w);
  max-height: calc(100dvh - var(--edge) * 2);
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: var(--r-panel);
  background: var(--night);
}

.sheet__head {
  position: relative;
  flex: none;
  padding-bottom: 6px;
}

/* Once the body has scrolled, a rule marks where it passes under the head. */
.sheet.is-scrolled .sheet__head::after {
  content: '';
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  background: var(--hairline);
}

.sheet__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.sheet__grab {
  display: none;
}

/* Never seen: the sheet reads the safe-area insets off it. */
.sheet__safe {
  position: absolute;
  visibility: hidden;
  padding-top: var(--safe-t);
  padding-bottom: var(--safe-b);
}

.sheet h2 {
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.3;
}

/* Stale data and failures: said once, at the top, with the way out beside it. */
.notice {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin: var(--row-inset) var(--row-inset) 0;
  padding: var(--s-1) calc(var(--pad) - var(--row-inset));
  border-radius: var(--r-group);
  background: var(--raise-1);
  font-size: var(--text-sm);
  line-height: 1.4;
}

.notice p {
  flex: 1;
  padding-block: var(--s-1);
}

.notice .textbtn {
  flex: none;
  white-space: nowrap;
}

.status {
  padding: var(--s-4) var(--pad) var(--s-5);
}

.status p {
  margin-top: var(--s-1);
  color: var(--mist);
  line-height: 1.45;
}

.status .textbtn {
  margin-top: var(--s-2);
}

/* Until there is a forecast, the sheet holds one message and nothing else pretends to be ready. */
[data-state]:not([data-state='ready']) :is(.head, .lede, .window, .facts, .sheet__rest, .tl, .timechip, .legend) {
  display: none;
}

/* ------------------------------------------------------------------------------------------------ head */

.head__where {
  display: flex;
  align-items: center;
  padding: var(--row-inset) var(--row-inset) 0;
}

.place {
  display: grid;
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 5px calc(var(--pad) - var(--row-inset)) 6px;
  border-radius: var(--r-group);
}

.place:hover {
  background: var(--raise-1);
}

.place__name {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.3;
}

.place__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.place__name .icon {
  width: 18px;
  height: 18px;
  color: var(--mist);
}

/* --mist, not --dusk: the row takes a raised background on hover. */
.place__coords,
.place__example {
  color: var(--mist);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.head__when {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  margin-top: 6px;
  padding-inline: var(--pad);
  font-size: var(--text-sm);
  line-height: 18px;
}

.head__night {
  font-weight: 600;
  white-space: nowrap;
}

.head__countdown {
  color: var(--mist);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.verdict {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--s-3);
  margin-top: 2px;
  padding-inline: var(--pad);
}

.verdict__word {
  color: var(--status);
  font-size: var(--text-4xl);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.025em;
}

/* A night known only from the outlook gets no colour: a neutral word behind the board's hollow mark. */
.verdict__mark {
  display: none;
  width: 18px;
  height: 18px;
  margin-right: -3px;
  border: 3px solid var(--mist);
  border-radius: 50%;
}

.verdict[data-grade='typical'] .verdict__mark {
  display: block;
}

.verdict[data-grade='typical'] .verdict__word {
  color: var(--mist);
}

.badge {
  margin-top: 5px; /* sits on the word's x-height, not its line box */
  padding: 3px 10px 4px;
  border-radius: var(--r-full);
  background: var(--raise-2);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

/* ------------------------------------------------------------------------------------------------ the night */

.lede {
  padding-inline: var(--pad);
  font-weight: 450;
  line-height: 1.45;
  text-wrap: pretty;
}

.window {
  margin-top: 14px;
  padding-inline: var(--pad);
}

/* Times on the rails; the third column is as wide as a time, so the track under them ends where "Light by"
   ends and leaves a gutter on the right for the names of its two lanes. */
.window__grid {
  display: grid;
  grid-template-columns: var(--c1) calc(var(--c2) - var(--c1)) max-content minmax(0, 1fr);
  align-items: center;
}

.window[data-dark='all'] .window__grid {
  grid-template-columns: var(--c1) calc(var(--c2) - var(--c1)) 0 minmax(0, 1fr);
}

.window__times {
  display: contents;
}

.window__time {
  display: flex;
  flex-direction: column-reverse; /* the time reads first; its caption sits under it */
  grid-row: 1;
  min-width: 0;
}

.window__time dd {
  font-size: var(--text-3xl);
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.window__time dt {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--mist);
  font-size: var(--text-xs);
  line-height: 16px;
  white-space: nowrap;
}

.track__lane {
  position: relative;
  grid-column: 1 / 4;
}

.track__key {
  grid-column: 4;
  justify-self: end;
  color: var(--dusk);
  font-size: var(--text-2xs);
  line-height: 12px;
}

/* Room above the activity lane for the caret. */
.track__lane--activity,
.track__lane--activity + .track__key {
  margin-top: 13px;
}

.track__lane--cloud,
.track__lane--cloud + .track__key {
  margin-top: 2px;
}

.track__segs {
  display: flex;
  gap: 2px;
  height: 6px;
}

.track__segs i {
  flex: var(--w) 1 0;
  min-width: 0;
  border-radius: 1px;
  background: var(--c);
}

.track__segs i:first-child {
  border-radius: var(--r-mark) 1px 1px var(--r-mark);
}

.track__segs i:last-child {
  border-radius: 1px var(--r-mark) var(--r-mark) 1px;
}

.track__best {
  position: absolute;
  top: -8px;
  left: calc(var(--at) * 100%);
  transform: translateX(-50%);
}

.track__now {
  top: 1px; /* centred on the 6px lane */
  left: calc(var(--at) * 100%);
  transform: translateX(-50%);
}

/* A second, different strip: thinner, square, white by how much sky is covered, one cell per forecast hour. */
.track__cloud {
  display: flex;
  gap: 1px;
  height: 3px;
}

.track__cloud i {
  flex: var(--w) 1 0;
  min-width: 0;
  background: rgb(255 255 255 / calc(0.05 + var(--cover) * 0.7));
}

.window__words {
  color: var(--mist);
  line-height: 1.45;
}

/* ------------------------------------------------------------------------------------------------ three facts */

.facts {
  display: grid;
  grid-template-columns: var(--c1) calc(var(--c2) - var(--c1)) minmax(0, 1fr);
  margin: 14px var(--pad) 0;
}

.fact {
  min-width: 0;
  padding-right: var(--s-3);
}

/* The divider stands 12px left of the rail, so the fact's text still starts on it. */
.fact + .fact {
  margin-left: calc(var(--s-3) * -1);
  padding-left: calc(var(--s-3) - 1px);
  border-left: 1px solid var(--hairline);
}

.fact dt {
  color: var(--mist);
  font-size: var(--text-xs);
  line-height: 16px;
}

.fact__value {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 6px;
  color: var(--mist);
  font-size: var(--text-sm);
  line-height: 26px;
}

.fact__value b {
  color: var(--snow);
  font-size: var(--text-xl);
  font-weight: 650;
}

/* The level name shares the value's baseline without adding to the line's height. */
.fact__value span {
  line-height: 1;
}

.fact__value .moon {
  align-self: center;
}

.fact__value .moon path {
  fill: var(--snow);
}

.fact__note {
  color: var(--mist);
  font-size: var(--text-xs);
  line-height: 17px;
  font-variant-numeric: tabular-nums;
}

/* "NOAA says 1.67" is one figure: it may lean into the gap before the divider, but it does not break. */
.fact__note--figure {
  white-space: nowrap;
}

.source {
  margin: 10px var(--pad) 0;
  color: var(--dusk);
  font-size: var(--text-xs);
  line-height: 1.45;
  text-wrap: pretty;
}

.source a {
  color: var(--mist);
  white-space: nowrap;
}

/* ------------------------------------------------------------------------------------------------ nights board */

.board {
  margin-top: 14px;
  padding-bottom: var(--s-2);
  border-top: 1px solid var(--hairline);
}

.board h2 {
  padding: 10px var(--pad) 0;
}

/* The caption names the source; the column headings sit over the rails of the rows below. */
.board__cap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto calc(100% - var(--c2));
  align-items: end;
  padding: var(--s-2) var(--pad) var(--s-1);
  color: var(--mist);
  font-size: var(--text-xs);
  line-height: 16px;
}

.board__col {
  grid-column: 2;
  padding-right: var(--kp-rail);
  white-space: nowrap;
}

.board__col--status {
  grid-column: 3;
  padding-right: 0;
}

/* A long caption takes the line to itself and the headings drop under it. */
.board__group:not([data-group='forecast']) .board__cap > :first-child {
  grid-column: 1 / -1;
}

.board__group + .board__group {
  margin-top: var(--s-2);
  border-top: 1px solid var(--hairline);
}

.board__rows li {
  position: relative;
}

.board__rows li + li::before {
  content: '';
  position: absolute;
  inset: 0 var(--pad) auto;
  height: 1px;
  background: var(--hairline);
}

.board__rows li:has([aria-current])::before,
.board__rows li:has([aria-current]) + li::before {
  content: none;
}

.night,
.board__more {
  width: calc(100% - var(--row-inset) * 2);
  margin-inline: var(--row-inset);
  padding: 0 calc(var(--pad) - var(--row-inset));
  border-radius: var(--r-group);
}

.night {
  display: grid;
  grid-template-columns: var(--moon-col) calc(var(--c1) - var(--moon-col)) 46px minmax(0, 1fr) calc(100% - var(--c2));
  align-items: center;
  height: 44px;
}

.night:hover,
.board__more:hover {
  background: var(--raise-1);
}

.night[aria-current] {
  background: var(--raise-2);
}

.night__date {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Weekday and day number each keep a rail of their own, so 25, 26, 27 stack. */
.night__wd {
  width: 32px;
}

.night__dd {
  width: 18px;
  text-align: right;
}

.night__mo {
  align-self: baseline;
  color: var(--mist);
  font-size: var(--text-sm);
  font-weight: 500;
}

/* A night's activity in miniature, on the timeline's own 0 to 9 scale and standing on the text baseline. */
/* Every bar stands on a 3px plinth, so a quiet night is still a row of bars and not a row of crumbs. */
.strip {
  --strip-h: 24px;
  --plinth: 3px;
  --u: calc((var(--strip-h) - var(--plinth)) / 9);
  display: flex;
  align-items: flex-end;
  align-self: end;
  gap: 2px;
  height: var(--strip-h);
  margin-bottom: 16px;
}

.strip i {
  width: 4px;
  height: calc(var(--plinth) + var(--kp) * var(--u));
  border-radius: 1.5px 1.5px 0 0;
  background: var(--c);
}

/* Past the forecast a night has one value, so it has one mark, as wide as the eight bars it replaces:
   the typical level, solid, inside the range the night is likely to stay in. */
.strip .strip__range {
  position: relative;
  width: 46px;
  height: calc(var(--plinth) + var(--hi) * var(--u));
  border-radius: 2px 2px 0 0;
  background: var(--neutral-range);
}

.strip .strip__typ {
  position: absolute;
  inset: auto 0 0;
  width: auto;
  height: calc(var(--plinth) + var(--kp) * var(--u));
  border-radius: 0;
  background: var(--neutral-mark);
}

/* Extended outlook: the same mark, drawn hollow. */
.night[data-group='extended'] .strip__range {
  border: 1px solid var(--neutral-line);
  border-radius: 2px;
  background: none;
}

.night[data-group='extended'] .strip__typ {
  inset: auto 0 calc(var(--plinth) + var(--kp) * var(--u) - 2px);
  height: 1px;
  background: var(--neutral-line);
}

.night__kp {
  padding-right: var(--kp-rail);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.night__status {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  white-space: nowrap;
}

.dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status);
}

/* Outlook nights give up colour, extended nights give up contrast too. Never --dusk: rows change background. */
.night[data-grade='typical'] .dot {
  border: 1.5px solid var(--mist);
  background: none;
}

.night[data-grade='typical'] .night__kp,
.night[data-group='extended'] {
  color: var(--mist);
}

.night[data-group='extended'] .night__date {
  font-weight: 500;
}

.board__more {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--mist);
  font-size: var(--text-sm);
}

.board__more .icon {
  width: 16px;
  height: 16px;
  margin-right: var(--s-2);
}

.board__more[aria-expanded='true'] .icon {
  transform: rotate(180deg);
}

/* ------------------------------------------------------------------------------------------------ right now */

.now {
  margin-top: var(--s-2);
  padding: var(--s-3) var(--pad) var(--s-1);
  border-top: 1px solid var(--hairline);
}

.readings {
  margin-top: 6px;
}

/* Numbers end on the board's Kp rail, units hang after it, the Bz trace sits in the strip column. */
.reading {
  display: grid;
  grid-template-columns: var(--c1) 46px minmax(0, 1fr) calc(100% - var(--c2) + var(--kp-rail) - 6px);
  align-items: baseline;
  min-height: 32px;
}

.reading dt {
  grid-column: 1;
  color: var(--mist);
  white-space: nowrap;
}

.reading__spark {
  grid-column: 2;
  align-self: center;
  height: 20px;
}

.reading__value {
  grid-column: 3;
  padding-right: 6px;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.reading__unit {
  grid-column: 4;
  color: var(--mist);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.spark {
  display: block;
  overflow: visible;
  fill: none;
}

.spark__zero {
  stroke: var(--hairline-strong);
  stroke-width: 1;
}

.spark__line {
  stroke: var(--mist);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.now__watches {
  margin-top: var(--s-2);
}

.now__watches li {
  padding: 10px 0 0;
  border-top: 1px solid var(--hairline);
  font-weight: 600;
}

.now__rationale {
  margin-top: var(--s-1);
  color: var(--mist);
  font-size: var(--text-sm);
  line-height: 1.45;
  text-wrap: pretty;
}

.now .caption {
  margin-top: var(--s-3);
}

.sheet__foot {
  margin-top: var(--s-3);
  padding: var(--s-1) var(--row-inset) var(--s-2);
  border-top: 1px solid var(--hairline);
}

.sheet__foot .textbtn {
  padding: 0 calc(var(--pad) - var(--row-inset));
}

/* ------------------------------------------------------------------------------------------------ timeline */

/* One Kp axis, 0 to 9. The headroom above quiet bars is used on a 16px grid: zone captions on the first
   line, marks such as a storm watch on the second, the G1 label on the reference line itself. */
.tl {
  --plot-h: 104px;
  --u: calc(var(--plot-h) / 9);
  --axis-h: 18px;
  --line: 16px;
  --grip: 7px; /* how far the playhead stands above the plot */
}

.tl[data-mode='dock'] {
  position: fixed;
  right: var(--edge);
  bottom: var(--edge);
  left: calc(var(--edge) * 2 + var(--panel-w));
  z-index: var(--z-panel);
  height: var(--dock-h);
  padding: 12px var(--dock-pad) 0;
  border: 1px solid var(--hairline);
  border-radius: var(--r-panel);
  background: var(--night);
}

.tl__frame {
  position: relative;
}

.tl__view {
  position: relative;
  border-radius: var(--s-1);
  cursor: default;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* The ring stands clear of the bars and of the playhead's grip. */
.tl__view:focus-visible {
  box-shadow: 0 0 0 8px var(--night), 0 0 0 10px var(--snow);
}

.tl__strip {
  position: relative;
  flex: none;
}

.tl__plot {
  position: relative;
  height: var(--plot-h);
  border-bottom: 1px solid var(--hairline-strong);
}

/* The one reference: Kp 5-, where a G1 storm starts. Dashed, so it cannot be read as an axis or a border. */
.tl__g1 {
  position: absolute;
  right: 0;
  bottom: calc(4.67 * var(--u));
  left: 0;
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--hairline-strong) 0 3px, transparent 3px 6px);
}

.tl__bound {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  margin-left: -0.5px;
  background: var(--hairline);
}

.tl__step {
  position: absolute;
  top: 0;
  bottom: 0;
}

.tl__step b {
  position: absolute;
  right: 0;
  left: 0;
  display: block;
  transition: transform var(--t-fast) var(--ease-out);
}

/* The hovered step: a faint column says which one the readout is about, and its marks lift. */
.tl__step.is-hover {
  border-radius: var(--r-mark);
  background: var(--raise-1);
}

.tl__step.is-hover b {
  transform: translateY(-2px);
}

.tl__bar {
  bottom: 0;
  height: max(2px, calc(var(--kp) * var(--u)));
  border-radius: var(--r-mark) var(--r-mark) 0 0;
  background: var(--c);
}

/* Forecast: a ghost behind the bar reaches the level exceeded about one time in ten. */
.tl__ghost {
  bottom: 0;
  height: calc(var(--hi) * var(--u));
  border-radius: var(--r-mark) var(--r-mark) 0 0;
  background: color-mix(in srgb, var(--c) 24%, transparent);
}

/* NOAA's own figure, kept beside ours: one neutral tick everywhere, narrower than the bar, with a keyline
   above and below so it reads across a bar without becoming the loudest mark on the strip. */
.tl__step .tl__noaa {
  right: 20%;
  bottom: calc(var(--noaa) * var(--u) - 1px);
  left: 20%;
  height: 2px;
  background: var(--mist);
  box-shadow: 0 1px 0 var(--night), 0 -1px 0 var(--night);
}

/* Outlook: the range the day is likely to stay in, and a line at its typical level. */
.tl__range {
  bottom: calc(var(--lo) * var(--u));
  height: calc((var(--hi) - var(--lo)) * var(--u));
  border-radius: var(--r-mark);
  background: var(--neutral-range);
}

.tl__typ {
  bottom: calc(var(--kp) * var(--u));
  height: 1px;
  background: var(--mist);
}

.tl__step--extended .tl__range {
  border: 1px solid var(--neutral-line);
  background: none;
}

.tl__step--extended .tl__typ {
  right: 1px;
  left: 1px;
  background: var(--dusk);
}

.tl__zone {
  position: absolute;
  top: 0;
  height: var(--line);
  pointer-events: none;
}

/* A caption keeps a backing: only a severe storm reaches this high, and it must stay legible when one does. */
.tl__cap {
  position: relative;
  display: inline-block;
  padding-right: 6px;
  background: var(--night);
  color: var(--mist);
  font-size: var(--text-xs);
  line-height: 14px;
  white-space: nowrap;
  vertical-align: top;
}

/* A storm watch or an expected arrival: its name, and a rule over the steps it covers. */
.tl__mark {
  position: absolute;
  top: var(--line);
  height: 14px;
  border-bottom: 1px solid var(--mist);
  pointer-events: none;
}

.tl__mark span {
  position: absolute;
  bottom: 2px;
  left: 0;
  padding-right: 6px;
  background: var(--night);
  color: var(--mist);
  font-size: var(--text-2xs);
  line-height: 12px;
  white-space: nowrap;
}

/* Now is the boundary between what was observed and what is forecast. */
.tl__now {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  margin-left: -0.5px;
  background: rgb(241 244 247 / 0.45);
  pointer-events: none;
}

.tl__now .now-mark {
  bottom: calc(var(--now-kp) * var(--u));
  left: 50%;
  transform: translate(-50%, 50%);
}

.tl__axis {
  position: relative;
  height: var(--axis-h);
}

.tl__tick {
  position: absolute;
  top: 6px;
  color: var(--dusk);
  font-size: var(--text-2xs);
  line-height: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tl__tick::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 0;
  width: 1px;
  height: 3px;
  background: var(--hairline-strong);
}

/* The only snow label on the axis, tied to its line by a caret. */
.tl__tick--now {
  transform: translateX(-50%);
  color: var(--snow);
  font-weight: 600;
}

.tl__tick--now::before {
  top: -5px;
  left: 50%;
  width: 7px;
  height: 4px;
  margin-left: -3.5px;
  background: var(--snow);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

/* The playhead: the selected moment. Its grip stands above the plot, clear of the captions. */
.tl__playhead {
  position: absolute;
  top: calc(var(--grip) * -1);
  left: 0;
  width: 1px;
  height: calc(var(--plot-h) + var(--grip));
  margin-left: -0.5px;
  background: var(--snow);
  pointer-events: none;
  transition: transform var(--t-fast) var(--ease-out);
}

.tl.is-scrubbing .tl__playhead {
  transition: none;
}

.tl__grip {
  position: absolute;
  top: 0;
  left: 50%;
  width: 9px;
  height: 6px;
  margin-left: -4.5px;
  border-radius: 2px;
  background: var(--snow);
}

/* The right end of the strip carries what explains it: how fresh it is, what the tick is, what the line is. */
.tl__side {
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  grid-template-rows: var(--line) var(--line);
  justify-items: end;
  pointer-events: none;
}

.tl__side p {
  padding-left: var(--s-2);
  background: var(--night);
  color: var(--dusk);
  font-size: var(--text-2xs);
  line-height: 14px;
  white-space: nowrap;
}

.tl__side .tl__updated {
  grid-row: 1;
  font-size: var(--text-xs);
}

.tl__key {
  display: flex;
  grid-row: 2;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.tl__key-tick {
  width: 8px;
  height: 2px;
  background: var(--mist);
}

.tl__side .tl__g1-label {
  position: absolute;
  top: calc(var(--plot-h) - 4.67 * var(--u) - 16px);
  right: 0;
}

.tl__tip {
  position: absolute;
  bottom: calc(100% + 22px);
  z-index: 1;
  max-width: min(330px, 100%);
  padding: 6px 10px 7px;
  border: 1px solid var(--hairline-strong);
  border-radius: 10px;
  background: var(--night-2);
  font-size: var(--text-sm);
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  text-wrap: pretty;
}

.tl__foot {
  display: none;
}

/* ------------------------------------------------------------------------------------------------ dialogs */

.dialog {
  width: min(440px, 100vw - var(--s-4));
  max-height: min(660px, 100dvh - var(--s-8));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-panel);
  background: var(--night);
  color: var(--snow);
}

.dialog[open] {
  display: flex;
  flex-direction: column;
}

.dialog::backdrop {
  background: rgb(0 0 0 / 0.6);
}

.dialog__head {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-2) var(--s-2) 0 var(--s-5);
}

.dialog__head h2 {
  font-size: var(--text-lg);
  font-weight: 600;
}

.dialog__body {
  min-height: 0;
  padding: var(--s-2) var(--s-5) var(--s-5);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.picker .dialog__body {
  padding-inline: var(--s-2);
}

.picker__search {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  height: 48px;
  margin-inline: var(--s-1);
  padding: 0 var(--s-3);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-group);
  background: var(--night-2);
  color: var(--mist);
}

.picker__search:focus-within {
  box-shadow: var(--focus);
}

/* 16px: a smaller field makes a phone zoom the page on focus. */
.picker__input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--snow);
  font: inherit;
  font-size: 1rem;
  appearance: none;
}

.picker__input:focus-visible {
  box-shadow: none;
}

.picker__input::placeholder {
  color: var(--mist);
  opacity: 1;
}

.picker__input::-webkit-search-cancel-button {
  appearance: none;
}

.picker__locate {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  margin-top: var(--s-2);
  padding: 0 var(--s-4);
  border-radius: var(--r-group);
  font-weight: 600;
}

.picker__locate .icon {
  color: var(--mist);
}

.picker__locate:hover,
.picker__option:hover,
.picker__option[aria-selected='true'] {
  background: var(--raise-2);
}

.picker__status {
  padding: var(--s-2) var(--s-4);
  color: var(--mist);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.picker__label {
  margin-top: var(--s-2);
  padding: var(--s-2) var(--s-4) var(--s-1);
  color: var(--mist);
  font-size: var(--text-xs);
}

.picker__option {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 52px;
  padding: 6px var(--s-4) 7px;
  border-radius: var(--r-group);
  cursor: pointer;
}

.picker__name {
  font-weight: 600;
}

.picker__where {
  color: var(--mist);
  font-size: var(--text-sm);
}

.about {
  width: min(580px, 100vw - var(--s-4));
}

.about p,
.about dd,
.about li {
  line-height: 1.5;
  text-wrap: pretty;
}

.about h3 {
  margin-top: var(--s-6);
  margin-bottom: var(--s-1);
  font-weight: 600;
}

.about p + p {
  margin-top: var(--s-2);
}

.about section p,
.about dd,
.about__credits li,
.about__state {
  color: var(--mist);
}

.about__terms dt {
  margin-top: var(--s-3);
  font-weight: 600;
}

.about__terms dt:first-child {
  margin-top: var(--s-1);
}

.about__sources li {
  display: flex;
  flex-direction: column;
  padding: var(--s-2) 0;
  border-top: 1px solid var(--hairline);
}

.about__state,
.about__credits li {
  font-size: var(--text-sm);
}

.about__credits li + li {
  margin-top: 6px;
}

/* ------------------------------------------------------------------------------------------------ narrow desktop */

/* Less room beside the chip: the legend's caption takes two lines and the ramp sits under it. */
@media (max-width: 1199px) {
  :root {
    --dock-pad: var(--s-4);
  }

  .legend {
    width: 112px;
  }
}

/* 720 to 1023: a 340px sheet, and the dock runs the full width under it so the strip keeps its bars. */
@media (max-width: 1023px) {
  :root {
    --panel-w: 340px;
    --pad: var(--s-4);
    --c1: 96px;
    --c2: 192px;
    --kp-rail: 14px;
  }

  .sheet {
    max-height: calc(100dvh - var(--edge) * 2 - var(--dock-h) - var(--dock-gap));
  }

  .tl[data-mode='dock'] {
    left: var(--edge);
  }

  /* The free area is narrow and tall here, so the legend stands above the chip instead of beside it. */
  .legend {
    bottom: calc(var(--edge) * 2 + var(--dock-h) + 68px);
  }

  .window__time dd {
    font-size: 1.625rem; /* 26, as on a phone: three times must fit the narrower sheet */
  }

  /* No room for the month beside the date; the 1st of a month is plain enough. */
  .night__mo {
    display: none;
  }

  /* Nor for NOAA's figure on one line: unbroken, it would run through the divider into the next fact. */
  .fact__note--figure {
    white-space: normal;
  }
}

/* ------------------------------------------------------------------------------------------------ phone */

@media (max-width: 719px) {
  :root {
    --pad: var(--s-4);
    --content: calc(100vw - var(--pad) * 2);
    --c1: calc(var(--content) / 3);
    --c2: calc(var(--content) * 2 / 3);
    --kp-rail: 16px;
  }

  .topbar {
    top: calc(var(--s-2) + var(--safe-t));
    right: calc(var(--s-2) + var(--safe-r));
  }

  .legend {
    display: none;
  }

  /* Dialogs hang from the top, where an on-screen keyboard does not cover them. */
  .dialog {
    max-height: calc(100dvh - var(--s-6) - var(--safe-t));
    margin-top: calc(var(--s-3) + var(--safe-t));
  }

  /* The chip rides on the sheet's top edge, moving with it. */
  .timechip {
    bottom: var(--s-3);
    left: 50%;
    transform: translate(-50%, calc(var(--sheet-h) * -1));
    transition: transform var(--t-sheet) var(--ease-sheet);
  }

  /* At the full stop the globe is covered, so there is nothing for the chip to describe. */
  :root[data-sheet='full'] .timechip {
    visibility: hidden;
  }

  .sheet {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    height: var(--sheet-full);
    max-height: none;
    transform: translateY(calc(var(--sheet-full) - var(--sheet-h)));
    border-width: 1px 0 0;
    border-radius: var(--r-panel) var(--r-panel) 0 0;
    transition: transform var(--t-sheet) var(--ease-sheet);
  }

  .is-sheet-dragging :is(.sheet, .timechip) {
    transition: none;
  }

  .sheet__head {
    padding-bottom: 0;
    touch-action: none;
  }

  /* The handle is a real control: 44px to the finger, with the stops on the arrow keys. */
  .sheet__grab {
    position: relative;
    display: grid;
    place-items: center;
    width: 120px;
    height: 22px;
    margin-inline: auto;
    cursor: grab;
  }

  .sheet__grab::after {
    content: '';
    position: absolute;
    inset: 0 0 -22px;
  }

  .sheet__grab i {
    width: 36px;
    height: 5px;
    border-radius: var(--r-full);
    background: rgb(255 255 255 / 0.4);
  }

  .sheet__grab:focus-visible {
    box-shadow: none;
  }

  .sheet__grab:focus-visible i {
    box-shadow: var(--focus);
  }

  /* Below the full stop the body does not scroll; a drag anywhere on it moves the sheet. */
  .sheet__body {
    overflow-y: hidden;
    padding-bottom: calc(var(--s-4) + var(--safe-b));
    touch-action: none;
  }

  .sheet[data-stop='full'] .sheet__body {
    overflow-y: auto;
    touch-action: pan-y;
  }

  /* What lies below a stop is hidden, never cut through. */
  .sheet[data-reveal='peek'] :is([data-half-block], .sheet__rest),
  .sheet[data-reveal='half'] :is(.sheet__rest, .is-below-half) {
    visibility: hidden;
  }

  .notice {
    margin-top: 0;
    margin-bottom: var(--s-2);
  }

  /* Which night and when on the first line; the answer on the second, with the place opposite. */
  .head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      'when    when'
      'verdict where';
    align-items: center;
    padding-inline: var(--pad);
  }

  .head__when {
    grid-area: when;
    margin-top: 0;
    padding: 0;
  }

  .head__where {
    grid-area: where;
    max-width: 40vw;
    margin-right: calc(var(--s-2) * -1);
    padding: 0;
  }

  .locate,
  .place__country,
  .place__coords {
    display: none;
  }

  .place {
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    align-items: center;
    justify-content: flex-end;
    padding: 0 var(--s-2) 0 var(--s-3);
  }

  /* An example place says so under its name. The invitation to choose is the button itself. */
  .place__example {
    flex-basis: 100%;
    line-height: 1.2;
    text-align: right;
  }

  .place__example span {
    display: none;
  }

  .verdict {
    grid-area: verdict;
    min-height: 44px;
    margin-top: 0;
    padding: 0;
  }

  .verdict__word {
    font-size: 2.125rem; /* 34: the type roles give the verdict and the times a phone size outside the scale */
  }

  .verdict__mark {
    width: 16px;
    height: 16px;
  }

  .badge {
    margin-top: 4px;
  }

  .lede {
    margin-top: var(--s-3);
  }

  .window__time dd {
    font-size: 1.625rem; /* 26 */
  }

  /* The dock becomes a tape: the strip scrolls under a playhead fixed at the centre. */
  .tl[data-mode='tape'] {
    --plot-h: 100px;
    position: relative;
    margin-top: var(--s-2);
  }

  .tl[data-mode='tape'] .tl__frame {
    padding-top: var(--grip);
  }

  .tl[data-mode='tape'] .tl__view {
    display: flex;
    overflow: auto hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    border-radius: 0;
    touch-action: pan-x;
  }

  .tl[data-mode='tape'] .tl__view::-webkit-scrollbar {
    display: none;
  }

  /* Half a view of nothing on each side, so the first and last steps can reach the playhead. */
  .tl[data-mode='tape'] .tl__view::before,
  .tl[data-mode='tape'] .tl__view::after {
    content: '';
    flex: 0 0 50%;
  }

  .tl[data-mode='tape'] .tl__view:focus-visible {
    box-shadow: inset 0 0 0 2px var(--snow);
  }

  .tl__snap {
    position: absolute;
    top: 0;
    width: 1px;
    height: 1px;
    scroll-snap-align: center;
  }

  /* A zone's caption stays in view for as long as its zone does. */
  .tl[data-mode='tape'] .tl__cap {
    position: sticky;
    left: var(--pad);
  }

  .tl[data-mode='tape'] .tl__playhead {
    top: 0;
    left: 50%;
  }

  .tl[data-mode='tape'] .tl__side {
    top: var(--grip);
    right: var(--pad);
  }

  /* Captions scroll through the headroom here, so the key and the freshness take a line under the tape. */
  .tl[data-mode='tape'] .tl__side .tl__key {
    display: none;
  }

  .tl[data-mode='tape'] .tl__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    margin: var(--s-2) var(--pad) 0;
    color: var(--dusk);
    font-size: var(--text-xs);
    line-height: 16px;
  }
}

@media (max-width: 359px) {
  /* Thirds would leave no gutter beside the track for the names of its lanes. */
  :root {
    --c1: 88px;
    --c2: 176px;
    --kp-rail: 14px;
  }

  /* Too narrow for NOAA's figure on one line. */
  .fact__note--figure {
    white-space: normal;
  }

  /* Every caption takes its own line here, with the column headings under it. */
  .board__group .board__cap > :first-child {
    grid-column: 1 / -1;
  }

  .night__mo {
    display: none;
  }

}

/* ------------------------------------------------------------------------------------------------ no script */

.noscript {
  max-width: 34rem;
  padding: var(--s-6);
  color: var(--mist);
  line-height: 1.45;
}
