/* ==========================================================================
   Public Records & FOIA Request Automation — main stylesheet
   Light, professional, civic palette. Mobile-first, widescreen-friendly.
   ========================================================================== */

/* ----- Design tokens ----------------------------------------------------- */
:root {
  /* Brand */
  --navy: #14365c;
  --navy-700: #1d4e7e;
  --blue: #1f6feb;
  --blue-600: #1857c4;
  --teal: #0f9d8f;
  --teal-700: #0b7d72;
  --amber: #e0851f;
  --amber-light: #f5b54a;

  /* Ink + surfaces */
  --ink: #16252f;
  --ink-soft: #44586a;
  --ink-faint: #6c7e8d;
  --line: #e3e9f1;
  --line-strong: #cfd9e6;
  --surface: #ffffff;
  --surface-2: #f2f6fc;
  --surface-3: #e9f0f9;
  --bg: #f6f9fd;

  /* Code */
  --code-bg: #f5f8fd;
  --code-border: #e0e8f3;
  --code-inline-bg: #eef3fb;
  --code-inline-ink: #1d4e7e;

  /* Typography */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Code", "JetBrains Mono",
    "Roboto Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Layout */
  --container: 1380px;
  --container-wide: 1600px;
  --header-h: 66px;
  --gutter: clamp(1rem, 3.5vw, 2.75rem);

  /* Radii + shadow */
  --radius: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(20, 54, 92, 0.06), 0 1px 3px rgba(20, 54, 92, 0.08);
  --shadow-md: 0 6px 18px rgba(20, 54, 92, 0.09), 0 2px 6px rgba(20, 54, 92, 0.06);
  --shadow-lg: 0 18px 48px rgba(20, 54, 92, 0.16);

  --gradient-brand: linear-gradient(135deg, var(--navy) 0%, var(--blue) 55%, var(--teal) 100%);
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ----- Reset / base ------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }
svg { height: auto; }

a { color: var(--blue-600); text-decoration: none; }

.site-main { flex: 1 0 auto; width: 100%; }

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

@media (min-width: 1560px) {
  .container { max-width: var(--container-wide); }
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--navy);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ==========================================================================
   Header / primary navigation
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--navy);
  transition: transform var(--transition);
}
.brand:hover { transform: translateY(-1px); }
.brand__mark { width: 40px; height: 40px; flex: none; filter: drop-shadow(0 2px 5px rgba(20,54,92,0.18)); }
.brand__mark svg { width: 100%; height: 100%; border-radius: 10px; }
.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.brand__name { font-weight: 800; font-size: 1.12rem; letter-spacing: -0.01em; color: var(--navy); }
.brand__name-accent { color: var(--blue); }
.brand__sub { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-faint); }

.primary-nav__list {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
}

