/* theme.css: Sandbox Unblock. "Incident notebook on a quiet console".
   Loaded after styles.css, so these rules win. The builder keeps it linked and does not edit it.
   Signature: the unblock diff (.diff .line.removed / .line.added) with its −/+ gutter. */

:root {
  color-scheme: light dark;

  /* Palette, light. Contrast ratios are against --surface (#fff) unless noted. */
  --bg: #f3f5f3;
  --surface: #ffffff;
  --raised: #eaeeeb;
  --code-bg: #f1f4f2;
  --text: #15191c;            /* 17.6:1 */
  --muted: #4d565c;           /* 7.5:1; 6.9:1 on --bg */
  --border: #d3d9d5;
  --border-strong: #8f9a95;   /* 3.0:1, non-text UI edge */
  --accent: #0f6b5c;          /* 6.4:1; 5.9:1 on --bg */
  --accent-hover: #0b5a4d;
  --accent-active: #084a3f;
  --accent-text: #0f6b5c;     /* links: 6.4:1 */
  --accent-tint: #e1f2ed;     /* --accent on it 5.5:1, --text on it 15:1 */
  --accent-edge: #2f9a85;
  --on-accent: #ffffff;       /* on --accent 6.4:1 */
  --success: #1d6b33;         /* 6.5:1 */
  --success-tint: #e5f3e8;
  --warning: #7a4b00;         /* 7.0:1; 6.0:1 on --warning-tint */
  --warning-tint: #fdf3dc;
  --warning-edge: #d08a00;    /* edges only */
  --danger: #a8261f;          /* 7.1:1; 6.1:1 on --danger-tint */
  --danger-tint: #fcebea;
  --danger-edge: #d9483f;     /* edges only */
  --focus-halo: #0f6b5c33;

  /* Type */
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, "Cascadia Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  --t-xs: 13px;
  --t-s: 15px;
  --t-m: 17px;
  --t-l: 21px;
  --t-xl: clamp(30px, 5vw, 42px);

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

  /* Radii, shadows, motion */
  --r-s: 6px;
  --r-m: 10px;
  --r-l: 16px;
  --shadow-1: 0 1px 2px #15191c14, 0 2px 8px #15191c0d;
  --shadow-2: 0 10px 32px #15191c2e;
  --fast: 160ms;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111517;
    --surface: #181d20;
    --raised: #20272b;
    --code-bg: #0d1113;
    --text: #e6eae7;          /* 14.6:1 on --surface */
    --muted: #a9b3b0;         /* 7.9:1 */
    --border: #2e373b;
    --border-strong: #5b676c; /* 3.0:1, non-text UI edge */
    --accent: #5fd0b6;        /* 9.0:1 */
    --accent-hover: #7adcc5;
    --accent-active: #4bbfa5;
    --accent-text: #6fd8bf;   /* 9.6:1 */
    --accent-tint: #12322c;   /* --text on it 11:1 */
    --accent-edge: #3aa68e;
    --on-accent: #08201b;     /* on --accent 9.0:1 */
    --success: #7fd69a;       /* 9.5:1 */
    --success-tint: #16301f;
    --warning: #f0c060;       /* 10:1; 8.4:1 on --warning-tint */
    --warning-tint: #33280f;
    --warning-edge: #c98a1a;
    --danger: #ff9a8f;        /* 7.9:1; 6.9:1 on --danger-tint */
    --danger-tint: #3a1e1c;
    --danger-edge: #e0605a;
    --focus-halo: #5fd0b640;
    --shadow-1: 0 1px 2px #0006, 0 2px 8px #0004;
    --shadow-2: 0 12px 36px #000a;
  }
}

