/* ============================================================
   The Cheat Code — Interactive Diagram Framework
   Shared CSS for animations, tooltips, step-through bar
   Bento Design Language — updated 2026-04
   ============================================================ */

/* --- Google Fonts Import --- */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Sora:wght@400;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap');

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

:root {
  /* Existing light theme */
  --purple: #6B2FA0;
  --blue: #0078D4;
  --green: #107C10;
  --orange: #D83B01;
  --amber: #CA5010;
  --navy: #1B1B3A;
  --muted: #6B6B8D;
  --bg: #F8F8FC;
  --card: #FFFFFF;
  --shadow: rgba(0,0,0,0.08);
  --transition-speed: 0.4s;

  /* Bento additions */
  --purple-light: #9B5FD0;
  --purple-dark: #4A1F70;
  --navy-deep: #0E0E1F;
  --navy-light: #252548;
  --blue-light: #2899F5;
  --text-primary: #F0EDF8;
  --text-secondary: #A89DC0;
  --border-glass: rgba(255,255,255,0.08);
  --glass: rgba(255,255,255,0.04);
}

/* --- Light Mode Overrides --- */
[data-theme="light"] {
  --navy-deep: #F8F8FC;
  --navy: #FFFFFF;
  --navy-light: #F0ECF5;
  --bg: #F8F8FC;
  --card: #FFFFFF;
  --text-primary: #1B1B3A;
  --text-secondary: #6B6B8D;
  --border-glass: rgba(0, 0, 0, 0.08);
  --glass: rgba(0, 0, 0, 0.03);
  --purple-light: #6B2FA0;
  --shadow: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] body {
  background: var(--bg);
  color: var(--text-primary);
}

