/* ── Docs layout ─────────────────────────────────────────────────────────── */

:root {
  --docs-sidebar-w: 240px;
  --docs-header-h: var(--header-h); /* same as main site: 80px */
}

.docs-body {
  background: var(--bg);
  color: var(--text);
  /* Reset any global animations or canvas elements from main.css */
}

/* Ensure no hero/geo-scene elements bleed into docs */
.docs-body .hero__canvas,
.docs-body .geo-globe,
.docs-body .geo-scene {
  display: none !important;
}

/* ── Header - identical to site-header ── */
.docs-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--bg);
  box-shadow: 0 0 2px 1px rgba(61,61,61,.2);
  height: var(--docs-header-h);
  display: flex;
  align-items: center;
}

.docs-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: var(--max-w, 1120px);
  margin: 0 auto;
  width: 100%;
}

/* .logo and .logo-img from main.css are reused */

.docs-header__brand {
  display: inline-flex;
  align-items: center;
  gap: .625rem;
}

.docs-header__logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.docs-header__divider {
  font-size: 1.25rem;
  font-weight: 300;
  color: var(--border);
  line-height: 1;
}

.docs-header__section {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: color .12s;
}
.docs-header__section:hover { color: var(--text); }

.docs-header__bread {
  display: none; /* visible on mobile only */
  font-size: .75rem;
  color: var(--muted);
  padding: .25rem 1.25rem;
  border-top: 1px solid var(--border);
  gap: .375rem;
  align-items: center;
}
.docs-header__bread a { color: var(--teal); text-decoration: none; }

/* Mobile nav toggle */
/* Search button in header */
.docs-search-btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .375rem .875rem;
  background: var(--surface, #f9fbfb);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: .875rem;
  color: var(--muted);
  transition: border-color .15s, color .15s;
  white-space: nowrap;
}
.docs-search-btn:hover { border-color: var(--teal); color: var(--teal); }
.docs-search-btn__kbd {
  margin-left: .25rem;
  font-size: .7rem;
  background: var(--border);
  border-radius: 4px;
  padding: .1rem .35rem;
  color: var(--muted);
}
@media (max-width: 640px) {
  .docs-search-btn__label,
  .docs-search-btn__kbd { display: none; }
  .docs-search-btn { padding: .375rem .5rem; }
}

