/* SkyCast — "Thermochrome": a liquid-crystal thermometer strip.
   One accent system: the crystal hue, driven by temperature (see js/crystal.js).
   Everything else stays near-black / near-white. */

@property --drift { syntax: '<number>'; inherits: false; initial-value: 0; }

:root {
  --bg: #08080a;
  --surface: #000;
  --ink: #ecebe6;
  --ink2: #a3a3ab;
  --dim: #2a2a31;            /* un-triggered crystal print */
  --line: #1f1f25;
  --tick: #3a3a43;
  --hover: rgb(236 235 230 / .06);
  --bar: rgb(236 235 230 / .2);
  --grid: rgb(236 235 230 / .07);
  --focus: #f4f2ea;
  --L: 60;                   /* crystal lightness, % */
  --S: 90;                   /* crystal saturation, % */
  --glow: .35;
  --hero-fx: drop-shadow(0 0 28px hsl(var(--h) 90% 55% / .3));

  --display: 'Unbounded', 'Arial Black', system-ui, sans-serif;
  --mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --s0: clamp(96px, min(20vw, 30vh), 300px);   /* hero numeral size */
  --gutter: clamp(16px, 3vw, 40px);
  --radius: 4px;
  --tap: 44px;
}
:root[data-theme="light"] {
  --bg: #dcdfe2;
  --surface: #eef0f1;
  --ink: #101215;
  --ink2: #4a4f56;
  --dim: #c3c8cd;
  --line: #c9ced2;
  --tick: #a6acb2;
  --hover: rgb(16 18 21 / .05);
  --bar: rgb(16 18 21 / .16);
  --grid: rgb(16 18 21 / .08);
  --focus: #101215;
  --L: 34;
  --S: 92;
  --glow: 0;
  --hero-fx: drop-shadow(0 1px 0 rgb(0 0 0 / .25));
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font: 14px/1.5 var(--mono);
  -webkit-font-smoothing: antialiased;
}
h1, h2, p, dl, dd, ol, ul, figure { margin: 0; padding: 0; }
ol, ul { list-style: none; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
svg { display: block; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 50; padding: 10px 14px; background: var(--ink); color: var(--bg); }
.skip:focus { top: 8px; }

/* line icons share one style */
.icon-btn svg, .search-icon, .metrics svg, .glyph, .pin svg, .listbox svg {
  fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; gap: 12px 20px;
  padding: 12px var(--gutter);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 10px; min-height: var(--tap);
  font: 600 14px/1 var(--display); letter-spacing: .04em; text-transform: uppercase; text-decoration: none;
}
.brand svg { width: 26px; height: 20px; }
.brand-crystal { fill: hsl(var(--h, 175) 85% 55%); }
:root[data-theme="light"] .brand-crystal { fill: hsl(var(--h, 175) 85% 36%); }

.search { position: relative; flex: 1 1 auto; max-width: 480px; margin-left: auto; }
.search-icon { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--ink2); pointer-events: none; }
.search input {
  width: 100%; height: var(--tap); padding: 0 48px 0 40px;
  background: var(--surface); border: 1px solid var(--tick); border-radius: var(--radius);
  font-size: 15px;
}
.search input::placeholder { color: var(--ink2); opacity: 1; }
.search input::-webkit-search-cancel-button { display: none; }
.search input:hover { border-color: var(--ink2); }
.in-field { position: absolute; right: 0; top: 0; }

