/* ============================================================
   tofa docs — theme
   Brand front: tofa.tv navy/foam world (dark) and its near-white
   derivation (light). Tokens, type scale, and component look
   otherwise follow the elevated redesign layered in elevated.css.
   ============================================================ */

@font-face {
  font-family: "Inter Tight";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../fonts/inter-tight-latin.woff2") format("woff2");
}

:root {
  /* Hand-synced copy of the canonical brand set in
     tofa-connect/branding/brand-tokens.css, under this site's own names:
     paper=abyss #030b10, paper-2=harbor #071a26, ink=foam #f0fdfa,
     teal/teal-bright/on-accent verbatim. The light theme below is this
     site's own derivation. Update here when brand-tokens.css changes. */
  --teal: #2dd4bf;
  --teal-bright: #5eead4;
  --on-accent: #0c1014;
  --gutter: clamp(20px, 4.6vw, 56px);
  --sans: "Inter Tight", "Helvetica Neue", Helvetica, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --maxw: 1180px;

  color-scheme: dark;
  --paper: #030b10;
  --paper-2: #071a26;
  --ink: #f0fdfa;
  --ink-78: rgba(240, 253, 250, 0.82);
  --ink-58: rgba(240, 253, 250, 0.7);
  --ink-40: rgba(240, 253, 250, 0.56);
  --line: rgba(240, 253, 250, 0.12);
  --line-soft: rgba(240, 253, 250, 0.07);
  --border-strong: rgba(240, 253, 250, 0.28);
  --fill-strong: rgba(255, 255, 255, 0.11);
  --on-fill: #f0fdfa;
  --tint: rgba(255, 255, 255, 0.05);
  --tint-2: rgba(255, 255, 255, 0.025);
  --code-bg: #04121a;
}
:root[data-theme="light"] {
  color-scheme: light;
  --paper: #f4f7f8;
  --paper-2: #e8eff1;
  --ink: #06171f;
  --ink-78: rgba(6, 23, 31, 0.82);
  --ink-58: rgba(6, 23, 31, 0.72);
  --ink-40: rgba(6, 23, 31, 0.6);
  --line: rgba(6, 23, 31, 0.14);
  --line-soft: rgba(6, 23, 31, 0.08);
  --border-strong: rgba(6, 23, 31, 0.3);
  --fill-strong: #06171f;
  --on-fill: #f4f7f8;
  --tint: rgba(6, 23, 31, 0.04);
  --tint-2: rgba(6, 23, 31, 0.02);
  --code-bg: #e3eaec;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--teal); color: var(--on-accent); }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }

/* Ambient brand-front atmosphere on the abyss. A single fixed layer behind
   all content: one very-low-opacity teal radial glow anchored at the top
   plus a faint harbor-to-abyss vertical lift, so the page has depth without a
   starfield. Fixed + gradient-only (no filter, no JS, no animation) means no
   scroll jank; it sits at the viewport top so it never lands mid-column at
   reading strength, and it reads faintly through the sticky nav and the search
   dialog's translucent backdrop. Kin to concept.css .cpt-sky and
   authBrand.css .brand-glow, dialed down for a long-form reading surface. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(115vw 72vh at 50% -8%,
      rgba(45, 212, 191, 0.16) 0%, rgba(45, 212, 191, 0.05) 36%, transparent 70%),
    radial-gradient(90vw 55vh at 88% 108%,
      rgba(45, 212, 191, 0.05) 0%, transparent 60%),
    linear-gradient(180deg,
      rgba(7, 26, 38, 0.75) 0%, rgba(5, 19, 28, 0.3) 34%, transparent 68%);
}
:root[data-theme="light"] body::before {
  background:
    radial-gradient(115vw 68vh at 50% -8%,
      rgba(45, 212, 191, 0.06) 0%, transparent 58%),
    linear-gradient(180deg, rgba(6, 23, 31, 0.035) 0%, transparent 45%);
}

/* Brand micro-label: Inter Tight, not mono. The old warm-Swiss build set
   every eyebrow/label in system mono at 0.18em; the tofa.tv front carries
   labels in the sans at a restrained tracking. Reserve --mono for code. */
.label {
  font-family: var(--sans); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; font-size: 0.68rem; line-height: 1.2;
}
.tlink { color: var(--teal); }
.tlink:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---- top nav ----
   Matches the tofa.tv marketing header exactly (concept.css .cpt-nav): same
   floating glass bar, sticky offset, radius, blur/opacity, logo+wordmark
   scale, and link grammar (neutral hover wash, not a teal tint — teal stays
   reserved for interactive accents like the CTA/search, never plain nav
   links). The "docs" tag next to the wordmark follows the same plain-label
   pattern as accounts.tofa.tv's "account" tag (no chip border: this brand
   front never uses pill/chip decoration). */
