/* theme.css: Mta Sts Kit. "Change-window runbook": warm paper, ink, one steel-blue accent,
   monospace for every hostname and pattern. Signature: the cutover matrix, a 2 x 2 grid whose two
   mixed-state cells carry a hatched amber top edge. Loaded after styles.css; the builder adds
   layout only, never colours, radii, shadows or font sizes. Contrast ratios (WCAG 2.x) are noted
   beside each text pair. */

:root {
  color-scheme: light dark;

  /* Palette (light) */
  --bg: #f6f5f1;
  --surface: #ffffff;
  --raised: #eeece6;
  --text: #1b1f24;            /* 15.6:1 on --bg, 16.8:1 on --surface */
  --muted: #4f5660;           /* 6.7:1 on --bg, 7.3:1 on --surface, 6.1:1 on --raised */
  --border: #d9d6ce;
  --border-strong: #8d8a82;   /* 3.5:1 on --surface: input outlines (non-text) */
  --accent: #1c5aa6;          /* 6.9:1 with --on-accent */
  --accent-hover: #164a8a;
  --accent-active: #113b6f;
  --accent-text: #1c5aa6;     /* 6.9:1 on --surface, 6.3:1 on --bg */
  --accent-tint: #e6eef8;
  --on-accent: #ffffff;
  --success: #1d6b3a;         /* 6.4:1 on --surface, 5.8:1 on --success-tint */
  --success-tint: #e5f3ea;
  --warning: #8a5300;         /* 6.3:1 on --surface, 5.6:1 on --warning-tint */
  --warning-edge: #d08a17;    /* hatch and edges only, never text */
  --warning-tint: #fbf0d9;
  --danger: #b42318;          /* 6.5:1 on --surface, 5.8:1 on --danger-tint */
  --danger-tint: #fdecea;
  --neutral-tint: #eceae4;    /* "Unrestricted" tag; --text on it 14:1 */

  /* Type */
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --text-xs: 0.8125rem;   /* 13px caps labels */
  --text-sm: 0.9375rem;   /* 15px tables, field errors, notes */
  --text-md: 1.0625rem;   /* 17px body */
  --text-lg: 1.25rem;     /* 20px h2, report title */
  --text-xl: 1.625rem;    /* 26px matrix counts */
  --text-2xl: clamp(1.75rem, 4.6vw, 2.5rem); /* h1 */

  /* Space */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  /* Radii and shadows */
  --r-s: 6px;
  --r-m: 10px;
  --r-l: 14px;
  --shadow-1: 0 1px 2px rgb(27 31 36 / 0.06), 0 2px 8px rgb(27 31 36 / 0.05);
  --shadow-2: 0 8px 28px rgb(27 31 36 / 0.16);

  /* Motion */
  --fast: 160ms;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);

  /* Template variables, mapped so its own rules follow the theme */
  --line: var(--border);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121518;
    --surface: #1a1e23;
    --raised: #232830;
    --text: #e8eaed;            /* 15.9:1 on --bg, 14.6:1 on --surface */
    --muted: #a8b0ba;           /* 8.3:1 on --bg, 7.6:1 on --surface, 6.7:1 on --raised */
    --border: #2f353d;
    --border-strong: #6b737d;   /* 3.6:1 on --surface */
    --accent: #7fb0ec;          /* 7.7:1 with --on-accent */
    --accent-hover: #9cc3f2;
    --accent-active: #b8d4f6;
    --accent-text: #8dbaf0;     /* 7.6:1 on --surface */
    --accent-tint: #1c2a3b;
    --on-accent: #0b1a2c;
    --success: #6fd394;         /* 8.3:1 on --success-tint */
    --success-tint: #17291f;
    --warning: #f0b85a;         /* 9.0:1 on --warning-tint */
    --warning-edge: #c98a26;
    --warning-tint: #2e2412;
    --danger: #ff8f85;          /* 7.9:1 on --danger-tint */
    --danger-tint: #2f1a19;
    --neutral-tint: #2a3038;    /* --text on it 11:1 */
    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-2: 0 10px 32px rgb(0 0 0 / 0.55);
  }
}

/* ---------- Page ---------- */

html { background: var(--bg); }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--text-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

header, main, footer { max-width: 64rem; padding-left: var(--s5); padding-right: var(--s5); }

