/* =========================================================================
   Apache Druid Segment Management — site styles
   Light, elegant, professional. Widescreen-first, fully responsive.
   ========================================================================= */

:root {
  /* Palette */
  --indigo: #4f46e5;
  --indigo-600: #4f46e5;
  --indigo-500: #6366f1;
  --violet: #8b5cf6;
  --cyan: #06b6d4;
  --cyan-400: #22d3ee;
  --amber: #f59e0b;
  --amber-400: #fbbf24;
  --emerald: #10b981;
  --rose: #f43f5e;

  /* Semantic tokens */
  --bg: #f6f7fc;
  --bg-grad-1: #eef0fb;
  --bg-grad-2: #f6f7fc;
  --surface: #ffffff;
  --surface-2: #fbfbfe;
  --text: #1f2433;
  --text-soft: #3a4257;
  --muted: #66708a;
  --border: #e6e8f2;
  --border-strong: #d6d9e8;
  --code-bg: #f4f5fb;
  --code-inline-bg: #eef0fa;
  --primary: var(--indigo-600);
  --primary-ink: #ffffff;

  /* Accent (overridden per pillar) */
  --accent: var(--indigo-500);
  --accent-2: var(--violet);
  --accent-soft: #eef0fe;

  /* Geometry */
  --container: 1280px;
  --container-narrow: 1120px;
  --header-h: 66px;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(31, 36, 51, 0.06), 0 1px 3px rgba(31, 36, 51, 0.05);
  --shadow: 0 6px 20px rgba(31, 36, 51, 0.08);
  --shadow-lg: 0 18px 50px rgba(31, 36, 51, 0.14);
  --ring: 0 0 0 3px rgba(99, 102, 241, 0.35);

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

  --tr: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Per-pillar accents */
[data-pillar="apache-druid-segment-architecture-lifecycle-fundamentals"] {
  --accent: var(--indigo-500);
  --accent-2: var(--violet);
  --accent-soft: #eceefe;
}
[data-pillar="automated-ingestion-pipeline-orchestration"] {
  --accent: var(--cyan);
  --accent-2: #0891b2;
  --accent-soft: #e2f6fb;
}
[data-pillar="segment-compaction-retention-storage-optimization"] {
  --accent: var(--amber);
  --accent-2: #ea7a0c;
  --accent-soft: #fdf2dd;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: clamp(15px, 0.95rem + 0.1vw, 17px);
  line-height: 1.7;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-grad-1) 0%, var(--bg-grad-2) 240px) fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { max-width: 100%; }
svg { display: inline-block; vertical-align: middle; }

a { color: var(--accent-2); text-decoration: none; transition: color var(--tr); }
a:hover { color: var(--indigo-600); }

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(18px, 4vw, 48px);
}

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

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 200;
  background: var(--surface);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  transition: top var(--tr);
}
.skip-link:focus { top: 12px; }

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

/* ----------------------------------------------------------------- Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: var(--header-h);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-weight: 700;
}
.brand:hover { color: var(--text); }
.brand-logo { width: 38px; height: 38px; transition: transform var(--tr); filter: drop-shadow(0 3px 6px rgba(79,70,229,0.25)); }
.brand:hover .brand-logo { transform: rotate(-6deg) scale(1.05); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 1.02rem; letter-spacing: -0.01em; }
.brand-sub { font-size: 0.72rem; font-weight: 500; color: var(--muted); }

.primary-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.94rem;
  color: var(--text-soft);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--tr), color var(--tr), box-shadow var(--tr);
}
.nav-link:hover { background: var(--accent-soft); color: var(--indigo-600); }
.nav-link.is-active {
  color: var(--indigo-600);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.25);
}
.nav-icon { width: 18px; height: 18px; }
.nav-caret { width: 16px; height: 16px; transition: transform var(--tr); }
.has-menu { position: relative; }
.has-menu[data-open="true"] .nav-caret { transform: rotate(90deg); }

/* Mega menu */
.mega-menu {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: min(880px, 92vw);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px 22px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity var(--tr), transform var(--tr), visibility var(--tr);
}
.has-menu:hover .mega-menu,
.has-menu:focus-within .mega-menu,
.has-menu[data-open="true"] .mega-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.mega-col { padding: 6px; }
.mega-head {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border-bottom: 2px solid var(--accent);
  margin-bottom: 8px;
}
.mega-head:hover { color: var(--indigo-600); background: var(--accent-soft); }
.mega-head.is-active { color: var(--indigo-600); }
.mega-icon { width: 20px; height: 20px; color: var(--accent); }
.mega-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.mega-list a {
  display: block;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.86rem;
  color: var(--muted);
}
.mega-list a:hover, .mega-list a.is-active { background: var(--accent-soft); color: var(--indigo-600); }

