/* Weather Recorder: an instrument housing around a roll of chart paper. */

:root {
  color-scheme: dark;

  /* housing */
  --housing: #1d2925;
  --housing-raised: #25332e;
  --housing-edge: #34453f;
  --text: #e8ede4;
  --muted: #a3b3aa;

  /* chart paper + inks */
  --paper: #f2f5ee;
  --paper-shade: #e6ebe2;
  --grid-major: #a7c3ad;
  --grid-minor: #d5e3d5;
  --ink-text: #1f2a26;
  --ink-soft: #5a6a62;
  --ink-temp: #c4313b;
  --ink-precip: #2160b0;
  --ink-precip-wash: rgba(33, 96, 176, 0.14);

  /* the one warm metal: pen stylus + focus */
  --brass: #d2ad62;

  --font: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --gutter: clamp(16px, 4vw, 40px);
  --measure: 1200px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background-color: var(--housing);
  /* hammertone enamel */
  background-image:
    radial-gradient(1200px 600px at 15% -10%, rgba(255,255,255,0.05), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  font-variant-numeric: tabular-nums;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

a { color: inherit; text-underline-offset: 0.18em; }
a:hover { color: var(--brass); }

:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 3px; }

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

[hidden] { display: none !important; }

.muted { color: var(--muted); }

header.bar,
main,
.foot {
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- top bar ---------- */

header.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  padding-block: 24px 8px;
}

.place h1 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 650;
  font-stretch: 88%;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.place p { margin: 4px 0 0; font-size: 0.875rem; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 0 1 620px; justify-content: flex-end; }

.search { position: relative; flex: 1 1 260px; }
.search input {
  width: 100%;
  min-width: 0;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--housing-raised);
  border: 1px solid var(--housing-edge);
  border-radius: 999px;
  padding: 10px 16px;
}
.search input::placeholder { color: var(--muted); }
.search input:focus-visible { outline-offset: 0; border-radius: 999px; }

.results {
  position: absolute; z-index: 1000; left: 0; right: 0; top: calc(100% + 6px);
  margin: 0; padding: 6px; list-style: none;
  background: var(--housing-raised);
  border: 1px solid var(--housing-edge);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.45);
}
.results li {
  padding: 8px 10px; border-radius: 8px; cursor: pointer; line-height: 1.25;
}
.results li small { display: block; color: var(--muted); font-size: 0.8rem; }
.results li[aria-selected="true"], .results li:hover { background: var(--housing-edge); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: 0.9rem; font-weight: 550;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--housing-edge);
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.btn svg .fill { fill: currentColor; stroke: none; }

.units {
  display: inline-flex;
  border: 1px solid var(--housing-edge);
  border-radius: 999px;
  padding: 3px;
}
.units button {
  font: inherit; font-size: 0.9rem; font-weight: 600;
  color: var(--muted);
  background: none; border: 0; border-radius: 999px;
  padding: 6px 12px; cursor: pointer;
}
.units button[aria-pressed="true"] { color: var(--housing); background: var(--text); }

.status {
  margin: 12px 0 0;
  padding: 12px 16px;
  border: 1px solid var(--housing-edge);
  border-left: 3px solid var(--brass);
  border-radius: 6px;
  background: var(--housing-raised);
}

/* ---------- current conditions ---------- */

.now {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 24px 48px;
  align-items: end;
  padding-block: 24px 48px;
}

.now-main { display: flex; align-items: flex-end; gap: 8px 28px; flex-wrap: wrap; }

.now-temp {
  font-size: clamp(6.5rem, 19vw, 13.5rem);
  font-weight: 300;
  font-stretch: 125%;
  letter-spacing: -0.055em;
  line-height: 0.8;
  margin-left: -0.04em;
}
.now-temp sup {
  font-size: 0.32em;
  font-weight: 400;
  letter-spacing: 0;
  vertical-align: top;
  position: relative;
  top: 0.12em;
  margin-left: 0.04em;
  color: var(--muted);
}

.now-desc { padding-bottom: 4px; max-width: 22rem; }
.now-icon { display: block; width: 44px; height: 44px; color: var(--text); margin-bottom: 8px; }
.now-icon svg { width: 100%; height: 100%; }
.now-cond {
  margin: 0;
  font-size: clamp(1.4rem, 2.6vw, 1.85rem);
  font-weight: 600;
  font-stretch: 78%;
  line-height: 1.1;
}
.now-sub { margin: 6px 0 0; color: var(--muted); }