header {
  padding-top: var(--s3);
  padding-bottom: var(--s3);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
/* The mark: a 2 x 2 grid, the two mixed cells amber (same drawing as icons/favicon.svg). */
.brand::before {
  content: "";
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 5px;
  background:
    linear-gradient(var(--accent), var(--accent)) 3px 3px / 7px 7px no-repeat,
    linear-gradient(var(--warning-edge), var(--warning-edge)) 12px 3px / 7px 7px no-repeat,
    linear-gradient(var(--warning-edge), var(--warning-edge)) 3px 12px / 7px 7px no-repeat,
    linear-gradient(var(--accent), var(--accent)) 12px 12px / 7px 7px no-repeat,
    var(--raised);
  box-shadow: inset 0 0 0 1px var(--border);
}
header nav a {
  padding: 0 var(--s3);
  border-radius: var(--r-s);
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
header nav a:hover { background: var(--raised); color: var(--text); }

main { padding-top: var(--s6); padding-bottom: var(--s6); }

h1 {
  font-size: var(--text-2xl);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 0 0 var(--s3);
  max-width: 34ch;
}
.lede { font-size: 1.125rem; color: var(--muted); max-width: 62ch; margin: 0 0 var(--s6); }

h2 {
  font-size: var(--text-lg);
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: var(--s7) 0 var(--s3);
}
h3 { font-size: var(--text-md); margin: var(--s5) 0 var(--s1); }
main > p, main > ol, main > ul, .example p { max-width: 68ch; }
main li + li { margin-top: var(--s2); }

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

code, kbd, samp, pre { font-family: var(--font-mono); font-size: 0.92em; }
:not(pre) > code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--raised);
  overflow-wrap: anywhere;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--accent-tint);
}

/* ---------- Tool panel ---------- */

.tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-1);
  padding: var(--s5);
}

/* Four fields in a 2 x 2 grid that mirrors the report: columns Previous / Staged,
   rows Policy / MX list. */
.grid-heads, .fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: var(--s5);
}
.grid-heads { margin-bottom: var(--s2); }
.grid-heads span, .label-caps {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text);
}
.grid-heads span { display: flex; align-items: center; gap: var(--s2); padding-bottom: var(--s2); border-bottom: 2px solid var(--text); }
.grid-heads span + span { border-bottom-color: var(--accent); }

.field { display: flex; flex-direction: column; min-width: 0; margin: 0 0 var(--s4); }
.field label {
  font-weight: 650;
  font-size: var(--text-md);
  margin-bottom: var(--s1);
}
.field .hint {
  font-size: var(--text-sm);
  color: var(--muted);
  margin: 0 0 var(--s2);
}
.field textarea {
  width: 100%;
  min-height: 11.5rem;
  padding: var(--s3);
  font: 0.9375rem/1.55 var(--font-mono);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-m);
  resize: vertical;
  tab-size: 4;
  transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.field.list textarea { min-height: 7.5rem; }
.field textarea::placeholder { color: var(--muted); opacity: 0.85; }
.field textarea:hover { border-color: var(--text); }
.field textarea:focus-visible { background: var(--surface); border-color: var(--accent); }

/* Field error: reserved one line so nothing jumps when it appears. */
.field-error {
  min-height: 1.5em;
  margin: var(--s2) 0 0;
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--danger);
  font-weight: 600;
}
.field-error:not(:empty)::before {
  content: "!";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: var(--s2);
  vertical-align: -2px;
  border-radius: 50%;
  background: var(--danger);
  color: var(--surface); /* 6.5:1 light, 7.5:1 dark */
  font: 800 11px/16px var(--font-ui);
  text-align: center;
}
.field.invalid textarea, .field textarea[aria-invalid="true"] {
  border-color: var(--danger);
  border-width: 2px;
  padding: calc(var(--s3) - 1px);
  background: var(--danger-tint);
}
.field .count {
  align-self: flex-end;
  margin-top: var(--s1);
  font-size: var(--text-xs);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.field .count.over { color: var(--danger); font-weight: 700; }

/* ---------- Buttons ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s3);
  margin: var(--s2) 0 0;
}
.actions button, .btn {
  min-height: 44px;
  padding: 0 var(--s5);
  border-radius: var(--r-m);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.actions button:active, .btn:active { transform: translateY(1px); }

/* Primary: Compare. The only filled button on the page. */
.actions .primary, #compare {
  min-height: 48px;
  min-width: 11rem;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-1);
}
.actions .primary:hover, #compare:hover { background: var(--accent-hover); }
.actions .primary:active, #compare:active { background: var(--accent-active); }

/* Secondary: Load the worked example. */
.actions .secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.actions .secondary:hover { background: var(--raised); border-color: var(--text); }
.actions .secondary:active { background: var(--border); }