.nav-toggle {
  display: none;
  margin-left: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
}
.nav-toggle .icon { width: 22px; height: 22px; }
.nav-toggle-close { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle-open { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle-close { display: inline-block; }

/* ------------------------------------------------------------------- Hero */
.hero { padding: clamp(40px, 7vw, 96px) 0 clamp(28px, 4vw, 56px); }
.hero-inner { text-align: center; display: flex; flex-direction: column; align-items: center; }
.hero-logo { margin-bottom: 26px; }
.hero-mark {
  width: clamp(96px, 14vw, 148px);
  height: clamp(96px, 14vw, 148px);
  filter: drop-shadow(0 16px 34px rgba(79, 70, 229, 0.32));
  transition: transform var(--tr);
}
.hero-logo:hover .hero-mark { transform: translateY(-4px) scale(1.03); }
.hero-title {
  font-size: clamp(2rem, 1.4rem + 2.7vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.025em;
  margin: 0 0 18px;
  max-width: 18ch;
  background: linear-gradient(120deg, var(--indigo-600), var(--violet) 55%, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-amp { -webkit-text-fill-color: var(--amber); color: var(--amber); }
.hero-lead {
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.3rem);
  color: var(--text-soft);
  font-weight: 500;
  max-width: 62ch;
  margin: 0 auto 18px;
}
.hero-text { color: var(--muted); max-width: 70ch; margin: 0 auto 14px; }

.hero-cta {
  margin-top: 30px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
}
.cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px 14px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 650;
  box-shadow: var(--shadow-sm);
  transition: transform var(--tr), box-shadow var(--tr), border-color var(--tr);
}
.cta-btn:hover {
  color: var(--text);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}
.cta-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 14px color-mix(in srgb, var(--accent) 40%, transparent);
}
.cta-icon { width: 24px; height: 24px; }
.cta-arrow { width: 18px; height: 18px; color: var(--muted); transition: transform var(--tr); }
.cta-btn:hover .cta-arrow { transform: translateX(4px); color: var(--accent); }
.cta-label { max-width: 22ch; text-align: left; }

/* Per-button accent on home (since body data-pillar is empty there) */
.cta-btn[data-pillar="apache-druid-segment-architecture-lifecycle-fundamentals"] { --accent: var(--indigo-500); --accent-2: var(--violet); }
.cta-btn[data-pillar="automated-ingestion-pipeline-orchestration"] { --accent: var(--cyan); --accent-2: #0891b2; }
.cta-btn[data-pillar="segment-compaction-retention-storage-optimization"] { --accent: var(--amber); --accent-2: #ea7a0c; }

/* --------------------------------------------------------------- Pillars */
.pillars { padding-block: clamp(28px, 5vw, 64px) clamp(48px, 6vw, 88px); }
.section-title {
  font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
  letter-spacing: -0.02em;
  margin: 0 0 10px;
}
.section-intro { color: var(--muted); max-width: 70ch; margin: 0 0 32px; }

.pillar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 24px;
}
.pillar-card {
  --accent: var(--indigo-500); --accent-2: var(--violet);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform var(--tr), box-shadow var(--tr), border-color var(--tr);
}
.pillar-card[data-pillar="automated-ingestion-pipeline-orchestration"] { --accent: var(--cyan); --accent-2: #0891b2; }
.pillar-card[data-pillar="segment-compaction-retention-storage-optimization"] { --accent: var(--amber); --accent-2: #ea7a0c; }
.pillar-card::before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.pillar-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--accent); }
.pillar-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.pillar-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; border-radius: 13px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 14px color-mix(in srgb, var(--accent) 38%, transparent);
}
.pillar-name { font-weight: 750; font-size: 1.08rem; color: var(--text); letter-spacing: -0.01em; }
.pillar-desc { color: var(--muted); font-size: 0.92rem; margin: 0 0 16px; }
.pillar-links { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.pillar-links a { display: flex; align-items: center; gap: 6px; color: var(--text-soft); font-size: 0.92rem; padding: 4px 0; }
.pillar-links a:hover { color: var(--accent-2); }
.li-caret { width: 15px; height: 15px; color: var(--accent); flex: none; }
.pillar-more { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; color: var(--accent-2); }
.inline-arrow { width: 17px; height: 17px; transition: transform var(--tr); }
.inline-arrow.flip { transform: rotate(180deg); }
.pillar-more:hover .inline-arrow { transform: translateX(4px); }

/* --------------------------------------------------------- Page layout */
.page-layout { padding-block: 26px 64px; }

.breadcrumbs { margin-bottom: 20px; font-size: 0.85rem; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; padding: 0; }
.breadcrumbs li { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.breadcrumbs li + li::before { content: "›"; color: var(--border-strong); margin-right: 2px; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--accent-2); }
.breadcrumbs [aria-current="page"] { color: var(--text); font-weight: 600; }

/* ----------------------------------------------------------------- Prose */
.prose {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(24px, 3.4vw, 56px);
  box-shadow: var(--shadow-sm);
  max-width: none;          /* use full container width on desktop */
}
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }

.prose h1 {
  font-size: clamp(1.8rem, 1.4rem + 1.6vw, 2.7rem);
  line-height: 1.12;
  letter-spacing: -0.025em;
  margin: 0 0 0.7em;
  background: linear-gradient(120deg, var(--accent-2), var(--accent) 70%, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.prose h2 {
  font-size: clamp(1.35rem, 1.1rem + 0.9vw, 1.8rem);
  letter-spacing: -0.015em;
  margin: 1.9em 0 0.6em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.prose h3 { font-size: 1.28rem; margin: 1.6em 0 0.5em; color: var(--text); }
.prose h4 { font-size: 1.08rem; margin: 1.4em 0 0.4em; color: var(--text-soft); }
/* Anchor offset is handled globally by html { scroll-padding-top } so the
   sticky header never covers a linked heading. (Do NOT also set
   scroll-margin-top here — the two offsets would stack.) */
.prose h2, .prose h3, .prose h4 { position: relative; }

.prose p { margin: 0 0 1.15em; color: var(--text-soft); }
.prose ul, .prose ol { margin: 0 0 1.2em; padding-left: 1.4em; color: var(--text-soft); }
.prose li { margin: 0.35em 0; }
.prose li::marker { color: var(--accent); }

.prose a {
  color: var(--accent-2);
  font-weight: 550;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-underline-offset: 2px;
  transition: color var(--tr), text-decoration-color var(--tr), background var(--tr);
  border-radius: 3px;
}
.prose a:hover {
  color: var(--indigo-600);
  text-decoration-color: var(--accent);
  background: var(--accent-soft);
}

.prose blockquote {
  margin: 1.4em 0;
  padding: 0.6em 1.2em;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-soft);
}
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2.2em 0; }

.prose strong { color: var(--text); font-weight: 700; }

/* Heading anchor link */
.header-anchor {
  opacity: 0;
  margin-left: 0.4em;
  color: var(--accent);
  font-weight: 400;
  text-decoration: none;
  transition: opacity var(--tr);
}
.prose h2:hover .header-anchor,
.prose h3:hover .header-anchor,
.prose h4:hover .header-anchor { opacity: 0.8; }

/* Inline code — subtle, borderless, blends with text */
.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-inline-bg);
  color: #4338ca;
  padding: 0.12em 0.42em;
  border-radius: 6px;
  white-space: break-spaces;
}
[data-pillar="automated-ingestion-pipeline-orchestration"] .prose :not(pre) > code { color: #0e7490; }
[data-pillar="segment-compaction-retention-storage-optimization"] .prose :not(pre) > code { color: #b45309; }

/* Code blocks */
.code-wrap { position: relative; margin: 1.4em 0; }
.prose pre[class*="language-"] {
  margin: 0;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px;
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.6;
  tab-size: 2;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}
.prose pre[class*="language-"] code { font-family: var(--font-mono); background: none; padding: 0; color: #2d3350; }

/* Copy button */
.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  font-size: 0.74rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--tr), color var(--tr), border-color var(--tr), background var(--tr);
}
.code-wrap:hover .copy-btn,
.copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--indigo-600); border-color: var(--accent); }
.copy-btn .icon { width: 15px; height: 15px; }
.copy-btn.copied { color: var(--emerald); border-color: var(--emerald); }
@media (hover: none) { .copy-btn { opacity: 1; } }

