/* ── TOKENS ─────────────────────────────────────────────── */
:root {
  --ff-body: 'DM Sans', sans-serif;
  --ff-mono: 'DM Mono', monospace;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;

  --transition: 0.25s ease;

  /* light */
  --bg-page:    #f0f4f8;
  --bg-card:    #ffffff;
  --bg-card2:   #f7fafc;
  --bg-pill:    #e8edf2;
  --border:     rgba(0,0,0,0.07);
  --text-1:     #0f1923;
  --text-2:     #4a5568;
  --text-3:     #8a9bb0;
  --accent:     #2563eb;
  --accent-soft:#dbeafe;
  --temp-color: #e05252;
  --hum-color:  #2563eb;
  --pres-color: #7c3aed;
  --wind-color: #0891b2;
  --rain-color: #0369a1;
  --solar-color:#d97706;
  --uv-color:   #7c3aed;
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.10);
}
[data-theme="dark"] {
  --bg-page:    #0d1117;
  --bg-card:    #161b22;
  --bg-card2:   #1c2330;
  --bg-pill:    #21262d;
  --border:     rgba(255,255,255,0.07);
  --text-1:     #e6edf3;
  --text-2:     #8b949e;
  --text-3:     #484f58;
  --accent:     #58a6ff;
  --accent-soft:#1f3a5f;
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.5);
}

/* ── RESET ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--ff-body);
  background: var(--bg-page);
  color: var(--text-1);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

/* ── LAYOUT ──────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  gap: 0.5rem;
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.logo-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
.logo-text {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-1);
  white-space: nowrap;
}
.logo-text span { color: var(--accent); }
.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.station-badge {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-2);
  background: var(--bg-pill);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  display: block;
}
@media (min-width: 480px) { .station-badge { display: block; } }

@media (max-width: 480px) {
  .site-header { padding: 0.4rem 0.75rem; }
  .logo-icon { width: 26px; height: 26px; }
  .logo-text { display: none; }
  .header-right { gap: 0.4rem; }
  .theme-toggle { width: 32px; height: 32px; font-size: 0.9rem; }
}

.updated-time {
  font-size: 0.72rem;
  color: var(--text-3);
  font-family: var(--ff-mono);
  display: none;
}
@media (min-width: 640px) { .updated-time { display: block; } }

/* Theme toggle */
.theme-toggle {
  width: 40px; height: 40px;
  border: none;
  background: var(--bg-pill);
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  transition: background var(--transition), transform 0.2s;
  color: var(--text-1);
}
.theme-toggle:hover { transform: rotate(20deg); background: var(--border); }

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.station-select {
  font-family: var(--ff-body);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-2);
  background: var(--bg-pill);
  border: none;
  border-radius: 999px;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.station-select:focus { box-shadow: 0 0 0 2px var(--accent); }

/* ── CURRENT CONDITIONS GRID ─────────────────────────────── */
.section-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 0.75rem;
}

.conditions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
@media (min-width: 480px) {
  .conditions-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
  .conditions-grid { grid-template-columns: repeat(6, 1fr); }
}

.cond-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 0.9rem 0.85rem;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), border var(--transition), transform 0.15s;
  position: relative;
  overflow: hidden;
}
.cond-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-accent, var(--accent));
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.cond-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.cond-card-hdr {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}
.cond-icon { font-size: 1.1rem; }
.cond-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}
.cond-value {
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.cond-unit {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-3);
  margin-left: 1px;
}
.cond-sub {
  font-size: 0.7rem;
  color: var(--text-3);
  margin-top: 0.3rem;
  font-family: var(--ff-mono);
  min-height: 0;
}
.cond-sub:empty { margin-top: 0; }
.cond-minmax {
  font-size: 0.68rem;
  font-family: var(--ff-mono);
  margin-top: 0.25rem;
  color: var(--text-3);
  letter-spacing: 0.02em;
}
.cond-minmax:empty { display: none; }
.cond-value-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.pressure-trend-arrow {
  width: 16px;
  height: 16px;
  color: var(--text-3);
  flex-shrink: 0;
  transition: transform 0.6s ease;
  transform-origin: center;
}
.minmax-lo { color: #60a5fa; }
.minmax-hi { color: #f87171; }

/* ── GAUGE / DIAL VIEW ───────────────────────────────────── */
.section-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.section-label-row .section-label { margin-bottom: 0; }

.view-toggle-btn {
  font-size: 0.78rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--ff-body);
  line-height: 1;
}
.view-toggle-btn:hover,
.view-toggle-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.cond-gauge {
  display: none;
  width: 100%;
  margin-top: 0.2rem;
}
.conditions-grid.dial .cond-value { display: none; }
.conditions-grid.dial .cond-gauge  { display: block; }

.gauge-track {
  stroke: var(--bg-pill);
  stroke-width: 7;
  stroke-linecap: round;
}
.gauge-fill {
  stroke-width: 7;
  stroke-linecap: round;
}
.gauge-tick {
  stroke: var(--text-3);
  stroke-width: 1.5;
  stroke-linecap: round;
}
.gauge-label {
  font-family: var(--ff-body);
  font-size: 7.5px;
  fill: var(--text-3);
}
.gauge-val-text {
  font-family: var(--ff-body);
  font-size: 14px;
  font-weight: 700;
  fill: var(--text-1);
}

/* ── CHARTS GRID ─────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
@media (min-width: 700px) {
  .charts-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1050px) {
  .charts-grid { grid-template-columns: repeat(2, 1fr); }
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.1rem 0.9rem;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), border var(--transition);
  min-width: 0;
}
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.9rem;
}
.chart-title {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-2);
}
.chart-range {
  display: flex;
  gap: 0.3rem;
}
.range-btn {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--ff-body);
}
.range-btn.active,
.range-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.global-range-btn {
  font-size: 0.82rem;
  padding: 0.4rem 1.1rem;
  border-width: 1.5px;
}
.global-range-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.global-range-btn:hover:not(.active) {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.unit-btn {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  font-family: var(--ff-body);
  vertical-align: middle;
  transition: all 0.15s;
}
.unit-btn:hover {
  background: var(--accent);
  color: #fff;
}
.chart-wrap {
  position: relative;
  height: 160px;
  width: 100%;
  min-width: 0;
}
@media (min-width: 700px) { .chart-wrap { height: 180px; } }

/* ── WIND + RAIN ROW ─────────────────────────────────────── */
.bottom-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
@media (min-width: 600px) {
  .bottom-grid { grid-template-columns: 1fr 1fr; }
}

.info-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), border var(--transition);
}
.info-card-title {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 0.9rem;
}

