/* dnssec.sh: dark-first terminal readout. one column, ruled sections,
   colored verdict word, fixed status line. */

:root {
  color-scheme: dark light;
  --fs-xs: 11px; --fs-s: 12px; --fs-m: 14px; --fs-l: 19px; --fs-xl: 24px; --lh: 1.5;
  --bg: #0c1013; --fg: #d9e0e5; --dim: #8b98a3;
  --line: #27313a; --accent: #45d6b2;
  --ok: #5cd68d; --bad: #ff7b72; --warn: #d9b357;
  --sl: #090d10;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f6f3; --fg: #1d2126; --dim: #525c66;
    --line: #d8dcd4; --accent: #0a6e5c;
    --ok: #076b3a;
    --bad: #b3261e; --warn: #7a5b00;
    --sl: #ececea;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* real bug fix: .alg author rules otherwise beat the UA hidden sheet, so replay rows hidden by renderSharedMatrix paint as empty lines */
html { font-family: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace; font-size: var(--fs-m); line-height: var(--lh); }
body { margin: 0 0 calc(3.5rem + env(safe-area-inset-bottom, 0px)); background: var(--bg); color: var(--fg); -webkit-text-size-adjust: 100%; }
/* dark only: a nearly subliminal crt scanline, static, no perf cost */
@media (prefers-color-scheme: dark) {
  body { background-image: repeating-linear-gradient(0deg, rgba(213,224,232,0.016) 0 1px, transparent 1px 3px); }
}
main { max-width: 46rem; margin: 0 auto; padding: 2rem 1.25rem 3.25rem; }
::selection { background: var(--accent); color: var(--bg); }
html { scrollbar-width: thin; scrollbar-color: var(--dim) transparent; }
a { color: var(--accent); text-decoration: underline; text-decoration-style: dotted; text-decoration-color: var(--dim); text-underline-offset: 0.22em; overflow-wrap: anywhere; }
a:hover { text-decoration-style: solid; text-decoration-color: var(--accent); }
h1 a { text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code { color: var(--fg); }
.dim, .hint { color: var(--dim); }

/* header */
.top { display: flex; justify-content: space-between; align-items: baseline; }
h1 { font-size: var(--fs-l); margin: 0; font-weight: 700; }
h1 .tld { color: var(--accent); }
.tagline { color: var(--dim); font-size: var(--fs-s); margin: 0.15rem 0 0; }

/* sections: ruled grammar */
section { margin-top: 2.25rem; border-top: 1px solid var(--line); padding-top: 1.1rem; }
#verdictwrap { border-top: none; margin-top: 1.25rem; padding-top: 0; }
h2 { font-size: var(--fs-s); font-weight: 500; letter-spacing: 0.08em; color: var(--dim); margin: 0 0 0.9rem; }
.sublabel { font-size: var(--fs-s); color: var(--dim); letter-spacing: 0.08em; margin: 1.1rem 0 0.4rem; }

/* verdict: colored word, no box. --warn lives here only, never on cells.
   the answer is the loudest thing on the page: question small, answer big */
.verdict { font-size: var(--fs-xl); font-weight: 700; margin: 0; color: var(--dim); }
/* reserve the room live data will claim: rows arriving at seconds 2-30
   otherwise shift the page under the reader (lighthouse CLS 0.4) */
.iplist { min-height: calc(1.5em + 0.5rem); }
#resolvers { min-height: calc(3 * 1.5em + 1.3rem); }
.verdict[data-state="validating"] { color: var(--ok); }
.verdict[data-state="partial"] { color: var(--warn); }
.verdict[data-state="not-validating"] { color: var(--bad); }
.verdict[data-state="checking"], .verdict[data-state="blocked"] { color: var(--dim); font-weight: 400; }
/* phosphor bloom on the verdict word, dark only, static */
@media (prefers-color-scheme: dark) {
  .verdict[data-state="validating"] { text-shadow: 0 0 16px rgba(92,214,141,0.28); }
  .verdict[data-state="partial"] { text-shadow: 0 0 16px rgba(217,179,87,0.28); }
  .verdict[data-state="not-validating"] { text-shadow: 0 0 16px rgba(255,123,114,0.28); }
}
#verdict-sub { margin: 0.25rem 0 0; font-size: var(--fs-s); min-height: 1em; }
#rerunwrap { margin: 0.45rem 0 0; font-size: var(--fs-s); }
#rerunwrap a { text-decoration-style: solid; }

/* replay banner: a left rule, the page stays box-free */
.replaynote { color: var(--fg); font-size: var(--fs-s); border-left: 2px solid var(--accent); padding: 0.25rem 0 0.25rem 0.75rem; margin: 1rem 0 0; }

/* dnssec matrix: one grid via display: contents so verdicts column-align */
.matrix { display: grid; grid-template-columns: minmax(8rem, 1fr) repeat(4, minmax(6rem, 1fr)); gap: 0.25rem 0.9rem; align-items: baseline; margin-top: 0.2rem; }
.mhdr, .alg { display: contents; }
.mhdr span { color: var(--dim); font-size: var(--fs-s); }
.mhdr em { display: block; font-style: normal; opacity: 0.85; font-size: var(--fs-xs); margin-top: 0.15rem; }
.algname { color: var(--dim); font-size: var(--fs-s); }
.matrix .mt b { font-weight: 700; color: var(--dim); display: inline-block; min-width: 9ch; }
.matrix .mt.pass b { color: var(--ok); }
.matrix .mt.fail b { color: var(--bad); }
.matrix .mt.blocked b { color: var(--dim); font-weight: 400; }
.matrix .mt.pass b::before { content: "\2713  "; }
.matrix .mt.fail b::before { content: "\2717  "; }
#matrixnote { margin-top: 0.6rem; }
#matrixprogress { margin-top: 0.5rem; }
@media (min-width: 801px) {
  .mt em { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}

/* resolver + ip rows: one aligned grid; the 1fr middle track pushes geo and
   toks toward the right edge so chips align down the rows */
.hdr, .row { display: grid; grid-template-columns: minmax(10.5rem, 13rem) minmax(4rem, 1fr) fit-content(20rem) max-content; column-gap: 1.1rem; align-items: baseline; padding: 0.22rem 0; }
.hdr { font-size: var(--fs-s); color: var(--dim); border-bottom: 1px solid var(--line); padding-bottom: 0.35rem; }
.row .ip { grid-column: 1; color: var(--accent); overflow-wrap: anywhere; }
.row .ptr { grid-column: 2; min-width: 0; color: var(--dim); overflow-wrap: anywhere; }
.row .geo { grid-column: 3; color: var(--dim); font-size: var(--fs-s); }
.row .toks { grid-column: 4; justify-self: end; }
.net { color: var(--fg); font-size: var(--fs-s); font-weight: 500; padding: 0.8rem 0 0.15rem; }
.net:first-child { padding-top: 0.1rem; }

/* chips: rare second-class signal, dim */
.toks { display: inline-flex; gap: 0.6rem; flex-wrap: wrap; }
.tok { color: var(--dim); white-space: nowrap; }

/* tls panel: pinned label column, one aligned table */
.tlsinfo { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 0.3rem 1rem; margin: 0; }
.tlsinfo dt { color: var(--dim); white-space: nowrap; }
.tlsinfo dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.tlsver { margin: 0.4rem 0 0; display: flex; gap: 1.25rem; }
.tlsver .feat { color: var(--dim); font-size: var(--fs-s); }
.tlsver .feat::before { content: "\2022"; margin-right: 0.35rem; color: var(--dim); }
.tlsver .feat[data-on="true"] { color: var(--ok); }
.tlsver .feat[data-on="true"]::before { color: var(--ok); }

/* share */
.shareline { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin: 0 0 0.4rem; }
#share { font-weight: 500; }
/* WCAG 2.5.8 target size: the control links get a 24px box on every
   pointer type (prose links in help keep their inline wrap) */
#share, #rerunwrap a, footer a, .top a { min-height: 24px; display: inline-flex; align-items: center; }
#copyshare { font: inherit; font-size: var(--fs-s); color: var(--fg); background: none; border: 1px solid var(--line); border-radius: 3px; padding: 0.25rem 0.7rem; cursor: pointer; }
#copyshare:hover { border-color: var(--accent); color: var(--accent); }
#copyshare:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* every interactive element earns a finger-sized target on touch; the
   copy button already had one, the links did not */
@media (pointer: coarse) {
  #copyshare { min-height: 44px; min-width: 64px; }
  #share, #rerunwrap a, footer a { min-height: 44px; display: inline-flex; align-items: center; }
}

/* footer */
footer { margin-top: 3rem; border-top: 1px solid var(--line); padding-top: 1.1rem; font-size: var(--fs-s); color: var(--dim); }
footer p { margin: 0.4rem 0; overflow-wrap: anywhere; }
#verify { margin: 0.35rem 0 0.6rem; overflow-x: auto; }
#verify code { display: block; font-size: var(--fs-m); color: var(--fg); cursor: pointer; min-height: 24px; }
#verify code::before { content: "$ "; color: var(--dim); }
#verify code.copied { color: var(--ok); }

/* status line */
#statusline { position: fixed; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 1.1rem; background: var(--sl); border-top: 1px solid var(--line); padding: 0.55rem 1.25rem calc(0.55rem + env(safe-area-inset-bottom, 0px)); font-size: var(--fs-s); }
.sl-lab { color: var(--dim); }
#statusline b { font-weight: 500; color: var(--fg); }
#statusline .feats { display: flex; gap: 1rem; }
#statusline .feat { color: var(--dim); }
#statusline .feat::before { content: "\2022"; margin-right: 0.35rem; color: var(--dim); }
#statusline .feat[data-on="true"] { color: var(--accent); }
#statusline .feat[data-on="true"]::before { color: var(--accent); }
#statusline .feat[data-k="dnssec"][data-on="true"] { color: var(--ok); }
#statusline .feat[data-k="dnssec"][data-on="true"]::before { color: var(--ok); }
#statusline .feat[data-k="dnssec"][data-on="false"] { color: var(--bad); }
#statusline .feat[data-k="dnssec"][data-on="false"]::before { color: var(--bad); }
#conn { margin-left: auto; color: var(--dim); }
#conn[data-state="closed"] { color: var(--bad); }
#conn[data-state="done"] { color: var(--ok); }
.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; }

/* 800, not 720: with fully populated rows (long geo + an ecs chip, both
   nowrap) the desktop grid still overflowed around 790px real width;
   stacking below 800 is cheaper than teaching the tracks to shed. the
   matrix fits 5 columns from 801px up (mins 8rem + 4 x 6rem + gaps) */
@media (max-width: 800px) {
  /* matrix: 2x2 per algorithm, per-cell labels visible, data stays 14px */
  .matrix { display: block; }
  .mhdr { display: none; }
  .alg { display: grid; grid-template-columns: 1fr 1fr; column-gap: 0.75rem; row-gap: 0.3rem; padding: 0.25rem 0; }
  .algname { grid-column: 1 / -1; }
  .mt b { min-width: 0; }
  /* label left, verdict word right: two clean columns per cell instead of a
     wrapped run-on */
  .mt { display: flex; justify-content: space-between; align-items: baseline; gap: 0.4rem; }
  .mt em { display: inline; font-style: normal; color: var(--dim); font-size: var(--fs-xs); }

  /* rows stack: ip + ptr side by side, geo and toks full width, indented
     under the pair they belong to. ip is fit-content capped at 12rem: a
     max-length v6 address as plain auto ate the whole row at ~420px and
     left the ptr track 54px wide, wrapping real hostnames mid-word */
  .hdr { display: none; }
  .row { grid-template-columns: fit-content(12rem) minmax(0, 1fr); gap: 0.1rem 0.75rem; }
  .row .ip { grid-column: 1; }
  .row .ptr { grid-column: 2; }
  .row .geo, .row .toks { grid-column: 1 / -1; padding-left: 0.75rem; }
  .row .toks { justify-self: start; }

  body { margin-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)); }
  #statusline { display: grid; grid-template-columns: auto auto 1fr; grid-template-areas: "count avg conn" "feats feats feats"; row-gap: 0.3rem; padding: 0.45rem 1rem calc(0.45rem + env(safe-area-inset-bottom, 0px)); }
  .sl-count { grid-area: count; }
  .sl-avg { grid-area: avg; }
  #statusline .feats { grid-area: feats; }
  #conn { grid-area: conn; text-align: right; margin-left: 0; }
}
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* print: the instrument becomes a transcript. the fixed status line and
   its lamps are screen furniture; the ruled sections and monospace tables
   already read as paper */
@media print {
  body { margin: 0; background: #fff; color: #000; }
  #statusline { display: none; }
  a { color: #000; text-decoration: none; }
  #share::after { content: " (" attr(href) ")"; }
  section, footer { break-inside: avoid; }
  .verdict { text-shadow: none; }
}
