/* Self-hosted Departure Mono (SIL OFL 1.1 license) */
@font-face {
  font-family: 'Departure Mono';
  src: url('assets/fonts/DepartureMono-Regular.woff2') format('woff2'),
       url('assets/fonts/DepartureMono-Regular.woff') format('woff');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

/* ==========================================================================
   Swiss / International Typographic Style stylesheet for The AI Playbook
   Grid System: 12 columns, 24px gutters, 8px baseline rhythm
   ========================================================================== */

/* Design Tokens & Custom Variables (Default Level 5 Midnight) */
:root {
  --color-bg: #161619;
  --color-text-primary: #e4e4e9;
  --color-text-secondary: #90909c;
  --color-divider: #28282e;
  --color-accent: #e5484d;
  --color-code-bg: #202025;
  --color-inline-code-bg: #242429;
  --color-inline-code-text: #f0f0f5;
  --color-inline-code-border: #36363e;
  --color-card-bg: #1c1c20;
  --color-border-subtle: #26262c;
  --color-header-bg: rgba(22, 22, 25, 0.95);
  --color-hover-bg: #25252b;
  --icon-filter: invert(0.9) brightness(1.2);
  --font-sans: 'Inter', -apple-system, blinkmacsystemfont, "Segoe UI", roboto, sans-serif;
  --font-mono: 'JetBrains Mono', "SFMono-Regular", consolas, "Liberation Mono", menlo, monospace;
  --font-departure: 'Departure Mono', 'JetBrains Mono', monospace;
  --grid-dot-color: rgba(255, 255, 255, 0.05);
  --spacing-base: 8px;
  --spacing-xs: 8px;    /* 1x baseline */
  --spacing-sm: 16px;   /* 2x baseline */
  --spacing-md: 24px;   /* 3x baseline */
  --spacing-lg: 32px;   /* 4x baseline */
  --spacing-xl: 48px;   /* 6x baseline */
  --spacing-xxl: 64px;  /* 8x baseline */
  --spacing-huge: 80px; /* 10x baseline */
}

/* ==========================================================================
   6 CONTRAST THEME LEVELS (Left = Dark, Right = Light)
   ========================================================================== */

/* Level 1: Stark OLED (Leftmost - Pure Pitch Black & White) */
[data-theme-level="1"] {
  --color-bg: #000000;
  --color-text-primary: #ffffff;
  --color-text-secondary: #e0e0e0;
  --color-divider: #ffffff;
  --color-accent: #ffffff;
  --color-code-bg: #111111;
  --color-inline-code-bg: #000000;
  --color-inline-code-text: #ffffff;
  --color-inline-code-border: #ffffff;
  --color-card-bg: #080808;
  --color-border-subtle: #ffffff;
  --color-header-bg: rgba(0, 0, 0, 0.98);
  --color-hover-bg: #222222;
  --icon-filter: invert(1) brightness(2);
  --grid-dot-color: rgba(255, 255, 255, 0.08);
}

/* Level 2: Deep Midnight (Deep Dark Charcoal) */
[data-theme-level="2"] {
  --color-bg: #0c1017;
  --color-text-primary: #f0f6fc;
  --color-text-secondary: #8b949e;
  --color-divider: #30363d;
  --color-accent: #00d294;
  --color-code-bg: #161b22;
  --color-inline-code-bg: #1c2128;
  --color-inline-code-text: #f0f6fc;
  --color-inline-code-border: #30363d;
  --color-card-bg: #161b22;
  --color-border-subtle: #21262d;
  --color-header-bg: rgba(12, 16, 23, 0.95);
  --color-hover-bg: #21262d;
  --icon-filter: invert(0.9) brightness(1.2);
  --grid-dot-color: rgba(255, 255, 255, 0.05);
}

/* Level 3: Dark Slate (Medium Cool Dark) */
[data-theme-level="3"] {
  --color-bg: #1e222a;
  --color-text-primary: #e6e9f0;
  --color-text-secondary: #9aa2b1;
  --color-divider: #383e4c;
  --color-accent: #38bdf8;
  --color-code-bg: #262b36;
  --color-inline-code-bg: #2a303c;
  --color-inline-code-text: #f0f3f9;
  --color-inline-code-border: #3d4556;
  --color-card-bg: #242933;
  --color-border-subtle: #323846;
  --color-header-bg: rgba(30, 34, 42, 0.95);
  --color-hover-bg: #2e3442;
  --icon-filter: invert(0.9) brightness(1.2);
  --grid-dot-color: rgba(255, 255, 255, 0.05);
}

/* Level 4: Paper Muted (Warm Eye-Care Light Sepia) */
[data-theme-level="4"] {
  --color-bg: #e5e0d4;
  --color-text-primary: #2d261e;
  --color-text-secondary: #635b4f;
  --color-divider: #c5beaf;
  --color-accent: #b84000;
  --color-code-bg: #dcd6c8;
  --color-inline-code-bg: #ded7ca;
  --color-inline-code-text: #262018;
  --color-inline-code-border: #b8b0a0;
  --color-card-bg: #ede7dc;
  --color-border-subtle: #d0c8b9;
  --color-header-bg: rgba(229, 224, 212, 0.95);
  --color-hover-bg: #dcd6c8;
  --icon-filter: none;
  --grid-dot-color: rgba(45, 38, 30, 0.06);
}

/* Level 5: Soft Swiss Light (Comfortable Clean Light) */
[data-theme-level="5"] {
  --color-bg: #f5f5f0;
  --color-text-primary: #1c1c21;
  --color-text-secondary: #5a5a64;
  --color-divider: #d0d0c8;
  --color-accent: #d62828;
  --color-code-bg: #e8e8e0;
  --color-inline-code-bg: #eaeae2;
  --color-inline-code-text: #1a1a1e;
  --color-inline-code-border: #c8c8c0;
  --color-card-bg: #ffffff;
  --color-border-subtle: #d8d8d0;
  --color-header-bg: rgba(245, 245, 240, 0.95);
  --color-hover-bg: #e8e8e0;
  --icon-filter: none;
  --grid-dot-color: rgba(28, 28, 33, 0.05);
}

/* Level 6: Stark Light (Rightmost - Pure High Contrast White & Black, Complete opposite to OLED) */
[data-theme-level="6"] {
  --color-bg: #ffffff;
  --color-text-primary: #000000;
  --color-text-secondary: #222222;
  --color-divider: #000000;
  --color-accent: #000000;
  --color-code-bg: #eeeeee;
  --color-inline-code-bg: #ffffff;
  --color-inline-code-text: #000000;
  --color-inline-code-border: #000000;
  --color-card-bg: #ffffff;
  --color-border-subtle: #000000;
  --color-header-bg: rgba(255, 255, 255, 0.98);
  --color-hover-bg: #dddddd;
  --icon-filter: none;
  --grid-dot-color: rgba(0, 0, 0, 0.08);
}

/* Reset & Base Styles */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border-radius: 0 !important; /* Strict Swiss sharp geometry - zero border radius everywhere */
}