header.nav {
  /* Not sticky (founder call 2026-07-21, all surfaces): the bar scrolls away
     with the page. 14px top margin keeps the old sticky resting offset. */
  z-index: 60;
  max-width: 1060px; margin: 14px auto 0; padding: 10px 12px 10px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--paper-2) 78%, transparent);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}
@media (max-width: 1120px) { header.nav { margin: 14px 16px 0; } }
.nav-in {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; width: 100%;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 22px; letter-spacing: -0.02em; color: var(--ink); }
.brand .mark { width: 32px; height: auto; display: inline-block; }
.brand .wm { line-height: 1; }
.brand .tag {
  font-family: var(--sans); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; font-size: 0.65rem; color: var(--ink-40);
  padding-left: 4px;
}
.nav-right { display: flex; align-items: center; gap: 2px; }
.nav-link {
  display: inline-flex; align-items: center; min-height: 44px;
  font-family: var(--sans); font-weight: 500;
  font-size: 14px; padding: 0 12px; color: var(--ink-58);
  border-radius: 10px; transition: color 0.15s ease, background 0.15s ease;
}
.nav-link:hover { color: var(--ink); background: var(--tint); }
.nav-link.current { color: var(--ink); background: var(--tint); }
.theme-toggle, .menu-btn {
  width: 34px; height: 34px; border: 1px solid var(--line); background: var(--tint-2);
  color: var(--ink-58); cursor: pointer; font-size: 0.9rem; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.theme-toggle:hover, .menu-btn:hover {
  color: var(--teal-text, var(--teal)); border-color: var(--teal-rim, rgba(94, 234, 212, 0.75));
  background: rgba(45, 212, 191, 0.17);
}
.menu-btn { display: none; }

/* ---- layout ---- */
.shell {
  max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter);
  display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 56px;
  align-items: start;
}
.shell.with-toc {
  grid-template-columns: 232px minmax(0, 1fr) 200px;
}

