/* nWave documentation site — dark theme only.
   Tokens translated from branding/design-systems/web/design-system.md
   (live nwave.ai production values). */

:root {
  /* Brand accent */
  --accent-primary: #fac30f;
  --accent-hover: #ffe04a;
  --accent-muted: #d4a50d;
  --accent-tint-bg: #fac30f1a;
  --accent-glow-bg: #fac30f0d;
  --accent-glow-border: #fac30f33;

  /* Backgrounds & surfaces */
  --bg-base: #0a0a0a;
  --bg-surface: #111114;
  --bg-card: #1a1a1a;
  --bg-card-hover: #222222;

  /* Text */
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --text-muted: #6b6b6b;

  /* Borders */
  --border-subtle: #ffffff0f;
  --border-default: #ffffff1a;
  --border-hover: #ffffff33;

  /* System */
  --green: #22c55e;
  --red: #ef4444;

  /* Fonts */
  --font-body: "Lato", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-label: "Quattrocento", Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --radius-md: 0.5rem;
  --radius-lg: 1rem;
  --duration-fast: 0.15s;
  --duration-normal: 0.3s;

  --content-max: 48rem;
  --sidebar-w: 17rem;
  --pagetoc-w: 14rem;
  --header-h: 3.75rem;
}

* { box-sizing: border-box; }

html { font-size: 16px; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 1rem); }

body {
  margin: 0;
  color: var(--text-primary);
  background: var(--bg-base);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-primary); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ---------- Header / navbar ---------- */

.nw-navbar-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  height: var(--header-h);
  padding: 0 1.5rem;
  background: color-mix(in srgb, var(--bg-base) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-default);
}

.nw-navbar-logo a {
  display: inline-flex;
  align-items: baseline;
  gap: 0.15rem;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}
.nw-navbar-logo a:hover { text-decoration: none; }
.nw-navbar-logo__img { height: 22px; width: auto; display: block; align-self: center; }
.nw-navbar-logo__sub {
  font-family: var(--font-label);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  margin-left: 0.35rem;
  align-self: center;
}

.nw-navbar-links {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  justify-content: center;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.nw-navbar-links::-webkit-scrollbar { display: none; }

.nw-navbar-links .nw-navbar-link {
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-md);
  white-space: nowrap;
  font-weight: 500;
}
.nw-navbar-links .nw-navbar-link:hover { background: var(--bg-card); }
.nw-navbar-links .nw-navbar-link.active {
  color: var(--accent-primary);
  background: var(--accent-tint-bg);
}

.nw-navbar-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.version-select__label {
  font-family: var(--font-label);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

#version-select {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  transition: border-color var(--duration-fast);
}
#version-select:hover { border-color: var(--border-hover); }

.nw-navbar-link {
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.nw-navbar-link:hover { color: var(--text-primary); text-decoration: none; }

/* ---------- Search trigger ---------- */

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.32rem 0.6rem;
  cursor: pointer;
  transition: border-color var(--duration-fast), color var(--duration-fast);
}
.search-trigger:hover { border-color: var(--border-hover); color: var(--text-primary); }
.search-trigger__icon { font-size: 1.05rem; line-height: 1; }
.search-trigger__key {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  border: 1px solid var(--border-default);
  border-radius: 0.25rem;
  padding: 0 0.3rem;
  color: var(--text-muted);
}

/* ---------- Version picker ---------- */

.version-picker { position: relative; }
.version-picker__button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.32rem 0.6rem;
  cursor: pointer;
  transition: border-color var(--duration-fast);
}
.version-picker__button:hover { border-color: var(--border-hover); }
.version-picker__caret { color: var(--text-secondary); font-size: 0.7rem; }

.version-picker__pop {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  width: 18rem;
  max-width: 80vw;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 60px #0009;
  padding: 0.6rem;
  z-index: 40;
}
.version-picker__search {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.5rem;
}
.version-picker__search:focus { outline: none; border-color: var(--accent-primary); }
.version-picker__list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 16rem;
  overflow-y: auto;
}
.version-picker__opt {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.38rem 0.5rem;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.version-picker__opt:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.version-picker__opt--grouped { padding-left: 1rem; }
.version-picker__opt.current { color: var(--accent-primary); font-weight: 600; }
.version-picker__empty { color: var(--text-muted); font-size: 0.85rem; padding: 0.5rem; }
.version-picker__more {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  background: none;
  border: 0;
  border-top: 1px solid var(--border-subtle);
  color: var(--accent-primary);
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 0.5rem;
  cursor: pointer;
  text-align: left;
}
.version-picker__more:hover { color: var(--accent-hover); }

/* ---------- Layout ---------- */

.site-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, var(--content-max)) var(--pagetoc-w);
  gap: 2.5rem;
  justify-content: center;
  max-width: 88rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* The landing page has no category context and no in-page headings, so it
   collapses both side rails and centres on the content column. */
.site-layout:has(.landing) {
  grid-template-columns: minmax(0, 64rem);
}
.site-layout:has(.landing) .doc-sidebar,
.site-layout:has(.landing) .page-toc {
  display: none;
}

