/* ==========================================================================
   PAPER LAYOUT - Portable 3-Column Layout System for Academic Project Pages
   ========================================================================== */

/* === CSS CUSTOM PROPERTIES === */
:root {
    /* Layout Dimensions (reduced by 1.2x) */
    --layout-toc-width: 225px;
    --layout-content-width: 720px;
    --layout-sidenote-width: 183px;
    --layout-gap: 33px;

    /*
     * Side Column Gap - Distance between main content and TOC/sidenotes
     * Adjust this value to change spacing symmetrically on both sides
     * - TOC will be positioned: (content left edge) - toc-width - this gap
     * - Sidenotes will be positioned: (content right edge) + this gap
     */
    --layout-side-gap: 180px;

    /* Colors */
    --bg-page: #ffffff;
    --bg-header: linear-gradient(135deg, #ffffff 0%, #f8f6f2 40%, #fdf8f0 100%);
    --text-primary: #1a1a1a;
    --text-secondary: #444;
    --text-muted: #666;
    --accent: #2563eb;
    --border-light: #e5e5e5;

    /* Typography */
    --font-serif: 'Bitstream Charter', 'Charter', Georgia, serif;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --text-base: 18px;
    --leading-relaxed: 1.75;

    /* Spacing */
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
}

/* === BASE STYLES === */
body {
    background-color: var(--bg-page);
    font-family: var(--font-serif);
    font-size: var(--text-base);
    line-height: var(--leading-relaxed);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
}

/* === HEADER (Outside Grid) === */
.paper-header {
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-light);
    padding: var(--space-xl) var(--space-lg);
}

/* Header wrapper with hero background */
.header-wrapper {
    position: relative;
    border-bottom: 1px solid #e5e2dd;
}

.header-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('../img/hero_image.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    z-index: 0;
    pointer-events: none;
}

.paper-header-inner {
    max-width: 1200px;
    margin: 0 auto;
}

/* === CENTERED CONTENT LAYOUT (TOC & Sidenotes are fixed) === */
.paper-layout {
    display: block;
    max-width: var(--layout-content-width);
    margin: 0 auto;
    padding: var(--space-xl) var(--space-md);
}

/* === TABLE OF CONTENTS (Fixed Left Edge) === */
.paper-toc {
    position: fixed;
    left: var(--space-md);
    top: 120px;
    width: var(--layout-toc-width);
    height: fit-content;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    line-height: 1.5;
    z-index: 100;
}

.paper-toc h4 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 0 0 var(--space-md) 0;
}

.paper-toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.paper-toc li {
    margin-bottom: var(--space-sm);
}

.paper-toc a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
    display: block;
    padding: 2px 0;
}

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

.paper-toc a.active {
    color: var(--accent);
    font-weight: 500;
}

/* === MAIN CONTENT (Centered) === */
.paper-content {
    width: 100%;
    min-width: 0;
}

/* All direct children use full width of content column */
.paper-content > * {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
}

/* Typography in content */
.paper-content h1 {
    font-size: 2rem;
    margin: var(--space-2xl) 0 var(--space-lg) 0;
    line-height: 1.3;
}

.paper-content h2 {
    font-size: 1.6rem;
    margin: var(--space-xl) 0 var(--space-md) 0;
    line-height: 1.3;
}

.paper-content h3 {
    font-size: 1.3rem;
    margin: var(--space-lg) 0 var(--space-md) 0;
    line-height: 1.4;
}

.paper-content p {
    margin: 0 0 var(--space-lg) 0;
    font-size: 1.1rem;
}

/* Figures - same width as text */
.paper-content figure {
    width: 100%;
    margin: var(--space-xl) 0;
}

.paper-content figure img {
    width: 100%;
    height: auto;
    display: block;
}

.paper-content figcaption {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: var(--space-sm);
    line-height: 1.5;
    text-align: left;
}

/* Tables - same width as text */
.paper-content table {
    width: 100%;
    margin: var(--space-xl) 0;
    border-collapse: collapse;
}

/* === SIDENOTES === */
.sidenote-container {
    position: relative;
}

/* Mobile default: sidenotes appear inline */
.sidenote {
    display: block;
    font-family: var(--font-sans);
    font-size: 1.02rem;
    line-height: 1.5;
    color: var(--text-muted);
    margin: var(--space-md) 0;
    padding: var(--space-sm) var(--space-md);
    background: #f8f9fa;
    border-left: 3px solid #94a3b8;
    font-style: normal;
    border-radius: 0 4px 4px 0;
}

