/* ==========================================================================
   TimescaleDB Lifecycle & Automation Hub — global styles
   Light, elegant, professional. Teal/indigo primary, warm amber accent.
   ========================================================================== */

:root {
  /* palette */
  --teal-700: #0e7490;
  --teal-600: #0d9488;
  --teal-50: #ecfeff;
  --indigo-700: #4338ca;
  --indigo-50: #eef2ff;
  --amber-700: #b45309;
  --amber-400: #f59e0b;

  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  --bg: #f6f8fb;
  --bg-elev: #ffffff;
  --bg-tint: #f1f5f9;

  --primary: var(--teal-700);
  --primary-ink: #0b5566;
  --accent: var(--teal-700); /* overridden per-section inline */

  --code-bg: #f8fafc;
  --code-border: #e6edf3;
  --inline-code-bg: #eef2f6;

  /* shape + motion */
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow-md: 0 6px 20px -8px rgba(15, 23, 42, .18), 0 2px 6px rgba(15, 23, 42, .06);
  --shadow-lg: 0 24px 50px -22px rgba(15, 23, 42, .35);
  --ring: 0 0 0 3px rgba(14, 116, 144, .28);

  --header-h: 66px;
  /* content matches the header/footer width so the site lines up edge to edge */
  --content-max: 92rem;
  --shell-max: 92rem;

  --ease: cubic-bezier(.4, 0, .2, 1);

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

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem); /* in-page links clear the sticky header */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.075rem);
  line-height: 1.7;
  color: var(--ink-soft);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* sticky footer */
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

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

h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }

a { color: var(--primary); text-decoration: none; transition: color .18s var(--ease); }
a:hover { color: var(--amber-700); }

img, svg { max-width: 100%; }
.icon { width: 1.25em; height: 1.25em; flex: none; display: inline-block; vertical-align: middle; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

.skip-link {
  position: fixed; top: -100px; left: 12px; z-index: 1000;
  background: var(--primary); color: #fff; padding: .6rem 1rem; border-radius: 8px;
  transition: top .2s var(--ease);
}
.skip-link:focus { top: 12px; color: #fff; }

/* ----------------------------------------------------------------- header */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: var(--shell-max); margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 2.5rem);
  height: var(--header-h);
  display: flex; align-items: center; gap: 1rem;
}
.brand { display: inline-flex; align-items: center; gap: .65rem; color: var(--ink); flex: none; }
.brand:hover { color: var(--ink); }
.brand-logo { filter: drop-shadow(0 4px 8px rgba(14, 116, 144, .25)); transition: transform .25s var(--ease); }
.brand:hover .brand-logo { transform: rotate(-4deg) scale(1.05); }
.brand-text { display: flex; flex-direction: column; line-height: 1.12; }
.brand-name { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--teal-700), var(--indigo-700));
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-sub { font-size: .72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }

