/* Readout — the design system described in rtkt.dns/DESIGN.md.
 *
 * Token values are taken verbatim from that document's corrected palette, not
 * from rtkt.dns's shipped main.css: DESIGN.md records that the implemented
 * palette fails contrast (--dim 4.34:1, --green 4.26:1, .light 2.04:1).
 * The comment on each line is its measured ratio against that theme's ground.
 *
 * No webfont is loaded. --mono names JetBrains Mono first and falls through to
 * SF Mono / Menlo, which is what an Apple device renders anyway; a private
 * tools site should not round-trip to a font CDN to draw its own chrome.
 */

:root {
  color-scheme: light dark;

  /* Ground and ink */
  --bg:          #ebebeb;  /* the one background. Not white. */
  --bg-raised:   #f5f5f5;  /* callouts and table headers only */
  --fg:          #1c1c1c;  /* 14.30:1 — all primary text */
  --muted:       #5c5c5c;  /*  5.61:1 — labels, captions, secondary text */

  /* Rules. Hairlines are deliberately faint; grids that carry meaning are not. */
  --rule:        #c4c4c4;  /*  1.46:1 — section and chrome separators */
  --rule-strong: #878787;  /*  3.01:1 — data-table cell borders */

  /* State */
  --ok:          #15682e;  /*  5.77:1 */
  --warn:        #805400;  /*  5.53:1 */
  --bad:         #b53326;  /*  5.08:1 */

  /* Category */
  --info:        #0a58b0;  /*  5.80:1 — links, and one data category */
  --cat-a:       #7a3ea3;  /*  5.78:1 */
  --cat-b:       #4b4bbf;  /*  5.76:1 */

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo,
          Consolas, "Liberation Mono", monospace;
  --text: var(--mono);

  /* Space — four steps. Resist adding a fifth. */
  --s1: .25rem;
  --s2: .5rem;
  --s3: 1rem;
  --s4: 1.75rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #222222;
    --bg-raised:   #2a2a2a;
    --fg:          #e6e6e6;  /* 12.75:1 */
    --muted:       #949494;  /*  5.24:1 */
    --rule:        #444444;  /*  1.63:1 */
    --rule-strong: #6b6b6b;  /*  2.99:1 */
    --ok:          #4ec36f;  /*  7.09:1 */
    --warn:        #d59a2c;  /*  6.43:1 */
    --bad:         #f98d80;  /*  6.93:1 */
    --info:        #62aeff;  /*  6.83:1 */
    --cat-a:       #c08cf0;  /*  6.25:1 */
    --cat-b:       #8f9bff;  /*  6.29:1 */
  }
}

/* Repeated verbatim so an explicit toggle wins in both directions. */
:root[data-theme="dark"] {
  --bg:          #222222;
  --bg-raised:   #2a2a2a;
  --fg:          #e6e6e6;
  --muted:       #949494;
  --rule:        #444444;
  --rule-strong: #6b6b6b;
  --ok:          #4ec36f;
  --warn:        #d59a2c;
  --bad:         #f98d80;
  --info:        #62aeff;
  --cat-a:       #c08cf0;
  --cat-b:       #8f9bff;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */

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

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

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--text);
  font-size: .875rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

/* Visible focus, always. A square outline is entirely in keeping. */
:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 2px;
}

/* ── Chrome ─────────────────────────────────────────────────────────────── */

.head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;   /* never space-between */
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--rule);
}

.head .brand { font-weight: 700; }
.head .context { color: var(--muted); font-size: .8rem; letter-spacing: .02em; }
.head .tools { justify-self: end; display: flex; gap: var(--s2); align-items: center; }

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  padding: var(--s4) var(--s3);
  width: 100%;
  max-width: 100ch;
  margin: 0 auto;
}

.status {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s1) var(--s3);
  padding: var(--s2) var(--s3);
  border-top: 1px solid var(--rule);
  background: var(--bg);
  font-size: .8rem;
  color: var(--muted);
}

.status .spacer { flex: 1; }

/* ── Type ───────────────────────────────────────────────────────────────── */

h1, h2, h3 { font-size: 1rem; font-weight: 700; margin: 0; }

