/* ============================================================
   twostateweather — "Two Latitudes"
   North card: glacial cyan · South card: Appalachian amber
   ============================================================ */

:root {
  --font-display: "Big Shoulders Display", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
}

[data-theme="dark"] {
  --bg: #07090f;
  --bg-card: rgba(15, 19, 30, .72);
  --bg-card-edge: rgba(255, 255, 255, .07);
  --ink: #eef2f7;
  --ink-dim: #8b95a7;
  --ink-faint: #525c6e;
  --north: #5fd4e8;
  --north-deep: #0e3a46;
  --south: #f4a259;
  --south-deep: #4a2c10;
  --live: #4ade80;
  --stale: #f59e0b;
  --mesh-a: rgba(28, 84, 110, .35);
  --mesh-b: rgba(120, 64, 18, .28);
  --mesh-c: rgba(40, 30, 80, .30);
  --stat-line: rgba(255, 255, 255, .06);
  --shadow: 0 24px 70px -20px rgba(0, 0, 0, .8);
  --grain-opacity: .05;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f1ede4;
  --bg-card: rgba(255, 253, 248, .8);
  --bg-card-edge: rgba(20, 28, 40, .1);
  --ink: #1a2230;
  --ink-dim: #5b6678;
  --ink-faint: #9aa3b2;
  --north: #0e7c97;
  --north-deep: #c9eef6;
  --south: #c06414;
  --south-deep: #fbe3c8;
  --live: #15803d;
  --stale: #b45309;
  --mesh-a: rgba(110, 190, 215, .35);
  --mesh-b: rgba(244, 162, 89, .3);
  --mesh-c: rgba(190, 180, 240, .3);
  --stat-line: rgba(20, 28, 40, .08);
  --shadow: 0 24px 60px -28px rgba(30, 40, 60, .45);
  --grain-opacity: .035;
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 14px;
  overflow-x: hidden;
  transition: background .5s var(--ease-out), color .5s var(--ease-out);
}

/* ---------- atmosphere ---------- */
.mesh {
  position: fixed; inset: -20%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(45% 55% at 18% 25%, var(--mesh-a), transparent 70%),
    radial-gradient(45% 55% at 84% 70%, var(--mesh-b), transparent 70%),
    radial-gradient(40% 45% at 55% 105%, var(--mesh-c), transparent 70%);
  animation: mesh-drift 36s ease-in-out infinite alternate;
  transition: background .5s var(--ease-out);
}
@keyframes mesh-drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to   { transform: translate3d(2%, 2%, 0) scale(1.06); }
}

.grain {
  position: fixed; inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* ---------- top bar ---------- */
.topbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem clamp(1rem, 4vw, 3rem);
  animation: drop-in .7s var(--ease-out) both;
}

.brand { display: flex; align-items: center; gap: .65rem; }
.brand-mark { color: var(--north); display: grid; place-items: center; }
.brand h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.45rem;
  letter-spacing: .12em;
}
.brand h1 em {
  font-style: normal;
  font-weight: 500;
  color: var(--ink-dim);
}

.status { display: flex; align-items: center; gap: .9rem; }

.live {
  display: inline-flex; align-items: center; gap: .45rem;
  font-size: .62rem; letter-spacing: .18em; font-weight: 600;
  color: var(--ink-dim);
  border: 1px solid var(--bg-card-edge);
  border-radius: 99px;
  padding: .35rem .7rem;
  backdrop-filter: blur(6px);
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--stale);
  transition: background .3s;
}
.live.on .live-dot {
  background: var(--live);
  animation: pulse 2.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 50%, transparent); }
  50%      { box-shadow: 0 0 0 5px transparent; }
}

.refresh-ring { position: relative; display: grid; place-items: center; }
.refresh-ring svg { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--stat-line); stroke-width: 2.4; }
.ring-fg {
  fill: none; stroke: var(--north); stroke-width: 2.4;
  stroke-linecap: round;
  stroke-dasharray: 97.4;       /* 2πr, r=15.5 */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}
.ring-num {
  position: absolute;
  font-size: .58rem; font-weight: 600;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

.theme-toggle {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--bg-card-edge);
  background: var(--bg-card);
  color: var(--ink);
  cursor: pointer;
  transition: transform .25s var(--ease-out), border-color .25s;
}
.theme-toggle:hover { transform: rotate(20deg) scale(1.08); border-color: var(--ink-faint); }
[data-theme="dark"] .ico-moon { display: none; }
[data-theme="light"] .ico-sun { display: none; }