/* Wind compass */
.wind-compass-wrap {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.compass {
  position: relative;
  width: 90px; height: 90px;
  flex-shrink: 0;
}
.compass-ring {
  width: 90px; height: 90px;
  border-radius: 50%;
  border: 2px solid var(--border);
  position: relative;
  background: var(--bg-card2);
}
.compass-labels {
  position: absolute;
  inset: 0;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-3);
}
.compass-labels span {
  position: absolute;
  transform: translate(-50%, -50%);
}
.compass-labels .cn { top: 8%; left: 50%; }
.compass-labels .cs { top: 92%; left: 50%; }
.compass-labels .cw { top: 50%; left: 8%; }
.compass-labels .ce { top: 50%; left: 92%; }
.compass-needle {
  position: absolute;
  top: 50%; left: 50%;
  width: 3px;
  height: 36px;
  margin-left: -1.5px;
  transform-origin: bottom center;
  transition: transform 1s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: 3px 3px 0 0;
}
.needle-up   { background: var(--temp-color); height: 26px; margin-top: -26px; }
.needle-down { background: var(--text-3);     height: 12px; margin-top: 0; }

.wind-stats { flex: 1; }
.wind-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}
.wind-stat-row:last-child { border-bottom: none; }
.wind-stat-label { color: var(--text-3); }
.wind-stat-value {
  font-weight: 600;
  font-family: var(--ff-mono);
  color: var(--text-1);
}

/* Rainfall totals */
.rain-bars { display: flex; flex-direction: column; gap: 0.6rem; }
.rain-bar-row { display: flex; align-items: center; gap: 0.75rem; }
.rain-bar-label { font-size: 0.72rem; color: var(--text-3); width: 60px; flex-shrink: 0; }
.rain-bar-track {
  flex: 1;
  height: 6px;
  background: var(--bg-pill);
  border-radius: 999px;
  overflow: hidden;
}
.rain-bar-fill {
  height: 100%;
  background: var(--rain-color);
  border-radius: 999px;
  transition: width 1s ease;
}
.rain-bar-val {
  font-size: 0.72rem;
  font-family: var(--ff-mono);
  font-weight: 500;
  color: var(--text-1);
  width: 50px;
  text-align: right;
}

/* ── STATUS BAR ──────────────────────────────────────────── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse-dot 2s infinite;
  flex-shrink: 0;
}
@keyframes pulse-dot {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
.status-dot.offline { background: #ef4444; animation: none; }
.status-text { font-size: 0.72rem; color: var(--text-3); }

/* ── LOADING / ERROR ─────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-pill) 25%, var(--border) 50%, var(--bg-pill) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
  color: transparent !important;
  user-select: none;
  min-width: 60px;
  display: inline-block;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.error-banner {
  background: #7f1d1d22;
  border: 1px solid #ef444455;
  color: #fca5a5;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  font-size: 0.8rem;
  margin-bottom: 1rem;
  display: none;
}

/* ── COMPARE PAGE ────────────────────────────────────────── */
.cmp-grid {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
  transition: background var(--transition), border var(--transition);
}

.cmp-hdr-spacer,
.cmp-hdr {
  padding: 0.65rem 1rem;
  background: var(--bg-card2);
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 700;
}

.cmp-hdr {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--stn-color, var(--text-1));
  border-left: 1px solid var(--border);
}

.cmp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cmp-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  background: var(--bg-card2);
  border-bottom: 1px solid var(--border);
}

.cmp-val {
  padding: 0.75rem 1rem;
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.cmp-main {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.cmp-sub {
  font-size: 0.68rem;
  color: var(--text-3);
  font-family: var(--ff-mono);
  margin-top: 0.3rem;
}

.cmp-icon { font-size: 1rem; }

.cmp-grid > *:nth-last-child(-n+3) { border-bottom: none; }

.compare-chart-legend {
  display: flex;
  gap: 1.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 0.6rem;
  align-items: center;
}

.cleg-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

.cleg-dash {
  display: inline-block;
  width: 18px;
  border-top: 2px dashed;
  margin-right: 5px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

/* ── COMPARE PAGE MOBILE ─────────────────────────────────── */
@media (max-width: 580px) {
  .cmp-grid {
    grid-template-columns: 34px 1fr 1fr;
  }
  .cmp-hdr-spacer,
  .cmp-hdr {
    padding: 0.55rem 0.6rem;
  }
  .cmp-hdr {
    font-size: 0.7rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .cmp-label {
    padding: 0.65rem 0;
    justify-content: center;
    gap: 0;
  }
  .cmp-label-text { display: none; }
  .cmp-val {
    padding: 0.65rem 0.6rem;
  }
  .cmp-main {
    font-size: 1.15rem;
  }
  .cmp-sub {
    font-size: 0.6rem;
  }
}