::selection {
  background-color: var(--color-accent);
  color: #ffffff;
}

html {
  font-size: 16px;
  line-height: 1.5; /* 24px line height at 16px font-size */
  scroll-behavior: smooth;
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Swiss Background Dot Grid Overlay (Inspired by pi.dev) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(var(--grid-dot-color, rgba(255, 255, 255, 0.05)) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
  z-index: -1;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 76px;
}

/* Typography Scale (Mathematical Ratio aligned to 8px baseline) */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-sans);
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.02em;
  margin-top: var(--spacing-xl);
  margin-bottom: var(--spacing-sm);
  line-height: 1.25;
  text-wrap: balance;
  scroll-margin-top: 76px;
}

.heading-anchor-group {
  scroll-margin-top: 76px;
}

@keyframes heading-text-blink {
  0% {
    opacity: 1;
  }
  20% {
    opacity: 0.4;
  }
  40% {
    opacity: 1;
  }
  60% {
    opacity: 0.4;
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 1;
  }
}

.prose h1:target,
.prose h2:target,
.prose h3:target,
.prose h4:target,
.prose h5:target,
.prose h6:target,
.heading-target-blink {
  animation: heading-text-blink 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

h1 {
  font-size: 3rem; /* 48px */
  line-height: 3.5rem; /* 56px - 7x baseline */
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-top: 0;
  margin-bottom: var(--spacing-lg);
  border-bottom: 2px solid var(--color-text-primary);
  padding-bottom: var(--spacing-sm);
}

h2 {
  font-size: 2rem; /* 32px */
  line-height: 2.5rem; /* 40px - 5x baseline */
  letter-spacing: -0.025em;
  margin-top: var(--spacing-xxl);
  border-bottom: 1px solid var(--color-text-primary);
  padding-bottom: var(--spacing-xs);
}

h3 {
  font-size: 1.5rem; /* 24px */
  line-height: 2rem; /* 32px - 4x baseline */
  letter-spacing: -0.02em;
  margin-top: var(--spacing-xl);
}

h4 {
  font-size: 1.125rem; /* 18px */
  line-height: 1.5rem; /* 24px - 3x baseline */
  margin-top: var(--spacing-lg);
}

p {
  font-size: 1rem; /* 16px */
  line-height: 1.5rem; /* 24px - 3x baseline */
  font-weight: 400;
  margin-bottom: var(--spacing-sm);
  max-width: 720px; /* Optimal reading length */
  text-align: left; /* Ragged right */
  text-wrap: pretty;
}

/* Accessibility: Skip Link & Focus States */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--spacing-md);
  background: var(--color-accent);
  color: #fff;
  padding: var(--spacing-sm) var(--spacing-md);
  font-weight: 700;
  text-transform: uppercase;
  z-index: 1000;
  text-decoration: none;
  border: 1px solid var(--color-text-primary);
}

