/* wxrh.us weather dashboard — themes, layout, widgets */

:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 12px;
  --radius-sm: 8px;
  --gap: 16px;
  --maxw: 1480px;

  --bg: #eef2f7;
  --bg-elev: #ffffff;
  --bg-sunken: #e3e9f1;
  --bg-hover: #f4f7fb;
  --text: #15202b;
  --text-muted: #5b6b7c;
  --border: #d5dde7;
  --accent: #2d6cdf;
  --accent-contrast: #ffffff;
  --accent-soft: #e2ebfb;
  --warn: #c7811a;
  --warn-soft: #fdf1dc;
  --danger: #c93c3c;
  --danger-soft: #fbe3e3;
  --ok: #2b8a4b;
  --ok-soft: #dff3e6;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --chart-grid: rgba(21, 32, 43, .08);
  --temp: #e4572e;
  --feels: #f0a35e;
  --precip: #2d6cdf;
  --prob: #7fb3ff;
  --wind: #6a9b2e;
  --pressure: #8e5bd1;
  --dew: #1fa7a0;
  --sev-extreme: #b4005a;
  --sev-severe: #d2322d;
  --sev-moderate: #e38b00;
  --sev-minor: #2d6cdf;
  --sev-unknown: #6c757d;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1419;
    --bg-elev: #161c23;
    --bg-sunken: #0b0f13;
    --bg-hover: #1d252e;
    --text: #e6edf3;
    --text-muted: #94a3b3;
    --border: #273240;
    --accent: #5a9bff;
    --accent-contrast: #0b0f13;
    --accent-soft: #1b2a44;
    --warn: #f0b24f;
    --warn-soft: #3b2d12;
    --danger: #ff6b6b;
    --danger-soft: #3d1a1a;
    --ok: #4cc072;
    --ok-soft: #14301f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
    --chart-grid: rgba(230, 237, 243, .08);
    --prob: #3b6fb8;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1419;
  --bg-elev: #161c23;
  --bg-sunken: #0b0f13;
  --bg-hover: #1d252e;
  --text: #e6edf3;
  --text-muted: #94a3b3;
  --border: #273240;
  --accent: #5a9bff;
  --accent-contrast: #0b0f13;
  --accent-soft: #1b2a44;
  --warn: #f0b24f;
  --warn-soft: #3b2d12;
  --danger: #ff6b6b;
  --danger-soft: #3d1a1a;
  --ok: #4cc072;
  --ok-soft: #14301f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
  --chart-grid: rgba(230, 237, 243, .08);
  --prob: #3b6fb8;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
p { margin: 0 0 .75em; }
code, pre { font-family: var(--mono); font-size: .86em; }
.muted { color: var(--text-muted); }
.small { font-size: .85em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
img { max-width: 100%; height: auto; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 8px 16px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; color: var(--text); font-size: 1.05rem; }
.brand-icon { width: 26px; height: 26px; color: var(--accent); }
.views { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.views a {
  text-decoration: none; color: var(--text-muted); padding: 7px 12px; border-radius: 999px; font-weight: 600; font-size: .92rem;
}
.views a:hover { background: var(--bg-hover); color: var(--text); }
.views a.active { background: var(--accent-soft); color: var(--accent); }
.views a[data-tropical]::before { content: "🌀"; margin-right: 5px; font-size: .9em; }
.topbar-tools { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.loc-select {
  background: var(--bg-elev); color: var(--text); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px; font: inherit; font-weight: 600; max-width: 220px;
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text);
  cursor: pointer; text-decoration: none; font: inherit; font-weight: 700; font-size: .85rem; padding: 0;
}
.icon-btn:hover { background: var(--bg-hover); }
.icon-btn.spinning svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
:root[data-theme="dark"] .icon-sun, :root:not([data-theme="light"]) .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon, :root:not([data-theme="light"]) .icon-moon { display: block; }
:root[data-theme="light"] .icon-sun { display: block; }
:root[data-theme="light"] .icon-moon { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .icon-sun { display: block; }
  :root:not([data-theme="dark"]) .icon-moon { display: none; }
}

/* ---------------------------------------------------------------- layout */
.dashboard { max-width: var(--maxw); margin: 0 auto; padding: 18px 16px 40px; }
.view-intro { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.view-intro h1 { margin: 0; }
.view-intro p { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--gap); }
.widget { grid-column: span 6; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; display: flex; flex-direction: column; }
@media (min-width: 760px) {
  .widget.size-half { grid-column: span 3; }
  .widget.size-third { grid-column: span 3; }
  .widget.size-two-thirds { grid-column: span 6; }
}
@media (min-width: 1100px) {
  .widget.size-third { grid-column: span 2; }
  .widget.size-two-thirds { grid-column: span 4; }
}
.widget-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px 10px; border-bottom: 1px solid var(--border);
}
.widget-head h2 { margin: 0; font-size: 1rem; }
.widget-meta { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--text-muted); }
.source { background: var(--bg-sunken); padding: 2px 8px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.updated { white-space: nowrap; }
.widget-refresh { width: 26px; height: 26px; font-size: .95rem; }
.widget-body { padding: 14px 16px 16px; flex: 1; min-width: 0; }
.widget.collapsed .widget-body { display: none; }
.loading { color: var(--text-muted); font-style: italic; }
.error { color: var(--danger); background: var(--danger-soft); padding: 10px 12px; border-radius: var(--radius-sm); }
.notice { color: var(--text-muted); background: var(--bg-sunken); padding: 10px 12px; border-radius: var(--radius-sm); }
.stale-tag { color: var(--warn); }
.empty-state h1 { font-size: 1.3rem; }

/* ---------------------------------------------------------------- generic components */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-elev); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); vertical-align: middle; }
.pill { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--bg-sunken); color: var(--text); margin: 2px 4px 2px 0; }
.flash { padding: 10px 14px; border-radius: var(--radius-sm); margin: 0 0 14px; font-weight: 500; }
.flash-success { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-warning { background: var(--warn-soft); color: var(--warn); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.tab-btn {
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text-muted);
  font: inherit; font-size: .84rem; font-weight: 600; cursor: pointer;
}
.tab-btn:hover { background: var(--bg-hover); color: var(--text); }
.tab-btn.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
select.inline-select, .widget-body select, .widget-body input[type="text"], .widget-body input[type="search"] {
  background: var(--bg-elev); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 10px; font: inherit; font-size: .9rem;
}
.controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }

/* stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--bg-sunken); border-radius: var(--radius-sm); padding: 10px 12px; min-width: 0; }
.stat-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; }
.stat-value { font-size: 1.25rem; font-weight: 700; line-height: 1.2; margin-top: 2px; }
.stat-value small { font-size: .7em; font-weight: 500; color: var(--text-muted); }
.stat-sub { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }
.hero { display: flex; align-items: center; gap: 18px; margin-bottom: 14px; flex-wrap: wrap; }
.hero-temp { font-size: 3.4rem; font-weight: 750; line-height: 1; letter-spacing: -.03em; }
.hero-temp small { font-size: .4em; font-weight: 500; color: var(--text-muted); margin-left: 2px; }
.hero-desc { font-size: 1.05rem; font-weight: 600; }
.hero-sub { color: var(--text-muted); font-size: .9rem; }
.cond-icon { width: 64px; height: 64px; flex: none; }
.cond-icon.sm { width: 28px; height: 28px; }
.cond-icon.md { width: 40px; height: 40px; }

/* tables */
.table-wrap { overflow: auto; max-height: 520px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table.data { border-collapse: collapse; width: 100%; font-size: .86rem; white-space: nowrap; }
table.data th, table.data td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: right; }
table.data th:first-child, table.data td:first-child { text-align: left; position: sticky; left: 0; background: var(--bg-elev); }
table.data thead th { position: sticky; top: 0; background: var(--bg-sunken); z-index: 2; font-weight: 600; color: var(--text-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
table.data thead th:first-child { z-index: 3; background: var(--bg-sunken); }
table.data tr.day-sep td { border-top: 2px solid var(--border); }
table.data tr.now td { background: var(--accent-soft); }
table.data td.wrap { white-space: normal; min-width: 240px; text-align: left; }
table.data .cond { display: inline-flex; align-items: center; gap: 6px; }

/* daily cards */
.cards-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(118px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; }
.day-card { background: var(--bg-sunken); border-radius: var(--radius-sm); padding: 10px; text-align: center; scroll-snap-align: start; min-width: 118px; }
.day-card .d { font-weight: 700; }
.day-card .dt { font-size: .76rem; color: var(--text-muted); }
.day-card .hi { font-weight: 700; font-size: 1.1rem; }
.day-card .lo { color: var(--text-muted); }
.day-card .line { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }
.day-card .desc { font-size: .78rem; margin-top: 4px; min-height: 2.2em; }
.range-bar { height: 6px; border-radius: 3px; background: var(--bg-elev); margin: 6px 0; position: relative; overflow: hidden; }
.range-bar span { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: linear-gradient(90deg, var(--dew), var(--temp)); }

/* alerts */
.alert { border-left: 5px solid var(--sev-unknown); background: var(--bg-sunken); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 10px; }
.alert.sev-extreme { border-color: var(--sev-extreme); }
.alert.sev-severe { border-color: var(--sev-severe); }
.alert.sev-moderate { border-color: var(--sev-moderate); }
.alert.sev-minor { border-color: var(--sev-minor); }
.alert summary { cursor: pointer; font-weight: 700; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.alert summary .meta { font-weight: 500; color: var(--text-muted); font-size: .84rem; }
.alert pre { white-space: pre-wrap; font-family: var(--font); font-size: .9rem; margin: 10px 0 0; }
.alert .instr { margin-top: 10px; padding: 8px 10px; background: var(--bg-elev); border-radius: var(--radius-sm); }
.alert-ok { color: var(--ok); font-weight: 600; }

/* gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.gallery.cols-2 { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
.gallery.cols-1 { grid-template-columns: 1fr; }
.gallery-item { background: var(--bg-sunken); border-radius: var(--radius-sm); overflow: hidden; }
.gallery-item img { display: block; width: 100%; height: auto; cursor: zoom-in; background: #fff; }
.gallery-item figcaption { padding: 7px 10px; font-size: .82rem; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.gallery-item figcaption a { font-size: .78rem; }
.gallery-item .img-fail { padding: 30px 10px; text-align: center; color: var(--text-muted); font-size: .85rem; }
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .88); display: flex; align-items: center; justify-content: center; padding: 20px; }
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; max-width: 100%; max-height: 100%; text-align: center; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 80px); object-fit: contain; background: #fff; }
.lightbox figcaption { color: #fff; margin-top: 8px; font-size: .9rem; }
.lightbox-close { position: absolute; top: 12px; right: 16px; background: none; border: 0; color: #fff; font-size: 2rem; cursor: pointer; }

/* text products */
.pre { white-space: pre-wrap; font-family: var(--mono); font-size: .8rem; line-height: 1.45; background: var(--bg-sunken); border-radius: var(--radius-sm); padding: 12px 14px; max-height: 560px; overflow: auto; margin: 0; }
.pre.tall { max-height: 900px; }
.product-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; font-size: .86rem; color: var(--text-muted); }

/* charts */
.chart-wrap { position: relative; height: 280px; }
.chart-wrap.tall { height: 360px; }
.chart-wrap.short { height: 200px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .8rem; color: var(--text-muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

/* map */
.map { width: 100%; height: 520px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: var(--bg-sunken); z-index: 0; }
.map-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; font-size: .84rem; color: var(--text-muted); }
.map-bar input[type="range"] { width: 160px; }
.leaflet-container { font: inherit; }
.leaflet-control-layers { border-radius: var(--radius-sm) !important; }
.leaflet-popup-content { font-size: .86rem; }
:root[data-theme="dark"] .leaflet-control-layers, :root[data-theme="dark"] .leaflet-bar a, :root[data-theme="dark"] .leaflet-popup-content-wrapper, :root[data-theme="dark"] .leaflet-popup-tip {
  background: var(--bg-elev); color: var(--text);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .leaflet-control-layers, :root:not([data-theme="light"]) .leaflet-bar a, :root:not([data-theme="light"]) .leaflet-popup-content-wrapper, :root:not([data-theme="light"]) .leaflet-popup-tip {
    background: var(--bg-elev); color: var(--text);
  }
}
.leaflet-control-attribution { font-size: .68rem !important; }

/* aqi / bars */
.bar { height: 10px; border-radius: 5px; background: var(--bg-sunken); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 5px; }
.aqi-scale { height: 10px; border-radius: 5px; background: linear-gradient(90deg, #00e400 0 16.6%, #ffff00 0 33.3%, #ff7e00 0 50%, #ff0000 0 66.6%, #8f3f97 0 83.3%, #7e0023 0); position: relative; margin: 8px 0 18px; }
.aqi-scale i { position: absolute; top: -4px; width: 4px; height: 18px; background: var(--text); border-radius: 2px; transform: translateX(-50%); }
.aqi-badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-weight: 700; color: #111; }

/* storms */
.storm { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; background: var(--bg-sunken); }
.storm-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.storm-head h3 { margin: 0; font-size: 1.2rem; }
.storm-cat { font-weight: 800; padding: 3px 10px; border-radius: 999px; color: #111; background: #ffd166; }
.storm-cat.hu { background: #ff6b6b; }
.storm-cat.mh { background: #c1121f; color: #fff; }
.storm-cat.td, .storm-cat.ptc, .storm-cat.po { background: #9ad1ff; }
.storm-links { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }

/* sun & moon */
.sun-arc { position: relative; height: 70px; margin: 6px 0; }
.sun-arc svg { width: 100%; height: 100%; }
.moon { width: 56px; height: 56px; border-radius: 50%; background: #d8dde6; position: relative; overflow: hidden; flex: none; box-shadow: inset -4px -4px 10px rgba(0,0,0,.15); }
.moon::after { content: ""; position: absolute; inset: 0; background: #2a2f3a; border-radius: 50%; }

/* footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 20px; }
.footer-inner { max-width: var(--maxw); margin: 0 auto; padding: 18px 16px 30px; font-size: .82rem; color: var(--text-muted); }

/* misc */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: .9rem; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 3px 0; }
.wind-arrow { display: inline-block; transition: transform .3s; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }
details.more summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .88rem; }
