/* ═══════════════════════════════════════════════════════════════════════════
   DESIGN INTELLIGENCE — When Figma Learns to See
   
   A scrollytelling journey through intelligent design automation.
   For PMs and designers who believe in magic.
   
   h(x) ≥ 0
═══════════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════════════
   DESIGN TOKENS
═══════════════════════════════════════════════════════════════════════════ */

:root {
    /* ─────────────────────────────────────────────────────────────────────
       VOID SCALE — Backgrounds (darkest to lightest)
    ───────────────────────────────────────────────────────────────────── */
    --void-deepest: #030305;
    --void: #07060B;
    --void-warm: #0d0c14;
    --obsidian: #12101A;
    --obsidian-light: #1a1826;
    --obsidian-lighter: #232030;
    
    /* ─────────────────────────────────────────────────────────────────────
       LIGHT SCALE — Text and accents
    ───────────────────────────────────────────────────────────────────── */
    --light: #F8F6F2;
    --light-dim: rgba(248, 246, 242, 0.85);
    --light-faint: rgba(248, 246, 242, 0.6);
    --light-ghost: rgba(248, 246, 242, 0.3);
    --light-whisper: rgba(248, 246, 242, 0.15);
    --light-breath: rgba(248, 246, 242, 0.08);
    
    /* ─────────────────────────────────────────────────────────────────────
       FIGMA BRAND — Primary palette
    ───────────────────────────────────────────────────────────────────── */
    --figma-red: #F24E1E;
    --figma-orange: #FF7262;
    --figma-purple: #A259FF;
    --figma-blue: #1ABCFE;
    --figma-green: #0ACF83;
    
    /* Figma brand with alpha */
    --figma-purple-20: rgba(162, 89, 255, 0.2);
    --figma-purple-10: rgba(162, 89, 255, 0.1);
    --figma-purple-05: rgba(162, 89, 255, 0.05);
    --figma-blue-20: rgba(26, 188, 254, 0.2);
    --figma-blue-10: rgba(26, 188, 254, 0.1);
    --figma-green-20: rgba(10, 207, 131, 0.2);
    --figma-green-10: rgba(10, 207, 131, 0.1);
    
    /* ─────────────────────────────────────────────────────────────────────
       COLONY COLORS — Kagami accent palette
    ───────────────────────────────────────────────────────────────────── */
    --spark: #FF6B35;
    --forge: #D4AF37;
    --flow: #4ECDC4;
    --nexus: #9B7EBD;
    --beacon: #F59E0B;
    --grove: #7EB77F;
    --crystal: #67D4E4;
    
    /* ─────────────────────────────────────────────────────────────────────
       STATUS COLORS — Semantic
    ───────────────────────────────────────────────────────────────────── */
    --success: #22C55E;
    --success-dim: rgba(34, 197, 94, 0.2);
    --warning: #F59E0B;
    --warning-dim: rgba(245, 158, 11, 0.2);
    --error: #EF4444;
    --error-dim: rgba(239, 68, 68, 0.2);
    --info: #3B82F6;
    --info-dim: rgba(59, 130, 246, 0.2);
    
    /* ─────────────────────────────────────────────────────────────────────
       GLASS MORPHISM — Overlays and cards
    ───────────────────────────────────────────────────────────────────── */
    --glass-bg: rgba(255, 255, 255, 0.02);
    --glass-bg-hover: rgba(255, 255, 255, 0.04);
    --glass-bg-active: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-hover: rgba(255, 255, 255, 0.12);
    --glass-border-active: rgba(255, 255, 255, 0.16);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --glass-shadow-hover: 0 16px 48px rgba(0, 0, 0, 0.4);
    --glass-blur: blur(20px);
    
    /* ─────────────────────────────────────────────────────────────────────
       GRADIENTS — Complex backgrounds
    ───────────────────────────────────────────────────────────────────── */
    --gradient-figma: linear-gradient(135deg, var(--figma-purple), var(--figma-blue));
    --gradient-figma-reverse: linear-gradient(135deg, var(--figma-blue), var(--figma-purple));
    --gradient-success: linear-gradient(135deg, #14532d, var(--success));
    --gradient-warning: linear-gradient(135deg, #78350f, var(--warning));
    --gradient-error: linear-gradient(135deg, #7f1d1d, var(--error));
    --gradient-glow: radial-gradient(ellipse 80% 60% at 50% 50%, var(--figma-purple-10) 0%, transparent 70%);
    --gradient-hero: radial-gradient(ellipse 100% 80% at 50% 0%, var(--figma-purple-10) 0%, transparent 50%),
                     radial-gradient(ellipse 80% 60% at 50% 100%, rgba(78, 205, 196, 0.05) 0%, transparent 50%);
    
    /* ─────────────────────────────────────────────────────────────────────
       TYPOGRAPHY — Font stacks
    ───────────────────────────────────────────────────────────────────── */
    --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'IBM Plex Mono', 'SF Mono', 'Fira Code', monospace;
    --font-display: var(--font-body);
    
    /* ─────────────────────────────────────────────────────────────────────
       TYPOGRAPHY — Size scale (fluid)
    ───────────────────────────────────────────────────────────────────── */
    --text-hero: clamp(3.5rem, 12vw, 7rem);
    --text-chapter: clamp(2rem, 6vw, 4rem);
    --text-section: clamp(1.5rem, 4vw, 2.5rem);
    --text-large: clamp(1.125rem, 2vw, 1.25rem);
    --text-body: 1rem;
    --text-small: 0.875rem;
    --text-micro: 0.75rem;
    --text-nano: 0.65rem;
    
    /* ─────────────────────────────────────────────────────────────────────
       TYPOGRAPHY — Line heights
    ───────────────────────────────────────────────────────────────────── */
    --leading-none: 1;
    --leading-tight: 1.1;
    --leading-snug: 1.3;
    --leading-normal: 1.7;
    --leading-relaxed: 1.9;
    --leading-loose: 2;
    
    /* ─────────────────────────────────────────────────────────────────────
       TYPOGRAPHY — Letter spacing
    ───────────────────────────────────────────────────────────────────── */
    --tracking-tighter: -0.02em;
    --tracking-tight: -0.01em;
    --tracking-normal: 0;
    --tracking-wide: 0.05em;
    --tracking-wider: 0.1em;
    --tracking-widest: 0.2em;
    
    /* ─────────────────────────────────────────────────────────────────────
       SPACING — 8px grid system
    ───────────────────────────────────────────────────────────────────── */
    --space-1: 0.25rem;   /* 4px */
    --space-2: 0.5rem;    /* 8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.25rem;   /* 20px */
    --space-6: 1.5rem;    /* 24px */
    --space-8: 2rem;      /* 32px */
    --space-10: 2.5rem;   /* 40px */
    --space-12: 3rem;     /* 48px */
    --space-16: 4rem;     /* 64px */
    --space-20: 5rem;     /* 80px */
    --space-24: 6rem;     /* 96px */
    --space-32: 8rem;     /* 128px */
    
    /* ─────────────────────────────────────────────────────────────────────
       MOTION — Fibonacci timing (ms)
    ───────────────────────────────────────────────────────────────────── */
    --dur-micro: 89ms;      /* Hover states, toggles */
    --dur-fast: 144ms;      /* Buttons, small interactions */
    --dur-normal: 233ms;    /* Cards, reveals */
    --dur-medium: 377ms;    /* Section transitions */
    --dur-slow: 610ms;      /* Hero animations */
    --dur-dramatic: 987ms;  /* Scene changes */
    --dur-epic: 1597ms;     /* Major transitions */
    --dur-stagger: 55ms;    /* Stagger delay base */
    
    /* ─────────────────────────────────────────────────────────────────────
       MOTION — Easings
    ───────────────────────────────────────────────────────────────────── */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --ease-bounce: cubic-bezier(0.68, -0.2, 0.32, 1.2);
    --ease-elastic: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    
    /* ─────────────────────────────────────────────────────────────────────
       LAYOUT — Containers and breakpoints
    ───────────────────────────────────────────────────────────────────── */
    --container-sm: 640px;
    --container-md: 768px;
    --container-lg: 1024px;
    --container-xl: 1280px;
    --container-prose: 65ch;
    
    /* ─────────────────────────────────────────────────────────────────────
       BORDERS & RADIUS
    ───────────────────────────────────────────────────────────────────── */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 24px;
    --radius-full: 9999px;
    
    /* ─────────────────────────────────────────────────────────────────────
       Z-INDEX SCALE
    ───────────────────────────────────────────────────────────────────── */
    --z-base: 1;
    --z-above: 10;
    --z-modal: 100;
    --z-overlay: 200;
    --z-toast: 300;
    --z-tooltip: 400;
    --z-max: 9999;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════════════════════════════════ */

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    height: 100%;
    /* Overscroll background - visible when pulling down */
    background: var(--void-deepest);
    background-image: 
        radial-gradient(ellipse 60% 40% at 30% -10%, rgba(162, 89, 255, 0.15) 0%, transparent 60%),
        radial-gradient(ellipse 50% 30% at 70% -5%, rgba(78, 205, 196, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse 40% 25% at 50% -15%, rgba(26, 188, 254, 0.1) 0%, transparent 40%);
}

body {
    font-family: var(--font-body);
    font-size: var(--text-body);
    line-height: var(--leading-normal);
    background: var(--void);
    color: var(--light);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100%;
}

/* Animated overscroll reveal zone */
body::before {
    content: '';
    position: fixed;
    top: -200px;
    left: 0;
    right: 0;
    height: 200px;
    background: 
        radial-gradient(circle 80px at 25% 80%, rgba(162, 89, 255, 0.3) 0%, transparent 70%),
        radial-gradient(circle 60px at 50% 60%, rgba(78, 205, 196, 0.25) 0%, transparent 60%),
        radial-gradient(circle 40px at 75% 90%, rgba(26, 188, 254, 0.2) 0%, transparent 50%);
    pointer-events: none;
    z-index: 1;
    animation: overscrollPulse 4s ease-in-out infinite;
}

@keyframes overscrollPulse {
    0%, 100% { 
        opacity: 0.8;
        transform: translateY(0);
    }
    50% { 
        opacity: 1;
        transform: translateY(10px);
    }
}

/* Loading state - hide content until loaded */
body.loading {
    overflow: hidden;
}

/* Use visibility instead of opacity to prevent flicker */
body.loading > *:not(.loading-screen) {
    visibility: hidden;
    opacity: 0;
}

/* Disable grain during load to prevent flicker */
body.loading .grain-overlay {
    display: none;
}

/* Smooth content reveal after loading */
body:not(.loading) > * {
    visibility: visible;
    opacity: 1;
    transition: opacity var(--dur-medium) var(--ease-out);
}

::selection {
    background: var(--figma-purple);
    color: var(--void);
}

/* Focus visible for keyboard users */
:focus-visible {
    outline: 2px solid var(--figma-purple);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ACCESSIBILITY
═══════════════════════════════════════════════════════════════════════════ */

.skip-link {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-4) var(--space-6);
    background: var(--light);
    color: var(--void);
    font-weight: 600;
    text-decoration: none;
    z-index: var(--z-max);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    transition: top var(--dur-normal) var(--ease-out);
}

.skip-link:focus {
    top: 0;
}

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

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .particle,
    .magic-spark,
    .scroll-line,
    .flow-packet {
        display: none;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   LOADING SCREEN
═══════════════════════════════════════════════════════════════════════════ */

.loading-screen {
    position: fixed;
    inset: 0;
    background: var(--void);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: var(--z-max);
    will-change: opacity, visibility;
    transition: opacity var(--dur-slow) var(--ease-out),
                visibility var(--dur-slow);
    overflow: visible;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-logo {
    width: 120px;
    height: 180px;
    position: relative;
    will-change: transform;
    animation: logoPulse 2s ease-in-out infinite;
    overflow: visible;
}

@keyframes logoPulse {
    0%, 100% { 
        filter: drop-shadow(0 0 30px rgba(162, 89, 255, 0.4));
        transform: scale(1);
    }
    50% { 
        filter: drop-shadow(0 0 50px rgba(162, 89, 255, 0.7));
        transform: scale(1.03);
    }
}

.loading-logo svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* Figma logo pieces animate in sequence with dramatic effect */
.logo-piece {
    opacity: 0;
    transform-origin: center center;
    will-change: transform, opacity;
    animation: logoAssemble 600ms var(--ease-spring) forwards;
}

.logo-piece:nth-child(1) { animation-delay: 100ms; }
.logo-piece:nth-child(2) { animation-delay: 200ms; }
.logo-piece:nth-child(3) { animation-delay: 300ms; }
.logo-piece:nth-child(4) { animation-delay: 400ms; }
.logo-piece:nth-child(5) { animation-delay: 500ms; }

@keyframes logoAssemble {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(40px) rotate(-15deg);
    }
    50% {
        opacity: 1;
        transform: scale(1.15) translateY(-8px) rotate(3deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0) rotate(0deg);
    }
}

.loading-text {
    margin-top: var(--space-8);
    font-family: var(--font-mono);
    font-size: var(--text-small);
    color: var(--light-dim);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    opacity: 0;
    animation: fadeInUp var(--dur-normal) var(--ease-out) 0.5s forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.loading-progress {
    width: 200px;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    margin-top: var(--space-8);
    overflow: hidden;
    opacity: 0;
    animation: fadeIn var(--dur-normal) var(--ease-out) 0.7s forwards;
}

.loading-progress-bar {
    height: 100%;
    background: var(--gradient-figma);
    width: 0%;
    transition: width 100ms linear;
    box-shadow: 0 0 12px var(--figma-purple), 0 0 24px rgba(162, 89, 255, 0.3);
    border-radius: var(--radius-full);
}

/* ═══════════════════════════════════════════════════════════════════════════
   BACKGROUND LAYERS
═══════════════════════════════════════════════════════════════════════════ */

#design-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-base);
    pointer-events: none;
}

.gradient-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gradient-hero);
    z-index: calc(var(--z-base) + 1);
    pointer-events: none;
}

/* Film grain texture */
/* Film grain - extremely subtle texture overlay */
.grain-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.5' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.004;
    z-index: calc(var(--z-base) + 2);
    pointer-events: none;
    mix-blend-mode: overlay;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PROGRESS BAR
═══════════════════════════════════════════════════════════════════════════ */

#progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: var(--gradient-figma);
    width: 0%;
    z-index: var(--z-overlay);
    transition: width var(--dur-micro) linear;
    box-shadow: 0 0 20px var(--figma-purple),
                0 0 40px var(--figma-purple-20);
}

#progress-bar::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 100px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   CHAPTER NAVIGATION
═══════════════════════════════════════════════════════════════════════════ */

#chapter-nav {
    position: fixed;
    right: var(--space-8);
    top: 50%;
    transform: translateY(-50%);
    z-index: var(--z-overlay);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.chapter-dot {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    position: relative;
    padding: 0;
    transition: transform var(--dur-fast) var(--ease-out);
}

.chapter-dot:hover {
    transform: scale(1.1);
}

.chapter-dot::before {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    background: var(--light-ghost);
    border: 1px solid var(--glass-border);
    transition: all var(--dur-normal) var(--ease-out);
}

.chapter-dot:hover::before {
    background: var(--light-faint);
    transform: scale(1.3);
    border-color: var(--light-faint);
}

.chapter-dot.active::before {
    background: var(--figma-purple);
    border-color: var(--figma-purple);
    box-shadow: 0 0 15px var(--figma-purple),
                0 0 30px var(--figma-purple-20);
    transform: scale(1.2);
}

.chapter-dot::after {
    content: attr(data-label);
    position: absolute;
    right: 54px;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-mono);
    font-size: var(--text-micro);
    color: var(--light-dim);
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--dur-normal) var(--ease-out),
                transform var(--dur-normal) var(--ease-out);
    pointer-events: none;
    padding: var(--space-1) var(--space-2);
    background: var(--obsidian);
    border-radius: var(--radius-sm);
    transform: translateY(-50%) translateX(10px);
}

