/* The Twistor's Engineer. Twistor blueprint language, teal accent.
 * Dark default; light via data-theme="light". Teal is never text on light: use --brand-ink. */
:root {
  --bg: #151414; --bg-2: #1a1917; --bg-3: #22211e;
  --line: rgba(235, 233, 225, 0.09); --line-2: rgba(235, 233, 225, 0.16); --line-3: rgba(235, 233, 225, 0.28);
  --text: #ebe9e1; --bright: #fbfaf4; --muted: #a29f95;
  --brand: #5af8dc; --brand-hi: #8cfbe6; --brand-lo: #36e6c7; --brand-on: #151414;
  --brand-ink: #7ef9e3; --brand-soft: rgba(90, 248, 220, 0.13);
  --hover: rgba(235, 233, 225, 0.06);
  --node: 7px; --cut: 14px; --strand: 1.25px;
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ss: "ss01" 1, "cv11" 1, "cv09" 1;
  --frame: 1216px; --gutter: clamp(16px, 3.8vw, 44px);
  --r-xl: 6px; --r-lg: 4px; --r-md: 3px; --r-sm: 2px;
  --ease: cubic-bezier(0.25, 0.65, 0.15, 1); --ease-untwist: cubic-bezier(0.65, 0, 0.35, 1);
  --section-space: clamp(72px, 8.6vw, 116px);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f8f8f3; --bg-2: #efefe8; --bg-3: #e6e5dd;
  --line: rgba(42, 42, 37, 0.12); --line-2: rgba(42, 42, 37, 0.2); --line-3: rgba(42, 42, 37, 0.34);
  --text: #2a2a25; --bright: #141410; --muted: #66645b;
  --brand-ink: #00685a; --brand-soft: rgba(0, 104, 90, 0.12);
  --hover: rgba(42, 42, 37, 0.05);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 1rem/1.6 var(--font-sans); font-optical-sizing: auto; overflow-x: hidden; }
a { color: inherit; text-decoration-color: var(--line-3); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--brand-ink); }
:focus-visible { outline: 2px solid var(--brand-ink); outline-offset: 2px; }
code { font: 400 0.875em/1.5 var(--font-mono); font-variant-ligatures: none; }
h1, h2 { font-weight: 460; letter-spacing: -0.034em; font-variation-settings: "opsz" 32; font-feature-settings: var(--ss); color: var(--bright); margin: 0; text-wrap: balance; }
h1 { font-size: clamp(2.5rem, 6vw, 4.6rem); line-height: 1.02; letter-spacing: -0.045em; }
h2 { font-size: clamp(1.9rem, 3.6vw, 3.1rem); line-height: 1.06; }
h3 { font-weight: 560; font-size: 1.0625rem; letter-spacing: -0.01em; margin: 0; color: var(--bright); }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -48px; z-index: 20; padding: 8px 12px; background: var(--brand); color: var(--brand-on); border-radius: var(--r-md); font: 500 13px var(--font-mono); }
.skip:focus { top: 12px; }
.frame { width: 100%; max-width: var(--frame); margin: 0 auto; padding: 0 var(--gutter); }
.mono { font-family: var(--font-mono); }

/* ---------- atoms: eyebrow, ray, node, glyph ---------- */
.eyebrow { display: inline-flex; align-items: center; gap: 9px; font: 500 12px/1.3 var(--font-mono); color: var(--muted); margin: 0 0 16px; }
.eyebrow b { color: var(--brand-ink); font-weight: 500; }
.ray { display: inline-block; width: 12px; height: 1px; background: var(--line-3); transform: rotate(-45deg); flex-shrink: 0; }
.node { position: absolute; width: var(--node); height: var(--node); border: 1px solid var(--brand-ink); background: var(--bg); transform: rotate(45deg); transition: transform .3s var(--ease); }
.glyph { width: 36px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.25; flex-shrink: 0; }
.glyph .acc { fill: var(--brand); stroke: none; }

/* ---------- nav ---------- */
.nav { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 90%, transparent); border-bottom: 1px solid var(--line); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.nav-in { display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 560; letter-spacing: -0.01em; color: var(--bright); }
.links { display: flex; gap: 20px; margin-left: auto; font: 500 13px var(--font-mono); }
.links a { text-decoration: none; color: var(--muted); padding: 8px 0; }
.links a:hover { color: var(--text); }
.theme { font: 500 12px var(--font-mono); color: var(--text); background: none; border: 1px solid var(--line-2); border-radius: var(--r-md); height: 32px; min-width: 64px; padding: 0 10px; cursor: pointer; }
.theme:hover { border-color: var(--brand-ink); }
@media (max-width: 640px) { .links { display: none; } .theme { margin-left: auto; } }

