/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

  --color-bg: #ffffff;
  --color-surface: #faf9f7;
  --color-text: #1a1a1a;
  --color-text-secondary: #52525b;
  --color-text-tertiary: #8a8a92;
  --color-border: #e4e4e7;
  --color-border-strong: #d4d4d8;

  --color-accent: #4338ca;
  --color-accent-hover: #33288f;
  --color-accent-soft: #eeecfd;
  --color-accent-soft-border: #d6d1f7;

  --color-warn-soft: #fdf2e3;
  --color-warn-border: #eec27f;
  --color-warn-text: #7c4a03;

  --color-code-bg: #1b1a27;
  --color-code-text: #e6e4f5;
  --color-code-border: #322f47;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(26,26,26,0.07);
  --shadow-md: 0 8px 24px rgba(26,26,26,0.09), 0 2px 6px rgba(26,26,26,0.06);
  --shadow-lg: 0 24px 48px rgba(26,26,26,0.16);

  --max-prose: 700px;
  --max-wide: 1000px;

  --header-h: 56px;
}

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

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--color-accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--color-accent-hover); }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; border-radius: 3px; }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; color: var(--color-text); margin: 0; }

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

/* ============================================================
   PROGRESS BAR + HEADER
   ============================================================ */
#reading-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0%;
  background: linear-gradient(90deg, #6d28d9, #4338ca);
  z-index: 1000; transition: width 80ms linear;
}

.site-header {
  position: sticky; top: 0; z-index: 900;
  height: var(--header-h);
  display: flex; align-items: center;
  padding: 0 24px;
  background: rgba(255,255,255,0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border);
}
.site-header .wrap {
  width: 100%; max-width: var(--max-wide); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
}
.logo {
  font-family: var(--font-display); font-weight: 700; font-size: 1.15rem;
  letter-spacing: -0.01em; color: var(--color-text); text-decoration: none;
  display: flex; align-items: center; gap: 8px;
}
.logo .mark {
  width: 22px; height: 22px; border-radius: 5px;
  background: linear-gradient(135deg, #6d28d9, #4338ca);
  flex-shrink: 0;
}
.header-tag {
  font-size: 0.8rem; color: var(--color-text-tertiary); font-weight: 500;
}
@media (max-width: 620px) { .header-tag { display: none; } }

/* ============================================================
   HERO
   ============================================================ */
.hero {
  position: relative;
  background: radial-gradient(circle at 15% 15%, #7c3aed 0%, transparent 45%),
              linear-gradient(155deg, #1e1b4b 0%, #3730a3 45%, #4338ca 78%, #6d28d9 100%);
  color: #f5f4ff;
  padding: 64px 24px 40px;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.08) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: 0.5;
  pointer-events: none;
}
.hero .wrap { position: relative; max-width: var(--max-prose); margin: 0 auto; }
.eyebrow-pill {
  display: inline-block;
  font-size: 0.8rem; font-weight: 600;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.28);
  color: #ede9fe;
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 20px;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-bottom: 18px;
  max-width: 15ch;
}
.hero .subtitle {
  font-family: var(--font-body);
  font-size: 1.15rem;
  font-weight: 400;
  color: #ded9ff;
  max-width: 56ch;
  line-height: 1.55;
  margin-bottom: 32px;
}
.hero-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 18px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.22);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}
.author-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #fbbf24, #f472b6);
  color: #1a1a1a; font-weight: 700; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.author-chip .name { font-weight: 600; font-size: 0.92rem; color: #fff; line-height: 1.25; }
