/* ============================================================
   HiMu Project Page — Styles
   ============================================================ */

:root {
    /* Colors */
    --color-bg-dark: #1a1040;
    --color-bg-dark-2: #2d1b69;
    --color-bg-light: #faf9fc;
    --color-bg-alt: #f3f1f8;
    --color-bg-card: #ffffff;
    --color-accent-primary: #c0392b;
    --color-accent-secondary: #e67e22;
    --color-accent-gradient: linear-gradient(135deg, #c0392b, #e67e22);
    --color-text-primary: #1a1a2e;
    --color-text-secondary: #5a5a7a;
    --color-text-on-dark: #f0edf5;
    --color-text-muted: #8a8aaa;
    --color-border: #e8e5f0;
    --color-border-dark: #3a2a6a;

    /* Expert colors */
    --color-clip: #7c3aed;
    --color-ovd: #e74c3c;
    --color-ocr: #f39c12;
    --color-asr: #3498db;
    --color-clap: #1abc9c;

    /* Typography */
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Spacing */
    --section-padding: 5rem 0;
    --container-max: 1100px;
    --container-narrow: 800px;

    /* Transitions */
    --transition: 0.25s ease;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.12);
    --radius: 12px;
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 70px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    color: var(--color-text-primary);
    line-height: 1.6;
    background: var(--color-bg-light);
}

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

a {
    text-decoration: none;
    color: inherit;
}

/* ---- Layout ---- */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 1.5rem;
}

.container--narrow {
    max-width: var(--container-narrow);
}

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

.section--light {
    background: var(--color-bg-light);
}

.section--alt {
    background: var(--color-bg-alt);
}

.section--dark {
    background: linear-gradient(135deg, var(--color-bg-dark), var(--color-bg-dark-2));
    color: var(--color-text-on-dark);
}

.section-title {
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    font-weight: 700;
    text-align: center;
    margin-bottom: 1.5rem;
    letter-spacing: -0.02em;
}

.section-intro {
    text-align: center;
    max-width: 750px;
    margin: 0 auto 2.5rem;
    color: var(--color-text-secondary);
    font-size: 1.05rem;
    line-height: 1.7;
}

.section--dark .section-intro {
    color: rgba(240, 237, 245, 0.8);
}

/* ---- Navigation ---- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: transparent;
    overflow: visible;
    transition: background var(--transition), box-shadow var(--transition), backdrop-filter var(--transition);
}

.navbar.scrolled {
    background: rgba(26, 16, 64, 0.95);
    backdrop-filter: blur(12px);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
}

.nav-container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 74px;
}

.nav-logo {
    font-size: 1.6rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.02em;
}

.nav-logo:hover {
    background: var(--color-accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.nav-links a {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
    font-weight: 500;
    transition: color var(--transition);
    position: relative;
}

.nav-links a:hover,
.nav-links a.active {
    color: #fff;
}

.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--color-accent-gradient);
    border-radius: 1px;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.nav-toggle span {
    width: 24px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform var(--transition), opacity var(--transition);
}

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

.nav-toggle.open span:nth-child(2) {
    opacity: 0;
}

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

/* ---- Hero ---- */
.hero {
    background: linear-gradient(135deg, var(--color-bg-dark) 0%, var(--color-bg-dark-2) 50%, #1a1040 100%);
    color: var(--color-text-on-dark);
    padding: 7rem 1.5rem 4rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 50%, rgba(192, 57, 43, 0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 50%, rgba(230, 126, 34, 0.06) 0%, transparent 50%);
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 850px;
    margin: 0 auto;
}

.venue-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.3rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: 1.5rem;
}

.nav-institution-logo {
    height: 74px;
    width: auto;
    object-fit: contain;
    padding: 4px 0;
}