/* ---------- hero ---------- */
.hero { position: relative; padding: clamp(56px, 9vw, 120px) 0 0; overflow: hidden; }
.lead { max-width: 640px; font-size: 1.125rem; color: var(--muted); margin: 24px 0 32px; }
.lead em { font-style: normal; color: var(--text); font-family: var(--font-mono); font-size: 0.95em; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; }
.btn { display: inline-flex; align-items: center; height: 44px; padding: 0 18px; border-radius: var(--r-md); font: 500 14px var(--font-sans); text-decoration: none; border: 1px solid transparent; transition: background .2s, border-color .2s; }
.btn-brand { background: var(--brand); color: var(--brand-on); }
.btn-brand:hover { background: var(--brand-hi); }
.btn-line { border-color: var(--line-3); color: var(--text); }
.btn-line:hover { border-color: var(--brand-ink); }
.stats { list-style: none; padding: 0; margin: 48px 0 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border-block: 1px solid var(--line); max-width: 720px; }
.stats li { background: var(--bg); padding: 16px 16px 16px 0; display: flex; flex-direction: column; }
.stats li + li { padding-left: 16px; }
.stats b { font-weight: 460; font-size: 2rem; letter-spacing: -0.03em; color: var(--bright); font-variant-numeric: tabular-nums; font-variation-settings: "opsz" 32; }
.stats span { font: 400 12px var(--font-mono); color: var(--muted); }
.bundle { display: block; width: 100%; height: clamp(90px, 14vw, 180px); margin-top: 40px; }
.bundle path { fill: none; stroke-width: var(--strand); vector-effect: non-scaling-stroke; }
.bundle .tg { stroke: var(--line-3); }
.bundle .st { stroke: var(--brand); stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 0.9s var(--ease-untwist) forwards; animation-delay: calc(0.35s + var(--i) * 0.12s); }
:root[data-theme="light"] .bundle .st { stroke: var(--brand-ink); }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- sections ---------- */
.sec { padding-top: var(--section-space); }
.head { display: grid; grid-template-columns: 7fr 5fr; column-gap: 40px; align-items: end; margin-bottom: 36px; }
.head .eyebrow { grid-column: 1 / -1; }
.sub { margin: 0; color: var(--muted); }
@media (max-width: 860px) { .head { grid-template-columns: 1fr; row-gap: 14px; } }

/* plate: hairline box, one 14px chamfer top-right, one node bottom-left */
.plate { position: relative; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--bg-2); padding: clamp(18px, 3vw, 28px);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%); }
.plate::before { content: ""; position: absolute; top: -1px; right: -1px; width: var(--cut); height: var(--cut);
  background: linear-gradient(to top right, transparent calc(50% - 0.5px), var(--line-2) calc(50% - 0.5px) calc(50% + 0.5px), transparent calc(50% + 0.5px)); }
.plate > .node { left: 10px; bottom: 10px; }
.cmds { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-md); }
.cmds li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 12px; background: var(--bg); padding: 10px 10px 10px 14px; }
.cmds code { overflow-x: auto; white-space: nowrap; color: var(--bright); padding: 4px 0; }
.step { font: 500 12px var(--font-mono); color: var(--brand-ink); }
.copy { font: 500 12px var(--font-mono); background: none; color: var(--text); border: 1px solid var(--line-2); border-radius: var(--r-sm); height: 32px; padding: 0 10px; cursor: pointer; }
.copy:hover { border-color: var(--brand-ink); }
.copy[data-done] { border-color: var(--brand-ink); color: var(--brand-ink); }
.note { margin: 18px 0 0 22px; font-size: 0.9rem; color: var(--muted); overflow-wrap: anywhere; }
.note code { color: var(--text); }

/* lattice: 1px gaps */
.lattice { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.lattice > * { background: var(--bg); min-width: 0; }
.lattice-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 960px) { .lattice-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .lattice-3 { grid-template-columns: minmax(0, 1fr); } }
.skills a { position: relative; display: grid; grid-template-columns: auto 1fr; column-gap: 12px; row-gap: 6px; height: 100%; padding: 20px; text-decoration: none; transition: background .2s; }
.skills a:hover, .skills a[aria-current] { background: var(--hover); }
.skills .idx { font: 500 12px var(--font-mono); color: var(--brand-ink); grid-row: 1; }
.skills .node { position: static; margin-top: 6px; justify-self: end; grid-column: 2; grid-row: 1; }
.skills a[aria-current] .node, .skills a:hover .node { background: var(--brand); border-color: var(--brand); transform: rotate(0deg); }
.skills h3 { grid-column: 1 / -1; font-family: var(--font-mono); font-weight: 500; font-size: 0.95rem; letter-spacing: 0; }
.skills p { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 0.925rem; line-height: 1.5; }
.skills .count { grid-column: 1 / -1; font: 400 12px var(--font-mono); color: var(--muted); margin-top: 6px; }
.extras li { padding: 20px; }
.extras .kind { font: 500 11px var(--font-mono); color: var(--brand-ink); text-transform: lowercase; }
.extras h3 { margin: 6px 0 8px; }
.extras h3 code { font-size: 1rem; }
.extras p { margin: 0; color: var(--muted); font-size: 0.925rem; }

