/*
 * Colour roles follow the data-viz reference palette. Status colours are fixed
 * and never themed, and never carry meaning alone -- every badge pairs its
 * colour with a glyph and a word.
 *
 * Dark values are declared under two scopes on purpose: the media query covers
 * the OS setting, the [data-theme] scope covers the explicit toggle, and the
 * toggle has to win both ways.
 */

:root {
  color-scheme: light;

  --page:            #f9f9f7;
  --surface:         #fcfcfb;
  --text-primary:    #0b0b0b;
  --text-secondary:  #52514e;
  --text-muted:      #898781;
  --rule:            #e1e0d9;

  /* status palette -- fixed, not themed */
  --status-good:     #0ca30c;
  --status-critical: #d03b3b;
  --status-warning:  #fab219;

  --accent:          #2a78d6;

  --radius: 4px;
  --measure: 68ch;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page:           #0d0d0d;
    --surface:        #1a1a19;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --rule:           #2c2c2a;
    --accent:         #3987e5;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page:           #0d0d0d;
  --surface:        #1a1a19;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --rule:           #2c2c2a;
  --accent:         #3987e5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 16px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

p, li { max-width: var(--measure); }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 2rem; margin: 0.2em 0 0.4em; }
h2 { font-size: 1.35rem; margin: 2.5rem 0 0.75rem; }
h3 { font-size: 1rem; margin: 1.75rem 0 0.5rem; }

.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
  padding: 2.5rem 0 2rem;
}
.eyebrow {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.lede { font-size: 1.075rem; color: var(--text-secondary); }

main { padding-bottom: 4rem; }
section { margin-bottom: 3rem; }

.muted { color: var(--text-muted); }
.footnote { font-size: 0.875rem; color: var(--text-muted); }

/* --- KPI row ------------------------------------------------------------ */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 1.25rem 0;
}
.stat { background: var(--surface); padding: 1rem 1.15rem; }
.stat-label {
  margin: 0 0 0.25rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.stat-value {
  margin: 0;
  font-size: 1.75rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

/* --- search ------------------------------------------------------------- */

.search { margin: 1.5rem 0 0.5rem; }
.search-label {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.search-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.search-row input {
  flex: 1 1 22rem;
  min-width: 0;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.9375rem;
}
.search-row input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.search-hint {
  margin: 0.45rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.search-hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}
.ghost.inline { margin-top: 0; }

/* --- table -------------------------------------------------------------- */

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

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-size: 0.9375rem;
}
th, td {
  text-align: left;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
th {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}
tbody tr:last-child td { border-bottom: 0; }
td.name { font-weight: 600; white-space: normal; }
td.version, td.arch, td.when { font-variant-numeric: tabular-nums; color: var(--text-secondary); }
td.when { font-size: 0.875rem; }

/* Status: colour is never the only channel -- glyph + word carry it. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.8125rem;
  font-weight: 600;
}
.badge::before { font-size: 0.9em; line-height: 1; }
.badge-good     { color: var(--status-good); }
.badge-good::before { content: "\2713"; }        /* check */
.badge-bad      { color: var(--status-critical); }
.badge-bad::before { content: "\2717"; }         /* cross */
.badge-unknown  { color: var(--text-muted); }
.badge-unknown::before { content: "\2013"; }     /* dash */

/* --- keys & code -------------------------------------------------------- */

.key-block {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem 1.15rem;
  margin: 1.25rem 0;
}
.key-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.key-head h3 { margin: 0; }
.tag {
  display: inline-block;
  margin-left: 0.5em;
  padding: 0.1em 0.5em;
  border-radius: 999px;
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--status-good);
  color: #ffffff;
  vertical-align: 0.15em;
}
.tag.muted-tag { background: var(--text-muted); }

pre.key, pre.code {
  overflow-x: auto;
  margin: 0.75rem 0 0;
  padding: 0.85rem 1rem;
  background: var(--page);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font: 0.8125rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text-secondary);
}
pre.key { max-height: 11rem; overflow-y: auto; word-break: break-all; white-space: pre-wrap; }
pre.code { color: var(--text-primary); }
code { font-family: inherit; }

/* --- controls ----------------------------------------------------------- */

.button, .ghost {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  background: var(--page);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.875rem;
  text-decoration: none;
  cursor: pointer;
}
.button:hover, .ghost:hover { border-color: var(--text-muted); }
.ghost { margin-top: 1.25rem; }

.notice {
  margin: 1rem 0;
  padding: 0.7rem 0.9rem;
  border-left: 3px solid var(--status-warning);
  background: var(--surface);
  font-size: 0.9375rem;
  color: var(--text-secondary);
}
.notice:empty { display: none; }

details { margin-top: 1.5rem; }
summary { cursor: pointer; font-weight: 600; }

footer { border-top: 1px solid var(--rule); padding-top: 1.5rem; padding-bottom: 3rem; }
footer p { font-size: 0.875rem; }

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