.skip-link:focus {
  top: var(--spacing-md);
  outline: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* Header Styles */
.site-header {
  position: sticky;
  top: 0;
  width: 100%;
  background-color: var(--color-header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-divider);
  z-index: 100;
  height: 64px; /* 8x baseline */
}

.header-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-link {
  text-decoration: none;
  color: var(--color-text-primary);
  transition: opacity 0.15s ease;
}

.logo-link:hover {
  opacity: 0.85;
}

.header-logo {
  font-family: var(--font-departure);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.logo-bold {
  color: var(--color-text-primary);
  font-weight: 700;
}

.logo-light {
  color: var(--color-accent);
  font-weight: 400;
}

.header-meta {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

/* Theme Slider Popover Component */
.theme-slider-popover-wrapper {
  position: relative;
  display: inline-block;
}

.theme-toggle-btn {
  background: transparent;
  border: 1px solid var(--color-divider);
  color: var(--color-text-primary);
  font-family: var(--font-departure);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.theme-icon-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  overflow: hidden;
}

.theme-icon {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
}

/* Light themes (Levels 4, 5, 6): Sun visible in center, Moon pushed down */
html[data-theme="light"] .icon-sun,
html:not([data-theme="dark"]) .icon-sun {
  transform: translateY(0) rotate(0deg);
  opacity: 1;
}

html[data-theme="light"] .icon-moon,
html:not([data-theme="dark"]) .icon-moon {
  transform: translateY(140%) rotate(-45deg);
  opacity: 0;
}

/* Dark themes (Levels 1, 2, 3): Sun slides down out of button, Moon slides up into center */
html[data-theme="dark"] .icon-sun {
  transform: translateY(140%) rotate(45deg);
  opacity: 0;
}

html[data-theme="dark"] .icon-moon {
  transform: translateY(0) rotate(0deg);
  opacity: 1;
}

.theme-toggle-btn:hover {
  border-color: var(--color-text-primary);
  background-color: var(--color-hover-bg);
}

.theme-toggle-btn:hover .icon-sun {
  transform: translateY(0) rotate(20deg);
}

.theme-toggle-btn:hover .icon-moon {
  transform: translateY(0) rotate(-15deg);
}

.theme-toggle-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.theme-level-badge {
  font-family: var(--font-departure);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  font-feature-settings: "tnum";
}

.doc-date, .last-updated-date {
  font-family: var(--font-departure);
  font-weight: 700;
  letter-spacing: 0.05em;
}

.theme-popover-card {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-width: calc(100vw - 24px);
  padding: 16px;
  background-color: var(--color-card-bg);
  border: 2px solid var(--color-text-primary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 1200;
  border-radius: 0;
}

@media (max-width: 768px) {
  .theme-popover-card {
    position: fixed;
    top: 60px;
    left: 12px;
    right: 12px;
    width: auto;
    max-width: calc(100vw - 24px);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  }
}

.theme-popover-card[hidden] {
  display: none !important;
}

.theme-popover-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-divider);
}

.popover-title {
  font-family: var(--font-departure);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.popover-level-readout {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-text-primary);
}

.theme-slider-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.theme-slider-track-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.6875rem;
  font-family: var(--font-departure);
  color: var(--color-text-secondary);
  text-transform: uppercase;
}

.theme-contrast-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--color-divider);
  outline: none;
  cursor: pointer;
  border-radius: 0;
  margin: 6px 0;
}

.theme-contrast-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--color-text-primary);
  border: 2px solid var(--color-bg);
  border-radius: 0;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  transition: transform 0.1s ease;
}

.theme-contrast-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.theme-contrast-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--color-text-primary);
  border: 2px solid var(--color-bg);
  border-radius: 0;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.theme-step-ticks {
  display: flex;
  justify-content: space-between;
  gap: 4px;
}

.step-tick {
  flex: 1;
  padding: 6px 0;
  background: var(--color-code-bg);
  border: 1px solid var(--color-divider);
  color: var(--color-text-secondary);
  font-family: var(--font-departure);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  font-feature-settings: "tnum";
}

.step-tick.active,
.step-tick:hover {
  background: var(--color-text-primary);
  color: var(--color-bg);
  border-color: var(--color-text-primary);
}

.theme-popover-description {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  line-height: 1.4;
  margin: 0;
}

.chapter-badge {
  background-color: var(--color-text-primary);
  color: var(--color-bg);
  padding: 2px 8px;
  font-family: var(--font-departure);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

.mobile-menu-btn,
.close-menu-btn {
  display: none;
}

/* 12-Column Grid Layout */
.layout-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--spacing-xl) var(--spacing-lg);
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--spacing-lg);
  flex: 1;
  width: 100%;
}

/* Sticky Sidebar Index Navigation (Left 3 columns) */
.sidebar {
  grid-column: 1 / 4; /* 3 columns wide */
  position: sticky;
  top: 96px; /* Header height + spacing */
  align-self: start;
  max-height: calc(100vh - 120px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--color-divider);
  padding-right: var(--spacing-md);
}

