/* ==================== CSS VARIABLES ==================== */
:root {
    /* Warm earth-tone palette inspired by Nerfies */
    --color-bg: #faf8f5;
    --color-bg-alt: #f5f2ed;
    --color-text: #2d2a26;
    --color-text-light: #5c5650;
    --color-text-muted: #8a817a;

    /* Primary accent - warm terracotta/brown */
    --color-primary: #8b5a3c;
    --color-primary-hover: #6d4530;
    --color-accent-warm: #c17f59;

    /* Secondary accent - muted sage green */
    --color-secondary: #5a7a6a;
    --color-secondary-hover: #456051;

    /* Neutral borders and cards */
    --color-border: #d9d4cc;
    --color-card-bg: #fffefc;
    --color-accent-bg: #f0ece5;

    /* Minimal shadows */
    --shadow-sm: 0 1px 3px rgba(45, 42, 38, 0.08);
    --shadow-md: 0 2px 8px rgba(45, 42, 38, 0.12);

    /* Minimal radius - academic feel */
    --radius: 2px;
    --radius-lg: 4px;

    --max-width: 1000px;
    --font-serif: 'Georgia', 'Times New Roman', serif;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', Consolas, monospace;
}

/* ==================== RESET & BASE ==================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    font-size: 14.5px;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

a:hover {
    border-bottom-color: var(--color-primary);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ==================== LAYOUT ==================== */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
}

section {
    padding: 36px 0;
}

section:nth-child(even) {
    background-color: var(--color-bg-alt);
}

/* ==================== HEADER ==================== */
.site-header {
    background: linear-gradient(180deg, #fffefc 0%, var(--color-bg) 100%);
    padding: 56px 0 40px;
    text-align: center;
    border-bottom: 1px solid var(--color-border);
}

.paper-title {
    font-family: var(--font-serif);
    font-size: clamp(2.2rem, 5vw, 3.2rem);
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: -2px;
    letter-spacing: -0.01em;
}

.paper-subtitle {
    font-family: var(--font-serif);
    font-size: clamp(1.15rem, 2.5vw, 1.8rem);
    color: var(--color-text-light);
    font-weight: 400;
    margin-bottom: 22px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.4;
    white-space: nowrap;
}

/* Authors */
.authors {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 20px;
    margin-bottom: 14px;
}

.author {
    font-size: 1rem;
}

.author a {
    color: var(--color-text);
    font-weight: 500;
    border-bottom: none;
}

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

.author sup {
    color: var(--color-text-muted);
    font-size: 0.7em;
    margin-left: 2px;
}

/* Affiliations */
.affiliations {
    color: var(--color-text-light);
    font-size: 0.88rem;
    margin-bottom: 28px;
}

.affiliations p {
    margin: 3px 0;
}

.affiliations sup {
    color: var(--color-text-muted);
    font-size: 0.7em;
}

/* Button Bar - Minimal Academic Style */
.button-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--radius);
    font-size: 0.92rem;
    font-weight: 500;
    transition: all 0.15s ease;
    border: 1px solid var(--color-border);
    cursor: pointer;
    background: transparent;
    color: var(--color-text);
}

.btn-primary {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background-color: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    text-decoration: none;
    border-bottom-color: transparent;
}

.btn-secondary {
    background-color: transparent;
    border-color: var(--color-border);
    color: var(--color-text);
}

.btn-secondary:hover {
    background-color: var(--color-accent-bg);
    border-color: var(--color-text-muted);
    text-decoration: none;
    border-bottom-color: transparent;
}

.btn .icon {
    width: 16px;
    height: 16px;
}

/* ==================== TEASER SECTION ==================== */
section.teaser-section {
    padding: 24px 0 36px;
    background-color: #ffffff;
}

.teaser-figure {
    margin: 0;
    text-align: center;
}

.teaser-figure img {
    margin: 0 auto;
}

.teaser-figure figcaption {
    max-width: 100%;
    margin: 16px auto 0;
    color: var(--color-text-light);
    font-size: 0.9rem;
    line-height: 1.55;
}

