/* Docs shell: the page frame every page sits in (templates/layout.ts).
 *
 * Frame contract, for the stylesheets that build inside it:
 * - main.docs-frame holds the page body and keeps room at the bottom for
 *   the dock;
 * - #docs-sidebar-root is the sidebar column: fixed on the left at
 *   --d-sidebar-w from 1024px, an off-canvas drawer below that
 *   (html.docs-nav-open opens it);
 * - #docs-toc-root is the TOC column: fixed on the right at --d-toc-w from
 *   1280px, hidden below;
 * - .docs-main is the content column: centred in the space left between
 *   them, at most --d-content-w wide.
 * Pages without a sidebar or TOC (landings, changelog) get the full width
 * and centre their own content. Colours come from tokens.css only. */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 24px;
}

body.docs-body {
  margin: 0;
  min-height: 100vh;
  background: var(--d-bg);
  color: var(--d-fg);
  font-family: var(--d-font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* The vendored @syott/styles gives every button pill padding, a margin and
 * a column layout; reset that at element level, so any class wins. */
:where(.docs-body) button {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  align-self: auto;
  gap: 0;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border-radius: 0;
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
}

:where(.docs-body) a {
  color: inherit;
}

/* The vendored styles nudge radios out of place; pages lay them out. */
:where(.docs-body) input[type="radio"] {
  position: static;
  top: auto;
}

:where(.docs-body) :focus-visible {
  outline: 2px solid var(--d-focus);
  outline-offset: 2px;
}

/* ---- Frame ---- */

.docs-frame {
  --docs-frame-top: 64px;
  --docs-frame-bottom: calc(var(--d-dock-h) + 2 * var(--d-dock-gap));

  display: block;
  min-height: 100vh;
  padding-bottom: var(--docs-frame-bottom);
}

.docs-main {
  width: 100%;
  max-width: calc(var(--d-content-w) + 48px);
  margin-inline: auto;
  padding: var(--docs-frame-top) 24px 0;
}

#docs-sidebar-root {
  position: fixed;
  z-index: 40;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(var(--d-sidebar-w), calc(100vw - 48px));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--docs-frame-top) 0 var(--docs-frame-bottom);
  background: var(--d-bg);
  scrollbar-width: thin;
}

#docs-toc-root {
  display: none;
}

/* Below 1024px the sidebar is a drawer, opened from the dock. */
@media (max-width: 1023.98px) {
  #docs-sidebar-root {
    box-shadow: var(--d-shadow-pop);
    transform: translateX(-102%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  }

  html.docs-nav-open #docs-sidebar-root {
    transform: none;
  }

  .docs-scrim {
    position: fixed;
    z-index: 39;
    inset: 0;
    background: rgba(0, 0, 0, 0.32);
  }

  html:not(.docs-nav-open) .docs-scrim {
    display: none;
  }
}

@media (min-width: 1024px) {
  .docs-frame:has(#docs-sidebar-root) {
    padding-left: var(--d-sidebar-w);
  }

  .docs-scrim {
    display: none;
  }
}

@media (min-width: 1280px) {
  #docs-toc-root {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    display: block;
    width: var(--d-toc-w);
    overflow-y: auto;
    padding: 104px 24px var(--docs-frame-bottom) 0;
    scrollbar-width: none;
  }

  .docs-frame:has(#docs-toc-root) {
    padding-right: var(--d-toc-w);
  }
}

@media (max-width: 640px) {
  .docs-frame {
    --docs-frame-top: 72px;
  }

  .docs-main {
    padding-inline: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #docs-sidebar-root {
    transition: none;
  }
}
