/* =========================================================
   OSM Data Processing & QA Pipelines — site stylesheet
   Light, cartographic-inspired palette.
   ========================================================= */

:root {
  /* Palette — softened cartographic tones */
  --c-bg: #f7f5ef;
  --c-bg-elev: #fffdf8;
  --c-surface: #ffffff;
  --c-surface-sub: #f1ede3;
  --c-ink: #1d2a30;
  --c-ink-soft: #41525c;
  --c-ink-muted: #6a7882;
  --c-rule: #e2dccc;
  --c-rule-strong: #cfc7b3;

  --c-accent: #2c6b56;        /* primary green */
  --c-accent-2: #1f5a7d;      /* deep teal blue */
  --c-accent-3: #c97a36;      /* warm clay */
  --c-accent-4: #6c5ce7;      /* gentle indigo */
  --c-accent-5: #d83a7a;      /* rose */
  --c-accent-6: #b58300;      /* mustard */

  --c-link: #1f5a7d;
  --c-link-hover: #2c6b56;
  --c-code-bg: #f3efe1;
  --c-code-inline-bg: rgba(31, 90, 125, 0.06);
  --c-code-border: #e0d8c1;

  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-pill: 999px;

  --sh-sm: 0 1px 2px rgba(20, 30, 35, 0.06);
  --sh-md: 0 6px 18px rgba(20, 30, 35, 0.07);
  --sh-lg: 0 20px 40px rgba(20, 30, 35, 0.10);

  --header-h: 64px;

  --container: min(100% - 2rem, 1280px);
  --container-wide: min(100% - 2rem, 1600px);

  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "Menlo", "Consolas", monospace;
}

@media (min-width: 1600px) {
  :root {
    --container: min(100% - 3rem, 1480px);
    --container-wide: min(100% - 3rem, 1820px);
  }
}
@media (min-width: 2000px) {
  :root {
    --container-wide: min(100% - 4rem, 1960px);
  }
}

/* -------------------------------------------------------------
   Reset / base
   ------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-ink);
  font-family: var(--font-sans);
  font-size: clamp(15px, 0.55vw + 13.5px, 17px);
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

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

a {
  color: var(--c-link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.18s ease, text-decoration-color 0.18s ease;
}
a:hover, a:focus-visible {
  color: var(--c-link-hover);
  text-decoration-color: currentColor;
}
a:focus-visible {
  outline: 2px solid var(--c-accent-2);
  outline-offset: 2px;
  border-radius: 3px;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--c-accent);
  color: #fff;
  padding: 0.6rem 1rem;
  z-index: 100;
  border-radius: 0 0 var(--r-md) 0;
  text-decoration: none;
}
.skip-link:focus { left: 0; }

/* -------------------------------------------------------------
   Layout helpers
   ------------------------------------------------------------- */

.container { width: var(--container); margin-inline: auto; }
.container--wide { width: var(--container-wide); }

.page__main { flex: 1 0 auto; padding-top: calc(var(--header-h) + 0px); }

/* -------------------------------------------------------------
   Site header
   ------------------------------------------------------------- */

.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: rgba(255, 253, 248, 0.88);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--c-rule);
  z-index: 50;
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: 1rem;
}
.site-header__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--c-ink);
  font-weight: 700;
  letter-spacing: 0.01em;
}
.site-header__brand:hover .site-header__name { color: var(--c-accent); }
.site-header__name {
  transition: color 0.18s ease;
  font-size: 1.02rem;
}

.site-nav__list {
  list-style: none;
  display: flex;
  gap: 0.25rem;
  margin: 0; padding: 0;
}
.site-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  border-radius: var(--r-pill);
  text-decoration: none;
  color: var(--c-ink-soft);
  font-weight: 500;
  font-size: 0.95rem;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
}
.site-nav__link:hover,
.site-nav__link:focus-visible {
  color: var(--c-accent);
  background: rgba(44, 107, 86, 0.10);
}
.site-nav__link.is-active {
  color: var(--c-accent);
  background: rgba(44, 107, 86, 0.14);
}
.site-nav__icon { width: 18px; height: 18px; }

@media (max-width: 640px) {
  .site-header__name { display: none; }
  .site-nav__link span:not(.visually-hidden) { display: none; }
  .site-nav__link { padding: 0.5rem; }
}

/* -------------------------------------------------------------
   Logo
   ------------------------------------------------------------- */

.logo { width: 36px; height: 36px; }
.logo--sm { width: 32px; height: 32px; }
.logo--xl { width: clamp(120px, 18vw, 200px); height: auto; }