.icon-btn {
  width: var(--tap); height: var(--tap); flex: none;
  display: inline-grid; place-items: center;
  background: transparent; border: 0; border-radius: var(--radius); cursor: pointer; color: var(--ink);
}
.icon-btn:hover { background: var(--hover); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn[aria-busy="true"] svg { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.controls { display: flex; align-items: center; gap: 6px; }
.seg { display: inline-flex; height: 36px; border: 1px solid var(--tick); border-radius: var(--radius); overflow: hidden; }
.seg button { min-width: 44px; padding: 0 10px; background: transparent; border: 0; cursor: pointer; font-size: 13px; color: var(--ink2); }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg button:focus-visible { outline-offset: -3px; }
:root[data-theme="dark"] .i-moon, :root[data-theme="light"] .i-sun { display: none; }

/* autocomplete */
.listbox {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0;
  max-height: min(420px, 60vh); overflow: auto;
  background: var(--surface); border: 1px solid var(--tick); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgb(0 0 0 / .35);
}
.listbox[hidden] { display: none; }
.listbox .group { padding: 10px 14px 4px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink2); }
.listbox [role="option"] {
  display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 8px 14px; cursor: pointer;
}
.listbox [role="option"] svg { width: 16px; height: 16px; flex: none; color: var(--ink2); }
.listbox [role="option"] .sub { margin-left: auto; padding-left: 12px; color: var(--ink2); font-size: 12px; text-align: right; }
.listbox [role="option"]:hover { background: var(--hover); }
.listbox [role="option"][aria-selected="true"] { background: var(--ink); color: var(--bg); }
.listbox [role="option"][aria-selected="true"] svg,
.listbox [role="option"][aria-selected="true"] .sub { color: inherit; }
.listbox mark { background: none; color: inherit; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.listbox .empty { padding: 14px; color: var(--ink2); }

/* ---------- layout ---------- */
main { flex: 1; width: 100%; max-width: 1360px; margin: 0 auto; padding: clamp(16px, 3vh, 32px) var(--gutter) 40px; }

.notice {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding: 10px 14px;
  border: 1px solid var(--tick); border-radius: var(--radius); color: var(--ink);
}
.notice[hidden] { display: none; }
.notice button { margin-left: auto; min-height: 36px; padding: 0 14px; background: var(--ink); color: var(--bg); border: 0; border-radius: var(--radius); cursor: pointer; }

/* ---------- current conditions ---------- */
.place { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 12px; }
.place h1, .place-meta { grid-column: 1; }
.place h1 { display: flex; align-items: center; gap: 8px; font: 600 clamp(22px, 2.6vw, 32px)/1.15 var(--display); letter-spacing: -.01em; }
.pin svg { width: 22px; height: 22px; }
.pin[hidden] { display: none; }
.place-meta { color: var(--ink2); font-size: 13px; }
.place-meta time:not(:empty)::before { content: "· "; }
.fav { grid-column: 2; grid-row: 1 / span 2; color: var(--ink2); }
.fav[aria-pressed="true"] { color: var(--ink); }
.fav[aria-pressed="true"] svg { fill: currentColor; }
.fav[hidden] { display: none; }

.strip-plate {
  margin-top: clamp(12px, 2vh, 20px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(10px, 2vh, 20px) 0 0; overflow: hidden;
}
.strip {
  --px: 35%; --py: 30%; --shift: 0;
  display: grid; grid-auto-flow: column; grid-template-rows: auto 22px; justify-content: center;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
  transition: opacity .16s ease, filter .16s ease;
}
.strip.fade { opacity: 0; filter: blur(6px) saturate(1.6); }
.cell { display: contents; }
.num {
  align-self: baseline; padding: .08em .14em .04em; text-align: center; white-space: nowrap;
  font: 600 max(14px, calc(var(--s0) * .1))/.8 var(--display); font-variant-numeric: tabular-nums;
  color: var(--dim); transition: color .6s ease, text-shadow .6s ease;
}
.cell[data-d="1"] .num { font-size: calc(var(--s0) * .32); color: hsl(var(--h) calc(var(--S) * 1%) calc(var(--L) * 1%) / .7); }
.cell[data-d="2"] .num { font-size: calc(var(--s0) * .21); color: hsl(var(--h) calc(var(--S) * 1%) calc(var(--L) * 1%) / .4); }
.cell[data-d="3"] .num { font-size: calc(var(--s0) * .15); color: hsl(var(--h) calc(var(--S) * 1%) calc(var(--L) * 1%) / .2); }
.cell[data-d="4"] .num { font-size: calc(var(--s0) * .12); }
.cell[data-d="0"] .num {
  font-size: var(--s0); font-weight: 800; letter-spacing: -.02em; color: transparent;
  -webkit-background-clip: text; background-clip: text;
  background-image:
    radial-gradient(55% 60% at var(--px) var(--py), rgb(255 255 255 / .4), transparent 62%),
    conic-gradient(from calc(var(--drift) * 1deg) at 62% 58%,
      hsl(calc(var(--h) + var(--shift) - 38) 94% calc(var(--L) * 1% + 4%)),
      hsl(calc(var(--h) + var(--shift)) 96% calc(var(--L) * 1%)),
      hsl(calc(var(--h) + var(--shift) + 46) 92% calc(var(--L) * 1% + 8%)),
      hsl(calc(var(--h) + var(--shift) - 38) 94% calc(var(--L) * 1% + 4%)));
  filter: var(--hero-fx);
  animation: drift 26s linear infinite;
}
:root[data-theme="light"] .cell[data-d="0"] .num {
  background-image:
    radial-gradient(50% 55% at var(--px) var(--py), rgb(255 255 255 / .2), transparent 60%),
    conic-gradient(from calc(var(--drift) * 1deg) at 62% 58%,
      hsl(calc(var(--h) + var(--shift) - 30) 95% 30%),
      hsl(calc(var(--h) + var(--shift)) 96% 33%),
      hsl(calc(var(--h) + var(--shift) + 34) 92% 30%),
      hsl(calc(var(--h) + var(--shift) - 30) 95% 30%));
}
@keyframes drift { to { --drift: 360; } }
.strip[data-warm] .cell[data-d="0"] .num { opacity: 0; }
.cell[data-d="0"] .num { transition: opacity .4s ease; }
.num.hot { color: hsl(var(--h) 95% calc(var(--L) * 1% + 8%)); text-shadow: 0 0 22px hsl(var(--h) 95% 55% / .7); transition-duration: .05s; }
:root[data-theme="light"] .num.hot { color: hsl(var(--h) 95% 30%); text-shadow: none; }

/* scale ticks under the numerals */
.mk { position: relative; align-self: start; height: 22px; border-top: 1px solid var(--tick); }
.mk::before { content: ""; position: absolute; left: 50%; top: 0; width: 1px; height: 6px; background: var(--tick); }
.cell[data-d="0"] .mk { border-top-color: hsl(var(--h) 90% calc(var(--L) * 1%)); }
.cell[data-d="0"] .mk::before { width: 2px; height: 10px; margin-left: -1px; background: hsl(var(--h) 90% calc(var(--L) * 1%)); }
/* feels-like: a secondary crystal activation on the same strip */
.mk.feels::before { width: 2px; height: 10px; margin-left: -1px; background: hsl(var(--h) 90% calc(var(--L) * 1%)); }
.mk.feels::after {
  content: ""; position: absolute; left: 50%; top: 0; width: 140%; height: 22px; transform: translateX(-50%);
  background: radial-gradient(60% 80% at 50% 0, hsl(var(--h) 90% 55% / .5), transparent 70%);
}
:root[data-theme="light"] .mk.feels::after { background: radial-gradient(60% 80% at 50% 0, hsl(var(--h) 90% 40% / .4), transparent 70%); }

/* key readings */
.metrics {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px;
  margin-top: 12px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.metric {
  display: grid; grid-template-columns: 22px 1fr; align-items: center; column-gap: 12px;
  padding: 14px 16px; background: var(--surface);
}
.metric dt { display: contents; }
.metric dt > :first-child { grid-row: 1 / span 2; width: 22px; height: 22px; color: var(--ink2); }
.metric dt span:last-child { font-size: 12px; color: var(--ink2); }
.metric dd { grid-column: 2; font: 500 18px/1.2 var(--mono); white-space: nowrap; }
.metric dd small { font-size: 13px; color: var(--ink2); }
.metric .feels-dot {
  display: block; border-radius: 50%;
  background: radial-gradient(circle, hsl(var(--h) 90% calc(var(--L) * 1%)) 0 3px, hsl(var(--h) 90% 55% / .35) 4px, transparent 11px);
}

/* ---------- forecast + chart ---------- */
.lower {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(16px, 2.4vw, 32px);
  margin-top: clamp(20px, 3vh, 32px);
}
.lower h2 { font: 600 15px/1.3 var(--display); letter-spacing: .01em; margin-bottom: 12px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chart-key { display: flex; gap: 16px; font-size: 12px; color: var(--ink2); }
.chart-key li { display: inline-flex; align-items: center; gap: 6px; }
.k-line { width: 20px; height: 3px; border-radius: 2px; background: linear-gradient(90deg, hsl(45 90% calc(var(--L) * 1%)), hsl(145 90% calc(var(--L) * 1%)), hsl(215 90% calc(var(--L) * 1%))); }
.k-bar { width: 8px; height: 12px; border-radius: 1px; background: var(--bar); }

.days { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.day {
  display: grid; align-items: center; gap: 12px;
  grid-template-columns: 4.2em 24px 3.4em 2.6em minmax(60px, 1fr) 2.6em;
  min-height: 52px; padding: 6px 16px;
}
.days li + li .day { border-top: 1px solid var(--line); }
.day time { font-weight: 500; }
.day .glyph { width: 24px; height: 24px; }
.day .pp { font-size: 12px; color: hsl(205 70% calc(var(--L) * 1% + 6%)); }
:root[data-theme="light"] .day .pp { color: hsl(210 70% 32%); }
.day .lo { text-align: right; color: var(--ink2); }
.day .hi { font-weight: 500; }
.range { position: relative; height: 6px; border-radius: 3px; background: var(--dim); }
.range .band { position: absolute; top: 0; bottom: 0; border-radius: 3px; box-shadow: 0 0 12px hsl(var(--gh) 90% 55% / var(--glow)); }
.range .nowdot {
  position: absolute; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%;
  background: var(--ink); box-shadow: 0 0 0 2px var(--surface);
}

.chart { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 12px 8px; }
.chart-wrap { position: relative; height: clamp(240px, 32vh, 340px); }
.fallback { padding: 24px; color: var(--ink2); }

.foot { padding: 0 var(--gutter) 24px; color: var(--ink2); font-size: 12px; text-align: center; }

/* ---------- loading skeleton ---------- */
main[aria-busy="true"] .strip,
main[aria-busy="true"] .metrics,
main[aria-busy="true"] .days,
main[aria-busy="true"] .chart-wrap { opacity: .35; }
main[aria-busy="true"] .strip:empty { height: calc(var(--s0) * .9); }
main[aria-busy="true"] .days:empty { height: 364px; }
main[aria-busy="true"] .metrics:empty { height: 72px; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .lower { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .top { flex-wrap: wrap; }
  .controls { margin-left: auto; }
  .search { order: 3; flex-basis: 100%; max-width: none; margin-left: 0; }
  .cell[data-d="4"] *, .cell[data-d="5"] *, .cell[data-d="6"] * { display: none; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric:first-child { grid-column: 1 / -1; }
}
@media (max-width: 420px) {
  :root { --s0: clamp(110px, 40vw, 180px); }
  .cell[data-d="3"] * { display: none; }
  .day { grid-template-columns: 3.4em 22px 2.8em 2.4em minmax(40px, 1fr) 2.4em; gap: 8px; padding: 6px 12px; }
  .metric { padding: 12px; gap: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