.chapter-dot:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* ═══════════════════════════════════════════════════════════════════════════
   OVERTURE / HERO
═══════════════════════════════════════════════════════════════════════════ */

.overture {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: var(--z-above);
    padding: var(--space-16) var(--space-8);
    text-align: center;
}

.overture-content {
    max-width: 900px;
    width: 100%;
    text-align: center;
}

/* Gradient orb behind title */
.hero-orb {
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--figma-purple-20) 0%, transparent 70%);
    border-radius: var(--radius-full);
    filter: blur(60px);
    z-index: -1;
    animation: orbFloat 20s ease-in-out infinite;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    25% { transform: translate(-45%, -55%) scale(1.05); }
    50% { transform: translate(-50%, -50%) scale(0.95); }
    75% { transform: translate(-55%, -45%) scale(1.02); }
}

.overture-eyebrow {
    font-family: var(--font-mono);
    font-size: var(--text-small);
    color: var(--figma-purple);
    text-transform: uppercase;
    letter-spacing: var(--tracking-widest);
    margin-bottom: var(--space-8);
    opacity: 0;
    animation: fadeInUp var(--dur-dramatic) var(--ease-out) 0.2s forwards;
}

.overture-title {
    font-size: var(--text-hero);
    font-weight: 300;
    line-height: var(--leading-snug); /* Increased to prevent descender clipping */
    margin-bottom: var(--space-6);
    letter-spacing: var(--tracking-tight);
    overflow: visible; /* Ensure descenders aren't clipped */
}

