/* =============================================================================
   HydrAI — hydrai.org design system
   Dark-first, aligned with the embedded Playground palette. A light override is
   provided for readers who prefer it (prefers-color-scheme: light).
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0e1016;
  --bg-2:      #141722;
  --surface:   #161a24;
  --surface-2: #1c2130;
  --border:    rgba(255, 255, 255, 0.09);
  --border-2:  rgba(255, 255, 255, 0.16);
  --text:      #e8eaf0;
  --text-muted:#9aa0b8;
  --text-dim:  #868cab;
  --accent:    #8b80ea;
  --accent-2:  #7c6fe0;
  --accent-dim:#5a4fb8;
  --accent-bg: rgba(124, 111, 224, 0.12);
  --green:     #35c08a;
  --amber:     #d6a04a;
  --red:       #e0765a;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Code', monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --maxw: 1080px;
  --nav-h: 62px;

  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:        #ffffff;
    --bg-2:      #f6f5fb;
    --surface:   #faf9fd;
    --surface-2: #f1eff9;
    --border:    rgba(20, 18, 40, 0.10);
    --border-2:  rgba(20, 18, 40, 0.20);
    --text:      #16151f;
    --text-muted:#5c5a70;
    --text-dim:  #8a889c;
    --accent:    #5a4fb8;
    --accent-2:  #534AB7;
    --accent-dim:#7f77dd;
    --accent-bg: rgba(83, 74, 183, 0.09);
    color-scheme: light;
  }
}

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); }

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Subtle radial glow behind the top of the page */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 640px;
  background: radial-gradient(70% 100% at 50% -10%, rgba(124, 111, 224, 0.16), transparent 70%);
  pointer-events: none;
  z-index: -1;
}

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

h1, h2, h3, h4 { line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: clamp(2.1rem, 5vw, 3.3rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: 1.15rem; }

code, pre, kbd { font-family: var(--mono); }
:not(pre) > code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.1em 0.4em;
  border-radius: 5px;
  font-size: 0.88em;
  color: var(--text);
}

pre {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.05rem 1.2rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
  margin: 1.1rem 0;
}
pre code { background: none; border: none; padding: 0; font-size: inherit; }

/* ── Nav ─────────────────────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
}
.logo-group { display: flex; align-items: center; gap: 10px; color: var(--text); }
.logo-group:hover { text-decoration: none; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 9px; background: #534AB7;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(83, 74, 183, 0.4);
}
.logo-mark.small { width: 26px; height: 26px; border-radius: 7px; }
.logotype { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.nav-links { display: flex; align-items: center; gap: 1.4rem; }
.nav-links a { color: var(--text-muted); font-size: 0.92rem; font-weight: 450; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links a.active { color: var(--text); }
.nav-cta {
  border: 1px solid var(--border-2); border-radius: 7px; padding: 0.35rem 0.75rem;
  color: var(--text) !important;
}
.nav-cta:hover { border-color: var(--accent); background: var(--accent-bg); }
.nav-toggle { display: none; background: none; border: 0; cursor: pointer; padding: 8px; }
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--text); margin: 4px 0; border-radius: 2px; }

/* ── Layout primitives ───────────────────────────────────────────────────── */
main { min-height: 60vh; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2rem); }
.section { padding: clamp(3rem, 7vw, 5.5rem) 0; }
.lede { font-size: 1.18rem; color: var(--text-muted); max-width: 60ch; }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.8rem; font-weight: 500; color: var(--text-muted);
  border: 1px solid var(--border-2); border-radius: 999px; padding: 0.3rem 0.8rem;
  background: var(--surface);
}
.pill-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.95rem; font-weight: 500; font-family: var(--sans);
  padding: 0.6rem 1.15rem; border-radius: 9px; cursor: pointer;
  border: 1px solid transparent; transition: transform .06s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent-2); color: #fff; }
.btn-primary:hover { background: var(--accent); }
.btn-ghost { border-color: var(--border-2); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); background: var(--accent-bg); }

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero { text-align: center; padding: clamp(3.5rem, 9vw, 7rem) 0 clamp(2.5rem, 5vw, 4rem); }
.hero h1 { margin: 1.2rem auto 0; max-width: 16ch; }
.hero h1 .grad {
  background: linear-gradient(100deg, var(--accent) 10%, #b7aef7 60%, var(--accent-2) 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero-expand { margin: 0.9rem 0 0; color: var(--text-muted); font-size: 1rem; letter-spacing: 0.01em; }
.hero-expand abbr { text-decoration: none; border-bottom: 1px dotted var(--border-2); }
.hero-expand .hl { color: var(--accent); font-weight: 600; }
.hero .lede { margin: 1.2rem auto 0; text-align: center; font-size: 1.22rem; }
.hero-cta { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; margin-top: 2rem; }
.hero-oneliner {
  margin: 2.6rem auto 0; max-width: 720px; padding: 1rem 1.3rem;
  border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text-muted); text-align: left; font-size: 0.98rem;
}
.hero-oneliner strong { color: var(--text); font-weight: 600; }

/* ── Cards / grids ───────────────────────────────────────────────────────── */
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.card {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.4rem; background: var(--surface);
  transition: border-color .15s ease, transform .15s ease;
}
.card:hover { border-color: var(--border-2); }
.card .card-ic {
  width: 38px; height: 38px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-bg); color: var(--accent); margin-bottom: 0.9rem; font-size: 1.2rem;
}
.card h3 { margin-bottom: 0.4rem; }
.card p { color: var(--text-muted); font-size: 0.95rem; }