[data-theme="light"] .global-nav {
  background: var(--navy);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .step-bar {
  background: var(--navy);
  box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .step-bar button {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.12);
  color: var(--text-primary);
}

[data-theme="light"] .step-bar button.btn-primary {
  background: var(--purple);
  border-color: var(--purple);
  color: white;
}

[data-theme="light"] .step-bar .step-counter {
  color: var(--text-secondary);
}

[data-theme="light"] .step-dot {
  background: rgba(0, 0, 0, 0.1);
  border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .narrative-panel {
  background: var(--card);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .narrative-panel .narrative-title {
  color: var(--text-primary);
}

[data-theme="light"] .expand-panel,
[data-theme="light"] .context-panel {
  background: var(--card);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .context-panel .context-label {
  color: var(--purple);
}

[data-theme="light"] .context-panel .context-body {
  color: var(--text-secondary);
}

[data-theme="light"] .context-pill {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
  color: var(--text-primary);
}

[data-theme="light"] .context-prereqs li {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
  color: var(--text-secondary);
}

[data-theme="light"] .context-code {
  background: #1B1B3A;
}

[data-theme="light"] .context-link {
  color: var(--purple);
}

[data-theme="light"] .global-nav .nav-brand { color: var(--text-primary); }
[data-theme="light"] .global-nav .nav-brand:hover { color: var(--purple); }
[data-theme="light"] .global-nav .nav-issue-link { color: rgba(0,0,0,0.5); }
[data-theme="light"] .global-nav .nav-issue-link:hover { background: rgba(0,0,0,0.05); color: var(--text-primary); }
[data-theme="light"] .global-nav .nav-issue-link.active { background: var(--purple); color: white; }
[data-theme="light"] .global-nav .nav-divider { background: rgba(0,0,0,0.1); }

[data-theme="light"] .expand-overlay { background: rgba(0, 0, 0, 0.2); }

[data-theme="light"] .page-header .back-link { color: var(--purple); }
[data-theme="light"] .page-header h1 { color: var(--text-primary); }

[data-theme="light"] .expand-panel .expand-title { color: var(--text-primary); }
[data-theme="light"] .expand-panel .expand-details li { color: var(--text-primary); }
[data-theme="light"] .expand-panel .expand-close:hover { color: var(--text-secondary); }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--navy);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Global Navigation Bar --- */
.global-nav {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 52px;
  gap: 0;
  position: sticky;
  top: 0;
  z-index: 300;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}

.global-nav .nav-brand {
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: white;
  text-decoration: none;
  margin-right: 24px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.global-nav .nav-brand:hover { color: var(--text-secondary); }

.global-nav .nav-brand .brand-accent {
  color: var(--purple-light);
}

.global-nav .nav-divider {
  width: 1px;
  height: 24px;
  background: var(--border-glass);
  margin: 0 16px;
  flex-shrink: 0;
}

.global-nav .nav-issues {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  flex: 1;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.global-nav .nav-issues::-webkit-scrollbar { display: none; }

.global-nav .nav-issue-link {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 4px;
}
.global-nav .nav-issue-link:hover {
  background: var(--glass);
  border-color: var(--border-glass);
  color: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
}
.global-nav .nav-issue-link.active {
  background: var(--purple);
  border-color: var(--purple-light);
  color: white;
}

/* Issue type badges in nav */
.nav-issue-link .issue-type {
  font-size: 8px;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.nav-issue-link .type-practical {
  background: rgba(216,59,1,0.3);
  color: #F77050;
}
.nav-issue-link .type-conceptual {
  background: rgba(0,120,212,0.3);
  color: #5BB5FF;
}

.global-nav .nav-archive {
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  white-space: nowrap;
  margin-left: auto;
  transition: background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}
.global-nav .nav-archive:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

/* Back to portal link */
.nav-back-to-portal {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid var(--border-glass);
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.nav-back-to-portal:hover {
  background: var(--glass);
  border-color: rgba(255,255,255,0.15);
  color: white;
}

@media (max-width: 600px) {
  .global-nav { padding: 0 12px; height: 46px; }
  .global-nav .nav-brand { font-size: 13px; margin-right: 12px; }
  .global-nav .nav-divider { margin: 0 8px; }
  .global-nav .nav-issue-link { font-size: 10px; padding: 5px 8px; }
  .global-nav .nav-archive { font-size: 11px; padding: 5px 8px; }
}

/* --- Page Shell --- */
.interactive-page {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 24px 120px;
  flex: 1;
}

.page-header {
  text-align: center;
  margin-bottom: 32px;
}

.page-header .back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--purple);
  text-decoration: none;
  margin-bottom: 16px;
  transition: opacity var(--transition-speed);
  letter-spacing: 0.3px;
}
.page-header .back-link:hover { opacity: 0.7; }

.page-header h1 {
  font-family: 'Sora', sans-serif;
  font-size: 32px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--navy);
}

.page-header .page-subtitle {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  color: var(--muted);
  margin: 0;
}

.page-header .issue-badge {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 6px;
  background: var(--purple);
  color: white;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 12px;
}

/* --- Diagram Canvas --- */
.diagram-canvas {
  position: relative;
  padding: 32px 20px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 24px var(--shadow);
  overflow: visible;
}

/* --- Zone & Component Interactivity --- */
[data-step] {
  transition: opacity var(--transition-speed) ease,
              transform var(--transition-speed) ease,
              box-shadow var(--transition-speed) ease,
              filter var(--transition-speed) ease;
  cursor: pointer;
  position: relative;
}

/* Dimmed state when a step is active */
.step-active [data-step] {
  opacity: 0.25;
  filter: grayscale(0.5);
  transform: scale(0.98);
}

/* Highlighted step element */
.step-active [data-step].step-highlight {
  opacity: 1;
  filter: none;
  transform: scale(1.02);
  z-index: 10;
}

/* Glow effect on highlighted zone */
.step-active [data-step].step-highlight.zone,
.step-active [data-step].step-highlight.step-zone,
.step-active [data-step].step-highlight.source-lane,
.step-active [data-step].step-highlight.input-node,
.step-active [data-step].step-highlight.output-node,
.step-active [data-step].step-highlight.input-card,
.step-active [data-step].step-highlight.output-card,
.step-active [data-step].step-highlight.analyzer-zone,
.step-active [data-step].step-highlight.process-zone,
.step-active [data-step].step-highlight.playbook-box,
.step-active [data-step].step-highlight.conn-row {
  box-shadow: 0 0 0 4px rgba(107, 47, 160, 0.2),
              0 8px 32px rgba(107, 47, 160, 0.15);
}

/* Keep arrows visible during steps */
.step-active .arrow-down,
.step-active .arrow-right,
.step-active .arrow-between,
.step-active .fan-arrows {
  opacity: 0.4;
  transition: opacity var(--transition-speed);
}
.step-active .arrow-highlight {
  opacity: 1;
}

/* --- Hover Tooltips --- */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--navy);
  color: white;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  padding: 10px 14px;
  border-radius: 8px;
  white-space: normal;
  width: max-content;
  max-width: 280px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100;
}

[data-tooltip]::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--navy);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 100;
}

