/* =====================================================================
   JustinGeoSci — shared documentation styles
   Single source of truth for all package guide pages. Edit here once and
   every page updates. Palette and tokens follow the home page (index.html).
   ===================================================================== */

/* ---------- Self-hosted fonts ----------
   Drop the matching .woff2 files into /assets/fonts/ (see assets/fonts/FONTS.md).
   Electrolize = wordmark; Inter = everything else; JetBrains Mono = code. */
@font-face {
  font-family: 'Electrolize';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/Electrolize-Regular.woff2') format('woff2');
}
/* Inter is supplied as variable fonts (wght 100–900, opsz 14–32); one face
   each for upright and italic covers every weight the site uses. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/assets/fonts/Inter-Variable.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url('/assets/fonts/Inter-Italic-Variable.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/JetBrainsMono-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/JetBrainsMono-Medium.woff2') format('woff2');
}

/* ---------- Design tokens ---------- */
:root {
  --radius: 8px;
  --maxw-content: 820px;
  --sidebar-w: 270px;
  --toc-w: 220px;
  --header-h: 60px;
  --subnav-h: 52px;
  --font-display: 'Electrolize', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #F8F7F4;
  --surface: #FFFFFF;
  --surface-2: #EFEDE8;
  --surface-3: #FFFFFF;
  --text: #292B2D;
  --primary: #306998;
  --secondary: #6C5F55;
  --accent: #D34516;
  --muted: #4B4E51;
  --border: #E5E2DC;
  --accent-soft: rgba(211, 69, 22, 0.10);
  --code-bg: #F3F1EC;
  --code-text: #292B2D;
  --code-border: #E5E2DC;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 8px 24px rgba(0, 0, 0, 0.04);
  --table-stripe: #FAF9F6;
  --eqn-bg: #E1DDD7;
  --footer-bg: var(--secondary);
  --footer-text: #F8F7F4;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121417;
  --surface: #1B1E22;
  --surface-2: #23282E;
  --surface-3: #1B1E22;
  --text: #F1F0ED;
  --primary: #83B5E1;
  --secondary: #E7E3DE;
  --accent: #F0784D;
  --muted: #CBCAC7;
  --border: #30353C;
  --accent-soft: rgba(240, 120, 77, 0.14);
  --code-bg: #171A1E;
  --code-text: #F1F0ED;
  --code-border: #30353C;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 30px rgba(0, 0, 0, 0.35);
  --table-stripe: #171A1E;
  --eqn-bg: var(--code-bg);
  --footer-bg: var(--surface);
  --footer-text: var(--text);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  min-height: 100%;
  background-color: var(--bg);
  transition: background-color 0.25s ease;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-weight: 300;
  line-height: 1.65;
  color: var(--text);
  background-color: var(--bg);
  transition: background-color 0.25s ease, color 0.25s ease;
  scroll-padding-top: calc(var(--subnav-h) + 16px);
}

a {
  font-family: var(--font-body);
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---------- Header (wordmark, no background) ---------- */
header.site {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background-color: transparent;
  padding: 1rem 2rem;
  min-height: var(--header-h);
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.12em;
  font-family: var(--font-display);
  /* Electrolize ships in a single (400) weight; a text stroke adds the extra
     heft so the wordmark reads bolder without a bold font file. */
  font-weight: 600;
  -webkit-text-stroke: 0.6px currentColor;
  font-size: 2rem;
  letter-spacing: 0.04em;
  line-height: 1.05;
  text-decoration: none;
}

.wordmark:hover {
  text-decoration: none;
  opacity: 0.9;
}

.wordmark .wm-brackets {
  color: var(--accent);
}

.wordmark .wm-name {
  color: var(--primary);
}

/* ---------- Top navigation bar ---------- */
nav.subnav {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--subnav-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(140%);
}

nav.subnav .topnav-links {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

nav.subnav .topnav-links > a {
  display: inline-flex;
  align-items: center;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--primary);
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, color 0.15s ease;
}

nav.subnav .topnav-links > a:hover {
  border-color: var(--accent);
  text-decoration: none;
}

nav.subnav .topnav-links > a.active {
  color: var(--primary);
  font-weight: 700;
  border-color: var(--accent);
}

nav.subnav .spacer {
  flex: 1;
}

/* ---------- Nav dropdowns (Thermal Sciences, Computational Geometry) ---------- */
.nav-dropdown {
  position: relative;
  display: inline-block;
}

.nav-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--primary);
  background: none;
  border: 1px solid var(--primary);
  cursor: pointer;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius);
  transition: border-color 0.15s ease, color 0.15s ease;
}