.section-head { text-align: center; max-width: 62ch; margin: 0 auto 2.6rem; }
.section-head .eyebrow { color: var(--accent); font-weight: 600; font-size: 0.82rem; letter-spacing: 0.06em; text-transform: uppercase; }
.section-head h2 { margin: 0.5rem 0 0.7rem; }
.section-head p { color: var(--text-muted); }

.divider { height: 1px; background: var(--border); max-width: var(--maxw); margin: 0 auto; }

/* Numbered opinion list */
.opinions { display: grid; gap: 0.6rem; max-width: 840px; margin: 0 auto; counter-reset: op; }
.opinion {
  display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: start;
  border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.1rem 1.3rem; background: var(--surface);
}
.opinion::before {
  counter-increment: op; content: counter(op, decimal-leading-zero);
  font-family: var(--mono); color: var(--accent); font-size: 0.9rem; font-weight: 500; padding-top: 2px;
}
.opinion h3 { font-size: 1rem; margin-bottom: 0.2rem; }
.opinion p { color: var(--text-muted); font-size: 0.93rem; }

/* Thesis / bigger-picture section */
.pull {
  max-width: 820px; margin: 0 auto 2.2rem; text-align: center;
  font-size: clamp(1.15rem, 2.4vw, 1.5rem); line-height: 1.45; font-weight: 500; color: var(--text);
  border: 0; padding: 0 1rem;
}
.pull::before { content: "“"; color: var(--accent); }
.pull::after { content: "”"; color: var(--accent); }
.thesis-step {
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.4rem; background: var(--surface);
}
.thesis-step .step-n {
  display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  border-radius: 8px; background: var(--accent-bg); color: var(--accent); font-family: var(--mono);
  font-weight: 500; margin-bottom: 0.8rem;
}
.thesis-step h3 { margin-bottom: 0.4rem; }
.thesis-step p { color: var(--text-muted); font-size: 0.95rem; }

/* Code sample with a label */
.code-sample { margin: 1.2rem 0; }
.code-sample .code-label {
  font-family: var(--mono); font-size: 0.75rem; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.4rem;
}

/* Split feature row */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; align-items: center; }
.split .prose h2 { margin-bottom: 0.8rem; }
.split .prose p { color: var(--text-muted); margin-bottom: 0.8rem; }

