/* ============================================================================
 * docs_v2.css — v2 documentation layout + prose + code styles.
 * Loaded only on /v2/docs/* and related pages via docs_v2/_base.html.
 * Design tokens come from Base/base_v2.html :root — do not redefine here.
 * Only valid spacing-scale steps: 1 2 3 4 5 6 8 10 12 16 20 24 32.
 * ============================================================================ */


/* ============================================================ LAYOUT */

.docs-body { background: var(--bg-primary); }

/* Clear the fixed navbar — matches the .landing-page main pattern in landing.css */
.docs-body main { padding-top: var(--nav-height); }

.docs-layout {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  min-height: calc(100vh - var(--nav-height));
  /* align-items defaults to stretch — sidebar + content cells both fill row height */
}
@media (min-width: 992px) {
  .docs-layout {
    grid-template-columns: 260px minmax(0, 1fr);
  }
}


/* ============================================================ SIDEBAR
 * The outer .docs-sidebar is a normal grid cell that STRETCHES to fill the
 * row height (so its background extends all the way down to the footer,
 * with no gap). The inner .docs-sidebar-inner is position: sticky so the
 * nav items stay visible as the user scrolls through long content.
 * ============================================================ */

.docs-sidebar {
  display: none;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  font-family: var(--font-sans);
  /* NOTE: no sticky here; the inner is sticky */
}
@media (min-width: 992px) {
  .docs-sidebar { display: block; }
}

.docs-sidebar-inner {
  position: sticky;
  top: var(--nav-height);
  max-height: calc(100vh - var(--nav-height));
  overflow-y: auto;
  padding: var(--space-8) var(--space-6) var(--space-10);
}

.docs-sidebar-heading {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 var(--space-5) 0;
}

.docs-nav {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
}
.docs-nav ul {
  list-style: none;
  padding: 0 0 0 var(--space-3);
  margin: 0;
  border-left: 1px solid var(--border-color);
}
.docs-nav li { margin: 0; }
.docs-nav a {
  display: block;
  padding: 4px var(--space-3);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 6px;
}
.docs-nav a:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}
.docs-nav a.is-active {
  color: var(--accent-color);
  background: var(--accent-alpha);
  font-weight: 500;
}
/* Anchor links (same-page scroll) get a # prefix to read as "section of this page". */
.docs-nav a[href^="#"]::before {
  content: "#";
  display: inline-block;
  width: 12px;
  opacity: 0.45;
  font-family: var(--font-mono);
  font-size: 0.85em;
}
/* Page links (navigate elsewhere) get a trailing arrow to signal "go somewhere". */
.docs-nav a[href^="/"] {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.docs-nav a[href^="/"]::after {
  content: "\2192"; /* → */
  opacity: 0.35;
  font-size: 0.9em;
  transition: opacity var(--t-fast), transform var(--t-fast);
}
.docs-nav a[href^="/"]:hover::after {
  opacity: 0.8;
  transform: translateX(2px);
}

.docs-nav-group + .docs-nav-group {
  margin-top: var(--space-5);
}
.docs-nav-group-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
}


/* ============================================================ MOBILE DRAWER */

.docs-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  position: sticky;
  top: var(--nav-height, 64px);
  z-index: 10;
  width: 100%;
  padding: var(--space-3) var(--space-5);
  border: 0;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
}
.docs-sidebar-toggle i {
  width: 18px;
  height: 18px;
}
@media (min-width: 992px) {
  .docs-sidebar-toggle {
    display: none;
  }
}

.docs-sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}
.docs-sidebar-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}
@media (min-width: 992px) {
  .docs-sidebar-overlay { display: none; }
}

@media (max-width: 991px) {
  .docs-sidebar {
    display: block;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 200ms ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  }
  .docs-sidebar.is-open {
    transform: translateX(0);
  }
  body.docs-sidebar-open { overflow: hidden; }
}


/* ============================================================ CONTENT */

.docs-content {
  min-width: 0;                /* prevents content from overflowing grid */
}

.docs-content-inner {
  max-width: 780px;
  margin: 0 auto;
  padding: var(--space-10) var(--space-5) var(--space-20);
}
@media (min-width: 992px) {
  .docs-content-inner {
    padding: var(--space-16) var(--space-10) var(--space-24);
  }
}


/* ============================================================ BREADCRUMBS */

/* Breadcrumbs: quiet one-line path above the page title.
 * One color inherited everywhere, opacity on the parent to make the whole
 * thing recede. Left-edge indent is killed with explicit zero on every side
 * to defeat Bootstrap Reboot's <ol>/<ul> padding-inline-start default. */
