/* ===========================================================
   WEATHER PROTOCOL — theme tokens
   Terminal aesthetic. Accent is swappable at runtime via
   <html data-accent="green|amber|cyan|ice|red">.
   =========================================================== */

:root {
  /* --- accent ramp (green default; overridden below) --- */
  --a:        #00ff41;
  --a-dim:    #00b82f;
  --a-deep:   #016b1c;
  --a-glow:   rgba(0, 255, 65, .45);
  --a-wash:   rgba(0, 255, 65, .08);
  --a-line:   rgba(0, 255, 65, .22);

  /* --- surfaces --- */
  --bg:       #05070a;
  --bg-2:     #080c11;
  --panel:    #0a0f15;
  --panel-2:  #0d141c;
  --raised:   #111a24;
  --line:     rgba(255, 255, 255, .07);
  --line-2:   rgba(255, 255, 255, .13);

  /* --- text --- */
  --fg:       #d6e3dd;
  --fg-2:     #8ba296;
  --fg-3:     #75847c;   /* 4.9:1 on panels — was 3.2:1, too faint for small text */
  --fg-hi:    #f2fff6;

  /* --- semantic --- */
  --ok:       #00ff41;
  --info:     #2fb6ff;
  --warn:     #ffb000;
  --danger:   #ff4d3d;
  --extreme:  #ff00d4;
  --cold:     #6fd3ff;
  --heat:     #ff7a2f;

  /* --- type --- */
  --mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", "SF Mono",
          "DejaVu Sans Mono", Consolas, "Courier New", monospace;
  /* --fs-scale comes from Settings -> Text size (1 = 100%) */
  --fs-scale: 1;
  --fs-micro: calc(11px * var(--fs-scale));
  --fs-xs:    calc(12px * var(--fs-scale));
  --fs-sm:    calc(13px * var(--fs-scale));
  --fs-md:    calc(14px * var(--fs-scale));
  --fs-lg:    calc(18px * var(--fs-scale));
  --fs-xl:    calc(26px * var(--fs-scale));
  --fs-2xl:   calc(40px * var(--fs-scale));
  --fs-3xl:   calc(64px * var(--fs-scale));

  /* --- geometry --- */
  --r:        3px;
  --gap:      14px;
  --rail:     60px;   /* left nav rail width */
  --head:     46px;   /* top status bar height */

  --shadow:   0 8px 30px rgba(0, 0, 0, .6);
  --speed:    .18s;
}

:root[data-accent="amber"] {
  --a: #ffb000; --a-dim: #c98600; --a-deep: #6e4a00;
  --a-glow: rgba(255,176,0,.45); --a-wash: rgba(255,176,0,.08); --a-line: rgba(255,176,0,.22);
  --fg: #e6ddcb; --fg-2: #aa9c86; --fg-3: #888074; --fg-hi: #fff6e4; --ok: #ffb000;
}
:root[data-accent="cyan"] {
  --a: #00e5ff; --a-dim: #00a7bb; --a-deep: #015e6b;
  --a-glow: rgba(0,229,255,.45); --a-wash: rgba(0,229,255,.08); --a-line: rgba(0,229,255,.22);
  --fg: #cfe7ec; --fg-2: #85a2a9; --fg-3: #758386; --fg-hi: #eafcff; --ok: #00e5ff;
}
:root[data-accent="ice"] {
  --a: #b8d4ff; --a-dim: #7fa4d8; --a-deep: #3b5476;
  --a-glow: rgba(184,212,255,.4); --a-wash: rgba(184,212,255,.07); --a-line: rgba(184,212,255,.2);
  --fg: #dbe5f2; --fg-2: #93a2b8; --fg-3: #77818f; --fg-hi: #f4f8ff; --ok: #b8d4ff;
}
:root[data-accent="red"] {
  --a: #ff3b30; --a-dim: #c22a21; --a-deep: #6b100b;
  --a-glow: rgba(255,59,48,.45); --a-wash: rgba(255,59,48,.08); --a-line: rgba(255,59,48,.22);
  --fg: #efd8d6; --fg-2: #b39693; --fg-3: #8d7e7c; --fg-hi: #fff0ee; --ok: #ff3b30;
}

/* Light substrate — daytime / glare / accessibility. Keeps the accent. */
:root[data-surface="light"] {
  --bg: #eef2ef; --bg-2: #e4eae6; --panel: #ffffff; --panel-2: #f5f8f6; --raised: #e9eeeb;
  --line: rgba(0,0,0,.1); --line-2: rgba(0,0,0,.18);
  --fg: #12201a; --fg-2: #4a5b52; --fg-3: #69756f; --fg-hi: #000;
  --a-dim: #067a22; --a-wash: rgba(0,160,40,.09); --a-line: rgba(0,140,35,.3);
}

