/* Documentation layout (as-x1xc). READING theme: colours come from /reading.css
   tokens; this file owns geometry only.

   Wide screens run left to right: guide list | article | on-page contents.
   Prose is capped at --reading-measure (80ch) for line length, while the
   frame, cards, code and glossary use the full width. From 2000px sections
   flow into two columns so a 2560px monitor is filled, not floated in space.
   Below 1100px the contents list sits inline under the intro; below 640px the
   guide list becomes one scrolling row of chips. */
.docs-page {
  --docs-nav: clamp(220px, 15vw, 320px);
  --docs-toc: clamp(210px, 14vw, 300px);
  --docs-gap: clamp(32px, 4vw, 96px);
}
.docs-page { min-height: 100vh; display: flex; flex-direction: column; }
.docs-page .docs-shell { flex: 1 0 auto; }
.docs-shell {
  display: grid;
  grid-template-columns: var(--docs-nav) minmax(0, 1fr);
  gap: var(--docs-gap);
  width: 100%;
  max-width: none;
  margin: 0;
  padding: calc(var(--header) + clamp(32px, 3.2vw, 64px)) var(--shell-gutter, 24px) clamp(64px, 6vw, 120px);
}
.docs-sidebar { min-width: 0; align-self: start; position: sticky; top: calc(var(--header) + 32px); max-height: calc(100vh - var(--header) - 48px); overflow-y: auto; }
.docs-eyebrow { color: var(--air); font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 18px; }
.docs-sidebar nav { display: grid; gap: 5px; }
.docs-sidebar nav a { display: block; padding: 10px 12px; border-left: 2px solid transparent; font-size: 14px; line-height: 1.55; color: var(--text-2); text-decoration: none; overflow-wrap: anywhere; }
.docs-sidebar nav a:hover { color: var(--text-1); background: var(--bg-2); }
.docs-sidebar nav a[aria-current] { color: var(--accent); border-color: var(--accent); background: var(--bg-1); }

/* Article: one column; contents and two-column flow are added by width below. */
.docs-article {
  --docs-cols: minmax(0, 1fr);
  min-width: 0;
  display: grid;
  grid-template-columns: var(--docs-cols);
  column-gap: var(--docs-gap);
  align-content: start;
  font-size: var(--reading-size, 16px);
}
.docs-article > * { grid-column: 1; min-width: 0; }
.docs-intro { margin-bottom: 40px; }
.docs-intro h1 { font-size: clamp(32px, 2.6vw + 12px, 64px); line-height: 1.12; letter-spacing: -.035em; font-weight: 700; color: var(--text-1); text-wrap: balance; overflow-wrap: anywhere; }
.docs-lead { margin-top: 22px; color: var(--text-2); font-size: 1.18em; line-height: 1.6; max-width: 70ch; }
.docs-article section { margin: 0 0 36px; scroll-margin-top: calc(var(--header) + 20px); }
.docs-article h2 { font-size: 1.45em; line-height: 1.3; font-weight: 650; letter-spacing: -.02em; color: var(--text-1); margin-bottom: 14px; overflow-wrap: anywhere; }
.docs-article section p, .docs-article li, .docs-glossary dd { font-size: 1em; line-height: 1.75; color: var(--text-2); overflow-wrap: anywhere; }
.docs-article section :is(p, ol, ul), .docs-glossary dd { max-width: var(--reading-measure, 80ch); }
.docs-article section p + p { margin-top: 14px; }
.docs-article ol { padding-left: 25px; }
.docs-article li { padding-left: 8px; margin: 14px 0; }
.docs-article li::marker { color: var(--text-1); font-weight: 650; }
.docs-links { display: flex; gap: 12px 24px; flex-wrap: wrap; margin-top: 18px; }
.docs-links a, .docs-next a { color: var(--link); text-decoration: underline; text-underline-offset: 4px; overflow-wrap: anywhere; }
.docs-links a:hover, .docs-next a:hover { color: var(--text-1); }
.docs-note { padding: 24px; border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--bg-1); }
.docs-article pre { border: 1px solid var(--border-strong); border-radius: var(--r-sm); padding: 18px; background: var(--bg-1); margin: 18px 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-1); }
.docs-article code { font-family: var(--font-mono); font-size: .9em; }
.docs-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(14px, 1.4vw, 28px); }
.docs-card { display: flex; flex-direction: column; padding: 26px; border: 1px solid var(--border-strong); border-radius: var(--r-md); text-decoration: none; color: var(--text-1); background: var(--bg-0); min-width: 0; }
.docs-card h2 { font-size: 1.3em; }
.docs-card p { color: var(--text-2); line-height: 1.65; font-size: 1em; overflow-wrap: anywhere; }
.docs-card span { margin-top: auto; padding-top: 20px; font-size: 22px; }
.docs-card:hover { border-color: var(--text-1); background: var(--bg-1); }
.docs-glossary { display: grid; grid-template-columns: minmax(0, 1fr); column-gap: var(--docs-gap); }
.docs-glossary > div { padding: 24px 0; border-top: 1px solid var(--border); }
.docs-glossary > div:first-child { border-top: 0; padding-top: 0; }
.docs-glossary dt { font-size: 1.3em; font-weight: 650; color: var(--text-1); margin-bottom: 8px; scroll-margin-top: calc(var(--header) + 20px); }
.docs-next { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 20px; border-top: 1px solid var(--border); padding-top: 24px; margin-top: 40px; font-size: 15px; }
.docs-page a:focus-visible { outline: 2px solid var(--air); outline-offset: 4px; border-radius: 3px; }

