/* ==========================================================================
   Backpropagation Educational Site - Main Stylesheet
   ========================================================================== */

/* ==========================================================================
   CSS Variables & Theme
   ========================================================================== */
:root {
    /* Colors - Dark Theme (default) */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a26;
    --text-primary: #e8e6e3;
    --text-secondary: #a09b94;
    --text-muted: #6b6660;
    --accent-gold: #d4a853;
    --accent-gold-dim: #b8923f;
    --accent-cyan: #4ecdc4;
    --accent-magenta: #c44569;
    --accent-blue: #5b7cfa;
    --accent-green: #2ecc71;
    --accent-red: #e74c3c;
    
    /* Gradients */
    --gradient-gold: linear-gradient(135deg, #d4a853, #e8c776);
    --gradient-neural: linear-gradient(135deg, #4ecdc4, #5b7cfa, #c44569);
    --shadow-glow: 0 0 40px rgba(212, 168, 83, 0.15);
    
    /* Typography */
    --font-display: 'Sora', sans-serif;
    --font-body: 'Crimson Pro', Georgia, serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    /* Spacing */
    --section-padding: 6rem;
    --container-max-width: 900px;
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.6s ease;
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #f8f7f4;
    --bg-secondary: #ffffff;
    --bg-tertiary: #eeeee9;
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-muted: #7a7a7a;
    --accent-gold: #b8923f;
    --shadow-glow: 0 0 40px rgba(212, 168, 83, 0.2);
}

/* ==========================================================================
   Base Styles
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1.125rem;
    line-height: 1.8;
    overflow-x: hidden;
    transition: background var(--transition-normal), color var(--transition-normal);
}

/* Background Pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(212, 168, 83, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(78, 205, 196, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(91, 124, 250, 0.02) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

/* Grid Pattern Overlay */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(212, 168, 83, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(212, 168, 83, 0.02) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: -1;
}

/* ==========================================================================
   Skip Link (Accessibility)
   ========================================================================== */
.skip-link {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-gold);
    color: var(--bg-primary);
    padding: 0.75rem 1.5rem;
    border-radius: 0 0 8px 8px;
    font-family: var(--font-display);
    font-size: 0.9rem;
    text-decoration: none;
    z-index: 10000;
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: 0;
    outline: 3px solid var(--accent-cyan);
    outline-offset: 2px;
}

/* ==========================================================================
   Progress Bar
   ========================================================================== */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--gradient-gold);
    z-index: 10001;
    transition: width 0.1s linear;
}

/* ==========================================================================
   Navigation
   ========================================================================== */
nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1rem 3rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    background: linear-gradient(to bottom, var(--bg-primary), transparent);
    backdrop-filter: blur(10px);
    transition: background var(--transition-normal);
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    background: var(--gradient-gold);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    display: flex;
    gap: 2rem;
    list-style: none;
}

.nav-links a {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-secondary);
    text-decoration: none;
    letter-spacing: 0.05em;
    transition: color var(--transition-normal);
    position: relative;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-gold);
    transition: width var(--transition-normal);
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--accent-gold);
}

.nav-links a.active::after,
.nav-links a:hover::after {
    width: 100%;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Theme Toggle */
.theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--text-muted);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
}

.theme-toggle:hover {
    border-color: var(--accent-gold);
    background: var(--bg-secondary);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-secondary);
    fill: none;
    transition: stroke var(--transition-normal);
}

.theme-toggle:hover svg {
    stroke: var(--accent-gold);
}

.theme-toggle .sun-icon {
    display: none;
}

[data-theme="light"] .theme-toggle .sun-icon {
    display: block;
}

[data-theme="light"] .theme-toggle .moon-icon {
    display: none;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
}

.mobile-menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    margin: 5px 0;
    transition: all var(--transition-normal);
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Mobile Navigation Drawer */
.mobile-nav {
    display: none;
    position: fixed;
    top: 0;
    right: -100%;
    width: 300px;
    height: 100vh;
    background: var(--bg-secondary);
    padding: 5rem 2rem 2rem;
    z-index: 999;
    transition: right var(--transition-normal);
    box-shadow: -5px 0 30px rgba(0,0,0,0.3);
}

.mobile-nav.active {
    right: 0;
}