/* filters: square chips, radius 2 */
.filters { border: 0; margin: 0 0 20px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm); font: 500 12px var(--font-mono); color: var(--muted); cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip .n { color: var(--muted); opacity: 0.8; font-variant-numeric: tabular-nums; }
.chip:hover { color: var(--text); border-color: var(--line-3); }
.chip:has(input:checked) { background: var(--brand); border-color: var(--brand); color: var(--brand-on); }
.chip:has(input:checked) .n { color: var(--brand-on); }
.chip:has(input:focus-visible) { outline: 2px solid var(--brand-ink); outline-offset: 2px; }

/* rules ledger: before / after / why */
.ledger { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.rule { display: grid; grid-template-columns: 200px minmax(0, 1fr) minmax(0, 1fr); column-gap: 28px; row-gap: 6px; padding: 18px 0; border-bottom: 1px dashed var(--line-2); }
.rule[hidden] { display: none; }
.rn { font: 400 12px/1.5 var(--font-mono); color: var(--muted); grid-row: span 2; padding-top: 3px; overflow-wrap: anywhere; }
.rn b { display: block; font-weight: 500; color: var(--brand-ink); font-size: 13px; }
.before, .after { margin: 0; line-height: 1.5; }
.before { color: var(--muted); }
.after { color: var(--bright); }
.tag { display: block; font: 500 11px var(--font-mono); margin-bottom: 4px; color: var(--muted); }
.after .tag { color: var(--brand-ink); }
.after .tag::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 7px; background: var(--brand-ink); transform: rotate(45deg); vertical-align: 1px; }
.why { grid-column: 2 / -1; margin: 4px 0 0; font-size: 0.875rem; color: var(--muted); }
.src a { font: 500 11px var(--font-mono); color: var(--brand-ink); text-decoration: none; border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 1px 5px; margin-left: 2px; white-space: nowrap; }
.src a:hover { border-color: var(--brand-ink); }
@media (max-width: 860px) {
  .rule { grid-template-columns: minmax(0, 1fr); }
  .rn { grid-row: auto; }
  .rn b { display: inline; margin-left: 6px; }
  .why { grid-column: 1; }
}

/* companions */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); }
.comp { width: 100%; border-collapse: collapse; font-size: 0.925rem; min-width: 520px; }
.comp th { text-align: left; font: 500 12px var(--font-mono); color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line-2); background: var(--bg-2); }
.comp td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.comp tr:last-child td { border-bottom: 0; }
.comp td:first-child { font-family: var(--font-mono); font-size: 0.875rem; white-space: nowrap; }
.comp td:first-child a { color: var(--brand-ink); text-decoration: none; }
.comp td:last-child { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--muted); white-space: nowrap; }

/* footer */
.foot { margin-top: var(--section-space); border-top: 1px solid var(--line); padding: 28px 0 40px; }
.foot-in { display: flex; flex-wrap: wrap; gap: 12px 32px; justify-content: space-between; align-items: center; }
.foot p { margin: 0; color: var(--muted); font-size: 0.875rem; }
.foot .tag { display: inline-flex; align-items: center; gap: 10px; font: inherit; color: var(--text); margin: 0; }
.foot .mono { font-size: 12px; }
.sep { color: var(--line-3); margin: 0 6px; }

/* decode: unresolved glyphs in mono, teal ink */
/* unresolved text keeps its width so the line never reflows */
.dc-rest { visibility: hidden; }
.dc { font-family: var(--font-mono); color: var(--brand-ink); font-weight: 400; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .bundle .st { animation: none; stroke-dashoffset: 0; }
  .node, .btn, .skills a { transition: none; }
}

/* benchmark */
.bench { min-width: 0; }
.bench td, .bench td:last-child { font: 0.875rem var(--font-mono); vertical-align: middle; }
.bench td:first-child { white-space: normal; overflow-wrap: anywhere; }
.bench td:nth-child(2) { color: var(--brand-ink); }

/* install groups */
#install .kind { font: 500 12px var(--font-mono); color: var(--brand-ink); margin: 18px 0 8px; }
#install .kind:first-child { margin-top: 0; }