/* ---------- Base ---------- */
html { background: var(--bg); }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--t-m);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
header, main, footer { max-width: 70rem; padding-inline: var(--s5); }
header {
  border-bottom: 1px solid var(--border);
  max-width: none;
  padding-block: var(--s2);
  padding-inline: max(var(--s5), calc((100% - 70rem) / 2 + var(--s5)));
}
.brand {
  display: inline-flex; align-items: center; gap: var(--s2);
  font-weight: 750; letter-spacing: -0.01em; color: var(--text);
}
.brand .mark { width: 24px; height: 24px; border-radius: var(--r-s); flex: none; }
header nav a {
  padding-inline: var(--s3); border-radius: var(--r-s);
  color: var(--muted); text-decoration: none; font-weight: 600;
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
header nav a:hover { background: var(--raised); color: var(--text); }

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

h1 {
  font-size: var(--t-xl); font-weight: 780; letter-spacing: -0.02em;
  margin: var(--s6) 0 var(--s3);
}
h2 { font-size: var(--t-l); line-height: 1.3; letter-spacing: -0.01em; margin: var(--s7) 0 var(--s3); }
h3 { font-size: var(--t-m); line-height: 1.35; }
main p, main li { max-width: 68ch; }
.lede { font-size: 19px; color: var(--muted); max-width: 62ch; margin: 0 0 var(--s6); }

code, kbd, pre { font-family: var(--font-mono); }
:not(pre) > code {
  font-size: 0.88em; padding: 1px 5px; border-radius: 4px;
  background: var(--raised); color: var(--text);
}
kbd {
  font-size: var(--t-xs); padding: 1px 6px; border-radius: 4px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--surface);
}
pre {
  margin: 0; padding: var(--s3) var(--s4);
  font-size: var(--t-s); line-height: 1.6;
  background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--r-s);
  overflow-x: auto; white-space: pre; tab-size: 4;
}
pre code { background: none; padding: 0; font-size: inherit; overflow-wrap: normal; }

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

/* ---------- Tool ---------- */
.tool { margin: 0 0 var(--s7); }
.fields {
  display: grid; grid-template-columns: 11fr 9fr; gap: var(--s5); align-items: start;
  grid-template-rows: auto auto 1fr auto;
}
.field { display: grid; grid-row: span 4; grid-template-rows: subgrid; min-width: 0; }
.field > label {
  font-size: var(--t-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text);
}
.field .hint { margin: var(--s1) 0 var(--s2); font-size: var(--t-s); color: var(--muted); }
.field textarea {
  width: 100%; min-height: 12rem; height: 14rem; resize: vertical;
  padding: var(--s3) var(--s4);
  font: var(--t-s)/1.6 var(--font-mono);
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-m);
  box-shadow: var(--shadow-1);
  transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.field textarea::placeholder { color: var(--muted); opacity: .8; }
.field textarea:hover { border-color: var(--accent-edge); }
.field textarea:focus-visible { border-color: var(--accent); outline-offset: 0; }
.field-error {
  min-height: 1.5em; margin: var(--s2) 0 0;
  font-size: var(--t-s); font-weight: 600; color: var(--danger);
}
.field.invalid textarea { border: 2px solid var(--danger-edge); background: var(--danger-tint); }

.actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3);
  margin: var(--s4) 0 var(--s2);
}
.actions .clear-push, .actions #clear { margin-left: auto; }
@media (min-width: 46.01rem) {
  main p.actions, .actions { width: 100%; max-width: none; flex-wrap: nowrap; }
}

button, .button {
  min-height: 44px; padding: 10px var(--s4);
  font: 600 var(--t-m)/1.2 var(--font-ui);
  border-radius: var(--r-m); border: 1px solid transparent;
  cursor: pointer;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease),
    color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
button:active { transform: translateY(1px); }
.actions button, button.primary, button.secondary, button.quiet { background: transparent; color: var(--text); }
button.primary, .actions button.primary {
  min-height: 48px; padding-inline: var(--s6);
  background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-1);
}
button.primary:hover { background: var(--accent-hover); }
button.primary:active { background: var(--accent-active); }
button.secondary, .actions button.secondary {
  background: var(--surface); color: var(--accent-text); border-color: var(--accent-edge);
}
button.secondary:hover { background: var(--accent-tint); }
button.secondary:active { background: var(--accent-tint); border-color: var(--accent); }
button.quiet, .actions button.quiet { background: transparent; color: var(--muted); }
button.quiet:hover { background: var(--raised); color: var(--text); }
button.quiet:active { background: var(--border); }
.kbd-hint { font-size: var(--t-xs); color: var(--muted); }

#status {
  min-height: 1.6em; margin: 0 0 var(--s3);
  font-size: var(--t-s); font-weight: 600; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
#status.error { color: var(--danger); }
#status.ok { color: var(--success); }