[data-tooltip]:hover::after,
[data-tooltip]:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Override tooltip arrow transform */
[data-tooltip]:hover::before {
  transform: translateX(-50%);
}

/* --- Narrative Panel --- */
.narrative-panel {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
  padding: 20px 28px;
  max-width: 600px;
  width: calc(100% - 48px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 50;
  border-top: 4px solid var(--purple);
}

.narrative-panel.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.narrative-panel .narrative-step-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--purple);
  margin-bottom: 6px;
}

.narrative-panel .narrative-title {
  font-family: 'Sora', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 8px;
}

.narrative-panel .narrative-text {
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}

/* --- Step-Through Bottom Bar --- */
.step-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 200;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.2);
  padding: 0 24px;
}

.step-bar .step-counter {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.7);
  min-width: 100px;
  text-align: center;
  letter-spacing: 0.5px;
}

.step-bar button {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.step-bar button:hover {
  background: rgba(255,255,255,0.2);
}

.step-bar button:active {
  transform: scale(0.97);
}

.step-bar button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.step-bar button.btn-primary {
  background: var(--purple);
  border-color: var(--purple-light);
  box-shadow: 0 0 20px rgba(107,47,160,0.3);
}

.step-bar button.btn-primary:hover {
  background: #7D3CB5;
  box-shadow: 0 0 28px rgba(107,47,160,0.45);
}

.step-bar .btn-reset {
  position: absolute;
  right: 24px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  padding: 6px 14px;
  opacity: 0.6;
}
.step-bar .btn-reset:hover { opacity: 1; }

/* Step dots */
.step-dots {
  display: flex;
  gap: 8px;
  align-items: center;
}

.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  transition: background 0.3s, transform 0.3s, opacity 0.3s;
  cursor: pointer;
}

.step-dot.active {
  background: var(--purple-light);
  border-color: var(--purple-light);
  transform: scale(1.3);
  box-shadow: 0 0 8px rgba(155,95,208,0.5);
}

.step-dot.visited {
  background: var(--purple-light);
  opacity: 0.6;
}

/* --- Flow Animations --- */
@keyframes flowPulse {
  0% { transform: translateY(-100%); opacity: 0; }
  20% { opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateY(100%); opacity: 0; }
}

@keyframes flowPulseH {
  0% { transform: translateX(-100%); opacity: 0; }
  20% { opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateX(100%); opacity: 0; }
}

@keyframes fadeSlideUp {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes fadeSlideRight {
  0% { opacity: 0; transform: translateX(-20px); }
  100% { opacity: 1; transform: translateX(0); }
}

@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(107, 47, 160, 0); }
  50% { box-shadow: 0 0 0 8px rgba(107, 47, 160, 0.12); }
}

@keyframes dotFlow {
  0% { top: 0; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

/* Entrance animations (triggered by class) */
.animate-in {
  animation: fadeSlideUp 0.5s ease forwards;
}

.animate-in-right {
  animation: fadeSlideRight 0.5s ease forwards;
}

/* Staggered entrance for zones */
[data-step="1"].animate-in { animation-delay: 0.1s; }
[data-step="2"].animate-in { animation-delay: 0.3s; }
[data-step="3"].animate-in { animation-delay: 0.5s; }
[data-step="4"].animate-in { animation-delay: 0.7s; }
[data-step="5"].animate-in { animation-delay: 0.9s; }

/* Arrow flow dot */
.arrow-down .shaft,
.arrow-between .arrow-h .shaft {
  position: relative;
  overflow: hidden;
}

.flow-active .arrow-down .shaft::after {
  content: '';
  position: absolute;
  left: -2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--purple-light);
  animation: dotFlow 1.2s ease-in-out infinite;
}

/* --- Click-to-Expand Detail --- */
.expand-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 14, 31, 0.5);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.expand-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.expand-panel {
  position: fixed;
  right: -420px;
  top: 0;
  bottom: 64px;
  width: 400px;
  background: white;
  box-shadow: -8px 0 40px rgba(0,0,0,0.15);
  z-index: 90;
  transition: right 0.3s ease;
  overflow-y: auto;
  padding: 32px 24px;
}