.title-word {
    display: block;
    opacity: 0;
    animation: titleReveal var(--dur-dramatic) var(--ease-out) forwards;
    padding-bottom: 0.1em; /* Extra space for descenders */
}

.title-word:nth-child(1) { animation-delay: 0.3s; }
.title-word:nth-child(2) { 
    animation-delay: 0.5s; 
    background: var(--gradient-figma);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

@keyframes titleReveal {
    0% {
        opacity: 0;
        transform: translateY(30px);
        filter: blur(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

.overture-subtitle {
    font-size: var(--text-large);
    color: var(--light-dim);
    margin-bottom: var(--space-12);
    opacity: 0;
    animation: fadeInUp var(--dur-dramatic) var(--ease-out) 0.7s forwards;
}

.overture-meta {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-6);
    flex-wrap: wrap;
    font-family: var(--font-mono);
    font-size: var(--text-small);
    color: var(--light-faint);
    opacity: 0;
    animation: fadeInUp var(--dur-dramatic) var(--ease-out) 0.9s forwards;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    transition: all var(--dur-fast) var(--ease-out);
    animation: metaBob 4s ease-in-out infinite;
}

.meta-item:nth-child(1) { animation-delay: 0s; }
.meta-item:nth-child(3) { animation-delay: 0.5s; }
.meta-item:nth-child(5) { animation-delay: 1s; }

@keyframes metaBob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.meta-item:hover {
    background: var(--glass-bg-hover);
    border-color: var(--figma-purple-20);
    transform: translateY(-2px);
}

.meta-icon {
    color: var(--figma-purple);
}

.meta-divider {
    color: var(--light-ghost);
    display: none;
}

/* Scroll indicator */
.scroll-indicator {
    position: absolute;
    bottom: var(--space-12);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    opacity: 0;
    animation: fadeIn var(--dur-dramatic) var(--ease-out) 1.4s forwards;
    cursor: pointer;
    transition: transform var(--dur-fast) var(--ease-out);
}

.scroll-indicator:hover {
    transform: translateX(-50%) translateY(-4px);
}

.scroll-line {
    width: 1px;
    height: 60px;
    background: linear-gradient(to bottom, var(--light-ghost), transparent);
    position: relative;
    overflow: hidden;
}

.scroll-line::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 20px;
    background: var(--light);
    animation: scrollPulse 2s ease-in-out infinite;
}

@keyframes scrollPulse {
    0% { transform: translateY(-20px); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translateY(60px); opacity: 0; }
}

.scroll-text {
    font-family: var(--font-mono);
    font-size: var(--text-nano);
    color: var(--light-ghost);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
}

/* ═══════════════════════════════════════════════════════════════════════════
   CHAPTERS — General
═══════════════════════════════════════════════════════════════════════════ */

.chapter {
    min-height: 100vh;
    min-height: 100dvh;
    padding: var(--space-24) var(--space-8);
    position: relative;
    z-index: var(--z-above);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chapter-header {
    text-align: center;
    margin-bottom: var(--space-12);
    max-width: 700px;
    opacity: 0;
    transform: translateY(30px);
    transition: all var(--dur-slow) var(--ease-out);
}

.chapter-header.visible {
    opacity: 1;
    transform: translateY(0);
}

.chapter-number {
    font-family: var(--font-mono);
    font-size: var(--text-small);
    color: var(--figma-purple);
    text-transform: uppercase;
    letter-spacing: var(--tracking-widest);
    margin-bottom: var(--space-3);
    display: inline-block;
    padding: var(--space-1) var(--space-3);
    background: var(--figma-purple-10);
    border-radius: var(--radius-sm);
}

.chapter-title {
    font-size: var(--text-chapter);
    font-weight: 300;
    margin-bottom: var(--space-4);
    letter-spacing: var(--tracking-tight);
}

.chapter-description {
    font-size: var(--text-large);
    color: var(--light-dim);
    line-height: var(--leading-relaxed);
}

.chapter-content {
    max-width: 1100px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ═══════════════════════════════════════════════════════════════════════════
   THE GAP — Problem visualization
═══════════════════════════════════════════════════════════════════════════ */

.gap-chapter {
    justify-content: center;
}

.gap-visualization {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    margin-bottom: var(--space-16);
    flex-wrap: wrap;
    perspective: 1000px;
}

.gap-side {
    text-align: center;
    padding: var(--space-10);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    min-width: 220px;
    transition: all var(--dur-medium) var(--ease-out);
    transform-style: preserve-3d;
    cursor: pointer;
}

.gap-side:hover {
    background: var(--glass-bg-hover);
    border-color: var(--glass-border-hover);
    transform: translateY(-8px) rotateX(5deg);
    box-shadow: var(--glass-shadow-hover);
}

.design-side:hover {
    border-color: var(--figma-purple-20);
}

.code-side:hover {
    border-color: var(--figma-blue-20);
}

.gap-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-4);
    position: relative;
}

.gap-icon svg {
    width: 100%;
    height: 100%;
    transition: transform var(--dur-medium) var(--ease-out);
}

.gap-side:hover .gap-icon svg {
    transform: scale(1.1);
}

.design-side .gap-icon {
    color: var(--figma-purple);
}

.code-side .gap-icon {
    color: var(--flow);
}

.gap-label {
    font-size: var(--text-section);
    font-weight: 500;
    margin-bottom: var(--space-2);
}

.gap-desc {
    font-size: var(--text-small);
    color: var(--light-faint);
}

/* The chasm between design and code */
.gap-chasm {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-8) var(--space-4);
    position: relative;
}

.chasm-line {
    width: 80px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--error), transparent);
    position: relative;
    overflow: hidden;
}

