/* ── Design tokens — Wagoe brand ─────────────────────────────────────────────
   Light is the default; dark is opt-in via html[data-theme="dark"].
   Palette: ink + one deep teal, copper as a sparing warm accent.            */
:root {
  /* Surfaces */
  --bg:           #F5F6F5;
  --bg-1:         #FFFFFF;
  --bg-2:         #EEF4F1;   /* mist */
  --bg-3:         #E2ECE7;
  --ink:          #0F1C18;   /* deliberate dark panel on a light page */

  --border:       rgba(15,28,24,0.10);
  --border-md:    rgba(15,28,24,0.17);
  --hover-tint:   rgba(15,28,24,0.045);
  --nav-bg:       rgba(245,246,245,0.88);

  /* Text */
  --text:         #16211D;
  --text-muted:   #55665F;
  --text-subtle: #5A6B64;

  /* Brand */
  --teal:         #12836D;
  --teal-soft:    #5FD3B6;
  --copper:       #A05C2B;

  /* Accent — the readable brand colour for text, links and fills.
     Flips to light teal on dark so it stays legible on ink.               */
  --accent:       #107A65;
  --accent-hover: #0D6B58;
  --accent-on:    #FFFFFF;
  --accent-tint:  rgba(18,131,109,0.09);
  --accent-line:  rgba(18,131,109,0.24);
  --accent-glow:  rgba(18,131,109,0.26);

  /* Code surfaces */
  --code-bg:      #F3F7F5;
  --code-inline:  #EAF2EE;

  --font-body:    'Inter', system-ui, sans-serif;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;
  --nav-h:        84px;
  --sidebar-w:    272px;
}

html[data-theme="dark"] {
  --bg:           #0F1C18;
  --bg-1:         #142621;
  --bg-2:         #172D27;
  --bg-3:         #1F382F;
  --ink:          #0A1512;

  --border:       rgba(255,255,255,0.07);
  --border-md:    rgba(255,255,255,0.14);
  --hover-tint:   rgba(255,255,255,0.05);
  --nav-bg:       rgba(15,28,24,0.90);

  --text:         #E3EEEA;
  --text-muted:   #94A9A1;
  --text-subtle: #7B958B;

  --teal:         #2FA98C;
  --teal-soft:    #5FD3B6;
  --copper:       #E0A579;

  --accent:       #5FD3B6;
  --accent-hover: #7FE2C9;
  --accent-on:    #06120F;
  --accent-tint:  rgba(95,211,182,0.11);
  --accent-line:  rgba(95,211,182,0.28);
  --accent-glow:  rgba(95,211,182,0.28);

  --code-bg:      #0A1512;
  --code-inline:  rgba(255,255,255,0.06);
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  display: flex;
  min-height: 100vh;
}

/* ── Top navigation bar ──────────────────────────────────────────────────── */
.top-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 300;
  height: var(--nav-h);
  background: var(--nav-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.top-nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* The wordmark's glyphs sit low inside its line-height:1 box, so the mark and
   badge are aligned to the glyphs (not the box) above. That leaves the visible
   lockup ~3px higher than the rest of the bar, so nudge the group back down to
   sit on the same centreline as the nav links. */
.top-nav-brand {
  position: relative;
  top: 3px;
  display: flex;
  align-items: baseline;
  gap: 11px;
  text-decoration: none;
  flex-shrink: 0;
}

/* The s-expression mark: inline SVG inheriting currentColor. */
.brand-mark {
  align-self: center;
  position: relative;
  top: -3px;
  width: 44px;
  height: 44px;
  color: var(--accent);
  flex-shrink: 0;
}

.top-nav-brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2rem;
  color: var(--accent);
  letter-spacing: -0.015em;
  line-height: 1;
}

/* Baseline-aligned with the wordmark, then nudged up onto the optical middle of
   the letterforms: 'wagoe' is all x-height, so a chip sharing its baseline reads
   bottom-heavy. */
.top-nav-badge {
  position: relative;
  top: -4px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  background: var(--bg-1);
  color: var(--accent);
  border: 1px solid var(--accent-line);
  border-radius: 4px;
  padding: 2px 6px;
}

.top-nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
}

.top-nav-links a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.top-nav-links a:hover { color: var(--text); }
.top-nav-links a.active { color: var(--text); }

.top-nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  line-height: 0;
}

.top-nav-gh {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.top-nav-gh:hover { color: var(--text); }

.top-nav-cta {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-body);
  background: var(--accent);
  color: var(--accent-on);
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
  white-space: nowrap;
}

.top-nav-cta:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 20px var(--accent-glow);
  transform: translateY(-1px);
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-2);
  flex-shrink: 0;
  position: fixed;
  top: var(--nav-h);
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  border-right: 1px solid var(--border-md);
  overflow-y: auto;
}