/* On-page contents: inline list on narrow screens, sticky right rail on wide. */
.docs-toc { display: block; margin: 0 0 36px; counter-reset: toc; }
.docs-toc a { counter-increment: toc; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 6px 0; border-top: 1px solid var(--border); color: var(--text-2); font-size: 15px; line-height: 1.4; text-decoration: none; }
.docs-toc a::before { content: counter(toc); flex: none; width: 20px; color: var(--air); font-size: 13px; font-weight: 700; }
.docs-toc a:hover { color: var(--text-1); text-decoration: underline; text-underline-offset: 3px; }

@media (min-width: 1100px) {
  .docs-article:has(> .docs-toc) { --docs-cols: minmax(0, 1fr) var(--docs-toc); }
  .docs-toc { grid-column: 2; grid-row: 1 / span 20; align-self: start; position: sticky; top: calc(var(--header) + 32px); margin: 0; padding-left: 20px; border-left: 1px solid var(--border); }
  .docs-toc a { border-top: 0; min-height: 40px; }
}
@media (min-width: 2000px) {
  .docs-article:has(> section) { --docs-cols: repeat(2, minmax(0, 1fr)); }
  .docs-article:has(> section):has(> .docs-toc) { --docs-cols: repeat(2, minmax(0, 1fr)) var(--docs-toc); }
  .docs-article:has(> section) > :is(.docs-intro, .docs-next) { grid-column: 1 / span 2; }
  .docs-article:has(> section) > section { grid-column: auto; }
  .docs-article:has(> section):has(> .docs-toc) > .docs-toc { grid-column: 3; }
  .docs-glossary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .docs-glossary > div:nth-child(2) { border-top: 0; padding-top: 0; }
}
@media (min-width: 1500px) {
  .docs-cards { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .docs-card { grid-column: span 2; }
  /* Five guides: three over two. */
  .docs-card:nth-child(4):nth-last-child(2), .docs-card:nth-child(5):last-child { grid-column: span 3; }
}
@media (max-width: 960px) {
  .docs-shell { grid-template-columns: 185px minmax(0, 1fr); gap: 28px; }
  .docs-cards { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .docs-shell { display: block; padding: calc(var(--header) + 20px) 20px 48px; }
  /* One compact, scrollable row of guides; the current guide is scrolled into view by docs-locale.js. */
  .docs-sidebar { position: static; max-height: none; overflow: visible; margin: 0 -20px 28px; padding: 0 20px 14px; border-bottom: 1px solid var(--border); }
  .docs-sidebar .docs-eyebrow { display: none; }
  .docs-sidebar nav { display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-inline: contain; scroll-snap-type: x proximity; scrollbar-width: none; margin-inline: -20px; padding-inline: 20px; -webkit-mask-image: linear-gradient(90deg, transparent, #000 20px, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, transparent, #000 20px, #000 calc(100% - 28px), transparent); }
  .docs-sidebar nav::-webkit-scrollbar { display: none; }
  .docs-sidebar nav a { flex: 0 0 auto; display: flex; align-items: center; min-height: 44px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: var(--r-lg); font-size: 14px; line-height: 1.2; white-space: nowrap; scroll-snap-align: center; overflow-wrap: normal; }
  .docs-sidebar nav a[aria-current] { border-color: var(--accent); }
  .docs-intro { margin-bottom: 28px; }
  .docs-lead { font-size: 17px; }
  .docs-card { padding: 22px; }
  .docs-note { padding: 20px; }
}
@media (prefers-reduced-motion: reduce) { .docs-page { scroll-behavior: auto; } }
