/* =========================================================================
   Cross-Engine Data Reconciliation — site styles
   Light, professional palette. Wide on desktop, elegant on mobile.
   ========================================================================= */

/* ---- Design tokens ---- */
:root {
  /* palette */
  --ink: #0f2024;
  --text: #1f2d33;
  --muted: #56707a;
  --bg: #f3f8f7;
  --surface: #ffffff;
  --surface-2: #ecf6f4;
  --border: #d6e6e3;
  --border-strong: #b9d6d1;

  --primary: #0f766e;
  --primary-600: #0d6359;
  --primary-700: #0b4f47;
  --primary-soft: #d6f3ee;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --amber: #f97316;
  --amber-soft: #ffedd5;
  --green: #059669;
  --red: #b3261e;

  /* gradients for icons/CTAs */
  --grad-architecture: linear-gradient(135deg, #38bdf8, #2563eb);
  --grad-hashing: linear-gradient(135deg, #34d399, #0f766e);
  --grad-diffing: linear-gradient(135deg, #fbbf24, #f97316);

  /* type */
  --font-sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;

  /* spacing / sizing */
  --shell: min(94rem, 92vw);
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 22px;
  --header-height: 68px;

  --shadow-sm: 0 1px 2px rgba(15, 32, 36, 0.06), 0 1px 3px rgba(15, 32, 36, 0.05);
  --shadow: 0 6px 18px rgba(15, 32, 36, 0.08);
  --shadow-lg: 0 18px 48px rgba(15, 32, 36, 0.14);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ---- Reset / base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: clamp(1rem, 0.97rem + 0.15vw, 1.075rem);
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(60rem 40rem at 85% -10%, var(--primary-soft) 0, transparent 55%),
    radial-gradient(48rem 32rem at -5% 0%, var(--blue-soft) 0, transparent 50%);
  background-attachment: fixed;
  /* sticky footer */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

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

.site-main {
  flex: 1 0 auto;
  width: 100%;
  padding-block: clamp(1.75rem, 1rem + 3vw, 3.5rem);
}

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

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  z-index: 1000;
  background: var(--primary);
  color: #fff;
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius-sm);
  transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 0.75rem; }

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

/* =========================================================================
   Header
   ========================================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(150%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: var(--header-height);
  padding-block: 0.5rem;
}

.brand { display: inline-flex; align-items: center; gap: 0.6rem; margin-right: auto; }
.brand__mark { filter: drop-shadow(0 3px 6px rgba(15, 118, 110, 0.25)); transition: transform 0.3s var(--ease); }
.brand:hover .brand__mark { transform: rotate(-6deg) scale(1.05); }
.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.brand__name { font-weight: 800; color: var(--ink); letter-spacing: -0.01em; font-size: 1.08rem; }
.brand__sub { font-size: 0.78rem; color: var(--muted); font-weight: 600; }

.primary-nav__list {
  list-style: none;
  display: flex;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  position: relative;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}
.nav-link__icon { color: var(--primary); transition: transform 0.2s var(--ease); }
.nav-link:hover { background: var(--surface-2); transform: translateY(-1px); }
.nav-link:hover .nav-link__icon { transform: scale(1.12); }
.nav-link.is-current { background: var(--primary); color: #fff; }
.nav-link.is-current .nav-link__icon { color: #fff; }

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  color: var(--ink);
  cursor: pointer;
}
.nav-toggle__close { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle__open { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle__close { display: block; }

/* =========================================================================
   Footer
   ========================================================================= */
.site-footer {
  flex-shrink: 0;
  margin-top: 3rem;
  background: var(--ink);
  color: #cfe3df;
}
.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  justify-content: space-between;
  padding-block: 2.5rem 1.5rem;
}
.site-footer__brand { display: flex; gap: 0.9rem; align-items: center; max-width: 32rem; }
.site-footer__name { margin: 0; font-weight: 700; color: #fff; }
.site-footer__tagline { margin: 0.2rem 0 0; font-size: 0.9rem; color: #9fc2bb; }
.site-footer__heading { margin: 0 0 0.6rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: #7fb3a9; }
.site-footer__nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.site-footer__nav a { color: #cfe3df; transition: color 0.2s var(--ease), padding-left 0.2s var(--ease); }
.site-footer__nav a:hover { color: #fff; padding-left: 0.25rem; }
.site-footer__bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: space-between;
  padding-block: 1rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.82rem;
  color: #8fb3ac;
}

/* =========================================================================
   Hero / home
   ========================================================================= */
.hero { text-align: center; }
.hero__inner { display: flex; flex-direction: column; align-items: stretch; }
.hero__logo { margin: 0 0 1.25rem; }
.hero__logo-img {
  width: clamp(112px, 9vw + 64px, 168px);
  height: auto;
  filter: drop-shadow(0 12px 28px rgba(15, 118, 110, 0.28));
  animation: floaty 6s ease-in-out infinite;
}
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.hero__title {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 1.2rem + 3.4vw, 3.6rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-weight: 800;
}
.hero__title-accent {
  background: linear-gradient(120deg, var(--primary), var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero__lede {
  font-size: clamp(1.1rem, 1rem + 0.6vw, 1.4rem);
  color: var(--ink);
  margin: 0 0 1.25rem;
  font-weight: 500;
}
.hero__body { color: var(--muted); margin: 0 0 1rem; }

.hero__ctas {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
  gap: 1rem;
  width: 100%;
  margin-top: 2rem;
  text-align: left;
}
.cta {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
}
.cta:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.cta__icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  border-radius: 14px;
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.cta__text { display: flex; flex-direction: column; gap: 0.15rem; }
.cta__title { font-weight: 700; color: var(--ink); font-size: 1.08rem; }
.cta__sub { font-size: 0.88rem; color: var(--muted); line-height: 1.4; }
.cta__arrow { margin-left: auto; color: var(--primary); flex: 0 0 auto; transition: transform 0.2s var(--ease); }
.cta:hover .cta__arrow { transform: translateX(4px); }

.cta--architecture .cta__icon, .home-pillar__icon.cta--architecture { background: var(--grad-architecture); }
.cta--hashing .cta__icon, .home-pillar__icon.cta--hashing { background: var(--grad-hashing); }
.cta--diffing .cta__icon, .home-pillar__icon.cta--diffing { background: var(--grad-diffing); }
.cta--architecture .cta__icon use, .cta--hashing .cta__icon use, .cta--diffing .cta__icon use { stroke: #fff; }
.cta__icon svg [stroke] { stroke: #fff; }
.cta__icon svg [fill]:not([fill="none"]) { fill: rgba(255,255,255,0.18); }

/* home sections */
.home-sections { margin-top: clamp(2.5rem, 1.5rem + 4vw, 5rem); }
.home-sections__heading { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); color: var(--ink); margin: 0 0 0.4rem; }
.home-sections__intro { color: var(--muted); margin: 0 0 2rem; max-width: 70ch; }

.home-pillar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.25s var(--ease);
}
.home-pillar:hover { box-shadow: var(--shadow); }
.home-pillar__head { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.home-pillar__icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 13px; color: #fff; flex: 0 0 auto; }
.home-pillar__title { margin: 0; font-size: 1.3rem; }
.home-pillar__title a { color: var(--ink); }
.home-pillar__title a:hover { color: var(--primary); }
.home-pillar__tagline { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.95rem; }
.home-pillar__links { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); gap: 0.4rem 1.25rem; }
.home-pillar__links a {
  display: block;
  padding: 0.5rem 0.75rem 0.5rem 1.5rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  position: relative;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}
.home-pillar__links a::before {
  content: "›"; position: absolute; left: 0.6rem; color: var(--primary); font-weight: 700;
  transition: transform 0.2s var(--ease);
}
.home-pillar__links a:hover { background: var(--surface-2); color: var(--primary-700); transform: translateX(2px); }
.home-pillar__links a:hover::before { transform: translateX(2px); }

/* =========================================================================
   Page layout (article + section)
   ========================================================================= */
.page-layout { display: block; }

/* Breadcrumbs */
.breadcrumbs { margin-bottom: 1.25rem; }
.breadcrumbs ol {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.1rem;
  font-size: 0.85rem; color: var(--muted);
}
.breadcrumbs li { display: inline-flex; align-items: center; }
.breadcrumbs li + li::before { content: "/"; margin: 0 0.5rem; color: var(--border-strong); }
.breadcrumbs a { color: var(--muted); transition: color 0.2s var(--ease); }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs [aria-current="page"] { color: var(--ink); font-weight: 600; }

/* =========================================================================
   Prose / article content
   ========================================================================= */
.prose {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(1.25rem, 0.8rem + 2vw, 3rem);
  box-shadow: var(--shadow-sm);
  /* Text uses the full width of its container (the card), which is itself
     constrained to a wide-but-not-full-page measure via .shell. */
}
.prose > * { max-width: 100%; }

.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }

.prose h1 {
  font-size: clamp(1.8rem, 1.3rem + 2vw, 2.8rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 0 0 1.25rem;
  font-weight: 800;
  background: linear-gradient(120deg, var(--primary-700), var(--primary) 45%, var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.prose h2 {
  font-size: clamp(1.4rem, 1.15rem + 1vw, 1.9rem);
  margin: 2.4rem 0 0.9rem;
  color: var(--ink);
  letter-spacing: -0.01em;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--surface-2);
}
.prose h3 { font-size: clamp(1.15rem, 1rem + 0.6vw, 1.4rem); margin: 1.9rem 0 0.7rem; color: var(--primary-700); }
.prose h4 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; color: var(--ink); }

/* anchor offset for sticky header */
.prose :is(h1, h2, h3, h4, h5, h6)[id] { scroll-margin-top: calc(var(--header-height) + 1.25rem); }
.header-anchor {
  text-decoration: none;
  color: var(--border-strong);
  margin-left: -1.1em;
  padding-right: 0.35em;
  opacity: 0;
  transition: opacity 0.15s var(--ease), color 0.15s var(--ease);
}
.prose :is(h1,h2,h3,h4):hover .header-anchor { opacity: 1; }
.header-anchor:hover { color: var(--primary); }

.prose p { margin: 0 0 1.15rem; }
.prose strong { color: var(--ink); font-weight: 700; }

/* links in content */
.prose a:not(.header-anchor) {
  color: var(--primary-700);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
  transition: color 0.2s var(--ease), text-decoration-color 0.2s var(--ease), background 0.2s var(--ease);
  border-radius: 3px;
}
.prose a:not(.header-anchor):hover {
  color: var(--blue);
  text-decoration-color: var(--blue);
  background: var(--blue-soft);
}

/* lists */
.prose ul, .prose ol { margin: 0 0 1.15rem; padding-left: 1.5rem; }
.prose li { margin: 0.35rem 0; }
.prose li::marker { color: var(--primary); }

/* blockquote */
.prose blockquote {
  margin: 1.5rem auto;
  padding: 0.75rem 1.25rem;
  border-left: 4px solid var(--primary);
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink);
}
.prose blockquote p:last-child { margin-bottom: 0; }

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

/* =========================================================================
   Inline code + code blocks
   ========================================================================= */
:not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-2);
  color: var(--primary-700);
  padding: 0.12em 0.42em;
  border-radius: 6px;
  /* no border; blends with text */
}

.code-block {
  margin: 1.5rem auto;
  background: #fbfdfc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.code-block__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.55rem 0.4rem 0.95rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.code-block__lang {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.code-block__copy {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--primary-700);
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.15s var(--ease);
}
.code-block__copy:hover { background: var(--primary); color: #fff; transform: translateY(-1px); }
.code-block__copy.is-copied { background: var(--green); color: #fff; border-color: var(--green); }
.code-block__pre {
  margin: 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.6;
  color: #1c2b30;
  background: #fbfdfc;
  -webkit-overflow-scrolling: touch;
}
.code-block__pre code { font-family: inherit; background: none; padding: 0; color: inherit; }

/* Prism token colours tuned to the light palette */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #6a8a86; font-style: italic; }
.token.punctuation { color: #5a7378; }
.token.keyword, .token.boolean, .token.atrule, .token.important { color: #0b4f47; font-weight: 600; }
.token.string, .token.char, .token.attr-value, .token.regex { color: #b45309; }
.token.number, .token.constant { color: #2563eb; }
.token.function, .token.class-name { color: #1d4ed8; }
.token.operator, .token.entity, .token.url { color: #0f766e; }
.token.property, .token.tag, .token.symbol, .token.deleted { color: #be123c; }
.token.builtin, .token.attr-name { color: #047857; }
.token.decorator, .token.annotation { color: #9333ea; }

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

/* =========================================================================
   Task-list checkboxes (togglable, strike-through when checked)
   ========================================================================= */
.prose ul.contains-task-list { list-style: none; padding-left: 0.25rem; }
.prose ul.contains-task-list .contains-task-list { padding-left: 1.5rem; }
.prose li.task-list-item { position: relative; padding-left: 2rem; margin: 0.45rem 0; list-style: none; }
.prose li.task-list-item::marker { content: ""; }
.task-list-item-checkbox {
  position: absolute;
  left: 0;
  top: 0.28em;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  display: grid;
  place-content: center;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease);
}
.task-list-item-checkbox::after {
  content: "";
  width: 0.62rem;
  height: 0.34rem;
  border-left: 2.5px solid #fff;
  border-bottom: 2.5px solid #fff;
  transform: rotate(-45deg) scale(0);
  transition: transform 0.18s var(--ease);
  margin-top: -2px;
}
.task-list-item-checkbox:checked { background: var(--primary); border-color: var(--primary); }
.task-list-item-checkbox:checked::after { transform: rotate(-45deg) scale(1); }
.task-list-item-checkbox:checked ~ * ,
.task-list-item.is-checked > label,
.task-list-item.is-checked { color: var(--muted); }
.task-list-item.is-checked > label,
.task-list-item.is-checked { text-decoration: line-through; text-decoration-color: var(--border-strong); }

/* =========================================================================
   FAQ accordions (<details>) — also auto-generated from FAQ sections
   ========================================================================= */
.faq { margin: 1.75rem auto; display: grid; gap: 0.6rem; }
.faq__item, .prose details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.faq__item > summary, .prose details > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.95rem 1.15rem;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.faq__item > summary::-webkit-details-marker, .prose details > summary::-webkit-details-marker { display: none; }
.faq__item > summary::after, .prose details > summary::after {
  content: "+";
  margin-left: auto;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--primary);
  transition: transform 0.25s var(--ease);
}
.faq__item[open] > summary, .prose details[open] > summary { background: var(--surface-2); color: var(--primary-700); }
.faq__item[open] > summary::after, .prose details[open] > summary::after { transform: rotate(45deg); }
.faq__item > summary:hover, .prose details > summary:hover { background: var(--surface-2); }
.faq__answer, .prose details > .faq__answer, .prose details > *:not(summary) { padding: 0 1.15rem; }
.faq__answer > :last-child { padding-bottom: 1rem; }
.faq__item .faq__answer { padding-top: 0.25rem; }

/* =========================================================================
   Mermaid diagrams
   ========================================================================= */
pre.mermaid {
  margin: 1.5rem auto;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}
pre.mermaid:not([data-processed]) { color: transparent; min-height: 3rem; }

/* Zoomable visualizations + full-screen lightbox */
.viz { position: relative; }
.viz .mermaid,
pre.mermaid.is-zoomable { cursor: zoom-in; }
.viz__expand {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.6rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary-700);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease), background 0.2s var(--ease), color 0.2s var(--ease);
}
.viz:hover .viz__expand,
.viz:focus-within .viz__expand { opacity: 1; transform: translateY(0); }
.viz__expand:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
@media (hover: none) { .viz__expand { opacity: 1; } }

.viz-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  place-items: center;
  padding: clamp(0.5rem, 2vw, 2rem);
  background: rgba(8, 22, 25, 0.78);
  backdrop-filter: blur(6px);
}
.viz-modal.is-open { display: grid; animation: viz-fade 0.18s var(--ease); }
@keyframes viz-fade { from { opacity: 0; } to { opacity: 1; } }

.viz-modal__stage {
  position: relative;
  width: min(96vw, 1600px);
  height: min(90vh, 1100px);
  overflow: hidden;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  touch-action: none;
  cursor: grab;
}
.viz-modal__stage.is-panning { cursor: grabbing; }
.viz-modal__pan {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transform-origin: center center;
  will-change: transform;
}
/* Fit-to-contain by default (fully visible, large); zoom/pan goes bigger.
   Mermaid SVGs carry a viewBox + preserveAspectRatio="xMidYMid meet", so
   width/height 100% letterboxes the diagram neatly inside the stage. */
.viz-modal__pan svg {
  max-width: 100% !important;
  max-height: 100%;
  width: 100%;
  height: 100%;
}
.viz-modal__toolbar {
  position: absolute;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.3rem;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.viz-modal__btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.viz-modal__btn:hover { background: var(--surface-2); color: var(--primary-700); }
.viz-modal__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s var(--ease), color 0.15s var(--ease), transform 0.15s var(--ease);
}
.viz-modal__close:hover { background: var(--red); color: #fff; transform: rotate(90deg); }
.viz-modal__hint {
  position: absolute;
  bottom: 0.6rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.76rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.85);
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  pointer-events: none;
}

/* =========================================================================
   Cards (section landing) + related
   ========================================================================= */
.cards { margin-top: 2.5rem; }
.cards__heading { font-size: 1.4rem; color: var(--ink); margin: 0 0 1.1rem; }
.cards__grid, .related__grid {
  list-style: none; margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 21rem), 1fr));
  gap: 1rem;
}
.card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  height: 100%;
  padding: 1.1rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease), border-color 0.22s var(--ease);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.card__icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); flex: 0 0 auto; }
.card__body { display: flex; flex-direction: column; gap: 0.2rem; }
.card__title { font-weight: 700; color: var(--ink); line-height: 1.25; }
.card__desc { font-size: 0.85rem; color: var(--muted); }
.card__arrow { margin-left: auto; color: var(--primary); flex: 0 0 auto; transition: transform 0.2s var(--ease); }
.card:hover .card__arrow { transform: translateX(4px); }

.related {
  margin-top: 2.25rem;
  padding: 1.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.related__title { display: flex; align-items: center; gap: 0.6rem; margin: 0 0 1rem; font-size: 1.25rem; color: var(--ink); }
.related__card {
  display: flex; align-items: center; gap: 0.6rem; height: 100%;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.related__card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.related__card-title { font-weight: 600; color: var(--ink); line-height: 1.3; }
.related__card-arrow { margin-left: auto; color: var(--primary); flex: 0 0 auto; }
.related__back { margin: 1.25rem 0 0; }
.related__back a { font-weight: 600; }

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .primary-nav {
    position: fixed;
    inset: var(--header-height) 0 auto 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 0.75rem var(--shell-pad, 1rem);
    transform: translateY(-12px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s var(--ease), opacity 0.22s var(--ease);
  }
  .primary-nav.is-open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .primary-nav__list { flex-direction: column; gap: 0.2rem; width: var(--shell); margin-inline: auto; }
  .nav-link { padding: 0.7rem 0.9rem; border-radius: var(--radius-sm); }
  .nav-link.is-current { background: var(--primary); }
}
