/* CSS Variables for consistent theming */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --accent-color: #667eea;
    --accent-dark: #764ba2;
    --success-color: #28a745;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --text-dark: #333333;
    --text-light: #666666;
    --border-light: #eeeeeee;
    --shadow: 0 4px 8px rgba(0,0,0,0.1);
    --shadow-hover: 0 8px 16px rgba(0,0,0,0.15);
    --border-radius: 10px;
    --transition: all 0.3s ease;
    --math-bg: #f0f4ff;
    --math-border: #d1e7ff;
    
    /* Header height - will be calculated dynamically by JavaScript */
    --header-height: 360px; /* Default fallback value */
    
    /* Animation timing configuration - change these values to control timing */
    --animation-duration: 1s;
    --animation-duration-header: 0.5s;
    
    /* Animation delay options */
    --animation-delay-short: 0.2s;
    --animation-delay-medium: 0.5s;
    --animation-delay-long: 1s;
    
    /* Animation easing functions */
    --animation-ease-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --animation-ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --animation-ease-sharp: cubic-bezier(0.55, 0.085, 0.68, 0.53);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
}

/* Full-width header */
.paper-header {
    background: var(--primary-gradient);
    color: white;
    padding: 40px 0;
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    margin-bottom: 40px;
    box-shadow: var(--shadow);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    text-align: center;
}

.paper-header h1 {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 700;
    margin-bottom: 25px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.authors {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.author {
    text-align: center;
    line-height: 1;
}

.author br {
    line-height: 0;
    margin: 0;
    padding: 0;
}

.author strong {
    display: block;
    font-size: 1.1em;
    margin-bottom: 0px;
}

.author .affiliation {
    display: block;
    font-size: 0.85em;
    color: rgba(255,255,255,0.8);
    font-style: italic;
    margin-bottom: 8px;
    line-height: 1.3;
}

.author a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-size: 0.9em;
}

.author a:hover {
    color: white;
    text-decoration: underline;
}

.affiliation-unified {
    text-align: center;
    font-size: 0.9em;
    color: rgba(255,255,255,0.85);
    font-style: italic;
    margin: 25px 0;
    line-height: 1.4;
}

.paper-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.paper-link {
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 12px 24px;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 500;
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

.paper-link:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-2px);
}

/* Main container with sidebar */
.main-container {
    max-width: 1200px; /* Back to original centered width */
    margin: 0 auto;
    padding: 0 20px;
    /* Remove flex layout - content takes full width */
}

/* Sidebar navigation - positioned relative to viewport */
.sidebar-nav {
    width: 170px;
    position: fixed;
    top: calc(var(--header-height, 360px) + 20px); /* Dynamic based on header height + margin */
    left: 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: calc(100vh - var(--header-height, 360px) - 40px); /* Dynamic max-height */
    overflow-y: auto;
    transition: top 0.3s ease;
}

/* When header is scrolled past, stick to top */
.sidebar-nav.sticky {
    top: 20px;
    max-height: calc(100vh - 40px);
}

.sidebar-nav h3 {
    color: var(--accent-color);
    margin-bottom: 8px;
    font-size: 0.75em;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    margin-bottom: 2px;
}

.sidebar-nav a {
    display: block;
    color: var(--text-dark);
    text-decoration: none;
    padding: 4px 6px;
    border-radius: 3px;
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.75em;
    opacity: 0.7;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--accent-color);
    color: white;
    opacity: 1;
    transform: translateX(1px);
}

/* Animation toggle */
.animation-toggle {
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    gap: 8px;
    font-size: 0.7em;
    color: var(--text-dark);
    opacity: 0.8;
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 32px;
    height: 16px;
    background: #ccc;
    border-radius: 16px;
    transition: var(--transition);
    flex-shrink: 0;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: var(--transition);
}

.toggle-label input[type="checkbox"]:checked + .toggle-slider {
    background: var(--accent-color);
}

.toggle-label input[type="checkbox"]:checked + .toggle-slider::before {
    transform: translateX(16px);
}

.toggle-text {
    font-weight: 500;
    user-select: none;
}

/* Main content area */
.content {
    /* Content now takes full width of centered container */
    width: 100%;
}

section {
    margin-bottom: 50px;
}

h2 {
    color: var(--accent-color);
    border-bottom: 3px solid var(--accent-color);
    padding-bottom: 15px;
    margin: 40px 0 25px 0;
    font-size: 2em;
}

