/* ============================================
   TinyTorch Design System - ML Systems Education
   ============================================ */

/* ============================================
   Header Icons - Hide Download & Align
   ============================================ */

/* Hide download button completely */
.dropdown-download-buttons,
.dropdown.dropdown-download,
.btn.dropdown-toggle[aria-label*="download"],
button[aria-label*="Download"],
.header-article-item:has(.dropdown-download),
.download-button {
    display: none !important;
}

/* Align header article icons properly */
.header-article-items {
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
}

.header-article-item {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Make all header buttons same size and aligned */
.header-article-items button,
.header-article-items .btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0.5rem !important;
    min-width: 2.5rem !important;
    min-height: 2.5rem !important;
}

/* Dropdown buttons container alignment */
.dropdown-buttons {
    display: flex !important;
    align-items: center !important;
    gap: 0.25rem !important;
}

/* Hide intro page from sidebar navigation */
.bd-sidebar nav a[href="intro.html"],
.bd-sidebar nav a[href="./intro.html"],
.bd-sidebar nav a[href="../intro.html"],
.bd-links a[href="intro.html"],
nav.bd-links a[href="intro.html"],
.bd-toc-item a[href="intro.html"] {
    display: none !important;
}

/* Hide any list item containing intro.html link */
.bd-sidebar nav li:has(a[href="intro.html"]),
.bd-links li:has(a[href="intro.html"]) {
    display: none !important;
}

/* Textbook link in main content */
.bd-content p a[href*="mlsysbook.ai"],
.bd-content p a.textbook-link {
    color: #64748b;
    text-decoration: none;
    border-bottom: 1px solid #cbd5e1;
    transition: all 0.2s ease;
}

.bd-content p a[href*="mlsysbook.ai"]:hover,
.bd-content p a.textbook-link:hover {
    color: #1e293b;
    border-bottom-color: #1e293b;
}

/* Tier card hover effects */
.tier-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
    cursor: pointer;
}

.tier-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2) !important;
}

/* Color Variables - ML Systems Theme */
:root {
    /* Primary Brand Colors */
    --tt-primary-blue: #1e3a8a;
    --tt-primary-blue-light: #3b82f6;
    --tt-primary-blue-lighter: #60a5fa;

    /* Fire Gradient (Tagline) */
    --tt-fire-red: #E74C3C;
    --tt-fire-orange: #E67E22;
    --tt-fire-yellow: #F39C12;

    /* Tier Colors - Learning Journey */
    --tt-foundation-bg: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    --tt-foundation-border: #1976d2;
    --tt-foundation-text: #0d47a1;
    --tt-foundation-text-light: #1565c0;

    --tt-architecture-bg: linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%);
    --tt-architecture-border: #7b1fa2;
    --tt-architecture-text: #4a148c;
    --tt-architecture-text-light: #6a1b9a;

    --tt-optimization-bg: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    --tt-optimization-border: #f57c00;
    --tt-optimization-text: #e65100;
    --tt-optimization-text-light: #ef6c00;

    --tt-olympics-bg: linear-gradient(135deg, #fce4ec 0%, #f8bbd0 100%);
    --tt-olympics-border: #c2185b;
    --tt-olympics-text: #880e4f;
    --tt-olympics-text-light: #ad1457;

    /* Semantic Colors */
    --tt-text-primary: #1f2937;
    --tt-text-secondary: #374151;
    --tt-text-muted: #6b7280;

    /* Spacing System */
    --tt-space-xs: 0.5rem;
    --tt-space-sm: 0.75rem;
    --tt-space-md: 1rem;
    --tt-space-lg: 1.5rem;
    --tt-space-xl: 2rem;
    --tt-space-2xl: 3rem;

    /* Border Radius */
    --tt-radius-sm: 0.5rem;
    --tt-radius-md: 0.75rem;

    /* Shadows */
    --tt-shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --tt-shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --tt-shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
}

/* ============================================
   Mermaid Diagram Styling
   ============================================ */

/* Container styling */
pre.mermaid {
    background: transparent !important;
    border: none !important;
    margin: 1.5rem auto !important;
    text-align: center !important;
    padding: 0 !important;
}

.mermaid {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    margin: 2rem 0 !important;
}

/* Flowchart nodes */
.mermaid .node rect,
.mermaid .node circle,
.mermaid .node ellipse,
.mermaid .node polygon {
    stroke-width: 2px;
    rx: 5px;
    ry: 5px;
}

