/* Hull — shared stylesheet for the public help section.
 *
 * Loaded by static/help.html and static/help/*.html. Same-origin, so CSP
 * `style-src 'self'` allows it (hull_backend/security_headers.py).
 *
 * The :root token block is copied VERBATIM from static/index.html so the docs
 * and the app never drift apart on colour. If you change a token there, change
 * it here.
 *
 * Unlike the app, these pages are responsive — docs get read on phones. The
 * nav rail collapses to a horizontal scroller under 900px.
 */

:root {
  --bg-0: #07090c;
  --bg-1: #0d1217;
  --bg-2: #131922;
  --bg-3: #1a212c;
  --line-1: #20283454;
  --line-2: #2a3543;
  --line-3: #3a4a5e;
  --ink-1: #e6ecf3;
  --ink-2: #9aa7b8;
  --ink-3: #5d6c7f;
  --ink-4: #3d4a5c;
  --accent: oklch(0.78 0.13 200);
  --accent-soft: oklch(0.78 0.13 200 / 0.12);
  --accent-line: oklch(0.78 0.13 200 / 0.45);
  --warn: oklch(0.78 0.13 60);
  --good: oklch(0.78 0.13 150);
  --bad: oklch(0.7 0.16 25);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--ink-1);
  font-family: var(--sans);
}
body { min-height: 100vh; }
::selection { background: var(--accent-soft); color: var(--ink-1); }

/* ------------------------------------------------------------------ topbar */

.topbar {
  height: 44px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line-2);
  background: var(--bg-1);
  padding: 0 14px;
  font-size: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-size: 13px;
  color: var(--ink-1);
  text-decoration: none;
}
.brand:hover { color: var(--ink-1); }
.brand span { color: var(--ink-3); font-weight: 400; }
.brand-mark { width: 18px; height: 18px; display: block; }
.topbar-spacer { flex: 1; }
.top-actions { display: flex; gap: 4px; align-items: center; }
.top-actions a {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-2);
  height: 28px;
  padding: 0 12px;
  border-radius: 4px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.top-actions a:hover {
  color: var(--ink-1);
  background: var(--bg-2);
  border-color: var(--line-2);
}
.top-actions a.primary {
  color: #07171c;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
.top-actions a.primary:hover {
  background: oklch(0.84 0.13 200);
  border-color: oklch(0.84 0.13 200);
  color: #07171c;
}

/* ------------------------------------------------------------------ layout */

.layout {
  display: grid;
  grid-template-columns: 232px 1fr;
  align-items: start;
}

.rail {
  position: sticky;
  top: 44px;
  max-height: calc(100vh - 44px);
  overflow-y: auto;
  background: var(--bg-1);
  border-right: 1px solid var(--line-2);
  padding: 20px 12px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.rail-group { display: flex; flex-direction: column; gap: 2px; }
.rail-h {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  padding: 0 8px;
  margin-bottom: 6px;
}
.rail a {
  display: block;
  padding: 7px 8px;
  border-radius: 4px;
  font-size: 12.5px;
  color: var(--ink-2);
  font-weight: 500;
  border: 1px solid transparent;
  text-decoration: none;
}
.rail a:hover { background: var(--bg-2); color: var(--ink-1); }

/* Current page. Each page sets a body class (e.g. <body class="p-wizard">)
 * and the matching rail link carries id="nav-wizard". Zero JavaScript.
 * (No p-home clause: the hub has no rail — its card grid is its navigation.) */
.p-start   #nav-start,
.p-wizard  #nav-wizard,
.p-designer #nav-designer,
.p-optimize #nav-optimize,
.p-numbers #nav-numbers,
.p-export  #nav-export,
.p-glossary #nav-glossary {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--ink-1);
}

/* ------------------------------------------------------------ prose column */

.doc {
  padding: 34px 40px 80px;
  max-width: 820px;
  min-width: 0;
}
.doc > .lede {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--ink-2);
  margin: 0 0 26px;
}

.doc h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 10px;
}
.doc h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin: 40px 0 12px;
  padding-top: 22px;
  border-top: 1px solid var(--line-2);
  clear: both;   /* a floated figure.panel must not run under the next section */
}
/* Same reason, one level down — and tables especially: squeezed into the
 * remaining ~430px beside a float they wrap every cell to three lines. */
.doc h3, .doc table { clear: both; }
/* Only the h2 that genuinely opens the content loses its rule. Scoping this
 * to :first-of-type instead would drop the rule from whichever h2 happens to
 * come first in source order, which on pages that open with a step list or a
 * callout is one somewhere down the middle. */
.doc > .lede + h2 { border-top: 0; padding-top: 0; }
.doc h3 {
  font-size: 13.5px;
  font-weight: 600;
  margin: 26px 0 8px;
  color: var(--ink-1);
}
.doc h4 {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  margin: 22px 0 8px;
}
.doc p {
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--ink-2);
  margin: 0 0 14px;
}
.doc li { font-size: 13.5px; line-height: 1.7; color: var(--ink-2); margin-bottom: 7px; }
.doc ul, .doc ol { margin: 0 0 16px; padding-left: 22px; }
.doc strong { color: var(--ink-1); font-weight: 600; }
.doc a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; }
.doc a:hover { border-bottom-color: var(--accent-line); }
.doc hr { border: 0; border-top: 1px solid var(--line-2); margin: 32px 0; }