/* ── CTA band ────────────────────────────────────────────────────────────── */
.cta-band { text-align: center; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--bg-2); }
.cta-band h2 { margin-bottom: 0.6rem; }
.cta-band p { color: var(--text-muted); max-width: 52ch; margin: 0 auto 1.6rem; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-foot { border-top: 1px solid var(--border); margin-top: 2rem; background: var(--bg-2); }
.foot-inner { max-width: var(--maxw); margin: 0 auto; padding: 2.4rem clamp(1rem, 4vw, 2rem); display: grid; gap: 1rem; }
.foot-brand { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 0.95rem; }
.foot-links { display: flex; gap: 1.4rem; flex-wrap: wrap; }
.foot-links a { color: var(--text-muted); font-size: 0.92rem; }
.foot-fine { color: var(--text-dim); font-size: 0.82rem; }

/* ── Docs layout ─────────────────────────────────────────────────────────── */
.docs { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 2.5rem; max-width: var(--maxw); margin: 0 auto; padding: 2.5rem clamp(1rem, 4vw, 2rem) 4rem; align-items: start; }
.docs-side { position: sticky; top: calc(var(--nav-h) + 20px); align-self: start; }
.docs-side .side-group { margin-bottom: 1.4rem; }
.docs-side .side-title { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); font-weight: 600; margin-bottom: 0.5rem; }
.docs-side a { display: block; color: var(--text-muted); font-size: 0.92rem; padding: 0.25rem 0; }
.docs-side a:hover { color: var(--text); text-decoration: none; }
.docs-side a.active { color: var(--accent); }
.docs-main { min-width: 0; }
.prose { max-width: 74ch; }
.prose > * + * { margin-top: 1rem; }
.prose h1 { margin-bottom: 0.4rem; }
.prose h2 { margin-top: 2.4rem; padding-top: 0.4rem; border-top: 1px solid var(--border); }
.prose h3 { margin-top: 1.6rem; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin-top: 0.35rem; }
.prose li::marker { color: var(--accent); }
.prose blockquote { border-left: 3px solid var(--accent); padding: 0.4rem 1rem; color: var(--text-muted); background: var(--surface); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.prose table { border-collapse: collapse; width: 100%; font-size: 0.9rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 0.5rem 0.8rem; text-align: left; }
.prose th { background: var(--surface-2); }
.prose .lede { margin-bottom: 1.4rem; }

/* callout */
.note { border: 1px solid var(--border); border-left: 3px solid var(--accent); background: var(--surface); border-radius: 0 var(--radius-md) var(--radius-md) 0; padding: 0.9rem 1.2rem; margin: 1.2rem 0; font-size: 0.95rem; }
.note.warn { border-left-color: var(--amber); }
.note strong { color: var(--text); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
  .docs { grid-template-columns: 1fr; }
  .docs-side { position: static; border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
  .nav-toggle { display: block; }
  .nav-links {
    position: absolute; top: var(--nav-h); left: 0; right: 0; flex-direction: column; align-items: stretch;
    gap: 0; background: var(--bg); border-bottom: 1px solid var(--border); padding: 0.5rem 1rem 1rem; display: none;
  }
  body.nav-open .nav-links { display: flex; }
  .nav-links a { padding: 0.6rem 0; }
}
@media (max-width: 560px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

/* ── Accessibility ───────────────────────────────────────────────────────── */
.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 100;
  background: var(--accent-2); color: #fff; padding: 0.5rem 0.9rem; border-radius: 0 0 8px 8px;
  transition: top .15s ease;
}
.skip-link:focus { top: 0; text-decoration: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
main:focus { outline: none; }

.nav-links a[aria-current="page"] { color: var(--text); }
.nav-links a[aria-current="page"]::after {
  content: ""; display: block; height: 2px; background: var(--accent); border-radius: 2px; margin-top: 2px;
}
.ext { font-size: 0.85em; opacity: 0.7; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ── Vocabulary namespace page ───────────────────────────────────────────── */
.vocab-doc { padding-top: 2.5rem; padding-bottom: 4rem; max-width: 940px; }
.vocab-doc h1 { margin: 0.8rem 0 0; font-size: clamp(1.8rem, 4vw, 2.6rem); }
.vocab-doc > .lede { margin: 1rem 0 1.4rem; white-space: pre-line; }
.vocab-doc h2 { margin: 2.6rem 0 0.4rem; padding-top: 0.6rem; border-top: 1px solid var(--border); scroll-margin-top: calc(var(--nav-h) + 16px); }
.alt-links { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 0.6rem; }
.alt-links a { margin: 0 0.15rem; }
.partition-nav { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.4rem; }
.partition-nav a { margin: 0 0.15rem; }
.partition-nav a[aria-current="page"] code { color: var(--accent); }
.vocab-meta { padding: 1.1rem 1.4rem; }
.vocab-meta p { margin: 0.3rem 0; }
.vocab-meta table { border-collapse: collapse; margin: 0.2rem 0 0.6rem; }
.vocab-meta td { padding: 0.1rem 0.9rem 0.1rem 0; font-size: 0.9rem; }

.term {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.2rem 1.4rem; margin: 0.9rem 0; background: var(--surface);
  scroll-margin-top: calc(var(--nav-h) + 16px);
}
.term.shape { border-left: 3px solid var(--accent-dim); }
.term-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.term-name { margin: 0; font-size: 1.05rem; font-weight: 600; }
.term-name a { color: var(--text); }
.term-name a:hover { color: var(--accent); text-decoration: none; }
.term-kind { font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-dim); white-space: nowrap; }
.term-label { color: var(--text-muted); margin: 0.15rem 0 0.5rem; font-size: 0.95rem; }
.term-comment { margin: 0.5rem 0; white-space: pre-line; }
.term-meta { display: grid; grid-template-columns: max-content 1fr; gap: 0.15rem 0.9rem; margin: 0.7rem 0 0; font-size: 0.88rem; }
.term-meta dt { color: var(--text-dim); }
.term-meta dd { margin: 0; word-break: break-word; }
.term-meta-inline { font-size: 0.9rem; margin: 0.5rem 0 0; }
.term-links { font-size: 0.85rem; color: var(--text-muted); margin: 0.7rem 0 0; }
.term-links code { color: inherit; }
.shape-prop { list-style: none; margin: 0.5rem 0 0; padding: 0.6rem 0.9rem; background: var(--bg-2); border-radius: var(--radius-sm); font-size: 0.86rem; }
.shape-prop li { padding: 0.12rem 0; }
.shape-prop li::marker { content: none; }
.vocab-foot-note { color: var(--text-muted); font-size: 0.9rem; margin-top: 2.4rem; border-top: 1px solid var(--border); padding-top: 1rem; }

/* Reference block reused inside docs prose */
.prose .term { background: var(--surface-2); }