#output { min-height: 9rem; font-variant-numeric: tabular-nums; }
#output:focus-visible { box-shadow: none; outline-offset: 6px; border-radius: var(--r-l); }
#output > * { animation: rise 180ms var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Empty state */
.empty-state {
  display: flex; flex-direction: column; justify-content: center; gap: var(--s2);
  min-height: 9rem; padding: var(--s5);
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-l);
  color: var(--muted);
}
.empty-state strong { color: var(--text); font-size: var(--t-m); }
.empty-state p { margin: 0; font-size: var(--t-s); }

/* ---------- Report ---------- */
.report-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2) var(--s3);
  margin: var(--s5) 0 var(--s4);
}
.report-head h2 { margin: 0; font-size: var(--t-l); overflow-wrap: anywhere; }
.report-head h2 code { font-size: 0.92em; background: none; padding: 0; }
.report-head .count {
  font-size: var(--t-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent-text); background: var(--accent-tint);
  padding: 2px var(--s2); border-radius: 999px;
}
.placeholder {
  font-size: var(--t-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--warning); background: var(--warning-tint);
  border: 1px solid var(--warning-edge); padding: 1px var(--s2); border-radius: 999px;
}

.finding {
  margin: 0 0 var(--s5); padding: var(--s5);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l);
  box-shadow: var(--shadow-1);
}
.finding-head { border-bottom: 0; max-width: none; margin-inline: 0; padding: 0; padding-inline: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin-bottom: var(--s4); }
.finding-head h3 { margin: 0; padding-left: 0; font-size: var(--t-l); }
.finding-head .num {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--text); color: var(--surface);
  font: 700 var(--t-xs)/1 var(--font-mono);
}
.finding-head .directive { margin-left: auto; }

/* Signature: file tab + unblock diff */
.file-tab {
  display: inline-block; max-width: 100%;
  margin: 0; padding: var(--s1) var(--s3);
  font: var(--t-xs)/1.5 var(--font-mono); color: var(--muted);
  background: var(--raised); border: 1px solid var(--border); border-bottom: 0;
  border-radius: var(--r-s) var(--r-s) 0 0;
  overflow-wrap: anywhere;
}
.file-tab code { background: none; padding: 0; font-size: inherit; color: var(--text); }
.diff {
  border: 1px solid var(--border); border-radius: 0 var(--r-s) var(--r-s) var(--r-s);
  overflow: hidden; font: var(--t-s)/1.6 var(--font-mono);
}
.diff .line { display: flex; align-items: stretch; min-height: 2.4em; }
.diff .line + .line { border-top: 1px solid var(--border); }
.diff .gutter {
  flex: none; width: 2.5rem; display: grid; place-items: center;
  font-weight: 800; font-size: var(--t-m); user-select: none;
}
.diff .line code {
  flex: 1; min-width: 0; padding: var(--s2) var(--s3);
  background: none; font-size: inherit; white-space: pre-wrap; overflow-wrap: anywhere;
}
.diff .removed { background: var(--danger-tint); box-shadow: inset 4px 0 0 var(--danger-edge); }
.diff .removed .gutter { color: var(--danger); }
.diff .removed code { color: var(--text); text-decoration: line-through; text-decoration-color: var(--danger-edge); text-decoration-thickness: 1.5px; }
.diff .added { background: var(--accent-tint); box-shadow: inset 4px 0 0 var(--accent-edge); }
.diff .added .gutter { color: var(--accent-text); }
.diff .added code { color: var(--text); font-weight: 600; }

.label, .finding .label {
  margin: var(--s4) 0 var(--s2);
  font-size: var(--t-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text);
}
.log-line { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); }
.why { margin: var(--s4) 0 0; }
.cannot {
  margin: var(--s3) 0 0; padding: var(--s3) var(--s4);
  font-weight: 650; color: var(--warning);
  background: var(--warning-tint); border-radius: var(--r-s);
  box-shadow: inset 4px 0 0 var(--warning-edge);
}
.note {
  margin: var(--s4) 0 0; padding: var(--s3) var(--s4);
  font-size: var(--t-s); background: var(--raised); border-radius: var(--r-s);
}
.note.warn { background: var(--warning-tint); color: var(--warning); box-shadow: inset 4px 0 0 var(--warning-edge); }
.note.warn code { background: transparent; color: inherit; }