/* Place Computational Geometry to the left of Thermal Sciences without
   touching the per-page markup (order within the flex nav). */
.nav-dropdown:has(.nav-dropdown-menu[aria-label="Computational Geometry"]) {
  order: 1;
}

.nav-dropdown:has(.nav-dropdown-menu[aria-label="Thermal Sciences"]) {
  order: 2;
}

nav.subnav .topnav-links > a[href="/about/"] {
  order: 3;
}

.rail-toggle-nav {
  order: 4;
}

.nav-dropdown-toggle:hover,
.nav-dropdown-toggle[aria-expanded="true"] {
  border-color: var(--accent);
}

.nav-dropdown-toggle.active {
  color: var(--primary);
  font-weight: 700;
  border-color: var(--accent);
}

/* While a dropdown is open, only the open toggle shows the accent border; the
   page's active item (Home/About or the other dropdown) drops back to primary
   until the menu closes — e.g. by clicking back on the page — then regains it. */
nav.subnav .topnav-links:has(.nav-dropdown-toggle[aria-expanded="true"]) > a.active,
nav.subnav .topnav-links:has(.nav-dropdown-toggle[aria-expanded="true"]) .nav-dropdown-toggle.active:not([aria-expanded="true"]) {
  border-color: var(--primary);
}

.nav-dropdown-toggle .caret {
  display: inline-block;
  font-size: 1rem;
  transition: transform 0.2s ease;
}

.nav-dropdown-toggle[aria-expanded="true"] .caret {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 190px;
  display: none;
  flex-direction: column;
  padding: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 50;
}

.nav-dropdown-menu.open {
  display: flex;
}