/* ==================== ABSTRACT SECTION ==================== */
.abstract-section h2,
.method-section h2,
.technical-section h2,
.results-section h2,
.video-section h2,
.citation-section h2,
.acknowledgements-section h2 {
    font-family: var(--font-serif);
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 18px;
    color: var(--color-text);
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 8px;
}

.abstract-section p {
    font-size: 0.97rem;
    margin-bottom: 10px;
    color: var(--color-text);
    text-align: justify;
}

/* ==================== VIDEO SECTION ==================== */
.video-section {
    background-color: var(--color-bg-alt);
}

/* Video Row Titles */
.video-row-title {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 28px 0 12px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--color-border);
}

.video-row-title:first-of-type {
    margin-top: 20px;
}

/* ==================== VIDEO CAROUSEL ==================== */
.video-carousel {
    position: relative;
    margin-bottom: 24px;
}

.carousel-track {
    display: flex;
    gap: 20px;
    overflow-x: hidden;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    padding-bottom: 8px;
}

.video-carousel .video-card {
    flex: 0 0 calc((100% - 40px) / 3);
    min-width: 260px;
    scroll-snap-align: start;
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

/* Carousel Dots Navigation */
.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
    padding: 8px 0;
}

.carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: none;
    background: var(--color-border);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.carousel-dot:hover {
    background: var(--color-accent-warm);
}

.carousel-dot.active {
    background: var(--color-primary);
    transform: scale(1.1);
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.video-card {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.video-wrapper {
    position: relative;
    aspect-ratio: 16 / 9;
    background: var(--color-accent-bg);
}

.video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.video-card .video-caption {
    padding: 10px 14px;
    margin: 0;
    font-size: 0.88rem;
    color: var(--color-text-light);
    text-align: center;
    background: var(--color-card-bg);
}

.video-placeholder {
    aspect-ratio: 16 / 9;
    background: var(--color-accent-bg);
    border: 2px dashed var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.placeholder-content {
    text-align: center;
    padding: 16px;
    color: var(--color-text-muted);
}

.placeholder-content svg {
    width: 40px;
    height: 40px;
    margin-bottom: 8px;
    opacity: 0.5;
}

.placeholder-hint {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 6px;
}

.video-instructions {
    margin-top: 36px;
    padding: 18px;
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
}

.video-instructions h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.video-instructions ol {
    margin-left: 18px;
    color: var(--color-text-light);
    font-size: 0.9rem;
}

.video-instructions li {
    margin: 6px 0;
}

.video-instructions pre {
    background: var(--color-accent-bg);
    padding: 10px;
    margin-top: 6px;
    overflow-x: auto;
    font-size: 0.85rem;
}

.video-instructions code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

/* ==================== VIDEO COMPARISON SLIDER ==================== */
.video-compare-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--color-accent-bg);
    overflow: hidden;
    cursor: col-resize;
}

.video-compare-container .video-bg,
.video-compare-container .video-fg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-compare-container .video-bg {
    z-index: 1;
}

.video-compare-container .video-fg {
    z-index: 2;
    clip-path: inset(0 50% 0 0);
}

.compare-slider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    background: #fff;
    z-index: 3;
    transform: translateX(-50%);
    box-shadow: 0 0 10px rgba(0,0,0,0.3);
}

.compare-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 24px;
    background: #fff;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    cursor: col-resize;
    pointer-events: none;
}

.compare-handle svg {
    width: 4px;
    height: 8px;
    color: var(--color-text);
}

.video-labels {
    position: absolute;
    top: 10px;
    left: 0;
    right: 0;
    z-index: 4;
    display: flex;
    justify-content: space-between;
    padding: 0 10px;
    pointer-events: none;
}

.video-label {
    background: rgba(45, 42, 38, 0.85);
    color: #fff;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 2px;
}

.video-compare-container:hover .compare-handle {
    transform: translate(-50%, -50%) scale(1.1);
    transition: transform 0.15s ease;
}

/* Comparison slider placeholder */
.compare-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-accent-bg);
    z-index: 5;
}

.compare-placeholder .placeholder-content {
    text-align: center;
    padding: 16px;
    color: var(--color-text-muted);
}