.hero-title {
    font-size: clamp(4rem, 10vw, 7rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
    line-height: 1.1;
}

.accent-text {
    background: var(--color-accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: clamp(1.1rem, 3vw, 1.6rem);
    font-weight: 300;
    color: rgba(240, 237, 245, 0.85);
    margin-bottom: 2rem;
    line-height: 1.5;
}

.authors {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.3rem 1.5rem;
    margin-bottom: 0.5rem;
}

.author {
    font-size: 1.05rem;
    font-weight: 500;
}

.affiliations {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.85rem;
    color: rgba(240, 237, 245, 0.65);
    margin-bottom: 2rem;
}

.hero-buttons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 3rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.4rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font-body);
    border: none;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

.btn:hover {
    transform: translateY(-1px);
}

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

.btn-primary:hover {
    box-shadow: 0 4px 15px rgba(192, 57, 43, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.1);
}

.btn-accent {
    background: rgba(230, 126, 34, 0.15);
    color: var(--color-accent-secondary);
    border: 1px solid rgba(230, 126, 34, 0.3);
}

.btn-accent:hover {
    background: rgba(230, 126, 34, 0.25);
}

.btn-disabled {
    opacity: 0.6;
    cursor: default;
    pointer-events: none;
}

/* Hero Teaser */
.hero-teaser {
    position: relative;
    z-index: 1;
    max-width: 900px;
    margin: 0 auto;
}

.teaser-card {
    background: var(--color-bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.teaser-card img {
    border-radius: 8px;
    margin: 0 auto;
}

.teaser-card figcaption {
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    text-align: center;
    margin-top: 1rem;
    line-height: 1.5;
}

/* ---- Stats Banner ---- */
.stats-banner {
    padding: 3rem 0;
    background: var(--color-bg-card);
    border-bottom: 1px solid var(--color-border);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.stat-card {
    text-align: center;
    padding: 1.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: var(--color-bg-light);
    transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-number {
    font-size: clamp(1.3rem, 2.5vw, 1.8rem);
    font-weight: 800;
    background: var(--color-accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.3rem;
}

.stat-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 0.2rem;
}

.stat-detail {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* ---- Abstract ---- */
.abstract-text {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--color-text-secondary);
    border-left: 3px solid;
    border-image: var(--color-accent-gradient) 1;
    padding-left: 1.5rem;
}

.abstract-text p {
    margin-bottom: 1rem;
}

.abstract-text p:last-child {
    margin-bottom: 0;
}

/* ---- Method Section ---- */
.pipeline-figure {
    margin: 2rem auto 3rem;
    background: #ffffff;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.pipeline-figure img {
    border-radius: 8px;
    margin: 0 auto;
}

.steps-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-top: 2rem;
}

.step-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--color-border-dark);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.step-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.15);
}

.step-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.step-icon--purple { background: rgba(124, 58, 237, 0.2); color: var(--color-clip); }
.step-icon--red { background: rgba(231, 76, 60, 0.2); color: var(--color-ovd); }
.step-icon--amber { background: rgba(243, 156, 18, 0.2); color: var(--color-ocr); }
.step-icon--teal { background: rgba(26, 188, 156, 0.2); color: var(--color-clap); }

.step-number {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-text-muted);
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.step-card h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.step-card p {
    font-size: 0.85rem;
    color: rgba(240, 237, 245, 0.7);
    line-height: 1.5;
}

/* ---- Figures ---- */
.figure-card {
    background: var(--color-bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    max-width: 850px;
    margin: 0 auto;
}

.figure-card--wide {
    max-width: 1000px;
}

.figure-card img {
    border-radius: 8px;
    margin: 0 auto;
}

.figure-card figcaption {
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    text-align: center;
    margin-top: 1rem;
    line-height: 1.5;
}

.lightbox-trigger {
    cursor: zoom-in;
    transition: opacity var(--transition);
}

.lightbox-trigger:hover {
    opacity: 0.9;
}

/* ---- Results ---- */
.results-efficiency {
    margin-bottom: 3rem;
}

.results-table-section {
    margin-bottom: 2rem;
}

.table-tabs {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg-card);
    color: var(--color-text-secondary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.tab-btn:hover {
    border-color: var(--color-accent-primary);
    color: var(--color-accent-primary);
}

.tab-btn.active {
    background: var(--color-accent-gradient);
    color: #fff;
    border-color: transparent;
}

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--color-bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.5rem;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    white-space: nowrap;
}

.results-table th {
    background: var(--color-bg-alt);
    padding: 0.75rem 1rem;
    text-align: center;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
    border-bottom: 2px solid var(--color-border);
}

.results-table th:first-child,
.results-table td:first-child {
    text-align: left;
    padding-left: 1.2rem;
}

.results-table td {
    padding: 0.65rem 1rem;
    text-align: center;
    border-bottom: 1px solid var(--color-border);
}

.highlight-row {
    background: rgba(192, 57, 43, 0.06);
}

.highlight-row td {
    border-bottom-color: rgba(192, 57, 43, 0.15);
}

.gray-row {
    color: var(--color-text-muted);
    font-style: italic;
}

.table-divider td {
    padding: 0;
    height: 2px;
    background: var(--color-border);
    border: none;
}

.table-caption {
    text-align: center;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 0.75rem;
}

.gray-text {
    color: var(--color-text-muted);
}

/* Side-by-side ablation tables */
.ablation-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .ablation-grid {
        grid-template-columns: 1fr;
    }
}

/* Sub-table titles within panels */
.table-subtitle {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: 0.75rem;
    padding-left: 0.5rem;
}

/* Spacing between stacked table wrappers */
.table-panel .table-wrapper + .table-wrapper {
    margin-top: 1.5rem;
}

/* Section header rows (e.g. latency breakdown groups) */
.results-table .section-header-row td {
    font-weight: 600;
    font-style: italic;
    color: var(--color-text-secondary);
    background: var(--color-bg-alt);
    border-bottom: 1px solid var(--color-border);
}

.results-highlight {
    max-width: 800px;
    margin: 0 auto;
}

.highlight-card {
    background: var(--color-bg-card);
    border-left: 4px solid;
    border-image: var(--color-accent-gradient) 1;
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow);
    font-size: 1rem;
    line-height: 1.7;
    color: var(--color-text-secondary);
}