h3 {
    color: var(--accent-dark);
    margin: 30px 0 15px 0;
    font-size: 1.4em;
}

/* Content blocks */
.content-block {
    background: var(--bg-white);
    padding: 35px;
    border-radius: var(--border-radius);
    border-left: 5px solid var(--accent-color);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

/* Strong elements should always be bold and visible */
.content-block strong {
    font-weight: 700 !important;
    color: var(--text-dark) !important;
    opacity: 1 !important;
}

/* Examples within content blocks */
.content-block .examples-grid {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.content-block .examples-grid figure {
    flex: 1;
    margin: 0;
    text-align: center;
}

.content-block .examples-grid img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.content-block .examples-grid figcaption {
    margin-top: 10px;
    font-weight: 600;
    color: var(--accent-color);
    font-size: 1em;
}

.content-block .colorbar-container {
    text-align: center;
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
    margin-bottom: 30px;
}

.content-block .colorbar-container img {
    max-width: 16%;
    height: auto;
    border-radius: 1px;
}

.content-block .colorbar-label {
    margin-top: 10px;
    font-weight: 600;
    color: var(--text-dark);
    font-style: italic;
    font-size: 0.8em;
}

.abstract {
    background: var(--bg-white);
    padding: 35px;
    border-radius: var(--border-radius);
    border-left: 5px solid var(--accent-color);
    font-size: 1.1em;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    /* make it wider */
    width: 100%;
}

.abstract::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
    background: var(--primary-gradient);
}

.abstract p,
.content-block p {
    margin-bottom: 20px;
}

.abstract p:last-child,
.content-block p:last-child {
    margin-bottom: 0;
}

/* Math blocks */
.math-block {
    background: var(--math-bg);
    border: 2px solid var(--math-border);
    border-radius: 8px;
    padding: 20px;
    margin: 25px 0;
    text-align: center;
    font-family: 'KaTeX_Math', 'Latin Modern Math', 'Computer Modern', 'Cambria Math', 'Times New Roman', serif;
    font-size: 1.3em;
    font-weight: bold;
    color: var(--accent-dark);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    line-height: 1.4;
}

/* MathJax styling */
.MathJax {
    font-size: 1.2em !important;
}

.MathJax_Display {
    font-size: 1.4em !important;
    margin: 20px 0 !important;
}

/* Ensure MathJax uses Latin Modern Math font when available */
.MathJax svg {
    font-family: 'Latin Modern Math', 'Computer Modern', serif !important;
}


/* Examples container with colorbar */
.examples-container {
    background: var(--bg-white);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin: 30px 0;
}

.examples-grid {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.examples-grid figure {
    flex: 1;
    margin: 0;
    text-align: center;
}

.examples-container img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.examples-container figcaption {
    margin-top: 10px;
    font-weight: 600;
    color: var(--accent-color);
    font-size: 1em;
}

.colorbar-container {
    text-align: center;
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
}

.colorbar-container img {
    max-width: 16%;
    height: auto;
    border-radius: 1px;
}

.colorbar-label {
    margin-top: 10px;
    font-weight: 600;
    color: var(--text-dark);
    font-style: italic;
    font-size: 0.8em;
}

/* Demo containers - auto height */
.demo-container {
    margin: 20px 0 0 0;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    background: var(--bg-light);
    border: 1px solid var(--border-light);
}

.demo-container iframe {
    width: 100%;
    min-height: 700px;
    height: 700px;
    border: none;
    display: block;
    overflow: hidden;
}

/* Specific demo container heights */
.demo-container.llada iframe {
    min-height: 630px;
    height: 630px;
}

.demo-container.diffucoder iframe {
    min-height: 790px;
    height: 790px;
}

/* Demo containers within content blocks */
.content-block .demo-container {
    margin: 20px 0 0 0;
}

.content-block h3 + .demo-container {
    margin-top: 15px;
}

/* Spacing between multiple demos in same content block */
.content-block .demo-container + h3 {
    margin-top: 40px;
}

/* Side-by-side benchmark tables */
.benchmark-tables {
    display: flex;
    gap: 30px;
    margin: 30px 0;
}

.table-container {
    flex: 1;
}

.table-container h3 {
    margin-bottom: 15px;
    text-align: center;
}

.benchmark-table {
    overflow-x: auto;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    background: var(--bg-white);
}

table {
    width: 100%;
    border-collapse: collapse;
    border-radius: var(--border-radius);
    overflow: hidden;
}

th, td {
    padding: 18px;
    text-align: center;
    border-bottom: 1px solid var(--border-light);
    transition: var(--transition);
}

th {
    background: var(--primary-gradient);
    color: white;
    font-weight: 600;
    font-size: 1em;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

tr {
    transition: var(--transition);
}

tr:hover {
    background: var(--bg-light);
}

tr:hover td {
    color: var(--accent-dark);
}

.dus-score {
    font-weight: bold;
    color: var(--success-color);
    position: relative;
}

.dus-score::before {
    content: '🎯';
    margin-right: 5px;
}

.key-takeaways {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    padding: 30px;
    border-radius: var(--border-radius);
    border-left: 5px solid #2196f3;
    margin: 30px 0;
    box-shadow: var(--shadow);
}

.key-takeaways h4 {
    color: #1976d2;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.key-takeaways ul {
    margin-left: 20px;
}

.key-takeaways li {
    margin-bottom: 10px;
}

.theory-section {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    padding: 30px;
    border-radius: var(--border-radius);
    border-left: 5px solid #ff9800;
    margin: 30px 0;
    box-shadow: var(--shadow);
}

/* BibTeX section */
.bibtex-section {
    background: var(--bg-white);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.bibtex {
    background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
    color: #e2e8f0;
    padding: 25px;
    border-radius: var(--border-radius);
    font-family: 'Monaco', 'Consolas', 'Courier New', monospace;
    font-size: 0.9em;
    overflow-x: auto;
    box-shadow: var(--shadow);
    /* cursor: pointer; */
    white-space: pre; /*-line;*/
    line-height: 1.4;
}

.bibtex:hover {
    box-shadow: var(--shadow-hover);
}

/* Scroll animations */
.scroll-animate {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity var(--animation-duration) var(--animation-ease-smooth), 
                transform var(--animation-duration) var(--animation-ease-smooth);
}

.scroll-animate.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Animation utility classes */
.slide-up {
    animation: slideUp var(--animation-duration) var(--animation-ease-smooth) forwards;
}

.bounce-in {
    animation: bounceIn var(--animation-duration) var(--animation-ease-bounce) forwards;
}

/* Additional keyframes for utility classes */
@keyframes slideUp {
    from { 
        opacity: 0; 
        transform: translateY(30px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

@keyframes bounceIn {
    0% { 
        opacity: 0; 
        transform: scale(0.3); 
    }
    50% { 
        opacity: 1; 
        transform: scale(1.1); 
    }
    100% { 
        opacity: 1; 
        transform: scale(1); 
    }
}

/* Text reveal animation - diffusion effect only, no fade-in */
.text-reveal {
    display: inline-block;
    opacity: 1; /* Always visible - no fade-in */
}

@keyframes revealText {
    0% {
        opacity: 1; /* Start visible */
    }
    100% {
        opacity: 1; /* Stay visible */
    }
}

/* Initially hide text elements that will be animated - but only when they haven't been processed yet */
.paper-header:not(.animated) p, .paper-header:not(.animated) h1, .paper-header:not(.animated) h2, .paper-header:not(.animated) h3, .paper-header:not(.animated) h4,
.paper-header:not(.animated) .author strong, .paper-header:not(.animated) .author a, .paper-header:not(.animated) .affiliation-unified, .paper-header:not(.animated) .paper-link,
#abstract:not(.animated) p, #abstract:not(.animated) h1, #abstract:not(.animated) h2, #abstract:not(.animated) h3, #abstract:not(.animated) h4,
#abstract:not(.animated) .math-block, #abstract:not(.animated) figcaption,
.scroll-animate:not(.animated) p, .scroll-animate:not(.animated) li, .scroll-animate:not(.animated) ul, .scroll-animate:not(.animated) ol, .scroll-animate:not(.animated) h1, 
.scroll-animate:not(.animated) h2, .scroll-animate:not(.animated) h3, .scroll-animate:not(.animated) h4, .scroll-animate:not(.animated) .math-block, 
.scroll-animate:not(.animated) figcaption, .scroll-animate:not(.animated) strong {
    opacity: 0;
}

/* Always show strong elements regardless of animation state */
strong {
    opacity: 1 !important;
    font-weight: 700 !important;
}

/* Show text elements after animation setup */
.text-animated {
    opacity: 1;
}

/* Responsive design */
@media (max-width: 768px) {
    .main-container {
        padding: 0 15px;
    }

    .sidebar-nav {
        position: relative;
        width: 100%;
        left: auto;
        top: auto;
        margin-bottom: 20px;
        max-height: none;
    }

    .sidebar-nav ul {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }

    .sidebar-nav li {
        margin-bottom: 0;
    }

    .sidebar-nav a {
        padding: 8px 12px;
        font-size: 0.9em;
    }

    .paper-header {
        padding: 30px 0;
    }

    .authors {
        flex-direction: column;
        gap: 20px;
    }

    .examples-grid {
        flex-direction: column;
        gap: 15px;
    }

    .benchmark-tables {
        flex-direction: column;
        gap: 20px;
    }

    th, td {
        padding: 12px 8px;
        font-size: 0.9em;
    }

    .demo-container iframe {
        min-height: 600px;
    }
}

@media (max-width: 480px) {
    .abstract, .content-block, .key-takeaways, .theory-section, .bibtex-section {
        padding: 20px;
    }

    .math-block {
        font-size: 1em;
        padding: 15px;
    }

    .paper-links {
        flex-direction: column;
        align-items: center;
    }
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-light);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-gradient);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-dark);
}

/* Focus styles for accessibility */
a:focus, button:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .paper-header, .sidebar-nav {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
    }
    
    .demo-container {
        display: none;
    }
    
    .main-container {
        flex-direction: column;
    }
    
    .sidebar-nav {
        display: none;
    }
}

/* Code formatting and indentation styles - Strong specificity */
.content-block {
    /* Use consistent indentation for nested elements */
    font-family: inherit;
}

.content-block > * {
    margin-left: 0 !important;
}

.content-block h3 {
    margin-left: 0 !important;
    margin-top: 30px;
    margin-bottom: 15px;
}

.content-block h4 {
    margin-left: 30px !important;
    margin-top: 25px;
    margin-bottom: 12px;
    color: var(--accent-dark);
    font-weight: 600;
}

.content-block p {
    margin-left: 0 !important;
    text-align: justify;
    line-height: 1.6;
}

/* Following h4, indent paragraphs and lists with double indentation */
.content-block h4 + p,
.content-block h4 + ul,
.content-block h4 + ol {
    margin-left: 60px !important;
}

/* All elements after h4 until next h3 should have double indentation */
.content-block h4 ~ p:not(h3 ~ p):not(.conclusion),
.content-block h4 ~ ul:not(h3 ~ ul),
.content-block h4 ~ ol:not(h3 ~ ol),
.content-block h4 ~ .MathJax_Display:not(h3 ~ .MathJax_Display) {
    margin-left: 60px !important;
}

/* Conclusion paragraphs should have no indentation */
.content-block p.conclusion {
    margin-left: 0 !important;
}

.content-block ul {
    margin-left: 30px !important;
    padding-left: 20px !important;
}

.content-block ol {
    margin-left: 30px !important;
    padding-left: 20px !important;
}

/* Override for lists under h4 */
.content-block h4 ~ ul,
.content-block h4 ~ ol {
    margin-left: 60px !important;
    padding-left: 20px !important;
}

.content-block li {
    margin-bottom: 8px;
    line-height: 1.5;
    margin-left: 0 !important;
}

/* Nested lists */
.content-block ul ul,
.content-block ol ol,
.content-block ul ol,
.content-block ol ul {
    margin-left: 20px !important;
    margin-top: 8px;
    margin-bottom: 8px;
}

/* Math blocks indentation - double for h4 sections */
.content-block .math-block {
    margin-left: 60px !important;
    margin-right: 60px !important;
}

/* Math display blocks under h4 get double indentation */
.content-block h4 ~ .MathJax_Display {
    margin-left: 60px !important;
    margin-right: 60px !important;
}

/* Horizontal rules */
.content-block hr {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Special indentation for items that contain math blocks */
.content-block li .math-block {
    margin-left: 20px !important;
    margin-right: 20px !important;
    margin-top: 10px;
    margin-bottom: 10px;
}

/* Reset margins for elements directly under h3 */
.content-block h3 + p,
.content-block h3 + ul,
.content-block h3 + ol {
    margin-left: 0 !important;
}

/* Paragraphs following math blocks should maintain h4 indentation */
.content-block .MathJax_Display + p {
    margin-left: 60px !important;
}

/* Any paragraph between h4 and h3 should be indented */
.content-block h4 ~ p {
    margin-left: 60px !important;
}
