/* =========================================================
   Weather Analytics — "immersive sky" theme
   Dash serves every file in assets/ automatically.

   The root .app element carries two classes chosen in
   weather_scene.py:  tod-<night|dawn|day|dusk>
                      wx-<clear|sunny|overcast|rain|snow|fog>
   ========================================================= */

/* Self-hosted fonts (SIL OFL 1.1, see fonts/OFL.txt): one variable
   file per family covers every weight used below. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/outfit-latin.woff2") format("woff2");
}

:root {
  --ink: #FFFFFF;
  --ink-soft: rgba(226, 232, 255, 0.82);
  --ink-mute: rgba(226, 232, 255, 0.66);
  --line: rgba(255, 255, 255, 0.12);
  --glass: rgba(12, 22, 52, 0.38);
  --glass-hover: rgba(20, 34, 74, 0.48);
  --glass-border: rgba(255, 255, 255, 0.14);
  --pill: rgba(255, 255, 255, 0.92);
  --pill-ink: #0B1430;
  --waverly: #FFFFFF;
  --east: #FCB36B;
  --ok: #4ADE80;
  --warn: #FBBF24;
  --display: "Outfit", "Inter", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: #050816;
  color: var(--ink);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---------------------------------------------------------
   Sky layers (fixed behind the page)
   --------------------------------------------------------- */

.app { position: relative; min-height: 100vh; }

.sky-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: linear-gradient(180deg, #000000 0%, #03050A 50%, #070A12 100%);
  transition: background 1.2s ease;
}

