/* freeseek status dashboard — dark default, light via light-dark() */

:root {
  color-scheme: light dark;
  --bg: light-dark(#fbfaf7, #000000);
  --surface: light-dark(#f2f1ec, #0d0d0d);
  --surface-2: light-dark(#e8e7e0, #141414);
  --line: light-dark(#d4d1c7, #262626);
  --text: light-dark(#17171a, #e8e8e8);
  --muted: light-dark(#5a5a60, #9a9a9a);
  --cyan: light-dark(#0a6e85, #00c2e9);
  --pink: light-dark(#bd0e60, #e41478);
  --purple: light-dark(#7a12b8, #bf00ff);
  --yellow: light-dark(#7a5200, #ffd53d);
  --strong: light-dark(#000000, #ffffff);
  --dur-fast: 140ms;
  --dur-slow: 320ms;
  --ease: cubic-bezier(0.25, 0, 0.2, 1);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

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

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 2px;
}

code {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--mono);
  font-size: 0.92em;
}

h1, h2, h3 { color: var(--strong); line-height: 1.25; }
h2 { font-size: 18px; margin: 0 0 4px; }
h3 { font-size: 13px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: 0.08em; }

/* ---------- masthead ---------- */

.masthead { border-bottom: 1px solid var(--line); background: var(--bg); }
.masthead-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 12px;
  padding-bottom: 12px;
  flex-wrap: wrap;
}
.wordmark {
  font-size: 18px;
  font-weight: 700;
  color: var(--strong);
  letter-spacing: 0.02em;
}
.wordmark span { color: var(--cyan); }
.wordmark:hover { text-decoration: none; }

.mastnav { margin-left: auto; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.mastnav a { color: var(--muted); font-size: 13px; }
.mastnav a:hover { color: var(--text); }

#theme-toggle {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1;
  padding: 5px 8px;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease);
}
#theme-toggle:hover { border-color: var(--cyan); }

/* state pill */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 2px 11px;
  font-size: 12px;
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.pill.st-ok { color: var(--cyan); }
.pill.st-busy { color: var(--yellow); }
.pill.st-warn { color: var(--pink); }
.pill.st-off { color: var(--muted); }
.pill.st-ok::before { animation: pulse 2.4s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- hero ---------- */

.hero { padding: 40px 0 8px; }
.hero h1 { font-size: clamp(24px, 5vw, 36px); margin: 0 0 10px; }
.hero-sub { max-width: 62ch; margin: 0 0 18px; color: var(--muted); }
.hero-sub strong { color: var(--text); }
.hero-note { color: var(--muted); font-size: 13px; max-width: 70ch; }

.codeblock {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  max-width: 720px;
}
.codeblock pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.7;
}
.codeblock code { background: none; border: 0; padding: 0; }
#copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
#copy-btn:hover { color: var(--cyan); border-color: var(--cyan); }

/* ---------- dashboard ---------- */

#dash { padding: 26px 0 6px; }
.dash-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.detail { margin: 0; color: var(--muted); font-size: 13px; }

.offline {
  border: 1px solid var(--pink);
  color: var(--pink);
  border-radius: 6px;
  padding: 10px 14px;
  margin: 0 0 14px;
  font-size: 13px;
}

#dash.stale .tile-v,
#dash.stale .gauge-fill,
#dash.stale .bar { opacity: 0.5; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px 18px;
  margin-bottom: 14px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.tile-v {
  font-size: 22px;
  font-weight: 700;
  color: var(--strong);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile-l { font-size: 11px; color: var(--muted); letter-spacing: 0.04em; }

/* chart */
.chart { padding: 14px 18px 10px; }
.chart-cap {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  flex-wrap: wrap;
}
#spark-readout { color: var(--cyan); font-variant-numeric: tabular-nums; }
#spark {
  display: block;
  width: 100%;
  height: 150px;
  color: var(--cyan);       /* line + fill colour, read by app.js */
  border-color: var(--muted); /* axis/grid colour, read by app.js */
  touch-action: pan-y;
}
.chart-x {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* two-column card rows */
.cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.cols .card { margin-bottom: 0; }

/* gauges */
.gauge { margin-bottom: 14px; }
.gauge-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 6px;
}
.gauge-top span:last-child {
  color: var(--strong);
  font-variant-numeric: tabular-nums;
}
.gauge-track {
  height: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.gauge-fill {
  height: 100%;
  width: 0;
  background: var(--cyan);
  border-radius: 999px;
  transition: width var(--dur-slow) var(--ease), background-color var(--dur-slow) var(--ease);
}
.gauge-fill.warn { background: var(--yellow); }
.gauge-fill.crit { background: var(--pink); }

.fineprint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

/* tables */
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
caption { text-align: left; color: var(--muted); font-size: 12px; padding-bottom: 8px; }
th, td { text-align: right; padding: 5px 8px; font-size: 13px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 400; }
thead th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
tbody th, td:first-child, th:first-child { text-align: left; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
.totals td { color: var(--strong); }
.subjects td:first-child { color: var(--muted); }

/* bar lists (endpoints, countries) */
.barlist { list-style: none; margin: 0; padding: 0; }
.barlist li {
  display: grid;
  grid-template-columns: minmax(72px, auto) 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  font-size: 13px;
}
.barlist .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist .bar {
  height: 8px;
  background: var(--cyan);
  border-radius: 4px;
  min-width: 2px;
  transition: width var(--dur-slow) var(--ease);
}
.barlist .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.barlist .empty, .subjects .empty { color: var(--muted); }

/* key pool + system */
.keypool { margin: 0; color: var(--strong); }
.sysline { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.sysline li { color: var(--muted); font-size: 13px; }
.sysline span { color: var(--text); }

/* ---------- how it works ---------- */

.how { padding: 26px 0 10px; border-top: 1px solid var(--line); }
.how h2 { margin-bottom: 14px; }
.how h3 { margin-top: 20px; }
.steps { margin: 0; padding-left: 22px; max-width: 72ch; }
.steps li { margin-bottom: 10px; }
.steps strong { color: var(--cyan); }
.limits { list-style: none; margin: 0; padding: 0; display: flex; gap: 10px; flex-wrap: wrap; }
.limits li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
}
.limits span { color: var(--strong); font-weight: 700; }

/* ---------- footer ---------- */

.footer {
  border-top: 1px solid var(--line);
  margin-top: 30px;
  padding: 20px 0 30px;
  font-size: 13px;
  color: var(--muted);
}
.footer nav { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.footer p { margin: 0; max-width: 70ch; }

/* ---------- prose pages ---------- */

/* The dashboard is an instrument panel; privacy, terms, story and vision
 * are long-form reading, and the two want different rhythm. They share
 * the masthead and footer, so the rules here only add what reading needs:
 * a measure, vertical rhythm, and a slightly taller line.
 *
 * These pages carry no .wrap element — they are a masthead, a <main> and
 * a footer — so the horizontal padding lives on those three directly.
 * They are marked with class="doc" on <body> rather than detected with
 * :has(), so the selector says what it means and works everywhere. */

.doc .masthead {
  display: flex;
  align-items: baseline;
  gap: 20px;
  flex-wrap: wrap;
  max-width: 820px;
  margin: 0 auto;
  padding: 16px 20px;
}
.doc .masthead nav {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-left: auto;
}
.doc .masthead nav a { color: var(--muted); font-size: 13px; }
.doc .masthead nav a:hover { color: var(--text); }

.prose {
  max-width: 74ch;
  margin: 0 auto;
  padding: 28px 20px 8px;
  /* Prose is read, not scanned. A little more leading than the dashboard
   * uses, which is tuned for numbers in tiles. */
  line-height: 1.7;
}

.prose h1 { font-size: clamp(24px, 5vw, 32px); margin: 0 0 16px; }
.prose h2 {
  font-size: 17px;
  margin: 32px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.prose h3 {
  font-size: 13px;
  margin: 22px 0 8px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--strong);
}
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { margin: 0 0 14px; padding-left: 1.4em; }
.prose li { margin: 0 0 6px; }
.prose li::marker { color: var(--muted); }
.prose dt { color: var(--strong); margin-top: 12px; }
.prose dd { margin: 0 0 10px; padding-left: 1.4em; color: var(--muted); }
.prose table { margin: 0 0 18px; }
.prose a { text-decoration: underline; text-underline-offset: 2px; }

/* The opening paragraph, set larger so the page states its purpose
 * before anyone decides whether to read the rest. */
.prose .lede {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 22px;
}

/* Dates, provenance, asides. Quiet by construction. */
.prose .note {
  color: var(--muted);
  font-size: 12px;
}

/* The one voice that has to interrupt: what a reader must not assume.
 * A left rule rather than a filled box — a full alert panel in the
 * middle of a legal page reads as decoration and gets skipped. */
.prose .warn {
  border-left: 2px solid var(--pink);
  padding: 2px 0 2px 14px;
  margin: 0 0 16px;
  color: var(--text);
}

.doc .footer { max-width: 820px; margin: 30px auto 0; padding-left: 20px; padding-right: 20px; }

/* ---------- responsive ---------- */

@media (max-width: 920px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 680px) {
  .cols { grid-template-columns: 1fr; }
  .hero { padding-top: 28px; }
  th, td { padding: 5px 6px; }
  /* keep the copy button clear of the first code line */
  .codeblock pre { padding-top: 42px; }
}
@media (max-width: 440px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile-v { font-size: 19px; }
  .wrap { padding: 0 14px; }
}
@media (min-width: 1800px) {
  body { font-size: 15px; }
  .wrap { max-width: 1320px; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