/* ---------- Left sidebar nav ---------- */

.doc-sidebar {
  font-size: 0.9rem;
  min-width: 0;
}
.doc-sidebar.is-empty { display: none; }
.doc-sidebar nav {
  position: sticky;
  top: calc(var(--header-h) + 1.5rem);
  max-height: calc(100vh - var(--header-h) - 3rem);
  overflow-y: auto;
  padding-right: 0.5rem;
}

.nav-section { margin-bottom: 1.5rem; }
.nav-section__title {
  font-family: var(--font-label);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--accent-muted);
  margin: 0 0 0.5rem;
  font-weight: 700;
}

.nav-tree, .nav-tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-tree ul { padding-left: 0.85rem; border-left: 1px solid var(--border-subtle); margin-left: 0.1rem; }
.nav-tree li { margin: 0.05rem 0; }
.nav-tree a {
  display: block;
  padding: 0.28rem 0.5rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  line-height: 1.35;
  transition: background var(--duration-fast), color var(--duration-fast);
}
.nav-tree a:hover { background: var(--bg-card); color: var(--text-primary); text-decoration: none; }
.nav-tree a.current {
  color: var(--accent-primary);
  background: var(--accent-tint-bg);
  font-weight: 600;
}
.nav-tree__branch > a { color: var(--text-primary); font-weight: 600; }

/* ---------- Main content ---------- */

.doc-main { min-width: 0; }

.doc__title {
  font-size: clamp(2rem, 1.4rem + 2vw, 2.75rem);
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 1.5rem;
}

.doc h1, .doc h2, .doc h3, .doc h4 {
  font-family: var(--font-body);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  scroll-margin-top: calc(var(--header-h) + 1rem);
}
.doc h2 {
  font-size: 1.6rem;
  margin: 2.75rem 0 0.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
}
.doc h3 { font-size: 1.25rem; margin: 2rem 0 0.5rem; }
.doc h4 { font-size: 1.05rem; margin: 1.5rem 0 0.5rem; color: var(--text-secondary); }

.doc p { margin: 0.85rem 0; color: #e8e8e8; }
.doc strong { font-weight: 700; color: var(--text-primary); }
.doc em { font-style: italic; }

.doc a { text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--accent-glow-border); }
.doc a:hover { text-decoration-color: var(--accent-hover); }

.doc ul, .doc ol { padding-left: 1.4rem; margin: 0.85rem 0; }
.doc li { margin: 0.3rem 0; color: #e8e8e8; }

.doc code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 0.1em 0.35em;
  border-radius: 0.3rem;
  color: var(--accent-hover);
}

.doc pre {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.55;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  padding: 1rem 1.15rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 1.25rem 0;
}
.doc pre code {
  background: none;
  border: none;
  padding: 0;
  color: #e8e8e8;
  font-size: inherit;
}

.doc blockquote {
  border-left: 3px solid var(--accent-primary);
  background: var(--accent-glow-bg);
  margin: 1.25rem 0;
  padding: 0.5rem 1.15rem;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-secondary);
}
.doc blockquote p { color: var(--text-secondary); }

.doc table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.92rem;
  display: block;
  overflow-x: auto;
}
.doc th, .doc td {
  text-align: left;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border-default);
}
.doc th { background: var(--bg-surface); font-weight: 700; color: var(--text-primary); }
.doc tr:nth-child(even) td { background: var(--bg-surface); }

.doc img { max-width: 100%; height: auto; display: block; margin: 1.75rem auto; border-radius: var(--radius-md); }
.doc figure { margin: 1.75rem 0; }
.doc figcaption { font-size: 0.85rem; color: var(--text-secondary); text-align: center; margin-top: 0.5rem; }

.doc hr { border: none; border-top: 1px solid var(--border-default); margin: 2.5rem 0; }

/* ---------- Right "on this page" toc ---------- */

.page-toc { font-size: 0.82rem; min-width: 0; }
.page-toc nav {
  position: sticky;
  top: calc(var(--header-h) + 1.5rem);
  max-height: calc(100vh - var(--header-h) - 3rem);
  overflow-y: auto;
}
.page-toc__heading {
  font-family: var(--font-label);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin: 0 0 0.6rem;
  font-weight: 700;
}
.page-toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border-subtle); }
.page-toc li { margin: 0; }
.page-toc a {
  display: block;
  padding: 0.25rem 0 0.25rem 0.75rem;
  margin-left: -1px;
  color: var(--text-muted);
  border-left: 2px solid transparent;
}
.page-toc a:hover { color: var(--text-secondary); text-decoration: none; }
.page-toc a.active { color: var(--accent-primary); border-left-color: var(--accent-primary); }
.page-toc li.lvl-3 a { padding-left: 1.5rem; font-size: 0.95em; }

/* ---------- Landing page ---------- */

