/*
 * Docs — Desk-style knowledge-base layer on top of the Oatmeal theme.
 *
 * Consumes Oatmeal's token roles only (--canvas, --surface, --ink, --accent,
 * --card, --line, …), so retheming happens entirely in tokens.css/oatmeal.css.
 * Left unlayered on purpose: these rules win over the @layer modules blocks in
 * oatmeal.css, so a `.docs-*` block can safely refine a shared class.
 *
 * Layout: a three-column shell — category sidebar, article, on-this-page TOC —
 * that degrades to two columns (drop TOC), then one (sidebar becomes a
 * collapsible <details> drawer) as the viewport narrows.
 */

/* Sticky footer — keep the footer pinned to the viewport bottom on short pages
   (e.g. the 404 or a stub article) while still flowing below tall content. */
body.layout-oatmeal {
  display: flex;
  flex-direction: column;
  min-block-size: 100vh;
}
body.layout-oatmeal > main { flex: 1 0 auto; }
body.layout-oatmeal > .oatmeal-footer { flex-shrink: 0; }

/* ───────────────────────────── Shell / grid ───────────────────────────── */
.docs-shell {
  --docs-sidebar: 15rem;
  --docs-toc: 13rem;
  --docs-gap: clamp(1.5rem, 3vw, 3rem);

  display: grid;
  gap: var(--docs-gap);
  grid-template-columns: var(--docs-sidebar) minmax(0, 1fr) var(--docs-toc);
  align-items: start;
}
.docs-shell[data-layout="wide"] { grid-template-columns: var(--docs-sidebar) minmax(0, 1fr); }

@media (max-width: 68rem) {
  .docs-shell { grid-template-columns: var(--docs-sidebar) minmax(0, 1fr); }
  .docs-toc { display: none; }
}
@media (max-width: 52rem) {
  .docs-shell { grid-template-columns: 1fr; }
}

/* ───────────────────────────── Sidebar nav ────────────────────────────── */
.docs-nav {
  position: sticky;
  top: 6rem;
  max-block-size: calc(100vh - 7rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-inline-end: 0.5rem;
  padding-block-end: 1rem;
}
/* The <summary> is a mobile-only "Browse docs" toggle; hidden on desktop. */
.docs-nav__summary {
  align-items: center;
  background: var(--card);
  border-radius: var(--radius-pill);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  font-size: var(--text-small);
  font-weight: 600;
  gap: 0.5rem;
  list-style: none;
  margin-block-end: 1rem;
  padding: 0.6rem 1rem;
}
.docs-nav__summary::-webkit-details-marker { display: none; }
.docs-nav__summary .icon { color: var(--accent); }
.docs-nav__summary-chevron { margin-inline-start: auto; transition: transform 150ms var(--ease-out-expo); }
.docs-nav[open] .docs-nav__summary-chevron { transform: rotate(180deg); }

.docs-nav__group + .docs-nav__group { margin-block-start: 1.5rem; }
.docs-nav__group-title {
  align-items: center;
  color: var(--ink);
  display: flex;
  font-size: var(--text-x-small);
  font-weight: 600;
  gap: 0.5rem;
  letter-spacing: 0.04em;
  padding-inline: 0.75rem;
  text-transform: uppercase;
}
.docs-nav__group-title .icon { color: var(--accent); }
.docs-nav__list { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.docs-nav__link {
  border-radius: var(--radius-2);
  color: var(--ink-muted);
  display: block;
  font-size: var(--text-small);
  line-height: 1.35;
  padding: 0.4rem 0.75rem;
  text-decoration: none;
}
.docs-nav__link:hover { background: var(--card); color: var(--ink); }
.docs-nav__link[aria-current="page"] {
  background: color-mix(in oklch, var(--accent) 12%, transparent);
  color: var(--accent);
  font-weight: 600;
}

/* On desktop the sidebar body is always shown regardless of <details> state. */
@media (min-width: 52.01rem) {
  .docs-nav__summary { display: none; }
  .docs-nav__body { display: block !important; }
}
@media (max-width: 52rem) {
  .docs-nav { position: static; max-block-size: none; overflow: visible; }
}

/* ─────────────────────────────── Article ──────────────────────────────── */
.docs-main { min-inline-size: 0; padding-block-start: 0.5rem; }

.docs-breadcrumb {
  align-items: center;
  color: var(--ink-subtle);
  display: flex;
  flex-wrap: wrap;
  font-size: var(--text-x-small);
  gap: 0.4rem;
  margin-block-end: 1.5rem;
}
.docs-breadcrumb a { color: var(--ink-muted); text-decoration: none; }
.docs-breadcrumb a:hover { color: var(--accent); }
.docs-breadcrumb .icon { color: var(--ink-subtle); }
.docs-breadcrumb .icon svg { width: 0.85em; height: 0.85em; }

.docs-article__eyebrow { color: var(--accent); font-size: var(--text-small); font-weight: 600; }
.docs-article__title {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(2rem, 1.5rem + 2.4vw, 3rem);
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.08;
  margin-block-start: 0.5rem;
  text-wrap: balance;
}
.docs-article__lede {
  color: var(--ink-muted);
  font-size: var(--text-medium);
  line-height: 1.6;
  margin-block-start: 0.75rem;
  max-inline-size: 46rem;
}
.docs-article__meta { color: var(--ink-subtle); font-size: var(--text-x-small); margin-block-start: 0.75rem; }

/* ─────────────────────── Prose (article body) ─────────────────────────── */
.docs-prose {
  color: var(--color-stone-800);
  font-size: var(--text-prose);
  line-height: 1.75;
  margin-block-start: 2.5rem;
  max-inline-size: 46rem;
}
html[data-theme="dark"] .docs-prose { color: var(--color-stone-200); }
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) .docs-prose { color: var(--color-stone-200); }
}
.docs-prose > * + * { margin-block-start: 1.1rem; }

