/**
 * Docs + help-center stylesheet.
 *
 * Why plain CSS (and not Tailwind `@apply`):
 * - Article body HTML is pre-rendered at build time by
 *   `scripts/build-docs.mjs` into `src/generated/docs-manifest.ts` as
 *   strings. Those strings are not a reliable scan surface for Tailwind's
 *   `@source` content detector — semantic class names on h2/h3/p/pre would
 *   need every possible variant explicitly enumerated.
 * - The sibling patterns in `build.js` (`buildTryStyles()`,
 *   `buildJoinStyles()`) are already plain PostCSS for the same reason.
 *
 * Consumed by:
 * - `src/ssr/docs/shell.ts` via `<link rel="stylesheet" href="/static/docs.css">`.
 * - The shell also inlines a small fallback copy of the critical rules
 *   below so the page is still legible if this file fails to load.
 *
 * Brand tokens (mirrored from `src/ssr/brand.ts` Color / Font / Gradient):
 * - ink          #1C1C24
 * - ink-secondary #4A4A4A
 * - ink-tertiary  #666666
 * - wash         #FAFAFA
 * - paper        #FFFFFF
 * - border       #E8E8E8
 * - gradient-start #FF6B6B
 * - gradient-end   #FF8E53
 * - success      #10B981
 * - error        #DC2626
 * - font family "Inter"
 * - display font "Open Sans" (hero only)
 *
 * If any of those values change in brand.ts, update both this stylesheet
 * AND the fallback block inline in `src/ssr/docs/shell.ts`.
 */

:root {
  color-scheme: light;
  --docs-ink: #1C1C24;
  --docs-ink-secondary: #4A4A4A;
  --docs-ink-tertiary: #666666;
  --docs-wash: #FAFAFA;
  --docs-paper: #FFFFFF;
  --docs-border: #E8E8E8;
  --docs-accent-start: #FF6B6B;
  --docs-accent-mid: #FFD93D;
  --docs-accent-end: #FF8E53;
  --docs-success: #10B981;
  --docs-error: #DC2626;
  --docs-warn: #FFFBF5;
  --docs-code-bg: #F1F1F4;
  --docs-pre-bg: #F7F7F9;
  --docs-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --docs-font-display: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --docs-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --docs-shadow-sm: 0 1px 2px rgba(28, 28, 36, 0.04);
  --docs-radius-sm: 6px;
  --docs-radius-md: 8px;
  --docs-radius-lg: 12px;
  --docs-radius-pill: 999px;
}

@media (prefers-color-scheme: dark) {
  /*
   * Light-first today. A dark mode for docs is an explicit open question in
   * the plan; this block exists only to document the knob we'd turn.
   */
}

* { box-sizing: border-box; }

body.docs-body {
  margin: 0;
  background: var(--docs-wash);
  color: var(--docs-ink);
  font-family: var(--docs-font-sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--docs-ink); }

/* Header + nav
   ----------------------------------------------------------------- */
.docs-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 32px;
  background: color-mix(in srgb, var(--docs-wash) 95%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--docs-border);
}

.docs-header-nav {
  display: flex;
  gap: 20px;
  align-items: center;
}

.docs-header-nav a {
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  color: var(--docs-ink);
  padding: 6px 4px;
  transition: color 120ms ease;
}

.docs-header-nav a:hover {
  color: var(--docs-ink-secondary);
}

.docs-sidebar-toggle {
  display: none;
  background: var(--docs-paper);
  border: 1px solid var(--docs-border);
  border-radius: var(--docs-radius-md);
  padding: 8px 10px;
  cursor: pointer;
  color: var(--docs-ink-secondary);
}

/* Layout
   ----------------------------------------------------------------- */
.docs-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 220px;
  gap: 40px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px;
}

@media (max-width: 1200px) {
  .docs-layout { grid-template-columns: 240px minmax(0, 1fr); }
  .docs-toc { display: none; }
}

@media (max-width: 900px) {
  .docs-layout { grid-template-columns: minmax(0, 1fr); padding: 20px; gap: 20px; }
  .docs-sidebar-toggle { display: inline-flex; align-items: center; gap: 6px; }
}

/* Sidebar
   ----------------------------------------------------------------- */
.docs-sidebar {
  position: sticky;
  top: 88px;
  align-self: start;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  /*
   * Symmetric horizontal padding is required: `.docs-sidebar-link` below
   * uses `margin: 2px -10px` to bleed the active-state pill to the
   * sidebar's edges, and `overflow-y: auto` establishes a clipping box
   * that also clips overflowing x. Without at least 10px of left
   * padding, the first character of every link gets cut off.
   */
  padding: 0 12px;
}