/* Labels */
.mermaid .label {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    font-size: 14px !important;
}

/* Edge labels */
.mermaid .edgeLabel {
    background-color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 13px !important;
}

/* Sequence diagram */
.mermaid .actor {
    stroke: #1976d2;
    fill: #e3f2fd;
}

.mermaid .actor-line {
    stroke: #1976d2;
}

.mermaid .messageLine0,
.mermaid .messageLine1 {
    stroke: #666;
    stroke-width: 2;
}

/* Note boxes */
.mermaid .note {
    fill: #fff5e6;
    stroke: #ff9800;
}

/* Class diagram */
.mermaid .classGroup rect {
    fill: #e3f2fd;
    stroke: #1976d2;
}

.mermaid .classLabel .box {
    fill: #1976d2;
}

.mermaid .classLabel .label {
    fill: white;
    font-weight: 600;
}

/* Fix oversized navigation links at bottom of pages */
.prev-next-area .prev-next-info .prev-next-label {
    font-size: 0.9rem !important;
    font-weight: normal !important;
}

.prev-next-area .prev-next-info a {
    font-size: 1rem !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
}

/* Ensure consistent navigation styling */
.prev-next-area {
    border-top: 1px solid #dee2e6;
    padding-top: 1rem;
    margin-top: 2rem;
    margin-bottom: 0;
}

.prev-next-area .prev-next-info {
    max-width: none !important;
}

/* TinyTorch Top Bar - Fire-themed navigation */
.tinytorch-bar {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    color: #ffffff;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    transition: transform 0.3s ease;
    height: 56px;
    border-bottom: 2px solid #f97316;
}

.tinytorch-bar.hidden {
    transform: translateY(-100%);
}

.tinytorch-bar-content {
    max-width: 100%;
    height: 100%;
    margin: 0;
    padding: 0 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tinytorch-bar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 100%;
}

.tinytorch-bar-brand {
    display: flex;
    align-items: center;
    font-size: 1.2rem;
    font-weight: 600;
    color: #ffffff;
    text-decoration: none;
    letter-spacing: -0.01em;
}

.tinytorch-bar-brand:hover {
    color: #fbbf24;
}

.tinytorch-bar-brand .brand-fire {
    font-size: 1.1rem;
}

.tinytorch-bar-badge {
    font-size: 0.75rem;
    font-weight: 600;
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.12);
    padding: 0.3rem 0.75rem;
    border-radius: 4px;
    border: 1px solid rgba(251, 191, 36, 0.25);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.tinytorch-bar-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    height: 100%;
}

.tinytorch-bar-links a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #e5e7eb;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    transition: all 0.15s ease;
    background: transparent;
    border: none;
}

.tinytorch-bar-links a:hover {
    background: rgba(249, 115, 22, 0.15);
    color: #ffffff;
}

.tinytorch-bar-links .link-icon {
    font-size: 1rem;
}

.tinytorch-bar-links .link-text {
    font-size: 0.9rem;
}

/* Download link - same as other links, no special styling */
.tinytorch-bar-links a.download-link {
    background: transparent;
    border: none;
}

.tinytorch-bar-links a.download-link:hover {
    background: rgba(249, 115, 22, 0.15);
    border: none;
}

/* Subscribe link - same as others, no special treatment */
.tinytorch-bar-links a.subscribe-trigger {
    background: transparent;
}

.tinytorch-bar-links a.subscribe-trigger:hover {
    background: rgba(249, 115, 22, 0.15);
}

/* Responsive: hide text on small screens, keep icons */
@media (max-width: 768px) {
    .tinytorch-bar-links .link-text {
        display: none;
    }

    .tinytorch-bar-links a {
        padding: 0.5rem;
    }

    .tinytorch-bar-links .link-icon {
        font-size: 1.1rem;
    }

    .tinytorch-bar-badge {
        display: none;
    }

    .tinytorch-bar-left {
        gap: 0.5rem;
    }

    .tinytorch-bar-content {
        padding: 0 0.75rem;
    }

    .tinytorch-bar {
        height: 44px;
    }

    /* Keep download link visible but compact on mobile */
    .tinytorch-bar-links a.download-link {
        padding: 0.4rem 0.6rem;
    }
}

