/* Wind at the flying field. Grass, windsock orange and an overcast sky. */

@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url("fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 700; font-display: swap; src: url("fonts/barlow-latin-700-normal.woff2") format("woff2"); }

:root {
  --sky: #eef3f1;          /* overcast: the page background */
  --ink: #1f2d29;          /* hedge-dark text */
  --muted: #55665f;
  --rule: #cbd8d1;
  --field: #dfe9d6;        /* the field around the strip */
  --mown-a: #8cb066;       /* mown stripes on the strip */
  --mown-b: #79a056;
  --sock: #ee6a1f;         /* windsock orange: the wind itself */
  --sock-soft: rgba(238, 106, 31, 0.18);
  --warn-bg: #fff3d6;
  --warn-ink: #6b4500;
  --bad-bg: #fbe3e1;
  --bad-ink: #7d1f17;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--sky);
  color: var(--ink);
  font: 400 1rem/1.45 "Barlow", "Segoe UI", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

.wx { max-width: 760px; margin: 0 auto; padding: 16px 16px 20px; }

/* Header: the title and the units switch */
.wx-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.wx-head h1 { margin: 0; font-size: 1.375rem; font-weight: 600; line-height: 1.2; }

.units { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; padding: 2px; background: #fff; }
.units button {
  font: inherit; font-weight: 500; font-size: 0.9375rem;
  border: 0; background: transparent; color: var(--muted);
  padding: 4px 12px; border-radius: 999px; cursor: pointer;
}
.units button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.units button:focus-visible { outline: 2px solid var(--sock); outline-offset: 2px; }

/* Status line: plain when live, tinted when something is off */
.wx-status { margin: 8px 0 4px; color: var(--muted); font-size: 0.9375rem; min-height: 1.45em; }
.wx-status.is-warn, .wx-status.is-bad { padding: 8px 12px; border-radius: 8px; }
.wx-status.is-warn { background: var(--warn-bg); color: var(--warn-ink); }
.wx-status.is-bad { background: var(--bad-bg); color: var(--bad-ink); }
.wx-status .battery { display: block; margin-top: 4px; font-weight: 500; }

/* Now: the field drawing beside the numbers */
.wx-now { display: grid; grid-template-columns: minmax(200px, 290px) 1fr; gap: 8px 28px; align-items: center; margin-top: 4px; }
.field { margin: 0; }
.field svg { display: block; width: 100%; height: auto; }

.readout { min-width: 0; }
.speed { margin: 0; line-height: 0.9; }
.speed-num { font-size: clamp(4rem, 12vw, 5.75rem); font-weight: 700; letter-spacing: -0.02em; }
.speed-unit { font-size: 1.5rem; font-weight: 500; color: var(--muted); }
.gust { margin: 6px 0 0; font-size: 1.5rem; font-weight: 500; }
.dir { margin: 2px 0 0; font-size: 1.125rem; color: var(--muted); }

.advice { margin-top: 16px; padding-left: 14px; border-left: 4px solid var(--sock); }
.advice h2 { margin: 0; font-size: 1.25rem; font-weight: 600; line-height: 1.25; }
.advice p { margin: 2px 0 0; max-width: 34em; }

.is-stale .speed, .is-stale .gust, .is-stale .dir, .is-stale .advice, .is-stale .field { opacity: 0.55; }

/* Chart */
.wx-chart { margin-top: 22px; }
.wx-chart h2 { margin: 0 0 4px; font-size: 1.0625rem; font-weight: 600; }
.wx-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--rule); stroke-width: 1; }
.chart-label { fill: var(--muted); font: 500 13px "Barlow", system-ui, sans-serif; }
.chart-band { fill: var(--sock-soft); }
.chart-gust { fill: none; stroke: var(--sock); stroke-width: 2; stroke-linejoin: round; }
.chart-mean { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--ink); }
.chart-arrow { fill: var(--ink); }
.chart-empty { fill: var(--muted); font: 500 15px "Barlow", system-ui, sans-serif; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 6px 0 0; padding: 0; list-style: none; font-size: 0.875rem; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 18px; height: 0; border-top: 3px solid var(--ink); }
.key-gust { border-top: 2px solid var(--sock); box-shadow: 0 5px 0 0 var(--sock-soft); }
.key-dir { width: 0; height: 0; border-top: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 9px solid var(--ink); }

/* The smaller readings */
.wx-extra { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--rule); }
.wx-extra div { min-width: 0; }
.wx-extra dt { font-size: 0.875rem; color: var(--muted); }
.wx-extra dd { margin: 0; font-size: 1.25rem; font-weight: 600; }

.wx-foot { margin: 14px 0 0; font-size: 0.875rem; color: var(--muted); }

/* Field drawing */
.f-ground { fill: var(--field); }
.f-ring { fill: none; stroke: var(--rule); stroke-width: 1.5; }
.f-tick { stroke: #a9b9b1; stroke-width: 1.5; }
.f-cardinal { fill: var(--muted); font: 600 13px "Barlow", system-ui, sans-serif; text-anchor: middle; dominant-baseline: central; }
.f-mown-a { fill: var(--mown-a); }
.f-mown-b { fill: var(--mown-b); }
.f-strip-edge { fill: none; stroke: #5f8743; stroke-width: 1; }
.f-takeoff { fill: #fff; stroke: #5f8743; stroke-width: 0.8; stroke-linejoin: round; }
.f-spread { fill: var(--sock-soft); }
.f-arrow { fill: var(--sock); }
.f-arrow-g { transition: transform 700ms cubic-bezier(.2, .7, .2, 1); }
.f-calm { fill: var(--sock); }

@media (max-width: 560px) {
  .wx-now { grid-template-columns: 1fr; }
  .field { width: min(78vw, 280px); margin: 0 auto; }
  .readout { text-align: left; }
  .wx-extra { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .f-arrow-g { transition: none; }
}