.docs-sidebar-group {
  margin-bottom: 24px;
}

.docs-sidebar-heading {
  display: block;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--docs-ink-secondary);
  margin-bottom: 8px;
  text-decoration: none;
}

.docs-sidebar-heading:hover { color: var(--docs-ink); }

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

.docs-sidebar-link {
  display: block;
  padding: 6px 10px;
  margin: 2px -10px;
  border-radius: var(--docs-radius-sm);
  color: var(--docs-ink-secondary);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.4;
  transition: background 120ms ease, color 120ms ease;
}

.docs-sidebar-link:hover {
  background: var(--docs-paper);
  color: var(--docs-ink);
}

.docs-sidebar-link--active {
  background: var(--docs-paper);
  color: var(--docs-ink);
  font-weight: 600;
  box-shadow: var(--docs-shadow-sm);
}

/* Mobile drawer state: toggled via `.docs-body[data-drawer-open="true"]` by
   `client/docs.ts`. When closed on mobile the sidebar is hidden; when open
   it slides in as an overlay. */
@media (max-width: 900px) {
  .docs-sidebar {
    display: none;
    position: fixed;
    inset: 64px 0 0 0;
    background: var(--docs-wash);
    padding: 20px 20px 40px;
    max-height: none;
    overflow-y: auto;
    z-index: 25;
    border-top: 1px solid var(--docs-border);
  }
  body.docs-body[data-drawer-open='true'] .docs-sidebar {
    display: block;
  }
}

/* Breadcrumbs, lede, meta
   ----------------------------------------------------------------- */
.docs-main { min-width: 0; }

.docs-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--docs-ink-tertiary);
}

.docs-crumb {
  text-decoration: none;
  color: var(--docs-ink-secondary);
}
.docs-crumb[aria-current='page'] { color: var(--docs-ink); font-weight: 600; }
.docs-crumb-sep { color: var(--docs-border); }

.docs-article-meta {
  margin: 0 0 24px;
  color: var(--docs-ink-tertiary);
  font-size: 13px;
}

.docs-article-lede {
  font-size: 18px;
  line-height: 1.6;
  color: var(--docs-ink-secondary);
  margin: 0 0 24px;
}

/* Prose (article body)
   ----------------------------------------------------------------- */
.docs-prose h1 {
  font-family: var(--docs-font-display);
  font-weight: 800;
  font-size: clamp(32px, 5vw, 44px);
  letter-spacing: -0.01em;
  margin: 0 0 8px;
}

.docs-prose h2 {
  font-weight: 700;
  font-size: 24px;
  line-height: 1.3;
  margin: 48px 0 12px;
  scroll-margin-top: 100px;
}

.docs-prose h3 {
  font-weight: 700;
  font-size: 18px;
  line-height: 1.35;
  margin: 32px 0 10px;
  scroll-margin-top: 100px;
}

.docs-prose p,
.docs-prose li {
  line-height: 1.7;
  color: var(--docs-ink-secondary);
  font-size: 16px;
}

.docs-prose p { margin: 0 0 18px; }

.docs-prose ul,
.docs-prose ol {
  margin: 0 0 20px;
  padding-left: 24px;
}

.docs-prose li + li { margin-top: 6px; }

.docs-prose a {
  color: var(--docs-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: color 120ms ease;
}

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

/* Heading anchors from `rehype-autolink-headings` (wrap behavior): the
   whole heading becomes an <a>. Strip the underline and add a subtle
   hover affordance. */
.docs-prose h2 a,
.docs-prose h3 a {
  color: inherit;
  text-decoration: none;
}

.docs-prose h2:hover a::after,
.docs-prose h3:hover a::after {
  content: ' §';
  color: var(--docs-ink-tertiary);
  font-weight: 400;
}

.docs-prose code {
  background: var(--docs-code-bg);
  padding: 2px 6px;
  border-radius: var(--docs-radius-sm);
  font-family: var(--docs-font-mono);
  font-size: 0.9em;
}

.docs-prose pre {
  background: var(--docs-pre-bg);
  border: 1px solid var(--docs-border);
  padding: 16px;
  border-radius: var(--docs-radius-md);
  overflow-x: auto;
  margin: 0 0 24px;
}

.docs-prose pre code {
  background: transparent;
  padding: 0;
  font-size: 14px;
}

.docs-prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 24px;
  font-size: 14px;
}

.docs-prose th,
.docs-prose td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--docs-border);
  text-align: left;
}

.docs-prose th {
  font-weight: 600;
  color: var(--docs-ink);
  background: var(--docs-paper);
}

