/* EHS Weather Watch — STULZ
   Industrial / safety-utility styling. Slate structure + safety amber. */

:root {
  /* Surfaces */
  --bg: #0b1220;          /* deep slate background */
  --surface: #111a2c;
  --surface-2: #16223a;
  --surface-3: #1d2c48;
  --border: #243551;
  --border-strong: #2f4773;

  /* Text */
  --text: #e6ecf6;
  --text-muted: #9aa8c1;
  --text-faint: #6b7a96;

  /* Brand / accents */
  --teal: #2dd4bf;
  --teal-700: #0f766e;

  /* Safety palette */
  --amber: #f59e0b;
  --amber-700: #b45309;
  --orange: #ea580c;
  --red: #dc2626;
  --green: #16a34a;
  --blue: #3b82f6;

  /* Status */
  --status-not-bg: rgba(34, 197, 94, .12);
  --status-not-fg: #4ade80;
  --status-not-bd: rgba(74, 222, 128, .35);

  --status-monitor-bg: rgba(245, 158, 11, .12);
  --status-monitor-fg: #fbbf24;
  --status-monitor-bd: rgba(251, 191, 36, .4);

  --status-effect-bg: rgba(234, 88, 12, .14);
  --status-effect-fg: #fb923c;
  --status-effect-bd: rgba(251, 146, 60, .45);

  --status-high-bg: rgba(220, 38, 38, .16);
  --status-high-fg: #f87171;
  --status-high-bd: rgba(248, 113, 113, .55);

  --shadow-md: 0 6px 24px -10px rgba(0,0,0,.5);
  --shadow-lg: 0 12px 32px -14px rgba(0,0,0,.55);
  --radius: 12px;
  --radius-sm: 8px;

  font-family: 'Satoshi', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-feature-settings: "ss01", "cv11";
}

body.theme-light {
  /* Surfaces */
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e8eef7;
  --border: #cbd5e1;
  --border-strong: #94a3b8;

  /* Text */
  --text: #111827;
  --text-muted: #475569;
  --text-faint: #64748b;

  /* Brand / accents */
  --teal: #0f766e;
  --teal-700: #115e59;

  /* Status */
  --status-not-bg: rgba(22, 163, 74, .10);
  --status-not-fg: #166534;
  --status-not-bd: rgba(22, 101, 52, .24);

  --status-monitor-bg: rgba(245, 158, 11, .15);
  --status-monitor-fg: #92400e;
  --status-monitor-bd: rgba(180, 83, 9, .32);

  --status-effect-bg: rgba(234, 88, 12, .13);
  --status-effect-fg: #9a3412;
  --status-effect-bd: rgba(194, 65, 12, .30);

  --status-high-bg: rgba(220, 38, 38, .12);
  --status-high-fg: #991b1b;
  --status-high-bd: rgba(185, 28, 28, .32);

  --shadow-md: 0 8px 24px -18px rgba(15, 23, 42, .35);
  --shadow-lg: 0 16px 36px -24px rgba(15, 23, 42, .40);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 100% -200px, rgba(245, 158, 11, .08), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(45, 212, 191, .06), transparent 60%),
    var(--bg);
}

body.theme-light {
  background:
    radial-gradient(1100px 540px at 100% -180px, rgba(245, 158, 11, .11), transparent 58%),
    radial-gradient(850px 480px at -10% 0%, rgba(15, 118, 110, .08), transparent 58%),
    var(--bg);
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute; left: -9999px;
  background: var(--surface); color: var(--text);
  padding: 8px 12px; border-radius: 6px;
}
.skip-link:focus { left: 12px; top: 12px; z-index: 100; }