/* A UI string quoted verbatim from the app — button labels, field names. */
.ui {
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--ink-1);
  white-space: nowrap;
}
/* A numeric value or unit. */
.n { font-family: var(--mono); font-size: 12px; color: var(--ink-1); }

/* -------------------------------------------------------------- components */

/* Concept callout — the naval-architecture explainer boxes.
 * The title is a <div>, not an <hN>: it is an eyebrow label, not a rung in the
 * document outline, and marking it up as a heading skipped levels under the
 * surrounding h2. */
.concept {
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-left: 2px solid var(--accent-line);
  border-radius: 0 6px 6px 0;
  padding: 14px 16px;
  margin: 20px 0;
}
.concept-h {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
}
.concept p { margin: 0 0 9px; font-size: 13px; }
.concept p:last-child { margin-bottom: 0; }

/* Plain note / caveat. */
.note {
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 12px 14px;
  margin: 18px 0;
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink-2);
}
.note.warn { border-color: oklch(0.78 0.13 60 / 0.4); background: oklch(0.78 0.13 60 / 0.05); }
.note.good { border-color: oklch(0.78 0.13 150 / 0.4); background: oklch(0.78 0.13 150 / 0.05); }
.note strong { color: var(--ink-1); }

/* Paid-plan badge. */
.gate {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--warn);
  background: oklch(0.78 0.13 60 / 0.08);
  border: 1px solid oklch(0.78 0.13 60 / 0.4);
  border-radius: 3px;
  padding: 2px 7px;
  vertical-align: middle;
  white-space: nowrap;
}
/* Not available yet. Distinct from .gate.opt below — a reader who learns the
 * grey pill means "you cannot have this" must not meet the same pill on an
 * optional wizard step. */
.gate.soon { color: var(--ink-2); background: var(--bg-2); border-color: var(--line-3); }
/* Available, but behind a checkbox or skippable. */
.gate.opt {
  color: var(--ink-2); background: transparent; border-color: var(--line-2);
  font-weight: 500; letter-spacing: 0.08em; text-transform: none;
}

/* Numbered walkthrough. */
ol.steps { list-style: none; padding: 0; margin: 22px 0; counter-reset: step; }
ol.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0 0 4px 44px;
  margin-bottom: 26px;
}
ol.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 1px solid var(--accent-line);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
ol.steps > li > h3 { margin-top: 0; margin-bottom: 6px; font-size: 14px; }

/* Tables — parameter ranges, metric lists, format comparisons. */
.doc table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 12.5px;
  display: block;
  overflow-x: auto;
}
.doc thead th {
  text-align: left;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line-2);
  padding: 8px 12px;
  white-space: nowrap;
}
.doc tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-1);
  color: var(--ink-2);
  line-height: 1.55;
  vertical-align: top;
}
.doc tbody tr:last-child td { border-bottom: 0; }
.doc tbody td:first-child { color: var(--ink-1); font-weight: 500; }
.doc table.mono tbody td:nth-child(2),
.doc table.mono tbody td:nth-child(3) { font-family: var(--mono); font-size: 11.5px; }

/* Keyboard-shortcut table. */
kbd {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg-2);
  border: 1px solid var(--line-3);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--ink-1);
  white-space: nowrap;
}

/* Diagram figure wrapping the inline SVGs. */
figure {
  margin: 24px 0;
  background: var(--bg-0);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  overflow: hidden;
}
figure svg { display: block; width: 100%; height: auto; }
/* --ink-3 is 3.5:1 on --bg-1 — fine for dense chrome in the app, but these
 * carry prose, so they use --ink-2 (7.7:1) to clear WCAG AA. The token block
 * itself stays byte-identical to index.html; only the usages differ. */
figure figcaption {
  font-size: 11.5px;
  color: var(--ink-2);
  line-height: 1.6;
  padding: 10px 14px;
  border-top: 1px solid var(--line-2);
  background: var(--bg-1);
}
/* Labels inside the diagrams. */
.dg-label { font-family: var(--mono); font-size: 9px; fill: var(--ink-2); }
.dg-dim   { font-family: var(--mono); font-size: 8px; fill: var(--ink-2); }
.dg-key   { font-family: var(--mono); font-size: 9px; fill: var(--accent); }

/* Screenshot slot — swap the div for an <img src="/help/<file>"> when a real
 * capture exists. CSP img-src 'self' already permits same-origin images. */
.shot {
  border: 1px dashed var(--line-3);
  border-radius: 6px;
  background: var(--bg-1);
  padding: 34px 20px;
  margin: 24px 0;
  text-align: center;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.7;
}
.shot b { display: block; color: var(--ink-2); font-weight: 500; margin-bottom: 4px; }