.compare-placeholder .placeholder-content svg {
    width: 40px;
    height: 40px;
    margin-bottom: 8px;
    opacity: 0.5;
}

/* Hide placeholder when videos are loaded */
.video-compare-container.has-videos .compare-placeholder {
    display: none;
}

/* ==================== METHOD SECTION ==================== */
.method-section {
    background-color: #fffefc;
}

/* ==================== TECHNICAL DETAILS SECTION ==================== */
section.technical-section {
    background-color: #faf8f5;
}

.technical-section h2 {
    font-family: var(--font-serif);
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 0;
    color: var(--color-text);
    border-bottom: none;
    padding-bottom: 0;
}

/* Technical Details Toggle Header */
.technical-details-header {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    padding: 8px 0;
    margin: 0;
    position: relative;
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 8px;
}

.technical-details-header:hover {
    background-color: rgba(255, 255, 255, 0.3);
    margin-left: -12px;
    margin-right: -12px;
    padding-left: 12px;
    padding-right: 12px;
    border-radius: var(--radius);
}

.technical-toggle-icon {
    width: 24px;
    height: 24px;
    color: var(--color-text-muted);
    transition: transform 0.3s ease;
    flex-shrink: 0;
    transform: rotate(90deg);
}

/* Collapsed: arrow points left, Expanded: arrow points down (90deg) */
.technical-details-header.collapsed .technical-toggle-icon {
    transform: rotate(180deg);
}

/* Technical Details Content */
.technical-details-content {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
    max-height: 20000px;
    opacity: 1;
    margin-top: 18px;
}

.technical-details-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

.technical-section h3 {
    font-size: 1.12rem;
    font-weight: 600;
    margin: 20px 0 8px;
    color: var(--color-text);
}

.technical-section h4 {
    font-size: 0.98rem;
    font-weight: 600;
    margin: 14px 0 6px;
    color: var(--color-text-light);
}

.technical-section p {
    margin-bottom: 10px;
    font-size: 0.95rem;
    color: var(--color-text);
    text-align: justify;
}

.method-section p {
    margin-bottom: 10px;
    font-size: 0.95rem;
    color: var(--color-text);
    text-align: justify;
}

.method-figure,
.results-figure,
.process-figure {
    margin: 18px 0;
    text-align: center;
}

.method-figure img,
.results-figure img,
.process-figure img {
    margin: 0 auto;
}

.method-figure figcaption,
.results-figure figcaption,
.process-figure figcaption {
    max-width: 100%;
    margin: 12px auto 0;
    color: var(--color-text-light);
    font-size: 0.88rem;
    line-height: 1.5;
}

/* Method section subheadings */
.method-section h3 {
    font-size: 1.12rem;
    font-weight: 600;
    margin: 20px 0 8px;
    color: var(--color-text);
}

.method-section h4 {
    font-size: 0.98rem;
    font-weight: 600;
    margin: 14px 0 6px;
    color: var(--color-text-light);
}

/* ==================== PARADIGM HIGHLIGHT ==================== */
.paradigm-highlight {
    background: var(--color-accent-bg);
    border-left: 3px solid var(--color-accent-warm);
    padding: 12px 16px;
    margin: 0 0 18px;
}

.paradigm-highlight h3 {
    font-family: var(--font-serif);
    color: var(--color-primary);
    font-size: 1.1rem;
    margin: 0 0 10px 0;
}

.paradigm-highlight p {
    margin: 8px 0;
    font-size: 0.95rem;
}

.paradigm-highlight p:last-child {
    margin-bottom: 0;
}

/* ==================== METHOD FORMULAS ==================== */
.formula-box {
    background: var(--color-accent-bg);
    border-left: 2px solid var(--color-secondary);
    padding: 8px 14px;
    margin: 10px 0;
    overflow-x: auto;
    font-size: 0.92rem;
}

.formula-row {
    margin: 6px 0;
    line-height: 1.5;
}

.formula-row:first-child {
    margin-top: 0;
}

.formula-row:last-child {
    margin-bottom: 0;
}

/* ==================== RESULTS SECTION ==================== */
.results-section {
    background-color: #fffefc;
}