.mobile-nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.mobile-nav-links a {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition-normal);
    display: block;
    padding: 0.5rem 0;
}

.mobile-nav-links a:hover,
.mobile-nav-links a.active {
    color: var(--accent-gold);
}

.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.mobile-nav-overlay.active {
    opacity: 1;
}

/* ==========================================================================
   Hero Section
   ========================================================================== */
.hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 6rem 2rem;
    position: relative;
}

.hero-badge {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent-gold);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-bottom: 2rem;
    opacity: 0;
    animation: fadeInUp 0.8s ease forwards;
}

.hero h1 {
    font-family: var(--font-display);
    font-size: clamp(3rem, 8vw, 6rem);
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    opacity: 0;
    animation: fadeInUp 0.8s ease 0.2s forwards;
}

.hero h1 span {
    background: var(--gradient-neural);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.35rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin-bottom: 3rem;
    opacity: 0;
    animation: fadeInUp 0.8s ease 0.4s forwards;
}

.hero-cta {
    display: flex;
    gap: 1rem;
    opacity: 0;
    animation: fadeInUp 0.8s ease 0.6s forwards;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 1rem 2rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-normal);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--gradient-gold);
    color: var(--bg-primary);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--text-muted);
}

.btn-secondary:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

/* ==========================================================================
   Scroll Indicator
   ========================================================================== */
.scroll-indicator {
    position: absolute;
    bottom: 3rem;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    animation: fadeInUp 0.8s ease 0.8s forwards, bounce 2s ease-in-out 1.5s infinite;
}

.scroll-indicator svg {
    width: 24px;
    height: 24px;
    stroke: var(--text-muted);
}

/* ==========================================================================
   Content Sections
   ========================================================================== */
.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 2rem;
}

section {
    padding: var(--section-padding) 0;
}

.section-header {
    margin-bottom: 4rem;
}

.section-number {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-gold);
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
    display: block;
}

h2 {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 1rem;
}

h3 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    margin: 3rem 0 1.5rem;
    color: var(--text-primary);
}

h4 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    margin: 2rem 0 1rem;
    color: var(--accent-cyan);
}

p {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* ==========================================================================
   Math Blocks
   ========================================================================== */
.math-block {
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent-gold);
    padding: 2rem;
    margin: 2rem 0;
    border-radius: 0 8px 8px 0;
    overflow-x: auto;
}

.math-block.highlight {
    border-left-color: var(--accent-cyan);
    background: linear-gradient(135deg, var(--bg-secondary), rgba(78, 205, 196, 0.05));
}

.math-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent-gold);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
    display: block;
}

/* ==========================================================================
   Definition Boxes
   ========================================================================== */
.definition {
    background: var(--bg-tertiary);
    border: 1px solid rgba(212, 168, 83, 0.2);
    border-radius: 8px;
    padding: 2rem;
    margin: 2rem 0;
}

.definition-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-gold);
    margin-bottom: 1rem;
}

/* ==========================================================================
   Key Insight Boxes
   ========================================================================== */
.insight {
    background: linear-gradient(135deg, rgba(196, 69, 105, 0.1), rgba(91, 124, 250, 0.1));
    border: 1px solid rgba(196, 69, 105, 0.3);
    border-radius: 8px;
    padding: 2rem;
    margin: 2rem 0;
}

.insight-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.insight-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-magenta);
    margin-bottom: 0.5rem;
}

/* ==========================================================================
   Code Blocks
   ========================================================================== */
.code-block {
    background: var(--bg-secondary);
    border-radius: 8px;
    margin: 2rem 0;
    overflow: hidden;
    position: relative;
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.code-block-lang {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.copy-btn {
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.copy-btn:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.copy-btn.copied {
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.code-block pre {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-secondary);
    padding: 1.5rem;
    overflow-x: auto;
    margin: 0;
}

.code-block .comment { color: var(--text-muted); }
.code-block .keyword { color: var(--accent-magenta); }
.code-block .function { color: var(--accent-cyan); }
.code-block .number { color: var(--accent-gold); }
.code-block .string { color: var(--accent-green); }

/* ==========================================================================
   Visualization Containers
   ========================================================================== */
.visualization-container {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 2rem;
    margin: 3rem 0;
}

.visualization-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-cyan);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.visualization-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--bg-tertiary);
}