.docs-breadcrumbs,
.docs-breadcrumbs ol,
.docs-breadcrumbs ul {
  list-style: none;
  padding: 0 !important;                 /* kills Bootstrap's padding-inline-start */
  padding-inline-start: 0 !important;
  margin: 0;
  margin-inline-start: 0 !important;
}
.docs-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0 0 var(--space-4) 0;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-muted);
  opacity: 0.7;                           /* whole line recedes */
}
.docs-breadcrumbs li {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0;
  color: inherit;
}
.docs-breadcrumbs li + li::before {
  content: "/";                            /* lighter visual weight than › */
  margin: 0 8px;
  color: inherit;
  opacity: 0.5;
}
.docs-breadcrumbs a,
.docs-breadcrumbs li:last-child {
  color: inherit;                          /* one uniform tone everywhere */
  text-decoration: none;
  font-weight: 400;                        /* no bold on current page */
}
.docs-breadcrumbs a:hover {
  color: var(--text-secondary);
  text-decoration: underline;
  opacity: 1;                              /* crumbs un-fade only on hover */
}


/* ============================================================ PAGE HEADER */

.docs-page-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: var(--space-6);
  margin-bottom: var(--space-10);
}
.docs-page-eyebrow {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-color);
  margin: 0 0 var(--space-3) 0;
}
.docs-page-title {
  font-family: var(--font-sans);
  font-size: clamp(1.85rem, 3.5vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text-primary);
  margin: 0 0 var(--space-4) 0;
}
.docs-page-lead {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 620px;
  margin: 0;
}


/* ============================================================ PROSE */

/* Section-level anchor offset. The global scroll-padding-top on html in
 * base_v2.html handles this for modern browsers; this is a per-element
 * fallback for anything targeting a section id. */
.docs-section {
  scroll-margin-top: calc(var(--nav-height, 64px) + var(--space-4));
}

.docs-content h2 {
  font-family: var(--font-sans);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
  margin: var(--space-12) 0 var(--space-4) 0;
  scroll-margin-top: calc(var(--nav-height, 64px) + var(--space-4));
}
.docs-content h3 {
  font-family: var(--font-sans);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: var(--space-8) 0 var(--space-3) 0;
  scroll-margin-top: calc(var(--nav-height, 64px) + var(--space-4));
}
.docs-content h4 {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: var(--space-5) 0 var(--space-2) 0;
}

.docs-content p {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin: 0 0 var(--space-4) 0;
  text-align: justify;
  hyphens: auto;
  text-wrap: pretty;
}
/* Pillar cards live inside .docs-content but their internal paragraphs (kicker,
   short descriptions) shouldn't inherit body-prose justify — short lines look
   broken with extra word spacing. */
.docs-content .lp-pillar-kicker,
.docs-content .lp-pillar p {
  text-align: left;
  hyphens: manual;
}
/* Override .docs-content h3's section-heading margin (var(--space-8) top) for
   pillar-card titles — those are card titles, not in-prose section headings. */
.docs-content .lp-pillar-title {
  margin: 0 0 var(--space-2) 0;
}
.docs-content strong { color: var(--text-primary); }
.docs-content a { color: var(--accent-color); }
.docs-content a:hover { text-decoration: underline; }

.docs-content ul, .docs-content ol {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin: 0 0 var(--space-4) 0;
  padding-left: var(--space-6);
}
.docs-content li { margin-bottom: var(--space-2); }
.docs-content li > ul, .docs-content li > ol { margin-top: var(--space-2); margin-bottom: 0; }


/* ============================================================ CODE */

.docs-content code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 2px 6px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  color: var(--text-primary);
  border: 1px solid var(--card-border);
  /* Disable ligatures in code so `|>`, `->`, `!=`, `>=` render as two glyphs,
     not merged into triangle / arrow / not-equal ligatures. Matters for R
     snippets with the native pipe `|>`. */
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
}

.docs-code-block {
  position: relative;
  font-family: var(--font-mono);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md, 8px);
  padding: var(--space-4) var(--space-5);
  margin: 0 0 var(--space-5) 0;
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-primary);
  /* Same ligature suppression for fenced code blocks. */
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
}
.docs-code-block pre {
  margin: 0;
  white-space: pre;
}
.docs-code-block code {
  font-size: inherit;
  padding: 0;
  background: transparent;
  border: 0;
  color: inherit;
}


/* ============================================================ TABLES */