/* ── Top bar ────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.02), transparent);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(8px);
}

body.theme-light .topbar {
  background: rgba(255,255,255,.86);
  box-shadow: 0 1px 0 rgba(15, 23, 42, .04);
}

.brand { display: flex; align-items: center; gap: 14px; color: var(--amber); }
.stulz-logo {
  display: block;
  width: auto; height: 36px;
  border-radius: 4px;
  background: #fff; /* logo has white border on red — keep it crisp on dark bg */
  padding: 2px 4px;
  box-shadow: 0 1px 0 rgba(255,255,255,.04), 0 0 0 1px rgba(255,255,255,.04) inset;
}
.brand-divider {
  width: 1px; height: 28px; background: var(--border);
}
@media print { .stulz-logo { background: transparent; box-shadow: none; padding: 0; } .brand-divider { background: #cbd5e1; } }
.brand-text { color: var(--text); }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--text-muted); letter-spacing: .04em; text-transform: uppercase; }

.topbar-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.meta {
  font-size: 12px; color: var(--text-muted);
  display: grid; gap: 2px;
  border-right: 1px solid var(--border);
  padding-right: 14px; margin-right: 4px;
}
.meta-row { display: flex; gap: 8px; align-items: center; }
.meta-label { color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; font-size: 11px; }
.meta-value { color: var(--text); font-feature-settings: "tnum"; font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 999px; background: var(--green); margin-right: 6px; box-shadow: 0 0 0 3px rgba(22,163,74,.18); }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; font-size: 13px;
  cursor: pointer; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  transition: background .15s ease, transform .1s ease, border-color .15s ease;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.btn-ghost { background: transparent; }
.btn-primary { background: var(--amber); color: #1a1304; border-color: transparent; }
.btn-primary:hover { background: #fbbf24; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
body.theme-light .btn-ghost { background: #ffffff; }
body.theme-light .btn-ghost:hover { background: #f8fafc; }

/* ── Main layout ────────────────────────────────────────── */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px 28px 28px;
  display: grid;
  gap: 18px;
}

/* ── Banner ─────────────────────────────────────────────── */
.banner {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  padding: 18px 20px;
  box-shadow: var(--shadow-md);
}

body.theme-light .banner {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}
.banner-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}
@media (max-width: 900px) {
  .banner-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .banner-grid { grid-template-columns: 1fr; }
}
.banner-cell { display: grid; gap: 4px; }
.banner-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); }
.banner-value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.banner-sub { font-size: 12px; color: var(--text-muted); }
.banner-action { color: var(--amber); font-size: 18px; line-height: 1.3; }
.banner-cell + .banner-cell { border-left: 1px solid var(--border); padding-left: 22px; }
@media (max-width: 900px) { .banner-cell + .banner-cell { border-left: none; padding-left: 0; } }

.banner.is-high { border-color: var(--status-high-bd); background: linear-gradient(180deg, rgba(220,38,38,.08), var(--surface)); }
.banner.is-effect { border-color: var(--status-effect-bd); }
.banner.is-monitor { border-color: var(--status-monitor-bd); }