/* -------------------------------------------------------------
   Footer
   ------------------------------------------------------------- */

.site-footer {
  margin-top: 4rem;
  background: linear-gradient(180deg, rgba(31, 90, 125, 0.02), rgba(44, 107, 86, 0.06));
  border-top: 1px solid var(--c-rule);
  padding: 2.5rem 0 1rem;
}
.site-footer__inner {
  display: grid;
  gap: 2rem;
  grid-template-columns: 1fr;
}
@media (min-width: 760px) {
  .site-footer__inner {
    grid-template-columns: 1.4fr 1fr;
    align-items: start;
  }
}
.site-footer__brand {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
}
.site-footer__title {
  font-weight: 700;
  font-size: 1.05rem;
}
.site-footer__tagline {
  color: var(--c-ink-muted);
  font-size: 0.93rem;
  margin-top: 0.2rem;
}
.site-footer__heading {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--c-ink-muted);
  margin: 0 0 0.6rem;
}
.site-footer__nav ul {
  list-style: none;
  padding: 0; margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.site-footer__nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: var(--c-ink);
  font-weight: 500;
}
.site-footer__nav a:hover { color: var(--c-accent); }
.site-footer__nav .icon { width: 16px; height: 16px; }

.site-footer__base {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--c-rule);
  color: var(--c-ink-muted);
}

/* -------------------------------------------------------------
   Hero (home page)
   ------------------------------------------------------------- */

.hero {
  padding: clamp(2rem, 4vw, 4rem) 0 clamp(2rem, 4vw, 3.5rem);
  background:
    radial-gradient(60% 60% at 10% 10%, rgba(44, 107, 86, 0.10), transparent 70%),
    radial-gradient(50% 50% at 90% 30%, rgba(31, 90, 125, 0.10), transparent 70%),
    radial-gradient(40% 40% at 50% 90%, rgba(216, 58, 122, 0.06), transparent 70%);
}
.hero__inner { text-align: center; }
.hero__logo-line { display: flex; justify-content: center; margin-bottom: 1.5rem; }
.hero__logo-line .logo { filter: drop-shadow(0 10px 18px rgba(20, 30, 35, 0.18)); }

.hero__title {
  margin: 0 auto;
  font-size: clamp(1.9rem, 3.2vw + 0.6rem, 3.6rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-weight: 800;
  max-width: 22ch;
}
.hero__title-main {
  background: linear-gradient(90deg, var(--c-accent), var(--c-accent-2) 55%, var(--c-accent-4));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-block;
}
.hero__title-sub {
  display: block;
  color: var(--c-ink);
  font-weight: 600;
  font-size: 0.6em;
  margin-top: 0.35rem;
}

.hero__intro {
  margin: 1.5rem auto 0;
  max-width: 72ch;
  color: var(--c-ink-soft);
  text-align: left;
}
.hero__intro p { margin: 0 0 0.9rem; }

.hero__ctas {
  margin-top: 1.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.cta {
  --cta-color: var(--c-accent);
  --cta-color-2: var(--c-accent-2);
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 1.05rem 0.7rem 0.85rem;
  border-radius: var(--r-pill);
  background: var(--c-surface);
  color: var(--c-ink);
  text-decoration: none;
  font-weight: 600;
  border: 1px solid var(--c-rule);
  box-shadow: var(--sh-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.cta:hover, .cta:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
  border-color: var(--cta-color);
  color: var(--c-ink);
}
.cta__icon {
  width: 34px; height: 34px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--cta-color), var(--cta-color-2));
  color: #fff;
}
.cta__icon .icon { width: 18px; height: 18px; }
.cta__arrow { color: var(--c-ink-muted); display: inline-flex; }
.cta__arrow .icon { width: 16px; height: 16px; }
.cta:hover .cta__arrow { color: var(--cta-color); }

.cta--teal   { --cta-color: #2c6b56; --cta-color-2: #1f5a7d; }
.cta--indigo { --cta-color: #6c5ce7; --cta-color-2: #1f5a7d; }
.cta--amber  { --cta-color: #c97a36; --cta-color-2: #b58300; }
.cta--rose   { --cta-color: #d83a7a; --cta-color-2: #6c5ce7; }

/* -------------------------------------------------------------
   Section overview + about (home)
   ------------------------------------------------------------- */

.section-overview { padding: clamp(2rem, 4vw, 3rem) 0; }
.section-overview__heading,
.about__heading {
  font-size: clamp(1.4rem, 1.4vw + 0.9rem, 2rem);
  margin: 0 0 1.5rem;
  color: var(--c-ink);
}
.section-overview__grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
.track-card {
  background: var(--c-bg-elev);
  border: 1px solid var(--c-rule);
  border-radius: var(--r-lg);
  padding: 1.4rem 1.4rem 1.2rem;
  box-shadow: var(--sh-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
}
.track-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-md);
  border-color: var(--c-accent);
}
.track-card__icon {
  width: 48px; height: 48px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--c-accent), var(--c-accent-2));
  color: #fff;
  display: inline-flex;
  align-items: center; justify-content: center;
  margin-bottom: 0.9rem;
}
.track-card__icon .icon { width: 24px; height: 24px; }
.track-card__title {
  font-size: 1.18rem;
  margin: 0 0 0.5rem;
}
.track-card__title a {
  text-decoration: none;
  color: var(--c-ink);
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 2px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: background-size 0.25s ease, color 0.18s ease;
}
.track-card__title a:hover {
  color: var(--c-accent);
  background-size: 100% 2px;
}
.track-card__blurb {
  color: var(--c-ink-soft);
  margin: 0 0 0.9rem;
}
.track-card__list {
  list-style: none;
  padding: 0; margin: 0 0 1rem;
  display: grid;
  gap: 0.3rem;
}
.track-card__list a {
  text-decoration: none;
  color: var(--c-link);
  font-size: 0.94rem;
}
.track-card__list a:hover { color: var(--c-link-hover); text-decoration: underline; }
.track-card__more {
  margin-top: auto;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--c-accent);
}
.track-card__more .icon { width: 18px; height: 18px; transition: transform 0.18s ease; }
.track-card__more:hover .icon { transform: translateX(3px); }

.about { padding: clamp(1.5rem, 3vw, 3rem) 0 3rem; }
.about__grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.about__grid h3 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  color: var(--c-accent-2);
}
.about__grid p { margin: 0; color: var(--c-ink-soft); }

