/* ============================================================
   MindMerge — shared design system
   Self-hosted system fonts only (no external CDN, no web fonts)
   ============================================================ */

:root {
  /* Palette — deep space with a "merge of colours" accent triad */
  --bg:        #08080f;
  --bg-2:      #0d0d1a;
  --surface:   rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.06);
  --border:    rgba(255, 255, 255, 0.10);
  --border-2:  rgba(255, 255, 255, 0.16);

  --text:      #ecebf5;
  --muted:     #a2a1bd;
  --faint:     #8a89a6; /* lifted to clear WCAG AA (>=4.5:1) where used as text */

  --violet:    #8b5cff;
  --cyan:      #29d3ee;
  --pink:      #ff5c9d;
  --amber:     #ffb454;
  --green:     #46e5a0;

  --accent:    var(--violet);
  --grad: linear-gradient(100deg, var(--violet) 0%, var(--cyan) 55%, var(--pink) 100%);

  --radius:    18px;
  --radius-sm: 11px;
  --maxw:      1120px;
  --readw:     min(720px, 92vw);

  --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.8);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
          Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
          "Liberation Mono", monospace;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  font-size: clamp(16px, 1rem + 0.2vw, 18px);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Ambient background glow, sits behind everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60% 50% at 18% 0%, rgba(139, 92, 255, 0.20), transparent 60%),
    radial-gradient(55% 45% at 88% 12%, rgba(41, 211, 238, 0.16), transparent 60%),
    radial-gradient(50% 40% at 60% 100%, rgba(255, 92, 157, 0.12), transparent 60%),
    var(--bg);
}

a { color: inherit; text-decoration: none; }

.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: 24px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  background: rgba(8, 8, 15, 0.62);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 68px;
}
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 700; letter-spacing: -0.02em; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand b {
  font-size: 1.15rem;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.nav { display: flex; align-items: center; gap: 8px; }
.nav a {
  color: var(--muted); font-size: 0.95rem; font-weight: 500;
  padding: 8px 12px; border-radius: 10px; transition: color .18s ease, background .18s ease;
}
.nav a:hover { color: var(--text); background: var(--surface); }

/* Mobile hamburger — top-right disclosure, JS-free via <details> */
.nav-menu { display: none; position: relative; }
.nav-toggle {
  list-style: none; cursor: pointer;
  width: 42px; height: 42px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border-2); color: var(--text);
}
.nav-toggle::-webkit-details-marker { display: none; }
.nav-toggle svg { width: 20px; height: 20px; }
.nav-menu[open] .nav-toggle { background: var(--surface-2); }
.nav-drawer {
  position: absolute; top: calc(100% + 12px); right: 0; z-index: 60;
  min-width: 210px; display: flex; flex-direction: column; gap: 2px;
  background: rgba(13, 13, 26, 0.97);
  backdrop-filter: saturate(150%) blur(16px);
  -webkit-backdrop-filter: saturate(150%) blur(16px);
  border: 1px solid var(--border-2); border-radius: 14px; padding: 8px;
  box-shadow: var(--shadow);
}
.nav-drawer a { color: var(--text); font-size: 0.98rem; font-weight: 500; padding: 11px 14px; border-radius: 9px; }
.nav-drawer a:hover { background: var(--surface); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  font: inherit; font-weight: 600; font-size: 0.98rem;
  padding: 12px 20px; border-radius: 999px; border: 1px solid transparent;
  cursor: pointer; transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary {
  color: #0a0a12; background: var(--grad);
  box-shadow: 0 10px 30px -10px rgba(139, 92, 255, 0.7);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 40px -12px rgba(139, 92, 255, 0.8); }
.btn-ghost { color: var(--text); background: var(--surface); border-color: var(--border-2); }
.btn-ghost:hover { background: var(--surface-2); transform: translateY(-2px); }

@media (prefers-reduced-motion: reduce) {
  .btn:hover { transform: none; }
}

/* ---------- Hero ---------- */
.hero { position: relative; padding: 92px 0 40px; }
.hero-grid {
  display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 48px; align-items: center;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); background: var(--surface); border: 1px solid var(--border);
  padding: 6px 13px; border-radius: 999px; margin-bottom: 22px;
}
.eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.hero h1 {
  margin: 0 0 18px; font-size: clamp(2.6rem, 5.2vw, 4.2rem);
  line-height: 1.02; letter-spacing: -0.035em; font-weight: 800;
}
.hero h1 .accent {
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p.lead { margin: 0 0 30px; font-size: clamp(1.05rem, 1rem + 0.5vw, 1.28rem); color: var(--muted); max-width: 34ch; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 14px; }
.hero-figure { position: relative; }
.hero-figure svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 30px 60px rgba(0,0,0,0.55)); }