.docs-prose h2 {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--text-x-large);
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin-block-start: 2.75rem;
  scroll-margin-top: 6rem;
}
.docs-prose h3 {
  color: var(--ink);
  font-size: var(--text-medium);
  font-weight: 600;
  margin-block-start: 2rem;
  scroll-margin-top: 6rem;
}
.docs-prose h2 + h3 { margin-block-start: 1rem; }

.docs-prose a {
  color: var(--accent);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.docs-prose a:hover { text-decoration-thickness: 2px; }
.docs-prose strong { color: var(--ink); font-weight: 600; }

.docs-prose ul { list-style: square; padding-inline-start: 1.5rem; }
.docs-prose ol { list-style: decimal; padding-inline-start: 1.5rem; }
.docs-prose li { padding-inline-start: 0.35rem; }
.docs-prose li + li { margin-block-start: 0.4rem; }
.docs-prose li::marker { color: var(--ink-subtle); }

/* Heading anchor — appears on hover for direct links to sections. */
.docs-prose :is(h2, h3) .docs-anchor {
  color: var(--ink-subtle);
  margin-inline-start: 0.4rem;
  opacity: 0;
  text-decoration: none;
  transition: opacity 120ms;
}
.docs-prose :is(h2, h3):hover .docs-anchor { opacity: 1; }

/* Code */
.docs-prose :not(pre) > code {
  background: var(--card-hover);
  border-radius: var(--radius-2);
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 0.1em 0.4em;
}
.docs-prose pre {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-2);
  font-size: var(--text-small);
  line-height: 1.6;
  overflow-x: auto;
  padding: 1rem 1.15rem;
}
.docs-prose pre code { font-family: var(--font-mono); }

/* Blockquote */
.docs-prose blockquote {
  border-inline-start: 3px solid var(--accent);
  color: var(--ink-muted);
  padding-inline-start: 1.1rem;
}

/* Tables */
.docs-prose table {
  border-collapse: collapse;
  display: block;
  font-size: var(--text-small);
  inline-size: 100%;
  overflow-x: auto;
}
.docs-prose :is(th, td) {
  border-block-end: 1px solid var(--line);
  padding: 0.6rem 0.9rem;
  text-align: start;
}
.docs-prose thead th { color: var(--ink); font-weight: 600; }
.docs-prose td { color: var(--ink-muted); }