/* -------------------------------------------------------------
   Content pages
   ------------------------------------------------------------- */

.content-page {
  padding: clamp(1rem, 2vw, 2rem) 0 3rem;
  display: grid;
  gap: 1.5rem;
}

/* Wide layout on big screens: optional sidebar slot via .related */
@media (min-width: 1280px) {
  .content-page { grid-template-columns: minmax(0, 1fr); }
}

.prose {
  width: 100%;
  margin: 0;
}
/* On desktops the prose fills the wide container — code blocks and tables
   benefit, and paragraph line length stays comfortable thanks to the
   container's own cap. */
@media (min-width: 1100px) {
  .prose { max-width: 100%; }
}

/* Headings */
.prose h1 {
  font-size: clamp(2rem, 2vw + 1.1rem, 2.8rem);
  line-height: 1.15;
  margin: 0 0 1.1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  background: linear-gradient(90deg, var(--c-accent), var(--c-accent-2) 60%, var(--c-accent-4));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.prose h2 {
  font-size: clamp(1.35rem, 0.8vw + 1.05rem, 1.75rem);
  margin: 2.2rem 0 0.8rem;
  color: var(--c-ink);
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--c-rule);
}
.prose h3 {
  font-size: clamp(1.1rem, 0.4vw + 1rem, 1.3rem);
  margin: 1.8rem 0 0.6rem;
  color: var(--c-accent-2);
}
.prose h4 {
  font-size: 1.05rem;
  margin: 1.4rem 0 0.5rem;
  color: var(--c-ink);
}
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  scroll-margin-top: calc(var(--header-h) + 16px);
}
/* The H1 is the page title — the in-page anchor link is noise, so hide it. */
.prose h1 a.header-anchor { display: none; }
.prose h2 a[href^="#"], .prose h3 a[href^="#"], .prose h4 a[href^="#"] {
  color: var(--c-rule-strong);
  text-decoration: none;
  margin-left: 0.4em;
  opacity: 0;
  transition: opacity 0.18s ease, color 0.18s ease;
  font-weight: 400;
}
.prose h2:hover a[href^="#"],
.prose h3:hover a[href^="#"],
.prose h4:hover a[href^="#"] { opacity: 1; }
.prose h2 a[href^="#"]:hover,
.prose h3 a[href^="#"]:hover,
.prose h4 a[href^="#"]:hover { color: var(--c-accent); }

.prose p {
  margin: 0 0 1.05rem;
  color: var(--c-ink-soft);
}
.prose strong { color: var(--c-ink); }

.prose ul, .prose ol {
  margin: 0 0 1.1rem;
  padding-left: 1.4rem;
  color: var(--c-ink-soft);
}
.prose li { margin: 0.2rem 0; }
.prose li::marker { color: var(--c-accent-3); }