.control-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--text-muted);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.control-btn:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.control-btn.active {
    background: var(--accent-gold);
    border-color: var(--accent-gold);
    color: var(--bg-primary);
}

.visualization-canvas {
    width: 100%;
    border-radius: 8px;
    background: var(--bg-primary);
}

.visualization-info {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

/* Neural Network Visualization */
.nn-visualization {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 3rem;
    margin: 3rem 0;
    text-align: center;
}

.nn-canvas {
    width: 100%;
    max-width: 700px;
    height: 400px;
    margin: 0 auto;
    touch-action: none; /* Prevent scrolling while interacting */
    cursor: pointer;
}

/* Show/hide hints based on device */
.mobile-hint {
    display: none;
}

.desktop-hint {
    display: inline;
}

@media (hover: none) and (pointer: coarse) {
    /* Touch devices */
    .mobile-hint {
        display: inline;
    }
    .desktop-hint {
        display: none;
    }
}

/* ==========================================================================
   Interactive Demo
   ========================================================================== */
.demo-container {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 2rem;
    margin: 3rem 0;
}

.demo-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-cyan);
    margin-bottom: 1.5rem;
}

.demo-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}

.control-group {
    flex: 1;
    min-width: 180px;
}

.control-group label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 0.5rem;
}

.control-group input[type="range"] {
    width: 100%;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    appearance: none;
    cursor: pointer;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-gold);
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.control-group input[type="range"]:focus {
    outline: none;
}

.control-group input[type="range"]:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px rgba(212, 168, 83, 0.3);
}

.control-value {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--accent-gold);
    text-align: right;
}

.demo-output {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 1.5rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

/* ==========================================================================
   Quiz Styles
   ========================================================================== */
.quiz-container {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 2rem;
    margin: 3rem 0;
    border: 1px solid var(--bg-tertiary);
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--bg-tertiary);
}

.quiz-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-magenta);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.quiz-progress {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.quiz-question {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.quiz-option {
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.quiz-option:hover {
    border-color: var(--accent-gold);
}

.quiz-option.selected {
    border-color: var(--accent-blue);
    background: rgba(91, 124, 250, 0.1);
}

.quiz-option.correct {
    border-color: var(--accent-green);
    background: rgba(46, 204, 113, 0.1);
}

.quiz-option.incorrect {
    border-color: var(--accent-red);
    background: rgba(231, 76, 60, 0.1);
}

.quiz-option-marker {
    width: 24px;
    height: 24px;
    border: 2px solid var(--text-muted);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.quiz-option.selected .quiz-option-marker {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.quiz-option.correct .quiz-option-marker {
    border-color: var(--accent-green);
    background: var(--accent-green);
    color: white;
}

.quiz-option.incorrect .quiz-option-marker {
    border-color: var(--accent-red);
    background: var(--accent-red);
    color: white;
}

.quiz-option-text {
    color: var(--text-secondary);
    flex: 1;
}

.quiz-feedback {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: 8px;
    display: none;
}

.quiz-feedback.show {
    display: block;
}

.quiz-feedback.correct {
    background: rgba(46, 204, 113, 0.1);
    border: 1px solid var(--accent-green);
}

.quiz-feedback.incorrect {
    background: rgba(231, 76, 60, 0.1);
    border: 1px solid var(--accent-red);
}

.quiz-feedback-title {
    font-family: var(--font-display);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.quiz-feedback.correct .quiz-feedback-title {
    color: var(--accent-green);
}

.quiz-feedback.incorrect .quiz-feedback-title {
    color: var(--accent-red);
}

.quiz-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
}

/* ==========================================================================
   Collapsible Sections
   ========================================================================== */
.collapsible {
    background: var(--bg-secondary);
    border-radius: 8px;
    margin: 2rem 0;
    overflow: hidden;
}

.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    cursor: pointer;
    transition: background var(--transition-normal);
}

.collapsible-header:hover {
    background: var(--bg-tertiary);
}

.collapsible-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.collapsible-icon {
    width: 20px;
    height: 20px;
    stroke: var(--text-muted);
    transition: transform var(--transition-normal);
}

.collapsible.open .collapsible-icon {
    transform: rotate(180deg);
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.collapsible.open .collapsible-content {
    max-height: 2000px;
}

.collapsible-inner {
    padding: 0 1.5rem 1.5rem;
}

/* ==========================================================================
   Steps List
   ========================================================================== */
.steps {
    counter-reset: step;
    list-style: none;
    margin: 2rem 0;
}

.steps li {
    position: relative;
    padding-left: 3.5rem;
    margin-bottom: 1.5rem;
    counter-increment: step;
}

.steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0;
    width: 2rem;
    height: 2rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-gold);
}

/* ==========================================================================
   Table of Contents
   ========================================================================== */
.toc {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 2rem;
    margin: 3rem 0;
}

.toc-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

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

.toc-list li {
    margin-bottom: 0.75rem;
}

.toc-list a {
    font-family: var(--font-display);
    font-size: 0.95rem;
    color: var(--text-secondary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: color var(--transition-normal);
    padding: 0.25rem 0;
}

.toc-list a:hover {
    color: var(--accent-gold);
}

.toc-list a.completed {
    color: var(--accent-green);
}

.toc-list .toc-number {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    width: 2rem;
}

.toc-check {
    width: 16px;
    height: 16px;
    margin-left: auto;
    opacity: 0;
    stroke: var(--accent-green);
}

.toc-list a.completed .toc-check {
    opacity: 1;
}

/* ==========================================================================
   Divider
   ========================================================================== */
.divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--text-muted), transparent);
    margin: 4rem 0;
}

/* ==========================================================================
   Back to Top Button
   ========================================================================== */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    background: var(--bg-secondary);
    border: 1px solid var(--text-muted);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all var(--transition-normal);
    z-index: 100;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    border-color: var(--accent-gold);
    background: var(--bg-tertiary);
}