/* ---------- Section headings ---------- */
.section { padding: 56px 0; }
.section-lead { padding-top: 46px; }
.section-head { max-width: 660px; margin-bottom: 36px; }
.section-head .kicker {
  font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--cyan);
}
.section-head :is(h1, h2) { margin: 10px 0 12px; font-size: clamp(1.7rem, 1.4rem + 1.4vw, 2.5rem); letter-spacing: -0.025em; line-height: 1.1; }
.section-head p { margin: 0; color: var(--muted); }
.section-head .lib-stat { margin-top: 14px; font-family: var(--mono); font-size: 0.82rem; color: var(--faint); }
.section-head .lib-stat strong { color: var(--cyan); font-weight: 600; }

/* ---------- Breadcrumbs ---------- */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; font-family: var(--mono); font-size: 0.8rem; color: var(--muted); margin-bottom: 22px; }
.crumbs a { color: var(--muted); transition: color .15s ease; }
.crumbs a:hover { color: var(--text); }
.crumbs .sep { color: var(--faint); }
.crumbs [aria-current] { color: var(--text); }
.article .crumbs { max-width: var(--readw); margin-inline: auto; }

/* ---------- Content cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 26px; overflow: hidden;
  transition: transform .2s ease, border-color .2s ease, background .2s ease;
}
.card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(120deg, transparent, rgba(139,92,255,0.0));
}
.card.feature { border-color: var(--border-2); }
.card-badge {
  align-self: flex-start; font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--violet); background: rgba(139,92,255,0.12);
  border: 1px solid rgba(139,92,255,0.28); padding: 5px 10px; border-radius: 999px; margin-bottom: 16px;
}
.card h3 { margin: 0 0 10px; font-size: 1.28rem; letter-spacing: -0.01em; }
.card p { margin: 0 0 18px; color: var(--muted); font-size: 0.97rem; }
.card .card-link { margin-top: auto; display: inline-flex; align-items: center; gap: 7px; color: var(--text); font-weight: 600; font-size: 0.95rem; }
.card .card-link svg { width: 16px; height: 16px; transition: transform .18s ease; }
.card:hover { transform: translateY(-4px); border-color: var(--border-2); background: var(--surface-2); }
.card:hover .card-link svg { transform: translateX(4px); }
.card.soon { opacity: 0.8; }
.card.soon .card-badge { color: var(--faint); background: var(--surface); border-color: var(--border); }
.lib-more { margin-top: 30px; display: flex; justify-content: center; }

/* Grouped topics on the library hub */
.topic-group + .topic-group { margin-top: 46px; }
.group-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; padding-bottom: 13px; border-bottom: 1px solid var(--border); }
.group-head h2 { margin: 0; font-size: 1.32rem; letter-spacing: -0.02em; }
.group-head p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.card.concept { border-color: rgba(255, 180, 84, 0.28); }
.card.concept .card-badge { color: var(--amber); background: rgba(255, 180, 84, 0.10); border-color: rgba(255, 180, 84, 0.28); }

@media (prefers-reduced-motion: reduce) {
  .card:hover { transform: none; }
  .card:hover .card-link svg { transform: none; }
}

/* small feature list */
.mini-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; margin-top: 8px; }
.mini { display: flex; gap: 13px; align-items: flex-start; }
.mini .ic { flex: none; width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); }
.mini .ic svg { width: 19px; height: 19px; }
.mini h2 { margin: 2px 0 4px; font-size: 1rem; line-height: 1.3; font-weight: 700; }
.mini p { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 40px; padding: 34px 0; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; }
.site-footer p { margin: 0; color: var(--faint); font-size: 0.9rem; }
.site-footer .brand b { font-size: 1rem; }

/* ---------- Focus visibility (a11y) ---------- */
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 4px; }

/* =========================================================
   ARTICLE / LONG-FORM STYLES
   ========================================================= */
.article { padding: 56px 0 24px; }
.article-wrap { max-width: var(--readw); margin-inline: auto; }
.article-hero { max-width: var(--readw); margin: 0 auto 40px; }
.article-hero .kicker { font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--cyan); }
.article-hero h1 { margin: 12px 0 14px; font-size: clamp(2rem, 1.5rem + 2.4vw, 3.1rem); letter-spacing: -0.03em; line-height: 1.06; }
.article-hero .subtitle { color: var(--muted); font-size: 1.12rem; margin: 0; }
.article-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.chip { font-family: var(--mono); font-size: 0.76rem; color: var(--muted); background: var(--surface); border: 1px solid var(--border); padding: 5px 11px; border-radius: 999px; }

