/* Docs section styles. Hand-written -- not touched by scripts/build-docs.py.
   Reuses the custom properties, fonts, and card/link patterns defined in
   /styles.css so the docs pages read as part of the same site. */

.docs-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 7.5rem 1.5rem 5rem;
  display: flex;
  align-items: flex-start;
  gap: 3rem;
}

/* Sidebar: search box + section nav */

.docs-sidebar {
  flex: 0 0 240px;
  width: 240px;
  position: sticky;
  top: 6rem;
  align-self: flex-start;
  /* Scroll the nav on its own when it is taller than the viewport */
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 0.5rem;
}

.docs-nav-home {
  margin-bottom: 1.1rem;
}

.docs-nav-home a {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  padding: 0.22rem 0.6rem;
  border-left: 2px solid transparent;
}

.docs-nav-home a:hover {
  color: var(--pen);
}

.docs-nav-home a[aria-current="page"] {
  color: var(--pen);
  border-left-color: var(--pen);
}

.docs-search {
  margin-bottom: 1.5rem;
  position: relative;
}

.docs-search-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.docs-search-input {
  width: 100%;
  font-family: var(--sans);
  font-size: 0.88rem;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  transition: border-color 0.2s;
}

.docs-search-input::placeholder {
  color: var(--text-muted);
}

.docs-search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.docs-search-results {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  z-index: 120;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  padding: 0.35rem;
  max-height: 60vh;
  overflow-y: auto;
}

.docs-search-results[hidden] {
  display: none;
}

.docs-search-result {
  display: block;
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
}

.docs-search-result:hover,
.docs-search-result.is-active {
  background: var(--bg-alt);
}

.docs-search-result-title {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
}

.docs-search-result-section {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  margin-left: 0.5rem;
}

.docs-search-result-snippet {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  line-height: 1.5;
}

.docs-search-result-snippet mark {
  background: rgba(232, 18, 31, 0.16);
  color: var(--text);
  border-radius: 2px;
  padding: 0 0.05em;
}

.docs-search-empty {
  padding: 0.65rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Section nav */

.docs-menu > summary {
  display: none;
}

.docs-nav-section {
  margin-bottom: 1.4rem;
}

.docs-nav-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.docs-nav-list {
  list-style: none;
}

.docs-nav-list li {
  margin: 0;
}

.docs-nav-list a {
  display: block;
  font-size: 0.86rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.28rem 0;
  border-left: 2px solid transparent;
  padding-left: 0.7rem;
  margin-left: -0.7rem;
  transition: color 0.15s, border-color 0.15s;
}

.docs-nav-list a:hover {
  color: var(--text);
}

.docs-nav-list a[aria-current="page"] {
  color: var(--accent);
  font-weight: 500;
  border-left-color: var(--accent);
}

/* Article */

.docs-article {
  flex: 1 1 auto;
  max-width: 46rem;
  min-width: 0;
}

.docs-eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.docs-article h1 {
  font-family: var(--serif);
  font-size: 2.1rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
}

.docs-article h2 {
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 2.2rem 0 0.9rem;
}

.docs-article h3 {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 1.6rem 0 0.6rem;
}

.docs-article > h2:first-child,
.docs-article > h3:first-child {
  margin-top: 0;
}

.docs-article p {
  color: var(--text-muted);
  margin-bottom: 1.1rem;
  line-height: 1.7;
}

.docs-article ul,
.docs-article ol {
  color: var(--text-muted);
  margin: 0 0 1.1rem;
  padding-left: 1.4rem;
  line-height: 1.7;
}

.docs-article ul {
  list-style: disc;
}

.docs-article ol {
  list-style: decimal;
}

.docs-article li {
  margin-bottom: 0.45rem;
}

.docs-article li strong {
  color: var(--text);
}

.docs-article a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.2s;
}

.docs-article a:hover {
  color: var(--accent-hover);
}

.docs-article strong {
  color: var(--text);
  font-weight: 600;
}

.docs-article code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.4em;
}

.docs-article pre {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  margin: 0 0 1.1rem;
  overflow-x: auto;
}

.docs-article pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre;
}

.docs-article blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.2rem 0 0.2rem 1.1rem;
  margin: 0 0 1.1rem;
  color: var(--text-muted);
}

.docs-article blockquote p {
  margin-bottom: 0;
}

.docs-table-wrap {
  overflow-x: auto;
  margin: 0 0 1.1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.docs-article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.docs-article th,
.docs-article td {
  text-align: left;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.docs-article thead th {
  background: var(--bg-alt);
  color: var(--text);
  font-weight: 600;
  font-size: 0.82rem;
}

.docs-article td {
  color: var(--text-muted);
}

.docs-article tbody tr:last-child td {
  border-bottom: none;
}

/* Pager */

.docs-pager {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.docs-pager-link {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  max-width: 48%;
}

.docs-pager-next {
  text-align: right;
  margin-left: auto;
}

.docs-pager-dir {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.docs-pager-title {
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--text);
  margin-top: 0.2rem;
}

.docs-pager-link:hover .docs-pager-title {
  color: var(--accent);
}

/* Landing page (docs/index.html) */

.docs-landing-intro {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-bottom: 1.5rem;
  max-width: 34rem;
}

.docs-landing > .docs-search {
  max-width: 28rem;
  margin-bottom: 3rem;
}

.docs-landing-section {
  margin-bottom: 2.5rem;
}

.docs-landing-section h2 {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.docs-landing-grid.card-grid {
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-top: 0;
}

/* .docs-article a underlines prose links, but card links (title + summary)
   should keep the site's plain card-link treatment, not an underline. */
.docs-article .docs-landing-grid a,
.docs-article .docs-landing-grid a:hover {
  text-decoration: none;
}

.docs-landing-grid .card {
  padding: 1.1rem 1.25rem;
}

.docs-landing-grid .card h3 {
  font-size: 1rem;
}

.docs-landing-grid .card p {
  font-size: 0.88rem;
}

/* Mobile: sidebar collapses above the content */

@media (max-width: 820px) {
  .docs-shell {
    flex-direction: column;
    padding-top: 6.5rem;
    gap: 1.5rem;
  }

  .docs-sidebar {
    position: static;
    width: 100%;
    flex: none;
  }

  .docs-menu > summary {
    display: block;
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    cursor: pointer;
  }

  .docs-menu[open] > summary {
    border-radius: 6px 6px 0 0;
    border-bottom: none;
  }

  .docs-menu .docs-nav {
    display: block;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 6px 6px;
    padding: 0.8rem;
  }

  .docs-landing-grid.card-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .docs-pager-link {
    max-width: 100%;
  }
}
