@font-face {
  font-family: "Inter";
  src: url("/assets/inter-var.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f7f5f1;
  --bg-elevated: #ffffff;
  --ink: #1a1f24;
  --muted: #5c6670;
  --line: #d9d3c7;
  --accent: #0b6e4f;
  --accent-ink: #ffffff;
  --code-bg: #ece7de;
  --focus: #0b6e4f;
  --nav-w: 16.5rem;
  --font-sans: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #12151a;
  --bg-elevated: #1b2129;
  --ink: #e8ecef;
  --muted: #9aa3ad;
  --line: #2c3540;
  --accent: #3ecf8e;
  --accent-ink: #0b1611;
  --code-bg: #0f1318;
  --focus: #3ecf8e;
  color-scheme: dark;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  background:
    radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 55%),
    var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:hover {
  text-decoration: none;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.5rem 0.75rem;
  z-index: 1000;
}

.skip-link:focus {
  left: 0.75rem;
  top: 0.75rem;
}

.shell {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow: auto;
  padding: 1.25rem 1rem 2rem;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  backdrop-filter: blur(8px);
}

.mobile-nav-close {
  display: none;
}

.brand {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  margin-bottom: 0.25rem;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 1.25rem;
}

.nav-section {
  margin-top: 1.25rem;
}

.nav-section h2 {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

.nav-section a {
  display: block;
  padding: 0.35rem 0.5rem;
  border-radius: 0.35rem;
  color: var(--ink);
  text-decoration: none;
}

.nav-description {
  margin: 0.2rem 0.5rem 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.nav-section a:hover,
.nav-section a[aria-current="page"] {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.toolbar {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
}

.toolbar button,
.toolbar input,
.topbar-theme-toggle {
  font: inherit;
}

.toolbar button,
.topbar-theme-toggle {
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--ink);
  border-radius: 0.4rem;
  padding: 0.4rem 0.65rem;
  cursor: pointer;
}

.toolbar button:focus-visible,
.topbar-theme-toggle:focus-visible,
.module-search:focus-visible,
.nav-section a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.module-search {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--ink);
  border-radius: 0.4rem;
  padding: 0.55rem 0.65rem;
  margin-top: 0.35rem;
}

.module-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}

.module-list li[hidden] {
  display: none;
}

.module-list a {
  display: block;
  padding: 0.3rem 0.5rem;
  border-radius: 0.35rem;
  color: var(--ink);
  text-decoration: none;
}

.module-label {
  display: block;
  font-weight: 550;
}

.module-slug {
  display: block;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.25;
}

.module-list a:hover,
.module-list a.is-active,
.module-list [aria-selected="true"] a {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.main {
  padding: 1.5rem 1.75rem 3rem;
  max-width: 58rem;
  min-width: 0;
  width: 100%;
  overflow-x: hidden;
}

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

.advanced-nav {
  margin-top: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  padding: 0.35rem 0.5rem 0.5rem;
  background: color-mix(in srgb, var(--bg-elevated) 70%, transparent);
}

.advanced-nav > summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  list-style: none;
  padding: 0.25rem 0.15rem;
}

.advanced-nav > summary::-webkit-details-marker {
  display: none;
}

.advanced-nav > summary::before {
  content: "▸ ";
  color: var(--accent);
}

.advanced-nav[open] > summary::before {
  content: "▾ ";
}

.advanced-module-list {
  margin-top: 0.35rem;
}

.skill-pack-link {
  display: block;
  margin-top: 0.45rem;
  padding: 0.35rem 0.5rem;
  border-radius: 0.35rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.88rem;
}

.skill-pack-link:hover {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

/* Reference pages: slim top bar; Elements owns the only sidebar. */
body.is-reference {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg-elevated);
}

.reference-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.reference-topbar .brand {
  margin: 0;
  font-size: 1.1rem;
}

.module-switcher-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.module-switcher {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 0.35rem;
  padding: 0.35rem 0.55rem;
  min-width: 11rem;
}

.topbar-theme-toggle {
  margin-left: auto;
}

.module-switcher:focus-visible,
.topbar-link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.topbar-link {
  color: var(--ink);
  text-decoration: none;
  font-size: 0.95rem;
  padding: 0.25rem 0.4rem;
  border-radius: 0.3rem;
}

.topbar-link:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.reference-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  max-width: none;
  overflow: hidden;
}