/* Quiet: Clear all four fields. */
.actions .quiet {
  background: transparent;
  color: var(--muted);
  padding: 0 var(--s3);
  margin-left: auto;
}
.actions .quiet:hover { color: var(--text); background: var(--raised); }
.actions .quiet:active { background: var(--border); }

.actions .kbd-hint { font-size: var(--text-xs); color: var(--muted); }
kbd {
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
  font-size: 0.85em;
}

/* ---------- Status line ---------- */

#status {
  min-height: 1.6em;
  margin: var(--s4) 0 0;
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--muted);
}
#status.error { color: var(--danger); }
#status.ok { color: var(--success); }

/* ---------- Report ---------- */

#output { min-height: 0; }
#output:empty { display: none; }
#output:not(:empty) {
  margin-top: var(--s5);
  padding-top: var(--s5);
  border-top: 1px solid var(--border);
  animation: rise 180ms var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Empty state, shown in #output before the first comparison. */
#output .empty, .empty-state {
  display: flex;
  gap: var(--s4);
  align-items: flex-start;
  padding: var(--s5);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-m);
  color: var(--muted);
  background: var(--bg);
}
.empty-state strong { display: block; color: var(--text); margin-bottom: var(--s1); }
.empty-state p { margin: 0; max-width: 60ch; }

.report-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s2) var(--s4); margin-bottom: var(--s4); }
.report-head h2 { margin: 0; font-size: var(--text-lg); }
.report-verdict {
  margin: 0 0 var(--s5);
  font-size: 1.125rem;
  font-weight: 650;
  max-width: 62ch;
}
.report-verdict.bad { color: var(--danger); }
.report-verdict.good { color: var(--success); }

/* Signature: the cutover matrix. */
.matrix {
  display: grid;
  grid-template-columns: minmax(8rem, 0.7fr) 1fr 1fr;
  gap: var(--s2);
  margin: 0 0 var(--s6);
}
.matrix .corner { }
.matrix .col-head, .matrix .row-head {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  align-self: end;
  padding: 0 var(--s1) var(--s1);
}
.matrix .row-head { align-self: center; padding: 0 var(--s2) 0 0; }
.matrix .mode, .mode {
  display: inline-block;
  margin-left: var(--s1);
  padding: 0 6px;
  border-radius: 4px;
  font: 600 var(--text-xs)/1.6 var(--font-mono);
  letter-spacing: 0;
  text-transform: none;
  background: var(--raised);
  color: var(--text);
}
.cell {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  min-height: 8.5rem;
  padding: var(--s4);
  padding-top: calc(var(--s4) + 6px);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  background: var(--surface);
  overflow: hidden;
}
.cell::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: var(--border);
}
.cell.mixed::before {
  background: repeating-linear-gradient(-45deg, var(--warning-edge) 0 6px, transparent 6px 12px);
  background-color: var(--warning-tint);
}
.cell .kind {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.cell.mixed .kind { color: var(--warning); }
.cell .figure {
  font: 700 var(--text-xl)/1.1 var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.cell .figure small { font: 600 var(--text-sm) var(--font-ui); color: var(--muted); letter-spacing: 0; }
.cell .when { font-size: var(--text-sm); color: var(--muted); margin: 0; }
.cell.zero { border-color: var(--danger); background: var(--danger-tint); }
.cell.zero .figure { color: var(--danger); }
.flag {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--s2);
  margin-top: auto;
  padding-top: var(--s2);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--danger);
}
.flag::before {
  content: "";
  flex: none;
  width: 0;
  height: 0;
  margin-top: 3px;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 12px solid currentColor;
}

/* Host tables */
.list-block { margin: 0 0 var(--s6); }
.list-block h3 {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
  margin: 0 0 var(--s2);
  font-size: var(--text-md);
}
.list-block h3 .n { font-weight: 500; color: var(--muted); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  background: var(--surface);
}
#output table, table.hosts {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
#output th, #output td, table.hosts th, table.hosts td {
  padding: var(--s3) var(--s4);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
#output tr:last-child td { border-bottom: 0; }
#output thead th {
  background: var(--raised);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
#output thead th .mode { text-transform: none; }
#output tbody th, #output td.host {
  font: 600 0.9375rem/1.45 var(--font-mono);
  overflow-wrap: anywhere;
  min-width: 12rem;
}
#output tbody tr:hover { background: var(--bg); }
#output td.mixed { box-shadow: inset 3px 0 0 var(--warning-edge); }