.docs-prose img {
  border: 1px solid var(--line);
  border-radius: var(--radius-2);
  display: block;
  inline-size: 100%;
}
.docs-prose hr { border: 0; border-block-start: 1px solid var(--line); margin-block: 2rem; }

/* Callouts — write with: > **Note:** … inside a blockquote, or the include. */
.docs-callout {
  background: var(--card);
  border-radius: var(--radius-2);
  border-inline-start: 3px solid var(--accent);
  display: flex;
  font-size: var(--text-small);
  gap: 0.75rem;
  line-height: 1.65;
  padding: 0.9rem 1.1rem;
}
.docs-callout .icon { color: var(--accent); flex-shrink: 0; margin-block-start: 0.1rem; }
.docs-callout[data-kind="warning"] { border-inline-start-color: var(--color-negative); }
.docs-callout[data-kind="warning"] .icon { color: var(--color-negative); }
.docs-callout__body > * + * { margin-block-start: 0.5rem; }
.docs-callout strong { color: var(--ink); }

/* ─────────────────────────── Prev / next ──────────────────────────────── */
.docs-pager {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr 1fr;
  margin-block-start: 3.5rem;
}
@media (max-width: 34rem) { .docs-pager { grid-template-columns: 1fr; } }
.docs-pager__link {
  background: var(--card);
  border-radius: var(--radius-2);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.15rem;
  text-decoration: none;
  transition: background-color 150ms var(--ease-out-expo);
}
.docs-pager__link:hover { background: var(--card-hover); }
.docs-pager__link[data-dir="next"] { text-align: end; }
.docs-pager__dir { color: var(--ink-subtle); font-size: var(--text-x-small); }
.docs-pager__title { color: var(--ink); font-weight: 500; }

/* ─────────────────────── On this page (right TOC) ─────────────────────── */
.docs-toc { position: sticky; top: 6rem; }
.docs-toc__title {
  color: var(--ink);
  font-size: var(--text-x-small);
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-block-end: 0.75rem;
  text-transform: uppercase;
}
.docs-toc__list { list-style: none; margin: 0; padding: 0; }
.docs-toc__link {
  border-inline-start: 2px solid var(--line);
  color: var(--ink-muted);
  display: block;
  font-size: var(--text-x-small);
  line-height: 1.4;
  padding: 0.3rem 0 0.3rem 0.75rem;
  text-decoration: none;
}
.docs-toc__link:hover { color: var(--ink); }
.docs-toc__link[data-level="3"] { padding-inline-start: 1.5rem; }
.docs-toc__link[aria-current="true"] { border-inline-start-color: var(--accent); color: var(--accent); }

/* ───────────────────────── Landing (home) ─────────────────────────────── */

/* Hero band — reuses the marketing site's teal "wallpaper" gradient (Pine
   accent-400 → accent-700, dark: 800 → 950) plus the grayscale noise overlay,
   so the docs hero matches the screenshot backdrop on verkilo.com. */
.docs-hero-band {
  background-image: var(--wallpaper-green);
  border-radius: var(--radius-card);
  padding: clamp(2.5rem, 6vw, 4.5rem) clamp(1.5rem, 5vw, 4rem);
  position: relative;
  /* No overflow:hidden — it would clip the search results dropdown. The gradient
     is clipped by border-radius already; the noise overlay rounds itself below. */
}
.docs-hero-band::before {
  background-image: var(--noise);
  border-radius: inherit;
  content: "";
  inset: 0;
  mix-blend-mode: overlay;
  opacity: 0.3;
  pointer-events: none;
  position: absolute;
}
.docs-hero-band > * { position: relative; }

/* On the teal band, flip the type to light for contrast (both color modes).
   A 1px Pine-600 outline (4-way text-shadow) draws a crisp border around each
   glyph so the light text reads cleanly against the lighter top of the gradient. */
.docs-hero-band .docs-hero {
  --hero-outline: 1px 1px 0 var(--color-pine-600), -1px 1px 0 var(--color-pine-600),
                  1px -1px 0 var(--color-pine-600), -1px -1px 0 var(--color-pine-600);
}
/* Dark mode: the light Pine rim reads harsh against the near-black gradient
   bottom, so drop the outline entirely — the white text has enough contrast. */
