/* ============================================================================
   ExoAtlas Documentation — shared stylesheet
   One file for the /documentation/ hub, /documentation/concepts/, and every
   app section. Loaded after /assets/css/style.css (site chrome).

   The site stylesheet uses hard-coded colors (no global custom properties),
   so the docs palette is defined here as --docs-* variables and kept
   consistent with the site's existing accents (#2563eb / #1d4ed8 from
   updates.css, #3b82f6 focus ring from style.css). All colors are explicit
   so pages stay legible under both values of <meta name="color-scheme">.
   ============================================================================ */

:root {
  --docs-accent: #2563eb;
  --docs-accent-strong: #1d4ed8;
  --docs-text: #333333;
  --docs-text-muted: #6b7280;
  --docs-heading: #111827;
  --docs-border: #e5e7eb;
  --docs-bg: #ffffff;
  --docs-bg-subtle: #f8fafc;
  --docs-bg-code: #f3f4f6;
  --docs-pro-text: #92400e;
  --docs-pro-bg: #fef3c7;
  --docs-pro-border: #fcd34d;
  --docs-warn-text: #7f1d1d;
  --docs-warn-bg: #fef2f2;
  --docs-warn-border: #fecaca;
  --docs-note-text: #1e3a5f;
  --docs-note-bg: #eff6ff;
  --docs-note-border: #bfdbfe;
  --docs-sidebar-w: 260px;
  --docs-toc-w: 200px;
  --docs-gap: 32px;
}

/* ---------------------------------------------------------------------------
   Layout grid: sidebar / content / on-this-page TOC
   ≥1200px: three columns. 900–1199px: sidebar + content. <900px: single
   column; the sidebar collapses to a "Documentation menu" <details> bar.
   --------------------------------------------------------------------------- */
.docs-layout {
  display: grid;
  grid-template-columns: var(--docs-sidebar-w) minmax(0, 1fr) var(--docs-toc-w);
  gap: var(--docs-gap);
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px 64px;
  box-sizing: border-box;
  color: var(--docs-text);
  background: var(--docs-bg);
}

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

@media (max-width: 899px) {
  .docs-layout { grid-template-columns: minmax(0, 1fr); padding: 12px 14px 48px; }
}

/* ---------------------------------------------------------------------------
   Ad-flanked page shell
   The two <aside class="ad-sidebar"> live right after `<div class="page">`,
   before `.docs-layout`. CSS `order` positions them to the left/right of the
   centered docs grid. Ad show/hide, sizing, and the <1200px hide are all
   inherited from the shared /assets/css/ads.css rules, so nothing here needs
   to duplicate those breakpoints.
   --------------------------------------------------------------------------- */
.page:has(> .docs-layout) {
  flex-direction: row;
  justify-content: center;
  align-items: stretch; /* rails span the full row height so the ad can travel */
  gap: 1.5rem;
  box-sizing: border-box;
}
.page:has(> .docs-layout) > .ad-sidebar-left  { order: 0; }
.page:has(> .docs-layout) > .docs-layout      { order: 1; flex: 1 1 auto; min-width: 0; }
.page:has(> .docs-layout) > .ad-sidebar-right { order: 2; }

/* Vertically center the ad in the viewport and keep it centered while the user
   scrolls. The rail (.ad-sidebar) is stretched to the full column height above,
   which gives the sticky ad room to travel; the rail ends where the docs grid
   ends — above the global <footer>, which lives outside `.page` — so the ad
   parks clear of the footer at the bottom of the scroll. The site header is
   position:relative (it scrolls away), so a centered ad never overlaps it.

   `top` centers the ad unit (600px tall + label/padding ≈ 660px) in the
   viewport via calc() rather than a transform, so the ad is never shifted up
   over the header at rest. max-height is cleared so tall viewports show the
   full unit instead of the site-wide clamp. */
.page:has(> .docs-layout) .ad-container {
  position: sticky;
  top: max(16px, calc((100vh - 660px) / 2));
  max-height: none;
}

/* Below the ads.css sidebar breakpoint the asides are display:none; drop the
   flex gap so the grid keeps its own centered margins. */
@media (max-width: 1199px) {
  .page:has(> .docs-layout) { gap: 0; }
}

/* ---------------------------------------------------------------------------
   Sidebar
   --------------------------------------------------------------------------- */
.docs-sidebar { font-size: 0.92rem; line-height: 1.45; }

.docs-sidebar-menu { border: 0; }
.docs-sidebar-menu > summary {
  display: none; /* desktop: sidebar is always expanded */
  cursor: pointer;
  font-weight: 600;
  color: var(--docs-heading);
  padding: 10px 12px;
  border: 1px solid var(--docs-border);
  border-radius: 8px;
  background: var(--docs-bg-subtle);
  list-style: none;
}
.docs-sidebar-menu > summary::-webkit-details-marker { display: none; }
.docs-sidebar-menu > summary::after { content: " ▾"; color: var(--docs-text-muted); }