.chasm-line::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    animation: glitch 2s linear infinite;
}

@keyframes glitch {
    0%, 100% { left: -100%; }
    50% { left: 100%; }
}

.chasm-label {
    font-family: var(--font-mono);
    font-size: var(--text-micro);
    color: var(--error);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    padding: var(--space-1) var(--space-3);
    background: var(--error-dim);
    border-radius: var(--radius-sm);
    animation: chasmPulse 2s ease-in-out infinite;
}

@keyframes chasmPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Stats */
.gap-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-10);
    max-width: 700px;
    width: 100%;
}

@media (max-width: 640px) {
    .gap-stats {
        grid-template-columns: 1fr;
        max-width: 280px;
    }
}

.stat-card {
    text-align: center;
    padding: var(--space-6);
    background: var(--glass-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    transition: all var(--dur-medium) var(--ease-out);
}

.stat-card:hover {
    background: var(--glass-bg-hover);
    transform: translateY(-4px);
    border-color: var(--figma-purple-20);
}

.stat-number {
    display: block;
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: 300;
    background: var(--gradient-figma);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: var(--leading-none);
    margin-bottom: var(--space-3);
}

.stat-label {
    font-size: var(--text-small);
    color: var(--light-faint);
}

/* Quote */
.gap-quote {
    max-width: 600px;
    text-align: center;
    padding: var(--space-8) var(--space-6);
    position: relative;
}

.gap-quote::before,
.gap-quote::after {
    font-size: 4rem;
    color: var(--figma-purple-20);
    font-family: Georgia, serif;
    line-height: 1;
    position: absolute;
}

.gap-quote::before {
    content: '"';
    top: 0;
    left: 0;
}

.gap-quote::after {
    content: '"';
    bottom: 0;
    right: 0;
}

.gap-quote p {
    font-size: var(--text-large);
    font-style: italic;
    color: var(--light-dim);
    margin-bottom: var(--space-3);
    position: relative;
    z-index: 1;
}

.gap-quote cite {
    font-family: var(--font-mono);
    font-size: var(--text-small);
    color: var(--light-faint);
    font-style: normal;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FLOW DIAGRAM — Architecture visualization
═══════════════════════════════════════════════════════════════════════════ */

.flow-section {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    padding: var(--space-8) var(--space-4);
    margin-bottom: var(--space-12);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--figma-purple-20) transparent;
}

.flow-section::-webkit-scrollbar {
    height: 6px;
}

.flow-section::-webkit-scrollbar-track {
    background: transparent;
}

.flow-section::-webkit-scrollbar-thumb {
    background: var(--figma-purple-20);
    border-radius: var(--radius-full);
}

.flow-diagram {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    min-width: max-content;
    padding: var(--space-4);
    margin: 0 auto;
}

.flow-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-6);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    min-width: 140px;
    transition: all var(--dur-medium) var(--ease-out);
    cursor: pointer;
    position: relative;
}

.flow-node::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + var(--space-2));
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    padding: var(--space-2) var(--space-3);
    background: var(--obsidian);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: var(--text-nano);
    color: var(--light-dim);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--dur-fast) var(--ease-out);
    z-index: var(--z-tooltip);
}

.flow-node:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.flow-node:hover {
    transform: translateY(-6px);
    border-color: var(--figma-purple);
    box-shadow: 0 12px 40px var(--figma-purple-20);
}

.flow-node.active {
    border-color: var(--figma-purple);
    background: var(--figma-purple-05);
}

.flow-node.active::before {
    content: '';
    position: absolute;
    inset: -4px;
    border: 2px solid var(--figma-purple);
    border-radius: calc(var(--radius-xl) + 4px);
    animation: nodePulse 2s ease-in-out infinite;
}

@keyframes nodePulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 0; transform: scale(1.05); }
}

.node-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    background: var(--glass-bg);
}

.node-icon svg {
    width: 24px;
    height: 24px;
    stroke: var(--figma-purple);
}

.figma-icon {
    color: var(--figma-purple);
}

.webhook-icon {
    color: var(--figma-orange);
}

.brain-icon {
    color: var(--flow);
}

.action-icon-color {
    color: var(--figma-green);
}

.node-label {
    font-family: var(--font-mono);
    font-size: var(--text-small);
    color: var(--light-dim);
    text-align: center;
}

/* Flow arrows with animated packets */
.flow-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    position: relative;
    min-width: 100px;
}

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

.flow-line {
    stroke: var(--light-ghost);
    stroke-width: 2;
    stroke-dasharray: 6 4;
    animation: flowDash 1s linear infinite;
}

@keyframes flowDash {
    0% { stroke-dashoffset: 10; }
    100% { stroke-dashoffset: 0; }
}

.flow-arrowhead {
    fill: var(--figma-purple);
}

/* Data packet animation */
.flow-packet {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--figma-purple);
    border-radius: var(--radius-full);
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    animation: packetMove 2s ease-in-out infinite;
    box-shadow: 0 0 10px var(--figma-purple);
}

@keyframes packetMove {
    0% { left: 0; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { left: calc(100% - 8px); opacity: 0; }
}

.arrow-label {
    font-family: var(--font-mono);
    font-size: var(--text-micro);
    color: var(--light-faint);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    white-space: nowrap;
}

/* Output nodes */
.flow-outputs {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    flex-shrink: 0;
}

.output-node {
    min-width: 110px;
    padding: var(--space-4);
    font-size: var(--text-small);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
}

/* ═══════════════════════════════════════════════════════════════════════════
   CAPABILITY GRID
═══════════════════════════════════════════════════════════════════════════ */

.capability-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-6);
    max-width: 1100px;
    width: 100%;
}

@media (min-width: 1024px) {
    .capability-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.capability-card {
    padding: var(--space-6);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    transition: all var(--dur-medium) var(--ease-out);
    opacity: 0;
    transform: translateY(30px);
    position: relative;
    overflow: hidden;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.capability-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-figma);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--dur-medium) var(--ease-out);
}

.capability-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.capability-card:hover {
    background: var(--glass-bg-hover);
    border-color: var(--glass-border-hover);
    transform: translateY(-6px);
    box-shadow: var(--glass-shadow);
}

.capability-card:hover::before {
    transform: scaleX(1);
}

.capability-icon {
    width: 48px;
    height: 48px;
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--figma-purple-10);
    border-radius: var(--radius-lg);
}

.capability-icon svg {
    width: 24px;
    height: 24px;
    stroke: var(--figma-purple);
}

.capability-card h4 {
    font-size: var(--text-body);
    font-weight: 600;
    margin-bottom: var(--space-2);
    text-align: center;
}

.capability-card p {
    font-size: var(--text-small);
    color: var(--light-faint);
    line-height: var(--leading-relaxed);
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MAGIC CHAPTER — @design-qa demo
═══════════════════════════════════════════════════════════════════════════ */

.magic-demo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-6);
    margin-bottom: var(--space-16);
    max-width: 550px;
    width: 100%;
}