.nav-link {
  --nav-accent: var(--blue);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  border-radius: 10px;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.95rem;
  position: relative;
  transition: color var(--transition), background var(--transition), transform var(--transition);
}
.nav-link__icon { display: inline-flex; }
.nav-link__icon svg { width: 20px; height: 20px; color: var(--nav-accent); transition: transform var(--transition); }
.nav-link:hover { color: var(--navy); background: var(--surface-2); transform: translateY(-1px); }
.nav-link:hover .nav-link__icon svg { transform: scale(1.12); }
.nav-link.is-current { color: var(--navy); background: color-mix(in srgb, var(--nav-accent) 12%, white); }
.nav-link.is-current::after {
  content: "";
  position: absolute;
  left: 0.85rem; right: 0.85rem; bottom: 0.18rem;
  height: 2px; border-radius: 2px;
  background: var(--nav-accent);
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--navy);
  cursor: pointer;
}
.nav-toggle svg { width: 24px; height: 24px; }
.nav-toggle__close { display: none; }

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(1200px 460px at 18% -10%, rgba(31, 111, 235, 0.12), transparent 60%),
    radial-gradient(900px 420px at 96% 0%, rgba(15, 157, 143, 0.12), transparent 55%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
}
.hero__inner {
  padding-block: clamp(2.5rem, 6vw, 5rem) clamp(2.5rem, 5vw, 4rem);
  text-align: center;
}
.hero__logo { width: clamp(96px, 16vw, 150px); margin: 0 auto 1.5rem; }
.hero__logo svg { border-radius: 26px; box-shadow: var(--shadow-lg); }
.hero__eyebrow {
  font-weight: 700; font-size: 0.82rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--teal-700);
  margin-bottom: 0.75rem;
}
.hero__title {
  font-size: clamp(2rem, 4.6vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  font-weight: 800;
  color: var(--navy);
  max-width: 24ch;
  margin-inline: auto;
}
.hero__title-accent {
  background: linear-gradient(120deg, var(--blue), var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero__lede {
  max-width: min(100%, 1120px);
  margin: 1.8rem auto 0;
  color: var(--ink-soft);
  font-size: 1.1rem;
  text-align: left;
}
.hero__lede p { margin: 0 0 1rem; }
.hero__lede p:last-child { margin-bottom: 0; }
@media (min-width: 992px) {
  .hero__lede { columns: 2; column-gap: 3.5rem; }
  .hero__lede p { break-inside: avoid; }
}

.hero__cta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 2.25rem;
}
.cta-button {
  --cta-accent: var(--blue);
  display: flex;
  align-items: center;
  gap: 0.9rem;
  text-align: left;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.cta-button:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--cta-accent) 45%, var(--line));
}
.cta-button__icon {
  flex: none;
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, color-mix(in srgb, var(--cta-accent) 78%, white), var(--cta-accent));
  box-shadow: 0 6px 14px color-mix(in srgb, var(--cta-accent) 40%, transparent);
}
.cta-button__icon svg { width: 26px; height: 26px; }
.cta-button__body { display: flex; flex-direction: column; flex: 1; }
.cta-button__label { font-weight: 700; color: var(--navy); font-size: 1.05rem; }
.cta-button__hint { font-size: 0.85rem; color: var(--ink-faint); }
.cta-button__arrow { color: var(--cta-accent); transition: transform var(--transition); }
.cta-button__arrow svg { width: 22px; height: 22px; }
.cta-button:hover .cta-button__arrow { transform: translateX(4px); }

/* ==========================================================================
   Homepage pillar cards
   ========================================================================== */
.sections { padding-block: clamp(2.5rem, 5vw, 4.5rem); }
.section-head { text-align: center; max-width: 60ch; margin: 0 auto 2.5rem; }
.section-head__title {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  color: var(--navy);
  letter-spacing: -0.01em;
}
.section-head__sub { margin-top: 0.6rem; color: var(--ink-soft); }

.pillar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}
.pillar {
  --pillar-accent: var(--blue);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--pillar-accent);
  border-radius: var(--radius);
  padding: 1.6rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}
.pillar:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.pillar__head { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.9rem; }
.pillar__icon {
  flex: none; width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 12px;
  color: var(--pillar-accent);
  background: color-mix(in srgb, var(--pillar-accent) 12%, white);
}
.pillar__icon svg { width: 26px; height: 26px; }
.pillar__title { font-size: 1.25rem; color: var(--navy); }
.pillar__title a { color: inherit; }
.pillar__title a:hover { color: var(--pillar-accent); }
.pillar__blurb { color: var(--ink-soft); font-size: 0.98rem; }
.pillar__links { list-style: none; padding: 0; margin: 1.1rem 0; display: grid; gap: 0.15rem; }
.pillar__links a {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 0.95rem;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}
.pillar__link-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pillar-accent); flex: none; }
.pillar__links a:hover { background: var(--surface-2); color: var(--navy); transform: translateX(3px); }
.pillar__more {
  margin-top: auto;
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-weight: 700; color: var(--pillar-accent);
}
.pillar__more svg { width: 20px; height: 20px; transition: transform var(--transition); }
.pillar__more:hover svg { transform: translateX(4px); }

/* ==========================================================================
   Content layout
   ========================================================================== */
.content-layout {
  padding-block: 2rem 3.5rem;
}

/* Two-column layout with a sticky "On this page" rail on wide screens.
   Content stays generously wide; the rail is desktop-only. */
@media (min-width: 1200px) {
  .content-layout.has-toc {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 15rem;
    column-gap: 2.75rem;
    align-items: start;
    grid-template-areas:
      "crumbs crumbs"
      "article toc"
      "related related";
  }
  .content-layout.has-toc .breadcrumbs { grid-area: crumbs; }
  .content-layout.has-toc .prose { grid-area: article; min-width: 0; }
  .content-layout.has-toc .related { grid-area: related; }
  .content-layout.has-toc .toc { grid-area: toc; }
}