.landing { max-width: 64rem; margin: 0 auto; }
.landing__hero { text-align: center; padding: 3rem 0 3.5rem; }
.nw-section-label {
  font-family: var(--font-label);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent-primary);
  margin: 0 0 1rem;
}
.landing__headline {
  font-size: clamp(2.2rem, 1.4rem + 3vw, 3.75rem);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0 0 1rem;
}
.landing__subhead {
  font-size: clamp(1.05rem, 0.95rem + 0.5vw, 1.3rem);
  color: var(--text-secondary);
  max-width: 38rem;
  margin: 0 auto;
}

/* Optional explainer video (rendered only when landing.video_embed is set). */
.landing__video { margin: 0 auto 3rem; max-width: 52rem; }
.landing__video-frame {
  position: relative;
  padding-top: 56.25%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-default);
  background: var(--bg-card);
}
.landing__video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Getting-started prose (rendered from landing.md, inherits .doc styles). */
.landing__guide {
  max-width: 44rem;
  margin: 0 auto 3.5rem;
}
.landing__guide h2 {
  border-top: none;
  padding-top: 0;
  margin-top: 2.5rem;
}
.landing__guide > h2:first-child { margin-top: 0; }

.landing__nav-label {
  text-align: center;
  margin-bottom: 1.25rem;
}

.quadrant-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.nw-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  transition: background var(--duration-normal), border-color var(--duration-normal), transform var(--duration-normal);
}
.quadrant-card {
  display: block;
  padding: 1.75rem;
  color: inherit;
}
.quadrant-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-glow-border);
  transform: translateY(-2px);
  text-decoration: none;
}
.quadrant-card__kicker {
  font-family: var(--font-label);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-muted);
  margin-bottom: 0.6rem;
}
.quadrant-card__title { font-size: 1.4rem; font-weight: 700; margin: 0 0 0.5rem; }
.quadrant-card__desc { color: var(--text-secondary); font-size: 0.95rem; margin: 0 0 1rem; }
.quadrant-card__cta { color: var(--accent-primary); font-weight: 600; font-size: 0.9rem; }

/* ---------- Edit links + pager ---------- */

.doc-edit {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.85rem;
}
.doc-edit a { color: var(--text-secondary); }
.doc-edit a:hover { color: var(--accent-primary); }

.doc-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}
.doc-pager__link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  text-decoration: none;
  transition: border-color var(--duration-fast), background var(--duration-fast);
}
.doc-pager__link:hover { border-color: var(--accent-glow-border); background: var(--bg-card-hover); text-decoration: none; }
.doc-pager__next { text-align: right; }
.doc-pager__dir { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.doc-pager__title { color: var(--accent-primary); font-weight: 600; font-size: 0.95rem; }

/* ---------- Search overlay (Pagefind) ---------- */

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #000a;
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 8vh 1rem 1rem;
}
.search-overlay[hidden] { display: none; }
.search-overlay__panel {
  width: 100%;
  max-width: 42rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px #000a;
  padding: 1.25rem;
  max-height: 80vh;
  overflow-y: auto;
}
body.search-open { overflow: hidden; }
.search-unavailable { color: var(--text-secondary); text-align: center; padding: 2rem 1rem; }

/* Pagefind UI theme — map its CSS variables onto the nWave palette. */
#search-box {
  --pagefind-ui-primary: var(--accent-primary);
  --pagefind-ui-text: var(--text-primary);
  --pagefind-ui-background: var(--bg-surface);
  --pagefind-ui-border: var(--border-default);
  --pagefind-ui-tag: var(--bg-card);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: 0.5rem;
  --pagefind-ui-font: var(--font-body);
}

/* ---------- Footer ---------- */

.nw-footer {
  border-top: 1px solid var(--border-default);
  padding: 2rem 1.5rem;
  text-align: center;
}
.nw-footer-copyright { color: var(--text-muted); font-size: 0.85rem; margin: 0; }
.nw-footer code { background: none; color: var(--text-secondary); }
.nw-footer a { color: var(--text-secondary); }

/* ---------- Mobile ---------- */

.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 1.25rem;
  left: 1.25rem;
  z-index: 40;
  background: var(--accent-primary);
  color: var(--bg-base);
  border: none;
  border-radius: 9999px;
  padding: 0.7rem 1.2rem;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  box-shadow: 0 8px 24px #0009;
}

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

@media (max-width: 820px) {
  .site-layout { grid-template-columns: minmax(0, 1fr); padding-top: 1.5rem; }
  .quadrant-grid { grid-template-columns: minmax(0, 1fr); }
  .sidebar-toggle { display: block; }
  .doc-sidebar {
    position: fixed;
    inset: var(--header-h) 0 0 0;
    z-index: 35;
    background: var(--bg-base);
    padding: 1.5rem;
    transform: translateX(-100%);
    transition: transform var(--duration-normal);
    overflow-y: auto;
  }
  .doc-sidebar.open { transform: translateX(0); }
  .doc-sidebar nav { position: static; max-height: none; }
  .version-select__label { display: none; }
  .nw-navbar-link--ext { display: none; }
  .nw-navbar-header { padding: 0 1rem; gap: 0.5rem; }
  .nw-navbar-links { justify-content: flex-start; }
}
