/* Documentation layout. Loaded after home.css, which supplies the tokens, the nav
   and footer styling, and the base typography. Nothing here restyles the chrome. */

.doc-page { padding-top: 72px; } /* the nav is fixed at 72px */

.doc-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 40px;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr) 208px;
  gap: 48px;
  align-items: start;
}

/* ---------- sidebar ---------- */

.doc-sidebar {
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 72px);
  overflow-y: auto;
  padding: 32px 0 64px;
  scrollbar-width: thin;
}

.doc-search-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  margin-bottom: 24px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: rgba(15, 16, 21, 0.6);
  color: var(--fog);
  font-size: 13px;
  transition: border-color 0.2s var(--ease-out), color 0.2s var(--ease-out);
}
.doc-search-btn:hover { border-color: rgba(246, 234, 198, 0.2); color: var(--cream); }
.doc-search-btn kbd {
  border: 1px solid var(--hairline);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 11px;
  color: var(--fog);
}
.doc-search-btn.wide { max-width: 420px; margin: 28px 0 0; }

.doc-nav-section { margin-bottom: 4px; }
.doc-nav-section > summary {
  list-style: none;
  cursor: pointer;
  padding: 7px 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fog);
}
.doc-nav-section > summary::-webkit-details-marker { display: none; }
.doc-nav-section > summary::after {
  content: "+";
  float: right;
  color: var(--ink-600);
}
.doc-nav-section[open] > summary::after { content: "–"; }
.doc-nav-section > summary:hover { color: var(--gold-200); }

.doc-nav ul { list-style: none; margin: 2px 0 14px; padding: 0; }
.doc-nav li a {
  display: block;
  padding: 6px 12px;
  margin-left: -12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: rgba(243, 239, 228, 0.62);
  transition: color 0.15s var(--ease-out), background 0.15s var(--ease-out);
}
.doc-nav li a:hover { color: var(--cream); background: rgba(246, 234, 198, 0.05); }
.doc-nav li a[aria-current="page"] {
  color: var(--gold-200);
  background: rgba(220, 176, 75, 0.08);
  font-weight: 600;
}

/* ---------- main column ---------- */

.doc-main { padding: 32px 0 96px; min-width: 0; }

.doc-crumbs { font-size: 11px; letter-spacing: 0.08em; color: var(--text-tertiary); }
.doc-crumbs a { color: var(--fog); }
.doc-crumbs a:hover { color: var(--gold-200); }
.doc-crumb-section { display: inline-flex; align-items: center; gap: 7px; }
.doc-crumb-section svg { width: 14px; height: 14px; color: var(--gold-400); }

.doc-body { max-width: 76ch; }
.doc-body h1 {
  font-family: var(--font-display);
  font-size: clamp(32px, 4vw, 44px);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 14px 0 0;
}
.doc-lede { color: var(--text-secondary); font-size: 17px; margin-top: 14px; }
.doc-updated { font-size: 11px; letter-spacing: 0.08em; color: var(--text-tertiary); margin-top: 18px; }

.doc-body h2 {
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: -0.01em;
  margin: 56px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--hairline);
  scroll-margin-top: 96px;
}
.doc-body h3 {
  font-size: 17px;
  font-weight: 650;
  margin: 34px 0 0;
  scroll-margin-top: 96px;
}
.doc-body h4 { font-size: 15px; font-weight: 650; margin: 26px 0 0; color: var(--text-secondary); }