/* Status tags: text first, colour second. */
.tag {
  display: inline-block;
  padding: 2px var(--s2) 2px calc(var(--s2) + 2px);
  border-radius: var(--r-s);
  border-left: 4px solid currentColor;
  font-weight: 700;
  font-size: var(--text-sm);
  line-height: 1.45;
  white-space: nowrap;
}
.tag.matched { color: var(--success); background: var(--success-tint); }
.tag.excluded { color: var(--danger); background: var(--danger-tint); }
.tag.mismatch { color: var(--warning); background: var(--warning-tint); }
.tag.unrestricted { color: var(--text); background: var(--neutral-tint); border-left-color: var(--border-strong); }
.why {
  display: block;
  margin-top: var(--s1);
  color: var(--muted);
  font-size: var(--text-sm);
}
.why code { color: var(--text); }

/* Notes under the report */
.notes { display: grid; gap: var(--s3); margin: 0; }
.note {
  margin: 0;
  padding: var(--s3) var(--s4);
  border-radius: var(--r-m);
  background: var(--raised);
  font-size: var(--text-sm);
  max-width: none;
}
.note.testing { background: var(--warning-tint); box-shadow: inset 4px 0 0 var(--warning-edge); }
.note strong { color: var(--text); }

/* Error summary panel (when #status is not enough, e.g. 2+ fields) */
.error-summary {
  margin: var(--s4) 0 0;
  padding: var(--s3) var(--s4);
  border-radius: var(--r-m);
  background: var(--danger-tint);
  box-shadow: inset 4px 0 0 var(--danger);
  color: var(--text);
  font-size: var(--text-sm);
}
.error-summary a { color: var(--danger); font-weight: 700; }

/* ---------- Worked example (reading section) ---------- */

.example {
  margin: var(--s4) 0 0;
  padding: var(--s5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
}
.example .pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); margin: var(--s4) 0; }
.example figure { margin: 0; min-width: 0; }
.example figcaption {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-bottom: var(--s1);
}
.example pre {
  margin: 0;
  padding: var(--s3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-s);
  overflow-x: auto;
  line-height: 1.5;
}
.example .mixed-callout {
  padding: var(--s3) var(--s4);
  border-radius: var(--r-m);
  background: var(--warning-tint);
  box-shadow: inset 4px 0 0 var(--warning-edge);
  margin: var(--s3) 0 0;
}

/* ---------- Template furniture: styled, never resized ---------- */

.ad-slot { background: var(--raised); border: 1px solid var(--border); }
.ad-label { color: var(--muted); opacity: 1; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; }
.house-card { background: var(--surface); border: 1px solid var(--border); transition: border-color var(--fast) var(--ease); }
.house-card:hover { border-color: var(--accent); }
.house-card strong { color: var(--accent-text); }
.house-card span { color: var(--muted); }

.consent {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-2);
}
.consent button { border-color: var(--border-strong); border-radius: var(--r-m); font-weight: 600; transition: background-color var(--fast) var(--ease); }
.consent button:hover { background: var(--raised); }

footer {
  opacity: 1;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: var(--s7);
  padding-top: var(--s5);
  padding-bottom: var(--s6);
  font-size: var(--text-sm);
}
footer a { color: var(--muted); }
footer a:hover { color: var(--text); }

/* ---------- Phone ---------- */

@media (max-width: 46rem) {
  header, main, footer { padding-left: var(--s4); padding-right: var(--s4); }
  main { padding-top: var(--s5); }
  .tool { padding: var(--s4); margin: 0 calc(-1 * var(--s2)); border-radius: var(--r-m); }
  .grid-heads { display: none; }
  .fields { grid-template-columns: 1fr; }
  .field label .side { display: inline; }
  .actions { gap: var(--s2); }
  .actions .primary, #compare { flex: 1 1 100%; }
  .actions .secondary { flex: 1 1 auto; }
  .actions .quiet { margin-left: 0; }
  .actions .kbd-hint { display: none; }
  .matrix { grid-template-columns: 1fr 1fr; }
  .matrix .corner, .matrix .row-head-wide { display: none; }
  .matrix .row-head { grid-column: 1 / -1; padding: var(--s2) 0 0; }
  .cell { min-height: 7.5rem; padding: var(--s3); padding-top: calc(var(--s3) + 6px); }
  .cell .figure { font-size: 1.375rem; }
  .example { padding: var(--s4); }
  .example .pair { grid-template-columns: 1fr; }
}
/* Desktop: the column head shows Previous / Staged, so the side word is hidden visually but
   still read by screen readers as part of the label. */
@media (min-width: 46.01rem) {
  .field label .side {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* ---------- Motion off ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .actions button:active, .btn:active { transform: none; }
}