.tod-dawn  .sky-layer { background: linear-gradient(180deg, #101C33 0%, #2D4568 42%, #7A90AB 76%, #D8C2A2 100%); }
.tod-day   .sky-layer { background: linear-gradient(180deg, #1663C7 0%, #2F86D8 50%, #74B6EA 100%); }
.tod-dusk  .sky-layer { background: linear-gradient(180deg, #0B1326 0%, #22335A 42%, #5E6782 74%, #C08458 100%); }

/* Weather overrides: a night variant and a daylight variant. */
.wx-overcast .sky-layer          { background: linear-gradient(180deg, #3E4A5E 0%, #5A687E 50%, #7D8A9E 100%); }
.wx-rain .sky-layer              { background: linear-gradient(180deg, #1F2938 0%, #2F3B4F 55%, #46536A 100%); }
.tod-night.wx-rain .sky-layer    { background: linear-gradient(180deg, #010203 0%, #05080D 55%, #0B1018 100%); }
.wx-snow .sky-layer              { background: linear-gradient(180deg, #4E5A70 0%, #6E7A90 50%, #98A3B6 100%); }
.tod-night.wx-snow .sky-layer    { background: linear-gradient(180deg, #030406 0%, #0A0D14 55%, #151A24 100%); }
.wx-fog .sky-layer               { background: linear-gradient(180deg, #475263 0%, #5F6A7B 50%, #7C8696 100%); }
.tod-night.wx-fog .sky-layer     { background: linear-gradient(180deg, #030405 0%, #0A0C11 55%, #14171E 100%); }

.fx { position: absolute; inset: 0; opacity: 0; transition: opacity 1.2s ease; }

/* Stars and moon: clear nights, faint at dawn and dusk. */
.stars {
  background-image:
    radial-gradient(1px 1px at 12% 8%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 22%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 46% 6%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 63% 17%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 79% 9%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 91% 25%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 31%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 37% 34%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 71% 30%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 41%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 19% 47%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 86% 44%, #fff 50%, transparent 51%);
}
.tod-night.wx-clear .stars { opacity: 0.9; }
.tod-dawn.wx-clear .stars,
.tod-dusk.wx-clear .stars  { opacity: 0.3; }

.glow {
  inset: auto;
  top: -160px;
  right: 8%;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200, 214, 255, 0.22) 0%, rgba(200, 214, 255, 0) 65%);
}
.tod-night.wx-clear .glow { opacity: 1; }
.wx-sunny .glow {
  opacity: 1;
  top: -200px;
  right: -120px;
  background: radial-gradient(circle, rgba(255, 244, 214, 0.95) 0%, rgba(255, 226, 160, 0.45) 18%, rgba(255, 226, 160, 0) 60%);
}

/* Drifting clouds. */
.cloud {
  position: absolute;
  border-radius: 50%;
  filter: blur(30px);
  animation: drift 22s ease-in-out infinite alternate;
}
.cloud.c1 { left: -10%; top: 6%;  width: 70%; height: 160px; background: rgba(226, 232, 240, 0.40); }
.cloud.c2 { right: -15%; top: 30%; width: 80%; height: 180px; background: rgba(203, 213, 225, 0.34); animation-duration: 28s; }
.cloud.c3 { left: 0; top: 62%;    width: 90%; height: 150px; background: rgba(241, 245, 249, 0.26); animation-duration: 34s; }
.wx-overcast .clouds { opacity: 1; }
.wx-rain .clouds, .wx-snow .clouds { opacity: 0.55; }
.wx-sunny .clouds { opacity: 0.35; }
.wx-sunny .cloud.c1, .wx-sunny .cloud.c2 { display: none; }
.tod-night .cloud { filter: blur(34px) brightness(0.45); }

/* Rain and snow. The tilt wrapper is rotated from Python to follow the wind. */
.precip-tilt { position: absolute; inset: -15%; transition: transform 1.5s ease; }
.rain, .snow { position: absolute; inset: 0; opacity: 0; transition: opacity 1.2s ease; }
.rain {
  /* Three depths of rain: far drops are short, faint and slow; near drops
     are long, bright and fast. Odd tile sizes keep the repeat hidden. */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='167' height='239'><defs><linearGradient id='s' x1='0' y1='0' x2='0' y2='1'><stop offset='0' stop-color='%23D7E6FF' stop-opacity='0'/><stop offset='1' stop-color='%23D7E6FF' stop-opacity='0.75'/></linearGradient></defs><g fill='url(%23s)'><rect x='17.1' y='20' width='1.8' height='38' rx='0.9'/><rect x='69.1' y='130' width='1.8' height='34' rx='0.9'/><rect x='120.1' y='60' width='1.8' height='40' rx='0.9'/><rect x='149.1' y='180' width='1.8' height='36' rx='0.9'/><rect x='43.1' y='200' width='1.8' height='34' rx='0.9'/></g></svg>"), url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='113' height='173'><defs><linearGradient id='s' x1='0' y1='0' x2='0' y2='1'><stop offset='0' stop-color='%23C3DAFF' stop-opacity='0'/><stop offset='1' stop-color='%23C3DAFF' stop-opacity='0.6'/></linearGradient></defs><g fill='url(%23s)'><rect x='9.35' y='12' width='1.3' height='22' rx='0.65'/><rect x='36.35' y='88' width='1.3' height='20' rx='0.65'/><rect x='61.35' y='40' width='1.3' height='24' rx='0.65'/><rect x='87.35' y='120' width='1.3' height='20' rx='0.65'/><rect x='103.35' y='8' width='1.3' height='22' rx='0.65'/><rect x='23.35' y='140' width='1.3' height='20' rx='0.65'/><rect x='75.35' y='70' width='1.3' height='22' rx='0.65'/></g></svg>"), url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='73' height='131'><defs><linearGradient id='s' x1='0' y1='0' x2='0' y2='1'><stop offset='0' stop-color='%23B4CDF5' stop-opacity='0'/><stop offset='1' stop-color='%23B4CDF5' stop-opacity='0.45'/></linearGradient></defs><g fill='url(%23s)'><rect x='5.5' y='8' width='1' height='14' rx='0.5'/><rect x='22.5' y='70' width='1' height='12' rx='0.5'/><rect x='40.5' y='30' width='1' height='14' rx='0.5'/><rect x='57.5' y='96' width='1' height='12' rx='0.5'/><rect x='66.5' y='52' width='1' height='13' rx='0.5'/><rect x='14.5' y='110' width='1' height='12' rx='0.5'/><rect x='48.5' y='4' width='1' height='12' rx='0.5'/></g></svg>");
  background-size: 167px 239px, 113px 173px, 73px 131px;
  animation: fall-rain 1.1s linear infinite;
}
.snow {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><g fill='rgba(255,255,255,0.85)'><circle cx='12' cy='10' r='2.2'/><circle cx='48' cy='34' r='1.6'/><circle cx='86' cy='14' r='2.6'/><circle cx='104' cy='60' r='1.8'/><circle cx='30' cy='76' r='2.4'/><circle cx='66' cy='94' r='1.5'/><circle cx='8' cy='108' r='1.7'/><circle cx='96' cy='104' r='2'/></g></svg>");
  animation: fall-snow 7s linear infinite;
}
.wx-rain .rain { opacity: 1; }

/* Drizzle (light rain): no near layer, fainter, slower drops, and a
   lighter grey sky than steady rain. */
.rain-light .rain {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='113' height='173'><defs><linearGradient id='s' x1='0' y1='0' x2='0' y2='1'><stop offset='0' stop-color='%23C3DAFF' stop-opacity='0'/><stop offset='1' stop-color='%23C3DAFF' stop-opacity='0.35'/></linearGradient></defs><g fill='url(%23s)'><rect x='9.35' y='12' width='1.3' height='22' rx='0.65'/><rect x='36.35' y='88' width='1.3' height='20' rx='0.65'/><rect x='61.35' y='40' width='1.3' height='24' rx='0.65'/><rect x='87.35' y='120' width='1.3' height='20' rx='0.65'/><rect x='103.35' y='8' width='1.3' height='22' rx='0.65'/><rect x='23.35' y='140' width='1.3' height='20' rx='0.65'/><rect x='75.35' y='70' width='1.3' height='22' rx='0.65'/></g></svg>"), url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='73' height='131'><defs><linearGradient id='s' x1='0' y1='0' x2='0' y2='1'><stop offset='0' stop-color='%23B4CDF5' stop-opacity='0'/><stop offset='1' stop-color='%23B4CDF5' stop-opacity='0.3'/></linearGradient></defs><g fill='url(%23s)'><rect x='5.5' y='8' width='1' height='14' rx='0.5'/><rect x='22.5' y='70' width='1' height='12' rx='0.5'/><rect x='40.5' y='30' width='1' height='14' rx='0.5'/><rect x='57.5' y='96' width='1' height='12' rx='0.5'/><rect x='66.5' y='52' width='1' height='13' rx='0.5'/><rect x='14.5' y='110' width='1' height='12' rx='0.5'/><rect x='48.5' y='4' width='1' height='12' rx='0.5'/></g></svg>");
  background-size: 113px 173px, 73px 131px;
  animation: fall-drizzle 2.4s linear infinite;
}
.rain-light.wx-rain .sky-layer           { background: linear-gradient(180deg, #3A4558 0%, #4E5A6E 55%, #6A7588 100%); }
.rain-light.tod-night.wx-rain .sky-layer { background: linear-gradient(180deg, #020304 0%, #070A0F 55%, #0F141C 100%); }
.wx-snow .snow { opacity: 1; }
.wx-rain .precip, .wx-snow .precip { opacity: 1; }

/* Fog bands. */
.band { position: absolute; left: -25%; width: 150%; filter: blur(28px); animation: drift 26s ease-in-out infinite alternate; }
.band.b1 { top: 28%; height: 90px;  background: rgba(226, 232, 240, 0.36); }
.band.b2 { top: 52%; height: 110px; background: rgba(241, 245, 249, 0.40); animation-duration: 32s; }
.band.b3 { top: 78%; height: 130px; background: rgba(248, 250, 252, 0.46); animation-duration: 38s; }
.wx-fog .fog { opacity: 1; }
.tod-night .band { filter: blur(30px) brightness(0.5); }

@keyframes drift     { from { transform: translateX(-6%); } to { transform: translateX(6%); } }
/* Each layer moves exactly whole tiles per loop so the loop is seamless:
   near 2 × 239, middle 2 × 173, far 1 × 131 in 1.1 s. */
@keyframes fall-rain {
  from { background-position: 0 0, 0 0, 0 0; }
  to   { background-position: 0 478px, 0 346px, 0 131px; }
}
@keyframes fall-drizzle {
  from { background-position: 0 0, 0 0; }
  to   { background-position: 0 346px, 0 131px; }
}
@keyframes fall-snow { from { background-position: 0 0; } to { background-position: 0 120px; } }

/* Trends page: same sky, quieter effects so they don't fight the chart. */
.page-trends.wx-overcast .clouds, .page-trends.wx-rain .clouds,
.page-trends.wx-snow .clouds, .page-trends.wx-fog .fog { opacity: 0.25; }
.page-trends.wx-rain .rain, .page-trends.wx-snow .snow { opacity: 0.35; }

@media (prefers-reduced-motion: reduce) {
  .cloud, .band, .rain, .snow, .rain-light .rain { animation: none; }
}

/* ---------------------------------------------------------
   Layout and glass
   --------------------------------------------------------- */

.shell {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 22px 32px 64px;
}

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: 0 10px 40px rgba(2, 6, 23, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Pale skies: darker glass so white text stays readable. */
.tod-day .glass, .wx-overcast .glass, .wx-snow .glass, .wx-fog .glass {
  --glass: rgba(15, 25, 50, 0.42);
  --glass-hover: rgba(15, 25, 50, 0.52);
}

/* Header */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 500; font-size: 19px; letter-spacing: -0.01em; }
.brand img { width: 26px; height: 26px; }
.spacer { flex-grow: 1; }
.nav-back { margin-left: 16px; padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; color: #FFFFFF; background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.22); transition: background 0.2s ease; }
.nav-back:hover { background: rgba(255, 255, 255, 0.24); }
.nav-back:focus-visible { outline: 2px solid #FFFFFF; outline-offset: 2px; }

.live { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.live.stale .live-dot { background: var(--warn); box-shadow: 0 0 10px var(--warn); }

/* Segmented controls (dcc.RadioItems) */
.seg { display: flex; gap: 2px; padding: 4px; border-radius: 999px; }
.seg label {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.seg label:hover { background: rgba(255, 255, 255, 0.12); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked),
.seg .dash-options-list-option.selected { background: var(--pill); color: var(--pill-ink); font-weight: 600; }
.seg .dash-options-list-option-wrapper { display: contents; }
.seg .dash-options-list-option:hover,
.seg .dash-options-list-option:focus-within { color: #FFFFFF; }
.seg .dash-options-list-option.selected:hover,
.seg .dash-options-list-option.selected:focus-within { color: var(--pill-ink); }
.seg label:has(input:focus-visible) { outline: 2px solid #FFFFFF; outline-offset: 2px; }

/* ---------------------------------------------------------
   Now page
   --------------------------------------------------------- */

.hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 64px 0 52px; }
.hero-loc { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 500; color: var(--ink-soft); }
.hero-loc img { width: 15px; height: 15px; }
.hero-temp { margin: 6px 0 0; font-family: var(--display); font-weight: 200; font-size: clamp(104px, 14vw, 168px); line-height: 1; letter-spacing: -0.06em; padding-left: 0.12em; }
.hero-deg { font-size: 0.45em; vertical-align: top; position: relative; top: 0.12em; margin-left: 0.06em; }
.hero-sub { margin-top: 4px; font-size: 20px; color: rgba(255, 255, 255, 0.92); }
.hero-hl { margin-top: 6px; display: flex; gap: 16px; font-size: 17px; color: var(--ink-soft); }

.daycard { border-radius: 24px; padding: 20px 24px 18px; margin-bottom: 18px; }
.daycard-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.daycard-head a, .link-button { font: inherit; font-size: 13px; font-weight: 600; color: rgba(255, 255, 255, 0.9); background: none; border: 0; padding: 0; cursor: pointer; }
.daycard-head a:hover, .link-button:hover { color: #FFFFFF; text-decoration: underline; }
.link-button:focus-visible { outline: 2px solid #FFFFFF; outline-offset: 3px; border-radius: 4px; }
.hours { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); margin-top: 10px; text-align: center; font-variant-numeric: tabular-nums; }
.hour-t { font-size: 12px; color: var(--ink-mute); }
.hour-v { font-size: 16px; font-weight: 500; margin-top: 2px; }
.hours > div:last-child .hour-t { color: #FFFFFF; font-weight: 600; }

.cap { font-size: 12px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: rgba(226, 232, 255, 0.72); display: flex; align-items: center; gap: 8px; }
.cap img { width: 14px; height: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-more { font-size: 13px; font-weight: 600; color: rgba(255, 255, 255, 0.75); white-space: nowrap; transition: color 0.2s ease; }
.trend-card:hover .card-more, .trend-card:focus-visible .card-more { color: #FFFFFF; text-decoration: underline; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.card { border-radius: 24px; padding: 20px 22px; display: flex; flex-direction: column; gap: 10px; min-height: 196px; }
.trend-card { cursor: pointer; transition: transform 0.25s ease, background 0.25s ease; }
.trend-card:hover { transform: translateY(-3px); background: var(--glass-hover); }
.trend-card:focus-visible { outline: 2px solid #FFFFFF; outline-offset: 3px; }
.big { font-family: var(--display); font-weight: 300; font-size: 48px; line-height: 1; white-space: nowrap; }
.unit { font-size: 24px; }
.note { font-size: 14px; color: var(--ink-soft); }
.note-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.grow { flex-grow: 1; }
.split { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-grow: 1; }
.split.bottom { align-items: flex-end; }
.split .note { white-space: nowrap; }

/* Wind speed scale */
.scale { position: relative; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.16); }
.scale-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #A5F3FC, #E0F2FE); transition: width 0.8s ease; }
.scale-knob { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #FFFFFF; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25); transition: left 0.8s ease; }
.scale-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-mute); }

/* Compass */
.compass { position: relative; width: clamp(132px, 44%, 170px); height: auto; aspect-ratio: 1; flex: none; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, 0.22); }
.compass::before { content: ""; position: absolute; inset: 3px; border-radius: 50%; border: 6px dotted rgba(255, 255, 255, 0.35); }
.compass .pt { position: absolute; font-size: 14px; font-weight: 600; color: rgba(255, 255, 255, 0.85); transform: translate(-50%, -50%); }
.compass .n { left: 50%; top: 21%; } .compass .e { left: 79%; top: 50%; }
.compass .s { left: 50%; top: 79%; } .compass .w { left: 21%; top: 50%; }
.needle { position: absolute; inset: 0; transition: transform 1s ease; }
/* Shaft from the centre out toward the rim; arrowhead at the rim end. */
.needle::before { content: ""; position: absolute; left: 50%; top: 36%; width: 3px; height: 14%; margin-left: -1.25px; border-radius: 2px; background: #FFFFFF; }
.needle::after { content: ""; position: absolute; left: 50%; top: 28%; margin-left: -7px; border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 14px solid #FFFFFF; }
.compass .hub { position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #FFFFFF; box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.2); }
.compass.calm .hub { opacity: 0.5; }
.compass.calm .needle { display: none; }

/* Humidity bar */
.bar { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.16); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #A5B4FC, #E0E7FF); transition: width 0.8s ease; }

/* Pressure: number on top; the gauge's top meets the bottom of the number line, on the right (980 to 1040 hPa). */
.press-top { display: flex; flex-direction: column; }
.gauge-box { --gauge: 152px; --track: calc(var(--gauge) * 0.09); flex: none; align-self: flex-end; display: grid; grid-template-columns: 1fr 1fr; row-gap: 4px; padding: 0 8px; }
/* The dial spans both columns; 980 and 1040 sit under the ends of the arc. */
.gauge-box .gauge { grid-column: 1 / 3; grid-row: 1; }
.gauge-end { grid-row: 2; font-size: 11px; line-height: 1; color: var(--ink-mute); transform: translateX(calc(var(--track) / 2 - 50%)); }
.gauge-end:last-child { justify-self: end; transform: translateX(calc(50% - var(--track) / 2)); }
/* An exact half circle: the needle's pivot sits level with the two ends. */
.gauge { --track: calc(var(--gauge) * 0.09); position: relative; width: var(--gauge); height: calc(var(--gauge) * 0.5); }
.gauge::before { content: ""; position: absolute; inset: 0 0 auto 0; box-sizing: border-box; height: var(--gauge); border-radius: 50%; border: var(--track) solid rgba(255, 255, 255, 0.25); clip-path: inset(0 0 50% 0); }
.gauge-needle { position: absolute; left: 50%; bottom: 0; width: 2.5px; height: calc(var(--gauge) * 0.36); margin-left: -1.25px; border-radius: 2px; background: #FFFFFF; transform-origin: 50% 100%; transition: transform 1s ease; }
.gauge::after { content: ""; position: absolute; left: 50%; bottom: -5px; z-index: 1; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: #FFFFFF; }

/* 24-hour strips: thin bars, newest on the right, sized to fill the card */
.strip { flex: 1 1 auto; min-height: 40px; max-height: 88px; margin-top: auto; display: flex; align-items: flex-end; gap: 2px; }
.sbar { flex: 1; min-width: 0; border-radius: 2px 2px 1px 1px; background: rgba(255, 255, 255, 0.24); }
.sbar.now { background: rgba(255, 255, 255, 0.8); }
.sbar.gap { background: none; }
.strip-rain { max-height: 110px; gap: 3px; }
.strip-rain .sbar { background: rgba(186, 230, 253, 0.85); min-height: 2px; }
.strip-rain .sbar.now { background: #E0F2FE; }
.strip-rain .sbar.dry { background: rgba(255, 255, 255, 0.18); height: 3px !important; }
.strip-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-mute); margin-top: -4px; }

/* Light card: number top-left, notes bottom-left, sun arc on the right.
   Sun-dot positions are in % (SUN_ARC_* in pages/landing_page.py). */
.light-notes { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: auto; padding-top: 8px; }
.sunbox { flex: 1 1 auto; min-height: 64px; max-height: 130px; margin-top: 10px; display: flex; flex-direction: column; }
.sunpath { position: relative; flex: 1; min-height: 36px; margin: 0 8%; }
.sunpath .arc { position: absolute; left: 5%; right: 5%; top: 10%; height: 140%; border-radius: 50%; border: 1.5px dashed rgba(255, 255, 255, 0.4); clip-path: inset(0 0 50% 0); }
.sunpath .horizon { position: absolute; left: 0; right: 0; top: 80%; height: 1px; background: rgba(255, 255, 255, 0.4); }
.sunpath .sun { position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: #FDE68A; box-shadow: 0 0 18px rgba(253, 230, 138, 0.85); transition: left 1s ease, top 1s ease; }
.sunpath .sun.down { width: 10px; height: 10px; margin: -5px 0 0 -5px; background: rgba(255, 255, 255, 0.55); box-shadow: none; }
.sun-times { margin: 0 4%; display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--ink-soft); font-variant-numeric: tabular-nums; margin-top: 2px; }

/* ---------------------------------------------------------
   Trends page
   --------------------------------------------------------- */

.trend-head { padding: 52px 0 28px; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 24px; }
.eyebrow { font-size: 15px; font-weight: 500; color: var(--ink-soft); }
.title { margin: 4px 0 0; font-family: var(--display); font-weight: 200; font-size: clamp(52px, 7vw, 76px); line-height: 1; letter-spacing: -0.04em; }
.controls { display: flex; flex-wrap: wrap; gap: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip { padding: 9px 16px; border-radius: 999px; font-size: 14px; font-weight: 500; border: 1px solid rgba(255, 255, 255, 0.22); color: rgba(255, 255, 255, 0.9); transition: background 0.2s ease; }
.chip:hover { background: rgba(255, 255, 255, 0.12); }
.chip.active { background: var(--pill); color: var(--pill-ink); border-color: transparent; font-weight: 600; }

.chart-card { border-radius: 28px; padding: 24px 24px 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.stat-label { font-size: 13px; color: rgba(226, 232, 255, 0.75); }
/* The time sits 10px after the value; if it doesn't fit, it moves whole to the next line. */
.stat-value { font-family: var(--display); font-weight: 300; font-size: 30px; line-height: 1.1; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 10px; }
.stat-sub { font-family: var(--body); font-size: 14px; color: rgba(226, 232, 255, 0.75); white-space: nowrap; }
.stat-row { display: flex; align-items: center; gap: 14px; }
.swatch { width: 22px; height: 3px; border-radius: 2px; flex: none; }

.view-switch { align-self: flex-start; display: inline-flex; margin: 14px 0 4px; }
.chart-area { height: 560px; margin-top: 8px; }
.chart-loading { height: 100%; }
.table-panel { margin-top: 10px; }

.pager { display: flex; align-items: center; gap: 10px; }
.btn-page {
  font: inherit; font-size: 13px; font-weight: 600;
  min-height: 32px; padding: 4px 14px;
  border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08); color: #FFFFFF; cursor: pointer;
  transition: background 0.2s ease;
}
.btn-page:hover:not(:disabled) { background: rgba(255, 255, 255, 0.16); }
.btn-page:focus-visible { outline: 2px solid #FFFFFF; outline-offset: 2px; }
.btn-page:disabled { opacity: 0.35; cursor: default; }
.page-label { min-width: 86px; text-align: center; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.btn-link { font: inherit; font-size: 13px; font-weight: 600; background: none; border: 0; color: #FFFFFF; cursor: pointer; padding: 4px 0; }
.btn-link:hover { text-decoration: underline; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.data-table th { padding: 10px 12px; text-align: left; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(226, 232, 255, 0.7); }
.data-table td { padding: 11px 12px; border-top: 1px solid rgba(255, 255, 255, 0.08); font-weight: 500; }
.data-table td:first-child, .data-table td.muted { color: var(--ink-soft); font-weight: 400; }
.table-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 12px 4px; font-size: 13px; color: var(--ink-mute); }

.empty { padding: 120px 0; text-align: center; }
.empty h1 { font-family: var(--display); font-weight: 300; font-size: 44px; margin: 0 0 8px; }
.empty a { font-weight: 600; text-decoration: underline; }

.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 28px; font-size: 13px; color: rgba(226, 232, 255, 0.6); }

/* Dash's graph loading overlay: keep it subtle on the dark glass. */
._dash-loading { color: var(--ink-mute); }

/* ---------------------------------------------------------
   Single screen: from iPad width (768 px) up, each page fits the
   window exactly, whatever its height, with no page scroll. Sizes
   follow the window height (vh) between a floor and a ceiling.
   Narrower than an iPad (phones): the stacked, scrolling layout.
   --------------------------------------------------------- */

@media (min-width: 768px) {
  .shell { height: 100vh; display: flex; flex-direction: column; padding: clamp(8px, 2vh, 16px) clamp(20px, 2.6vw, 32px) clamp(6px, 1.4vh, 12px); }
  .topbar { flex-wrap: nowrap; gap: 16px; }
  .live { white-space: nowrap; }
  .shell > .topbar { flex: none; }
  .shell > .topbar + div,
  #_pages_content,
  .now-page,
  .trend-page { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .foot { flex: none; margin-top: 10px; font-size: 12px; }
  .seg label { min-height: clamp(30px, 5vh, 40px); padding-top: clamp(4px, 1vh, 9px); padding-bottom: clamp(4px, 1vh, 9px); }

  /* Now: temperature and 24-hour graph side by side, cards fill the rest */
  .now-top { flex: none; display: grid; grid-template-columns: minmax(240px, 360px) minmax(0, 1fr); gap: clamp(8px, 1.8vh, 16px); margin: clamp(6px, 1.8vh, 16px) 0; }
  .hero { padding: 0; justify-content: center; }
  .hero-loc { font-size: clamp(12px, 1.9vh, 15px); }
  .hero-temp { margin-top: 0; font-size: clamp(44px, 12.5vh, 116px); }
  .hero-sub { margin-top: 0; font-size: clamp(13px, 2.1vh, 17px); text-wrap: balance; }
  .hero-hl { margin-top: 2px; font-size: clamp(12px, 1.8vh, 15px); }
  .daycard { margin: 0; padding: clamp(8px, 1.8vh, 16px) 22px clamp(6px, 1.5vh, 14px); }
  .daycard-head { padding-bottom: clamp(4px, 1.2vh, 12px); }
  #day-graph { height: clamp(44px, 12vh, 110px) !important; margin-top: clamp(4px, 1.2vh, 14px) !important; }
  .hours { margin-top: clamp(4px, 1vh, 10px); }
  .hour-t { font-size: clamp(10px, 1.5vh, 12px); }
  .hour-v { font-size: clamp(12px, 2vh, 16px); margin-top: 0; }

  .cards { flex: 1; min-height: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: clamp(8px, 1.8vh, 16px); }
  .card { min-height: 0; padding: clamp(8px, 1.8vh, 16px) clamp(12px, 1.6vw, 20px); gap: clamp(2px, 0.9vh, 8px); overflow: hidden; }
  .card > * { flex-shrink: 0; }
  .card > .strip, .card > .sunbox { flex-shrink: 1; }
  .cap { font-size: clamp(10px, 1.5vh, 12px); }
  .card-more { font-size: clamp(11px, 1.6vh, 13px); }
  .big { font-size: clamp(26px, 5.2vh, 48px); }
  .unit { font-size: 0.5em; }
  .note { font-size: clamp(11px, 1.75vh, 14px); }
  .scale-labels, .strip-labels, .sun-times { font-size: clamp(10px, 1.45vh, 12px); }
  .compass { width: min(44%, clamp(64px, calc(30vh - 90px), 170px)); }
  .compass .pt { font-size: clamp(10px, 1.6vh, 14px); }
  .gauge-box { --gauge: clamp(60px, calc(30vh - 110px), 152px); row-gap: 2px; }
  .card .strip { min-height: clamp(6px, 2.5vh, 40px); max-height: clamp(24px, 9vh, 88px); }
  .card .strip-rain { max-height: clamp(28px, 11vh, 110px); }
  .sunbox { min-height: clamp(30px, 6vh, 64px); max-height: clamp(44px, 14vh, 130px); margin-top: clamp(2px, 1vh, 10px); }
  .sunpath { min-height: 20px; }
  .light-notes { padding-top: clamp(2px, 0.8vh, 8px); }

  /* Trends: chart or table fills the space under the stats */
  .trend-head { padding: clamp(6px, 1.8vh, 16px) 0 clamp(4px, 1.4vh, 12px); gap: 12px; }
  .eyebrow { font-size: clamp(12px, 1.9vh, 15px); }
  .title { font-size: clamp(30px, 6vh, 56px); }
  .chips { margin-bottom: clamp(4px, 1.4vh, 12px); }
  .chip { padding: clamp(4px, 0.9vh, 9px) 14px; font-size: clamp(12px, 1.8vh, 14px); }
  .chart-card { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: clamp(8px, 1.8vh, 16px) 22px clamp(4px, 1vh, 10px); }
  .stats { flex: none; padding-bottom: clamp(4px, 1.4vh, 12px); }
  .stat-value { font-size: clamp(18px, 3.3vh, 30px); }
  .stat-label, .stat-sub { font-size: clamp(11px, 1.7vh, 14px); }
  .view-switch { margin: clamp(4px, 0.9vh, 8px) 0 0; }
  .view-switch label { padding-top: 4px; padding-bottom: 4px; }
  .chart-area { flex: 1; min-height: 0; height: auto; }
  .table-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .table-wrap { flex: 1; min-height: 0; overflow: auto; }
  .table-foot { flex: none; }
  .data-table th, .data-table td { padding: clamp(3px, 0.7vh, 6px) 12px; }
}

/* Portrait windows (iPad upright): two columns of cards in three rows. */
@media (min-width: 768px) and (max-aspect-ratio: 1/1) {
  .hours > div:nth-child(even):not(:last-child) { display: none; }
  .hours { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .compass { width: min(44%, clamp(64px, calc(14vh - 10px), 170px)); }
  .gauge-box { --gauge: clamp(60px, calc(11vh - 30px), 140px); }
  .live { font-size: 12px; }
  .brand { font-size: 17px; }
  .sunbox { max-height: clamp(44px, 7vh, 100px); }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }
}

/* Short windows: the footer line is the first thing to go. */
@media (min-width: 768px) and (max-height: 800px) {
  .foot { display: none; }
}

/* ---------------------------------------------------------
   Pop-up trend panel (Now page): opens over a blurred page
   --------------------------------------------------------- */

.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 32px; visibility: hidden; opacity: 0; pointer-events: none; transition: opacity 0.2s ease, visibility 0s linear 0.2s; }
.modal.open { visibility: visible; opacity: 1; pointer-events: auto; transition: opacity 0.2s ease; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 10, 28, 0.42); -webkit-backdrop-filter: blur(14px) saturate(120%); backdrop-filter: blur(14px) saturate(120%); cursor: pointer; }
.modal-panel { position: relative; width: min(1180px, 100%); height: min(820px, 100%); display: flex; flex-direction: column; padding: 22px 28px 14px; border-radius: 28px; background: rgba(14, 28, 64, 0.74); border: 1px solid rgba(255, 255, 255, 0.18); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35); -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px); transform: translateY(12px) scale(0.98); transition: transform 0.2s ease; }
.modal.open .modal-panel { transform: none; }
.modal-close { position: absolute; top: 18px; right: 18px; z-index: 2; width: 38px; height: 38px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.1); color: #FFFFFF; font-size: 16px; line-height: 1; cursor: pointer; transition: background 0.2s ease; }
.modal-close:hover { background: rgba(255, 255, 255, 0.22); }
.modal-close:focus-visible { outline: 2px solid #FFFFFF; outline-offset: 2px; }
.modal-panel .trend-head { flex: none; padding: 0 56px 14px 0; }
.modal-title { font-size: clamp(36px, 4vw, 48px); }
.modal-panel .chart-card { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0; border-radius: 0; background: none; border: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.modal-panel .stats { flex: none; padding-bottom: 12px; }
.modal-panel .view-switch { margin: 8px 0 0; }
.modal-panel .chart-area { flex: 1; min-height: 0; height: auto; }
.modal-panel .table-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.modal-panel .table-wrap { flex: 1; min-height: 0; overflow: auto; }
.modal-panel .table-foot { flex: none; }
.modal-panel .data-table th, .modal-panel .data-table td { padding: 6px 12px; }
body:has(.modal.open) { overflow: hidden; }

@media (max-height: 800px) {
  .modal { padding: 20px; }
  .modal-panel { padding: 16px 22px 10px; }
  .modal-title { font-size: clamp(32px, 3.5vw, 40px); }
  .modal-panel .data-table th, .modal-panel .data-table td { padding: 4px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .modal, .modal.open, .modal-panel { transition: none; }
}

/* ---------------------------------------------------------
   Small screens
   --------------------------------------------------------- */

@media (max-width: 720px) {
  .shell { padding: 16px 16px 48px; }
  .hero { padding: 40px 0 36px; }
  .hero-sub { font-size: 17px; }
  .hours { grid-template-columns: repeat(5, minmax(0, 1fr)); row-gap: 10px; }
  .hours > div:nth-child(even):not(:last-child) { display: none; }
  .cards { grid-template-columns: 1fr; }
  .chart-card { padding: 16px 12px 10px; }
  .modal { padding: 0; }
  .modal-panel { height: 100%; border-radius: 0; padding: 16px; }
}