.sidebar-header {
  border-bottom: 2px solid var(--color-text-primary);
  padding-bottom: var(--spacing-xs);
  margin-bottom: var(--spacing-sm);
}

.sidebar-title {
  font-family: var(--font-departure);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-primary);
}

.sidebar-nav {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--color-text-secondary) transparent;
}

.toc-list {
  list-style: none;
}

.toc-item {
  margin-bottom: var(--spacing-xs);
  line-height: 1.35;
}

.toc-item a {
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  align-items: first baseline;
  gap: 0.25rem;
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 4px 6px;
  border-left: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease, transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.toc-item a:hover {
  color: var(--color-text-primary);
  border-left-color: var(--color-text-primary);
  background-color: var(--color-hover-bg);
}

.toc-item.active-chapter a {
  color: var(--color-accent);
  font-weight: 700;
  border-left-color: var(--color-accent);
  background-color: var(--color-hover-bg);
}

.toc-num {
  font-family: var(--font-departure);
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--color-accent);
  font-feature-settings: "tnum";
  white-space: nowrap;
}

.toc-text {
  min-width: 0;
}

/* Content Column (Center 6 columns in 3-6-3 grid) */
.content-wrapper {
  grid-column: 4 / 10;
  min-width: 0;
}

/* Sticky On-This-Page Right Sidebar Navigation (Right 3 columns) */
.on-this-page-sidebar {
  grid-column: 10 / 13;
  position: sticky;
  top: 96px;
  align-self: start;
  max-height: calc(100vh - 120px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--color-divider);
  padding-left: var(--spacing-md);
}

.on-this-page-header {
  border-bottom: 2px solid var(--color-text-primary);
  padding-bottom: var(--spacing-xs);
  margin-bottom: var(--spacing-sm);
}

.on-this-page-title {
  font-family: var(--font-departure);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-primary);
}

.on-this-page-nav {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--color-text-secondary) transparent;
}

.on-this-page-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.on-this-page-item {
  margin-bottom: var(--spacing-xs);
  line-height: 1.35;
}

.on-this-page-item.depth-3 {
  padding-left: 12px;
}

.on-this-page-link {
  display: block;
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 4px 6px;
  border-left: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.on-this-page-link:hover {
  color: var(--color-text-primary);
  border-left-color: var(--color-text-primary);
  background-color: var(--color-hover-bg);
}

.on-this-page-link.active {
  color: var(--color-accent);
  font-weight: 700;
  border-left-color: var(--color-accent);
  background-color: var(--color-hover-bg);
}

/* Mobile Collapsible On-This-Page Jump Menu */
.mobile-on-this-page {
  display: none;
  margin: var(--spacing-md) 0 var(--spacing-lg) 0;
  border: 1px solid var(--color-divider);
  background-color: var(--color-code-bg);
  padding: var(--spacing-xs) var(--spacing-sm);
}

.mobile-otp-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-family: var(--font-departure);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-text-primary);
  list-style: none;
  user-select: none;
}

.mobile-otp-summary::-webkit-details-marker {
  display: none;
}

.mobile-otp-chevron {
  transition: transform 0.2s ease;
  color: var(--color-text-secondary);
}

.mobile-on-this-page[open] .mobile-otp-chevron {
  transform: rotate(180deg);
}

.mobile-otp-list {
  list-style: none;
  margin: var(--spacing-xs) 0 0 0;
  padding: var(--spacing-xs) 0 0 0;
  border-top: 1px solid var(--color-divider);
}

.mobile-otp-item {
  margin-bottom: 6px;
}

.mobile-otp-item.depth-3 {
  padding-left: 12px;
}

.mobile-otp-item a {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
}

.mobile-otp-item a:hover,
.mobile-otp-item a.active {
  color: var(--color-accent);
}

.prose {
  font-size: 1.0625rem;
  line-height: 1.6;
}

.prose a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
}

.prose a:hover {
  color: var(--color-text-primary);
}

.heading-anchor-group {
  position: relative;
}

.heading-anchor {
  display: inline-block;
  margin-left: 8px;
  color: var(--color-divider);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.heading-anchor-group:hover .heading-anchor {
  opacity: 1;
}

/* Code Snippet Wrapper */
.code-block-wrapper {
  position: relative;
  margin: var(--spacing-md) 0;
  border: 1px solid var(--color-divider);
  background-color: var(--color-code-bg);
}

.code-block-wrapper::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  height: 6px;
  pointer-events: none;
  background: 
    linear-gradient(var(--color-text-secondary), var(--color-text-secondary)) top left / 6px 1px no-repeat,
    linear-gradient(var(--color-text-secondary), var(--color-text-secondary)) top left / 1px 6px no-repeat,
    linear-gradient(var(--color-text-secondary), var(--color-text-secondary)) top right / 6px 1px no-repeat,
    linear-gradient(var(--color-text-secondary), var(--color-text-secondary)) top right / 1px 6px no-repeat;
  opacity: 0.5;
  z-index: 2;
}