.expand-panel.visible {
  right: 0;
}

.expand-panel .expand-title {
  font-family: 'Sora', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 8px;
}

.expand-panel .expand-desc {
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 20px;
}

.expand-panel .expand-details h3 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--purple);
  margin-bottom: 8px;
}

.expand-panel .expand-details ul {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
}

.expand-panel .expand-details li {
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  padding: 8px 0;
  border-bottom: 1px solid #F0F0F0;
  color: var(--navy);
}

.expand-panel .expand-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  line-height: 1;
}
.expand-panel .expand-close:hover { color: var(--navy); }

/* --- Implementation Context Panel --- */
/* Slide-from-right panel with Bento dark theme */
.context-panel {
  position: fixed;
  right: -460px;
  top: 0;
  bottom: 64px;
  width: 440px;
  background: var(--navy-light);
  box-shadow: -8px 0 48px rgba(0,0,0,0.35);
  z-index: 310;
  transition: right 0.3s ease;
  overflow-y: auto;
  padding: 32px 24px;
  color: var(--text-primary);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.context-panel::-webkit-scrollbar { width: 4px; }
.context-panel::-webkit-scrollbar-track { background: transparent; }
.context-panel::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
}

.context-panel.visible {
  right: 0;
}

.context-panel .expand-close,
.context-panel .context-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--glass);
  border: 1px solid var(--border-glass);
  font-size: 20px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px 8px;
  line-height: 1;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}
.context-panel .expand-close:hover,
.context-panel .context-close:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}

.context-panel .context-header {
  margin-bottom: 20px;
}

.context-panel .context-title {
  font-family: 'Sora', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  padding-right: 40px;
}

.context-panel .expand-title {
  font-family: 'Sora', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  padding-right: 40px;
}

.context-panel .expand-desc {
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
}

/* Shared context section elements */
.context-section {
  margin-bottom: 20px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.context-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--purple-light);
  margin-bottom: 8px;
  display: block;
}

.context-body {
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.context-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--purple-light);
  text-decoration: none;
  padding: 6px 0;
  transition: color 0.2s, gap 0.2s;
}
.context-link::before { content: '→'; font-size: 14px; order: 999; }
.context-link:hover {
  color: #B880E8;
  gap: 10px;
}

/* Pill tags for requirements */
.context-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.context-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--glass);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Prerequisites checklist */
.context-prereqs {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.context-prereqs li {
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  padding: 6px 10px;
  background: var(--glass);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.prereq-check {
  color: var(--green, #107C10);
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
  line-height: 1.5;
}

/* Key-value table for specs */
.context-table {
  width: 100%;
  border-collapse: collapse;
}

.context-table tr + tr td {
  border-top: 1px solid var(--border-glass);
}

.context-table td {
  padding: 7px 0;
  font-size: 13px;
  vertical-align: top;
}

.context-table td:first-child {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  width: 40%;
  padding-right: 12px;
}

.context-table td:last-child {
  font-family: 'Outfit', sans-serif;
  color: var(--text-primary);
}

/* Terminal-style code preview */
.context-code {
  background: var(--navy-deep);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-glass);
}

.context-code-titlebar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border-glass);
}