/* Desktop: sidenotes fixed at right edge */
@media (min-width: 1200px) {
    .sidenote {
        position: fixed;
        right: var(--space-md);
        top: 120px;
        width: var(--layout-sidenote-width);
        max-height: calc(100vh - 160px);
        overflow-y: auto;
        margin: 0;
        padding: 0 0 0 var(--space-md);
        background: none;
        border-left: 1px solid var(--border-light);
        border-radius: 0;
        z-index: 100;
    }
}

/* .paper-sidenotes placeholder no longer needed - sidenotes are fixed positioned */

/* === RESPONSIVE DESIGN === */

/* Tablet/Narrow Desktop: Hide TOC, content centered */
@media (max-width: 1199px) {
    .paper-layout {
        display: block;
        max-width: var(--layout-content-width);
        margin: 0 auto;
        padding: var(--space-lg);
    }

    .paper-toc {
        display: none;
    }

    .paper-content {
        width: 100%;
    }

    /* Sidenotes become inline blocks */
    .sidenote {
        position: static;
        width: 100%;
    }
}

/* Mobile: Full width with minimal padding */
@media (max-width: 767px) {
    .paper-layout {
        padding: var(--space-md);
    }

    .paper-content h1 {
        font-size: 1.6rem;
    }

    .paper-content h2 {
        font-size: 1.4rem;
    }

    .paper-content h3 {
        font-size: 1.2rem;
    }

    .paper-content p {
        font-size: 1rem;
    }
}

/* === UTILITY CLASSES === */

/* Horizontal rule */
.paper-content hr {
    border: none;
    border-top: 1px solid var(--border-light);
    margin: var(--space-2xl) 0;
}

/* Links */
.paper-content a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.paper-content a:hover {
    border-bottom-color: var(--accent);
}

/* Lists */
.paper-content ol,
.paper-content ul {
    margin: 0 0 var(--space-lg) var(--space-lg);
    padding: 0;
}

.paper-content li {
    margin-bottom: var(--space-sm);
}

/* Blockquotes */
.paper-content blockquote {
    margin: var(--space-lg) 0;
    padding: var(--space-md) var(--space-lg);
    background: #f8f9fa;
    border-left: 4px solid var(--accent);
    font-style: italic;
    color: var(--text-secondary);
}

/* Code blocks */
.paper-content pre {
    background: #f5f5f5;
    padding: var(--space-md);
    border-radius: 4px;
    overflow-x: auto;
    font-size: 0.9rem;
    margin: var(--space-lg) 0;
}

.paper-content code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.9em;
}

/* === BYLINE / AUTHOR INFO === */
.paper-byline {
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
    padding: var(--space-lg) 0;
    margin-bottom: var(--space-xl);
    text-align: center;
}

.paper-byline a {
    color: var(--text-primary);
    text-decoration: none;
}

.paper-byline a:hover {
    color: var(--accent);
}

/* === KEY FINDINGS === */
.key-findings {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin: var(--space-xl) 0;
    padding: var(--space-lg);
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border-light);
}

.key-findings-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 0 0 var(--space-sm) 0;
}

.key-finding {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
}

.key-finding-number {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
}

.key-finding-text {
    flex: 1;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-primary);
    margin: 0;
}

.key-finding-text strong {
    color: var(--accent);
}

@media (max-width: 767px) {
    .key-findings {
        padding: var(--space-md);
    }

    .key-finding-number {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }

    .key-finding-text {
        font-size: 0.95rem;
    }
}

/* === FINDING BOX - Gray callout for inline findings === */
.finding-box {
    background-color: rgba(240, 240, 240, 0.9);
    border: 1.2pt solid rgba(25, 25, 25, 0.6);
    border-radius: 10pt;
    padding: 2pt 10pt;
    margin: 1em 0;
    box-shadow: 2px 2px 4px rgba(128, 128, 128, 0.3);
    box-sizing: border-box;
}

.finding-box ul {
    margin: 0.5em 0;
    padding-left: 1.2em;
    list-style-type: disc;
}

.finding-box li {
    margin-bottom: 0.5em;
    line-height: 1.5;
}

.finding-box li:last-child {
    margin-bottom: 0;
}

/* === AUDIO PLAYER === */
.audio-player {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f8f9fa;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    max-width: 500px;
    margin: 0 auto;
}