.doc-body p { margin-top: 16px; color: var(--text-secondary); }
.doc-body strong { color: var(--cream); font-weight: 620; }
.doc-body a { color: var(--gold-300); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.doc-body a:hover { color: var(--gold-200); }

/* The anchor is only revealed on hover of its heading, so it never competes with the
   heading itself for attention. It stays focusable for keyboard users. */
.doc-anchor {
  margin-left: 10px;
  color: var(--ink-600);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s var(--ease-out);
}
.doc-body h2:hover .doc-anchor,
.doc-body h3:hover .doc-anchor,
.doc-anchor:focus-visible { opacity: 1; }

.doc-body ul, .doc-body ol { margin: 16px 0 0 20px; color: var(--text-secondary); }
.doc-body li { margin-top: 8px; }
.doc-body li > ul, .doc-body li > ol { margin-top: 8px; }
.doc-body li::marker { color: var(--gold-500); }

.doc-body img {
  margin-top: 24px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
}

/* Section breaks get the brand waveform instead of a bare hairline — five small
   gold bars between two fading rules. */
.doc-body hr {
  border: 0;
  margin: 48px 0 0;
  height: 14px;
  background:
    center / auto 14px no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 44 14' width='44' height='14'%3E%3Cg fill='%23CD9A33' fill-opacity='0.55'%3E%3Crect x='0' y='4' width='3' height='6' rx='1.5'/%3E%3Crect x='10' y='2' width='3' height='10' rx='1.5'/%3E%3Crect x='20' y='0' width='3' height='14' rx='1.5'/%3E%3Crect x='30' y='2' width='3' height='10' rx='1.5'/%3E%3Crect x='40' y='4' width='3' height='6' rx='1.5'/%3E%3C/g%3E%3C/svg%3E"),
    linear-gradient(90deg, transparent, var(--hairline) 18%, var(--hairline) 38%, transparent 42%,
                    transparent 58%, var(--hairline) 62%, var(--hairline) 82%, transparent) center / 100% 1px no-repeat;
}

.doc-body blockquote {
  margin-top: 20px;
  padding: 2px 0 2px 18px;
  border-left: 2px solid var(--gold-500);
  color: var(--text-muted);
  font-style: italic;
}

.doc-body pre {
  margin-top: 20px;
  padding: 18px 20px;
  background: var(--ink-850);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  overflow-x: auto;
  position: relative;
}
.doc-body pre code { font-family: var(--font-mono); font-size: 13px; line-height: 1.7; color: var(--text-secondary); }
.doc-body :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(246, 234, 198, 0.07);
  color: var(--gold-100);
}

.doc-copy {
  position: absolute;
  top: 10px; right: 10px;
  padding: 4px 9px;
  border: 1px solid var(--hairline);
  border-radius: 7px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--fog);
  opacity: 0;
  transition: opacity 0.15s var(--ease-out), color 0.15s var(--ease-out);
}
.doc-body pre:hover .doc-copy, .doc-copy:focus-visible { opacity: 1; }
.doc-copy:hover { color: var(--gold-200); }

.doc-body table {
  width: 100%;
  margin-top: 22px;
  border-collapse: collapse;
  font-size: 14px;
  display: block;
  overflow-x: auto;
}
.doc-body th, .doc-body td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
  color: var(--text-secondary);
}
.doc-body th {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fog);
}
.doc-body tbody tr { transition: background 0.15s var(--ease-out); }
.doc-body tbody tr:nth-child(even) { background: rgba(246, 234, 198, 0.02); }
.doc-body tbody tr:hover { background: rgba(220, 176, 75, 0.05); }

/* Keycap chips — the app's bordered-keycap treatment ("L Ctrl", "R Ctrl"),
   translated to the site palette. Produced by [[Key]] in the markdown. */
.doc-body kbd {
  display: inline-block;
  padding: 0 7px 1px;
  border: 1px solid rgba(246, 234, 198, 0.22);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: rgba(246, 234, 198, 0.045);
  font-family: var(--font-mono);
  font-size: 0.8em;
  line-height: 1.7;
  color: var(--cream);
  white-space: nowrap;
}

/* Off-site links get a small ↗ so readers know they are leaving the docs. */
.doc-body a[target="_blank"]::after {
  content: "\2197";
  font-size: 0.72em;
  margin-left: 2px;
  vertical-align: 0.2em;
  text-decoration: none;
  display: inline-block;
  color: var(--gold-400);
}

/* ---------- callouts ---------- */