/* Figma comments */
.figma-comment-card {
    width: 100%;
    background: var(--obsidian);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    transition: all var(--dur-medium) var(--ease-out);
}

.figma-comment-card:hover {
    border-color: var(--glass-border-hover);
}

.comment-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--gradient-figma);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-small);
    font-weight: 600;
    flex-shrink: 0;
}

.ai-avatar {
    background: linear-gradient(135deg, var(--flow), var(--crystal));
}

.comment-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.comment-author {
    font-weight: 500;
    font-size: var(--text-body);
}

.comment-time {
    font-size: var(--text-micro);
    color: var(--light-faint);
}

.comment-body {
    font-size: var(--text-body);
    line-height: var(--leading-relaxed);
}

/* Interactive input */
.comment-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--light);
    font-family: inherit;
    font-size: var(--text-body);
    outline: none;
    resize: none;
}

.comment-input::placeholder {
    color: var(--light-ghost);
}

/* Magic word highlight */
.magic-word {
    color: var(--figma-purple);
    font-weight: 600;
    background: var(--figma-purple-10);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    position: relative;
    display: inline-block;
}

.magic-word.sparkle::after {
    content: '✨';
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 14px;
    animation: sparkleFloat 1s ease-out forwards;
}

@keyframes sparkleFloat {
    0% { opacity: 1; transform: translate(0, 0) scale(1); }
    100% { opacity: 0; transform: translate(5px, -15px) scale(0.5); }
}

/* Magic arrow with sparks */
.magic-arrow {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-4);
    position: relative;
}

.magic-spark {
    width: 10px;
    height: 10px;
    background: var(--figma-purple);
    border-radius: var(--radius-full);
    animation: sparkle 1.5s ease-in-out infinite;
    box-shadow: 0 0 10px var(--figma-purple);
}

.magic-spark:nth-child(2) { animation-delay: 0.2s; }
.magic-spark:nth-child(3) { animation-delay: 0.4s; }

@keyframes sparkle {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.3); }
}

/* Loading dots */
.loading-dots {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-4);
}

.loading-dot {
    width: 8px;
    height: 8px;
    background: var(--light-faint);
    border-radius: var(--radius-full);
    animation: loadingBounce 1.4s ease-in-out infinite;
}

.loading-dot:nth-child(1) { animation-delay: 0s; }
.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes loadingBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-8px); }
}

/* Response card */
.response-card {
    border-color: var(--flow);
    box-shadow: 0 8px 32px rgba(78, 205, 196, 0.15);
    opacity: 0;
    transform: translateY(20px);
    transition: all var(--dur-slow) var(--ease-out);
}

.response-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.analysis-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

/* Score display with progress ring */
.analysis-score {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4);
    background: rgba(78, 205, 196, 0.1);
    border-radius: var(--radius-md);
}

.score-ring {
    width: 64px;
    height: 64px;
    position: relative;
    flex-shrink: 0;
}

.score-ring > svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.score-ring-bg {
    fill: none;
    stroke: var(--obsidian);
    stroke-width: 5;
}

.score-ring-progress {
    fill: none;
    stroke: url(#score-gradient);
    stroke-width: 5;
    stroke-linecap: round;
    stroke-dasharray: 163.36;
    stroke-dashoffset: 163.36;
    transition: stroke-dashoffset 1.5s var(--ease-out);
    filter: drop-shadow(0 0 4px var(--flow));
}

.score-ring.animated .score-ring-progress {
    stroke-dashoffset: 21.24; /* (1 - 0.87) * 163.36 */
}

.score-value-wrapper {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.score-check {
    width: 24px;
    height: 24px;
    stroke: var(--flow);
    opacity: 0;
    transform: scale(0.5);
    transition: all var(--dur-medium) var(--ease-spring);
}

.score-ring.animated .score-check {
    opacity: 1;
    transform: scale(1);
}

.score-text {
    display: flex;
    flex-direction: column;
}

.score-value {
    font-size: var(--text-section);
    font-weight: 600;
    color: var(--flow);
    line-height: var(--leading-none);
}

.score-label {
    font-size: var(--text-micro);
    color: var(--light-faint);
}

/* Analysis checklist */
.analysis-details {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.detail-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    font-size: var(--text-small);
    color: var(--light-dim);
    padding: var(--space-2) 0;
    opacity: 0;
    transform: translateX(-10px);
    transition: all var(--dur-normal) var(--ease-out);
}

.detail-item.visible {
    opacity: 1;
    transform: translateX(0);
}

.detail-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.detail-icon svg {
    width: 16px;
    height: 16px;
}

.detail-item.good .detail-icon svg { stroke: var(--success); }
.detail-item.warn .detail-icon svg { stroke: var(--warning); }
.detail-item.info .detail-icon svg { stroke: var(--figma-blue); }
.detail-item:not(.good):not(.warn):not(.info) .detail-icon svg { stroke: var(--figma-purple); }

/* Feature cards */
.magic-features {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-6);
    max-width: 900px;
    width: 100%;
}

@media (min-width: 768px) {
    .magic-features {
        grid-template-columns: repeat(3, 1fr);
    }
}

.feature-card {
    padding: var(--space-6);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    text-align: center;
    transition: all var(--dur-medium) var(--ease-out);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.feature-card:hover {
    background: var(--glass-bg-hover);
    transform: translateY(-4px);
    border-color: var(--glass-border-hover);
}

.feature-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.feature-icon {
    width: 48px;
    height: 48px;
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--figma-purple-10);
    border-radius: var(--radius-lg);
}

.feature-icon svg {
    width: 24px;
    height: 24px;
    stroke: var(--figma-purple);
}

.feature-card h4 {
    font-size: var(--text-body);
    font-weight: 500;
    margin-bottom: var(--space-2);
    text-align: center;
}

.feature-card p {
    font-size: var(--text-small);
    color: var(--light-faint);
    line-height: var(--leading-relaxed);
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════════════════
   QUALITY CHAPTER — Pipeline & Thresholds
═══════════════════════════════════════════════════════════════════════════ */

.pipeline-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: var(--space-2);
    margin-bottom: var(--space-12);
    max-width: 100%;
    width: 100%;
    overflow-x: auto;
    padding: var(--space-4);
    -webkit-overflow-scrolling: touch;
}

.pipeline-stage {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    min-width: 180px;
    flex-shrink: 0;
    transition: all var(--dur-medium) var(--ease-out);
    cursor: pointer;
    opacity: 0;
    transform: translateX(-20px);
}

.pipeline-stage.visible {
    opacity: 1;
    transform: translateX(0);
}

.pipeline-stage:hover {
    border-color: var(--figma-purple);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--figma-purple-10);
}

.pipeline-stage.active {
    border-color: var(--figma-purple);
    background: var(--figma-purple-05);
}

.pipeline-stage.completed .stage-number {
    background: var(--success);
}

.pipeline-stage.completed .stage-number::after {
    content: '✓';
    position: absolute;
    color: var(--void);
    font-size: var(--text-micro);
}

.stage-number {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--figma-purple);
    color: var(--void);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--text-body);
    flex-shrink: 0;
    position: relative;
}

.stage-content h4 {
    font-size: var(--text-body);
    font-weight: 500;
    margin-bottom: 2px;
}

.stage-content p {
    font-size: var(--text-micro);
    color: var(--light-faint);
}