.audio-player-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.audio-player-btn:hover {
    background: #1d4ed8;
    transform: scale(1.05);
}

.audio-player-btn svg {
    width: 16px;
    height: 16px;
    fill: white;
}

.audio-player-btn .pause-icon {
    display: none;
}

.audio-player.playing .audio-player-btn .play-icon {
    display: none;
}

.audio-player.playing .audio-player-btn .pause-icon {
    display: block;
}

.audio-player-progress {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.audio-player-bar {
    width: 100%;
    height: 4px;
    background: #e5e5e5;
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.audio-player-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s linear;
}

.audio-player-time {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.audio-player-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.audio-player-speed {
    padding: 4px 8px;
    background: white;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 42px;
    text-align: center;
}

.audio-player-speed:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.audio-player-share {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: white;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.audio-player-share:hover {
    border-color: var(--accent);
}

.audio-player-share svg {
    width: 14px;
    height: 14px;
    fill: var(--text-muted);
}

.audio-player-share:hover svg {
    fill: var(--accent);
}

/* Mobile responsive */
@media (max-width: 480px) {
    .audio-player {
        flex-wrap: wrap;
        gap: 10px;
    }

    .audio-player-progress {
        order: 3;
        width: 100%;
        flex: none;
    }

    .audio-player-controls {
        margin-left: auto;
    }
}

/* === CENTRAL HEADER TEMPLATE === */
.central-header {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 20px;
    text-align: center;
    position: relative;
    z-index: 1;
}

.central-header .title-section h1 {
    font-size: 2.2rem;
    margin: 0;
    line-height: 1.3;
    color: var(--text-primary);
}

.central-header .title-section h2 {
    font-size: 1.6rem;
    margin: 0.3em 0 0 0;
    line-height: 1.3;
    font-weight: 400;
    color: var(--text-secondary);
}

/* Authors - right after title */
.central-header .authors {
    margin: 20px 0;
    font-size: 1rem;
    line-height: 1.8;
    position: relative;
    z-index: 10;
}

.central-header .authors a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    position: relative;
    z-index: 10;
}

.central-header .authors a:hover {
    text-decoration: underline;
}

.central-header .affiliations {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.central-header .author-note {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

/* TL;DR blockquote style */
.central-header .tldr-section {
    margin: 25px auto;
    max-width: 800px;
    text-align: left;
    padding: 15px 20px;
    border-left: 4px solid var(--accent);
    background: #f8f9fa;
}

.central-header .tldr-section p {
    margin: 0;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

.central-header .tldr-section strong {
    color: var(--accent);
}

.central-header .tldr-section .tldr-label {
    font-weight: 700;
    color: var(--text-primary);
    margin-right: 6px;
}

/* Key points + image two column */
.central-header .hero-section {
    display: flex;
    gap: 40px;
    margin: 30px auto;
    max-width: 1000px;
    text-align: left;
    align-items: flex-start;
}

.central-header .hero-section > .key-points {
    flex: 1;
}

.central-header .hero-section > .hero-media {
    flex: 1;
}

.central-header .key-points {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.central-header .key-point {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.central-header .key-point-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    margin-top: 2px;
}

.central-header .key-point-text {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.central-header .key-point-text strong {
    color: var(--accent);
    font-weight: 600;
}

.central-header .hero-media {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.central-header .hero-media img,
.central-header .hero-media video {
    max-width: 100%;
    height: auto;
    transition: max-height 0.2s ease;
}

/* Button container */
.central-header .button-row {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
    margin-top: 25px;
    flex-wrap: wrap;
    position: relative;
    z-index: 10;
}

.central-header .button-row a {
    position: relative;
    z-index: 10;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: #fef3cd;
    color: #1a1a1a;
    border: 1.5px solid #dfc36a;
    border-radius: 50px;
    padding: 8px 18px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.central-header .button-row a:hover {
    background-color: #fce8a6;
    border-color: #c9a84a;
    box-shadow: 0 3px 8px rgba(0,0,0,0.12);
}

/* Responsive */
@media (max-width: 768px) {
    .central-header .title-section h1 {
        font-size: 1.6rem;
    }

    .central-header .title-section h2 {
        font-size: 1.2rem;
    }

    .central-header .tldr-section {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .central-header .hero-section {
        grid-template-columns: 1fr;
        gap: 25px;
    }

    .central-header .hero-media {
        order: -1;
    }
}
