/* ==========================================================================
   Clawgnition docs — layout chrome only.
   Builds on the shared tokens and components in site.css (do not restyle
   those here). This file owns: the two-column docs shell, the sidebar table
   of contents, the page header, the prev/next pager, and the CSS-only mobile
   sidebar toggle. Rich article text is styled by .prose in site.css.
   ========================================================================== */

.docs-shell {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 960px) {
  .docs-shell {
    grid-template-columns: 15rem minmax(0, 1fr);
    gap: 3rem;
    padding: 3rem 1.5rem 5rem;
  }
}

/* ---- Sidebar ---------------------------------------------------------- */

.docs-sidebar {
  min-width: 0;
}

@media (min-width: 960px) {
  .docs-sidebar {
    position: sticky;
    top: 1.5rem;
    align-self: start;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

/* Pure-CSS toggle (checkbox hack): collapsed on mobile, always open on desktop.
   The checkbox is visually hidden but stays focusable for keyboard users. */
.docs-sidebar__state {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.docs-sidebar__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.docs-sidebar__toggle::after {
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--ink-2);
  border-bottom: 2px solid var(--ink-2);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}

.docs-sidebar__state:checked ~ .docs-sidebar__toggle::after {
  transform: rotate(-135deg);
}

.docs-sidebar__state:focus-visible ~ .docs-sidebar__toggle {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.docs-nav {
  display: none;
  margin-top: 0.75rem;
  padding: 0.25rem 0;
}

.docs-sidebar__state:checked ~ .docs-nav {
  display: block;
}

@media (min-width: 960px) {
  .docs-sidebar__toggle {
    display: none;
  }
  .docs-nav {
    display: block;
    margin-top: 0;
  }
}

.docs-nav__group {
  margin-bottom: 1.5rem;
}

.docs-nav__title {
  margin: 0 0 0.5rem;
  padding: 0 0.75rem;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

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

.docs-nav__list li {
  margin: 0;
}

.docs-nav__list a {
  display: block;
  padding: 0.4rem 0.75rem;
  border-left: 2px solid transparent;
  border-radius: 0.45rem;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 0.92rem;
  line-height: 1.35;
}

.docs-nav__list a:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.docs-nav__list a[aria-current='page'] {
  color: var(--accent-deep);
  background: var(--accent-tint);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* ---- Main column ------------------------------------------------------ */

.docs-main {
  min-width: 0;
}

.docs-page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.docs-page-header h1 {
  margin: 0.5rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.docs-lede {
  margin: 1rem 0 0;
  max-width: 46rem;
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--ink-2);
}

/* ---- Pager ------------------------------------------------------------ */

.docs-pager {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

@media (min-width: 640px) {
  .docs-pager {
    grid-template-columns: 1fr 1fr;
  }
}

.docs-pager__link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: var(--surface);
  text-decoration: none;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}

.docs-pager__link:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.docs-pager__link--next {
  text-align: right;
  grid-column: 2;
}

.docs-pager__dir {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.docs-pager__label {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
}