/* Extra small screens - minimal spacing */
@media (max-width: 480px) {
    .tinytorch-bar-links {
        gap: 0.1rem;
    }

    .tinytorch-bar-links a {
        padding: 0.4rem;
    }

    .tinytorch-bar-brand {
        font-size: 1rem;
    }

    .tinytorch-bar-brand .brand-fire {
        font-size: 0.9rem;
    }
}

/* ============================================
   Dark Mode - TinyTorch Bar
   ============================================ */

/* Light mode: bar stays dark (already dark by default) */
/* Dark mode: slightly adjust for better contrast */
html[data-theme="dark"] .tinytorch-bar {
    background: linear-gradient(135deg, #0f172a 0%, #020617 100%);
    border-bottom-color: #ea580c;
}

html[data-theme="dark"] .tinytorch-bar-links a {
    color: #d1d5db;
}

html[data-theme="dark"] .tinytorch-bar-links a:hover {
    background: rgba(249, 115, 22, 0.2);
    color: #ffffff;
}

html[data-theme="dark"] .tinytorch-bar-links a.download-link {
    background: rgba(249, 115, 22, 0.15);
    border-color: rgba(249, 115, 22, 0.4);
}

html[data-theme="dark"] .tinytorch-bar-links a.download-link:hover {
    background: rgba(249, 115, 22, 0.3);
    border-color: rgba(249, 115, 22, 0.6);
}

html[data-theme="dark"] .tinytorch-bar-badge {
    background: rgba(251, 191, 36, 0.15);
    border-color: rgba(251, 191, 36, 0.3);
}

/* Push down Jupyter Book header to make room for bar */
header.bd-header {
    margin-top: 3.5rem !important;
}

/* Hide icon links from sidebar completely - only show in top navbar */
.bd-sidebar .icon-links,
.bd-sidebar .navbar-icon-links,
.bd-sidebar-primary .icon-links,
.bd-sidebar-primary .navbar-icon-links,
.bd-sidebar-primary .pst-navbar-icon,
.bd-sidebar-primary a.pst-navbar-icon,
.bd-sidebar-primary li.nav-item:has(.pst-navbar-icon),
.sidebar-primary-items__end .icon-links,
.sidebar-primary-items__end .navbar-icon-links,
.sidebar-primary-items__end .nav-item,
.sidebar-primary-items__end .pst-navbar-icon,
a.nav-link.pst-navbar-icon:not(.bd-header *) {
    display: none !important;
}

/* Navbar icon links - keep on one line with proper spacing */
.navbar-icon-links {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 0.5rem !important;
    align-items: center !important;
}

.navbar-icon-links a,
.navbar-icon-links a.btn,
.navbar-icon-links a[href*="pdf"],
.navbar-icon-links a[href*="download"] {
    padding: 0.4rem 0.6rem !important;
    font-size: 0.85rem !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.3rem !important;
    border-radius: 6px !important;
    transition: background-color 0.2s ease !important;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    border-color: transparent !important;
    box-shadow: none !important;
    white-space: nowrap !important;
}

.navbar-icon-links a:hover {
    background-color: rgba(255, 130, 70, 0.15) !important;
}

.navbar-icon-links a i,
.navbar-icon-links a svg {
    font-size: 1rem !important;
}

/* Increase overall navbar height for breathing room - match MLSysBook */
.bd-header .navbar-header-items {
    min-height: 60px !important;
    padding: 0.75rem 0 !important;
}

/* Responsive navbar icons - hide text on smaller screens */
@media (max-width: 1200px) {
    .navbar-icon-links a span,
    .navbar-icon-links a .link-text {
        display: none !important;
    }
    .navbar-icon-links a {
        padding: 0.4rem !important;
    }
    .navbar-icon-links {
        gap: 0.25rem !important;
    }
}

@media (max-width: 768px) {
    .navbar-icon-links {
        gap: 0.15rem !important;
    }
    .navbar-icon-links a {
        padding: 0.3rem !important;
    }
    .navbar-icon-links a i,
    .navbar-icon-links a svg {
        font-size: 0.9rem !important;
    }
}

/* Add spacing to main content area */
.bd-container {
    padding-top: 0.5rem !important;
}

/* ============================================
   Interactive Timeline - ML History Journey
   ============================================ */

.ml-timeline-container {
    position: relative;
    max-width: 900px;
    margin: 2rem auto;
    padding: 1rem 0;
}

.ml-timeline-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg,
        #E74C3C 0%,     /* Perceptron - Red */
        #E67E22 20%,    /* XOR - Orange */
        #F39C12 40%,    /* MLP - Yellow */
        #3b82f6 60%,    /* CNN - Blue */
        #7b1fa2 80%,    /* Transformer - Purple */
        #c2185b 100%    /* Olympics - Pink */
    );
    transform: translateX(-50%);
    box-shadow: 0 0 8px rgba(0,0,0,0.1);
}