.code-block-wrapper::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: -1px;
  right: -1px;
  height: 6px;
  pointer-events: none;
  background: 
    linear-gradient(var(--color-text-secondary), var(--color-text-secondary)) bottom left / 6px 1px no-repeat,
    linear-gradient(var(--color-text-secondary), var(--color-text-secondary)) bottom left / 1px 6px no-repeat,
    linear-gradient(var(--color-text-secondary), var(--color-text-secondary)) bottom right / 6px 1px no-repeat,
    linear-gradient(var(--color-text-secondary), var(--color-text-secondary)) bottom right / 1px 6px no-repeat;
  opacity: 0.5;
  z-index: 2;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-xs) var(--spacing-sm);
  background-color: var(--color-code-bg);
  border-bottom: 1px solid var(--color-divider);
}

.code-lang {
  font-family: var(--font-departure);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  letter-spacing: 0.05em;
}

.copy-btn {
  background: transparent;
  border: 1px solid var(--color-divider);
  color: var(--color-text-primary);
  padding: 2px 8px;
  font-size: 0.75rem;
  font-family: var(--font-departure);
  cursor: pointer;
  font-weight: 700;
  transition: all 0.15s ease;
}

.copy-btn:hover {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

.copy-btn.copied {
  background: #10b981;
  color: #fff;
  border-color: #10b981;
}

pre {
  margin: 0;
  padding: var(--spacing-md);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Standout Inline Code Pills (UI Craft) */
:not(pre) > code,
code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.85em;
  font-weight: 600;
  color: var(--color-inline-code-text);
  background-color: var(--color-inline-code-bg);
  border: 1px solid var(--color-inline-code-border);
  border-radius: 0 !important;
  padding: 0.15em 0.45em;
  margin: 0 0.12em;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  vertical-align: baseline;
  word-break: break-word;
}

/* Standardized High-Craft Table Design */
.table-container {
  width: 100%;
  overflow-x: auto;
  margin: var(--spacing-md) 0;
  border: 1px solid var(--color-divider);
  border-radius: 0;
  background-color: var(--color-card-bg);
}

.swiss-table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  font-size: 0.875rem;
  line-height: 1.5;
  text-align: left;
}

/* Header Row */
.swiss-table thead {
  background-color: var(--color-code-bg);
  border-bottom: 2px solid var(--color-divider);
}

.swiss-table thead th {
  padding: 12px 16px;
  font-family: var(--font-departure);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-primary);
  border-right: 1px solid var(--color-divider);
  white-space: nowrap;
}

.swiss-table thead th:last-child {
  border-right: none;
}

/* Body Rows & Hover */
.swiss-table tbody tr {
  border-bottom: 1px solid var(--color-divider);
  transition: background-color 0.15s ease;
}

.swiss-table tbody tr:last-child {
  border-bottom: none;
}

.swiss-table tbody tr:hover {
  background-color: var(--color-hover-bg);
}

/* Body Cells */
.swiss-table tbody td {
  padding: 12px 16px;
  color: var(--color-text-primary);
  vertical-align: top;
  border-right: 1px solid var(--color-divider);
  word-break: break-word;
}

.swiss-table tbody td:last-child {
  border-right: none;
}

/* Swiss Lists Alignment & Typography */
.prose ul,
.prose ol,
.swiss-list {
  margin: var(--spacing-sm) 0 var(--spacing-md) 0;
  padding-left: var(--spacing-md);
  font-size: 1.0625rem;
  line-height: 1.6;
}

.prose ul,
.swiss-list {
  list-style-type: square;
}

.prose ol {
  list-style-type: decimal;
  font-feature-settings: "tnum";
}

.prose ul li,
.prose ol li,
.swiss-list li {
  margin-bottom: var(--spacing-xs);
  padding-left: 4px;
  color: var(--color-text-primary);
}

.prose ul li::marker,
.swiss-list li::marker {
  color: var(--color-accent);
}

.prose ol li::marker {
  color: var(--color-text-secondary);
  font-family: var(--font-departure);
  font-weight: 700;
}

/* Reset inner <p> elements generated inside <li> by markdown parsers */
.prose ul li > p,
.prose ol li > p,
.swiss-list li > p {
  margin: 0;
  display: inline;
  font-size: inherit;
  line-height: inherit;
}

/* Swiss Multi-Page Pagination Bar */

/* Pagination Links at bottom of chapters */
.pagination-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--color-text-primary);
  padding-top: var(--spacing-lg);
  margin-top: var(--spacing-xxl);
}

.pagination-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--color-divider);
  background-color: var(--color-card-bg);
  transition: border-color 0.15s ease, 
              background-color 0.15s ease, 
              transform 0.15s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.15s ease;
  max-width: 340px;
}