/* Callouts (admonitions)
   ----------------------------------------------------------------- */
.callout {
  border-left: 4px solid var(--docs-accent-start);
  background: var(--docs-warn);
  padding: 14px 18px;
  border-radius: var(--docs-radius-sm);
  margin: 24px 0;
}

.callout p { color: var(--docs-ink); margin: 0; }
.callout p + p { margin-top: 10px; }
.callout--tip { border-left-color: var(--docs-success); background: #F1FBF5; }
.callout--warn { border-left-color: var(--docs-error); background: #FEF3F3; }

/* Right-rail TOC
   ----------------------------------------------------------------- */
.docs-toc {
  position: sticky;
  top: 88px;
  align-self: start;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  font-size: 14px;
}

.docs-toc-title {
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--docs-ink-secondary);
  margin: 0 0 12px;
}

.docs-toc-list { list-style: none; padding: 0; margin: 0; }
.docs-toc-item { margin: 2px 0; }
.docs-toc-item--h3 { padding-left: 14px; }

.docs-toc-link {
  display: block;
  padding: 4px 10px;
  margin: 0 -10px;
  border-radius: var(--docs-radius-sm);
  color: var(--docs-ink-secondary);
  text-decoration: none;
  border-left: 2px solid transparent;
  line-height: 1.4;
  transition: color 120ms ease, border-color 120ms ease;
}

.docs-toc-link:hover { color: var(--docs-ink); }

.docs-toc-link[data-active='true'] {
  color: var(--docs-ink);
  border-left-color: var(--docs-accent-start);
  font-weight: 600;
}

/* Prev/next
   ----------------------------------------------------------------- */
.docs-prevnext {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 64px 0 0;
  padding-top: 24px;
  border-top: 1px solid var(--docs-border);
}

.docs-prevnext-link {
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
  border: 1px solid var(--docs-border);
  border-radius: var(--docs-radius-md);
  text-decoration: none;
  color: var(--docs-ink);
  background: var(--docs-paper);
  transition: border-color 120ms ease, transform 120ms ease;
}

.docs-prevnext-link:hover {
  border-color: var(--docs-ink-secondary);
  transform: translateY(-1px);
}

.docs-prevnext-link--next { text-align: right; }

.docs-prevnext-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--docs-ink-tertiary);
  margin-bottom: 4px;
}

.docs-prevnext-title { font-weight: 600; }

/* Related
   ----------------------------------------------------------------- */
.docs-related {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--docs-border);
}

.docs-related h2 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
}

.docs-related-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.docs-related-list a {
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  border: 1px solid var(--docs-border);
  border-radius: var(--docs-radius-sm);
  background: var(--docs-paper);
  text-decoration: none;
  color: var(--docs-ink);
}

.docs-related-title { font-weight: 600; }
.docs-related-summary {
  color: var(--docs-ink-secondary);
  font-size: 13px;
  margin-top: 2px;
}

/* Landing hero + category grid
   ----------------------------------------------------------------- */
.docs-hero {
  background: linear-gradient(135deg, var(--docs-accent-start) 0%, var(--docs-accent-mid) 50%, var(--docs-accent-end) 100%);
  padding: 64px 32px;
  border-radius: var(--docs-radius-lg);
  margin-bottom: 32px;
  color: var(--docs-ink);
}

.docs-hero h1 {
  font-family: var(--docs-font-display);
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
}

.docs-hero p {
  font-size: 18px;
  max-width: 640px;
  margin: 0;
  color: var(--docs-ink);
  opacity: 0.9;
}

.docs-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/*
 * Category card structure (see `landing.ts#renderCategoryGrid`):
 *
 *   <div class="docs-category-card">                  ← outer box, relative
 *     <a class="docs-category-card-link" href="/…">   ← title/description link
 *       <h3>…</h3><p>…</p>
 *     </a>
 *     <ul class="docs-category-card-list">            ← real article anchors
 *       <li><a href="/…">…</a></li>
 *     </ul>
 *   </div>
 *
 * The outer card is a `<div>` on purpose: HTML5 forbids nested `<a>`, so if
 * the card itself were an anchor the parser would eject the inner
 * `<ul><a>` into the grid as a sibling cell — which caused the visible
 * "raw bulleted list in the right column" bug.
 *
 * The `::after` stretched-link on `.docs-category-card-link` preserves the
 * "whole card clickable" affordance. The inner article `<a>`s sit on top
 * via `position: relative; z-index: 1`.
 */
.docs-category-card {
  position: relative;
  padding: 20px;
  border: 1px solid var(--docs-border);
  border-radius: var(--docs-radius-lg);
  background: var(--docs-paper);
  color: inherit;
  transition: border-color 120ms ease, transform 120ms ease;
}

