/* Page scaffolding: header, footer, containers, docs grid */

.container {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--sp-5);
}

.page {
  padding-block: var(--sp-7) var(--sp-9);
}

.page-narrow {
  max-width: var(--container-narrow);
  margin-inline: auto;
  padding-inline: var(--sp-5);
}

/* ---- Header / nav ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: var(--border);
}

.site-header__inner {
  max-width: var(--container);
  margin-inline: auto;
  padding: var(--sp-3) var(--sp-5);
  display: flex;
  align-items: center;
  gap: var(--sp-5);
}

.brand {
  font-family: var(--font-sans);
  font-weight: var(--fw-semibold);
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}

.brand__mark {
  width: 1.15rem;
  height: 1.15rem;
  color: var(--accent);
}

.nav {
  font-family: var(--font-sans);
  font-size: var(--fs-ui);
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  margin-left: auto;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: var(--fw-medium);
  transition: color 0.15s ease;
}

.nav a:hover,
.nav a[aria-current] {
  color: var(--ink);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius);
  border: var(--border);
  color: var(--muted);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--rule-strong);
}

.theme-toggle svg {
  width: 1.05rem;
  height: 1.05rem;
}
.theme-toggle .icon-sun {
  display: none;
}
:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}
:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun {
    display: block;
  }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon {
    display: none;
  }
}

/* ---- Footer ---- */
.site-footer {
  border-top: var(--border);
  margin-top: var(--sp-9);
  padding-block: var(--sp-6) var(--sp-7);
  font-family: var(--font-sans);
  font-size: var(--fs-small);
  color: var(--muted);
}

.site-footer__inner {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--sp-5);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-5) var(--sp-6);
  justify-content: space-between;
}

.site-footer a {
  color: var(--muted);
}
.site-footer a:hover {
  color: var(--ink);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
}

.footer-disclaimer {
  max-width: 40rem;
  line-height: 1.5;
}

/* ---- Prose column ---- */
.prose {
  max-width: var(--measure);
}

.prose > * + * {
  margin-top: var(--sp-4);
}

.prose h2 {
  margin-top: var(--sp-7);
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: var(--border);
}

.prose h3 {
  margin-top: var(--sp-6);
  margin-bottom: var(--sp-2);
}

.prose h4 {
  margin-top: var(--sp-5);
  margin-bottom: var(--sp-2);
  font-family: var(--font-sans);
}

.prose :is(h2, h3, h4) + * {
  margin-top: 0;
}

.prose img {
  border-radius: var(--radius);
  border: var(--border);
}

/* ---- Docs layout: sidebar | content | toc ---- */
.docs {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--sp-5);
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: var(--sp-7);
  align-items: start;
  padding-block: var(--sp-6) var(--sp-9);
}

@media (min-width: 68rem) {
  .docs {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  }
}

.docs__main {
  min-width: 0;
}

/* ---- Sidebar ---- */
.sidebar {
  position: sticky;
  top: calc(var(--sp-6) + 3rem);
  align-self: start;
  font-family: var(--font-sans);
  font-size: var(--fs-ui);
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}

.sidebar__group + .sidebar__group {
  margin-top: var(--sp-5);
}

.sidebar__title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: var(--fw-semibold);
  color: var(--faint);
  margin-bottom: var(--sp-2);
}

.sidebar__list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar__list li {
  margin: 0;
}

.sidebar__link {
  display: block;
  padding: 0.28rem 0 0.28rem var(--sp-3);
  border-left: 2px solid var(--rule);
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.sidebar__link:hover {
  color: var(--ink);
  border-left-color: var(--rule-strong);
}

.sidebar__link[aria-current="page"] {
  color: var(--accent-ink);
  border-left-color: var(--accent);
  font-weight: var(--fw-medium);
}

/* ---- On-page table of contents ---- */
.toc {
  position: sticky;
  top: calc(var(--sp-6) + 3rem);
  align-self: start;
  font-family: var(--font-sans);
  font-size: var(--fs-small);
  display: none;
}

@media (min-width: 68rem) {
  .toc {
    display: block;
  }
}

.toc__title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: var(--fw-semibold);
  color: var(--faint);
  margin-bottom: var(--sp-2);
}

.toc a {
  display: block;
  padding: 0.2rem 0;
  color: var(--muted);
  text-decoration: none;
  line-height: 1.35;
}
.toc a:hover {
  color: var(--ink);
}
.toc__link--h3 {
  padding-left: var(--sp-3);
  font-size: 0.8rem;
}

/* Mobile: collapse sidebar into a disclosure at the top */
.sidebar-mobile {
  display: none;
}

@media (max-width: 60rem) {
  .docs {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    display: none;
  }
  .toc {
    display: none;
  }
  .sidebar-mobile {
    display: block;
    font-family: var(--font-sans);
    margin-bottom: var(--sp-5);
    border: var(--border);
    border-radius: var(--radius);
  }
  .sidebar-mobile > summary {
    padding: var(--sp-3) var(--sp-4);
    cursor: pointer;
    font-weight: var(--fw-medium);
    font-size: var(--fs-ui);
    list-style: none;
  }
  .sidebar-mobile[open] > summary {
    border-bottom: var(--border);
  }
  .sidebar-mobile .sidebar {
    position: static;
    max-height: none;
    padding: var(--sp-4);
  }
}