/* Anchor styling inside prose */
.prose a {
  color: var(--c-link);
  text-decoration: underline;
  text-decoration-color: rgba(31, 90, 125, 0.35);
  text-underline-offset: 3px;
  transition: color 0.18s ease, text-decoration-color 0.18s ease;
}
.prose a:hover {
  color: var(--c-accent);
  text-decoration-color: currentColor;
}

/* Inline code — subtle tint that blends with the surrounding prose. */
.prose code:not(pre code) {
  background: var(--c-code-inline-bg);
  color: inherit;
  padding: 0.06em 0.32em;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.86em;
  font-weight: inherit;
  border: 0;
  white-space: nowrap;
}

/* Blockquotes */
.prose blockquote {
  margin: 1.2rem 0;
  padding: 0.6rem 1rem;
  border-left: 4px solid var(--c-accent);
  background: var(--c-surface-sub);
  color: var(--c-ink-soft);
  border-radius: 0 var(--r-md) var(--r-md) 0;
}

/* Tables */
.table-scroll {
  overflow-x: auto;
  margin: 1.3rem 0;
  border: 1px solid var(--c-rule);
  border-radius: var(--r-md);
  background: var(--c-bg-elev);
  box-shadow: var(--sh-sm);
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
  min-width: 540px;
}
.prose thead th {
  background: linear-gradient(180deg, rgba(44, 107, 86, 0.08), rgba(31, 90, 125, 0.06));
  text-align: left;
  font-weight: 600;
  color: var(--c-ink);
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--c-rule);
}
.prose tbody td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--c-rule);
  color: var(--c-ink-soft);
  vertical-align: top;
}
.prose tbody tr:last-child td { border-bottom: 0; }
.prose tbody tr:hover td { background: rgba(44, 107, 86, 0.04); }

/* Task lists (checkboxes) */
.prose ul.contains-task-list,
.prose ol.contains-task-list {
  list-style: none;
  padding-left: 0;
}
.prose li.task-list-item {
  position: relative;
  padding-left: 1.9rem;
}
.prose li.task-list-item::marker { content: ""; }
.prose li.task-list-item > input[type="checkbox"] {
  position: absolute;
  left: 0;
  top: 0.25em;
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--c-accent);
  cursor: pointer;
}
.prose li.task-list-item.is-checked > * {
  text-decoration: line-through;
  color: var(--c-ink-muted);
}

/* Horizontal rule */
.prose hr {
  border: 0;
  height: 1px;
  background: var(--c-rule);
  margin: 2rem 0;
}

/* -------------------------------------------------------------
   Code blocks
   ------------------------------------------------------------- */

.code-block {
  margin: 1.2rem 0;
  border: 1px solid var(--c-code-border);
  border-radius: var(--r-md);
  background: var(--c-code-bg);
  overflow: hidden;
  box-shadow: var(--sh-sm);
}
.code-block__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.6rem 0.35rem 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255, 253, 248, 0.55);
  border-bottom: 1px solid var(--c-code-border);
  color: var(--c-ink-muted);
}
.code-block__lang { font-weight: 600; }
.code-block__copy {
  cursor: pointer;
  border: 1px solid var(--c-code-border);
  background: var(--c-bg-elev);
  color: var(--c-ink-soft);
  padding: 0.2rem 0.65rem;
  border-radius: var(--r-pill);
  font-size: 0.72rem;
  font-family: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.code-block__copy:hover {
  background: var(--c-accent);
  color: #fff;
  border-color: var(--c-accent);
}
.code-block__copy.is-copied {
  background: var(--c-accent);
  color: #fff;
  border-color: var(--c-accent);
}
.code-block__pre {
  margin: 0;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--c-ink);
  background: transparent;
}
.code-block__pre code { font-family: inherit; }

