/* chombo.solutions: dark only (docs/product-plan.md, Visual design). */

/* Self-hosted, subset to Latin (docs/adr/0003). The ?h= query makes the service
   worker cache them cache-first like other versioned assets; the version is also
   in the file name, so bump both when a font is updated. */
@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-4.1-latin.woff2?h=4.1") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono-2.304-latin.woff2?h=2.304") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --ground: #0e1013;
  --surface: #171a1f;
  --sunken: #13161a;
  --raised: #1f2329;
  --border: #2c313a;
  --border-strong: #3a404a;
  --text: #e7e9ec;
  --text-2: #b8bfc9;
  --muted: #a3abb7;
  --accent: #ff7a33;
  --link: #ff8a4c;
  --link-hover: #ffb088;
  --error: #ff6b6b;
  --loss-bg: #2a2210;
  --loss-border: #8a6420;
  --loss-text: #f3ddb0;
  --safe-bg: #13221b;
  --safe-border: #23503c;
  --safe-text: #8ee6bd;
  --info-bg: #121b2b;
  --info-border: #2d4a7a;
  --info-text: #c9dbff;

  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --radius: 6px;
  --side: 300px;
  --gutter: 24px;
  color-scheme: dark;
}

/* Base */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font: 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--link); text-underline-offset: 0.15em; }
a:hover { color: var(--link-hover); }