.label {
  font-size: .8rem;
  letter-spacing: .02em;
  color: var(--muted);
  margin-bottom: var(--s2);
}

.prose { max-width: 65ch; }

/* Identifiers, hashes, URLs, addresses. Never prose. */
.ident { word-break: break-all; }

/* ── Section ────────────────────────────────────────────────────────────── */

.section { display: flex; flex-direction: column; }

/* ── Aligned value list — the signature technique ───────────────────────── */

.rows { display: flex; flex-direction: column; }

.row {
  display: block;
  padding: var(--s1) 0;
  border-bottom: 1px solid var(--rule);
}
.row:first-child { border-top: 1px solid var(--rule); }

.row > span { display: inline-block; margin-right: 1ch; vertical-align: top; }

/* Applied only while the aligned layout still fits; main.js drops the class
 * when it no longer does, and the rows fall back to wrapping. */
.aligned .row > .c1 { min-width: var(--col-1); }
.aligned .row > .c2 { min-width: var(--col-2); }

.row .name { font-weight: 700; }
.row .note { color: var(--muted); }

a { color: var(--info); text-decoration: underline; }
/* Stays underlined on hover. Removing it is a bug. */
a:hover { text-decoration-thickness: 2px; }

/* ── Data table ─────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table {
  border-collapse: collapse;
  font-size: .875rem;
}
th, td {
  border: 1px solid var(--rule-strong);
  padding: var(--s1) var(--s2);
  text-align: left;
  vertical-align: top;
}
thead th {
  background: var(--bg-raised);
  color: var(--muted);
  font-size: .8rem;
  font-weight: 400;
  letter-spacing: .02em;
}
/* No zebra striping — the grid is the structure. */

/* ── Status chip ────────────────────────────────────────────────────────── */

/* Always carries a glyph as well as a hue: colour alone is not a signal. */
.chip { white-space: nowrap; }
.chip.ok   { color: var(--ok); }
.chip.warn { color: var(--warn); }
.chip.bad  { color: var(--bad); }

/* ── Callout ────────────────────────────────────────────────────────────── */

/* The one place a thick rule is allowed. At most one or two per page. */
.callout {
  background: var(--bg-raised);
  border-left: 3px solid var(--rule-strong);
  padding: var(--s2) var(--s3);
}
.callout.ok   { border-left-color: var(--ok); }
.callout.warn { border-left-color: var(--warn); }
.callout.bad  { border-left-color: var(--bad); }

/* ── Controls ───────────────────────────────────────────────────────────── */

button, .btn {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 0;
  padding: var(--s1) var(--s3);
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms, color 120ms;
}
button:hover, .btn:hover { background: var(--fg); color: var(--bg); }
button.bad, .btn.bad { color: var(--bad); }

/* A flat button that reads as a link but acts on this page. */
button.flat {
  border: 0;
  padding: 0;
  color: var(--info);
  text-decoration: underline;
}
button.flat:hover { background: transparent; color: var(--info); text-decoration-thickness: 2px; }

input, select {
  font: inherit;
  font-size: 1rem;          /* 1rem so iOS does not zoom on focus */
  color: inherit;
  background: transparent;
  border: 1px solid var(--rule-strong);
  border-radius: 0;
  padding: var(--s1) var(--s2);
}
input:focus-visible, select:focus-visible { border-color: var(--info); }

/* ── States ─────────────────────────────────────────────────────────────── */

/* De-emphasis is a token, never an opacity: opacity compounds against whatever
 * is behind it and silently drops text below legibility. */
.pending { color: var(--muted); }

.pending::after {
  content: "";
  animation: dots 1.2s steps(4, end) infinite;
}
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

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

/* ── Print ──────────────────────────────────────────────────────────────── */

@media print {
  .head .tools, .status { display: none; }
  body { background: #fff; color: #000; }
  a { color: #000; }
}

/* ── Category tags ──────────────────────────────────────────────────────── */

/* This project's taxonomy. Declared once, held to everywhere. Each tag carries
 * a word as well as a hue, so the meaning survives greyscale. */
.tag { color: var(--muted); }
.tag.service { color: var(--cat-a); }
.tag.admin   { color: var(--cat-b); }
.tag.site    { color: var(--info); }
.tag.code    { color: var(--muted); }