/* ---- Citation / BibTeX ---- */
.bibtex-block {
    position: relative;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--color-border-dark);
    border-radius: var(--radius);
    padding: 1.5rem;
    overflow-x: auto;
}

.bibtex-block pre {
    margin: 0;
}

.bibtex-block code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: rgba(240, 237, 245, 0.9);
    line-height: 1.6;
    white-space: pre;
}

.copy-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    padding: 0.4rem 0.9rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.8);
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.35);
}

.copy-btn.copied {
    background: rgba(26, 188, 156, 0.2);
    border-color: var(--color-clap);
    color: var(--color-clap);
}

/* ---- Lightbox ---- */
.lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    padding: 2rem;
    cursor: zoom-out;
}

.lightbox-overlay.active {
    display: flex;
}

.lightbox-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    font-size: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-content {
    max-width: 95vw;
    max-height: 90vh;
    overflow: auto;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
}

/* ---- Footer ---- */
.footer {
    background: var(--color-bg-dark);
    color: var(--color-text-muted);
    text-align: center;
    padding: 2rem 1.5rem;
    font-size: 0.85rem;
}

/* ---- Scroll Animations ---- */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.visible {
    opacity: 1;
    transform: none;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .steps-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    :root {
        --section-padding: 3.5rem 0;
    }

    .nav-toggle {
        display: flex;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 74px;
        left: 0;
        right: 0;
        background: rgba(26, 16, 64, 0.98);
        backdrop-filter: blur(12px);
        flex-direction: column;
        padding: 1rem 1.5rem;
        gap: 0;
        border-top: 1px solid var(--color-border-dark);
    }

    .nav-links.open {
        display: flex;
    }

    .nav-links li {
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .nav-links a {
        display: block;
        padding: 0.75rem 0;
    }

    .hero {
        padding: 6rem 1.5rem 3rem;
    }

    .authors {
        flex-direction: column;
        gap: 0.2rem;
    }

    .hero-buttons {
        flex-direction: column;
        align-items: center;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .steps-grid {
        grid-template-columns: 1fr;
    }

    .table-tabs {
        flex-direction: column;
        align-items: center;
    }
}

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

    .hero-title {
        font-size: 2.5rem;
    }

    .nav-institution-logo {
        height: 74px;
        width: auto;
    }
}