/* ── Legend ─────────────────────────────────────────────── */
.legend {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px 18px;
}
.legend-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); margin-bottom: 10px; }
.legend-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
@media (max-width: 1000px) { .legend-list { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .legend-list { grid-template-columns: 1fr; } }
.legend-list li { display: grid; gap: 6px; font-size: 13px; color: var(--text-muted); }

/* ── Pills ──────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  border-radius: 999px;
  border: 1px solid;
  width: max-content;
}
.pill-not { color: var(--status-not-fg); background: var(--status-not-bg); border-color: var(--status-not-bd); }
.pill-monitor { color: var(--status-monitor-fg); background: var(--status-monitor-bg); border-color: var(--status-monitor-bd); }
.pill-effect { color: var(--status-effect-fg); background: var(--status-effect-bg); border-color: var(--status-effect-bd); }
.pill-high { color: var(--status-high-fg); background: var(--status-high-bg); border-color: var(--status-high-bd); }

/* ── Location cards ─────────────────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
@media (max-width: 1100px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) { .cards { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: grid; gap: 10px;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-md);
}
.card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px; background: var(--border-strong);
}
.card.is-not::before { background: var(--status-not-fg); }
.card.is-monitor::before { background: var(--status-monitor-fg); }
.card.is-effect::before { background: var(--status-effect-fg); }
.card.is-high::before { background: var(--status-high-fg); }

.card-head {
  display: flex; justify-content: space-between; gap: 16px; align-items: flex-start;
}
.card-name { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.card-addr { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.card-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
}
@media (max-width: 460px) { .card-row { grid-template-columns: repeat(2, 1fr); } }

.metric { display: grid; gap: 2px; padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.metric-label { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); }
.metric-value { font-size: 18px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.metric-value small { font-size: 11px; color: var(--text-muted); font-weight: 500; margin-left: 2px; }
.metric-value.temp-pair { white-space: nowrap; font-size: 17px; }
.metric-note { font-size: 10px; line-height: 1.25; color: var(--text-muted); margin-top: 2px; }
.metric.heat .metric-value { color: var(--amber); }

.forecast-summary {
  font-size: 13px; line-height: 1.5; color: var(--text);
  background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.forecast-summary strong { color: var(--text); font-weight: 700; }
.forecast-summary .label { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); display: block; margin-bottom: 4px; }
.forecast-detail {
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 12px;
}
.forecast-detail summary {
  cursor: pointer;
  color: var(--teal);
  font-weight: 600;
}
.forecast-detail summary:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  border-radius: 4px;
}
.forecast-detail div {
  margin-top: 6px;
}

.alerts { display: grid; gap: 8px; }
.alert {
  border: 1px solid var(--status-high-bd);
  background: var(--status-high-bg);
  color: var(--text);
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 12px; line-height: 1.4;
}
.alert-title { font-weight: 700; color: var(--status-high-fg); margin-bottom: 2px; }

.actions {
  border-top: 1px dashed var(--border);
  padding-top: 12px;
  display: grid; gap: 6px;
}
.actions-title { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); }
.actions ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text); }
.actions li { margin-bottom: 3px; }

/* loading skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.sk-line { height: 14px; margin: 8px 0; }
.sk-line.sm { height: 10px; width: 60%; }
.sk-line.lg { height: 22px; width: 40%; }

/* error state */
.card.is-error { border-color: var(--status-high-bd); }
.error-msg {
  font-size: 13px; color: var(--status-high-fg);
  background: var(--status-high-bg); padding: 10px 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--status-high-bd);
}

/* ── Sources & footer ───────────────────────────────────── */
.sources {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 22px;
  font-size: 13px; color: var(--text-muted);
}
.sources h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--text); margin: 0 0 8px; }
.sources p { margin: 6px 0; }
.sources-list { font-size: 12px; }
.disclaimer { color: var(--text-faint); font-size: 12px; font-style: italic; }

.footer {
  border-top: 1px solid var(--border);
  padding: 18px 28px;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
}
.footer-sep { margin: 0 8px; }

/* ── Print / Save-as-PDF look ───────────────────────────── */
@media print {
  :root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --border: #cbd5e1;
    --border-strong: #94a3b8;
    --text: #0f172a;
    --text-muted: #475569;
    --text-faint: #64748b;
    --status-not-fg: #166534;
    --status-monitor-fg: #b45309;
    --status-effect-fg: #c2410c;
    --status-high-fg: #b91c1c;
  }
  body { background: #fff !important; }
  .topbar { position: static; border-bottom: 2px solid #0f172a; }
  .topbar-actions .btn { display: none; }
  .topbar-actions .meta { border-right: none; }
  main { padding: 16px 0; max-width: none; }
  .cards { grid-template-columns: 1fr 1fr !important; gap: 12px; }
  .banner { box-shadow: none; }
  .card { box-shadow: none; break-inside: avoid; page-break-inside: avoid; }
  .legend { break-inside: avoid; }
  .sources { break-inside: avoid; font-size: 11px; }
  .footer { border-top: 1px solid #cbd5e1; }
  a { color: #0f172a; text-decoration: underline; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}