.docs-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 var(--space-5) 0;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}
.docs-content th,
.docs-content td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
  color: var(--text-secondary);
}
.docs-content th {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.docs-content tr:last-child td { border-bottom: 0; }


/* ============================================================ STATE PILLS (shipped/drafted/coming) */

.docs-state {
  display: inline-block;
  padding: 2px 8px;
  margin-left: 8px;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  vertical-align: middle;
}
.docs-state-shipped {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}
.docs-state-drafted {
  background: rgba(234, 179, 8, 0.14);
  color: #92400e;
}
.docs-state-coming {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-secondary);
}
.docs-state-deprecated {
  background: rgba(220, 38, 38, 0.10);
  color: #b91c1c;
}
[data-mode="dark"] .docs-state-shipped { color: #34d399; background: rgba(52, 211, 153, 0.15); }
[data-mode="dark"] .docs-state-drafted { color: #fbbf24; background: rgba(251, 191, 36, 0.15); }
[data-mode="dark"] .docs-state-coming { color: var(--text-secondary); background: rgba(255, 255, 255, 0.08); }
[data-mode="dark"] .docs-state-deprecated { color: #f87171; background: rgba(248, 113, 113, 0.15); }


/* ============================================================ DOMAIN PAGE — flag, meta grid, bundle cards */

/* Catalog domain pages: page title with country flag inline */
.docs-page-title:has(.docs-page-flag) {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.docs-page-flag {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.docs-page-title-text {
  /* inherits font from h1 — flag sits to its left via parent flex */
}

.docs-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
  margin: var(--space-4) 0 var(--space-5) 0;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--bg-secondary, rgba(0, 0, 0, 0.04));
}
[data-mode="dark"] .docs-meta-grid { background: rgba(255, 255, 255, 0.04); }
.docs-meta-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.docs-meta-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.docs-meta-value {
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 500;
}

.docs-bundle-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  margin: 0 0 var(--space-4) 0;
  background: var(--bg-secondary, rgba(0, 0, 0, 0.02));
}
[data-mode="dark"] .docs-bundle-card { background: rgba(255, 255, 255, 0.03); }
.docs-bundle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}
.docs-bundle-version {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-right: 8px;
}
.docs-bundle-meta {
  font-size: var(--fs-meta);
  color: var(--text-muted);
}
.docs-bundle-changelog {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0 0 var(--space-3) 0;
  font-style: italic;
}
.docs-bundle-langs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.docs-bundle-btn {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: var(--bg, white);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  text-decoration: none;
  position: relative;
  transition: border-color var(--t-fast), background var(--t-fast);
  min-width: 140px;
}
.docs-bundle-btn:hover {
  border-color: var(--accent-color);
  background: var(--accent-alpha);
  text-decoration: none;
  color: var(--text-primary);
}
.docs-bundle-btn i {
  position: absolute;
  top: 10px; right: 10px;
  width: 14px; height: 14px;
  color: var(--text-muted);
}
.docs-bundle-btn-lang {
  font-weight: 600;
  font-size: 0.92rem;
}
.docs-bundle-btn-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
[data-mode="dark"] .docs-bundle-btn { background: rgba(255, 255, 255, 0.04); }


/* ============================================================ CALLOUTS */

.docs-callout {
  border-left: 3px solid var(--accent-color);
  background: var(--accent-alpha);
  padding: var(--space-4) var(--space-5);
  border-radius: 0 8px 8px 0;
  margin: 0 0 var(--space-6) 0;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-primary);
}
.docs-callout p:last-child { margin-bottom: 0; }
.docs-callout.docs-callout-warn {
  border-left-color: #c2410c;
  background: rgba(194, 65, 12, 0.06);
}
.docs-callout.docs-callout-muted {
  border-left-color: var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
}


/* ============================================================ SECTIONS */

.docs-section {
  margin-bottom: var(--space-10);
}


/* ============================================================ AUTHOR CARDS
 * The lp-team-* card UI is shared between landing and docs. Inside
 * .docs-content, prose rules (margin-top on h4, line-height/justify on p)
 * leak into the card and break top-alignment / make rows tall. Reset them.
 * Also provide a stacked-grid modifier for the docs use case where there's
 * no horizontal room to splay cards two-up.
 */

.docs-content .lp-team-grid {
  margin-top: var(--space-4);
  margin-bottom: 0;
}

.lp-team-grid.lp-team-grid-stacked,
.docs-content .lp-team-grid.lp-team-grid-stacked {
  grid-template-columns: 1fr;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

.docs-content .lp-team-name {
  margin: 0 0 2px 0;
  scroll-margin-top: 0;
}

.docs-content .lp-team-role,
.docs-content .lp-team-affiliation {
  text-align: left;
  hyphens: manual;
  line-height: 1.45;
}

.docs-content .lp-team-role {
  margin: 0;
}

.docs-content .lp-team-affiliation {
  margin: 2px 0 0 0;
}


/* ============================================================ HELPERS */

.docs-meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: var(--radius-pill, 999px);
  border: 1px solid var(--card-border);
}
.docs-meta-tag.docs-meta-tag-accent {
  background: var(--accent-alpha);
  color: var(--accent-color);
  border-color: transparent;
}
.docs-meta-tag.docs-meta-tag-coming {
  background: var(--bg-secondary);
  color: var(--text-muted);
}