.gauges {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  border-top: 1px solid var(--housing-edge);
}
.gauge {
  padding: 14px 12px 14px 0;
  border-bottom: 1px solid var(--housing-edge);
  min-width: 0;
}
.gauge dt { font-size: 0.82rem; color: var(--muted); }
.gauge dd {
  margin: 2px 0 0;
  font-size: 1.6rem;
  font-weight: 500;
  font-stretch: 82%;
  line-height: 1.1;
  display: flex; align-items: center; gap: 8px;
}
.gauge dd small { margin-left: -4px; }
.gauge dd small { font-size: 0.85rem; font-weight: 450; color: var(--muted); font-stretch: 100%; }
.gauge .note { display: block; margin-top: 2px; font-size: 0.8rem; color: var(--muted); }
.compass { width: 30px; height: 30px; flex: none; }
.compass circle { fill: none; stroke: var(--housing-edge); stroke-width: 1.5; }
.compass path { fill: var(--brass); }

/* ---------- section heads ---------- */

.section-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 8px 24px;
  margin-bottom: 14px;
}
.section-head h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2.4vw, 1.75rem);
  font-weight: 650;
  font-stretch: 80%;
  letter-spacing: -0.005em;
}
.section-head p { margin: 0; font-size: 0.875rem; }

.key { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0; padding: 0; list-style: none; font-size: 0.85rem; color: var(--muted); }
.key li { display: inline-flex; align-items: center; gap: 8px; }
.swatch { display: inline-block; width: 18px; height: 0; border-top: 2px solid; }
.swatch-temp { border-color: #e2545d; }
.swatch-chance { border-color: #6b9be0; border-top-style: solid; }
.swatch-amount { height: 10px; width: 8px; border: 0; background: #6b9be0; border-radius: 1px 1px 0 0; }

/* ---------- strip chart recorder ---------- */

.recorder { padding-bottom: 56px; }

.housing {
  background: linear-gradient(#2b3a35, #1a2521);
  border: 1px solid var(--housing-edge);
  border-radius: 16px;
  padding: 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 24px 50px -24px rgba(0,0,0,0.6);
}

.paper {
  position: relative;
  background: var(--paper);
  border-radius: 4px;
  overflow: hidden;
  color: var(--ink-text);
  box-shadow: inset 0 6px 10px -6px rgba(0,0,0,0.35), inset 0 -6px 10px -6px rgba(0,0,0,0.25);
}

.roll {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--grid-major) transparent;
  touch-action: pan-x pan-y;
}
.roll:focus-visible { outline-offset: -3px; }

.trace { display: block; }

/* perforations along the paper edges */
.roll::before, .roll::after {
  content: ""; position: absolute; left: 0; height: 10px; pointer-events: none;
  width: var(--roll-w, 100%);
  background-image: radial-gradient(circle, rgba(29,41,37,0.55) 2.2px, transparent 2.8px);
  background-size: 22px 10px;
  background-repeat: repeat-x;
}
.roll::before { top: 4px; }
.roll::after { top: calc(var(--paper-h, 400px) - 14px); }

.axis {
  position: absolute; top: 0; left: 0; z-index: 2; pointer-events: none;
}

.trace text, .axis text {
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}

.trace .ink-temp {
  fill: none; stroke: var(--ink-temp); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round;
}
.trace .ink-chance {
  fill: none; stroke: var(--ink-precip); stroke-width: 2; stroke-linejoin: round;
}
.trace .wash-chance { fill: var(--ink-precip-wash); }
.trace .bar { fill: var(--ink-precip); }

.trace .draw {
  stroke-dasharray: var(--len);
  stroke-dashoffset: var(--len);
  animation: pen 2.2s cubic-bezier(.45,.05,.3,1) 0.2s forwards;
}
@keyframes pen { to { stroke-dashoffset: 0; } }

.trace .fade-in { opacity: 0; animation: fade 0.6s ease 1.9s forwards; }
@keyframes fade { to { opacity: 1; } }

.days {
  display: grid;
  margin: 0; padding: 0; list-style: none;
  border-top: 1px solid var(--grid-major);
  background: var(--paper-shade);
}
.days li {
  padding: 10px 10px 14px;
  border-left: 1px solid var(--grid-major);
  min-width: 0;
}
.days li:first-child { border-left-color: transparent; }
.days .d-name { font-weight: 650; font-stretch: 85%; font-size: 0.98rem; }
.days .d-date { color: var(--ink-soft); font-size: 0.8rem; }
.days .d-icon { display: block; width: 28px; height: 28px; margin: 6px 0 4px; color: var(--ink-text); }
.days .d-icon svg { width: 100%; height: 100%; }
.days .d-temps { font-size: 1.05rem; font-weight: 600; font-stretch: 85%; }
.days .d-temps span { color: var(--ink-soft); font-weight: 450; }
.days .d-precip { font-size: 0.8rem; color: var(--ink-soft); }
.days .d-cond { font-size: 0.78rem; color: var(--ink-soft); line-height: 1.2; margin-top: 2px; }

.readout {
  position: absolute; top: 18px; z-index: 3; pointer-events: none;
  min-width: 140px;
  padding: 8px 10px;
  background: var(--ink-text);
  color: var(--paper);
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1.35;
  box-shadow: 0 10px 24px rgba(0,0,0,0.25);
}
.readout b { display: block; font-weight: 650; margin-bottom: 2px; }
.readout .r-row { display: flex; justify-content: space-between; gap: 14px; }
.readout .r-row i { font-style: normal; display: inline-flex; align-items: center; gap: 6px; color: #c9d4cc; }
.readout .r-row i::before { content: ""; width: 10px; height: 0; border-top: 2px solid var(--c); }

.hint { margin: 10px 0 0; font-size: 0.82rem; }

/* ---------- radar ---------- */

.radar { padding-bottom: 48px; }

.scope {
  background: var(--housing-raised);
  border: 1px solid var(--housing-edge);
  border-radius: 16px;
  overflow: hidden;
}

.map {
  height: clamp(340px, 58vh, 600px);
  background: #0f1513;
}
.leaflet-container { font-family: var(--font); }
.leaflet-control-attribution { font-size: 10px; background: rgba(15,21,19,0.75) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--text) !important; }
.leaflet-bar a { background: var(--housing-raised); color: var(--text); border-bottom-color: var(--housing-edge); }
.leaflet-bar a:hover { background: var(--housing-edge); color: var(--text); }
.leaflet-bar { border: 1px solid var(--housing-edge) !important; box-shadow: none !important; }

.you {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--brass);
  border: 2px solid var(--housing);
  box-shadow: 0 0 0 2px var(--brass);
}

.transport {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 16px 6px;
}

.play {
  flex: none;
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--housing-edge);
  background: var(--text);
  color: var(--housing);
  cursor: pointer;
}
.play svg { width: 22px; height: 22px; fill: currentColor; }
.play .i-pause { display: none; }
.play[aria-pressed="true"] .i-pause { display: inline; }
.play[aria-pressed="true"] .i-play { display: none; }
.play:disabled { opacity: 0.45; cursor: progress; }

.scrub { flex: 1; min-width: 0; }
.frame-time { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.frame-time strong { font-size: 1.15rem; font-weight: 600; font-stretch: 85%; }
.tag {
  font-size: 0.78rem; font-weight: 600;
  padding: 1px 8px; border-radius: 999px;
  border: 1px solid currentColor;
}
.tag.observed { color: #9fd3b4; }
.tag.forecast { color: var(--brass); }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 28px; margin: 0;
  background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px; background: var(--track, var(--housing-edge));
}
input[type="range"]::-moz-range-track {
  height: 6px; border-radius: 3px; background: var(--track, var(--housing-edge));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; margin-top: -7px;
  border-radius: 50%; background: var(--text); border: 3px solid var(--housing);
  box-shadow: 0 0 0 1px var(--muted);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--text); border: 3px solid var(--housing);
  box-shadow: 0 0 0 1px var(--muted);
}

.scrub-ends { position: relative; display: flex; justify-content: space-between; font-size: 0.78rem; height: 1.2em; }
.scrub-ends #scrub-now { position: absolute; left: var(--now, 50%); transform: translateX(-50%); color: var(--text); }

.dbz {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 16px 16px 80px;
  font-size: 0.78rem; color: var(--muted);
}
.dbz[data-scheme="rainviewer"] i {
  background: linear-gradient(90deg, #8fd3ff, #2fa0e6, #1257c4, #f5d200, #f08a00, #e0220f, #b4005a);
}
.dbz i {
  flex: 0 1 220px; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, #4fd67a, #11c517, #0b8f10, #f2e21a, #f0a000, #e8340f, #b5001a, #e11ee6, #9854c6);
}

/* ---------- footer ---------- */

.foot {
  padding-block: 8px 40px;
  font-size: 0.8rem;
  line-height: 1.6;
  max-width: var(--measure);
}

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .now { grid-template-columns: 1fr; padding-bottom: 36px; }
  .gauges { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  header.bar { padding-top: 16px; }
  .controls { width: 100%; }
  .search { flex-basis: 100%; }
  .btn span { display: none; }
  .btn { padding: 9px 11px; }
  .controls .btn { margin-right: auto; }
  .housing { padding: 8px; border-radius: 12px; }
  .transport { gap: 12px; padding-inline: 12px; }
  .dbz { padding-left: 12px; }
  .gauge dd { font-size: 1.35rem; }
}

@media (prefers-reduced-motion: reduce) {
  .trace .draw { animation: none; stroke-dasharray: none; stroke-dashoffset: 0; }
  .trace .fade-in { animation: none; opacity: 1; }
}