/* ---------- stage layout ---------- */
.stage {
  position: relative; z-index: 1;
  flex: 1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: clamp(.8rem, 2vw, 1.6rem);
  align-items: stretch;
  padding: clamp(.5rem, 2vh, 1.5rem) clamp(1rem, 4vw, 3rem) 1.5rem;
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- divider ---------- */
.divider {
  display: flex; flex-direction: column; align-items: center;
  gap: .9rem;
  padding: 1.5rem 0;
  animation: fade-in 1s .5s var(--ease-out) both;
}
.divider-line {
  flex: 1; width: 1px;
  background: linear-gradient(to bottom, transparent, var(--ink-faint), transparent);
}
.divider-label {
  writing-mode: vertical-rl;
  font-size: .6rem; letter-spacing: .35em; font-weight: 600;
  color: var(--ink-dim);
  white-space: nowrap;
}
.delta-badge {
  writing-mode: vertical-rl;
  font-size: .6rem; letter-spacing: .25em; font-weight: 600;
  color: var(--ink);
  background: linear-gradient(to bottom, color-mix(in srgb, var(--north) 22%, transparent), color-mix(in srgb, var(--south) 22%, transparent));
  border: 1px solid var(--bg-card-edge);
  border-radius: 99px;
  padding: .9rem .32rem;
  white-space: nowrap;
}
.delta-badge:empty { display: none; }

/* ---------- cards ---------- */
.card {
  position: relative;
  border-radius: 22px;
  border: 1px solid var(--bg-card-edge);
  background: var(--bg-card);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  padding: clamp(1.2rem, 2.5vw, 2rem);
  overflow: hidden;
  display: flex; flex-direction: column;
  min-height: 540px;
  transition: background .5s var(--ease-out), border-color .5s;
}
.card[data-city="greenlake"] { --accent: var(--north); --accent-deep: var(--north-deep); animation: rise-in .8s .1s var(--ease-out) both; }
.card[data-city="benton"]    { --accent: var(--south); --accent-deep: var(--south-deep); animation: rise-in .8s .25s var(--ease-out) both; }

.c-data { display: flex; flex-direction: column; flex: 1 1 auto; }

.card::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(120% 60% at 50% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%);
  pointer-events: none;
}
.card::after {
  content: "";
  position: absolute; top: 0; left: 8%; right: 8%; height: 1px;
  background: linear-gradient(to right, transparent, var(--accent), transparent);
  opacity: .7;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(26px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
@keyframes drop-in {
  from { opacity: 0; transform: translateY(-14px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.skeleton { justify-content: center; align-items: center; }
.skeleton::marker { content: ""; }

/* card header */
.c-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; position: relative; }
.c-place .c-state {
  font-size: .62rem; letter-spacing: .3em; font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: .2rem;
}
.c-place h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 3.2vw, 2.8rem);
  letter-spacing: .03em;
  line-height: 1;
  text-transform: uppercase;
}
.c-clock { text-align: right; }
.c-time {
  font-size: 1.05rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.c-date { font-size: .65rem; color: var(--ink-dim); letter-spacing: .12em; margin-top: .15rem; }

/* hero */
.c-hero {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  margin: auto 0;
  padding: 1.4rem 0;
  position: relative;
}
.c-temp-wrap { display: flex; flex-direction: column; }
.c-temp {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(5.5rem, 9vw, 8.5rem);
  line-height: .88;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}
.c-temp sup {
  font-size: .35em; font-weight: 700;
  color: var(--accent);
  vertical-align: super;
}
.c-cond {
  font-size: .78rem; letter-spacing: .22em; font-weight: 600;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-top: .7rem;
}
.c-feels { font-size: .68rem; color: var(--ink-faint); margin-top: .3rem; letter-spacing: .08em; }

/* hi/lo rail */
.c-hilo {
  display: flex; gap: 1.2rem;
  font-size: .72rem; letter-spacing: .1em;
  color: var(--ink-dim);
  margin-top: .9rem;
}
.c-hilo b { color: var(--ink); font-weight: 600; }
.c-hilo .hi b { color: var(--accent); }

/* stat grid */
.c-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--stat-line);
  position: relative;
}
.stat {
  padding: .85rem .5rem .3rem;
  border-bottom: 1px solid var(--stat-line);
  min-width: 0;
}
.stat:nth-child(-n+3) { border-top: none; }
.stat-k {
  font-size: .56rem; letter-spacing: .22em; font-weight: 600;
  color: var(--ink-faint);
  text-transform: uppercase;
  margin-bottom: .3rem;
}
.stat-v {
  font-size: .95rem; font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat-v small { font-size: .65em; color: var(--ink-dim); margin-left: .15em; }
.wind-arrow {
  display: inline-block;
  color: var(--accent);
  transition: transform 1s var(--ease-out);
  margin-right: .2em;
}

/* sun rail */
.c-sun {
  display: flex; justify-content: space-between;
  padding-top: .8rem;
  font-size: .66rem; letter-spacing: .1em;
  color: var(--ink-dim);
}
.c-sun b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.stale-tag {
  position: absolute; top: 0; right: 0;
  font-size: .55rem; letter-spacing: .2em;
  color: var(--stale);
  border: 1px solid color-mix(in srgb, var(--stale) 40%, transparent);
  border-radius: 99px;
  padding: .2rem .55rem;
}

.station-tag {
  display: inline-block;
  vertical-align: middle;
  margin-left: .5em;
  font-size: .52rem; letter-spacing: .18em; font-weight: 600;
  color: var(--live);
  border: 1px solid color-mix(in srgb, var(--live) 35%, transparent);
  background: color-mix(in srgb, var(--live) 8%, transparent);
  border-radius: 99px;
  padding: .18rem .55rem;
  animation: pulse 2.2s ease-in-out infinite;
}

.c-src {
  padding-top: .55rem;
  font-size: .55rem; letter-spacing: .2em;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* ---------- radar panel ---------- */
.c-radar {
  position: relative;
  margin-top: 1rem;
  height: 188px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--bg-card-edge);
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  isolation: isolate;
}
.radar-canvas { display: block; width: 100%; height: 100%; }
.radar-grad {
  position: absolute; inset: auto 0 0 0; height: 46%;
  background: linear-gradient(to top, color-mix(in srgb, var(--bg) 88%, transparent), transparent);
  pointer-events: none;
}
.radar-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: .5rem .7rem;
  font-size: .56rem; letter-spacing: .2em; font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.radar-label { color: var(--accent); }
.radar-attr {
  position: absolute; top: .45rem; right: .55rem;
  font-size: .48rem; letter-spacing: .12em;
  color: var(--ink-dim);
  opacity: .7;
  background: color-mix(in srgb, var(--bg) 45%, transparent);
  padding: .12rem .4rem; border-radius: 99px;
  pointer-events: none;
}

/* ============================================================
   Animated weather glyphs (pure CSS)
   ============================================================ */
.wicon {
  position: relative;
  width: clamp(96px, 11vw, 140px);
  height: clamp(96px, 11vw, 140px);
  flex: none;
  filter: drop-shadow(0 10px 24px color-mix(in srgb, var(--accent) 30%, transparent));
}

/* sun */
.wicon .sun {
  position: absolute; inset: 18%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffe9a8, #f6b73c 70%);
  animation: sun-throb 4s ease-in-out infinite;
}
.wicon .rays {
  position: absolute; inset: 0;
  animation: spin 26s linear infinite;
}
.wicon .rays::before {
  content: "";
  position: absolute; inset: 0;
  background:
    repeating-conic-gradient(from 0deg, #f6b73c 0deg 4deg, transparent 4deg 45deg);
  -webkit-mask: radial-gradient(circle, transparent 42%, #000 43%, #000 49%, transparent 50%);
          mask: radial-gradient(circle, transparent 42%, #000 43%, #000 49%, transparent 50%);
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes sun-throb { 50% { transform: scale(1.04); } }

/* moon */
.wicon .moon {
  position: absolute; inset: 20%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #e8edf5, #aab6cc 75%);
  box-shadow: inset -10px -8px 0 0 color-mix(in srgb, var(--bg) 60%, #6b7a96);
  animation: sun-throb 5s ease-in-out infinite;
}
.wicon .star {
  position: absolute;
  width: 4px; height: 4px;
  background: #dfe7f5;
  border-radius: 50%;
  animation: twinkle 2.6s ease-in-out infinite;
}
.wicon .star:nth-child(2) { top: 12%; left: 14%; animation-delay: .4s; }
.wicon .star:nth-child(3) { top: 22%; right: 8%; animation-delay: 1.1s; transform: scale(.7); }
.wicon .star:nth-child(4) { bottom: 14%; left: 8%; animation-delay: 1.8s; transform: scale(.8); }
@keyframes twinkle { 50% { opacity: .15; } }

/* cloud */
.wicon .cloud {
  position: absolute;
  left: 8%; right: 8%; bottom: 22%;
  height: 38%;
  background: linear-gradient(to bottom, #cfd8e6, #9fadc4);
  border-radius: 99px;
  animation: cloud-drift 6s ease-in-out infinite alternate;
}
.wicon .cloud::before,
.wicon .cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 50%;
}
.wicon .cloud::before { width: 52%; height: 130%; left: 12%; bottom: 30%; }
.wicon .cloud::after  { width: 38%; height: 95%;  right: 14%; bottom: 45%; }
.wicon .cloud.back {
  inset: auto 20% 42% 24%;
  height: 30%;
  opacity: .45;
  animation-duration: 8s;
  animation-direction: alternate-reverse;
}
@keyframes cloud-drift { from { transform: translateX(-4%); } to { transform: translateX(4%); } }

/* sun/moon peeking behind cloud */
.wicon.has-cloud .sun, .wicon.has-cloud .rays { inset: 6% 6% auto auto; width: 46%; height: 46%; }
.wicon.has-cloud .moon { inset: 8% 10% auto auto; width: 38%; height: 38%; }

/* rain */
.wicon .drops { position: absolute; left: 18%; right: 18%; bottom: 2%; height: 24%; }
.wicon .drop {
  position: absolute; top: 0;
  width: 2.5px; height: 11px;
  border-radius: 99px;
  background: linear-gradient(to bottom, transparent, #6fb6e8);
  animation: rain-fall 1.1s linear infinite;
}
.wicon .drop:nth-child(1) { left: 8%; animation-delay: 0s; }
.wicon .drop:nth-child(2) { left: 32%; animation-delay: .4s; }
.wicon .drop:nth-child(3) { left: 56%; animation-delay: .15s; }
.wicon .drop:nth-child(4) { left: 80%; animation-delay: .6s; }
@keyframes rain-fall {
  0% { transform: translateY(-4px); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: translateY(20px); opacity: 0; }
}

/* snow */
.wicon .flake {
  position: absolute; top: 0;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #eaf2fb;
  animation: snow-fall 2.4s linear infinite;
}
.wicon .flake:nth-child(1) { left: 10%; animation-delay: 0s; }
.wicon .flake:nth-child(2) { left: 38%; animation-delay: 1.2s; }
.wicon .flake:nth-child(3) { left: 64%; animation-delay: .5s; }
.wicon .flake:nth-child(4) { left: 86%; animation-delay: 1.7s; }
@keyframes snow-fall {
  0% { transform: translate(0, -4px); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(5px, 22px); opacity: 0; }
}

/* lightning */
.wicon .bolt {
  position: absolute;
  left: 44%; bottom: 4%;
  width: 22%; height: 26%;
  clip-path: polygon(45% 0, 100% 0, 60% 45%, 85% 45%, 20% 100%, 42% 52%, 12% 52%);
  background: #ffd84d;
  animation: bolt-flash 3.2s ease-in-out infinite;
  transform-origin: top center;
}
@keyframes bolt-flash {
  0%, 86%, 100% { opacity: 0; }
  88%, 94% { opacity: 1; }
  91% { opacity: .3; }
}

/* fog */
.wicon .fog-line {
  position: absolute;
  left: 12%; right: 12%;
  height: 5px; border-radius: 99px;
  background: linear-gradient(to right, transparent, #9fadc4, transparent);
  animation: fog-slide 4s ease-in-out infinite alternate;
}
.wicon .fog-line:nth-child(1) { top: 36%; }
.wicon .fog-line:nth-child(2) { top: 50%; animation-delay: .8s; animation-direction: alternate-reverse; }
.wicon .fog-line:nth-child(3) { top: 64%; animation-delay: 1.6s; }
@keyframes fog-slide { from { transform: translateX(-8%); opacity: .5; } to { transform: translateX(8%); opacity: 1; } }

/* ---------- footer ---------- */
.foot {
  position: relative; z-index: 1;
  display: flex; justify-content: center; align-items: center;
  flex-wrap: wrap;
  gap: .7rem;
  padding: .6rem 1rem 1.1rem;
  font-size: .62rem; letter-spacing: .14em;
  color: var(--ink-faint);
  text-transform: uppercase;
}
.foot a { color: var(--ink-dim); text-decoration-color: var(--ink-faint); }
.foot a:hover { color: var(--ink); }
.foot-sep { opacity: .4; }

/* ---------- skeleton shimmer ---------- */
.skeleton::before {
  background: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--ink) 6%, transparent) 50%, transparent 70%);
  background-size: 220% 100%;
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer { to { background-position: -220% 0; } }

/* ---------- responsive ---------- */
@media (max-width: 920px) {
  .stage { grid-template-columns: 1fr; }
  .divider { flex-direction: row; padding: 0 1rem; gap: 1rem; }
  .divider-line { width: auto; height: 1px; flex: 1; background: linear-gradient(to right, transparent, var(--ink-faint), transparent); }
  .divider-label, .delta-badge { writing-mode: horizontal-tb; padding: .35rem .9rem; }
  .card { min-height: 0; }
  .c-temp { font-size: clamp(4.5rem, 18vw, 6.5rem); }
  .brand h1 { font-size: 1.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; transition-duration: .01s !important; }
}