.stage-icon {
    margin-left: auto;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stage-icon svg {
    width: 24px;
    height: 24px;
    stroke: var(--light-dim);
}

.pipeline-connector {
    width: 40px;
    height: 2px;
    background: var(--gradient-figma);
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: scaleX(0);
    transition: all var(--dur-normal) var(--ease-out);
}

.pipeline-connector.visible {
    opacity: 1;
    transform: scaleX(1);
}

.pipeline-connector::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    animation: connectorFlow 1.5s linear infinite;
}

@keyframes connectorFlow {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Threshold visualization */
.threshold-visual {
    max-width: 800px;
    width: 100%;
    margin-bottom: var(--space-12);
}

.threshold-title {
    text-align: center;
    font-size: var(--text-large);
    margin-bottom: var(--space-6);
}

/* Interactive threshold slider */
.threshold-slider-container {
    margin-bottom: var(--space-6);
    padding: 0 var(--space-4);
}

.threshold-slider {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(90deg, 
        var(--error) 0%, var(--error) 70%,
        var(--warning) 70%, var(--warning) 80%,
        var(--success) 80%, var(--success) 100%
    );
    border-radius: var(--radius-full);
    cursor: pointer;
}

.threshold-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    background: var(--light);
    border-radius: var(--radius-full);
    cursor: grab;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform var(--dur-fast) var(--ease-out);
}

.threshold-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.threshold-slider::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.1);
}

.threshold-value-display {
    text-align: center;
    font-size: var(--text-section);
    font-weight: 600;
    margin-top: var(--space-4);
    transition: color var(--dur-fast);
}

.threshold-value-display.critical { color: var(--error); }
.threshold-value-display.warning { color: var(--warning); }
.threshold-value-display.passing { color: var(--success); }

/* Threshold bar zones */
.threshold-bar {
    display: flex;
    height: 56px;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: var(--space-6);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.threshold-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: all var(--dur-normal) var(--ease-out);
    cursor: pointer;
}

.threshold-zone:hover {
    filter: brightness(1.15);
}

.threshold-zone.critical { background: var(--gradient-error); }
.threshold-zone.warning { background: var(--gradient-warning); }
.threshold-zone.passing { background: var(--gradient-success); }

.zone-label {
    font-size: var(--text-micro);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}

.zone-range {
    font-family: var(--font-mono);
    font-size: var(--text-nano);
    opacity: 0.8;
}

/* Action cards */
.threshold-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-3);
}

@media (min-width: 768px) {
    .threshold-actions {
        grid-template-columns: repeat(3, 1fr);
    }
}

.action-card {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--glass-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    font-size: var(--text-small);
    transition: all var(--dur-normal) var(--ease-out);
    opacity: 0.5;
}

.action-card.active {
    opacity: 1;
    border-color: var(--glass-border-hover);
    background: var(--glass-bg-hover);
}

.action-card.critical-action.active {
    border-color: var(--error);
    background: var(--error-dim);
}

.action-card.warning-action.active {
    border-color: var(--warning);
    background: var(--warning-dim);
}

.action-card.passing-action.active {
    border-color: var(--success);
    background: var(--success-dim);
}

.action-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.action-icon svg {
    width: 20px;
    height: 20px;
}

.critical-action .action-icon svg { stroke: var(--error); }
.warning-action .action-icon svg { stroke: var(--warning); }
.passing-action .action-icon svg { stroke: var(--success); }

/* Accessibility callout */
.accessibility-callout {
    display: flex;
    gap: var(--space-6);
    padding: var(--space-6);
    background: var(--figma-purple-05);
    border: 1px solid var(--figma-purple-20);
    border-radius: var(--radius-xl);
    max-width: 800px;
    align-items: center;
}

.callout-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.callout-icon svg {
    width: 32px;
    height: 32px;
    stroke: var(--figma-purple);
}

.callout-content h4 {
    font-size: var(--text-large);
    margin-bottom: var(--space-3);
    color: var(--figma-purple);
}

.callout-content p {
    font-size: var(--text-body);
    color: var(--light-dim);
    line-height: var(--leading-relaxed);
}

/* ═══════════════════════════════════════════════════════════════════════════
   HARMONY CHAPTER — Token Sync
═══════════════════════════════════════════════════════════════════════════ */

.sync-visualization {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: stretch;
    gap: var(--space-4);
    margin-bottom: var(--space-12);
    max-width: 1000px;
    width: 100%;
}

.sync-source {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--dur-medium) var(--ease-out);
    display: flex;
    flex-direction: column;
}

.sync-source:hover {
    border-color: var(--glass-border-hover);
}

.source-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--glass-bg-hover);
    border-bottom: 1px solid var(--glass-border);
    font-weight: 500;
    font-size: var(--text-body);
}

.figma-logo-small {
    width: 18px;
    height: 27px;
    color: var(--figma-purple);
}

.code-icon {
    font-family: var(--font-mono);
    font-size: var(--text-body);
    color: var(--flow);
}

.token-preview {
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.token-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-small);
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    transition: background var(--dur-fast);
}

.token-item:hover {
    background: var(--glass-bg);
}

.token-swatch {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    flex-shrink: 0;
    transition: transform var(--dur-fast) var(--ease-out);
}

.token-item:hover .token-swatch {
    transform: scale(1.2);
}

.token-name {
    font-family: var(--font-mono);
    color: var(--light-dim);
}

/* Code preview */
.code-preview {
    padding: var(--space-4);
    background: var(--void-deepest);
}

.code-preview pre {
    margin: 0;
    font-family: var(--font-mono);
    font-size: var(--text-small);
    line-height: var(--leading-relaxed);
    color: var(--light-dim);
    overflow-x: auto;
}

/* Syntax highlighting */
.code-key { color: var(--figma-purple); }
.code-string { color: var(--flow); }
.code-bracket { color: var(--light-faint); }

/* Sync arrows */
.sync-arrows {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: var(--space-6);
    padding: var(--space-4);
}

.sync-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    color: var(--light-faint);
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
}

.sync-arrow:hover {
    color: var(--flow);
    transform: scale(1.1);
}

.sync-arrow svg {
    width: 32px;
    height: 24px;
    stroke: var(--flow);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sync-arrow svg path {
    animation: arrowPulse 2s ease-in-out infinite;
}

@keyframes arrowPulse {
    0%, 100% { opacity: 0.5; stroke-dashoffset: 0; }
    50% { opacity: 1; stroke-dashoffset: 4; }
}

.sync-arrow .arrow-label {
    font-family: var(--font-mono);
    font-size: var(--text-micro);
    color: var(--light-ghost);
}

/* Sync button */
.sync-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    min-width: 140px; /* Fixed width to prevent layout shift */
    background: var(--gradient-figma);
    border: none;
    border-radius: var(--radius-md);
    color: var(--light);
    font-family: var(--font-mono);
    font-size: var(--text-small);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
}

.sync-button svg {
    stroke: currentColor;
    transition: transform var(--dur-normal) var(--ease-out);
    flex-shrink: 0;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.sync-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--figma-purple-20);
}

.sync-button:active {
    transform: translateY(0);
}

/* Drift alert */
.drift-alert-demo {
    max-width: 550px;
    width: 100%;
    background: var(--error-dim);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: var(--space-16);
    animation: shakeIn var(--dur-medium) var(--ease-bounce);
}

@keyframes shakeIn {
    0% { transform: translateX(-10px); opacity: 0; }
    25% { transform: translateX(8px); }
    50% { transform: translateX(-6px); }
    75% { transform: translateX(4px); }
    100% { transform: translateX(0); opacity: 1; }
}

.alert-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    background: rgba(239, 68, 68, 0.15);
    border-bottom: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: bellRing 2s ease-in-out infinite;
}