.docs-category-card:hover {
  border-color: var(--docs-ink-secondary);
  transform: translateY(-1px);
}

.docs-category-card-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.docs-category-card-link::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.docs-category-card h3 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
}

.docs-category-card p {
  margin: 0 0 10px;
  color: var(--docs-ink-secondary);
  font-size: 14px;
  line-height: 1.5;
}

.docs-category-card-list {
  position: relative;
  z-index: 1;
  list-style: none;
  padding: 0;
  margin: 0;
}

.docs-category-card-list li {
  margin-top: 4px;
  font-size: 14px;
  color: var(--docs-ink-secondary);
}

.docs-category-card-list li a {
  color: inherit;
  text-decoration: none;
}

.docs-category-card-list li a:hover {
  color: var(--docs-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Category index
   ----------------------------------------------------------------- */
.docs-category-header h1 {
  font-family: var(--docs-font-display);
  font-weight: 800;
  font-size: clamp(28px, 4vw, 40px);
  margin: 0 0 8px;
}

.docs-category-header p {
  color: var(--docs-ink-secondary);
  font-size: 16px;
  margin: 0 0 32px;
}

.docs-article-list {
  list-style: none;
  counter-reset: docs-article;
  padding: 0;
  margin: 0;
}

.docs-article-row { margin: 12px 0; }

.docs-article-row-link {
  display: block;
  padding: 16px 20px;
  border: 1px solid var(--docs-border);
  border-radius: var(--docs-radius-md);
  background: var(--docs-paper);
  text-decoration: none;
  color: var(--docs-ink);
  transition: border-color 120ms ease, transform 120ms ease;
}

.docs-article-row-link:hover {
  border-color: var(--docs-ink-secondary);
  transform: translateY(-1px);
}

.docs-article-row h3 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 700;
}

.docs-article-row p {
  margin: 0 0 8px;
  color: var(--docs-ink-secondary);
  font-size: 14px;
  line-height: 1.5;
}

.docs-article-row-meta {
  font-size: 12px;
  color: var(--docs-ink-tertiary);
  letter-spacing: 0.02em;
}

/* 404 list + empties
   ----------------------------------------------------------------- */
.docs-notfound-list,
.docs-empty {
  color: var(--docs-ink-secondary);
}

.docs-notfound-list {
  list-style: none;
  padding: 0;
  margin: 16px 0;
  display: grid;
  gap: 6px;
}

.docs-notfound-list a {
  color: var(--docs-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Footer
   ----------------------------------------------------------------- */
.docs-footer {
  padding: 56px 32px;
  text-align: center;
  color: var(--docs-ink-tertiary);
  font-size: 13px;
  border-top: 1px solid var(--docs-border);
  background: var(--docs-paper);
  margin-top: 80px;
}

.docs-footer a {
  color: var(--docs-ink-secondary);
  margin: 0 10px;
  text-decoration: none;
}

.docs-footer a:hover { color: var(--docs-ink); }

/* Search overlay (Phase 4 wires behavior; Phase 3 scaffolds styles)
   ----------------------------------------------------------------- */
.docs-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(28, 28, 36, 0.4);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 20px 20px;
}

.docs-search-overlay[data-open='true'] { display: flex; }

.docs-search-dialog {
  width: 100%;
  max-width: 600px;
  background: var(--docs-paper);
  border-radius: var(--docs-radius-lg);
  box-shadow: 0 20px 60px rgba(28, 28, 36, 0.25);
  overflow: hidden;
}

.docs-search-input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--docs-border);
  padding: 18px 20px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
}

.docs-search-results {
  max-height: 50vh;
  overflow-y: auto;
  padding: 8px;
}

.docs-search-result {
  display: block;
  padding: 12px 14px;
  border-radius: var(--docs-radius-sm);
  text-decoration: none;
  color: var(--docs-ink);
  cursor: pointer;
}

.docs-search-result[aria-selected='true'],
.docs-search-result:hover {
  background: var(--docs-wash);
}

.docs-search-result-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  font-weight: 600;
}

.docs-search-result-badge {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--docs-radius-pill);
  background: var(--docs-code-bg);
  color: var(--docs-ink-secondary);
}

.docs-search-result-summary {
  display: block;
  color: var(--docs-ink-secondary);
  font-size: 13px;
  margin-top: 2px;
}

.docs-search-empty {
  padding: 24px 20px;
  color: var(--docs-ink-tertiary);
  text-align: center;
  font-size: 14px;
}

.docs-search-empty a { color: var(--docs-ink); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