.context-code-titlebar .traffic-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.context-code-titlebar .dot-red   { background: #FF5F57; }
.context-code-titlebar .dot-amber { background: #FFBD2E; }
.context-code-titlebar .dot-green { background: #28C840; }

.context-code-titlebar .code-filename {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  margin-left: 6px;
}

.context-code pre {
  margin: 0;
  padding: 16px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.65;
  color: #C8B8E8;
  overflow-x: auto;
  tab-size: 2;
}

/* Syntax color tokens inside code blocks */
.context-code .tok-keyword  { color: #9B5FD0; }
.context-code .tok-string   { color: #7EC8A4; }
.context-code .tok-comment  { color: #6B6B8D; font-style: italic; }
.context-code .tok-number   { color: #F9C67A; }
.context-code .tok-function { color: #5BB5FF; }

/* --- Lightweight mode --- */
.context-panel.mode-lightweight {
  /* Compact vertical rhythm */
}
.context-panel.mode-lightweight .context-section {
  margin-bottom: 16px;
}
.context-panel.mode-lightweight .context-section + .context-section {
  padding-top: 16px;
  border-top: 1px solid var(--border-glass);
}

/* --- Detailed mode --- */
.context-panel.mode-detailed .context-section + .context-section {
  padding-top: 20px;
  border-top: 1px solid var(--border-glass);
}

/* --- Micro-Interaction Enhancements --- */

/* Step dot ripple on activation */
.step-dot.active {
  animation: dotRipple 0.6s ease-out;
}
@keyframes dotRipple {
  0% { box-shadow: 0 0 0 0 rgba(107, 47, 160, 0.5); }
  100% { box-shadow: 0 0 0 8px rgba(107, 47, 160, 0); }
}

/* Visited dot subtle pulse */
.step-dot.visited {
  animation: visitedPulse 2s ease-in-out infinite;
}
@keyframes visitedPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.75; }
}

/* Link underline draw */
.context-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--purple-light);
  transition: width 0.35s ease;
}
.context-link:hover::after {
  width: 100%;
}

/* Context panel content staggering */
.context-panel.visible .context-section {
  opacity: 1;
  transform: translateY(0);
}
.context-panel.visible .context-section:nth-child(1) { transition-delay: 0.05s; }
.context-panel.visible .context-section:nth-child(2) { transition-delay: 0.13s; }
.context-panel.visible .context-section:nth-child(3) { transition-delay: 0.18s; }
.context-panel.visible .context-section:nth-child(4) { transition-delay: 0.23s; }
.context-panel.visible .context-section:nth-child(5) { transition-delay: 0.28s; }

/* Pill/tag hover lift */
.context-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* Reduced motion — disable all new animations */
@media (prefers-reduced-motion: reduce) {
  .step-dot.active { animation: none; }
  .step-dot.visited { animation: none; }
  .context-section { transition: none; opacity: 1; transform: none; }
  .context-link::after { transition: none; }
  .step-bar button:active { transform: none; }
  .context-pill:hover { transform: none; }
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .interactive-page { padding: 16px 12px 120px; }
  .page-header h1 { font-family: 'Sora', sans-serif; font-size: 24px; }
  .diagram-canvas { padding: 20px 12px; }
  .narrative-panel { max-width: calc(100% - 24px); padding: 16px 20px; }

  /* Stack horizontal layouts vertically */
  .canvas-responsive { flex-direction: column !important; gap: 24px !important; }
  .pipeline-responsive { flex-direction: column !important; align-items: center !important; gap: 16px !important; }

  .expand-panel { width: 100%; right: -100%; }
  .context-panel { width: 100%; right: -100%; }

  .step-bar { height: 56px; gap: 12px; }
  .step-bar button { padding: 6px 14px; font-size: 13px; }
}

@media (max-width: 600px) {
  .page-header h1 { font-size: 20px; }
  .step-dots { display: none; }
  .context-panel { bottom: 56px; }
  .expand-panel { bottom: 56px; }
}

/* --- Footer Branding --- */
.interactive-footer {
  text-align: center;
  padding: 24px;
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  color: var(--muted);
}

.interactive-footer a {
  color: var(--purple);
  text-decoration: none;
}
.interactive-footer a:hover { text-decoration: underline; }

/* --- Konami Easter Egg --- */
.konami-flash {
  position: fixed;
  inset: 0;
  background: var(--purple);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  color: white;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.konami-flash.active {
  opacity: 1;
  animation: konamiFlash 1.5s ease forwards;
}
@keyframes konamiFlash {
  0% { opacity: 1; }
  15% { opacity: 1; }
  100% { opacity: 0; }
}

/* --- Theme Toggle --- */
.theme-toggle {
  position: fixed;
  top: 60px;
  right: 16px;
  z-index: 400;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-glass);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-secondary, #A89DC0);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
}
.theme-toggle:hover {
  background: rgba(255,255,255,0.07);
  transform: scale(1.1);
}
[data-theme="light"] .theme-toggle:hover {
  background: rgba(0,0,0,0.06);
}