.alert-icon svg {
    width: 20px;
    height: 20px;
    stroke: var(--warning);
}

@keyframes bellRing {
    0%, 100% { transform: rotate(0); }
    10% { transform: rotate(15deg); }
    20% { transform: rotate(-15deg); }
    30% { transform: rotate(10deg); }
    40% { transform: rotate(-10deg); }
    50% { transform: rotate(0); }
}

.alert-title {
    font-weight: 600;
    color: var(--error);
}

.alert-body {
    padding: var(--space-6);
}

.alert-message {
    font-size: var(--text-body);
    margin-bottom: var(--space-4);
}

.drift-comparison {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-8);
    padding: var(--space-4);
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
}

.drift-value {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
}

.drift-label {
    font-size: var(--text-micro);
    color: var(--light-faint);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}

.drift-color {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    border: 2px solid var(--glass-border);
    transition: transform var(--dur-fast) var(--ease-out);
}

.drift-value:hover .drift-color {
    transform: scale(1.1);
}

.drift-value code {
    font-family: var(--font-mono);
    font-size: var(--text-small);
}

.drift-arrow {
    font-size: 2rem;
    color: var(--error);
    animation: driftPulse 1s ease-in-out infinite;
}

@keyframes driftPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.9); }
}

.alert-action {
    font-size: var(--text-small);
    color: var(--flow);
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.alert-action::before {
    content: '→';
}

/* Output formats grid */
.output-formats {
    text-align: center;
    max-width: 900px;
    width: 100%;
}

.output-formats h3 {
    font-size: var(--text-large);
    margin-bottom: var(--space-8);
}

.format-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
}

@media (min-width: 640px) {
    .format-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.format-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-6);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    transition: all var(--dur-medium) var(--ease-out);
}

.format-card:hover {
    background: var(--glass-bg-hover);
    transform: translateY(-4px);
    border-color: var(--glass-border-hover);
}

.format-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-2);
}

.format-icon svg {
    width: 32px;
    height: 32px;
    color: var(--figma-purple);
    transition: all var(--dur-medium) var(--ease-out);
}

/* Platform-specific icon colors */
.format-icon--swift svg {
    color: #F05138;
}

.format-icon--kotlin svg {
    fill: #7F52FF;
    color: #7F52FF;
}

.format-icon--css svg {
    color: #1572B6;
}

.format-icon--rust svg {
    color: #CE422B;
}

.format-card:hover .format-icon svg {
    transform: scale(1.1);
}

.format-name {
    font-weight: 500;
}

.format-card code {
    font-family: var(--font-mono);
    font-size: var(--text-small);
    color: var(--flow);
    background: rgba(78, 205, 196, 0.1);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
}

/* ═══════════════════════════════════════════════════════════════════════════
   FINALE CHAPTER
═══════════════════════════════════════════════════════════════════════════ */

.finale-chapter {
    text-align: center;
}

.future-vision {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-6);
    max-width: 1000px;
    margin-bottom: var(--space-12);
    width: 100%;
}

@media (min-width: 768px) {
    .future-vision {
        grid-template-columns: repeat(3, 1fr);
    }
}

.vision-card {
    padding: var(--space-6);
    background: linear-gradient(135deg, var(--figma-purple-05), rgba(78, 205, 196, 0.05));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    transition: all var(--dur-medium) var(--ease-out);
    transform-style: preserve-3d;
    perspective: 1000px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.vision-card:hover {
    transform: translateY(-8px) rotateX(5deg);
    border-color: var(--figma-purple-20);
    box-shadow: 0 20px 40px var(--figma-purple-10);
}

.vision-icon {
    width: 56px;
    height: 56px;
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--figma-purple-10), rgba(78, 205, 196, 0.1));
    border-radius: var(--radius-lg);
}

.vision-icon svg {
    width: 28px;
    height: 28px;
    stroke: var(--figma-purple);
}

.vision-card h4 {
    font-size: var(--text-body);
    font-weight: 600;
    margin-bottom: var(--space-2);
    text-align: center;
}

.vision-card p {
    font-size: var(--text-small);
    color: var(--light-faint);
    line-height: var(--leading-relaxed);
    text-align: center;
}

/* Summary stats */
.summary-stats {
    display: flex;
    justify-content: center;
    gap: var(--space-12);
    margin-bottom: var(--space-12);
    flex-wrap: wrap;
}

.summary-stat {
    text-align: center;
}

.summary-number {
    display: block;
    font-size: clamp(3rem, 10vw, 5rem);
    font-weight: 300;
    background: linear-gradient(135deg, var(--figma-purple) 0%, var(--flow) 50%, var(--figma-blue) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: var(--leading-none);
    margin-bottom: var(--space-3);
    filter: drop-shadow(0 2px 4px rgba(162, 89, 255, 0.2));
}

.summary-label {
    font-size: var(--text-small);
    color: var(--light-faint);
    max-width: 160px;
}

/* Finale quote */
.finale-quote {
    margin-bottom: var(--space-12);
    padding: var(--space-8) var(--space-12);
}

.finale-quote blockquote {
    font-size: var(--text-section);
    font-style: italic;
    color: var(--light-dim);
    max-width: 650px;
    margin: 0 auto;
    position: relative;
    padding: var(--space-4) var(--space-8);
}

.finale-quote blockquote::before,
.finale-quote blockquote::after {
    content: '"';
    color: var(--figma-purple-50);
    font-size: 5rem;
    font-family: Georgia, serif;
    position: absolute;
    line-height: 1;
    opacity: 0.8;
}

.finale-quote blockquote::before {
    top: -0.3em;
    left: -0.5em;
}

.finale-quote blockquote::after {
    content: '"';
    bottom: -0.6em;
    right: -0.5em;
}

/* CTA section */
.cta-section {
    padding: var(--space-8);
    text-align: center;
}

.cta-text {
    font-size: var(--text-large);
    margin-bottom: var(--space-6);
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.cta-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
}

.cta-button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-8);
    background: var(--gradient-figma);
    color: var(--light);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: var(--text-body);
    transition: all var(--dur-fast) var(--ease-out);
    position: relative;
    overflow: hidden;
}

.cta-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
    transform: translate(-50%, -50%);
    transition: width var(--dur-medium), height var(--dur-medium);
}

.cta-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 40px var(--figma-purple-20);
}

.cta-button:hover::before {
    width: 300px;
    height: 300px;
}

.cta-button:active {
    transform: translateY(-1px);
}

.cta-hint {
    font-size: var(--text-small);
    color: var(--light-faint);
}

.cta-hint code {
    font-family: var(--font-mono);
    color: var(--figma-purple);
    background: var(--figma-purple-10);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

/* ═══════════════════════════════════════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════════════════════════════════════ */

.site-footer {
    text-align: center;
    padding: var(--space-16) var(--space-8);
    position: relative;
    z-index: var(--z-above);
    border-top: 1px solid var(--glass-border);
}

.site-footer p {
    font-size: var(--text-body);
    color: var(--light-faint);
    margin-bottom: var(--space-3);
}

.footer-tech {
    font-family: var(--font-mono);
    font-size: var(--text-micro);
    color: var(--light-ghost);
    letter-spacing: var(--tracking-wide);
}

/* Hidden message (Easter egg) */
.hidden-message {
    margin-top: var(--space-24);
    opacity: 0;
    transform: translateY(20px);
    transition: all var(--dur-slow) var(--ease-out);
    font-style: italic;
    color: var(--light-ghost);
}

.hidden-message.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
═══════════════════════════════════════════════════════════════════════════ */

.toast-container {
    position: fixed;
    bottom: var(--space-8);
    right: var(--space-8);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.toast {
    padding: var(--space-4) var(--space-6);
    background: var(--obsidian);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--glass-shadow);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    animation: toastIn var(--dur-normal) var(--ease-spring);
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--error); }
.toast.info { border-color: var(--figma-blue); }

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

