/* Overpass dashboard styles (master plan §12).
   Colour tokens live in three authoritative theme blocks: :root (light),
   :root[data-theme="dark"], and :root[data-theme="contrast"]. web/contrast_test.go
   parses these blocks and fails any text pair under 4.5:1 or icon/large-text pair
   under 3:1. Accents are blue (pass) and orange (fail) — never red against green;
   status is always icon + text, and shapes differ per status. */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #eef1f5;
  --fg: #16191d;
  --muted: #464f59;
  --link: #0a58a8;
  --accent-pass: #1657c2;
  --accent-fail: #a34400;
  --border: #5b6673;
  --focus: #0a58a8;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1216;
  --surface: #191f26;
  --fg: #e8eef4;
  --muted: #a7b2bd;
  --link: #7cbcff;
  --accent-pass: #6fb2ff;
  --accent-fail: #f2a95c;
  --border: #7b8896;
  --focus: #7cbcff;
}

:root[data-theme="contrast"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #000000;
  --fg: #ffffff;
  --muted: #ffffff;
  --link: #ffff33;
  --accent-pass: #66ccff;
  --accent-fail: #ffaa33;
  --border: #ffffff;
  --focus: #ffff33;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  /* Words break at word boundaries everywhere. Only the raw-JSON <pre> opts
     into breaking anywhere; `anywhere` also shrinks min-content width, which is
     what collapsed table columns to one letter per line. */
  overflow-wrap: normal;
  word-break: normal;
}

/* Visible focus everywhere; never removed (§12). */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

a { color: var(--link); }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  overflow: hidden; white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -48px;
  background: var(--surface);
  color: var(--link);
  padding: 8px 12px;
  border: 2px solid var(--focus);
  border-radius: 6px;
  z-index: 10;
  transition: top 0.15s ease;
}
.skip-link:focus { top: calc(env(safe-area-inset-top, 0px) + 8px); }

.app-header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 20px 16px;
  border-bottom: 2px solid var(--border);
  background: var(--surface);
}
.app-header h1 { margin: 0; font-size: 1.6rem; }
.header-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.subtitle { margin: 4px 0 0; color: var(--muted); }

main { padding: 20px; max-width: 1100px; margin: 0 auto; }

section { margin: 0 0 32px; }
h2 { font-size: 1.25rem; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
h3 { font-size: 1.05rem; }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 12px 0;
}

button {
  font: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
}
button:hover { border-color: var(--focus); }
button[aria-pressed="true"] {
  background: var(--accent-pass);
  color: var(--bg);
  border-color: var(--accent-pass);
}

.field-error {
  color: var(--accent-fail);
  font-weight: 600;
}

.muted { color: var(--muted); }
.test-controls { border: 2px dashed var(--accent-fail); border-radius: 8px; padding: 10px 12px; }
.recorded-controls { border: 2px dashed var(--border); border-radius: 8px; padding: 10px 12px; }
.replay-banner {
  margin: 12px 0;
  padding: 10px 12px;
  border: 2px solid var(--accent-fail);
  border-radius: 8px;
  background: var(--surface);
  color: var(--fg);
  font-weight: 700;
}
.test-badge {
  font-weight: 700;
  color: var(--bg);
  background: var(--accent-fail);
  padding: 2px 8px;
  border-radius: 6px;
}