.results-section p {
    margin-bottom: 14px;
    font-size: 0.97rem;
}

.results-section h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 28px 0 16px;
    color: var(--color-text);
}

/* ==================== QUALITATIVE COMPARISON VIDEOS ==================== */
.qualitative-video-area {
    margin: 28px 0;
}

.qualitative-video-title {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 12px 0;
    padding-bottom: 6px;
    /* border-bottom: 1px solid var(--color-border); */
}

.qualitative-video-wrapper {
    width: 100%;
    background: var(--color-accent-bg);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.qualitative-video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.qualitative-video-caption {
    margin: 10px 0 0;
    font-size: 0.9rem;
    color: var(--color-text-light);
    text-align: center;
}

/* ==================== QUALITATIVE COMPARISON ROWS ==================== */
.comparison-row {
    margin: 24px 0;
}

.comparison-case {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--color-border);
}

.comparison-case:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.case-title {
    font-size: 0.92rem;
    color: var(--color-text-light);
    margin-bottom: 12px;
    font-style: italic;
}

.comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.comparison-item {
    position: relative;
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.comparison-item.highlight {
    box-shadow: 0 0 0 2px var(--color-secondary);
}

.comparison-item img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.method-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(45, 42, 38, 0.85);
    color: #fff;
    padding: 6px 10px;
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
}

.method-label.method-ours {
    background: var(--color-secondary);
}

/* Results figures container */
.results-figures {
    margin-top: 36px;
}

.results-figures .results-figure {
    margin: 24px 0;
}

.results-figures .results-figure:first-child {
    margin-top: 0;
}

/* ==================== CITATION SECTION ==================== */
section.citation-section {
    background-color: #faf8f5;
}

.bibtex-box {
    position: relative;
    margin-top: 16px;
}

.bibtex-box pre {
    background: #2d2a26;
    color: #f5f2ed;
    padding: 16px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.5;
}

.bibtex-box code {
    font-family: inherit;
}

.copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: #f5f2ed;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 5px 10px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ==================== ACKNOWLEDGEMENTS ==================== */
.acknowledgements-section {
    background-color: #f5f2ed;
}

.acknowledgements-section p {
    margin-bottom: 10px;
    color: var(--color-text-light);
    font-size: 0.95rem;
}

/* ==================== FOOTER ==================== */
.site-footer {
    background: #faf8f5;
    border-top: 1px solid var(--color-border);
    padding: 24px 0;
    text-align: center;
}

.site-footer p {
    color: var(--color-text-light);
    font-size: 0.88rem;
}

.footer-note {
    color: var(--color-text-muted);
    font-size: 0.82rem;
    margin-top: 4px;
}

/* ==================== CAROUSEL RESPONSIVE ==================== */
@media (max-width: 900px) {
    .video-carousel .video-card {
        flex: 0 0 calc((100% - 20px) / 2);
    }
}

@media (max-width: 600px) {
    .video-carousel .video-card {
        flex: 0 0 100%;
    }

    .carousel-track {
        gap: 16px;
    }
}

/* ==================== RESPONSIVE DESIGN ==================== */
@media (max-width: 768px) {
    section {
        padding: 36px 0;
    }

    .container {
        padding: 0 16px;
    }

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

    .author {
        font-size: 0.95rem;
    }

    .affiliations {
        font-size: 0.82rem;
    }

    .button-bar {
        flex-direction: column;
        align-items: center;
    }

    .btn {
        width: 180px;
        justify-content: center;
    }

    .video-grid,
    .comparison-grid {
        grid-template-columns: 1fr;
    }

    .abstract-section h2,
    .method-section h2,
    .technical-section h2,
    .results-section h2,
    .video-section h2,
    .citation-section h2,
    .acknowledgements-section h2 {
        font-size: 1.35rem;
    }
}

@media (max-width: 480px) {
    .site-header {
        padding: 40px 0 28px;
    }

    .paper-title {
        font-size: 1.7rem;
    }

    .method-section h3,
    .technical-section h3,
    .results-section h3 {
        font-size: 1.05rem;
    }
}