@media (max-width: 899px) {
  .docs-sidebar-menu > summary { display: block; }
  .docs-sidebar-inner {
    border: 1px solid var(--docs-border);
    border-top: 0;
    border-radius: 0 0 8px 8px;
    padding: 10px 12px;
  }
}

.docs-sidebar-inner { position: sticky; top: 16px; }
@media (max-width: 899px) { .docs-sidebar-inner { position: static; } }

/* Desktop: draw a bordered card around the sidebar menu. On mobile the
   collapsible <summary>/inner already carry their own border, so this is
   scoped to >=900px to avoid a double border. */
@media (min-width: 900px) {
  .docs-sidebar-menu > .docs-sidebar-inner {
    border: 1px solid var(--docs-border);
    border-radius: 10px;
    background: var(--docs-bg-subtle);
    padding: 14px 16px;
  }
}

.docs-sidebar-hub { margin: 0 0 6px; font-size: 0.85rem; }
.docs-sidebar-hub a { color: var(--docs-text-muted); text-decoration: none; }
.docs-sidebar-hub a:hover { color: var(--docs-accent); }

.docs-sidebar-title { margin: 0 0 10px; font-weight: 600; font-size: 1rem; }
.docs-sidebar-title a { color: var(--docs-heading); text-decoration: none; }
.docs-sidebar-title a:hover { color: var(--docs-accent); }
.docs-sidebar-title a[aria-current="page"] { color: var(--docs-accent-strong); }

.docs-sidebar details {
  margin: 0 0 8px;
  border: 0;
}
.docs-sidebar details > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--docs-heading);
  padding: 3px 0;
  list-style: none;
}
.docs-sidebar details > summary::-webkit-details-marker { display: none; }
.docs-sidebar details > summary::before {
  content: "▸";
  display: inline-block;
  width: 1em;
  color: var(--docs-text-muted);
  transition: transform 0.15s ease;
}
.docs-sidebar details[open] > summary::before { transform: rotate(90deg); }

.docs-sidebar ul { list-style: none; margin: 2px 0 6px; padding: 0 0 0 1em; }
.docs-sidebar ul li { margin: 0; }
.docs-sidebar ul a {
  display: block;
  padding: 3px 8px;
  border-radius: 6px;
  color: var(--docs-text);
  text-decoration: none;
}
.docs-sidebar ul a:hover { background: var(--docs-bg-subtle); color: var(--docs-accent); }
.docs-sidebar ul a[aria-current="page"] {
  background: var(--docs-note-bg);
  color: var(--docs-accent-strong);
  font-weight: 600;
}

/* ---------------------------------------------------------------------------
   Content column
   --------------------------------------------------------------------------- */
.docs-content { min-width: 0; font-size: 1rem; line-height: 1.65; }

.docs-content h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  line-height: 1.25;
  color: var(--docs-heading);
  margin: 6px 0 6px;
  font-weight: 600;
}
.docs-content h2 {
  font-size: 1.35rem;
  color: var(--docs-heading);
  margin: 36px 0 10px;
  padding-top: 8px;
  border-top: 1px solid var(--docs-border);
  font-weight: 600;
}
.docs-content h3 { font-size: 1.08rem; color: var(--docs-heading); margin: 22px 0 6px; font-weight: 600; }
.docs-content a { color: var(--docs-accent); }
.docs-content a:hover { color: var(--docs-accent-strong); }

.docs-breadcrumb { font-size: 0.85rem; color: var(--docs-text-muted); margin-bottom: 4px; }
.docs-breadcrumb a { color: var(--docs-text-muted); text-decoration: none; }
.docs-breadcrumb a:hover { color: var(--docs-accent); text-decoration: underline; }
.docs-breadcrumb span { color: var(--docs-text); }

.docs-meta { font-size: 0.85rem; color: var(--docs-text-muted); margin: 0 0 18px; }

.docs-lead { font-size: 1.08rem; color: var(--docs-heading); }

/* Numbered quick-start steps */
.docs-steps { padding-left: 1.4em; }
.docs-steps li { margin: 0 0 10px; }

/* Code + kbd */
.docs-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--docs-bg-code);
  border: 1px solid var(--docs-border);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  overflow-wrap: anywhere;
}
.docs-content pre {
  background: var(--docs-bg-code);
  border: 1px solid var(--docs-border);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.5;
}
.docs-content pre code { background: none; border: 0; padding: 0; overflow-wrap: normal; }

kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82em;
  background: var(--docs-bg-subtle);
  border: 1px solid var(--docs-border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0.08em 0.45em;
  color: var(--docs-heading);
}

/* Try-it deep-link button (visually primary) */
.docs-trylink {
  display: inline-block;
  background: var(--docs-accent);
  color: #ffffff !important;
  text-decoration: none;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  margin: 4px 0;
}
.docs-trylink:hover { background: var(--docs-accent-strong); color: #ffffff; }

/* Figures */
.docs-figure { margin: 18px 0; }
.docs-figure img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--docs-border);
  border-radius: 8px;
  display: block;
}
.docs-figure figcaption { font-size: 0.85rem; color: var(--docs-text-muted); margin-top: 6px; }

/* Pro callout — max ONE per app page, ZERO on concept pages */
.doc-pro-callout {
  border: 1px solid var(--docs-pro-border);
  background: var(--docs-pro-bg);
  color: var(--docs-pro-text);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 20px 0;
}
.doc-pro-callout p { margin: 0; }
.doc-pro-callout a { color: var(--docs-pro-text); font-weight: 600; }
.doc-pro-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: var(--docs-pro-border);
  color: var(--docs-pro-text);
  border-radius: 4px;
  padding: 1px 7px;
  margin: 0 0 6px !important;
}

/* Informational / honesty callouts */
.doc-note {
  border: 1px solid var(--docs-note-border);
  background: var(--docs-note-bg);
  color: var(--docs-note-text);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 16px 0;
}
.doc-note p { margin: 0; }
.doc-warning {
  border: 1px solid var(--docs-warn-border);
  background: var(--docs-warn-bg);
  color: var(--docs-warn-text);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 16px 0;
}
.doc-warning p { margin: 0; }

/* Tables (generic + URL-API params) */
.docs-content table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
  margin: 14px 0;
}
.docs-content th, .docs-content td {
  border: 1px solid var(--docs-border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
.docs-content thead th { background: var(--docs-bg-subtle); color: var(--docs-heading); }

.docs-params { display: block; overflow-x: auto; }
.docs-params code { white-space: nowrap; }
.docs-params td:first-child code { font-weight: 600; }

/* Related links */
.docs-related { padding-left: 1.3em; }
.docs-related li { margin: 4px 0; }

/* Mini-FAQ accordions */
.docs-content details.faq-item {
  border: 1px solid var(--docs-border);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 10px 0;
  background: var(--docs-bg-subtle);
}
.docs-content details.faq-item summary { cursor: pointer; font-weight: 600; color: var(--docs-heading); }
.docs-content details.faq-item p { margin: 8px 0 0; }

/* Prev/next pager */
.docs-pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 40px;
  padding-top: 14px;
  border-top: 1px solid var(--docs-border);
  font-size: 0.92rem;
}
.docs-pager a {
  text-decoration: none;
  color: var(--docs-accent);
  padding: 8px 12px;
  border: 1px solid var(--docs-border);
  border-radius: 8px;
  max-width: 48%;
}
.docs-pager a:hover { border-color: var(--docs-accent); }
.docs-pager .pager-next { margin-left: auto; text-align: right; }

/* On-this-page TOC */
.docs-toc { font-size: 0.85rem; }
.docs-toc > div { position: sticky; top: 16px; }
.docs-toc p { font-weight: 600; color: var(--docs-heading); margin: 0 0 6px; }
.docs-toc ul { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--docs-border); }
.docs-toc li a {
  display: block;
  padding: 3px 10px;
  color: var(--docs-text-muted);
  text-decoration: none;
}
.docs-toc li a:hover { color: var(--docs-accent); }

/* ---------------------------------------------------------------------------
   Hub + section-index cards
   --------------------------------------------------------------------------- */
.docs-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin: 18px 0;
}
.docs-card {
  display: block;
  border: 1px solid var(--docs-border);
  border-radius: 10px;
  padding: 16px 18px;
  text-decoration: none;
  color: var(--docs-text);
  background: var(--docs-bg-subtle);
}
.docs-card:hover { border-color: var(--docs-accent); }
.docs-card h3 { margin: 0 0 6px; font-size: 1.05rem; color: var(--docs-heading); }
.docs-card p { margin: 0; font-size: 0.9rem; color: var(--docs-text-muted); }

.docs-page-list { list-style: none; padding: 0; margin: 14px 0; }
.docs-page-list li {
  border-bottom: 1px solid var(--docs-border);
  padding: 10px 2px;
}
.docs-page-list li a { font-weight: 600; text-decoration: none; }
.docs-page-list li p { margin: 2px 0 0; font-size: 0.9rem; color: var(--docs-text-muted); }
