@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/bricolage.woff2") format("woff2-variations");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --paper: #F5F7F4;
  --paper-deep: #E7ECE6;
  --ledger: #0E4B43;
  --ledger-soft: #D5E5DF;
  --ink: #17212B;
  --ink-soft: #4A5661;
  --line: #CBD3CE;
  --error: #B8322B;
  --highlight: #F3D35B;
  --code-bg: #17212B;
  --code-fg: #E4EAE2;

  --sans: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Menlo, monospace;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.625rem;
  --step-3: 2.125rem;
  --step-4: clamp(2.5rem, 1.6rem + 3.6vw, 4.25rem);

  --gutter: clamp(1.25rem, 4vw, 3rem);
  --measure: 68ch;
  --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 1.5rem;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.55;
  font-optical-sizing: auto;
}

a { color: var(--ledger); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--ledger);
  outline-offset: 2px;
  border-radius: 3px;
}

code, pre { font-family: var(--mono); font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
:not(pre) > code {
  font-size: 0.88em;
  background: var(--paper-deep);
  padding: 0.08em 0.32em;
  border-radius: 4px;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  z-index: 10;
}
.skip:focus { top: 1rem; }

/* ------------------------------------------------------------ header and footer */

header.site {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 1.25rem var(--gutter);
  border-bottom: 1px solid var(--line);
}

.wordmark {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--ink);
  text-decoration: none;
}

header.site nav { display: flex; gap: 1.4rem; flex-wrap: wrap; }
header.site nav a { color: var(--ink); text-decoration: none; font-weight: 500; }
header.site nav a:hover { color: var(--ledger); text-decoration: underline; }

footer.site {
  margin-top: 5rem;
  padding: 2rem var(--gutter) 3rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: var(--step--1);
}
footer.site p { margin: 0.3rem 0; max-width: var(--measure); }

/* ------------------------------------------------------------ code panes */

.pane {
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
}

.pane-title {
  margin: 0;
  padding: 0.6rem 1rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: #A6B3BB;
  border-bottom: 1px solid #2A3743;
}

pre {
  margin: 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-size: 0.84rem;
  line-height: 1.6;
  tab-size: 4;
}
pre.shiki { background: var(--code-bg) !important; }