.toc { display: none; }
@media (min-width: 1200px) {
  .toc {
    display: block;
    position: sticky;
    top: calc(var(--header-h) + 1.5rem);
    align-self: start;
    max-height: calc(100vh - var(--header-h) - 3rem);
    overflow-y: auto;
    font-size: 0.86rem;
  }
}
.toc__title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-faint);
  font-weight: 700;
  margin-bottom: 0.7rem;
  padding-left: 0.8rem;
}
.toc ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.1rem; }
.toc a {
  display: block;
  padding: 0.32rem 0.6rem 0.32rem 0.8rem;
  border-left: 2px solid var(--line);
  color: var(--ink-soft);
  line-height: 1.35;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.toc li.toc-h3 a { padding-left: 1.5rem; font-size: 0.82rem; }
.toc a:hover { color: var(--navy); background: var(--surface-2); }
.toc a.is-active { color: var(--blue); font-weight: 600; border-left-color: var(--blue); }

.breadcrumbs { margin-bottom: 1.5rem; font-size: 0.875rem; }
.breadcrumbs__list { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 0.2rem; padding: 0; }
.breadcrumbs__item { display: inline-flex; align-items: center; gap: 0.2rem; color: var(--ink-faint); }
.breadcrumbs__item a { color: var(--ink-soft); font-weight: 600; padding: 0.15rem 0.3rem; border-radius: 6px; }
.breadcrumbs__item a:hover { color: var(--blue); background: var(--surface-2); }
.breadcrumbs__item [aria-current="page"] { color: var(--navy); font-weight: 700; }
.breadcrumbs__sep svg { width: 15px; height: 15px; color: var(--line-strong); }

/* ----- Prose ------------------------------------------------------------- */
.prose { max-width: none; }
.prose > * + * { margin-top: 1.15rem; }

.prose h1 {
  font-size: clamp(1.9rem, 3.6vw, 2.7rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  font-weight: 800;
  background: linear-gradient(120deg, var(--navy), var(--blue) 70%, var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 0.4rem;
  scroll-margin-top: calc(var(--header-h) + 1rem);
}
.prose h2 {
  font-size: clamp(1.4rem, 2.6vw, 1.85rem);
  color: var(--navy);
  font-weight: 750;
  letter-spacing: -0.01em;
  margin-top: 2.4rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: calc(var(--header-h) + 1rem);
}
.prose h3 {
  font-size: clamp(1.18rem, 2vw, 1.4rem);
  color: var(--navy-700);
  font-weight: 700;
  margin-top: 1.8rem;
  scroll-margin-top: calc(var(--header-h) + 1rem);
}
.prose h4 { font-size: 1.1rem; color: var(--navy-700); font-weight: 700; margin-top: 1.4rem; scroll-margin-top: calc(var(--header-h) + 1rem); }

.prose p { color: var(--ink); }
.prose strong { color: var(--navy); font-weight: 700; }

.prose a:not(.heading-anchor) {
  color: var(--blue-600);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--blue) 35%, transparent);
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
  transition: color var(--transition), text-decoration-color var(--transition);
}
.prose a:not(.heading-anchor):hover {
  color: var(--teal-700);
  text-decoration-color: var(--teal);
}
.prose a.external-link::after {
  content: "";
  display: inline-block;
  width: 0.7em; height: 0.7em;
  margin-left: 0.18em;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 5h5v5M19 5 11 13M18 13v5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 5h5v5M19 5 11 13M18 13v5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: 0.65;
  vertical-align: baseline;
}

/* heading anchor link */
.heading-anchor {
  margin-left: 0.4rem;
  color: var(--line-strong);
  opacity: 0;
  font-weight: 400;
  text-decoration: none;
  transition: opacity var(--transition), color var(--transition);
}
:is(h1, h2, h3, h4):hover .heading-anchor { opacity: 1; }
.heading-anchor:hover { color: var(--blue); }

/* lists */
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: 0.4rem; }
.prose ul:not(.contains-task-list) li::marker { color: var(--teal); }
.prose ol li::marker { color: var(--blue); font-weight: 700; }