.toast.hiding {
    animation: toastOut var(--dur-fast) var(--ease-out) forwards;
}

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

/* ═══════════════════════════════════════════════════════════════════════════
   CONFETTI (Easter egg)
═══════════════════════════════════════════════════════════════════════════ */

.confetti-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: var(--z-overlay);
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    animation: confettiFall 3s linear forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(-100px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   FILM GRAIN EASTER EGG (Konami code reveals beautiful analog film effect)
═══════════════════════════════════════════════════════════════════════════ */

/* Beautiful analog film grain - on by default */
body.grain-mode .grain-overlay {
    opacity: 0.06;
    mix-blend-mode: soft-light;
    animation: grainDrift 3s steps(3) infinite;
    background-size: 200px 200px;
}

@keyframes grainDrift {
    0% { transform: translate(0, 0); }
    33% { transform: translate(-0.5%, -0.5%); }
    66% { transform: translate(0.5%, 0.5%); }
    100% { transform: translate(0, 0); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   STAR FIELD (Easter egg - night mode)
═══════════════════════════════════════════════════════════════════════════ */

body.night-mode #design-canvas {
    background: radial-gradient(ellipse at center, #0a0a1a 0%, #000005 100%);
}

.star {
    position: absolute;
    background: white;
    border-radius: var(--radius-full);
    animation: twinkle 3s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   CUSTOM CURSOR (Desktop only)
═══════════════════════════════════════════════════════════════════════════ */

@media (hover: hover) and (pointer: fine) {
    body.custom-cursor {
        cursor: none;
    }
    
    .custom-cursor-dot {
        position: fixed;
        width: 8px;
        height: 8px;
        background: var(--figma-purple);
        border-radius: var(--radius-full);
        pointer-events: none;
        z-index: var(--z-max);
        transform: translate(-50%, -50%);
        transition: transform var(--dur-micro), background var(--dur-micro);
    }
    
    .custom-cursor-ring {
        position: fixed;
        width: 32px;
        height: 32px;
        border: 1px solid var(--figma-purple);
        border-radius: var(--radius-full);
        pointer-events: none;
        z-index: calc(var(--z-max) - 1);
        transform: translate(-50%, -50%);
        transition: transform var(--dur-fast) var(--ease-out),
                    border-color var(--dur-fast),
                    width var(--dur-fast),
                    height var(--dur-fast);
    }
    
    body.custom-cursor a:hover ~ .custom-cursor-ring,
    body.custom-cursor button:hover ~ .custom-cursor-ring {
        width: 48px;
        height: 48px;
        border-color: var(--flow);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ANIMATIONS
═══════════════════════════════════════════════════════════════════════════ */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet
═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    :root {
        --space-16: 3rem;
        --space-24: 4rem;
    }
    
    #chapter-nav {
        right: var(--space-4);
    }
    
    .overture {
        padding: var(--space-12) var(--space-6);
    }
    
    .chapter {
        padding: var(--space-16) var(--space-6);
    }
    
    .chapter-header {
        margin-bottom: var(--space-12);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile
═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    :root {
        --space-12: 2rem;
        --space-16: 2.5rem;
        --space-24: 3rem;
    }
    
    #chapter-nav {
        display: none;
    }
    
    .overture {
        padding: var(--space-8) var(--space-4);
    }
    
    .overture-meta {
        flex-direction: column;
        gap: var(--space-3);
    }
    
    .meta-divider {
        display: none;
    }
    
    .chapter {
        padding: var(--space-12) var(--space-4);
    }
    
    .chapter-header {
        margin-bottom: var(--space-8);
    }
    
    /* Gap visualization stacks vertically */
    .gap-visualization {
        flex-direction: column;
        gap: var(--space-6);
    }
    
    .gap-side {
        width: 100%;
        max-width: 280px;
        padding: var(--space-6);
    }
    
    .gap-chasm {
        transform: rotate(90deg);
        padding: var(--space-3) 0;
        width: 80px;
    }
    
    /* Pipeline stacks vertically */
    .pipeline-visual {
        flex-direction: column;
        overflow-x: visible;
        padding: var(--space-4) 0;
    }
    
    .pipeline-stage {
        width: 100%;
        max-width: 280px;
    }
    
    .pipeline-connector {
        width: 2px;
        height: 24px;
    }
    
    .threshold-actions {
        grid-template-columns: 1fr;
    }
    
    /* Touch targets minimum 44px */
    .chapter-dot,
    .sync-button,
    .flow-node,
    .pipeline-stage {
        min-height: 44px;
    }
    
    /* Card reflow */
    .capability-card,
    .feature-card,
    .vision-card {
        padding: var(--space-5);
    }
    
    .capability-icon,
    .vision-icon {
        width: 44px;
        height: 44px;
    }
    
    .capability-icon svg,
    .vision-icon svg {
        width: 22px;
        height: 22px;
    }
    
    /* Flow diagram scrolls on mobile */
    .flow-section {
        margin: 0 calc(-1 * var(--space-4));
        padding: var(--space-4);
    }
    
    /* Sync stacks vertically */
    .sync-visualization {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
    
    .sync-arrows {
        flex-direction: row;
        justify-content: center;
        order: 1;
    }
    
    .sync-arrows .sync-arrow svg {
        transform: rotate(90deg);
    }
    
    /* Accessibility callout stacks */
    .accessibility-callout {
        flex-direction: column;
        text-align: center;
    }
    
    /* Finale quote */
    .finale-quote blockquote::before,
    .finale-quote blockquote::after {
        display: none;
    }
    
    /* Summary stats */
    .summary-stats {
        gap: var(--space-8);
    }
    
    /* Toast on mobile */
    .toast-container {
        left: var(--space-4);
        right: var(--space-4);
        bottom: var(--space-4);
    }
    
    .toast {
        width: 100%;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Small Mobile
═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    .overture-title {
        font-size: clamp(2.5rem, 15vw, 3.5rem);
    }
    
    .chapter-title {
        font-size: clamp(1.75rem, 8vw, 2.5rem);
    }
    
    .gap-side {
        min-width: 100%;
    }
    
    .flow-diagram {
        padding: var(--space-4);
    }
    
    .flow-node {
        min-width: 100px;
        padding: var(--space-4);
    }
    
    .capability-grid,
    .magic-features,
    .future-vision {
        grid-template-columns: 1fr;
    }
    
    .drift-comparison {
        flex-direction: column;
        gap: var(--space-4);
    }
    
    .drift-arrow {
        transform: rotate(90deg);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SAFE AREA INSETS (Notched devices)
═══════════════════════════════════════════════════════════════════════════ */

@supports (padding: env(safe-area-inset-bottom)) {
    .site-footer {
        padding-bottom: calc(var(--space-16) + env(safe-area-inset-bottom));
    }
    
    .toast-container {
        bottom: calc(var(--space-8) + env(safe-area-inset-bottom));
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   PRINT STYLES
═══════════════════════════════════════════════════════════════════════════ */

@media print {
    body {
        background: white;
        color: black;
    }
    
    .loading-screen,
    #design-canvas,
    .gradient-overlay,
    .grain-overlay,
    #progress-bar,
    #chapter-nav,
    .scroll-indicator,
    .toast-container {
        display: none !important;
    }
    
    .chapter {
        page-break-inside: avoid;
    }
}