/* left side nav */
aside.side {
  /* The header scrolls away (it is not sticky), so the rails stick to the
     viewport top; their own padding provides the air. */
  position: sticky; top: 0; align-self: start;
  padding: 40px 18px 40px 0; border-right: 1px solid var(--line-soft);
  height: 100vh; overflow-y: auto;
}
aside .side-group { margin-bottom: 26px; }
aside .side-label {
  font-family: var(--sans); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; font-size: 0.62rem; color: var(--ink-40);
  margin: 0 0 12px;
}
aside nav a.guide {
  display: block; padding: 6px 10px; color: var(--ink-58);
  font-size: 0.9rem; border: 1px solid transparent; border-radius: 10px;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
aside nav a.guide:hover { color: var(--teal-text, var(--teal)); background: rgba(45, 212, 191, 0.1); }
aside nav a.guide.active {
  color: var(--on-fill); background: var(--surface, var(--paper-2));
  border-color: var(--line);
}
/* in-page section anchors, shown under the active guide */
aside .sections { margin: 2px 0 8px; }
aside .sections a {
  display: block; padding: 5px 10px 5px 22px; color: var(--ink-58);
  font-size: 0.82rem; border: 1px solid transparent; border-radius: 10px;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
aside .sections a:hover { color: var(--teal-text, var(--teal)); background: rgba(45, 212, 191, 0.1); }
aside .sections a.active {
  color: var(--on-fill); background: var(--surface, var(--paper-2));
  border-color: var(--line);
}

/* right-hand "on this page" rail (wide screens) */
aside.toc {
  position: sticky; top: 0; align-self: start;
  padding: 44px 0; height: 100vh; overflow-y: auto;
}
aside.toc .side-label { margin-bottom: 12px; }
aside.toc a {
  display: block; padding: 5px 10px; color: var(--ink-58);
  font-size: 0.82rem; border: 1px solid transparent; border-radius: 10px;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
aside.toc a:hover { color: var(--teal-text, var(--teal)); background: rgba(45, 212, 191, 0.1); }
aside.toc a.active {
  color: var(--on-fill); background: var(--surface, var(--paper-2));
  border-color: var(--line);
}

/* main content */
main.doc { padding: 44px 0 120px; min-width: 0; }
.eyebrow {
  font-family: var(--sans); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; font-size: 0.68rem; color: var(--teal);
  margin-bottom: 16px;
}
h1 {
  font-size: clamp(2rem, 4vw, 2.85rem); line-height: 1.04;
  letter-spacing: -0.035em; font-weight: 800; margin: 0 0 18px; max-width: 18ch;
}
.lede { font-size: 1.12rem; color: var(--ink-78); max-width: 60ch; margin: 0 0 14px; }

.doc h2 {
  font-size: 1.45rem; letter-spacing: -0.02em; font-weight: 700;
  margin: 52px 0 4px; padding-top: 26px; border-top: 1px solid var(--line);
  scroll-margin-top: 80px;
}
.doc h2 .num {
  font-family: var(--sans); font-weight: 700; font-variant-numeric: tabular-nums;
  font-size: 0.85rem; color: var(--teal); margin-right: 12px; letter-spacing: 0;
}
.doc h3 {
  font-size: 1.06rem; letter-spacing: -0.01em; font-weight: 700;
  margin: 30px 0 4px; scroll-margin-top: 80px;
}
.doc h2 .anchor, .doc h3 .anchor {
  opacity: 0; margin-left: 8px; color: var(--ink-40); font-weight: 400;
  font-size: 0.8em; transition: opacity 0.15s ease;
}
.doc h2:hover .anchor, .doc h3:hover .anchor { opacity: 1; }
.doc p { max-width: 64ch; color: var(--ink-78); }
.doc p strong, .doc li strong { color: var(--ink); font-weight: 700; }
.doc ul, .doc ol { max-width: 64ch; color: var(--ink-78); padding-left: 22px; }
.doc li { margin: 7px 0; }
.doc li::marker { color: var(--ink-40); }
.doc a:not(.tlink):not(.anchor) { color: var(--teal); }
.doc a:not(.tlink):not(.anchor):hover { text-decoration: underline; text-underline-offset: 3px; }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 40px 0; }

.doc code {
  font-family: var(--mono); font-size: 0.85em; background: var(--tint);
  padding: 2px 6px; border: 1px solid var(--line-soft); color: var(--ink);
  border-radius: 6px;
}
pre {
  background: var(--code-bg); border: 1px solid var(--line);
  padding: 18px 20px; overflow-x: auto; margin: 18px 0; max-width: 100%;
  position: relative; border-radius: 12px;
}

/* copy buttons (code blocks + page header) */
.copy-code, .copy-page {
  appearance: none; cursor: pointer;
  font-family: var(--sans); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; font-size: 0.62rem;
  color: var(--ink-40); background: var(--paper-2);
  border: 1px solid var(--line); padding: 5px 9px; border-radius: 8px;
  transition: color 120ms ease, border-color 120ms ease;
}
.copy-code:hover, .copy-page:hover { color: var(--teal); border-color: var(--teal); }
.copy-code:focus-visible, .copy-page:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.copy-code.copied, .copy-page.copied { color: var(--teal); border-color: var(--teal); }
.copy-code.copy-error, .copy-page.copy-error { color: #d08c4a; border-color: #d08c4a; }
.copy-code {
  position: absolute; top: 8px; right: 8px; opacity: 0;
}
pre:hover .copy-code, .copy-code:focus-visible, .copy-code.copied, .copy-code.copy-error { opacity: 1; }
@media (hover: none) { .copy-code { opacity: 1; } }
.doc-title { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.doc-title h1 { margin-bottom: 0; }
.doc-title .copy-page { flex: none; position: relative; top: -4px; }
pre code {
  font-family: var(--mono); font-size: 0.84rem; line-height: 1.6;
  background: none; border: 0; padding: 0; color: var(--ink-78);
}
pre .cmt { color: var(--ink-40); }
pre .k { color: var(--teal); }
pre .str { color: var(--ink); }

/* callout */
.note {
  border: 1px solid var(--line);
  background: var(--paper-2); padding: 16px 18px; margin: 22px 0; max-width: 64ch;
  border-radius: 12px;
}
.note .note-label {
  font-family: var(--sans); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; font-size: 0.62rem; color: var(--teal); margin-bottom: 6px;
}
.note p { margin: 0; color: var(--ink-78); font-size: 0.95rem; }
.note p + p { margin-top: 8px; }

/* compose builder */
.compose-builder { margin: 22px 0; }
.cb-form {
  border: 1px solid var(--line); background: var(--paper-2);
  padding: 20px 22px; display: grid; gap: 18px; max-width: 64ch;
  border-radius: 14px;
}
.cb-form fieldset { border: 0; padding: 0; margin: 0; }
.cb-form legend {
  font-family: var(--sans); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; font-size: 0.64rem; color: var(--ink-40);
  padding: 0; margin-bottom: 8px;
}
.cb-form label {
  display: flex; align-items: baseline; gap: 9px;
  font-size: 0.95rem; color: var(--ink-78); padding: 3px 0; cursor: pointer;
}
.cb-form label:has(input:disabled) { opacity: 0.45; cursor: not-allowed; }
.cb-form input[type="radio"], .cb-form input[type="checkbox"] {
  accent-color: var(--teal); flex: none; position: relative; top: 1px;
}
.cb-hint {
  font-family: var(--sans); font-weight: 600; font-size: 0.6rem; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--ink-40);
}
.cb-form input[type="text"] {
  font-family: var(--mono); font-size: 0.84rem; color: var(--ink);
  background: var(--tint); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; width: 100%; max-width: 34ch;
}
.cb-form input[type="text"]:focus-visible { outline: 2px solid var(--teal-text, var(--teal)); outline-offset: 1px; }
.cb-note { font-size: 0.82rem; color: var(--ink-40); margin: 6px 0 0; }
.cb-note code { font-size: 0.78rem; }
.cb-lede { margin: 18px 0 0; font-size: 0.95rem; color: var(--ink-78); }
.compose-builder pre { margin-top: 10px; }

/* OS/setup tabs */
.tabs { margin: 22px 0; }
.tab-list { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab-list button {
  appearance: none; background: none; border: 0; cursor: pointer;
  font-family: var(--sans); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; font-size: 0.68rem; color: var(--ink-40);
  padding: 9px 13px 10px; margin-bottom: -1px;
  border-bottom: 2px solid transparent; transition: color 120ms ease;
}
.tab-list button:hover { color: var(--teal-text, var(--teal)); background: rgba(45, 212, 191, 0.1); border-radius: 8px 8px 0 0; }
.tab-list button.active { color: var(--teal-text, var(--teal)); border-bottom-color: var(--teal-text, var(--teal)); }
.tab-list button:focus-visible { outline: 2px solid var(--focus, var(--teal)); outline-offset: 2px; }
.tab-panel { display: none; padding-top: 4px; }
.tab-panel.active { display: block; }
.tab-panel > :first-child { margin-top: 14px; }

/* table */
.doc table {
  border-collapse: separate; border-spacing: 0; width: 100%; max-width: 64ch;
  margin: 18px 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
}
.doc th, .doc td {
  text-align: left; padding: 11px 14px;
  border-bottom: 1px solid var(--line); border-right: 1px solid var(--line);
  font-size: 0.92rem; vertical-align: top;
}
.doc th:last-child, .doc td:last-child { border-right: 0; }
.doc tr:last-child td { border-bottom: 0; }
.doc th {
  font-family: var(--sans); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; font-size: 0.62rem; color: var(--ink-58); background: var(--tint);
}
.doc td code { white-space: nowrap; }

/* prev / next pager */
.pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 64px;
  border-top: 1px solid var(--line); padding-top: 28px;
}
.pager a {
  border: 1px solid var(--line); padding: 16px 18px; display: block;
  border-radius: 12px;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.pager a:hover { border-color: var(--teal-bright, var(--teal)); background: var(--tint-2); }
.pager a.next { text-align: right; }
.pager .dir {
  font-family: var(--sans); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; font-size: 0.62rem; color: var(--ink-40); margin-bottom: 6px;
}
.pager .ttl { color: var(--ink); font-weight: 700; letter-spacing: -0.01em; }
.pager a.placeholder { visibility: hidden; }

/* footer */
footer.foot {
  border-top: 1px solid var(--line); margin-top: 40px;
}
.foot-in {
  max-width: var(--maxw); margin: 0 auto; padding: 28px var(--gutter);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}
.foot .left { display: flex; align-items: center; gap: 10px; color: var(--ink-58); font-size: 0.85rem; }
.foot .left .mark { height: 17px; width: auto; display: inline-block; }
.foot .right { display: flex; gap: 4px; }

/* ============================================================
   landing page
   ============================================================ */
.landing { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
.hero { padding: 72px 0 36px; border-bottom: 1px solid var(--line); }
.hero h1 { font-size: clamp(2.3rem, 5.2vw, 3.6rem); max-width: 16ch; margin-bottom: 22px; }
.hero .lede { font-size: 1.22rem; max-width: 56ch; }
.hero .cta { display: flex; gap: 12px; margin-top: 30px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 11px 18px;
  font-family: var(--sans); font-weight: 600;
  letter-spacing: 0.005em; font-size: 0.86rem; border: 1px solid var(--line);
  border-radius: 11px; color: var(--ink);
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.btn.primary { background: var(--fill-strong); color: var(--on-fill); border-color: var(--fill-strong); }
.btn:hover {
  background: rgba(45, 212, 191, 0.17); color: var(--teal-bright, var(--teal));
  border-color: var(--teal-bright, var(--teal)); transform: scale(1.03);
}
@media (prefers-reduced-motion: reduce) { .btn:hover { transform: none; } }

.cat-block { padding: 44px 0; border-bottom: 1px solid var(--line-soft); }
.cat-block:last-child { border-bottom: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card {
  border: 1px solid var(--line); background: var(--tint); padding: 22px 22px 24px; display: block;
  border-radius: 14px;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.card:hover { border-color: rgba(94, 234, 212, 0.5); background: color-mix(in srgb, var(--teal) 6%, var(--tint)); }
.card .card-idx {
  font-family: var(--sans); font-weight: 700; font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--teal); letter-spacing: 0; margin-bottom: 12px;
}
.card .card-ttl { font-weight: 700; font-size: 1.12rem; letter-spacing: -0.02em; margin-bottom: 8px; }
.card .card-sum { color: var(--ink-58); font-size: 0.92rem; margin: 0; }
.card .card-go {
  margin-top: 16px; font-family: var(--sans); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; font-size: 0.64rem; color: var(--ink-40);
}
.card:hover .card-go { color: var(--teal); }

/* ---- mobile drawer ---- */
.scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 70;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(82vw, 320px); z-index: 80;
  background: var(--paper); border-right: 1px solid var(--line); padding: 22px var(--gutter);
  transform: translateX(-100%); transition: transform 0.24s ease; overflow-y: auto;
}
.drawer .drawer-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.drawer .close-btn {
  width: 34px; height: 34px; border: 1px solid var(--line); background: transparent;
  color: var(--ink-58); cursor: pointer; font-size: 1.1rem; line-height: 1;
  border-radius: 9px; transition: color 0.2s ease, border-color 0.2s ease;
}
.drawer .close-btn:hover { color: var(--teal-text, var(--teal)); border-color: var(--teal-rim, var(--teal)); }
body.nav-open { overflow: hidden; }
body.nav-open .scrim { opacity: 1; pointer-events: auto; }
body.nav-open .drawer { transform: translateX(0); }

@media (max-width: 1080px) {
  .shell.with-toc { grid-template-columns: 232px minmax(0, 1fr); }
  aside.toc { display: none; }
}
@media (max-width: 860px) {
  .shell, .shell.with-toc { grid-template-columns: 1fr; gap: 0; }
  aside.side { display: none; }
  .menu-btn { display: inline-flex; }
  .nav-link.hide-sm { display: none; }
  .pager { grid-template-columns: 1fr; }
}