.prose blockquote {
  border-left: 4px solid var(--teal);
  background: var(--surface-2);
  padding: 0.8rem 1.2rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-soft);
}

.prose hr { border: none; border-top: 1px solid var(--line); margin-block: 2rem; }

/* inline code — light tint, no border, blends with text */
.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--code-inline-bg);
  color: var(--code-inline-ink);
  padding: 0.12em 0.4em;
  border-radius: 6px;
  font-weight: 600;
  word-break: break-word;
}

/* ==========================================================================
   Code blocks (toolbar + copy)
   ========================================================================== */
.code-block {
  margin-block: 1.5rem;
  border: 1px solid var(--code-border);
  border-radius: var(--radius-md);
  background: var(--code-bg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.code-block__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.6rem 0.4rem 1rem;
  background: linear-gradient(180deg, #eef3fb, #e7eef8);
  border-bottom: 1px solid var(--code-border);
}
.code-block__lang {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--navy-700);
}
.code-block__copy {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--navy-700);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0.28rem 0.7rem;
  cursor: pointer;
  transition: all var(--transition);
}
.code-block__copy:hover { background: var(--blue); color: #fff; border-color: var(--blue); }
.code-block__copy.is-copied { background: var(--teal); color: #fff; border-color: var(--teal); }
.code-block__pre {
  margin: 0;
  padding: 1.1rem 1.2rem;
  overflow-x: auto;
  background: var(--code-bg);
}
.code-block__pre code { display: block; white-space: pre; }

/* ==========================================================================
   Task lists (togglable checkboxes)
   ========================================================================== */
.prose .contains-task-list { list-style: none; padding-left: 0; }
.prose .contains-task-list .contains-task-list { padding-left: 1.4rem; margin-top: 0.4rem; }
.task-list-item {
  display: block;
  list-style: none;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  transition: background var(--transition), border-color var(--transition);
}
.task-list-item + .task-list-item { margin-top: 0.5rem; }
.task-list-item::marker { content: ""; } /* belt-and-suspenders: no dot */
.task-list-item:hover { border-color: var(--line-strong); background: var(--surface-2); }
.task-list-item > label {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  cursor: pointer;
  margin: 0;
}
.task-list-item-checkbox {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 1.25rem; height: 1.25rem;
  margin-top: 0.18rem;
  border: 2px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  transition: background var(--transition), border-color var(--transition);
}
.task-list-item-checkbox:hover { border-color: var(--teal); }
.task-list-item-checkbox:checked {
  background: var(--teal);
  border-color: var(--teal);
}
.task-list-item-checkbox:checked::after {
  content: "";
  position: absolute;
  left: 5px; top: 1px;
  width: 5px; height: 10px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}
/* Strike-through when checked (CSS via :has, plus JS .is-checked fallback) */
.task-list-item:has(.task-list-item-checkbox:checked) > label,
.task-list-item.is-checked > label {
  color: var(--ink-faint);
}
.task-list-item:has(.task-list-item-checkbox:checked) > label,
.task-list-item.is-checked > label {
  text-decoration: line-through;
  text-decoration-color: var(--ink-faint);
}

/* ==========================================================================
   Tables (responsive scroll + styled)
   ========================================================================== */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-block: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  min-width: 520px;
}
.prose thead { background: var(--gradient-brand); }
.prose thead th { color: #fff; text-align: left; font-weight: 700; }
.prose th, .prose td { padding: 0.7rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose tbody tr:nth-child(even) { background: var(--surface-2); }
.prose tbody tr:hover { background: var(--surface-3); }
.prose tbody tr:last-child td { border-bottom: none; }

/* ==========================================================================
   FAQ accordions
   ========================================================================== */
.faq { margin-block: 1.5rem; display: grid; gap: 0.7rem; }
.faq__item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.faq__item[open] { box-shadow: var(--shadow-sm); border-color: var(--line-strong); }
.faq__q {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.2rem;
  font-weight: 700;
  color: var(--navy);
}
.faq__q::-webkit-details-marker { display: none; }
.faq__q::after {
  content: "";
  flex: none;
  width: 20px; height: 20px;
  background: var(--blue);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform var(--transition);
}
.faq__item[open] .faq__q::after { transform: rotate(180deg); }
.faq__q:hover { background: var(--surface-2); }
.faq__a { padding: 0 1.2rem 1.1rem; color: var(--ink-soft); }
.faq__a > :first-child { margin-top: 0; }

/* ==========================================================================
   Mermaid diagrams
   ========================================================================== */
.mermaid-figure {
  margin-block: 1.5rem;
  padding: 1.2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  text-align: center;
  overflow-x: auto;
}
.mermaid-figure pre.mermaid { margin: 0; background: none; border: none; text-align: center; }
.mermaid-figure pre.mermaid:not([data-processed]) { color: transparent; min-height: 2rem; }
/* Mermaid renders a block-level SVG; center it within the figure. */
.mermaid-figure svg { display: block; margin-inline: auto; height: auto; }
.mermaid-caption {
  margin-top: 0.85rem;
  padding-top: 0.7rem;
  border-top: 1px dashed var(--line);
  font-size: 0.85rem;
  font-style: italic;
  color: var(--ink-faint);
  text-align: center;
}

/* KaTeX sizing guard */
.katex-display { overflow-x: auto; overflow-y: hidden; padding-block: 0.4rem; }
.katex { font-size: 1.05em; }

/* ==========================================================================
   Related content
   ========================================================================== */
.related { margin-top: 3rem; padding-top: 2rem; border-top: 2px solid var(--line); }
.related__title { font-size: 1.35rem; color: var(--navy); margin-bottom: 1.1rem; }
.related__grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.related__card {
  --card-accent: var(--blue);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--card-accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}
.related__card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.related__card a { display: flex; flex-direction: column; gap: 0.35rem; padding: 1rem 1.1rem; height: 100%; }
.related__card-title { font-weight: 700; color: var(--navy); }
.related__card-intro { font-size: 0.88rem; color: var(--ink-faint); line-height: 1.5; }
.related__card-arrow { color: var(--card-accent); margin-top: auto; }
.related__card-arrow svg { width: 20px; height: 20px; transition: transform var(--transition); }
.related__card:hover .related__card-arrow svg { transform: translateX(4px); }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer { flex-shrink: 0; margin-top: auto; background: var(--navy); color: #cdd9e8; }
.site-footer__inner { display: grid; gap: 2.5rem; padding-block: 3rem; grid-template-columns: 1.4fr 2.6fr; }
.site-footer__brand { display: flex; gap: 1rem; align-items: flex-start; }
.site-footer__mark { width: 52px; height: 52px; flex: none; }
.site-footer__mark svg { border-radius: 12px; }
.site-footer__name { color: #fff; font-weight: 800; font-size: 1.05rem; }
.site-footer__desc { font-size: 0.9rem; color: #9fb3cc; margin-top: 0.35rem; max-width: 42ch; }
.site-footer__nav { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1.5rem 2rem; }
.site-footer__heading { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.09em; color: #7f97b6; margin-bottom: 0.7rem; }
.site-footer__col ul { list-style: none; padding: 0; display: grid; gap: 0.45rem; }
.site-footer__col a { color: #cdd9e8; font-size: 0.92rem; transition: color var(--transition), padding var(--transition); }
.site-footer__col a:hover { color: #fff; padding-left: 4px; }
.site-footer__bar { border-top: 1px solid rgba(255, 255, 255, 0.12); }
.site-footer__bar-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; padding-block: 1.1rem; font-size: 0.82rem; color: #8ba2bf; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .primary-nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    transform: translateY(-150%);
    transition: transform var(--transition);
    max-height: calc(100vh - var(--header-h));
    overflow-y: auto;
  }
  .primary-nav.is-open { transform: translateY(0); }
  .primary-nav__list { flex-direction: column; align-items: stretch; gap: 0.25rem; padding: 1rem var(--gutter); }
  .nav-link { padding: 0.8rem 1rem; font-size: 1.05rem; }
  .nav-link.is-current::after { display: none; }
  .nav-link.is-current { box-shadow: inset 3px 0 0 var(--nav-accent); }
  body.nav-open { overflow: hidden; }
}

@media (max-width: 640px) {
  body { font-size: 1rem; }
  .brand__sub { display: none; }
  .site-footer__inner { grid-template-columns: 1fr; gap: 1.8rem; }
  .hero__lede { font-size: 1rem; }
  .code-block__pre { font-size: 0.82rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