.nav-sections {
  list-style: none;
  margin: 0;
  padding: 0.75rem 0 2rem;
  flex: 1;
}

.nav-section { margin-bottom: 0; }

.nav-section-title {
  display: block;
  padding: 0.75rem 1.25rem 0.25rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  user-select: none;
}

.nav-section.active .nav-section-title { color: var(--text); }

.nav-pages {
  list-style: none;
  margin: 0;
  padding: 0 0 0.25rem;
}

.nav-page a {
  display: block;
  padding: 0.32rem 1.25rem 0.32rem 1.5rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.45;
  border-left: 2px solid transparent;
  transition: color 0.1s, background 0.1s;
}

.nav-page a:hover {
  color: var(--text);
  background: var(--hover-tint);
}

.nav-page.active > a {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--bg-1);
  font-weight: 500;
}

/* ── Content column ──────────────────────────────────────────────────────── */
main.content {
  margin-left: var(--sidebar-w);
  padding-top: var(--nav-h);
  flex: 1;
  min-width: 0;
  background: var(--bg-1);
  color: var(--text);
}

/* ── Page wrap: readable line length ─────────────────────────────────────── */
.page-wrap {
  padding: 2.5rem 3rem 5rem;
  max-width: 860px;
}

.page-wrap > #header,
.page-wrap > #content,
.page-wrap > #footnotes,
.page-wrap > #footer {
  width: auto;
  max-width: none;
  margin: 0;
  padding: 0;
}

.page-wrap > #header { padding-bottom: 0; }
#header > h1:first-child { margin-top: 0; color: var(--accent); }
.page-wrap > #content { margin-top: 1.75rem; }
#content { margin-left: 0; margin-right: 0; }
#content h2 { margin-top: 2rem; margin-bottom: 0.5rem; }
#content h3 { margin-top: 1.5rem; }

/* Section h2 as visual anchors */
#content h2 {
  color: var(--text);
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border-md);
}

/* HR */
#header hr, #content hr {
  border: none;
  border-top: 1px solid var(--border-md);
  margin: 1.25rem 0;
}

/* ── Asciidoctor overrides ───────────────────────────────────────────────── */
/* asciidoctor.css hardcodes its own palette on ~20 selectors. layout.css     */
/* loads after it, so same-or-higher specificity rules win. Everything here   */
/* is var-driven, so a single token block covers both themes.                 */

/* Headings + display type */
#content h1, #content h2, #content h3,
#content h4, #content h5, #content h6 { color: var(--text); }
#header h1, #content h1, #content h2, #content h3,
#content h4, #content h5, #content h6 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.015em;
}

/* asciidoctor.css ships a serif body and Open Sans furniture; sweep those onto
   the brand faces. Colour overrides live in the rules further down. */
#header, #content, #footnotes,
#content .verseblock pre, #content .admonitionblock td.icon .title,
#content .admonitionblock td.content > .title, #content .listingblock > .title,
#content .literalblock > .title, #content .paragraph > .title,
#content .ulist > .title, #content .olist > .title, #content .dlist > .title,
#content table.tableblock > .title, #content .quoteblock > .title,
#content .exampleblock > .title, #content .imageblock > .title,
#toc ul { font-family: var(--font-body); }
#content kbd, #content .conum[data-value] { font-family: var(--font-mono); }
#header a { color: var(--accent); }

/* Body text — paragraphs, lists, definition lists */
#content p, #content li, #content dt, #content dd,
#content .paragraph p,
#content .paragraph.lead > p,
#content #preamble .sectionbody > .paragraph p { color: var(--text); }

/* Links */
#content a { color: var(--accent); }

/* Heading anchor links */
#content h1 > a.link, #content h2 > a.link,
#content h3 > a.link, #content h4 > a.link,
#content h5 > a.link, #content h6 > a.link { color: var(--text); }
#content h2 > a.link:hover, #content h3 > a.link:hover { color: var(--accent); }

/* Inline code */
#content code { color: var(--text); font-family: var(--font-mono); }
#content :not(pre):not([class^=L])>code {
  background: var(--code-inline);
  border-color: var(--border-md);
}

/* Pre / code blocks */
#content pre, #content pre code { color: var(--text); font-family: var(--font-mono); }
#content .listingblock>.content>pre,
#content pre.highlight,
#content pre {
  background: var(--code-bg);
  border-color: var(--border-md);
}
/* highlight.js themes paint their own background on code.hljs, which would
   sit as a second panel inside our pre. Let the pre own the surface. */
#content pre code.hljs { background: transparent; padding: 0; }

/* Keyboard / menu shortcuts */
#content kbd {
  color: var(--text);
  background: var(--bg-3);
  border-color: var(--border-md);
  box-shadow: none;
}
#content .keyseq, #content .menuseq, #content .menuref { color: var(--text); }