/* Table of contents */
.toc {
  max-width: var(--readw); margin: 0 auto 44px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 26px;
}
.toc h2 { margin: 0 0 12px; font-size: 0.82rem; font-family: var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.toc ol { margin: 0; padding-left: 1.2em; columns: 2; column-gap: 34px; }
.toc li { margin: 5px 0; break-inside: avoid; }
.toc a { color: var(--muted); border-bottom: 1px solid transparent; transition: color .15s, border-color .15s; }
.toc a:hover { color: var(--text); border-color: var(--border-2); }

.prose { color: var(--text); }
.prose > * { max-width: var(--readw); margin-inline: auto; }
.prose h2 {
  margin: 56px auto 16px; font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  letter-spacing: -0.02em; line-height: 1.15; scroll-margin-top: 90px;
  padding-top: 14px; border-top: 1px solid var(--border);
}
.prose h3 { margin: 34px auto 10px; font-size: 1.25rem; letter-spacing: -0.01em; scroll-margin-top: 90px; }
.prose p { margin: 0 auto 18px; color: #d7d6e8; }
.prose ul, .prose ol { margin: 0 auto 20px; padding-left: 1.4em; color: #d7d6e8; }
.prose li { margin: 8px 0; }
.prose li::marker { color: var(--violet); }
.prose strong { color: #fff; font-weight: 650; }
.prose a.inline { color: var(--cyan); border-bottom: 1px solid rgba(41,211,238,0.4); }
.prose a.inline:hover { border-color: var(--cyan); }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 44px auto; }

/* Inline + block code */
.prose code {
  font-family: var(--mono); font-size: 0.88em;
  background: rgba(139,92,255,0.12); border: 1px solid rgba(139,92,255,0.2);
  padding: 0.12em 0.42em; border-radius: 6px; color: #e5defc;
}
.prose pre {
  position: relative; margin: 0 auto 22px; padding: 18px 20px; overflow-x: auto;
  background: #0b0b16; border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 0.86rem; line-height: 1.7;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
.prose pre code { background: none; border: none; padding: 0; color: #cfd8e6; font-size: inherit; }
.prose pre .cmt { color: var(--faint); }
.prose pre .cmd { color: var(--cyan); }
.prose pre .flag { color: var(--amber); }
.prose pre .str { color: var(--green); }
.prose pre .out { color: var(--faint); }

/* Callouts */
.callout {
  max-width: var(--readw); margin: 26px auto; padding: 18px 20px 18px 20px;
  border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--radius-sm);
  background: var(--surface); display: flex; gap: 14px; align-items: flex-start;
}
.callout .ico { flex: none; width: 24px; height: 24px; margin-top: 2px; }
.callout .ico svg { width: 24px; height: 24px; }
.callout p { margin: 0 0 6px; }
.callout p:last-child { margin-bottom: 0; }
.callout .label { font-weight: 700; letter-spacing: 0.01em; }
.callout.tip    { border-left-color: var(--green); }
.callout.warn   { border-left-color: var(--amber); }
.callout.danger { border-left-color: var(--pink); }
.callout.info   { border-left-color: var(--cyan); }
.callout.tip    .label { color: var(--green); }
.callout.warn   .label { color: var(--amber); }
.callout.danger .label { color: var(--pink); }
.callout.info   .label { color: var(--cyan); }

/* Comparison / analogy tables */
.table-scroll { max-width: var(--readw); margin: 0 auto 24px; overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.grid th, table.grid td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.grid th { color: var(--muted); font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 600; }
table.grid td code { font-size: 0.86em; }
table.grid tr:last-child td { border-bottom: none; }

/* Stage flow diagram (pure HTML/CSS) */
.stage-flow { max-width: var(--readw); margin: 8px auto 26px; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stage {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px; position: relative;
}
.stage .env { font-family: var(--mono); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--cyan); }
.stage h4 { margin: 6px 0 4px; font-size: 1.02rem; }
.stage p { margin: 0; color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
.stage .branch { margin-top: 10px; font-family: var(--mono); font-size: 0.78rem; color: var(--violet); }

/* Back-to-top / prev-next nav */
.article-nav { max-width: var(--readw); margin: 40px auto 0; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; gap: 30px; }
  .hero-figure { order: -1; max-width: 460px; }
  .hero { padding-top: 56px; }
  .toc ol { columns: 1; }
}
@media (max-width: 600px) {
  .nav { display: none; }
  .nav-menu { display: block; }
}
@media (max-width: 520px) {
  .wrap { padding-inline: 18px; }
  .hero-cta { flex-direction: column; align-items: stretch; }
  .hero-cta .btn { justify-content: center; }
}