.nav-dropdown-menu a {
  display: block;
  font-size: 0.9rem;
  color: var(--text);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-dropdown-menu a:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.nav-dropdown-menu a.active {
  color: var(--primary);
  font-weight: 500;
}

.version-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--primary);
  background: transparent;
  border: 1px solid var(--primary);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  letter-spacing: 0.02em;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  border: 1px solid var(--primary);
  background: var(--surface-3);
  color: var(--primary);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle:active {
  transform: scale(0.94);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

html[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

html[data-theme="light"] .theme-toggle .icon-sun {
  display: none;
}

html[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

html[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

/* ---------- Hamburger + mobile site menu (mobile only) ---------- */
.hamburger {
  display: none;
  /* revealed on mobile when JS enhances the nav */
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  border: 1px solid var(--primary);
  background: var(--surface-3);
  color: var(--primary);
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
}

.hamburger:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.hamburger:active {
  transform: scale(0.94);
}

.hamburger svg {
  width: 20px;
  height: 20px;
}

.hamburger .icon-close {
  display: none;
}

.hamburger[aria-expanded="true"] .icon-menu {
  display: none;
}

.hamburger[aria-expanded="true"] .icon-close {
  display: block;
}

.mobile-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  flex-direction: column;
  padding: 0.4rem 0.6rem 0.7rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  max-height: calc(100vh - var(--subnav-h));
  overflow-y: auto;
}

.mobile-menu .mm-section {
  display: block;
  font-weight: 600;
  color: var(--primary);
  padding: 0.6rem 0.6rem 0.2rem;
  text-decoration: none;
}

.mobile-menu .mm-sub {
  display: block;
  font-weight: 400;
  color: var(--secondary);
  padding: 0.32rem 0.6rem 0.32rem 1.4rem;
  text-decoration: none;
}

.mobile-menu a:hover {
  background: var(--surface-2);
  border-radius: 6px;
  text-decoration: none;
}

.mobile-menu a.active {
  color: var(--accent);
}

/* ---------- Layout grid (package pages with rails) ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  gap: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  align-items: start;
}

/* ---------- Left sidebar ---------- */
aside.sidebar {
  position: sticky;
  top: var(--subnav-h);
  height: calc(100vh - var(--subnav-h));
  overflow-y: auto;
  padding: 1.5rem 0.5rem 2rem 0;
  border-right: 1px solid var(--border);
}

.filter-wrap {
  padding: 0 0.5rem 1rem 0.25rem;
}

.filter-input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.7rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.filter-input::placeholder {
  color: var(--muted);
}

.filter-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.filter-empty {
  display: none;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---------- TOC ---------- */

nav.toc-nav .nav-group {
  margin-bottom: 0.4rem;
}

/* Group headers — primary color */
nav.toc-nav .nav-group>a.group-label {
  display: block;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  padding: 0.85rem 0.75rem 0.3rem;
  text-decoration: none;
}

/* Subsection links — secondary color */
nav.toc-nav .nav-group>a:not(.group-label) {
  display: block;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--secondary);
  padding: 0.32rem 0.75rem;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
  text-decoration: none;
  transition: background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

/* Hover action */
nav.toc-nav .nav-group>a.group-label:hover,
nav.toc-nav .nav-group>a:not(.group-label):hover {
  background: var(--surface-2);
  text-decoration: none;
}

/* Active subsection indicator — accent color */
nav.toc-nav .nav-group>a:not(.group-label).active {
  color: var(--secondary);
  font-weight: 500;
  border-left-color: var(--accent);
  background: transparent;
}

nav.toc-nav a.hidden {
  display: none;
}

/* ---------- Main content ---------- */
main {
  min-width: 0;
  max-width: var(--maxw-content);
  padding: 2.25rem 0 4rem;
}

main section {
  scroll-margin-top: calc(var(--subnav-h) + 16px);
}

main h1.page-title {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 2.5rem;
  letter-spacing: 0.03em;
  margin: 0 0 0.4rem;
  line-height: 1.1;
}

.lede {
  font-size: 1.12rem;
  color: var(--muted);
  margin: 0 0 2.25rem;
  max-width: 62ch;
}

main h2 {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.6rem;
  margin: 2.75rem 0 0.4rem;
  padding-left: 0.7rem;
  color: var(--primary);
  border-left: 4px solid var(--accent);
  scroll-margin-top: calc(var(--subnav-h) + 16px);
}

main h3 {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.12rem;
  margin: 1.8rem 0 0.3rem;
  color: var(--text);
}

main h3 code {
  font-size: 0.98rem;
}

main p {
  margin: 0.6rem 0 1rem;
  max-width: 70ch;
}

main ul,
main ol {
  max-width: 70ch;
}

main li {
  margin: 0.3rem 0;
}

/* anchor link affordance on headings */
.anchor {
  margin-left: 0.4rem;
  font-size: 0.85em;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.15s ease;
}

h2:hover .anchor,
h3:hover .anchor {
  opacity: 1;
}

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--code-bg);
  color: var(--code-text);
  border: 1px solid var(--code-border);
  border-radius: 5px;
  padding: 0.1rem 0.35rem;
}

.codeblock {
  position: relative;
  margin: 1rem 0 1.4rem;
}

.codeblock pre {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.6;
  background: var(--code-bg);
  color: var(--secondary);
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin: 0;
  overflow-x: auto;
}

.codeblock pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

/* Code prompt (>>>) — primary color; code itself — secondary color */
.codeblock .prompt {
  color: var(--primary);
  user-select: none;
}

.codeblock .out {
  color: var(--muted);
}

.copy-btn {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  font-family: var(--font-body);
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.22rem 0.5rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.codeblock:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.copy-btn.copied {
  color: var(--accent);
  border-color: var(--accent);
}

/* function reference tables */
.fn-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.4rem;
  font-size: 0.92rem;
}

.fn-table th,
.fn-table td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.fn-table th {
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.fn-table tbody tr:nth-child(even) {
  background: var(--table-stripe);
}

.fn-table td code {
  white-space: nowrap;
}

/* callout / note box */
.note {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  margin: 1.2rem 0;
  font-size: 0.95rem;
}

.note strong {
  color: var(--accent);
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0 1rem;
}

.mod-pill {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}

/* ---------- Function detail blocks (module pages) ---------- */
.fn-detail {
  padding-top: 0.4rem;
}

.fn-detail h3 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.1rem;
  border-top: 1px solid var(--border);
  padding-top: 1.4rem;
}

.eqn-meta {
  display: inline-block;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.72rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.55rem;
  margin-left: 0.55rem;
  letter-spacing: 0.01em;
}

.signature {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  color: var(--code-text);
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  padding: 0.55rem 0.8rem;
  margin: 0.5rem 0 0.8rem;
  overflow-x: auto;
}

dl.kv {
  margin: 0.4rem 0 1rem;
}

dl.kv dt {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  margin-top: 0.45rem;
}

dl.kv dd {
  margin: 0.05rem 0 0 1.1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

/* ---------- Right "On this page" TOC ---------- */
aside.onthispage {
  position: sticky;
  top: var(--subnav-h);
  height: calc(100vh - var(--subnav-h));
  overflow-y: auto;
  padding: 2.25rem 0.25rem 2rem;
  font-size: 0.85rem;
}

/* Label — primary color (matches left-TOC group headers) */
aside.onthispage .otp-label {
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 0.6rem;
}

/* Links — secondary color */
aside.onthispage a {
  display: block;
  color: var(--secondary);
  padding: 0.22rem 0 0.22rem 0.7rem;
  border-left: 2px solid var(--border);
  transition: color 0.15s ease, border-color 0.15s ease;
}

aside.onthispage a:hover {
  color: var(--text);
  text-decoration: none;
}

/* Active indicator — accent color */
aside.onthispage a.active {
  color: var(--secondary);
  border-left-color: var(--accent);
}

aside.onthispage a code {
  font-size: 0.82rem;
  background: none;
  border: none;
  padding: 0;
  color: inherit;
}

/* ---------- Footer (page-background color, centered) ---------- */
footer.site {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--subnav-h);
  margin-top: auto;
  padding: 0.5rem 1rem;
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 0.9rem;
  color: var(--footer-text);
  background-color: var(--footer-bg);
  text-align: center;
}

footer.site div {
  margin: 0;
}

footer.site a {
  color: inherit;
  text-decoration: underline;
}

/* Full-bleed wrapper paints the themed background itself, so it never
   depends on root/canvas background propagation (which an embedding
   iframe can interfere with). */
.page {
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  min-height: 100vh;
  transition: background-color 0.25s ease;
}

/* ---------- Simple pages (home / about / section intros) — no rails ---------- */
.page.simple main {
  max-width: 820px;
  margin: 0 auto;
  padding: 2.25rem 1.5rem 3rem;
}

.page.simple .intro {
  font-size: 1.12rem;
  color: var(--text);
  margin-bottom: 1.5rem;
  max-width: 72ch;
}

.proj-list,
.contact-list {
  list-style: none;
  padding-left: 0;
}

.proj-list>li {
  margin-bottom: 1.4rem;
}

.contact-list li {
  margin-bottom: 0.5rem;
}

/* Source equation shown below each function signature (rendered with KaTeX) */
.equation {
  margin: 0.4rem 0 1.2rem;
  padding: 0.7rem 0.9rem;
  background: var(--eqn-bg);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  color: var(--text);
  overflow-x: auto;
}

.equation .eqn-name {
  display: block;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--primary);
  margin-bottom: 0.4rem;
}

.equation .katex-eq {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text);
}