/* Real captures, once they replace a .shot placeholder. Without this a
 * 1440px-wide screenshot blows straight through the prose column. */
.doc img { max-width: 100%; height: auto; display: block; border-radius: 6px; margin: 24px 0; }
/* A capture inside a <figure> is framed by the figure, so it must drop .doc
 * img's own margin and radius or it sits inset with a double rounding. */
figure img { width: 100%; margin: 0; border-radius: 0; }
/* The right-hand tool panels are 300px-wide captures. Filling the 820px prose
 * column blows them up 2.7x and turns the 11px UI type to mush, so they render
 * at their own size — 302px is 300 plus the figure's 1px border either side,
 * which keeps them pixel-exact. Wide enough, they sit beside the prose that
 * describes them rather than pushing 800px of it down the page. */
figure.panel { max-width: 302px; margin-left: auto; margin-right: auto; }
/* Opt-in, per placement: only worth floating where real prose runs beside it.
 * Both the other panel captures are followed immediately by a table, which
 * clears — so floating them would strand 800px of empty column. */
@media (min-width: 901px) {
  figure.panel.beside { float: right; margin: 6px 0 22px 26px; }
}

/* ------------------------------------------------------------- hub-page bits */

.hero {
  padding: 56px 40px 40px;
  border-bottom: 1px solid var(--line-2);
  background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
}
.hero-inner { max-width: 900px; }
.hero h1 {
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
  line-height: 1.2;
}
.hero p {
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink-2);
  margin: 0 0 16px;
  max-width: 620px;
}
/* Inline links in hero prose. The .btn links in .hero-cta carry their own
   colours, so this is scoped to the paragraphs — without it a hero link falls
   back to the browser's default blue/visited purple. */
.hero p a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; }
.hero p a:hover { border-bottom-color: var(--accent-line); }
.hero p strong { color: var(--ink-1); font-weight: 600; }
.hero-cta { display: flex; gap: 10px; margin-top: 26px; flex-wrap: wrap; }
.btn {
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  color: var(--ink-1);
  padding: 9px 18px;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.btn:hover { background: var(--bg-3); border-color: var(--line-3); }
.btn.primary { background: var(--accent); color: #07171c; border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: oklch(0.84 0.13 200); border-color: oklch(0.84 0.13 200); color: #07171c; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin: 20px 0 8px;
}
.card {
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 16px 16px 18px;
  text-decoration: none;
  display: block;
  transition: border-color 120ms, transform 120ms;
}
a.card:hover { border-color: var(--line-3); transform: translateY(-1px); }
.card .k {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: block;
  margin-bottom: 8px;
}
.card h3 { margin: 0 0 5px; font-size: 13.5px; font-weight: 600; color: var(--ink-1); }
.card p { margin: 0; font-size: 12px; line-height: 1.6; color: var(--ink-2); }
.card svg { color: var(--accent); margin-bottom: 10px; display: block; }

/* ------------------------------------------------------------------ footer */

.doc-foot {
  margin-top: 52px;
  padding-top: 22px;
  border-top: 1px solid var(--line-2);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
}
.doc-foot a {
  font-size: 12.5px;
  color: var(--ink-2);
  text-decoration: none;
  border: 1px solid var(--line-2);
  background: var(--bg-1);
  border-radius: 5px;
  padding: 9px 14px;
  max-width: 46%;
}
.doc-foot a:hover { border-color: var(--line-3); color: var(--ink-1); }
.doc-foot a small {
  display: block;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 3px;
}
.page-foot {
  padding: 22px 40px 60px;
  color: var(--ink-3);
  font-size: 12px;
  border-top: 1px solid var(--line-2);
  margin-top: 20px;
}
.page-foot a { color: var(--accent); text-decoration: none; }

/* -------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  /* Quoted UI strings may wrap here. Some are long enough ("Set the load
   * (otherwise a sensible default is used)") that nowrap pushes the whole
   * document into a horizontal scroll on a phone. */
  .ui { white-space: normal; }

  /* Scaling a 640-unit diagram into a 335px column renders its 9-unit labels
   * at under 5px. Hold a legible minimum and let the figure scroll instead —
   * the surrounding page must still not scroll sideways. */
  figure { overflow-x: auto; }
  figure svg { min-width: 430px; }

  .layout { grid-template-columns: 1fr; }
  .rail {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line-2);
    flex-direction: row;
    overflow-x: auto;
    gap: 4px;
    padding: 10px 12px;
  }
  .rail-group { flex-direction: row; gap: 4px; }
  .rail-h { display: none; }
  .rail a { white-space: nowrap; border: 1px solid var(--line-2); background: var(--bg-2); }
  .doc { padding: 26px 20px 60px; }
  .hero { padding: 38px 20px 30px; }
  .hero h1 { font-size: 26px; }
  .page-foot { padding: 20px; }
  .doc-foot a { max-width: 100%; flex: 1 1 100%; }
}