.back-to-top svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-secondary);
    transition: stroke var(--transition-normal);
}

.back-to-top:hover svg {
    stroke: var(--accent-gold);
}

/* ==========================================================================
   Footer
   ========================================================================== */
footer {
    padding: 4rem 0;
    text-align: center;
    border-top: 1px solid var(--bg-tertiary);
}

footer p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    40% {
        transform: translateX(-50%) translateY(-10px);
    }
    60% {
        transform: translateX(-50%) translateY(-5px);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

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

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

/* Scroll reveal */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
    
    .reveal {
        opacity: 1;
        transform: none;
    }
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */
@media (max-width: 1024px) {
    nav {
        padding: 1rem 2rem;
    }
    
    .nav-links {
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    :root {
        --section-padding: 3rem;
    }
    
    body {
        font-size: 1rem;
    }
    
    nav {
        padding: 0.75rem 1rem;
    }
    
    .nav-links {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .mobile-nav {
        display: block;
    }
    
    .logo {
        font-size: 1.1rem;
    }
    
    .hero {
        min-height: 90vh;
        padding: 5rem 1.5rem 3rem;
    }
    
    .hero h1 {
        font-size: 2.2rem;
        margin-bottom: 1rem;
    }
    
    .hero-badge {
        font-size: 0.65rem;
        margin-bottom: 1.5rem;
    }
    
    .hero-subtitle {
        font-size: 1.1rem;
        margin-bottom: 2rem;
    }
    
    h2 {
        font-size: 1.75rem;
    }
    
    h3 {
        font-size: 1.25rem;
        margin: 2rem 0 1rem;
    }
    
    h4 {
        font-size: 1.05rem;
        margin: 1.5rem 0 0.75rem;
    }
    
    .section-header {
        margin-bottom: 2.5rem;
    }
    
    .math-block {
        padding: 1.25rem 1rem;
        margin: 1.5rem 0;
        border-radius: 0 6px 6px 0;
    }
    
    .math-block p {
        font-size: 0.9rem;
    }
    
    .math-block ul {
        font-size: 0.9rem;
        margin-left: 1rem !important;
    }
    
    .definition,
    .insight {
        padding: 1.25rem;
        margin: 1.5rem 0;
    }
    
    .definition-title,
    .insight-title {
        font-size: 0.9rem;
    }
    
    .demo-controls {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .control-group {
        min-width: 100%;
    }
    
    .control-btn {
        padding: 0.6rem 1rem;
        font-size: 0.75rem;
    }
    
    .quiz-option {
        padding: 0.75rem 1rem;
    }
    
    .quiz-option-text {
        font-size: 0.95rem;
    }
    
    .steps li {
        padding-left: 3rem;
        margin-bottom: 1.25rem;
        font-size: 0.95rem;
    }
    
    .steps li::before {
        width: 1.75rem;
        height: 1.75rem;
        font-size: 0.75rem;
    }
    
    .code-block pre {
        font-size: 0.8rem;
        padding: 1rem;
    }
    
    .visualization-container {
        padding: 1.25rem;
        margin: 2rem 0;
    }
    
    .visualization-controls {
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    
    .visualization-canvas {
        height: 280px;
    }
    
    .nn-visualization {
        padding: 1.5rem 1rem;
    }
    
    .nn-canvas {
        height: 300px;
    }
    
    .toc {
        padding: 1.25rem;
    }
    
    .toc-list a {
        font-size: 0.9rem;
        padding: 0.35rem 0;
    }
    
    .toc-number {
        font-size: 0.7rem;
        width: 1.75rem;
    }
    
    .divider {
        margin: 2.5rem 0;
    }
    
    .back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 44px;
        height: 44px;
    }
    
    .collapsible-header {
        padding: 1rem 1.25rem;
    }
    
    .collapsible-title {
        font-size: 0.9rem;
    }
    
    .collapsible-inner {
        padding: 0 1.25rem 1.25rem;
    }
    
    /* Math equations on mobile */
    mjx-container {
        font-size: 0.9em !important;
    }
    
    .MathJax {
        font-size: 0.95em !important;
    }
}

@media (max-width: 480px) {
    :root {
        --section-padding: 2.5rem;
    }
    
    body {
        font-size: 0.95rem;
        line-height: 1.7;
    }
    
    .container {
        padding: 0 0.875rem;
    }
    
    nav {
        padding: 0.625rem 0.875rem;
    }
    
    .logo {
        font-size: 1rem;
    }
    
    .theme-toggle {
        width: 36px;
        height: 36px;
    }
    
    .theme-toggle svg {
        width: 18px;
        height: 18px;
    }
    
    .hero {
        min-height: 85vh;
        padding: 4rem 1rem 2.5rem;
    }
    
    .hero h1 {
        font-size: 1.85rem;
        line-height: 1.2;
    }
    
    .hero-badge {
        font-size: 0.6rem;
        letter-spacing: 0.15em;
    }
    
    .hero-subtitle {
        font-size: 1rem;
        line-height: 1.6;
    }
    
    .hero-cta {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }
    
    .hero-cta .btn {
        width: 100%;
        justify-content: center;
        padding: 0.875rem 1.5rem;
    }
    
    .scroll-indicator {
        bottom: 2rem;
    }
    
    h2 {
        font-size: 1.5rem;
        line-height: 1.3;
    }
    
    h3 {
        font-size: 1.15rem;
    }
    
    h4 {
        font-size: 1rem;
    }
    
    .section-number {
        font-size: 0.7rem;
    }
    
    p {
        margin-bottom: 1.25rem;
    }
    
    .math-block {
        padding: 1rem 0.875rem;
        margin: 1.25rem 0;
        border-left-width: 2px;
    }
    
    .math-label {
        font-size: 0.65rem;
        margin-bottom: 0.75rem;
    }
    
    .definition,
    .insight {
        padding: 1rem;
        margin: 1.25rem 0;
    }
    
    .insight-icon {
        font-size: 1.25rem;
    }
    
    .toc,
    .demo-container,
    .quiz-container,
    .visualization-container {
        padding: 1rem;
        border-radius: 8px;
    }
    
    .toc-title,
    .demo-title,
    .quiz-title,
    .visualization-title {
        font-size: 1rem;
        margin-bottom: 1rem;
    }
    
    .demo-output {
        padding: 1rem;
        font-size: 0.8rem;
    }
    
    .control-group label {
        font-size: 0.7rem;
    }
    
    .control-value {
        font-size: 0.8rem;
    }
    
    .visualization-controls {
        margin-bottom: 1rem;
        padding-bottom: 1rem;
    }
    
    .control-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.7rem;
        flex: 1;
        min-width: calc(50% - 0.5rem);
    }
    
    .visualization-canvas {
        height: 250px;
    }
    
    .visualization-info {
        font-size: 0.8rem;
        padding: 0.75rem;
    }
    
    .nn-visualization {
        padding: 1.25rem 0.875rem;
    }
    
    .nn-canvas {
        height: 260px;
    }
    
    .quiz-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .quiz-question {
        font-size: 1rem;
    }
    
    .quiz-progress {
        font-size: 0.75rem;
    }
    
    .quiz-option {
        padding: 0.75rem;
    }
    
    .quiz-option-marker {
        width: 22px;
        height: 22px;
        font-size: 0.75rem;
    }
    
    .quiz-option-text {
        font-size: 0.9rem;
    }
    
    .quiz-actions {
        flex-direction: column;
    }
    
    .quiz-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    .quiz-feedback {
        padding: 0.875rem;
        font-size: 0.9rem;
    }
    
    .steps li {
        padding-left: 2.5rem;
        font-size: 0.9rem;
    }
    
    .steps li::before {
        width: 1.5rem;
        height: 1.5rem;
        font-size: 0.7rem;
    }
    
    .code-block {
        margin: 1.25rem 0;
        border-radius: 6px;
    }
    
    .code-block-header {
        padding: 0.5rem 0.75rem;
    }
    
    .code-block-lang {
        font-size: 0.65rem;
    }
    
    .copy-btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.6rem;
    }
    
    .code-block pre {
        font-size: 0.75rem;
        padding: 0.875rem;
        line-height: 1.5;
    }
    
    .collapsible {
        margin: 1.25rem 0;
    }
    
    .collapsible-header {
        padding: 0.875rem 1rem;
    }
    
    .collapsible-title {
        font-size: 0.85rem;
        gap: 0.5rem;
    }
    
    .collapsible-inner {
        padding: 0 1rem 1rem;
    }
    
    .divider {
        margin: 2rem 0;
    }
    
    footer {
        padding: 2.5rem 0;
    }
    
    footer p {
        font-size: 0.85rem;
    }
    
    /* Smaller math on very small screens */
    mjx-container {
        font-size: 0.85em !important;
        max-width: 100%;
    }
    
    /* Ensure math scrolls horizontally if needed */
    .math-block {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Mobile nav adjustments */
    .mobile-nav {
        width: 280px;
        padding: 4rem 1.5rem 1.5rem;
    }
    
    .mobile-nav-links a {
        font-size: 1rem;
        padding: 0.625rem 0;
    }
}

/* Extra small devices */
@media (max-width: 360px) {
    body {
        font-size: 0.9rem;
    }
    
    .hero h1 {
        font-size: 1.65rem;
    }
    
    .hero-subtitle {
        font-size: 0.95rem;
    }
    
    h2 {
        font-size: 1.35rem;
    }
    
    h3 {
        font-size: 1.1rem;
    }
    
    .math-block {
        padding: 0.875rem 0.75rem;
    }
    
    .code-block pre {
        font-size: 0.7rem;
    }
    
    .visualization-canvas,
    .nn-canvas {
        height: 220px;
    }
    
    .control-btn {
        min-width: 100%;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
    body::before,
    body::after,
    nav,
    .progress-bar,
    .back-to-top,
    .scroll-indicator,
    .mobile-nav,
    .mobile-nav-overlay,
    .theme-toggle,
    .copy-btn,
    .quiz-container,
    .visualization-controls {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
        font-size: 12pt;
    }
    
    .container {
        max-width: 100%;
    }
    
    .hero {
        min-height: auto;
        padding: 2rem 0;
    }
    
    section {
        padding: 2rem 0;
        page-break-inside: avoid;
    }
    
    .math-block,
    .definition,
    .insight,
    .code-block {
        background: #f5f5f5;
        border: 1px solid #ddd;
    }
    
    a {
        color: black;
        text-decoration: underline;
    }
}

/* ==========================================================================
   MathJax Overrides
   ========================================================================== */
mjx-container {
    color: var(--text-primary) !important;
    overflow-x: auto;
    overflow-y: hidden;
}

/* ==========================================================================
   Focus Styles (Accessibility)
   ========================================================================== */
:focus-visible {
    outline: 3px solid var(--accent-cyan);
    outline-offset: 2px;
}

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

/* Remove default focus for mouse users */
:focus:not(:focus-visible) {
    outline: none;
}