.equation .katex-display {
  margin: 0.2rem 0;
  text-align: left;
}

/* Sections-menu toggle in the top nav (mobile, documentation pages only) */
.rail-toggle-nav {
  display: none;
  align-items: center;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0.3rem 0.45rem;
  line-height: 1;
}

.rail-toggle-nav:hover {
  color: var(--accent);
}

.rail-toggle-nav .caret {
  display: inline-block;
  font-size: 0.85rem;
  transition: transform 0.2s ease;
}

.rail-toggle-nav[aria-expanded="true"] .caret {
  transform: rotate(180deg);
}

/* Clear label so the page-sections control reads distinctly from the site menu */
.rail-toggle-nav::before {
  content: "Sections";
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 400;
  margin-right: 0.35rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .layout {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }

  aside.onthispage {
    display: none;
  }
}

@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 0 1.1rem;
  }

  aside.sidebar {
    position: static;
    height: auto;
    overflow: visible;
    border-right: none;
    padding: 0;
  }

  .rail-toggle-nav {
    display: inline-flex;
  }

  /* Enhanced nav: hide the bordered buttons, show the hamburger + its menu.
     nav.subnav.nav-enhanced keeps this ahead of the base link display rule. */
  nav.subnav.nav-enhanced .topnav-links > a,
  nav.subnav.nav-enhanced .topnav-links > .nav-dropdown {
    display: none;
  }

  .nav-enhanced .hamburger {
    display: inline-flex;
  }

  .nav-enhanced .mobile-menu.open {
    display: flex;
  }

  .rail-body {
    display: none;
  }

  aside.sidebar.rail-open {
    border-bottom: 1px solid var(--border);
    padding: 0.7rem 0;
  }

  aside.sidebar.rail-open .rail-body {
    display: block;
  }

  .wordmark {
    font-size: 1.7rem;
  }

  main {
    padding-top: 1.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    transition: none !important;
  }
}