.callout {
  margin-top: 22px;
  padding: 16px 18px;
  border: 1px solid var(--hairline);
  border-left-width: 2px;
  border-radius: 10px;
  background: rgba(15, 16, 21, 0.7);
}
.callout p { margin-top: 0; }
.callout p + p { margin-top: 8px; }
.callout-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.callout-title svg { flex: none; }
.callout-note { border-left-color: var(--fog); }
.callout-note .callout-title { color: var(--fog); }
.callout-tip, .callout-important { border-left-color: var(--gold-400); }
.callout-tip .callout-title, .callout-important .callout-title { color: var(--gold-300); }
.callout-warning, .callout-caution { border-left-color: #E0794B; }
.callout-warning .callout-title, .callout-caution .callout-title { color: #E0794B; }

/* ---------- pager ---------- */

.doc-pager {
  max-width: 76ch;
  margin-top: 64px;
  padding-top: 28px;
  border-top: 1px solid var(--hairline);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.doc-pager-link {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  transition: border-color 0.2s var(--ease-out), transform 0.2s var(--spring-settle);
}
.doc-pager-link:hover { border-color: rgba(220, 176, 75, 0.35); transform: translateY(-2px); }
.doc-pager-link span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  transition: color 0.2s var(--ease-out);
}
.doc-pager-link.next span { justify-content: flex-end; }
.doc-pager-link span svg { transition: transform 0.2s var(--spring-settle); }
.doc-pager-link:hover span { color: var(--gold-300); }
.doc-pager-link.prev:hover span svg { transform: translateX(-3px); }
.doc-pager-link.next:hover span svg { transform: translateX(3px); }
.doc-pager-link strong { font-weight: 600; color: var(--cream); }
.doc-pager-link.next { text-align: right; align-items: flex-end; }

/* ---------- table of contents ---------- */

.doc-toc {
  position: sticky;
  top: 96px;
  padding: 36px 0 64px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}
.doc-toc-head { font-size: 10.5px; letter-spacing: 0.1em; color: var(--text-tertiary); }
.doc-toc ul { list-style: none; margin: 14px 0 0; padding: 0; border-left: 1px solid var(--hairline); }
.doc-toc li a {
  display: block;
  padding: 5px 0 5px 14px;
  margin-left: -1px;
  border-left: 1px solid transparent;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-tertiary);
  transition: color 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
}
.doc-toc li.lvl-3 a { padding-left: 26px; }
.doc-toc li a:hover { color: var(--cream); }
.doc-toc li a.active { color: var(--gold-200); border-left-color: var(--gold-400); }

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

.doc-landing { padding-top: 88px; padding-bottom: 120px; position: relative; }

/* Soft gold wash behind the hero — same treatment as the homepage, dialled down. */
.doc-home::before {
  content: "";
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: min(900px, 100vw);
  height: 480px;
  background: radial-gradient(ellipse 60% 55% at 50% 0%, rgba(205, 154, 51, 0.1), transparent 70%);
  pointer-events: none;
}

.doc-wave { display: block; margin-bottom: 26px; }
.doc-wave rect { fill: var(--gold-400); }
.doc-wave rect:nth-child(1), .doc-wave rect:nth-child(7) { opacity: 0.35; }
.doc-wave rect:nth-child(2), .doc-wave rect:nth-child(6) { opacity: 0.55; }
.doc-wave rect:nth-child(3), .doc-wave rect:nth-child(5) { opacity: 0.8; }

.doc-kicker { font-size: 11px; letter-spacing: 0.14em; color: var(--gold-400); }
.doc-landing h1 {
  font-family: var(--font-display);
  font-size: clamp(38px, 5.4vw, 62px);
  line-height: 1.06;
  letter-spacing: -0.025em;
  margin-top: 18px;
}
.doc-landing .doc-lede { max-width: 60ch; margin-top: 18px; font-size: 18px; }

.doc-cards {
  margin-top: 56px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 16px;
}
.doc-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 24px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: rgba(15, 16, 21, 0.5);
  transition: border-color 0.25s var(--ease-out), transform 0.25s var(--spring-settle);
}
.doc-card:hover { border-color: rgba(220, 176, 75, 0.35); transform: translateY(-3px); }
.doc-card-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(220, 176, 75, 0.18);
  border-radius: 10px;
  background: rgba(220, 176, 75, 0.06);
  color: var(--gold-300);
  transition: border-color 0.25s var(--ease-out), background 0.25s var(--ease-out);
}
.doc-card-icon svg { width: 19px; height: 19px; }
.doc-card:hover .doc-card-icon { border-color: rgba(220, 176, 75, 0.4); background: rgba(220, 176, 75, 0.12); }
.doc-card > .mono { font-size: 11px; letter-spacing: 0.1em; color: var(--gold-300); }
.doc-card-sum { color: var(--text-secondary); font-size: 14px; flex: 1; }
.doc-card-count {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}
.doc-card-arrow {
  color: var(--gold-400);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.25s var(--ease-out), transform 0.25s var(--spring-settle);
}
.doc-card:hover .doc-card-arrow { opacity: 1; transform: none; }