/* ---- motion preference ---------------------------------- */
:root[data-motion="off"] *,
:root[data-motion="off"] *::before,
:root[data-motion="off"] *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
}
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="on"]) *,
  :root:not([data-motion="on"]) *::before,
  :root:not([data-motion="on"]) *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ===========================================================
   base
   =========================================================== */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: var(--fs-md);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body { overflow: hidden; }

::selection { background: var(--a); color: #000; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--a-deep) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--a-deep); border-radius: 9px; }
*::-webkit-scrollbar-thumb:hover { background: var(--a-dim); }

/* ===========================================================
   primitives
   =========================================================== */

.mono-label {
  font-size: var(--fs-micro);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--fg-3);
  font-weight: 500;
}

.glow { text-shadow: 0 0 10px var(--a-glow); }

/* Panel: workhorse container with hairline corner brackets */
.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--gap);
}
.panel::before, .panel::after {
  content: "";
  position: absolute;
  width: 9px; height: 9px;
  border: 1px solid var(--a-line);
  pointer-events: none;
}
.panel::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.panel::after  { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

.panel-title {
  margin: 0 0 10px;
  font-size: var(--fs-micro);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--a);
  font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.panel-title::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, var(--a-line), transparent);
}

/* Buttons */
.btn {
  appearance: none;
  font: inherit;
  font-size: var(--fs-xs);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--fg-2);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  padding: 7px 12px;
  cursor: pointer;
  transition: color var(--speed), border-color var(--speed), background var(--speed);
  white-space: nowrap;
}
.btn:hover { color: var(--a); border-color: var(--a-line); background: var(--a-wash); }
.btn:focus-visible { outline: 1px solid var(--a); outline-offset: 2px; }
.btn[aria-pressed="true"], .btn.on {
  color: #000; background: var(--a); border-color: var(--a);
  text-shadow: none; font-weight: 600;
}
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger:hover { color: var(--danger); border-color: var(--danger); background: rgba(255,77,61,.08); }
.btn-sm { padding: 4px 8px; font-size: var(--fs-micro); }

/* Inputs */
.input, select.input, textarea.input {
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--fg);
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  padding: 8px 10px;
  width: 100%;
}
.input:focus { outline: none; border-color: var(--a); box-shadow: 0 0 0 1px var(--a-line); }
.input::placeholder { color: var(--fg-3); }

/* Chips / severity tags */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-micro); letter-spacing: .1em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--a-line); color: var(--a); background: var(--a-wash);
}
.chip[data-sev="Extreme"]  { color: var(--extreme); border-color: var(--extreme); background: rgba(255,0,212,.1); }
.chip[data-sev="Severe"]   { color: var(--danger);  border-color: var(--danger);  background: rgba(255,77,61,.1); }
.chip[data-sev="Moderate"] { color: var(--warn);    border-color: var(--warn);    background: rgba(255,176,0,.1); }
.chip[data-sev="Minor"]    { color: var(--info);    border-color: var(--info);    background: rgba(47,182,255,.1); }

/* Status dot */
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--fg-3); flex: none; }
.dot.live { background: var(--ok); box-shadow: 0 0 6px var(--a-glow); animation: pulse 2.4s ease-in-out infinite; }
.dot.warn { background: var(--warn); }
.dot.dead { background: var(--danger); }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .35 } }

/* Numeric readouts */
.readout { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* Utility */
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.spread { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.center { align-items: center; justify-content: center; }
.hidden { display: none !important; }
.scroll-y { overflow-y: auto; overflow-x: hidden; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* CRT scanline veil — decorative, toggleable in Settings */
.crt::after {
  content: "";
  position: fixed; inset: 0; z-index: 9000; pointer-events: none;
  background: repeating-linear-gradient(
    180deg, rgba(0,0,0,0) 0px, rgba(0,0,0,0) 2px, rgba(0,0,0,.17) 3px);
  opacity: .55;
}
:root[data-scanlines="off"] .crt::after { display: none; }

/* Scroll smoothness: the scanline veil sits on its own GPU layer so it is
   painted once, not every scroll frame; panels isolate their layout so a
   change inside one (clock tick, live dot) never re-lays-out the page. */
.crt::after { will-change: transform; transform: translateZ(0); }
.panel { contain: layout style; }