/* Drop-in, commands, undo blocks */
.block {
  margin: 0 0 var(--s4); padding: var(--s4) var(--s5) var(--s5);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l);
}
.block.dropin { border: 2px solid var(--accent-edge); box-shadow: var(--shadow-1); }
.block-head { margin-bottom: var(--s3); display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.block-head h3 { margin: 0; font-size: var(--t-m); }
.block .path { margin: var(--s2) 0 var(--s3); font-size: var(--t-s); overflow-wrap: anywhere; }
.block .path code { background: none; padding: 0; color: var(--muted); }
.block .hint { margin: var(--s3) 0 0; font-size: var(--t-s); color: var(--muted); }
.block pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.block.dropin pre { background: var(--accent-tint); border-color: transparent; font-weight: 600; }
button.copy {
  min-width: 11.5rem; text-align: center;
  background: var(--surface); color: var(--accent-text); border-color: var(--accent-edge);
  font-size: var(--t-s);
}
button.copy:hover { background: var(--accent-tint); }
button.copy:active { border-color: var(--accent); }
button.copy.copied { color: var(--success); border-color: var(--success); }
.blocks-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }

.caveat {
  margin: var(--s4) 0 0; font-size: var(--t-s); color: var(--muted);
  padding-left: var(--s3); border-left: 2px solid var(--border-strong);
}

/* No rule matched */
.unknown {
  padding: var(--s5); border-radius: var(--r-l);
  background: var(--warning-tint); color: var(--text);
  border: 1px solid var(--warning-edge);
}
.unknown strong { display: block; font-size: var(--t-l); color: var(--warning); margin-bottom: var(--s2); }
.unknown p { margin: var(--s2) 0; }
.looked-for { margin: var(--s2) 0 var(--s3); padding-left: var(--s5); font-size: var(--t-s); }
.looked-for li { margin: var(--s1) 0; }
.looked-for code { background: var(--surface); }

/* ---------- Reading section ---------- */
ol.rules { padding-left: var(--s5); }
ol.rules li { margin: var(--s2) 0; padding-left: var(--s1); }
ol.rules li::marker { font-family: var(--font-mono); font-weight: 700; color: var(--accent-text); }

.examples { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }
.example {
  margin: 0; padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-m);
}
.example figcaption { font: 700 var(--t-s)/1.4 var(--font-mono); color: var(--text); }
.example pre { font-size: var(--t-xs); white-space: pre-wrap; overflow-wrap: anywhere; }
.example p { margin: 0; font-size: var(--t-s); color: var(--muted); }
.example button { margin-top: auto; align-self: flex-start; }

main ol:not(.rules), main ul:not(.looked-for) { padding-left: var(--s5); }
main h3 + p { margin-top: var(--s1); }

/* ---------- Template furniture (sizes untouched) ---------- */
.ad-slot { background: var(--raised); border: 1px solid var(--border); }
.ad-label { color: var(--muted); opacity: 1; font-size: var(--t-xs); letter-spacing: 0.08em; text-transform: uppercase; }
.house-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-m); transition: border-color var(--fast) var(--ease); }
.house-card:hover { border-color: var(--accent-edge); }
.house-card strong { color: var(--accent-text); }
.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(--accent-edge); color: var(--accent-text); border-radius: var(--r-m); }
.consent button:hover { background: var(--accent-tint); }
footer {
  opacity: 1; color: var(--muted); font-size: var(--t-s);
  border-top: 1px solid var(--border); margin-top: var(--s8); padding-block: var(--s5);
}

/* ---------- Phone ---------- */
@media (max-width: 46rem) {
  header, main, footer { padding-inline: var(--s4); }
  header { padding-inline: var(--s4); }
  .fields { grid-template-columns: 1fr; grid-template-rows: none; gap: var(--s3); }
  .field { display: flex; flex-direction: column; grid-row: auto; }
  .field textarea { min-height: 12rem; height: 12rem; }
  .actions button.primary { flex: 1 0 100%; }
  .actions button.secondary, .actions button.quiet { flex: 1; }
  .actions #clear { margin-left: 0; }
  .kbd-hint { display: none; }
  .finding, .block { padding: var(--s4); }
  .finding-head .directive { margin-left: 0; flex-basis: 100%; }
  .blocks-row, .examples { grid-template-columns: 1fr; }
  button.copy { min-width: 0; flex: 1 0 100%; }
}

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

/* ---------- Print: the drop-in and diff stay readable on paper ---------- */
@media print {
  .actions, .ad-slot, .consent, button { display: none !important; }
  .finding, .block { box-shadow: none; break-inside: avoid; }
}