/* Prism token colors tuned to the light scheme */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #8a93a8; font-style: italic; }
.token.punctuation { color: #6b7390; }
.token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol { color: #b4337a; }
.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted { color: #0e8a6b; }
.token.operator, .token.entity, .token.url, .language-css .token.string, .style .token.string { color: #b25f00; }
.token.atrule, .token.attr-value, .token.keyword { color: #5b4ddb; }
.token.function, .token.class-name { color: #6d28d9; }
.token.regex, .token.important, .token.variable { color: #d4561d; }

/* Tables */
.table-scroll {
  margin: 1.4em 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  -webkit-overflow-scrolling: touch;
}
.prose table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.prose th, .prose td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose thead th {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
  position: sticky; top: 0;
}
.prose tbody tr:nth-child(even) { background: var(--surface-2); }
.prose tbody tr:hover { background: var(--accent-soft); }
.prose td code { white-space: nowrap; }

/* Task-list checkboxes — no bullet, line-through when checked */
.prose ul.contains-task-list { list-style: none; padding-left: 0.4em; }
.prose ul.contains-task-list .contains-task-list { padding-left: 1.4em; }
.prose li.task-list-item { display: flex; align-items: flex-start; gap: 10px; list-style: none; }
.prose li.task-list-item::marker { content: none; }
.prose li.task-list-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 3px;
  border: 2px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  transition: background var(--tr), border-color var(--tr);
}
.prose li.task-list-item input[type="checkbox"]:hover { border-color: var(--accent); }
.prose li.task-list-item input[type="checkbox"]:checked {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}
.prose li.task-list-item input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 6px; top: 2px;
  width: 5px; height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.prose li.task-list-item.is-checked > label,
.prose li.task-list-item input[type="checkbox"]:checked ~ label { text-decoration: line-through; color: var(--muted); }

/* FAQ accordions */
.accordion { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 1.4em 0; background: var(--surface); }
.accordion + .accordion { margin-top: -0.6em; border-top-left-radius: 0; border-top-right-radius: 0; }
.accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: none;
  border: 0;
  font: inherit;
  font-weight: 650;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}
.accordion-trigger:hover { background: var(--accent-soft); }
.accordion-trigger .acc-caret { width: 20px; height: 20px; color: var(--accent); transition: transform var(--tr); flex: none; }
.accordion[open] .accordion-trigger .acc-caret,
.accordion-trigger[aria-expanded="true"] .acc-caret { transform: rotate(90deg); }
.accordion-panel { padding: 0 18px; max-height: 0; overflow: hidden; transition: max-height var(--tr), padding var(--tr); }
.accordion-panel.open { padding: 0 18px 16px; }

/* KaTeX */
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 6px 0; }

/* Mermaid diagrams (visualizations) */
.prose .mermaid {
  position: relative;
  margin: 1.6em 0;
  padding: 18px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
/* Hide the raw diagram source until Mermaid has rendered the SVG. */
.prose .mermaid:not([data-processed]) { color: transparent; min-height: 120px; }
.prose .mermaid svg { max-width: 100%; height: auto; }
.prose .mermaid.viz {
  cursor: zoom-in;
  transition: box-shadow var(--tr), border-color var(--tr), transform var(--tr);
}
.prose .mermaid.viz:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.prose .mermaid.viz:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.viz-expand {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: zoom-in;
  opacity: 0;
  transition: opacity var(--tr), color var(--tr), border-color var(--tr);
}
.viz-expand .icon { width: 15px; height: 15px; }
.mermaid.viz:hover .viz-expand,
.mermaid.viz:focus-within .viz-expand { opacity: 1; }
.viz-expand:hover { color: var(--indigo-600); border-color: var(--accent); }
@media (hover: none) { .viz-expand { opacity: 1; } }

/* Full-screen diagram lightbox */
.viz-lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 56px);
  background: rgba(15, 18, 33, 0.78);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.viz-lightbox.open { display: flex; animation: viz-fade 160ms ease; }
@keyframes viz-fade { from { opacity: 0; } to { opacity: 1; } }
.viz-lightbox-canvas {
  width: min(96vw, 1500px);
  height: 88vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 3vw, 40px);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: auto;
}
.viz-lightbox-canvas svg { display: block; }
.viz-lightbox-close {
  position: absolute;
  top: clamp(12px, 2vw, 24px);
  right: clamp(12px, 2vw, 24px);
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--tr);
}
.viz-lightbox-close:hover { background: rgba(255, 255, 255, 0.28); }
.viz-lightbox-close .icon { width: 22px; height: 22px; }

/* Related / cards */
.related { margin-top: 40px; }
.related-title { font-size: 1.3rem; letter-spacing: -0.015em; margin: 0 0 18px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  transition: transform var(--tr), box-shadow var(--tr), border-color var(--tr);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--accent); color: var(--text); }
.card-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; flex: none; border-radius: 11px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.card-body { display: flex; flex-direction: column; gap: 3px; }
.card-title { font-weight: 650; line-height: 1.25; }
.card-link { font-size: 0.82rem; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.card:hover .card-link { color: var(--accent-2); }

.back-to-section { margin-top: 28px; }
.back-to-section a { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; color: var(--accent-2); }

/* ----------------------------------------------------------------- Footer */
.site-footer { flex-shrink: 0; margin-top: auto; background: #161a2b; color: #c9d0e3; }
.footer-inner { display: grid; grid-template-columns: minmax(220px, 1fr) 2.4fr; gap: 40px; padding-block: 52px 36px; }
.footer-logo { width: 48px; height: 48px; margin-bottom: 14px; }
.footer-tagline { color: #97a1bd; font-size: 0.9rem; max-width: 36ch; margin: 0; }
.footer-nav { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
.footer-head { display: flex; align-items: center; gap: 9px; font-weight: 700; color: #fff; margin-bottom: 12px; font-size: 0.92rem; }
.footer-head:hover { color: var(--cyan-400); }
.footer-icon { width: 19px; height: 19px; color: var(--cyan-400); }
.footer-col[data-pillar="apache-druid-segment-architecture-lifecycle-fundamentals"] .footer-icon { color: #a5b4fc; }
.footer-col[data-pillar="segment-compaction-retention-storage-optimization"] .footer-icon { color: var(--amber-400); }
.footer-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.footer-nav li a { color: #9aa4c0; font-size: 0.86rem; }
.footer-nav li a:hover { color: #fff; }
.footer-bottom { border-top: 1px solid rgba(255, 255, 255, 0.08); padding: 18px 0; }
.footer-bottom p { margin: 0; font-size: 0.8rem; color: #7e88a6; }

/* ----------------------------------------------------------- Responsive */
@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .primary-nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 16px clamp(18px, 4vw, 48px) 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateY(-120%);
    transition: transform var(--tr);
    max-height: calc(100vh - var(--header-h));
    overflow-y: auto;
  }
  .primary-nav.open { transform: translateY(0); }
  .nav-link { justify-content: flex-start; }
  .mega-menu {
    position: static;
    width: auto;
    grid-template-columns: 1fr;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: 0;
    padding: 6px 0 0;
    display: none;
  }
  .has-menu[data-open="true"] .mega-menu { display: grid; }
  .footer-inner { grid-template-columns: 1fr; gap: 28px; }
  .footer-nav { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .cta-btn { width: 100%; }
  .hero-cta { flex-direction: column; align-items: stretch; }
}

/* Widescreen — let the layout breathe */
@media (min-width: 1600px) {
  :root { --container: 1440px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