.author-chip .role { font-size: 0.78rem; color: #cabffb; }
.meta-divider { width: 1px; height: 28px; background: rgba(255,255,255,0.25); }
.hero-meta .meta-item { font-size: 0.85rem; color: #dcd6fb; }
.hero-meta .meta-item strong { display: block; color: #fff; font-size: 0.9rem; font-weight: 600; }

/* ============================================================
   LAYOUT / ARTICLE PROSE
   ============================================================ */
main { display: block; }
.prose-wrap { max-width: var(--max-prose); margin: 0 auto; padding: 0 24px; }
.wide-wrap { max-width: var(--max-wide); margin: 0 auto; padding: 0 24px; }

.lede {
  font-size: 1.15rem;
  color: var(--color-text-secondary);
  margin: 40px 0 28px;
  line-height: 1.6;
}

.takeaways {
  background: var(--color-accent-soft);
  border: 1px solid var(--color-accent-soft-border);
  border-radius: var(--radius-md);
  padding: 22px 24px 24px;
  margin: 0 0 40px;
}
.takeaways h2 {
  font-size: 1.05rem; font-family: var(--font-body); font-weight: 700;
  margin-bottom: 12px; color: #2e2470;
}
.takeaways ul { margin: 0; padding-left: 20px; }
.takeaways li { margin-bottom: 7px; color: #3a3470; font-size: 0.96rem; }
.takeaways li:last-child { margin-bottom: 0; }

/* Table of contents */
.toc {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 22px 24px 24px;
  margin-bottom: 48px;
}
.toc h2 {
  font-size: 0.78rem; text-transform: none; letter-spacing: 0.01em;
  font-family: var(--font-body); font-weight: 700; color: var(--color-text-tertiary);
  margin-bottom: 12px;
}
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc-counter; }
.toc > ol > li { counter-increment: toc-counter; margin-bottom: 4px; }
.toc a {
  display: block; text-decoration: none; color: var(--color-text);
  font-size: 0.97rem; font-weight: 500; padding: 7px 8px 7px 0;
  border-left: 2px solid transparent; padding-left: 12px;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
  border-radius: 4px;
}
.toc a::before {
  content: counter(toc-counter) ".";
  color: var(--color-accent); font-weight: 600; margin-right: 8px; font-variant-numeric: tabular-nums;
}
.toc a:hover, .toc a.active { border-left-color: var(--color-accent); background: var(--color-accent-soft); color: var(--color-accent-hover); }
.toc ul { list-style: none; margin: 2px 0 6px 20px; padding: 0; }
.toc ul a { font-size: 0.89rem; font-weight: 400; color: var(--color-text-secondary); }
.toc ul a::before { content: "–"; margin-right: 8px; color: var(--color-text-tertiary); }

/* Article sections */
.article-section { padding-top: 8px; scroll-margin-top: calc(var(--header-h) + 16px); }
.article-section h2 { font-size: clamp(1.5rem, 3.4vw, 1.9rem); margin: 56px 0 8px; scroll-margin-top: calc(var(--header-h) + 16px); }
.article-section h3 { font-size: 1.28rem; margin: 34px 0 12px; scroll-margin-top: calc(var(--header-h) + 16px); }
.article-section h4 { font-size: 1.05rem; margin: 24px 0 10px; color: var(--color-accent-hover); scroll-margin-top: calc(var(--header-h) + 16px); }
.article-section p { margin: 0 0 16px; color: var(--color-text); }
.article-section ul, .article-section ol { margin: 0 0 18px; padding-left: 22px; }
.article-section li { margin-bottom: 8px; }
.article-section strong { font-weight: 600; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.copy-link-btn {
  font-family: var(--font-body); font-size: 0.78rem; font-weight: 600;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 6px 13px 6px 11px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
  margin-top: 56px;
}
.copy-link-btn svg { width: 13px; height: 13px; }
.copy-link-btn:hover { background: var(--color-accent-soft); border-color: var(--color-accent-soft-border); color: var(--color-accent-hover); }
.copy-link-btn:active { transform: translateY(1px); }
.copy-link-btn[data-copied="true"] { background: #e9f7ee; border-color: #b9e6c8; color: #146c34; }

/* Pull quote */
blockquote.pull-quote {
  margin: 32px 0; padding: 4px 0 4px 24px;
  border-left: 3px solid var(--color-accent);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.35rem;
  line-height: 1.45;
  color: #2b235c;
}
blockquote.pull-quote cite {
  display: block; margin-top: 12px; font-family: var(--font-body);
  font-style: normal; font-size: 0.85rem; font-weight: 600; color: var(--color-text-tertiary);
}

/* Diagram figure */
.diagram-figure {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin: 28px 0 32px;
  box-shadow: var(--shadow-sm);
}
.diagram-figure figcaption {
  margin-top: 14px; font-size: 0.85rem; color: var(--color-text-tertiary); text-align: center;
}

/* Comparison table - full bleed */
.table-scroll {
  overflow-x: auto;
  margin: 8px 0 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.wide-wrap.table-wrap { margin: 24px auto 12px; }
table.compare {
  width: 100%; border-collapse: collapse; min-width: 720px;
  font-size: 0.92rem;
}
table.compare caption { text-align: left; padding: 14px 18px 0; font-weight: 600; font-size: 0.95rem; }
table.compare th, table.compare td {
  padding: 13px 18px; text-align: left; border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}
table.compare thead th {
  background: var(--color-surface);
  font-family: var(--font-body); font-weight: 700; font-size: 0.82rem;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border-strong);
}
table.compare tbody th {
  font-weight: 600; white-space: nowrap; color: var(--color-text-secondary); font-size: 0.85rem;
}
table.compare tbody tr:last-child td, table.compare tbody tr:last-child th { border-bottom: none; }
table.compare tbody tr:hover { background: #fbfaff; }
.table-caption-note { font-size: 0.83rem; color: var(--color-text-tertiary); margin: 8px 0 32px; }

/* Code blocks */
.code-card {
  background: var(--color-code-bg);
  border: 1px solid var(--color-code-border);
  border-radius: var(--radius-md);
  margin: 20px 0 28px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: transform 180ms ease, box-shadow 180ms ease;
}
.code-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.code-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--color-code-border);
  font-family: var(--font-mono); font-size: 0.78rem; color: #a7a3c9;
}
.code-card pre {
  margin: 0; padding: 18px 20px; overflow-x: auto;
  font-family: var(--font-mono); font-size: 0.85rem; line-height: 1.65;
  color: var(--color-code-text);
}
.tok-key { color: #93c5fd; }
.tok-str { color: #86efac; }
.tok-num { color: #fca5a5; }
.tok-com { color: #6f6b8f; font-style: italic; }
.tok-punc { color: #8a86ad; }

/* Callout - case study */
.callout {
  background: var(--color-warn-soft);
  border: 1px solid var(--color-warn-border);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  margin: 24px 0 28px;
}
.callout .callout-label {
  font-size: 0.75rem; font-weight: 700; color: var(--color-warn-text);
  margin-bottom: 8px; display: block;
}
.callout p:last-child { margin-bottom: 0; }

/* OpSec checklist grid */
.checklist-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
  margin: 28px 0 12px;
}
@media (max-width: 860px) { .checklist-grid { grid-template-columns: 1fr; } }
.checklist-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px 20px 22px;
  transition: box-shadow 180ms ease, transform 180ms ease;
}
.checklist-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.checklist-card h3 { font-size: 1.05rem; margin: 0 0 4px; }
.checklist-card .card-sub { font-size: 0.82rem; color: var(--color-text-tertiary); margin-bottom: 14px; }
.checklist-card ul { list-style: none; margin: 0; padding: 0; }
.checklist-card li {
  position: relative; padding-left: 26px; margin-bottom: 11px;
  font-size: 0.9rem; color: var(--color-text); line-height: 1.5;
}
.checklist-card li::before {
  content: ""; position: absolute; left: 0; top: 3px; width: 16px; height: 16px;
  border-radius: 5px; border: 1.5px solid var(--color-accent);
  background: var(--color-accent-soft);
}
.checklist-card li::after {
  content: ""; position: absolute; left: 4px; top: 6px; width: 8px; height: 4.5px;
  border-left: 1.5px solid var(--color-accent); border-bottom: 1.5px solid var(--color-accent);
  transform: rotate(-45deg);
}

/* Further reading */
.reading-list {
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: 28px 0 32px;
  margin: 48px 0;
}
.reading-list h2 { font-size: 1.05rem; font-family: var(--font-body); font-weight: 700; margin-bottom: 14px; }
.reading-list ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.reading-list a {
  display: flex; align-items: baseline; gap: 8px; font-size: 0.94rem; font-weight: 500;
  text-decoration: none; padding: 4px 0;
}
.reading-list a .src { color: var(--color-text-tertiary); font-weight: 400; font-size: 0.85rem; }

/* Author bio */
.author-bio {
  display: flex; gap: 16px; align-items: flex-start;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px; margin: 40px 0;
}
.author-bio .avatar { width: 52px; height: 52px; font-size: 1.05rem; }
.author-bio h2 { font-size: 1rem; font-family: var(--font-body); font-weight: 700; margin-bottom: 2px; }
.author-bio .role-line { font-size: 0.85rem; color: var(--color-text-tertiary); margin-bottom: 10px; }
.author-bio p { font-size: 0.92rem; color: var(--color-text-secondary); margin: 0; }

footer.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 32px 24px 56px;
  text-align: center;
  color: var(--color-text-tertiary);
  font-size: 0.85rem;
}

/* Back to top */
#back-to-top {
  position: fixed; right: 22px; bottom: 22px;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--color-text); color: #fff;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none; transform: translateY(8px);
  transition: opacity 200ms ease, transform 200ms ease, background 150ms ease;
  z-index: 800;
}
#back-to-top.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
#back-to-top:hover { background: var(--color-accent); }

#copy-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 12px);
  background: var(--color-text); color: #fff; font-size: 0.85rem; font-weight: 500;
  padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow-md);
  opacity: 0; transition: opacity 180ms ease, transform 180ms ease; pointer-events: none; z-index: 1100;
}
#copy-toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 620px) {
  .hero { padding: 44px 18px 32px; }
  .prose-wrap, .wide-wrap { padding: 0 18px; }
  .checklist-grid { gap: 14px; }
  .author-bio { flex-direction: column; }
}

/* ============================================================
   SITE NAV + MPC HUB
   ============================================================ */
.site-header .wrap { gap: 16px; min-width: 0; }
.site-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-left: auto;
  min-width: 0;
}
.site-nav a {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.site-nav a[aria-current="page"] {
  color: var(--color-text);
  text-decoration: underline;
  text-decoration-color: var(--color-accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
@media (max-width: 860px) {
  .site-header .wrap:has(.site-nav) .header-tag { display: none; }
}
@media (max-width: 640px) {
  .site-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .site-nav::-webkit-scrollbar { display: none; }
}

.inline-note {
  margin: -8px 0 28px;
  font-size: 0.95rem;
  font-weight: 600;
}

.hub-hero h1 { max-width: 22ch; }
.hero .btn-primary {
  display: inline-block;
  background: #fff;
  color: #312e81;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  padding: 12px 18px;
  border-radius: 999px;
}
.hero .btn-primary:hover,
.hero .btn-primary:focus-visible { color: var(--color-accent-hover); }

.hub-section { padding: 56px 0; }
.hub-section + .hub-section { border-top: 1px solid var(--color-border); }
.hub-section h2 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  margin-bottom: 12px;
}
.hub-intro {
  color: var(--color-text-secondary);
  max-width: 66ch;
  margin: 0 0 28px;
}
.card-grid,
.topic-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.info-card,
.topic-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px 20px 22px;
  background: var(--color-bg);
}
a.topic-card {
  display: block;
  color: inherit;
  text-decoration: none;
}
a.topic-card:hover,
a.topic-card:focus-visible {
  border-color: var(--color-accent-soft-border);
  box-shadow: var(--shadow-md);
}
.info-card h3,
.topic-card h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0 0 8px;
}
.info-card p,
.topic-card p {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 0.95rem;
}
.badge {
  display: inline-block;
  margin-bottom: 10px;
  padding: 3px 8px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.audience-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 18px;
}
.audience-list h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0 0 6px;
}
.audience-list p {
  margin: 0;
  color: var(--color-text-secondary);
  max-width: 66ch;
}
@media (max-width: 860px) {
  .card-grid,
  .topic-grid { grid-template-columns: 1fr; }
}