.ml-timeline-item {
    position: relative;
    margin-bottom: 2.5rem;
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

.ml-timeline-item:nth-child(1) { animation-delay: 0.1s; }
.ml-timeline-item:nth-child(2) { animation-delay: 0.2s; }
.ml-timeline-item:nth-child(3) { animation-delay: 0.3s; }
.ml-timeline-item:nth-child(4) { animation-delay: 0.4s; }
.ml-timeline-item:nth-child(5) { animation-delay: 0.5s; }
.ml-timeline-item:nth-child(6) { animation-delay: 0.6s; }

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

.ml-timeline-item.left .ml-timeline-content {
    margin-right: 55%;
    text-align: right;
}

.ml-timeline-item.right .ml-timeline-content {
    margin-left: 55%;
    text-align: left;
}

.ml-timeline-content {
    background: white;
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
}

.ml-timeline-content:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    border-color: currentColor;
}

.ml-timeline-dot {
    position: absolute;
    left: 50%;
    top: 1rem;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 3px solid;
    transform: translateX(-50%);
    z-index: 10;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.5);
    transition: all 0.3s ease;
}

.ml-timeline-item:hover .ml-timeline-dot {
    transform: translateX(-50%) scale(1.2);
    box-shadow: 0 0 0 6px rgba(255,255,255,0.8);
}

.ml-timeline-year {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 0.25rem 0;
    background: linear-gradient(135deg, currentColor, currentColor);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ml-timeline-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0.25rem 0;
    color: #1f2937;
}

.ml-timeline-desc {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0.25rem 0 0.5rem 0;
    line-height: 1.4;
}

.ml-timeline-tech {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.75rem;
    background: #f3f4f6;
    padding: 0.4rem 0.5rem;
    border-radius: 0.25rem;
    margin: 0.5rem 0 0 0;
    color: #374151;
    white-space: pre-line;
}

.ml-timeline-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

.ml-timeline-popup.active {
    display: flex;
}

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

.ml-timeline-popup-content {
    background: white;
    border-radius: 1rem;
    max-width: 700px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 2.5rem;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: slideUp 0.3s ease;
}

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

.ml-timeline-popup-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: #f3f4f6;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ml-timeline-popup-close:hover {
    background: #e5e7eb;
    color: #1f2937;
    transform: rotate(90deg);
}

.ml-timeline-popup h3 {
    margin: 0 0 1rem 0;
    font-size: 1.8rem;
    font-weight: 700;
}

.ml-timeline-popup-year {
    display: inline-block;
    background: linear-gradient(135deg, currentColor, currentColor);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 2rem;
    font-weight: 800;
    margin-right: 1rem;
}

.ml-timeline-popup-subtitle {
    font-size: 1.1rem;
    color: #6b7280;
    margin: 0.5rem 0 1.5rem 0;
    font-style: italic;
}

.ml-timeline-popup-section {
    margin: 1.5rem 0;
}

.ml-timeline-popup-section h4 {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 0.75rem 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ml-timeline-popup-section p,
.ml-timeline-popup-section ul {
    font-size: 0.95rem;
    color: #374151;
    line-height: 1.7;
    margin: 0.5rem 0;
}

.ml-timeline-popup-section ul {
    padding-left: 1.5rem;
}

.ml-timeline-popup-section li {
    margin: 0.375rem 0;
}

.ml-timeline-popup-code {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
    color: #1f2937;
    margin: 1rem 0;
    white-space: pre-line;
    line-height: 1.6;
}

.ml-timeline-popup-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 1rem 0;
}

.ml-timeline-popup-metric {
    background: #f9fafb;
    border-left: 3px solid currentColor;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
}

.ml-timeline-popup-metric-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.ml-timeline-popup-metric-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1f2937;
}

