/* Lorhor — Singapore rain, observed and predicted.
 *
 * One rule governs the palette: the rain is the only saturated thing on the
 * page. The radar publishes in NEA's 33-step scale, which is loud by design and
 * carries the whole reading; every other surface here is a cool neutral so that
 * nothing competes with it. Observed and predicted are told apart by weight and
 * opacity rather than by hue, for the same reason — a second accent colour
 * would be a third thing claiming to mean something. */

:root {
  --bg:      #0d1317;
  --panel:   #141d23;
  --rule:    #223038;
  --ink:     #e8eef1;
  --dim:     #8399a5;
  --faint:   #4c606b;

  --display: "IBM Plex Sans Condensed", "Helvetica Neue", Arial, sans-serif;
  --body:    "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --gutter:  clamp(1rem, 4vw, 2.5rem);
  --shell:   1080px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }

/* ── header rail ─────────────────────────────────────────────────────────── */

.rail {
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
  flex-wrap: wrap;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 1.4rem var(--gutter) 1rem;
  border-bottom: 1px solid var(--rule);
}

.mark {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.tagline {
  margin: 0;
  flex: 1 1 12rem;
  color: var(--dim);
  font-size: 0.85rem;
}

.live {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.live .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
}

.live[data-state="live"] .dot   { background: #00ca11; }
.live[data-state="stale"] .dot  { background: #ffb200; }
.live[data-state="down"] .dot   { background: #ff4900; }
.live[data-state="live"]        { color: var(--ink); }

/* ── the map ─────────────────────────────────────────────────────────────── */

main {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 var(--gutter) 3.5rem;
}

.stage { margin: 1.75rem 0 0; }

.plate {
  position: relative;
  background: #ededed;
  border: 1px solid var(--rule);
}

.base { display: block; width: 100%; height: auto; }

/* The overlay is 217 × 120 and the base map is 853 × 479; stretching the first
 * onto the second registers to the coastline within a pixel, which is measured
 * rather than assumed. It arrives already interpolated and feathered — see
 * SCALE in app.js — because a hard cell edge claims a boundary the model does
 * not resolve either, and a soft one reads as the estimate it is. The alpha is
 * the other half of that: rain you cannot place against a coastline is a
 * coloured blob, so the map stays visible through it. */
.rain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.78;
}

.void {
  position: absolute;
  inset: auto 0 0 0;
  margin: 0;
  padding: 0.5rem;
  background: rgba(13, 19, 23, 0.82);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.readout {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  flex-wrap: wrap;
  margin: 0.7rem 0 0;
}

.readout .clock {
  font-family: var(--mono);
  font-size: 1.65rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.readout .kind {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.readout .rel {
  margin-left: auto;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

/* ── the strip ───────────────────────────────────────────────────────────── */

.timeline { margin: 1.9rem 0 0; }

.controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.play,
.now-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 2px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.06em;
}

.play:hover,
.now-btn:hover { border-color: var(--dim); }

.play svg { width: 10px; height: 12px; fill: currentColor; }
.play .icon-pause { display: none; }
.play[data-playing="true"] .icon-play  { display: none; }
.play[data-playing="true"] .icon-pause { display: block; }

.strip {
  position: relative;
  height: 104px;
  padding-top: 18px;
  cursor: crosshair;
  touch-action: none;
}

.strip:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }

.bars { position: absolute; inset: 18px 0 1px; }

.bar {
  position: absolute;
  bottom: 0;
  min-height: 2px;
  background: var(--faint);
}

/* Three states, three opacities, no third colour: what the radar saw, what the
 * model predicts on its dense grid, and what it predicts on the half-hour grid
 * past two hours. Confidence falls in steps, so it is drawn in steps. */
.bar[data-kind="observed"]  { opacity: 1; }
.bar[data-kind="dense"]     { opacity: 0.75; }
.bar[data-kind="coarse"]    { opacity: 0.50; }

.bar[data-void="true"] {
  background: none;
  border-top: 1px solid var(--faint);
  opacity: 0.75;
}

.bar.sel { opacity: 1; box-shadow: 0 0 0 1px var(--ink); }

.baseline { position: absolute; bottom: 0; height: 1px; }

.baseline.observed { left: 0; background: var(--dim); }

.baseline.predicted {
  right: 0;
  background: repeating-linear-gradient(
    to right, var(--faint) 0 3px, transparent 3px 6px);
}

.nowrule {
  position: absolute;
  top: 4px;
  bottom: 0;
  width: 1px;
  background: var(--rule);
}

.nowrule span {
  position: absolute;
  top: -4px;
  left: 5px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.playhead {
  position: absolute;
  top: 14px;
  bottom: 0;
  width: 1px;
  background: var(--ink);
  opacity: 0.45;
  pointer-events: none;
}

.axis { position: relative; height: 1.5rem; margin-top: 0.3rem; }

.axis span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.68rem;
  white-space: nowrap;
}

/* ── notes ───────────────────────────────────────────────────────────────── */

.notes {
  display: grid;
  gap: 1.75rem 2.5rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  margin-top: 2.75rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--rule);
}

.notes .lbl {
  margin: 0 0 0.65rem;
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.notes .fine {
  margin: 0.7rem 0 0;
  color: var(--dim);
  font-size: 0.78rem;
  line-height: 1.5;
}

.ramp { display: flex; height: 12px; }
.ramp i { flex: 1; }

.ends {
  display: flex;
  justify-content: space-between;
  margin: 0.35rem 0 0;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.68rem;
}

/* Two columns, aligned at the top rather than centred: a one-line term beside a
 * four-line description should share its first baseline, not float in the
 * middle of it. */
.notes dl {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 0.3rem 0.9rem;
  margin: 0;
  font-size: 0.78rem;
}

.notes dt {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--mono);
  white-space: nowrap;
}

.notes dd { margin: 0; color: var(--dim); }

/* The strip key stacks instead, because its descriptions are sentences and its
 * column is a third of the page. Written after the rule it overrides and at a
 * specificity that says so, rather than relying on source order. */
.notes .key dl { grid-template-columns: 1fr; gap: 0; }
.notes .key dd { margin: 0.15rem 0 0.85rem; }
.notes .key dd:last-of-type { margin-bottom: 0; }

.swatch { width: 9px; height: 12px; background: var(--ink); }
.swatch.dense  { opacity: 0.75; }
.swatch.coarse { opacity: 0.50; }

.provenance dd { font-family: var(--mono); color: var(--dim); }

/* ── method ──────────────────────────────────────────────────────────────── */

.method {
  margin-top: 2.75rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--rule);
}

.method h2 {
  margin: 0 0 0.9rem;
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.method p {
  margin: 0 0 0.8rem;
  color: var(--dim);
  font-size: 0.85rem;
  line-height: 1.65;
}

.method p:last-child { margin-bottom: 0; }

/* One column, running the full width of the page rather than stopping short of
 * it. */
.colophon {
  margin: 2.25rem 0 0;
  color: var(--faint);
  font-size: 0.76rem;
  line-height: 1.6;
}

.fault {
  margin: 1.5rem 0 0;
  padding: 0.85rem 1rem;
  border-left: 2px solid #ff4900;
  background: var(--panel);
  font-size: 0.82rem;
}

/* ── narrow ──────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .strip { height: 84px; }
  .readout .clock { font-size: 1.35rem; }
  .readout .rel { margin-left: 0; width: 100%; }
}

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