.active-pass {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 0;
}
.active-pass div { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.active-pass dt { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; }
.active-pass dd { margin: 4px 0 0; font-size: 1.1rem; font-weight: 600; min-width: 0; overflow-wrap: break-word; }
/* A full hostname is longer than the others; it wraps at its dots (<wbr>). */
.active-pass dd.host { font-size: 1rem; }
.countdown { font-variant-numeric: tabular-nums; }

.table-scroll {
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
}
/* Tables scroll inside their labelled container rather than squeezing columns;
   each sets the width below which scrolling begins. */
table { border-collapse: collapse; width: 100%; min-width: 0; }
.t-schedule { min-width: 640px; }
.t-agents { min-width: 0; }
.t-battery { min-width: 520px; }
td.nowrap, th.nowrap { white-space: nowrap; }
/* Headings never wrap, so a narrow column cannot fall to one letter per line. */
thead th { white-space: nowrap; }
/* Agents table: the hostname, role, uplink basis and DANE outcome stay on one
   line (the hostname is what a judge reads letter by letter). The verdict and
   the check chips are the columns that give: they wrap at word boundaries but
   keep a floor so they never crush. */
/* Six columns: slightly tighter type and padding so the whole table fits a
   1100px main without scrolling. min-width on a <td> is ignored by auto table
   layout, so the floors below sit on the cell CONTENT (the chips box, the
   verdict label), which does set the column's min-content width. */
.t-agents { font-size: 0.9rem; }
.t-agents th, .t-agents td { padding: 8px 10px; vertical-align: top; }
.t-agents td.host { white-space: nowrap; font-variant-ligatures: none; }
/* The recorded stamp sits under the hostname, not beside it, so the host
   column is only as wide as the longest name. */
.t-agents td.host .tag.recorded { display: block; width: max-content; margin: 4px 0 0; }
.t-agents td.verdict .status { white-space: nowrap; }
.t-agents td.verdict .reason { display: block; margin-top: 2px; }
.t-agents td.checks .chips { display: flex; flex-wrap: wrap; gap: 4px 6px; min-width: 12rem; }
caption { text-align: left; padding: 10px 12px; color: var(--muted); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
thead th { background: var(--surface); border-bottom: 2px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
.empty-row td { color: var(--muted); font-style: italic; }

/* Status = icon + text + colour. Shape differs per status (§12). */
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.status svg { flex: none; }
.status.ok { color: var(--accent-pass); }
.status.bad { color: var(--accent-fail); }
.status.warn { color: var(--accent-fail); }
.status.pending { color: var(--muted); }
.status .label { color: var(--fg); }

/* One chip per verification check: the name is always visible, so a softened
   check (card_hash: Warn) can never read as a bare pass. */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  white-space: nowrap;
}
.chip.pass { border-color: var(--accent-pass); }
.chip.warn, .chip.fail { border-color: var(--accent-fail); }
.chip .k { color: var(--muted); }
.tag.recorded {
  display: inline-block;
  padding: 1px 8px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

#event-log {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  max-height: 260px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
}
#event-log .log-line { padding: 3px 0; border-bottom: 1px solid var(--border); }
#event-log .log-line:last-child { border-bottom: 0; }

/* Session cuts and rejections only. Styled like the rest of the page: a card,
   not raw text pinned to the bottom of the document. */
#alert-region { margin: 0 0 16px; }
#alert-region:not(:empty) {
  padding: 12px 16px;
  background: var(--surface);
  border: 2px solid var(--accent-fail);
  border-radius: 8px;
  color: var(--fg);
  font-weight: 600;
}
#alert-region p { margin: 0 0 8px; }
#alert-region p:last-of-type { margin-bottom: 0; }
#alert-region .dismiss { margin-top: 10px; font-weight: 600; }

/* Connection state: one small pill in the header, announced once per change. */
.live-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  font-size: 0.9rem;
  white-space: nowrap;
}
.live-pill.ok { border-color: var(--accent-pass); }

/* GoDaddy's agent verdict card. Rows are icon + text + value; the raw JSON is
   collapsed and scrolls inside its own box so the page never grows sideways. */
.verify-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.verify-card h3 { margin: 0 0 10px; font-size: 1.05rem; overflow-wrap: break-word; }
.verify-rows { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 16px; margin: 0; }
.verify-rows div { min-width: 0; }
.verify-rows dt { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; }
.verify-rows dd { margin: 2px 0 0; overflow-wrap: break-word; }
.verify-card details { margin-top: 10px; }
.verify-card summary { cursor: pointer; }
.raw-scroll { overflow-x: auto; max-height: 40vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; margin-top: 8px; }
.raw-scroll:focus { outline: 2px solid var(--focus, currentColor); outline-offset: 2px; }
.raw-scroll pre { margin: 0; padding: 10px; font-size: 0.8rem; white-space: pre-wrap; overflow-wrap: anywhere; }
/* Nothing may push the page wider than the viewport (audited at 360px). */
html, body { max-width: 100%; overflow-x: hidden; }
main > section, .controls, .active-pass { min-width: 0; }
main > section > * { min-width: 0; }
/* break-word, not anywhere: a long token may break, but ordinary words and
   table headings keep their min-content width. */
#event-log .log-line, .field-error, #alert-region p { overflow-wrap: break-word; }

@media (max-width: 700px) {
  main { padding: 16px; }
  .app-header { padding-left: 16px; padding-right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