/* 4-Corner Registration Marks (Matching code block textboxes) */
.pagination-btn::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  height: 6px;
  pointer-events: none;
  background: 
    linear-gradient(var(--color-text-secondary), var(--color-text-secondary)) top left / 6px 1px no-repeat,
    linear-gradient(var(--color-text-secondary), var(--color-text-secondary)) top left / 1px 6px no-repeat,
    linear-gradient(var(--color-text-secondary), var(--color-text-secondary)) top right / 6px 1px no-repeat,
    linear-gradient(var(--color-text-secondary), var(--color-text-secondary)) top right / 1px 6px no-repeat;
  opacity: 0.5;
  z-index: 2;
}

.pagination-btn::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: -1px;
  right: -1px;
  height: 6px;
  pointer-events: none;
  background: 
    linear-gradient(var(--color-text-secondary), var(--color-text-secondary)) bottom left / 6px 1px no-repeat,
    linear-gradient(var(--color-text-secondary), var(--color-text-secondary)) bottom left / 1px 6px no-repeat,
    linear-gradient(var(--color-text-secondary), var(--color-text-secondary)) bottom right / 6px 1px no-repeat,
    linear-gradient(var(--color-text-secondary), var(--color-text-secondary)) bottom right / 1px 6px no-repeat;
  opacity: 0.5;
  z-index: 2;
}

/* Directional Red Accent Borders on Hover */
.pagination-btn.prev-btn {
  border: 1px solid var(--color-divider);
}

.pagination-btn.prev-btn:hover {
  border-color: var(--color-text-primary);
  border-left-color: var(--color-accent);
  background-color: var(--color-hover-bg);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pagination-btn.next-btn {
  align-items: flex-end;
  text-align: right;
  border: 1px solid var(--color-divider);
}

.pagination-btn.next-btn:hover {
  border-color: var(--color-text-primary);
  border-right-color: var(--color-accent);
  background-color: var(--color-hover-bg);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pagination-label {
  font-family: var(--font-departure);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--color-accent);
  margin-bottom: 4px;
}

.nav-arrow {
  display: inline-block;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.prev-btn:hover .nav-arrow {
  transform: translateX(-4px);
}

.next-btn:hover .nav-arrow {
  transform: translateX(4px);
}

.pagination-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text-primary);
}

.pagination-placeholder {
  width: 1px;
}

/* Footer Styles */
.site-footer {
  border-top: 1px solid var(--color-divider);
  padding: var(--spacing-lg) 0;
  background-color: var(--color-bg);
  margin-top: auto;
}

.footer-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  font-family: var(--font-departure);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
}

.footer-left {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  flex-wrap: wrap;
}

.footer-author {
  color: var(--color-text-primary);
  font-weight: 700;
}

.footer-socials {
  display: flex;
  align-items: center;
  gap: 12px;
}

.footer-social-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  opacity: 0.75;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.footer-social-icon:hover {
  opacity: 1;
  transform: translateY(-2px);
}

.footer-social-icon img {
  width: 18px;
  height: 18px;
  filter: var(--icon-filter);
}

.sidebar-overlay {
  display: none;
}

/* Responsive Breakpoints */
@media (max-width: 1199px) {
  .layout-container {
    padding: var(--spacing-md) var(--spacing-sm);
  }

  .on-this-page-sidebar {
    display: none;
  }

  .sidebar {
    grid-column: 1 / 4;
  }

  .content-wrapper {
    grid-column: 4 / 13;
  }

  .mobile-on-this-page {
    display: block;
  }
}

@media (max-width: 768px) {
  .site-header {
    height: 56px;
  }

  .layout-container {
    display: block;
    padding: var(--spacing-md) var(--spacing-sm);
  }

  .sidebar {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    background-color: var(--color-bg);
    border-right: none;
    z-index: 1000;
    padding: var(--spacing-md) var(--spacing-lg) var(--spacing-xl);
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  body.drawer-open {
    overflow: hidden;
  }

  .sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--color-text-primary);
    padding-bottom: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
  }

  .close-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--color-divider);
    color: var(--color-text-primary);
    cursor: pointer;
    border-radius: 0;
    transition: background-color 0.15s ease, border-color 0.15s ease;
  }

  .close-menu-btn:hover,
  .close-menu-btn:focus-visible {
    background-color: var(--color-hover-bg);
    border-color: var(--color-text-primary);
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
  }

  .mobile-menu-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    z-index: 1100;
    border-radius: 0;
  }

  .mobile-menu-btn:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
  }

  .menu-icon-line {
    width: 100%;
    height: 2px;
    background-color: var(--color-text-primary);
    display: block;
    border-radius: 0;
  }

  .content-wrapper {
    width: 100%;
  }

  .header-meta {
    display: none;
  }

  .pagination-nav {
    flex-direction: column;
    gap: var(--spacing-sm);
  }

  .pagination-btn {
    width: 100%;
    align-items: flex-start !important;
    text-align: left !important;
  }

  h1 {
    font-size: 2.25rem;
    line-height: 2.75rem;
  }

  h2 {
    font-size: 1.75rem;
    line-height: 2.25rem;
  }
}