.terminal pre { color: var(--code-fg); }
.dim { color: #8896A0; }
.good { color: #8ED4C2; font-weight: 700; }
.bad { color: #FF8A7F; font-weight: 700; }

/* ------------------------------------------------------------ landing */

.home main { padding: 0 var(--gutter); }

.hero {
  display: grid;
  gap: 2.5rem;
  padding: clamp(2.5rem, 7vw, 5.5rem) 0 3rem;
  max-width: 1240px;
  margin: 0 auto;
}

.hero h1 {
  font-size: var(--step-4);
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-weight: 780;
  margin: 0;
  max-width: 15ch;
}

.lede {
  font-size: var(--step-1);
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 46ch;
  margin: 1.4rem 0 0;
}

.actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin: 2rem 0 0; }

.button {
  display: inline-block;
  padding: 0.7rem 1.15rem;
  border-radius: 8px;
  border: 1.5px solid var(--ink);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}
.button:hover { background: var(--paper-deep); text-decoration: none; }
.button.primary { background: var(--ledger); border-color: var(--ledger); color: var(--paper); }
.button.primary:hover { background: #0A3A34; }

/* The demo: the rule, its build, and the one character that breaks it. */
.demo {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 0.75rem;
}
.demo pre, .feature pre { font-size: 0.78rem; }
.demo .terminal { display: flex; flex-direction: column; }
.demo .output { flex: 1; }
.demo figcaption {
  grid-column: 1 / -1;
  color: var(--ink-soft);
  font-size: var(--step--1);
}

mark.flip {
  background: transparent;
  color: inherit;
  border-radius: 3px;
  padding: 0 0.1em;
  transition: background-color 160ms ease, color 160ms ease;
}
.demo[data-state="broken"] mark.flip {
  background: var(--highlight);
  color: var(--ink);
}

.flip-button {
  margin: 0 1rem 1rem;
  align-self: flex-start;
  font: inherit;
  font-weight: 600;
  font-size: var(--step--1);
  padding: 0.6rem 0.95rem;
  border-radius: 8px;
  border: 0;
  background: var(--highlight);
  color: var(--ink);
  cursor: pointer;
}
.flip-button code { background: rgba(23, 33, 43, 0.12); }
.flip-button:hover { background: #F7DE80; }
.flip-button:focus-visible { outline-color: var(--highlight); outline-offset: 3px; }
.demo[data-state="broken"] .flip-button { background: #E4EAE2; }

.feature {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: start;
  max-width: 1240px;
  margin: 0 auto;
  padding: 3.5rem 0;
  border-top: 1px solid var(--line);
}

.home h2 {
  font-size: var(--step-3);
  line-height: 1.1;
  letter-spacing: -0.025em;
  font-weight: 720;
  margin: 0 0 1rem;
}
.copy p, .copy li { max-width: 52ch; }
.copy p { margin: 0 0 1rem; }

.facts { padding-left: 1.2rem; margin: 0 0 1.25rem; }
.facts li { margin-bottom: 0.7rem; padding-left: 0.2rem; }
.facts li::marker { color: var(--ledger); }

.tabs [role="tablist"] { display: flex; gap: 0.25rem; margin-bottom: 0.5rem; }
.tabs [role="tab"] {
  font: inherit;
  font-weight: 600;
  padding: 0.4rem 0.9rem;
  border-radius: 7px;
  border: 1.5px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}
.tabs [role="tab"][aria-selected="true"] { border-color: var(--ink); color: var(--ink); }

.paths, .start {
  max-width: 1240px;
  margin: 0 auto;
  padding: 3.5rem 0;
  border-top: 1px solid var(--line);
}
.paths dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1.75rem 2.5rem;
  margin: 1.5rem 0 0;
}
.paths dt { font-size: var(--step-1); font-weight: 700; margin-bottom: 0.3rem; }
.paths dd { margin: 0; color: var(--ink-soft); }

.start > p { max-width: 60ch; color: var(--ink-soft); }
.start > pre, .start-columns pre { border-radius: var(--radius); }
.start h3 { font-size: var(--step-1); margin: 2.5rem 0 0.75rem; }
.start-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); gap: 0 2.5rem; }

/* ------------------------------------------------------------ docs */

.docs-shell {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr) 13rem;
  gap: 3rem;
  max-width: 1360px;
  margin: 0 auto;
  padding: 2.5rem var(--gutter) 0;
}

.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar .tree { position: sticky; top: 1.5rem; max-height: calc(100vh - 3rem); overflow-y: auto; }
.sidebar .group { display: block; font-weight: 700; margin: 1.4rem 0 0.35rem; }
.sidebar > ul > li:first-child .group, .menu ul > li:first-child .group { margin-top: 0; }
.sidebar ul ul a {
  display: block;
  padding: 0.22rem 0.7rem;
  margin-left: -0.7rem;
  color: var(--ink-soft);
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.97rem;
}
.sidebar ul ul a:hover { color: var(--ink); background: var(--paper-deep); }
.sidebar a[aria-current="page"] { color: var(--ledger); background: var(--ledger-soft); font-weight: 600; }
.menu { display: none; }

.prose { max-width: var(--measure); }
.prose h1 { font-size: var(--step-3); line-height: 1.1; letter-spacing: -0.03em; font-weight: 760; margin: 0 0 1.25rem; }
.prose h2 { font-size: var(--step-2); line-height: 1.2; letter-spacing: -0.02em; margin: 2.75rem 0 0.75rem; }
.prose h3 { font-size: var(--step-1); margin: 2rem 0 0.5rem; }
.prose h4 { font-size: var(--step-0); margin: 1.5rem 0 0.5rem; }
.prose .anchor { color: inherit; text-decoration: none; }
.prose .anchor:hover::after { content: "#"; color: var(--ink-soft); margin-left: 0.35em; font-weight: 400; }
.prose p, .prose ul, .prose ol { margin: 0 0 1rem; }
.prose li + li { margin-top: 0.3rem; }
.prose pre { border-radius: var(--radius); margin: 0 0 1.25rem; }
.prose .code { position: relative; }
.prose blockquote { margin: 0 0 1rem; padding: 0.2rem 1rem; border-left: 3px solid var(--line); color: var(--ink-soft); }

.table { overflow-x: auto; margin: 0 0 1.25rem; }
.prose table { border-collapse: collapse; font-size: 0.95rem; min-width: 100%; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: 0.5rem 0.9rem 0.5rem 0; border-bottom: 1px solid var(--line); }
.prose th { font-weight: 700; border-bottom-width: 2px; }

.copy-button {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font: inherit;
  font-size: 0.78rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  border: 1px solid #3A4855;
  background: #223040;
  color: #C9D3CC;
  cursor: pointer;
  opacity: 0;
}
.code:hover .copy-button, .copy-button:focus-visible, .copy-button[data-done] { opacity: 1; }

.pager { display: flex; justify-content: space-between; gap: 1rem; margin: 3rem 0 0; max-width: var(--measure); }
.pager a { display: flex; flex-direction: column; text-decoration: none; padding: 0.8rem 1rem; border: 1px solid var(--line); border-radius: 8px; font-weight: 600; }
.pager a span { font-weight: 400; font-size: var(--step--1); color: var(--ink-soft); }
.pager .next { text-align: right; margin-left: auto; }
.pager a:hover { border-color: var(--ledger); }
.edit { font-size: var(--step--1); margin-top: 1.5rem; }

.toc { position: sticky; top: 1.5rem; align-self: start; font-size: 0.9rem; }
.toc p { font-weight: 700; margin: 0 0 0.5rem; }
.toc ul { list-style: none; padding: 0; margin: 0; }
.toc li { margin: 0.35rem 0; }
.toc a { color: var(--ink-soft); text-decoration: none; }
.toc a:hover { color: var(--ledger); text-decoration: underline; }

.index .groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.5rem 2rem; margin-top: 2rem; }
.index .groups h2 { font-size: var(--step-1); margin: 1rem 0 0.4rem; }
.index .groups ul { padding-left: 1.1rem; }

main.missing { max-width: var(--measure); margin: 0 auto; padding: 5rem var(--gutter); }
main.missing h1 { font-size: var(--step-3); letter-spacing: -0.03em; }

/* ------------------------------------------------------------ small screens */

@media (max-width: 1180px) {
  .docs-shell { grid-template-columns: 14rem minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 960px) {
  .demo, .feature { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 820px) {
  .docs-shell { grid-template-columns: minmax(0, 1fr); gap: 1rem; padding-top: 1.25rem; }
  .sidebar .tree { display: none; }
  .menu { display: block; border: 1px solid var(--line); border-radius: 8px; padding: 0.6rem 0.9rem; }
  .menu summary { font-weight: 600; cursor: pointer; }
  .menu > ul { margin-top: 0.75rem; }
  pre { font-size: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* The build output wraps rather than scroll, so the whole error stays in view. */
.demo .output pre { white-space: pre-wrap; overflow-wrap: anywhere; }