/* Prism token colors — calibrated for the light theme */
.token.comment, .token.prolog, .token.cdata { color: #7a857c; font-style: italic; }
.token.punctuation { color: #41525c; }
.token.namespace { opacity: 0.7; }
.token.property, .token.tag, .token.constant, .token.symbol, .token.deleted { color: #b94b2f; }
.token.boolean, .token.number { color: #a04a16; }
.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted { color: #2c6b56; }
.token.operator, .token.entity, .token.url, .language-css .token.string, .style .token.string, .token.variable { color: #2c6b56; }
.token.atrule, .token.attr-value, .token.function, .token.class-name { color: #1f5a7d; }
.token.keyword { color: #6c5ce7; font-weight: 600; }
.token.regex, .token.important { color: #d83a7a; }
.token.important, .token.bold { font-weight: 700; }
.token.italic { font-style: italic; }
.token.entity { cursor: help; }

/* -------------------------------------------------------------
   Breadcrumbs
   ------------------------------------------------------------- */

.breadcrumbs {
  font-size: 0.88rem;
  color: var(--c-ink-muted);
  margin: 0 0 1.2rem;
}
.breadcrumbs__list {
  list-style: none;
  padding: 0; margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.4rem;
}
.breadcrumbs__item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.breadcrumbs__item a {
  text-decoration: none;
  color: var(--c-ink-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.breadcrumbs__item a:hover { color: var(--c-accent); }
.breadcrumbs__item .icon { width: 14px; height: 14px; }
.breadcrumbs__item.is-current { color: var(--c-ink); font-weight: 600; }
.breadcrumbs__sep { color: var(--c-rule-strong); display: inline-flex; }
.breadcrumbs__sep .icon { width: 14px; height: 14px; }

/* -------------------------------------------------------------
   Related (children + siblings)
   ------------------------------------------------------------- */

.related {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--c-rule);
  display: grid;
  gap: 1.75rem;
}
.related__heading {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--c-ink-muted);
  margin: 0 0 0.8rem;
}
.related__list {
  list-style: none;
  padding: 0; margin: 0;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
.related__link {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem 0.9rem;
  align-items: center;
  padding: 0.85rem 1rem;
  background: var(--c-bg-elev);
  border: 1px solid var(--c-rule);
  border-radius: var(--r-md);
  text-decoration: none;
  color: var(--c-ink);
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.related__link:hover {
  border-color: var(--c-accent);
  transform: translateY(-2px);
  box-shadow: var(--sh-sm);
}
.related__title { font-weight: 600; }
.related__desc {
  grid-column: 1 / -1;
  color: var(--c-ink-muted);
  font-size: 0.9rem;
}
.related__arrow {
  width: 18px; height: 18px;
  color: var(--c-accent);
  transition: transform 0.18s ease;
}
.related__link:hover .related__arrow { transform: translateX(3px); }

/* -------------------------------------------------------------
   FAQ accordion (<details> based)
   ------------------------------------------------------------- */

.prose details {
  border: 1px solid var(--c-rule);
  border-radius: var(--r-md);
  background: var(--c-bg-elev);
  margin: 0.7rem 0;
  padding: 0;
  overflow: hidden;
}
.prose details + details { margin-top: 0.5rem; }
.prose details > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.85rem 1rem;
  font-weight: 600;
  color: var(--c-ink);
  position: relative;
  padding-right: 2.4rem;
}
.prose details > summary::-webkit-details-marker { display: none; }
.prose details > summary::after {
  content: "+";
  position: absolute;
  right: 1rem; top: 50%;
  transform: translateY(-50%);
  width: 22px; height: 22px;
  border-radius: var(--r-pill);
  background: rgba(44, 107, 86, 0.12);
  color: var(--c-accent);
  display: inline-flex;
  align-items: center; justify-content: center;
  font-weight: 700;
  transition: transform 0.18s ease, background 0.18s ease;
}
.prose details[open] > summary::after { content: "−"; background: var(--c-accent); color: #fff; }
.prose details > *:not(summary) {
  padding: 0 1rem 1rem;
  color: var(--c-ink-soft);
}

/* -------------------------------------------------------------
   Mermaid container
   ------------------------------------------------------------- */

.mermaid-wrap {
  background: var(--c-bg-elev);
  border: 1px solid var(--c-rule);
  border-radius: var(--r-md);
  padding: 1rem;
  margin: 1.2rem auto;     /* auto-margin centres the card itself */
  max-width: 1000px;       /* keep diagram cards readable on wide screens */
  overflow-x: auto;
  text-align: center;
  box-shadow: var(--sh-sm);
}
/* Let the SVG (or the pre, pre-render) fill the card width so simple diagrams
   don't shrink to a tiny intrinsic size on desktop. */
.mermaid-wrap .mermaid {
  display: block;
  max-width: 100%;
}
.mermaid-wrap svg {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 100%;
  height: auto;
}
.mermaid { font-family: var(--font-sans); }

/* -------------------------------------------------------------
   KaTeX adjustments
   ------------------------------------------------------------- */

.katex { font-size: 1.02em; }
.katex-display {
  margin: 1rem 0;
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
}

/* -------------------------------------------------------------
   Print
   ------------------------------------------------------------- */

@media print {
  .site-header, .site-footer, .related, .code-block__copy, .skip-link { display: none !important; }
  body { background: #fff; }
  .page__main { padding-top: 0; }
}