html[data-theme="dark"] .docs-hero-band .docs-hero { --hero-outline: none; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) .docs-hero-band .docs-hero { --hero-outline: none; }
}
.docs-hero-band .oatmeal-eyebrow { color: #fff; text-shadow: var(--hero-outline); }
.docs-hero-band .docs-hero__title { color: #fff; text-shadow: var(--hero-outline); }
.docs-hero-band .docs-hero__lede { color: #fff; text-shadow: var(--hero-outline); }

.docs-hero { text-align: center; }
.docs-hero__title {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 1.7rem + 3.5vw, 4rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.05;
  text-wrap: balance;
}
.docs-hero__lede { color: var(--ink-muted); font-size: var(--text-medium); line-height: 1.6; margin-inline: auto; max-inline-size: 34rem; }

/* Category cards grid */
.docs-cats { --grid-min: 17rem; }
.docs-cat {
  background: var(--card);
  border: 1px solid transparent;
  border-radius: var(--radius-card);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.5rem;
  text-decoration: none;
  transition: background-color 150ms var(--ease-out-expo), border-color 150ms var(--ease-out-expo);
}
.docs-cat:hover { background: var(--card-hover); border-color: var(--line); }
.docs-cat__icon {
  align-items: center;
  background: color-mix(in oklch, var(--accent) 12%, transparent);
  border-radius: var(--radius-2);
  block-size: 2.75rem;
  color: var(--accent);
  display: inline-flex;
  inline-size: 2.75rem;
  justify-content: center;
}
.docs-cat__title { color: var(--ink); font-size: var(--text-medium); font-weight: 600; }
.docs-cat__desc { color: var(--ink-muted); font-size: var(--text-small); line-height: 1.6; }
.docs-cat__links { display: flex; flex-direction: column; gap: 0.35rem; margin-block-start: 0.25rem; }
.docs-cat__article { color: var(--ink-muted); font-size: var(--text-small); text-decoration: none; }
.docs-cat__article:hover { color: var(--accent); }
.docs-cat__more { color: var(--accent); font-size: var(--text-x-small); font-weight: 600; margin-block-start: 0.25rem; }

/* ─────────────────────────────── Search ───────────────────────────────── */
.docs-search { position: relative; margin-inline: auto; max-inline-size: 34rem; }
.docs-search__field {
  align-items: center;
  background: var(--surface);
  border-radius: var(--radius-pill);
  box-shadow: inset 0 0 0 1px var(--line);
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  transition: box-shadow 150ms var(--ease-out-expo);
}
.docs-search__field:focus-within { box-shadow: inset 0 0 0 2px var(--accent); }
.docs-search__field .icon { color: var(--ink-subtle); }
.docs-search__input {
  background: transparent;
  border: 0;
  color: var(--ink);
  flex: 1;
  font: inherit;
  min-inline-size: 0;
  outline: none;
}
.docs-search__input::placeholder { color: var(--ink-subtle); }
.docs-search__kbd {
  background: var(--card-hover);
  border-radius: var(--radius-2);
  color: var(--ink-subtle);
  font-size: var(--text-xx-small);
  font-weight: 600;
  padding: 0.15rem 0.45rem;
}

/* Results popover — anchored below the field. */
.docs-search__results {
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.18);
  display: none;
  inset-block-start: calc(100% + 0.5rem);
  inset-inline: 0;
  max-block-size: 24rem;
  overflow-y: auto;
  padding: 0.5rem;
  position: absolute;
  text-align: start;
  z-index: var(--z-nav);
}
.docs-search[data-open] .docs-search__results { display: block; }
.docs-search__result {
  border-radius: var(--radius-2);
  color: var(--ink);
  display: block;
  padding: 0.6rem 0.75rem;
  text-decoration: none;
}
.docs-search__result:hover,
.docs-search__result[data-active] { background: var(--card-hover); }
.docs-search__result-cat { color: var(--accent); display: block; font-size: var(--text-xx-small); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; margin-block-end: 0.15rem; }
.docs-search__result-title { color: var(--ink); display: block; font-size: var(--text-small); font-weight: 500; }
.docs-search__result-excerpt { color: var(--ink-muted); display: block; font-size: var(--text-x-small); line-height: 1.4; margin-block-start: 0.15rem; }
.docs-search__empty { color: var(--ink-subtle); font-size: var(--text-small); padding: 0.75rem; text-align: center; }
.docs-search mark { background: color-mix(in oklch, var(--accent) 25%, transparent); color: inherit; border-radius: 2px; }

/* Compact search variant that lives in the navbar. */
.docs-search[data-variant="nav"] { max-inline-size: 20rem; inline-size: 100%; }
.docs-search[data-variant="nav"] .docs-search__field { padding: 0.4rem 0.9rem; }

/* ─────────────────────────── Docs navbar ──────────────────────────────── */
.docs-topbar {
  background: var(--canvas);
  border-block-end: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
}
.docs-topbar__bar { min-block-size: 4.5rem; }
.docs-topbar__logo {
  align-items: baseline;
  color: var(--ink);
  display: inline-flex;
  font-family: var(--font-display);
  font-size: var(--text-large);
  gap: 0.4rem;
  text-decoration: none;
  white-space: nowrap;
}
.docs-topbar__logo span { color: var(--accent); font-size: var(--text-small); font-weight: 600; }
.docs-topbar__links { display: flex; gap: 1.5rem; }
.docs-topbar__link { color: var(--ink-muted); font-size: var(--text-small); font-weight: 500; text-decoration: none; }
.docs-topbar__link:hover { color: var(--accent); }

/* Hamburger button — hidden on desktop, revealed once the bar links collapse. */
.docs-topbar__burger {
  align-items: center;
  background: none;
  border: 0;
  border-radius: var(--radius-2);
  color: var(--ink);
  cursor: pointer;
  display: none;
  justify-content: center;
  padding: 0.4rem;
}
.docs-topbar__burger:hover { color: var(--accent); }
.docs-topbar__burger-icon { display: block; }
.docs-topbar__burger-icon--close { display: none; }
/* Swap hamburger → ✕ while the popover is open (no JS: :has + :popover-open). */
.docs-topbar:has(.docs-topbar__menu:popover-open) .docs-topbar__burger-icon--open { display: none; }
.docs-topbar:has(.docs-topbar__menu:popover-open) .docs-topbar__burger-icon--close { display: block; }

/* Mobile dropdown — a native [popover] pinned to the top-right corner. Opening,
   light-dismiss (outside click) and Escape are all handled by the platform. */
.docs-topbar__menu {
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.22);
  display: grid;
  gap: 0.25rem;
  inline-size: min(20rem, calc(100vw - 2rem));
  inset: auto;
  margin: 0;
  max-block-size: min(80vh, calc(100dvh - 5rem));
  overflow-y: auto;
  padding: 0.75rem;
  position: fixed;
  inset-block-start: 4rem;
  inset-inline-end: max(1rem, env(safe-area-inset-right));
}
/* Fade/slide in — degrades to an instant show where unsupported. */
.docs-topbar__menu {
  opacity: 0;
  transform: translateY(-0.4rem);
  transition: opacity 160ms ease, transform 180ms var(--ease-out-expo), overlay 180ms allow-discrete, display 180ms allow-discrete;
}
.docs-topbar__menu:popover-open { opacity: 1; transform: translateY(0); }
@starting-style {
  .docs-topbar__menu:popover-open { opacity: 0; transform: translateY(-0.4rem); }
}
.docs-topbar__menu-search { margin-block-end: 0.5rem; }
.docs-topbar__menu-search .docs-search { max-inline-size: none; }
.docs-topbar__menu-link {
  align-items: center;
  border-radius: var(--radius-2);
  color: var(--ink);
  display: flex;
  font-size: var(--text-medium);
  font-weight: 500;
  gap: 0.6rem;
  padding: 0.7rem 0.75rem;
  text-decoration: none;
}
.docs-topbar__menu-link:hover { background: var(--card); color: var(--accent); }
.docs-topbar__menu-link .icon { color: var(--accent); }

/* Below the two-column breakpoint the bar collapses into the hamburger:
   the search row and inline links move into the popover. */
@media (max-width: 52rem) {
  .docs-topbar__search { display: none; }
  .docs-topbar__links { display: none; }
  .docs-topbar__burger { display: inline-flex; }
}