/* Accessibility: Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Diagram & Custom Flow Components */
.flowchart {
  margin: var(--spacing-md) 0;
  padding: var(--spacing-md);
  background: var(--color-card-bg);
  border: 1px solid var(--color-border-subtle);
  border-radius: 8px;
  overflow-x: auto;
}

.flow-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  flex-wrap: nowrap;
}

.flow-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  background: var(--color-bg);
  border: 1px solid var(--color-border-subtle);
  border-radius: 8px;
  min-width: 100px;
  text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: default;
}

.flow-node:hover {
  border-color: var(--color-accent);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.flow-node-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 14px;
}

.flow-node-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-primary);
  letter-spacing: -0.01em;
}

.flow-node-desc {
  font-size: 11px;
  color: var(--color-text-secondary);
  line-height: 1.3;
}

.flow-arrow {
  display: flex;
  align-items: center;
  padding: 0 4px;
  color: var(--color-text-secondary);
  flex-shrink: 0;
}

.flow-arrow svg {
  width: 24px;
  height: 24px;
}

.flow-node.plan .flow-node-icon {
  background: var(--color-code-bg);
  color: var(--color-accent);
}

.flow-node.exec .flow-node-icon {
  background: var(--color-code-bg);
  color: var(--color-text-primary);
}

.flow-node.review .flow-node-icon {
  background: var(--color-code-bg);
  color: var(--color-text-secondary);
}

.flow-node.info .flow-node-icon {
  background: var(--color-code-bg);
  color: var(--color-text-primary);
}

.tdd-cycle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: var(--spacing-md) 0;
  padding: 16px;
  background: var(--color-code-bg);
  border: 1px solid var(--color-divider);
  border-radius: 0;
}

.tdd-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px;
  text-align: center;
  flex: 1;
  background: var(--color-card-bg);
  border: 1px solid var(--color-divider);
  border-radius: 0;
}

.tdd-circle {
  width: 36px;
  height: 36px;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-departure);
  font-size: 14px;
  font-weight: 700;
  border: 2px solid;
}

.tdd-step.red .tdd-circle {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
  color: #ef4444;
}

.tdd-step.green .tdd-circle {
  background: rgba(16, 185, 129, 0.1);
  border-color: #10b981;
  color: #10b981;
}

.tdd-step.refactor .tdd-circle {
  background: var(--color-code-bg);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.tdd-label {
  font-family: var(--font-departure);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--color-text-primary);
}

.tdd-desc {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-secondary);
  line-height: 1.4;
}

.tdd-arrow {
  color: var(--color-accent);
  flex-shrink: 0;
  padding: 0 4px;
  display: flex;
  align-items: center;
}

.tdd-arrow svg {
  width: 20px;
  height: 20px;
}

.tier-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 20px 0;
}

.tier-card {
  padding: 20px;
  border: 1px solid var(--color-border-subtle);
  border-radius: 8px;
  background: var(--color-card-bg);
}

.tier-card h4 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  margin-top: 0;
}

.tier-card.frontier h4 {
  color: var(--color-accent);
}

.tier-card.cheap h4 {
  color: var(--color-text-primary);
}

.tier-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tier-card li {
  font-size: 14px;
  padding: 4px 0;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-divider);
}

.tier-card li:last-child {
  border-bottom: none;
}

.tier-card li strong {
  color: var(--color-text-primary);
  font-weight: 500;
}

.daily-loop {
  margin: var(--spacing-md) 0;
  padding: var(--spacing-md);
  background: var(--color-card-bg);
  border: 1px solid var(--color-border-subtle);
  border-radius: 8px;
}

.loop-step {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-divider);
}

.loop-step:last-child {
  border-bottom: none;
}

.loop-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  border: 1px solid var(--color-border-subtle);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-secondary);
}

.loop-content {
  flex: 1;
}

.loop-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
}

.loop-desc {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.loop-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

.loop-tag.frontier {
  background: var(--color-code-bg);
  color: var(--color-accent);
}

.loop-tag.cheap {
  background: var(--color-code-bg);
  color: var(--color-text-primary);
}

.quick-ref {
  margin: var(--spacing-md) 0;
  padding: var(--spacing-md);
  background: var(--color-card-bg);
  border: 1px solid var(--color-border-subtle);
  border-radius: 8px;
}

.quick-ref-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.quick-ref-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--color-border-subtle);
  border-radius: 8px;
  font-size: 13px;
  text-decoration: none;
  color: var(--color-text-primary);
  transition: border-color 0.15s, background 0.15s;
}

.quick-ref-item:hover {
  border-color: var(--color-accent);
  background: var(--color-hover-bg);
}