/* Search modal */
.docs-search-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}
.docs-search-modal[hidden] { display: none; }
.docs-search-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
}
.docs-search-modal__box {
  position: relative;
  width: 100%;
  max-width: 600px;
  margin: 0 1rem;
  background: var(--bg, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
  overflow: hidden;
  max-height: 70vh;
  overflow-y: auto;
  /* Pagefind CSS variables — keep scale at 1 inside our modal */
  --pagefind-ui-scale: 1;
  --pagefind-ui-primary: var(--teal, #008080);
  --pagefind-ui-text: var(--text, #1a2b2b);
  --pagefind-ui-background: var(--bg, #fff);
  --pagefind-ui-border: var(--border, #e2e8e8);
  --pagefind-ui-border-width: 0;
  --pagefind-ui-border-radius: 0;
  --pagefind-ui-font: inherit;
}

/* Pagefind UI overrides to match site style */
#docs-search-ui .pagefind-ui__form {
  position: relative;
  border-bottom: 1px solid var(--border);
}
/* Reposition the built-in search icon — default top offset breaks after padding override */
#docs-search-ui .pagefind-ui__form::before {
  left: 1.25rem !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  width: 1.125rem !important;
  height: 1.125rem !important;
  opacity: .5 !important;
  background-color: var(--muted, #6b7a7a) !important;
}
#docs-search-ui .pagefind-ui__search-input {
  width: 100%;
  height: auto !important;
  padding: 1rem 1.25rem 1rem 2.75rem !important;
  font-size: 1rem !important;
  font-weight: 400 !important;
  border: none !important;
  border-radius: 0 !important;
  outline: none;
  background: transparent !important;
  color: var(--text);
  box-sizing: border-box;
}
#docs-search-ui .pagefind-ui__search-input::placeholder {
  color: var(--muted, #6b7a7a);
  opacity: .75 !important;
}
#docs-search-ui .pagefind-ui__search-clear { display: none; }
#docs-search-ui .pagefind-ui__results-area { margin-top: 0 !important; }
#docs-search-ui .pagefind-ui__results { padding: .5rem; }
#docs-search-ui .pagefind-ui__result {
  padding: .625rem .75rem;
  border: none !important;
  border-radius: 8px;
  cursor: pointer;
}
#docs-search-ui .pagefind-ui__result:hover { background: var(--surface-2); }
#docs-search-ui .pagefind-ui__result-title { font-weight: 600; color: var(--text); font-size: .9375rem; }
#docs-search-ui .pagefind-ui__result-excerpt { color: var(--muted); font-size: .8125rem; margin-top: .25rem; min-width: 0 !important; }
#docs-search-ui .pagefind-ui__result-excerpt mark { background: rgba(0,128,128,.18); color: var(--teal); border-radius: 2px; padding: 0 2px; }
#docs-search-ui .pagefind-ui__message { padding: 1rem 1.25rem; color: var(--muted); font-size: .875rem; height: auto !important; font-weight: 400 !important; }

.docs-nav-toggle {
  display: none;
  align-items: center;
  gap: .375rem;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text);
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .375rem .75rem;
  cursor: pointer;
}
.docs-nav-toggle:hover { background: var(--surface-2); }

/* ── Layout - same max-width as .container on main site ── */
.docs-layout {
  display: grid;
  grid-template-columns: var(--docs-sidebar-w) 1fr;
  min-height: calc(100vh - var(--docs-header-h));
  max-width: var(--max-w, 1120px);
  margin: 0 auto;
  width: 100%;
}

/* ── Sidebar - aligned with site typography ── */
.docs-sidebar {
  position: sticky;
  top: var(--docs-header-h);
  height: calc(100vh - var(--docs-header-h));
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 2rem 0;
  scrollbar-width: thin;
}

.docs-sidebar__nav { padding: 0 .75rem; }

.docs-sidebar__group { margin-bottom: 2rem; }

.docs-sidebar__section {
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .625rem;
  padding: 0 .625rem;
}

.docs-sidebar__nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: .125rem;
}

.docs-sidebar__link {
  display: block;
  padding: .425rem .625rem;
  border-radius: 8px;
  font-size: .875rem;
  color: var(--muted);
  text-decoration: none;
  transition: background .12s, color .12s;
  line-height: 1.4;
}
.docs-sidebar__link:hover { background: var(--surface-2); color: var(--text); }
.docs-sidebar__link.active {
  background: rgba(0,128,128,.1);
  color: var(--teal);
  font-weight: 600;
}

/* Child pages */
.docs-sidebar__children {
  list-style: none;
  padding: 0;
  margin: .125rem 0 .25rem;
  border-left: 2px solid rgba(0,128,128,.25);
  margin-left: 1rem;
}
.docs-sidebar__link--child {
  font-size: .8125rem;
  padding: .3rem .625rem;
  color: var(--muted);
}
.docs-sidebar__link--child::before {
  content: '';
}

.docs-sidebar__api-ref {
  display: block;
  padding: .4rem .5rem;
  font-size: .875rem;
  color: var(--teal);
  text-decoration: none;
  border: 1px solid rgba(0,128,128,.25);
  border-radius: 6px;
  text-align: center;
  transition: background .12s;
}
.docs-sidebar__api-ref:hover { background: rgba(0,128,128,.08); }

/* Overlay */
.docs-sidebar__overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 150;
  opacity: 0;
  transition: opacity .2s;
}
.docs-sidebar__overlay.visible { opacity: 1; }

/* ── Content - fills remaining grid column ── */
.docs-content {
  min-width: 0;
  padding: 2rem 2.5rem 5rem;
}

/* Breadcrumb - matches site section-label style */
.docs-breadcrumb {
  margin-bottom: 1.75rem;
}
.docs-breadcrumb ol {
  display: flex;
  align-items: center;
  gap: .375rem;
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: .8125rem;
  color: var(--muted);
  flex-wrap: wrap;
}
.docs-breadcrumb a { color: var(--muted); text-decoration: none; transition: color .12s; }
.docs-breadcrumb a:hover { color: var(--teal); }
.docs-breadcrumb [aria-current="page"] { color: var(--text); font-weight: 600; }