/* Color variants for each milestone */
.ml-timeline-item.perceptron .ml-timeline-dot { border-color: #E74C3C; }
.ml-timeline-item.perceptron .ml-timeline-year { color: #E74C3C; }
.ml-timeline-item.perceptron .ml-timeline-content:hover { border-color: #E74C3C; }
.ml-timeline-item.perceptron .ml-timeline-popup-year { color: #E74C3C; }

.ml-timeline-item.xor .ml-timeline-dot { border-color: #E67E22; }
.ml-timeline-item.xor .ml-timeline-year { color: #E67E22; }
.ml-timeline-item.xor .ml-timeline-content:hover { border-color: #E67E22; }
.ml-timeline-item.xor .ml-timeline-popup-year { color: #E67E22; }

.ml-timeline-item.mlp .ml-timeline-dot { border-color: #F39C12; }
.ml-timeline-item.mlp .ml-timeline-year { color: #F39C12; }
.ml-timeline-item.mlp .ml-timeline-content:hover { border-color: #F39C12; }
.ml-timeline-item.mlp .ml-timeline-popup-year { color: #F39C12; }

.ml-timeline-item.cnn .ml-timeline-dot { border-color: #3b82f6; }
.ml-timeline-item.cnn .ml-timeline-year { color: #3b82f6; }
.ml-timeline-item.cnn .ml-timeline-content:hover { border-color: #3b82f6; }
.ml-timeline-item.cnn .ml-timeline-popup-year { color: #3b82f6; }

.ml-timeline-item.transformer .ml-timeline-dot { border-color: #7b1fa2; }
.ml-timeline-item.transformer .ml-timeline-year { color: #7b1fa2; }
.ml-timeline-item.transformer .ml-timeline-content:hover { border-color: #7b1fa2; }
.ml-timeline-item.transformer .ml-timeline-popup-year { color: #7b1fa2; }

.ml-timeline-item.olympics .ml-timeline-dot { border-color: #c2185b; }
.ml-timeline-item.olympics .ml-timeline-year { color: #c2185b; }
.ml-timeline-item.olympics .ml-timeline-content:hover { border-color: #c2185b; }
.ml-timeline-item.olympics .ml-timeline-popup-year { color: #c2185b; }

/* Responsive design */
@media (max-width: 768px) {
    .ml-timeline-line {
        left: 30px;
    }

    .ml-timeline-dot {
        left: 30px;
    }

    .ml-timeline-item.left .ml-timeline-content,
    .ml-timeline-item.right .ml-timeline-content {
        margin-left: 60px;
        margin-right: 0;
        text-align: left;
    }

    .ml-timeline-popup-content {
        padding: 1.5rem;
        margin: 1rem;
    }

    .ml-timeline-popup-metrics {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Dark Mode Support
   ============================================ */

html[data-theme="dark"] {
    /* Dark mode background and text colors */
    --pst-color-background: #1a1a1a;
    --pst-color-on-background: #e0e0e0;
    --pst-color-surface: #242424;
    --pst-color-on-surface: #e0e0e0;

    /* Sidebar colors */
    --pst-color-sidebar-bg: #1f1f1f;
    --pst-color-sidebar-text: #e0e0e0;
    --pst-color-sidebar-link: #90caf9;
    --pst-color-sidebar-link-hover: #64b5f6;

    /* Code block colors */
    --pst-color-code-bg: #2d2d2d;
    --pst-color-code-text: #e0e0e0;
}

/* Dark mode - Logo treatment */
html[data-theme="dark"] .sidebar-brand-container img,
html[data-theme="dark"] .navbar-brand img,
html[data-theme="dark"] img.logo {
    background: #ffffff;
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Dark mode - Main content area */
html[data-theme="dark"] body {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

html[data-theme="dark"] .bd-main {
    background-color: #1a1a1a;
}

html[data-theme="dark"] .bd-container {
    background-color: #1a1a1a;
}

html[data-theme="dark"] .bd-content {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

/* Dark mode - Sidebar */
html[data-theme="dark"] .bd-sidebar {
    background-color: #1f1f1f !important;
    color: #e0e0e0;
}

html[data-theme="dark"] .bd-sidebar .nav-link {
    color: #b0b0b0 !important;
}

html[data-theme="dark"] .bd-sidebar .nav-link:hover {
    color: #90caf9 !important;
    background-color: #2a2a2a !important;
}

html[data-theme="dark"] .bd-sidebar .nav-link.active {
    color: #64b5f6 !important;
    background-color: #2d2d2d !important;
    border-left-color: #64b5f6 !important;
}

html[data-theme="dark"] .bd-sidebar .caption {
    color: #90caf9 !important;
}

/* Dark mode - Headers */
html[data-theme="dark"] .bd-header {
    background-color: #1f1f1f !important;
    color: #e0e0e0;
}

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6 {
    color: #f0f0f0;
}

/* Dark mode - Links */
html[data-theme="dark"] a {
    color: #90caf9;
}

html[data-theme="dark"] a:hover {
    color: #64b5f6;
}

/* Dark mode - Code blocks */
html[data-theme="dark"] pre,
html[data-theme="dark"] code {
    background-color: #2d2d2d !important;
    color: #e0e0e0 !important;
}

html[data-theme="dark"] .highlight {
    background-color: #2d2d2d !important;
}

/* Dark mode - Timeline */
html[data-theme="dark"] .ml-timeline-content {
    background-color: #2a2a2a;
    color: #e0e0e0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

html[data-theme="dark"] .ml-timeline-content:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

html[data-theme="dark"] .ml-timeline-title {
    color: #f0f0f0;
}

html[data-theme="dark"] .ml-timeline-desc {
    color: #b0b0b0;
}

html[data-theme="dark"] .ml-timeline-tech {
    background: #333333;
    color: #e0e0e0;
}

html[data-theme="dark"] .ml-timeline-dot {
    background: #1a1a1a;
}

html[data-theme="dark"] .ml-timeline-popup {
    background: rgba(0,0,0,0.8);
}

html[data-theme="dark"] .ml-timeline-popup-content {
    background-color: #2a2a2a;
    color: #e0e0e0;
}

html[data-theme="dark"] .ml-timeline-popup h3,
html[data-theme="dark"] .ml-timeline-popup h4 {
    color: #f0f0f0;
}

html[data-theme="dark"] .ml-timeline-popup-subtitle {
    color: #b0b0b0;
}

html[data-theme="dark"] .ml-timeline-popup-section p,
html[data-theme="dark"] .ml-timeline-popup-section ul {
    color: #d0d0d0;
}

html[data-theme="dark"] .ml-timeline-popup-code {
    background: #333333;
    border-color: #444444;
    color: #e0e0e0;
}

html[data-theme="dark"] .ml-timeline-popup-metric {
    background: #333333;
}

html[data-theme="dark"] .ml-timeline-popup-metric-label {
    color: #b0b0b0;
}

html[data-theme="dark"] .ml-timeline-popup-metric-value {
    color: #f0f0f0;
}

/* ============================================
   Hero Carousel - Compact User Journey Design
   ============================================ */

.hero-carousel-compact {
    position: relative;
    max-width: 1100px;
    margin: 2.5rem auto 3rem auto;
    padding: 0 2rem;
}

.carousel-track {
    position: relative;
    width: 100%;
    height: 450px;
    overflow: visible;
}

.carousel-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: none;
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
    z-index: 1;
}

.carousel-item.active {
    display: flex;
    flex-direction: column;
    opacity: 1;
    gap: 1.5rem;
    align-items: center;
    justify-content: flex-start;
}

.gif-preview {
    width: 100%;
    height: auto;
    background: #1e1e1e;
    border: 1px solid #2d2d2d;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: transform 0.3s ease;
    position: relative;
    overflow: hidden;
}

.gif-preview:hover {
    transform: scale(1.002);
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

.gif-preview img {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
    border-radius: 6px;
}

.preview-fallback {
    font-size: 6rem;
    opacity: 0.5;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

.gif-preview img:not([src=""]) + .preview-fallback,
.gif-preview img[src]:not([src=""]) + .preview-fallback {
    display: none;
}

.preview-icon {
    font-size: 6rem;
    opacity: 0.5;
}

.carousel-text {
    text-align: center;
    width: 100%;
    margin-top: 1rem;
    padding: 0 1rem;
}

.carousel-text h4 {
    font-size: 1.5rem;
    color: #1e293b;
    margin: 0 0 0.5rem 0;
    font-weight: 600;
    line-height: 1.3;
}

.carousel-text p {
    font-size: 0.95rem;
    color: #64748b;
    margin: 0;
    line-height: 1.6;
    font-family: 'Monaco', 'Menlo', monospace;
}

.carousel-nav {
    position: absolute;
    top: 405px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 100;
}

.nav-arrow {
    background: #e2e8f0;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.1rem;
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.nav-arrow:hover {
    background: #1e3a8a;
    color: white;
    transform: scale(1.1);
}

.carousel-indicators {
    display: none;
}

.indicator {
    display: none;
}

.indicator:hover {
    display: none;
}

.indicator.active {
    display: none;
}

/* Dark mode support */
html[data-theme="dark"] .gif-preview {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-color: #475569;
}

html[data-theme="dark"] .carousel-text h4 {
    color: #f1f5f9;
}

html[data-theme="dark"] .carousel-text p {
    color: #cbd5e1;
}

html[data-theme="dark"] .nav-arrow {
    background: #334155;
    color: #cbd5e1;
}

html[data-theme="dark"] .nav-arrow:hover {
    background: #3b82f6;
    color: white;
}

html[data-theme="dark"] .indicator {
    background: #475569;
}

html[data-theme="dark"] .indicator:hover {
    background: #64748b;
}

html[data-theme="dark"] .indicator.active {
    background: #3b82f6;
}

/* Comparison grid responsive wrapping - stack on tablets and smaller */
@media (max-width: 1024px) {
    .comparison-grid {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }
}

/* Responsive design */
@media (max-width: 768px) {
    /* Make logo visible and prominent on mobile */
    .navbar-brand {
        display: flex !important;
        align-items: center;
        padding: 0.5rem 0;
    }

    .navbar-brand img {
        max-height: 50px !important;
        width: auto;
    }

    /* Ensure main content headings are visible above carousel */
    .bd-content h1 {
        font-size: 2rem !important;
        margin-top: 1rem !important;
        line-height: 1.2 !important;
    }

    .bd-content h2 {
        font-size: 1.5rem !important;
        margin: 1rem 0 !important;
    }

    .bd-content > p {
        font-size: 1rem !important;
        margin-bottom: 1.5rem !important;
    }

    /* Stack comparison grid vertically on mobile - tighter spacing */
    .comparison-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
        margin: 2rem 0 1.5rem 0 !important;
    }

    /* Carousel adjustments */
    .hero-carousel-compact {
        padding: 0 1rem;
        margin: 1.5rem auto 2rem auto;
    }

    .gif-preview {
        height: auto;
        border-radius: 6px;
    }

    .gif-preview img {
        border-radius: 4px;
    }

    .carousel-track {
        height: 350px;
        overflow: visible;
    }

    .carousel-nav {
        top: 330px;
    }

    .nav-arrow {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .carousel-item.active {
        gap: 1rem;
    }
}

html[data-theme="dark"] .ml-timeline-popup-close {
    background: #333333;
    color: #b0b0b0;
}

html[data-theme="dark"] .ml-timeline-popup-close:hover {
    background: #444444;
    color: #f0f0f0;
}

/* Dark mode - Tier cards */
html[data-theme="dark"] .bd-content > div[style*="grid"] > div[style*="background"] {
    filter: brightness(0.7);
}

/* Dark mode - Table styling */
html[data-theme="dark"] table {
    background-color: #2a2a2a;
}

html[data-theme="dark"] th {
    background-color: #333333;
    color: #f0f0f0;
}

html[data-theme="dark"] td {
    background-color: #2a2a2a;
    color: #e0e0e0;
    border-color: #444444;
}

html[data-theme="dark"] tr:hover {
    background-color: #333333;
}

/* Dark mode - Mermaid diagrams */
html[data-theme="dark"] .mermaid table {
    background-color: #2a2a2a;
}

html[data-theme="dark"] .mermaid th {
    background: linear-gradient(135deg, #cc5800 0%, #cc7700 50%, #dd8826 100%) !important;
}

html[data-theme="dark"] .mermaid td {
    background-color: #2a2a2a !important;
    border-color: #555555 !important;
}

/* Dark mode - Admonitions and boxes */
html[data-theme="dark"] .admonition {
    background-color: #2a2a2a;
    border-left-color: #64b5f6;
}

html[data-theme="dark"] .admonition-title {
    background-color: #333333;
    color: #f0f0f0;
}

/* Dark mode - Navigation footer */
html[data-theme="dark"] .prev-next-area {
    border-top-color: #444444;
}

html[data-theme="dark"] .prev-next-info a {
    color: #90caf9;
}

html[data-theme="dark"] .prev-next-info a:hover {
    color: #64b5f6;
}

/* ==========================================================================
   Footer Styling - Clean default Jupyter Book footer
   ========================================================================== */

/* Tighten footer spacing */
.bd-footer,
footer.bd-footer {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
    margin-top: 0 !important;
    font-size: 0.875rem;
}