/* Monospace never uses ligatures: a tool must show exactly the characters it means. */
code, kbd, pre, textarea, input.mono, .mono {
  font-family: var(--mono);
  font-variant-ligatures: none;
}
code { font-size: 0.9em; }
:not(pre) > code { padding: 0.05em 0.3em; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; }
kbd {
  font-size: 0.78rem; color: var(--muted);
  border: 1px solid var(--border); border-radius: 4px; padding: 0.05em 0.4em;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Page frame: no header bar; the search button is pinned top right of the main
   column (300px, the sidebar's width), and headings leave room for it. */

.site-main, .site-footer { max-width: calc(1180px + 2 * var(--gutter)); margin: 0 auto; padding-inline: var(--gutter); }
.site-main { position: relative; padding-top: 32px; }

.search {
  position: absolute; top: 32px; right: var(--gutter);
  width: var(--side); height: 44px; padding: 0 12px 0 14px;
  display: flex; align-items: center; gap: 10px;
  font: inherit; font-size: 0.875rem; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer;
}
.search:hover { border-color: var(--border-strong); color: var(--text); }
.search svg { flex: none; }
.search-label { margin-right: auto; }

.page-head, .tool-head { padding-right: calc(var(--side) + 40px); }
.group {
  margin: 0; font-family: var(--mono); font-size: 0.8125rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}

.group a { color: inherit; text-decoration: none; }
.group a:hover { color: var(--link-hover); }

h1 { margin: 0; font-size: 2.25rem; line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; }
.lede { margin: 6px 0 0; color: var(--text-2); font-size: 1.0625rem; }

.site-footer {
  margin-top: 64px; padding-block: 24px 40px; border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px;
  color: var(--muted); font-size: 0.875rem;
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.site-footer a { color: var(--text-2); text-decoration: none; }
.site-footer a:hover { color: var(--text); text-decoration: underline; }
.site-footer .domain { font-family: var(--mono); font-size: 0.75rem; }

/* Tool Page */

.tool-head { display: grid; gap: 6px; }
.tool-page { min-width: 0; }

.tool { display: grid; gap: 20px; margin-top: 28px; }
.field { display: grid; gap: 8px; min-width: 0; }
.field > label, .field-head label, .field-head .label, .verify legend { font-weight: 600; font-size: 0.875rem; }
.field-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; min-height: 36px; }
.field-head label, .field-head .label { margin-right: auto; }
.optional { font-weight: 400; color: var(--muted); }

textarea, input.mono {
  width: 100%; padding: 12px 14px; resize: vertical;
  font-size: 0.9375rem; line-height: 1.6;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
}
input.mono { padding-block: 10px; }
input.mono:not([readonly]) { resize: none; }
textarea:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
::placeholder { color: #6b7380; opacity: 1; }
[readonly] { background: var(--sunken); }
[aria-invalid] { border-color: var(--error); }

/* Options row: checkboxes, selects, and radios drawn as segmented pills. */
.options { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; border: 0; padding: 0; margin: 0; font-size: 0.875rem; }
.options legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.options label { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; cursor: pointer; }
/* Code inside an option label is part of the sentence, not a chip. */
.options code { padding: 0; background: none; border: 0; color: var(--text); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

.options label:has(> input[type="radio"]) {
  position: relative;
  padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text-2);
}
.options label:has(> input[type="radio"]:checked) { border-color: var(--accent); background: var(--raised); color: var(--text); }
.options label:has(> input[type="radio"]:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
/* The real radio stays clickable and focusable, invisible and stretched over its pill. */
.options label > input[type="radio"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

select, input.count {
  font: inherit; font-size: 0.875rem; min-height: 36px; padding: 0 10px; margin-left: 4px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
}
input.count { width: 5.5em; font-family: var(--mono); }

/* Buttons */
.copy, .swap, .regenerate {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px;
  font: inherit; font-size: 0.8125rem; font-weight: 600; line-height: 1;
  border-radius: var(--radius); cursor: pointer; text-decoration: none; white-space: nowrap;
}
/* Copy is the strongest control on a Page. */
.copy { background: var(--text); color: var(--ground); border: 1px solid var(--text); }
.copy:hover { background: #ffffff; color: var(--ground); }
.swap, .regenerate { background: var(--surface); color: var(--text); border: 1px solid var(--border); font-weight: 500; }
.swap:hover, .regenerate:hover { border-color: var(--border-strong); color: var(--text); }

/* Messages */
.error { margin: 0; color: var(--error); font-size: 0.875rem; }
.losses, .findings {
  padding: 10px 14px; border: 1px solid; border-radius: var(--radius); font-size: 0.875rem;
}
.losses { background: var(--loss-bg); border-color: var(--loss-border); color: var(--loss-text); }
.findings { background: var(--info-bg); border-color: var(--info-border); color: var(--info-text); }
.losses p { margin: 0 0 4px; font-weight: 600; }
.losses ul, .findings ul { margin: 0; padding-left: 1.2em; display: grid; gap: 2px; }
.losses code, .findings code { background: rgb(255 255 255 / 0.06); border-color: transparent; }

.privacy-note {
  margin: 20px 0 0; padding: 10px 14px; display: flex; align-items: flex-start; gap: 8px;
  font-size: 0.8125rem; color: var(--safe-text);
  background: var(--safe-bg); border: 1px solid var(--safe-border); border-radius: var(--radius);
}
.privacy-note svg { flex: none; margin-top: 2px; }

/* Secondary outputs (Outcome.fields) */
.fields { display: grid; gap: 8px; }
.field-inline { grid-template-columns: 8rem minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.field-inline label { font-weight: 500; font-size: 0.875rem; color: var(--text-2); }
.field-inline input { padding: 8px 12px; }
.note { margin: 0; color: var(--muted); font-size: 0.875rem; }
.note:empty { display: none; }
.note span { font-family: var(--mono); color: var(--text); }

.now { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; color: var(--muted); }
.now code { color: var(--text); font-size: 1rem; }

.perm-grid { border-collapse: collapse; width: max-content; }
.perm-grid th, .perm-grid td { padding: 6px 16px; text-align: center; font-weight: 400; }
.perm-grid thead th { font-size: 0.8125rem; color: var(--muted); }
.perm-grid tbody th { text-align: left; font-weight: 600; font-size: 0.875rem; padding-left: 0; }
.perm-grid input { width: 20px; height: 20px; }

.verify { display: grid; gap: 10px; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 16px; margin: 0; }
.verify legend { padding: 0 6px; }
.verify .options { align-items: center; }
.verify-result { margin: 0; font-weight: 600; }
.verify-result:empty { display: none; }
.verify-result[data-state="ok"] { color: var(--safe-text); }
.verify-result[data-state="bad"] { color: var(--error); }
.verify-result[data-state="ok"]::before { content: "✓ "; }
.verify-result[data-state="bad"]::before { content: "✗ "; }

/* Reference block */
.reference { margin-top: 48px; padding-top: 8px; border-top: 1px solid var(--border); max-width: 70ch; color: #c9ced6; }
.reference h2, .text-page h2 { margin: 28px 0 8px; font-size: 1.25rem; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.reference p, .reference ul, .reference ol { margin: 0 0 12px; }
.reference ul, .reference ol { padding-left: 1.25em; display: grid; gap: 6px; }
.reference strong { color: var(--text); }
pre {
  margin: 0 0 12px; padding: 12px 14px; overflow-x: auto;
  background: var(--sunken); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 0.875rem; line-height: 1.6;
}
table { border-collapse: collapse; margin: 0 0 12px; font-size: 0.875rem; display: block; overflow-x: auto; }
th, td { padding: 6px 12px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--muted); font-weight: 600; }
pre.licence { white-space: pre-wrap; font-size: 0.75rem; max-height: 24em; overflow-y: auto; }

.related { list-style: none; padding: 0 !important; display: flex !important; flex-wrap: wrap; gap: 8px !important; }
.related a {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  text-decoration: none; font-size: 0.875rem;
}
.related a:hover { border-color: var(--border-strong); }

/* Lists of Tools (home, /tools) */
.page-head .lede { max-width: 60ch; }
.tool-list {
  margin-top: 32px; display: grid; gap: 32px 48px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}
.tool-list h2 {
  margin: 0 0 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: 0.8125rem; font-weight: 500; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.tool-list ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.tool-list li { display: flex; align-items: center; gap: 8px; }
.tool-list li a { display: inline-block; padding: 4px 0; color: var(--text); text-decoration: none; }
.tool-list li a:hover { color: var(--link-hover); }

/* Home page: one entry per Tool */
.tool-index {
  margin-top: 48px; display: grid; gap: 40px 48px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
}
.tool-index h2 {
  margin: 0 0 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: 0.8125rem; font-weight: 500; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.tool-index ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.tool-entry-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tool-name { color: var(--text); font-weight: 500; text-decoration: none; }
.tool-name:hover { color: var(--link-hover); }
.tool-index p { margin: 2px 0 0; color: var(--muted); font-size: 0.875rem; line-height: 1.45; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips a {
  font-family: var(--mono); font-size: 0.75rem; line-height: 1; padding: 6px 8px; white-space: nowrap;
  border: 1px solid var(--border); border-radius: 4px; color: var(--text-2); text-decoration: none;
}
.chips a:hover { border-color: var(--border-strong); background: var(--raised); color: var(--link-hover); }
.matrix { margin-top: 10px; border-collapse: collapse; font-family: var(--mono); font-size: 0.75rem; }
.matrix th { padding: 4px 8px; color: var(--text-2); font-weight: 500; }
.matrix th[scope="row"] { padding-left: 0; text-align: left; }
.matrix td { padding: 0; width: 44px; height: 30px; text-align: center; border: 1px solid var(--border); }
.matrix thead td { border: 0; }
.matrix td a { display: block; line-height: 30px; text-decoration: none; }
.matrix td a:hover { background: var(--raised); }
.all-pages { margin-top: 40px; }

/* Text pages (about, privacy, contact, 404) */
.text-page { max-width: 70ch; color: #c9ced6; }
.text-page h1 { color: var(--text); margin-bottom: 20px; }
.operator { font-style: normal; }

/* Command palette */
.palette {
  width: min(580px, calc(100vw - 32px)); margin-top: 12vh; padding: 0;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
  box-shadow: 0 24px 64px rgb(0 0 0 / 0.5);
}
.palette::backdrop { background: rgb(0 0 0 / 0.6); }
.palette input {
  width: 100%; height: 60px; padding: 0 18px; font: inherit; font-size: 1.0625rem;
  background: none; color: var(--text); border: 0; border-bottom: 1px solid var(--border); outline: none;
}
.palette input::-webkit-search-cancel-button { display: none; }
.palette ul { list-style: none; margin: 0; padding: 8px; max-height: 50vh; overflow-y: auto; }
.palette li a {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 0 12px;
  border-radius: var(--radius); color: var(--text); text-decoration: none;
}
.palette li a span { color: var(--muted); font-size: 0.8125rem; }
.palette li a:hover { background: var(--raised); }
.palette li[aria-selected="true"] a { background: var(--text); color: var(--ground); }
.palette li[aria-selected="true"] a span { color: #4a515c; }
.palette-action { padding: 4px 12px; text-align: right; }
.palette-action button { font: inherit; font-size: 0.8125rem; background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; min-height: 32px; }
.palette-hints {
  margin: 0; padding: 10px 18px; display: flex; flex-wrap: wrap; gap: 6px 18px;
  border-top: 1px solid var(--border); background: var(--sunken); font-size: 0.75rem; color: var(--muted);
}

/* Phones: search shrinks to an icon button on the first line, beside the
   group label (Tool Pages) or the title (other pages). */
@media (max-width: 699px) {
  :root { --gutter: 16px; }
  .site-main { padding-top: 16px; }
  .search { top: 16px; width: 44px; padding: 0; justify-content: center; color: var(--text); }
  .search-label, .search kbd { display: none; }
  .page-head, .tool-head { padding-right: 0; }
  .page-head h1, .tool-head .group { padding-right: 56px; min-height: 44px; }
  .tool-head .group { display: flex; align-items: center; }
  h1 { font-size: 1.75rem; }
  .tool-head h1 { min-height: 0; }
  /* Secondary values get the full width: label on its own line, value and Copy below. */
  .field-inline { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; }
  .field-inline label { grid-column: 1 / -1; font-size: 0.8125rem; }
  .copy, .swap, .regenerate { min-height: 44px; }
}

/* Paste anything (home) */
.paste { display: grid; gap: 8px; margin: 8px 0 32px; }
.paste textarea { min-height: 7.5rem; }
.suggestions { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.suggestions a {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 10px 14px; min-height: 44px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none;
}
.suggestions a span { color: var(--muted); font-size: 0.875rem; }
.suggestions a:hover, .suggestions a:focus-visible { border-color: var(--accent); }
.suggestions li[aria-selected="true"] a { border-color: var(--accent); }
.paste-hint { margin: 0; color: var(--muted); font-size: 0.875rem; }

/* Regex tester */
.regex-pattern { display: flex; align-items: center; gap: 8px; font-family: var(--mono); color: var(--muted); }
.regex-pattern input { flex: 1; min-width: 0; }
.regex-view {
  margin: 0; min-height: 3.2em; max-height: 24em; overflow: auto; padding: 12px 14px;
  font: 0.9375rem/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--sunken); color: var(--text-2); border: 1px solid var(--border); border-radius: var(--radius);
}
.regex-view mark { color: var(--text); background: rgb(255 122 51 / 0.30); border-radius: 2px; box-shadow: inset 0 -2px 0 var(--accent); }
.regex-view mark.odd { background: rgb(201 219 255 / 0.20); box-shadow: inset 0 -2px 0 var(--info-text); }

/* Text diff */
.diff-inputs { display: grid; gap: 20px; }
@media (min-width: 760px) { .diff-inputs { grid-template-columns: 1fr 1fr; } }
.diff-view {
  max-height: 36em; overflow: auto; font: 0.875rem/1.6 var(--mono);
  background: var(--sunken); border: 1px solid var(--border); border-radius: var(--radius);
}
.diff-row { display: grid; grid-template-columns: 3.5em minmax(0, 1fr) 3.5em minmax(0, 1fr); }
.diff-row > div { padding: 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff-row .num { color: var(--muted); text-align: right; user-select: none; border-right: 1px solid var(--border); }
.diff-row .new { border-right: 0; }
.diff-row .old { border-right: 1px solid var(--border); }
.diff-row.deleted .old, .diff-row.changed .old { background: rgb(255 107 107 / 0.12); }
.diff-row.inserted .new, .diff-row.changed .new { background: rgb(142 230 189 / 0.10); }
.diff-row .old mark { color: var(--text); background: rgb(255 107 107 / 0.38); }
.diff-row .new mark { color: var(--text); background: rgb(142 230 189 / 0.32); }
.diff-row.skipped { grid-template-columns: 1fr; }
.diff-skip { color: var(--muted); text-align: center; background: var(--surface); border-block: 1px solid var(--border); }
@media (max-width: 759px) {
  /* Stacked: the original line above the changed one. */
  .diff-row { grid-template-columns: 3em minmax(0, 1fr); }
  .diff-row.same > .num:nth-child(3), .diff-row.same > .new,
  .diff-row.deleted > .num:nth-child(3), .diff-row.deleted > .new,
  .diff-row.inserted > .num:first-child, .diff-row.inserted > .old { display: none; }
}