.quick-ref-num {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-text-primary);
  color: var(--color-bg);
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .tier-grid, .quick-ref-grid {
    grid-template-columns: 1fr;
  }
  .flow-row {
    flex-wrap: wrap;
    justify-content: center;
  }
  .flow-arrow {
    transform: rotate(90deg);
    padding: 4px 0;
  }
  .tdd-cycle {
    flex-direction: column;
  }
  .tdd-arrow {
    transform: rotate(90deg);
    padding: 4px 0;
  }
}

/* ==========================================================================
   PIXEL ART ICONOGRAPHY & MICRO-INTERACTION STYLES
   ========================================================================== */

.pixel-icon {
  display: inline-block;
  vertical-align: middle;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  shape-rendering: crispEdges;
  flex-shrink: 0;
}

/* Header Audio Sound Toggle Button */
.audio-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-code-bg);
  border: 1px solid var(--color-divider);
  color: var(--color-text-primary);
  font-family: var(--font-departure);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 5px 10px;
  cursor: pointer;
  border-radius: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.08s ease;
}

.audio-toggle-btn:hover {
  background-color: var(--color-hover-bg);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.audio-toggle-btn:active {
  transform: scale(0.96);
}

.audio-toggle-btn.muted {
  opacity: 0.6;
  border-style: dashed;
}

.audio-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Swiss Callout Box with Pixel Icon */
.swiss-callout {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: var(--spacing-md) 0;
  padding: 14px 16px;
  background: var(--color-card-bg);
  border: 1px solid var(--color-divider);
  border-left: 4px solid var(--color-accent);
  border-radius: 0;
}

.swiss-callout.callout-warning {
  border-left-color: #ef4444;
}

.swiss-callout.callout-tip {
  border-left-color: #10b981;
}

.callout-icon-col {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 2px;
  color: var(--color-accent);
}

.swiss-callout.callout-warning .callout-icon-col {
  color: #ef4444;
}

.swiss-callout.callout-tip .callout-icon-col {
  color: #10b981;
}

.callout-body {
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.5;
}

.callout-body p:first-child {
  margin-top: 0;
}

.callout-body p:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   INTERACTIVE SPRING-PHYSICS FLOWCHART & DIRECTIONAL ANIMATED PATHS
   ========================================================================== */

.interactive-flowchart-wrapper {
  margin: var(--spacing-lg) 0;
  border: 1px solid var(--color-divider);
  background: var(--color-code-bg);
  padding: 20px 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.flowchart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--color-divider);
  font-family: var(--font-departure);
}

.flowchart-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-accent);
  text-transform: uppercase;
}

.flowchart-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.flowchart-zoom-level {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--color-text-secondary);
  min-width: 42px;
  text-align: center;
  font-weight: 600;
  user-select: none;
}

.flowchart-btn {
  background: var(--color-card-bg);
  border: 1px solid var(--color-divider);
  color: var(--color-text-primary);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 2px;
  cursor: pointer;
  line-height: 1;
  transition: all 0.15s ease;
  user-select: none;
}

.flowchart-btn:hover {
  background: var(--color-accent);
  color: #ffffff;
  border-color: var(--color-accent);
}

.flowchart-btn:active {
  transform: translateY(1px);
}

.interactive-flowchart {
  width: 100%;
  height: auto;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  cursor: grab;
}

.interactive-flowchart.panning {
  cursor: grabbing;
}

/* Flowchart Connectors & Arrowhead */
.flow-path-bg {
  stroke: var(--color-divider);
  stroke-width: 2px;
  fill: none;
}

.flow-path {
  stroke: var(--color-accent);
  stroke-width: 2.5px;
  stroke-dasharray: 6 4;
  animation: flowDash 0.75s linear infinite;
  fill: none;
  transition: stroke 0.15s ease;
}

@keyframes flowDash {
  from {
    stroke-dashoffset: 20;
  }
  to {
    stroke-dashoffset: 0;
  }
}

.interactive-flowchart marker path,
#pixel-arrowhead path {
  fill: var(--color-accent);
}

/* Flowchart Draggable Nodes */
.flow-node-group {
  cursor: grab;
  user-select: none;
  will-change: transform;
}

.flow-node-group.dragging {
  cursor: grabbing;
}

.flow-node-box {
  fill: var(--color-card-bg);
  stroke: var(--color-accent);
  stroke-width: 2px;
  rx: 2px;
  transition: fill 0.15s ease, stroke-width 0.15s ease, filter 0.15s ease;
}

.flow-node-group:hover .flow-node-box,
.flow-node-group.dragging .flow-node-box {
  fill: var(--color-accent);
  stroke: var(--color-text-primary);
  stroke-width: 2.5px;
}

.flow-node-text {
  font-family: var(--font-departure);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  fill: var(--color-text-primary);
  pointer-events: none;
  text-anchor: middle;
  transition: fill 0.15s ease;
}

.flow-node-text tspan {
  dominant-baseline: central;
  text-anchor: middle;
}

.flow-node-group:hover .flow-node-text,
.flow-node-group.dragging .flow-node-text {
  fill: #ffffff;
}

@media (max-width: 768px) {
  .flowchart-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}