.primary-nav { margin-left: auto; }
.primary-nav ul { list-style: none; display: flex; align-items: center; gap: .25rem; margin: 0; padding: 0; }
.nav-link {
  --accent: var(--primary);
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .5rem .8rem; border-radius: 999px;
  color: var(--ink-soft); font-weight: 600; font-size: .94rem;
  border: 1px solid transparent; transition: background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease);
}
.nav-link .icon { color: var(--accent); }
.nav-link:hover { background: var(--bg-tint); color: var(--ink); }
.nav-link.is-current { background: color-mix(in srgb, var(--accent) 12%, #fff); color: var(--primary-ink); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }

.nav-toggle {
  display: none; margin-left: auto;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px;
  width: 44px; height: 44px; align-items: center; justify-content: center; color: var(--ink);
  cursor: pointer; transition: background .18s var(--ease), box-shadow .18s var(--ease);
}
.nav-toggle:hover { background: var(--bg-tint); box-shadow: var(--shadow-sm); }
.nav-toggle .icon { width: 1.4em; height: 1.4em; }

/* ----------------------------------------------------------------- footer */
.site-footer {
  flex-shrink: 0; margin-top: 4rem;
  background: linear-gradient(180deg, #0b3a47, #0a2540);
  color: #cbd5e1;
}
.footer-inner {
  max-width: var(--shell-max); margin: 0 auto;
  padding: clamp(2rem, 4vw, 3.5rem) clamp(1rem, 3vw, 2.5rem) 1.5rem;
  display: grid; gap: 2rem; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
}
.footer-brand { display: flex; gap: 1rem; align-items: flex-start; }
.footer-logo { filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .4)); }
.footer-tagline { margin: 0; color: #94a3b8; max-width: 46ch; font-size: .96rem; }
.footer-heading { color: #e2e8f0; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 .8rem; }
.footer-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.footer-nav a { --accent: #5eead4; display: inline-flex; align-items: center; gap: .55rem; color: #cbd5e1; padding: .3rem 0; font-weight: 500; }
.footer-nav a .icon { color: var(--accent); }
.footer-nav a:hover { color: #fff; }
.footer-bottom {
  max-width: var(--shell-max); margin: 0 auto;
  padding: 1rem clamp(1rem, 3vw, 2.5rem) 2rem;
  border-top: 1px solid rgba(255, 255, 255, .08);
}
.footer-bottom p { margin: 0; color: #7c8ba1; font-size: .85rem; }

/* ------------------------------------------------------------------- hero */
.page-home .site-main, .page-topics .site-main, .page-offline .site-main {
  max-width: var(--shell-max); margin: 0 auto; padding: 0 clamp(1rem, 3vw, 2.5rem);
}
.hero {
  text-align: center;
  padding: clamp(2.5rem, 6vw, 5rem) 0 clamp(1.5rem, 3vw, 2.5rem);
}
.hero-logo img {
  display: block; margin: 0 auto 1.5rem;
  width: clamp(110px, 16vw, 168px); height: auto;
  filter: drop-shadow(0 20px 40px rgba(14, 116, 144, .35));
  animation: floaty 6s var(--ease) infinite;
}
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.hero-title {
  font-size: clamp(2rem, 1.3rem + 3.4vw, 3.6rem); margin: 0 auto .8rem; max-width: 18ch; font-weight: 800;
}
.hero-accent { background: linear-gradient(100deg, var(--teal-600), var(--indigo-700));
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-lede { max-width: 60ch; margin: 0 auto; font-size: clamp(1.05rem, 1rem + 0.4vw, 1.3rem); color: var(--ink-soft); }

.hero-cta {
  margin: clamp(2rem, 4vw, 3rem) auto 0; max-width: var(--content-max);
  display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.cta-btn {
  --accent: var(--primary);
  display: flex; align-items: center; gap: .9rem; text-align: left;
  padding: 1rem 1.1rem; border-radius: var(--radius);
  background: var(--bg-elev); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); color: var(--ink);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.cta-btn:hover {
  transform: translateY(-4px); color: var(--ink);
  box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.cta-icon {
  flex: none; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 12px;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, #fff);
}
.cta-icon .icon { width: 1.7em; height: 1.7em; }
.cta-text { display: flex; flex-direction: column; min-width: 0; }
.cta-title { font-weight: 700; }
.cta-sub { color: var(--muted); font-size: .85rem; line-height: 1.4; }
.cta-go { margin-left: auto; color: var(--accent); opacity: .55; transition: transform .2s var(--ease), opacity .2s var(--ease); }
.cta-btn:hover .cta-go { transform: translateX(4px); opacity: 1; }
.cta-inline { flex: 0 1 auto; }

/* --------------------------------------------------- homepage intro/cards */
.intro { max-width: var(--content-max); margin: clamp(2rem, 4vw, 3.5rem) auto 0; }
.intro h2, .overview-heading, .related-heading, .faq-heading {
  font-size: clamp(1.4rem, 1.2rem + 1vw, 2rem);
  position: relative; padding-bottom: .4rem;
}
.overview-heading { text-align: center; margin: clamp(2.5rem, 5vw, 4rem) 0 1.8rem; }
.sections-overview, .topics-grid, .topics-head { max-width: var(--content-max); margin-inline: auto; }
.topics-head { padding-top: clamp(1.5rem, 3vw, 2.5rem); }
.topics-lede { color: var(--muted); }

.card-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.topics-grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); margin-top: 1.5rem; }

.section-card {
  --accent: var(--primary);
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 1.5rem; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .22s var(--ease);
}
.section-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 30%, #fff)); }
.section-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.section-card-head { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.section-card-icon { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 11px;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, #fff); }
.section-card-icon .icon { width: 1.5em; height: 1.5em; }
.section-card h2, .section-card h3 { margin: 0; font-size: 1.2rem; }
.section-card h2 a, .section-card h3 a { color: var(--ink); }
.section-card h2 a:hover, .section-card h3 a:hover { color: var(--accent); }
.section-card-tagline { color: var(--muted); margin: .25rem 0 1rem; font-size: .95rem; }
.section-card-links { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .15rem; }
.section-card-links a { display: flex; gap: .5rem; align-items: flex-start; color: var(--ink-soft); padding: .35rem .5rem; border-radius: 8px; font-size: .94rem; font-weight: 500; }
.section-card-links a .icon { color: var(--accent); margin-top: .15em; width: 1em; height: 1em; }
.section-card-links a:hover { background: color-mix(in srgb, var(--accent) 8%, #fff); color: var(--accent); }
.section-card-more { display: inline-flex; align-items: center; gap: .4rem; font-weight: 700; color: var(--accent); }
.section-card-more:hover { color: var(--accent); gap: .6rem; }
.section-card-more .icon { transition: transform .2s var(--ease); }
.section-card-more:hover .icon { transform: translateX(3px); }

/* topic cards (related sub-topics) */
.topic-card {
  --accent: var(--primary);
  display: flex; align-items: center; gap: .8rem; height: 100%;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow-sm); color: var(--ink);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.topic-card:hover { transform: translateY(-3px); color: var(--ink); box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.topic-card-icon { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, #fff); }
.topic-card-title { font-weight: 600; font-size: .96rem; line-height: 1.35; }
.topic-card-go { margin-left: auto; color: var(--accent); opacity: .5; transition: transform .2s var(--ease), opacity .2s var(--ease); }
.topic-card:hover .topic-card-go { transform: translateX(3px); opacity: 1; }

/* ---------------------------------------------------------- article shell */
.article {
  --accent: var(--primary);
  max-width: var(--shell-max); margin: 0 auto; width: 100%;
  padding: clamp(1.25rem, 3vw, 2.5rem) clamp(1rem, 3vw, 2.5rem) 0;
  display: grid; grid-template-columns: minmax(0, 1fr);
}
.article-head { max-width: var(--content-max); margin-inline: auto; width: 100%; }
.article-title {
  font-size: clamp(1.9rem, 1.4rem + 2.4vw, 3rem); margin: .6rem 0 1.5rem;
  background: linear-gradient(100deg, var(--accent), color-mix(in srgb, var(--accent) 45%, var(--indigo-700)));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* breadcrumbs */
.breadcrumbs { font-size: .85rem; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: .15rem; margin: 0; padding: 0; }
.breadcrumbs li { display: inline-flex; align-items: center; gap: .15rem; color: var(--muted); }
.breadcrumbs a { color: var(--muted); font-weight: 500; }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs li[aria-current] span { color: var(--ink-soft); font-weight: 600; }
.crumb-sep .icon { width: .85em; height: .85em; color: var(--line-strong); }
.breadcrumbs li:last-child .crumb-sep { display: none; }

/* ---------------------------------------------------------------- prose */
/* prose fills the full width of its container (matching code blocks, tables, etc.) */
.prose { max-width: var(--content-max); margin-inline: auto; width: 100%; }

.prose h2 { font-size: clamp(1.45rem, 1.2rem + 1vw, 2rem); margin: 2.6rem 0 1rem; padding-top: .2rem;
  border-top: 1px solid var(--line); padding-top: 1.6rem; }
.prose h3 { font-size: clamp(1.2rem, 1.05rem + .6vw, 1.5rem); margin: 2rem 0 .8rem; }
.prose h4 { font-size: 1.1rem; margin: 1.6rem 0 .6rem; color: var(--ink-soft); }

.prose p { margin: 0 0 1.15rem; }
.prose ul, .prose ol { margin: 0 0 1.2rem; padding-left: 1.4rem; }
.prose li { margin: .35rem 0; }
.prose li::marker { color: var(--accent); }
.prose strong { color: var(--ink); font-weight: 700; }
.prose blockquote {
  margin: 1.5rem 0; padding: .8rem 1.2rem; border-left: 4px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, #fff); border-radius: 0 10px 10px 0; color: var(--ink-soft);
}
.prose hr { border: none; border-top: 1px solid var(--line); margin: 2.5rem 0; }

/* header anchors */
.header-anchor { color: var(--line-strong); text-decoration: none; padding-right: .4rem; margin-left: -1.1rem;
  opacity: 0; transition: opacity .15s var(--ease), color .15s var(--ease); }
.prose h2:hover .header-anchor, .prose h3:hover .header-anchor, .prose h4:hover .header-anchor { opacity: 1; }
.header-anchor:hover { color: var(--accent); }

/* links in prose */
.prose a { font-weight: 600; color: var(--primary);
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 2px; background-repeat: no-repeat; background-position: 0 100%;
  transition: background-size .25s var(--ease), color .18s var(--ease); padding-bottom: 1px; }
.prose a:hover { color: var(--amber-700); background-size: 100% 2px; }

/* inline code — subtle, borderless, blends with text */
:not(pre) > code {
  font-family: var(--font-mono); font-size: .88em;
  background: var(--inline-code-bg); color: #0b5566;
  padding: .12em .42em; border-radius: 6px; white-space: break-spaces; word-break: break-word;
}

/* ----------------------------------------------------------- code blocks */
.code-block {
  margin: 1.5rem 0; border: 1px solid var(--code-border); border-radius: var(--radius);
  background: var(--code-bg); overflow: hidden; box-shadow: var(--shadow-sm);
}
.code-block figcaption {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .5rem .55rem .5rem .95rem; background: #eef3f8; border-bottom: 1px solid var(--code-border);
}
.code-lang { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; }
.copy-btn {
  display: inline-flex; align-items: center; gap: .4rem; cursor: pointer;
  font: inherit; font-size: .8rem; font-weight: 600; color: var(--primary-ink);
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .3rem .65rem;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.copy-btn:hover { background: var(--teal-50); border-color: color-mix(in srgb, var(--teal-700) 35%, var(--line)); }
.copy-icon { width: 14px; height: 14px;
  -webkit-mask: var(--copy-mask) center / contain no-repeat; mask: var(--copy-mask) center / contain no-repeat;
  background: currentColor; }
:root { --copy-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='9' y='9' width='11' height='11' rx='2' fill='none' stroke='black' stroke-width='1.8'/%3E%3Cpath fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' d='M5 15V5a2 2 0 0 1 2-2h8'/%3E%3C/svg%3E"); }
.copy-btn.is-copied { color: var(--teal-600); border-color: var(--teal-600); }
.code-block pre { margin: 0; padding: 1.1rem 1.2rem; overflow-x: auto; font-family: var(--font-mono);
  font-size: .88rem; line-height: 1.6; color: #1f2d3d; tab-size: 2; }
.code-block code { font-family: inherit; background: none; padding: 0; color: inherit; font-size: inherit; }

/* Prism token colours tuned to the light scheme */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #6b8299; font-style: italic; }
.token.punctuation { color: #5b7083; }
.token.keyword, .token.boolean, .token.atrule, .token.selector { color: #4338ca; font-weight: 600; }
.token.function, .token.class-name { color: #0e7490; }
.token.string, .token.char, .token.attr-value, .token.regex { color: #b45309; }
.token.number, .token.constant { color: #9333ea; }
.token.operator, .token.entity, .token.url { color: #0d9488; }
.token.property, .token.tag, .token.symbol, .token.deleted { color: #be123c; }
.token.attr-name, .token.variable { color: #1d4ed8; }
.token.important { color: #be123c; font-weight: 700; }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; margin: 1.5rem 0; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); -webkit-overflow-scrolling: touch; }
.table-wrap table { border-collapse: collapse; width: 100%; min-width: 480px; font-size: .94rem; }
.table-wrap th, .table-wrap td { text-align: left; padding: .7rem .95rem; border-bottom: 1px solid var(--line); }
.table-wrap thead th { background: var(--bg-tint); color: var(--ink); font-weight: 700;
  position: sticky; top: 0; border-bottom: 2px solid var(--line-strong); }
.table-wrap tbody tr { transition: background .15s var(--ease); }
.table-wrap tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, #fff); }
.table-wrap tbody tr:last-child td { border-bottom: none; }

/* --------------------------------------------------------- task checkboxes */
.prose ul.contains-task-list, .prose .contains-task-list { list-style: none; padding-left: .25rem; }
.prose .task-list-item { display: flex; align-items: flex-start; gap: .65rem; margin: .5rem 0; }
.prose .task-list-item::marker { content: ""; } /* remove the dot */
.prose .task-list-item input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex: none; margin-top: .28em;
  width: 1.15em; height: 1.15em; border: 2px solid var(--line-strong); border-radius: 6px;
  background: #fff; cursor: pointer; position: relative; transition: background .15s var(--ease), border-color .15s var(--ease);
}
.prose .task-list-item input[type="checkbox"]:hover { border-color: var(--accent); }
.prose .task-list-item input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.prose .task-list-item input[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 4px; top: 1px; width: 5px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.prose .task-list-item input[type="checkbox"]:checked ~ * ,
.prose .task-list-item.done { text-decoration: line-through; color: var(--muted); }

/* --------------------------------------------------------------- accordions */
.faq { display: grid; gap: .75rem; margin: 1.5rem 0; }
.faq-item {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev);
  box-shadow: var(--shadow-sm); overflow: hidden; transition: border-color .18s var(--ease);
}
.faq-item[open] { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.faq-item summary {
  cursor: pointer; list-style: none; padding: 1rem 1.2rem; font-weight: 700; color: var(--ink);
  display: flex; align-items: center; gap: .75rem; transition: background .15s var(--ease);
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before {
  content: ""; flex: none; width: 1.1em; height: 1.1em; border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 14%, #fff);
  -webkit-mask: var(--chevron-mask) center / .7em no-repeat; mask: var(--chevron-mask) center / .7em no-repeat;
  color: var(--accent); box-shadow: inset 0 0 0 2em currentColor; transition: transform .2s var(--ease);
}
:root { --chevron-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m9 6 6 6-6 6' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.faq-item[open] summary::before { transform: rotate(90deg); }
.faq-item summary:hover { background: var(--bg-tint); }
.faq-answer { padding: 0 1.2rem 1.1rem; color: var(--ink-soft); }
.faq-answer > :first-child { margin-top: 0; }

/* ---------------------------------------------------------------- related */
/* width:100% so these grid items fill the column instead of shrink-wrapping to content */
.related, .related-links { max-width: var(--content-max); width: 100%; margin: 3rem auto 0; }
.related-heading { font-size: 1.3rem; margin: 0 0 1.1rem; }
.related-links ul { list-style: none; margin: 0 0 2rem; padding: 0; display: grid; gap: .4rem; }
.related-link { --accent: var(--primary); display: flex; align-items: center; gap: .55rem; padding: .6rem .85rem;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg-elev); color: var(--ink-soft); font-weight: 500;
  transition: border-color .18s var(--ease), background .18s var(--ease), transform .18s var(--ease); }
.related-link .icon { color: var(--accent); }
.related-link:hover { color: var(--ink); border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  background: color-mix(in srgb, var(--accent) 5%, #fff); transform: translateX(3px); }
.related-up { font-weight: 700; }

/* ---------------------------------------------------------- diagrams */
figure.diagram {
  margin: 1.75rem 0;
  display: flex; flex-direction: column; align-items: center; gap: .65rem;
}
figure.diagram > figcaption {
  color: var(--muted); font-size: .9rem; text-align: center; max-width: 60ch;
}
.mermaid {
  position: relative; margin: 0; width: 100%;
  display: flex; justify-content: center; align-items: center;
  padding: 1.25rem 1rem; background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), transform .18s var(--ease);
  overflow-x: auto;
}
.mermaid svg { max-width: 100%; height: auto; }
.mermaid[role="button"] { cursor: zoom-in; }
.mermaid[role="button"]:hover {
  border-color: color-mix(in srgb, var(--accent, var(--primary)) 45%, var(--line));
  box-shadow: var(--shadow-md); transform: translateY(-2px);
}
.mermaid[role="button"]:focus-visible { box-shadow: var(--ring); border-color: var(--accent, var(--primary)); }
.diagram-expand-hint {
  position: absolute; top: .55rem; right: .55rem;
  width: 30px; height: 30px; display: grid; place-items: center;
  color: var(--accent, var(--primary)); background: color-mix(in srgb, var(--accent, var(--primary)) 12%, #fff);
  border: 1px solid color-mix(in srgb, var(--accent, var(--primary)) 28%, var(--line));
  border-radius: 8px; opacity: 0; transition: opacity .18s var(--ease);
  pointer-events: none;
}
.diagram-expand-hint svg { width: 16px; height: 16px; }
.mermaid[role="button"]:hover .diagram-expand-hint,
.mermaid[role="button"]:focus-visible .diagram-expand-hint { opacity: 1; }

/* fullscreen diagram modal */
body.modal-open { overflow: hidden; }
.diagram-modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; }
.diagram-modal[hidden] { display: none; }
.diagram-modal-backdrop {
  position: absolute; inset: 0; background: rgba(8, 15, 30, .82);
  backdrop-filter: blur(4px); animation: modalFade .2s var(--ease);
}
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.diagram-modal-dialog {
  position: relative; z-index: 1; margin: clamp(.75rem, 3vw, 2rem);
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: clamp(1.25rem, 3vw, 2.5rem);
  width: min(96vw, 1500px); max-width: 96vw; max-height: 94vh;
  display: flex; overflow: auto; animation: modalPop .22s var(--ease);
}
@keyframes modalPop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
.diagram-modal-content { margin: 0; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.diagram-modal-content svg { width: 100%; max-width: none; height: auto; max-height: 82vh; }
.diagram-modal-content figcaption { color: var(--muted); font-size: .95rem; text-align: center; }
.diagram-modal-close {
  position: absolute; top: .5rem; right: .5rem; z-index: 2;
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
  font-size: 1.6rem; line-height: 1; color: var(--ink-soft);
  background: var(--bg-elev); border: 1px solid var(--line);
  display: grid; place-items: center; transition: background .15s var(--ease), color .15s var(--ease);
}
.diagram-modal-close:hover { background: var(--bg-tint); color: var(--ink); }

/* katex shouldn't overflow */
.katex-display { overflow-x: auto; overflow-y: hidden; padding: .4rem 0; }

/* --------------------------------------------------------------- offline */
.offline { text-align: center; padding: clamp(3rem, 8vw, 6rem) 0; }
.offline-logo { opacity: .9; margin-bottom: 1rem; }
.offline-actions { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; margin-top: 1.5rem; }

/* --------------------------------------------------------------- responsive */
@media (max-width: 860px) {
  .footer-inner { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-flex; }
  .primary-nav {
    position: fixed; inset: var(--header-h) 0 auto 0; margin: 0;
    background: rgba(255, 255, 255, .98); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line); box-shadow: var(--shadow-md);
    max-height: calc(100dvh - var(--header-h)); overflow-y: auto;
    transform: translateY(-12px); opacity: 0; pointer-events: none;
    transition: opacity .2s var(--ease), transform .2s var(--ease);
  }
  .primary-nav.is-open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .primary-nav ul { flex-direction: column; align-items: stretch; gap: .2rem;
    padding: .85rem clamp(1rem, 4vw, 1.5rem) 1.1rem; }
  .nav-link { padding: .7rem .85rem; border-radius: 10px; font-size: 1rem; }
  .nav-link.is-current { background: color-mix(in srgb, var(--accent) 14%, #fff); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