/* ---------- search ---------- */

.doc-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(7, 8, 10, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 12vh 24px 24px;
}
.doc-search-overlay[hidden] { display: none; }
.doc-search-panel {
  max-width: 620px;
  margin: 0 auto;
  border: 1px solid rgba(246, 234, 198, 0.14);
  border-radius: 16px;
  background: var(--ink-850);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.9);
  overflow: hidden;
}
#doc-search-input {
  width: 100%;
  padding: 18px 22px;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  background: transparent;
  color: var(--cream);
  font-family: inherit;
  font-size: 16px;
}
#doc-search-input:focus { outline: none; }
.doc-search-results { list-style: none; margin: 0; padding: 6px; max-height: 52vh; overflow-y: auto; }
.doc-search-results li a {
  display: block;
  padding: 11px 16px;
  border-radius: 10px;
}
.doc-search-results li a:hover,
.doc-search-results li.selected a { background: rgba(246, 234, 198, 0.06); }
.doc-search-results li.selected a { box-shadow: inset 2px 0 0 var(--gold-400); }
.doc-search-results .r-title { color: var(--cream); font-size: 14px; font-weight: 600; }
.doc-search-results .r-section {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--gold-400);
}
.doc-search-results .r-icon {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.doc-search-results .r-desc { color: var(--text-tertiary); font-size: 12.5px; margin-top: 3px; }
.doc-search-results mark { background: rgba(220, 176, 75, 0.22); color: var(--gold-100); border-radius: 3px; }
.doc-search-empty { padding: 26px 22px; color: var(--text-tertiary); font-size: 13.5px; text-align: center; }
.doc-search-empty::before {
  content: "";
  display: block;
  margin: 0 auto 12px;
  width: 44px;
  height: 14px;
  opacity: 0.6;
  background: center / contain no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 44 14' width='44' height='14'%3E%3Cg fill='%23CD9A33' fill-opacity='0.55'%3E%3Crect x='0' y='4' width='3' height='6' rx='1.5'/%3E%3Crect x='10' y='2' width='3' height='10' rx='1.5'/%3E%3Crect x='20' y='0' width='3' height='14' rx='1.5'/%3E%3Crect x='30' y='2' width='3' height='10' rx='1.5'/%3E%3Crect x='40' y='4' width='3' height='6' rx='1.5'/%3E%3C/g%3E%3C/svg%3E");
}
.doc-search-hint { padding: 10px 18px; border-top: 1px solid var(--hairline); font-size: 10px; letter-spacing: 0.08em; color: var(--text-tertiary); }

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

@media (max-width: 1180px) {
  .doc-shell { grid-template-columns: 232px minmax(0, 1fr); gap: 40px; }
  .doc-toc { display: none; }
}

@media (max-width: 860px) {
  .doc-shell { display: block; padding: 0 24px; }
  .doc-sidebar {
    position: static;
    max-height: none;
    padding: 20px 0 0;
    border-bottom: 1px solid var(--hairline);
  }
  /* On phones the section list collapses behind a disclosure so the page starts at
     the content, not at 40 links. Gated on .doc-js: docs.js is what injects the
     toggle button, so without it the full list stays visible rather than vanishing. */
  .doc-js .doc-nav { display: none; }
  .doc-js .doc-sidebar.open .doc-nav { display: block; padding-bottom: 20px; }
  .doc-nav-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fog);
  }
  .doc-main { padding-top: 24px; }
  .doc-pager { grid-template-columns: 1fr; }
  .doc-landing { padding-top: 56px; }
}

@media (min-width: 861px) {
  .doc-nav-toggle { display: none; }
}