/* Blockquotes and verse blocks */
#content blockquote, #content blockquote p,
#content .quoteblock blockquote, #content .quoteblock p,
#content .verseblock pre { color: var(--text); }
#content .quoteblock .attribution cite,
#content .verseblock .attribution cite { color: var(--text-muted); }
#content .quoteblock blockquote::before { color: var(--accent); }

/* Block titles (listing, image, example, etc.) */
#content .paragraph > .title,
#content .listingblock > .title, #content .literalblock > .title,
#content .imageblock > .title, #content .exampleblock > .title,
#content .audioblock > .title, #content .videoblock > .title,
#content .stemblock > .title, #content .openblock > .title,
#content table.tableblock > .title,
#content .ulist > .title, #content .olist > .title,
#content .dlist > .title, #content .qlist > .title,
#content .hdlist > .title, #content .quoteblock > .title,
#content .verseblock > .title, #content .admonitionblock > table > caption,
#toctitle { color: var(--accent); }

/* Sidebar blocks */
#content .sidebarblock {
  background: var(--bg-2);
  border-color: var(--border-md);
}
#content .sidebarblock > .content > .title { color: var(--accent); }

/* Tables */
#content table, #content table.tableblock {
  background: var(--bg-1);
  border-collapse: collapse;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  display: block;
}
#content table thead, #content table tfoot,
#content table.tableblock thead, #content table.tableblock tfoot {
  background: var(--bg-2);
}
/* All cell variants — asciidoctor uses multiple specificity levels */
#content table tr th, #content table tr td,
#content table thead tr th, #content table thead tr td,
#content table tfoot tr th, #content table tfoot tr td,
#content tbody tr th, #content tfoot tr th,
#content td, #content th,
#content .tableblock>tbody>tr>td,
#content .tableblock>thead>tr>th {
  border-color: var(--border-md);
  color: var(--text);
}
/* Nested p/li inside cells */
#content table p, #content table li,
#content tbody tr th p, #content tfoot tr th p { color: var(--text); }
#content tbody tr:nth-child(even) { background: var(--hover-tint); }

/* Admonition blocks */
#content .admonitionblock > table { background: transparent; display: table; }
#content .admonitionblock td.content {
  background: var(--bg-2);
  border-color: var(--border-md);
  color: var(--text);
}
#content .admonitionblock td.content p { color: var(--text); }

/* Header author/details */
#header .details, #header .details span { color: var(--text-muted); }
#header .details a { color: var(--accent); }

/* Footnotes */
#content #footnotes { color: var(--text-muted); }

/* ── Hamburger button ───────────────────────────────────────────────────── */
.top-nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  margin-left: 8px;
  z-index: 301;
}

.top-nav-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.2s ease;
}

.top-nav-hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.top-nav-hamburger.active span:nth-child(2) { opacity: 0; }
.top-nav-hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Mobile menu overlay ────────────────────────────────────────────────── */
.mobile-menu {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 299;
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.mobile-menu.open { display: flex; opacity: 1; }

.mobile-menu a {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  padding: 12px 24px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}

.mobile-menu a:hover,
.mobile-menu a.active { color: var(--text); background: var(--hover-tint); }

.mobile-menu .mobile-menu-cta {
  margin-top: 16px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 12px 28px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-body);
  background: var(--accent);
  color: var(--accent-on);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .top-nav-links { display: none; }
  .top-nav-hamburger { display: flex; }
}

@media (max-width: 768px) {
  :root { --nav-h: 60px; }
  /* Scale the lockup back so it keeps breathing room in the shorter bar. */
  .brand-mark { width: 32px; height: 32px; top: -2px; }
  .top-nav-brand-name { font-size: 1.5rem; }
  .top-nav-brand { top: 2px; }
  .top-nav-badge { top: -2px; }
  .sidebar { display: none; }
  main.content { margin-left: 0; }
  .page-wrap { padding: 1.5rem 1.25rem 3rem; }
  .top-nav-badge { display: none; }
  .top-nav-cta { display: none; }
  #content { margin-left: 16px; margin-right: 16px; }
}

/* ── Theme toggle ─────────────────────────────────────────────────────────── */
.theme-btn {
  background: none;
  border: 1px solid var(--border-md);
  border-radius: 6px;
  padding: 7px 8px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  line-height: 0;
  transition: color 0.15s, background 0.15s;
}
.theme-btn:hover { color: var(--text); background: var(--hover-tint); }
/* Light is the default, so the moon (switch to dark) is what you see first. */
.icon-sun  { display: none; }
.icon-moon { display: block; }
html[data-theme="dark"] .icon-sun  { display: block; }
html[data-theme="dark"] .icon-moon { display: none; }