/* Article prose - matches site heading scale */
.docs-article h1 {
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -.025em;
  margin-bottom: .875rem;
  line-height: 1.15;
  color: var(--text);
}
.docs-article h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 2.25rem 0 .75rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
  color: var(--text);
}
.docs-article h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 1.5rem 0 .5rem;
  color: var(--text);
}
.docs-article p { line-height: 1.7; margin-bottom: 1rem; color: var(--muted); }
.docs-article p:has(+ ul), .docs-article p:has(+ ol) { margin-bottom: .5rem; }
.docs-article strong { color: var(--text); font-weight: 600; }
.docs-article a { color: var(--teal); text-decoration: underline; text-underline-offset: 3px; }
.docs-article ul, .docs-article ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  color: var(--muted);
}
.docs-article code:not(pre code) {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .1rem .4rem;
  font-size: .875em;
  color: var(--teal-dark, #005f5f);
}
.docs-article pre,
pre.docs-code,
.astro-code {
  background: #0d1117;
  border-radius: 10px;
  padding: 1.25rem 1.5rem !important;
  overflow-x: auto;
  margin: 1.25rem 0;
  font-size: .875rem;
  line-height: 1.7;
}
.docs-article pre code,
pre.docs-code code { color: #e6edf3; background: none; border: none; padding: 0; font-size: inherit; }
/* Shiki (astro:components Code) output */
.astro-code,
.astro-code span { font-family: 'Roboto Mono', 'SF Mono', Consolas, monospace; }

/* Callout */
.docs-callout {
  border-left: 3px solid var(--teal);
  background: rgba(0,128,128,.05);
  border-radius: 0 8px 8px 0;
  padding: .875rem 1.125rem;
  margin: 1.5rem 0;
  font-size: .9375rem;
  line-height: 1.65;
  color: var(--muted);
}
.docs-callout strong { color: var(--text); }
.docs-callout--warn { border-color: #c97a00; background: rgba(201,122,0,.04); }
.docs-callout--info { border-color: #3b82f6; background: rgba(59,130,246,.04); }

/* Steps - timeline */
.docs-steps {
  margin: 2rem 0;
  position: relative;
}

/* Vertical connecting line between circle centres */
.docs-steps::before {
  content: '';
  position: absolute;
  left: 1.25rem;     /* half of the 2.5rem circle */
  top: 1.25rem;
  bottom: 1.25rem;
  width: 2px;
  border-radius: 1px;
  background: linear-gradient(to bottom,
    rgba(0,128,128,.45) 0%,
    rgba(0,128,128,.12) 100%);
}

.docs-step {
  display: grid;
  grid-template-columns: 2.5rem 1fr;
  gap: 1rem;
  position: relative;
  margin-bottom: 1.125rem;
}
.docs-step:last-child { margin-bottom: 0; }

/* Numbered circle */
.docs-step__num {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--teal, #008080);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8125rem;
  font-weight: 700;
  font-family: 'Roboto Mono', monospace;
  flex-shrink: 0;
  align-self: start;
  position: relative;
  z-index: 1;
  /* white ring to "cut" through the connecting line */
  box-shadow: 0 0 0 5px var(--bg, #fff);
}

/* Content card */
.docs-step__body {
  background: var(--surface, #f9fbfb);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 1.125rem 1.375rem 1.25rem;
  min-width: 0;
}

.docs-step__body h3 {
  margin: 0 0 .75rem !important;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  padding-bottom: .625rem;
  border-bottom: 1px solid var(--border);
}

.docs-step__body p { margin-bottom: .75rem; color: var(--muted); }
.docs-step__body p:last-child { margin-bottom: 0; }
.docs-step__body p:has(+ pre),
.docs-step__body p:has(+ .docs-code) { margin-bottom: .375rem; }

.docs-step__body pre,
.docs-step__body pre.docs-code,
.docs-step__body .astro-code { margin: .625rem 0 !important; }
.docs-step__body pre:last-child,
.docs-step__body .astro-code:last-child { margin-bottom: 0 !important; }

.docs-step__body .docs-callout { margin: .75rem 0; }

/* Call-to-action button inside a step */
.docs-step-btn {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .625rem 1.25rem;
  background: var(--teal);
  color: #fff !important;
  font-size: .9375rem;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none !important;
  text-underline-offset: unset;
  margin: .75rem 0;
  transition: background .15s;
}
.docs-step-btn:hover { background: var(--teal-dark, #006666); text-decoration: none; }

/* Mobile: tighten up */
@media (max-width: 480px) {
  .docs-steps::before { display: none; }
  .docs-step { grid-template-columns: 2rem 1fr; gap: .75rem; }
  .docs-step__num { width: 2rem; height: 2rem; font-size: .75rem; box-shadow: none; }
  .docs-step__body { padding: .875rem 1rem 1rem; border-radius: 8px; }
}

/* Diagrams */
.docs-diagram {
  border: 1px solid var(--border);
  border-radius: var(--radius, 12px);
  overflow: hidden;
  background: #fff;
  padding: 1.5rem 1.5rem 1rem;
  margin: 1.75rem 0;
}

.docs-diagram__caption {
  margin-top: 1rem;
  font-size: .8125rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1.5rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}

.docs-diagram__legend {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
}

/* Data table */
.docs-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius, 12px);
  overflow: hidden;
  margin: 1.25rem 0;
}

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

.docs-table tr { border-bottom: 1px solid var(--border); }
.docs-table tr:last-child { border-bottom: none; }

.docs-table td {
  padding: .625rem 1rem;
  vertical-align: top;
  line-height: 1.55;
}

.docs-table td:first-child {
  white-space: nowrap;
  width: 1%;
  padding-right: 1.5rem;
}

.docs-table td code {
  font-size: .8125rem;
  font-weight: 700;
  color: var(--teal);
  background: none;
  border: none;
  padding: 0;
}

.docs-table td:last-child { color: var(--muted); }

/* API mini-grid in steps */
.docs-api-examples {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin: 1rem 0;
}

.docs-api-example {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
}

.docs-api-example__label {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--surface-2);
  padding: .4rem .875rem;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.docs-api-example pre {
  margin: 0 !important;
  border-radius: 0 !important;
  font-size: .8125rem !important;
}

/* See-also row */
.docs-seealso {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .25rem 1.25rem;
  margin: .75rem 0 0 !important;
  font-size: .875rem;
}
.docs-seealso span {
  color: var(--muted);
  font-weight: 500;
  margin-right: .25rem;
}
.docs-seealso a {
  color: var(--teal) !important;
  font-weight: 600;
  text-decoration: none !important;
}
.docs-seealso a:hover { text-decoration: underline !important; text-underline-offset: 3px; }

/* Prev/Next nav */
.docs-prevnext {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
}
.docs-prevnext a {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1.25rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .9375rem;
  font-weight: 600;
  color: var(--teal) !important;
  text-decoration: none !important;
  transition: border-color .15s, background .15s;
  flex: 1;
  max-width: 48%;
}
.docs-prevnext a:hover { border-color: var(--teal); background: rgba(0,128,128,.04); }
.docs-prevnext__next { justify-content: flex-end; margin-left: auto; }

/* All block children fill the content column */
.docs-article > *,
.docs-article .docs-steps,
.docs-article .docs-callout,
.docs-article .docs-api-examples,
.docs-article pre {
  width: 100%;
  box-sizing: border-box;
}

/* ── Mobile ── */
@media (max-width: 768px) {
  .docs-nav-toggle { display: inline-flex; }
  .docs-header__bread { display: flex; }
  .docs-header { height: auto; }

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

  .docs-sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: min(var(--docs-sidebar-w), 85vw);
    height: 100vh;
    z-index: 180;
    background: var(--bg);
    border-right: 1px solid var(--border);
    transition: left .25s ease;
    padding-top: 1rem;
  }
  .docs-sidebar.open { left: 0; }
  .docs-sidebar__overlay { display: block; }

  .docs-content { padding: 1.25rem 1.25rem 3rem; }
  .docs-breadcrumb { display: none; } /* shown in header on mobile */

  .docs-prevnext { flex-direction: column; }
  .docs-prevnext a { max-width: 100%; }
  .docs-prevnext__next { margin-left: 0; justify-content: flex-start; }
}

@media (min-width: 769px) {
  .docs-header__back-text { display: inline; }
}