.reference-try-it-note {
  margin: 0;
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  color: #5c4400;
  background: #fff7e6;
  border-bottom: 1px solid #f0c36d;
}

html[data-theme="dark"] .reference-try-it-note {
  color: #f5e6b8;
  background: #3a3018;
  border-bottom-color: #6b5a2a;
}

.reference-try-it-note a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

body.is-reference elements-api {
  display: block;
  flex: 1;
  min-height: 0;
  height: auto;
  width: 100%;
  overflow: auto;
}

.prose h1 {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 0.75rem;
}

.prose h2 {
  margin-top: 2.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--line);
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.prose h3 {
  margin-top: 1.75rem;
  font-size: 1.15rem;
  color: var(--ink);
}

.prose h1,
.prose h2,
.prose h3 {
  scroll-margin-top: 1rem;
}

.prose p,
.prose li {
  color: var(--ink);
}

.prose p,
.prose ul,
.prose ol {
  max-width: 44rem;
}

.prose .lede {
  font-size: 1.1rem;
  color: var(--muted);
  max-width: 40rem;
}

.prose table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin: 1rem 0 1.5rem;
}

.prose th,
.prose td {
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0.65rem;
  text-align: left;
  vertical-align: top;
}

.prose thead th {
  border-bottom: 2px solid var(--line);
  background: none;
}

.prose tbody tr:hover {
  background: color-mix(in srgb, var(--accent) 4%, transparent);
}

.prose pre {
  position: relative;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.9rem 1rem;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.86rem;
}

html[data-theme="dark"] .prose pre {
  background: var(--code-bg);
}

.prose pre.has-copy-button {
  padding-top: 2.65rem;
}

.copy-code {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg-elevated);
  color: var(--ink);
  font: 500 0.75rem var(--font-sans);
  cursor: pointer;
}

.copy-code:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.prose :not(pre) > code {
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 0.25rem;
  overflow-wrap: anywhere;
}

.anchor {
  margin-left: 0.2em;
  opacity: 0;
  font-size: 0.75em;
  text-decoration: none;
}

.prose :is(h1, h2, h3):hover .anchor,
.anchor:focus-visible {
  opacity: 1;
}

.toc {
  max-width: 44rem;
  margin: 1.5rem 0 2rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: color-mix(in srgb, var(--bg-elevated) 82%, transparent);
}

.toc h2 {
  margin: 0 0 0.5rem;
  padding: 0;
  border: 0;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toc ul {
  columns: 2;
  column-gap: 2rem;
  margin: 0;
  padding-left: 1.1rem;
}

.toc li {
  break-inside: avoid;
  margin: 0.25rem 0;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.not-found {
  padding-top: clamp(4rem, 14vh, 9rem);
}

.mobile-nav-toggle {
  display: none;
}

.nav-backdrop {
  display: none;
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(20rem, 88vw);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    z-index: 40;
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  body.nav-open {
    overflow: hidden;
  }

  .mobile-nav-close {
    display: inline-flex;
    float: right;
    border: 1px solid var(--line);
    border-radius: 0.35rem;
    padding: 0.35rem 0.55rem;
    background: var(--bg-elevated);
    color: var(--ink);
    font: inherit;
    cursor: pointer;
  }

  .nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: block;
    background: rgb(0 0 0 / 0.45);
  }

  .nav-backdrop[hidden] {
    display: none;
  }

  .mobile-nav-toggle {
    display: inline-flex;
    position: fixed;
    right: 0.75rem;
    top: 0.75rem;
    z-index: 50;
    border: 1px solid var(--line);
    border-radius: 0.4rem;
    padding: 0.45rem 0.7rem;
    background: var(--bg-elevated);
    color: var(--ink);
    font: inherit;
  }

  .main {
    padding: 4rem 1rem 2.5rem;
  }

  .reference-topbar {
    padding: 0.55rem 0.75rem;
  }

  .topbar-theme-toggle {
    margin-left: 0;
  }

  .module-switcher {
    min-width: 0;
    max-width: calc(100vw - 1.5rem);
  }

  .toc ul {
    columns: 1;
  }

  .prose table,
  .prose pre {
    max-width: 100%;
  }
}
