/* High-End Nostalgia Editorial Theme */
:root {
    --primary: #a63b00;
    --primary-container: #ffa17b;
    --secondary: #6a5f1a;
    
    --surface: #fbfae6;
    --surface-container-low: #f6f5e1;
    --surface-container-highest: #e4e4d0;
    --surface-container-lowest: #ffffff;
    
    --on-surface: #1f1a14;
    --on-surface-variant: #534433;
    --outline-variant: rgba(217, 195, 172, 0.2); /* Ghost Border Fallback */

    /* Ambient Shadow */
    --ambient-shadow: 0 8px 32px rgba(31, 26, 20, 0.06);

    /* Plyr overrides */
    --plyr-color-main: var(--primary);
    --plyr-video-background: var(--surface-container-low);
}

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

body {
    font-family: 'Work Sans', sans-serif;
    color: var(--on-surface-variant);
    background-color: var(--surface);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Subtle underlying pattern or warmth if requested, though we stick to pure surface color */
#ambient-background {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--surface);
    z-index: -1;
}

/* Animations */
.fade-in {
    animation: fadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.scale-up {
    animation: scaleUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

@keyframes scaleUp {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Global Header & Nav matching main site */
.site-header {
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 50;
    background-color: var(--surface);
    transition: all 0.2s ease-in-out;
}

.site-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1280px; /* max-w-7xl */
    margin: 0 auto;
    padding: 1rem 1.5rem; /* px-6 py-4 */
}

.brand-link {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
    text-decoration: none;
    letter-spacing: -0.05em; /* tracking-tighter */
}

.desktop-nav-links {
    display: flex;
    gap: 2rem; /* gap-8 */
    align-items: center;
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.25;
}

.desktop-nav-links a {
    color: var(--on-surface-variant);
    text-decoration: none;
    transition: color 0.2s ease-in-out;
    padding-bottom: 0.25rem; /* pb-1 */
    border-bottom: 2px solid transparent;
}

.desktop-nav-links a:hover {
    color: var(--primary);
}

.desktop-nav-links a.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    padding: 0.5rem; /* p-2 */
    color: var(--on-surface-variant);
    font-size: 1.5rem;
    cursor: pointer;
}

.mobile-menu-dropdown {
    display: none;
    flex-direction: column;
    gap: 1rem; /* gap-4 */
    background-color: var(--surface);
    border-top: 1px solid var(--outline-variant);
    padding: 1rem 1.5rem; /* py-4 px-6 */
    font-weight: 600;
}

.mobile-menu-dropdown a {
    color: var(--on-surface-variant);
    text-decoration: none;
    transition: color 0.2s ease;
}

.mobile-menu-dropdown a:hover {
    color: var(--primary);
}

.mobile-menu-dropdown a.text-primary {
    color: var(--primary);
}

/* Layout Wrappers */
.app-wrapper {
    flex: 1;
    padding: 2rem 1.5rem;
    gap: 1.5rem;
    display: flex;
    flex-direction: column;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

.hidden {
    display: none !important;
}

/* Glass Header - Editorial treatment */
.glass-header {
    background: rgba(251, 250, 230, 0.7); /* Semi-transparent surface */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    
    /* NO 1px solid Borders. Use layered surface shifts or shadow */
    box-shadow: var(--ambient-shadow);
    border-radius: 0.375rem; /* rounding */
    padding: 1.5rem 2rem;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    font-weight: 700;
    font-size: 1.75rem; /* display-sm */
    letter-spacing: -0.05em; /* tightly tracked for nostalgia */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--on-surface);
}

.brand i {
    color: var(--primary);
}

.file-details {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--surface-container-low);
    padding: 0.75rem 1.5rem;
    border-radius: 999px; /* full rounding scale for chips/tags */
    font-size: 0.95rem; /* body-md */
    color: var(--on-surface-variant);
    
    /* No border, rely on tonal shift */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 40vw;
}

#file-name {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Download Button (Primary CTA) */
.download-link {
    background: linear-gradient(to bottom, var(--primary), var(--primary-container));
    color: #ffffff;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem; /* rounded-md */
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: var(--ambient-shadow);
}

.download-link:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

/* Main Container - Tonal Layering */
.glass-container {
    background: var(--surface-container-lowest);
    box-shadow: var(--ambient-shadow);
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible; /* Let content grow naturally — page scrolls, not inner box */
    position: relative;
    padding: 2rem;
}

.loader {
    font-size: 2.5rem;
    color: var(--primary);
}

/* Media Overrides */
.glass-container img {
    max-width: 100%;
    max-height: 70vh; /* Force image to fit inside screen without scrolling */
    object-fit: contain;
    border-radius: 0.25rem;
}

.glass-container .plyr--video {
    width: 100%;
    max-height: 70vh; /* Force video player to fit inside screen bounds */
    border-radius: 0.25rem;
    overflow: hidden;
}

.glass-container .plyr--audio {
    width: 100%;
    max-width: 600px;
    border-radius: 0.375rem;
    box-shadow: var(--ambient-shadow);
    background: var(--surface-container-low);
    color: var(--on-surface-variant);
}

.glass-container object {
    width: 100%;
    height: 100%;
    border-radius: 0.25rem;
}

/* Error / Info States */
.state-panel {
    text-align: center;
    padding: 4rem; /* spacing-12 logic */
    max-width: 600px;
}

.state-panel i {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 2rem;
}

.state-panel h1 {
    font-size: 1.5rem; /* headline-md */
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--on-surface);
}

.state-panel p {
    color: var(--on-surface-variant);
    line-height: 1.6;
    font-size: 1rem; /* body-md */
}

/* Percentage Loader UI */
.global-progress-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 6rem 2rem;
    width: 100%;
    text-align: center;
}

.progress-text {
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.05em;
    line-height: 1;
}

.progress-label {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--on-surface-variant);
    margin-top: -0.5rem;
}

.progress-bar-container {
    width: 100%;
    max-width: 250px;
    height: 6px;
    background: var(--outline-variant);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(to right, var(--primary-container), var(--primary));
    border-radius: 999px;
    transition: width 0.1s linear;
}

/* Global Footer matching main site */
.site-footer {
    width: 100%;
    background-color: var(--surface-container-low);
    border-top: 1px solid var(--outline-variant);
    margin-top: auto;
}

.footer-content {
    max-width: 1280px; /* max-w-7xl */
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3rem 2rem; /* py-12 px-8 */
    font-size: 0.875rem; /* text-sm */
    color: var(--on-surface-variant);
}

.copyright {
    text-align: left;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2rem; /* gap-8 */
}

.footer-links a {
    color: var(--on-surface-variant);
    text-decoration: none;
    font-size: 0.875rem; /* text-sm */
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .site-navbar {
        padding: 1rem 1.5rem;
    }
    
    .brand-link {
        font-size: 1.25rem; /* text-xl */
    }

    .desktop-nav-links {
        display: none;
    }

    .mobile-menu-btn {
        display: block;
    }

    /* JavaScript will toggle from 'none' to 'flex' on this wrapper directly */
    .mobile-menu-dropdown.show {
        display: flex;
    }
    
    /* Footer Breakdown */
    .footer-content {
        flex-direction: column;
        padding: 2.5rem 2rem; /* py-10 px-8 */
    }
    .copyright {
        margin-bottom: 1.5rem; /* mb-6 */
        text-align: center;
    }
    .footer-links {
        column-gap: 1.5rem; /* gap-x-6 */
        row-gap: 1rem; /* gap-y-4 */
    }
    .footer-links a {
        font-size: 0.75rem; /* text-xs */
    }

    /* App Wrapper Breakdown */
    .app-wrapper {
        padding: 1.5rem 1rem;
        justify-content: flex-start; /* Better vertical flow on small screens */
        padding-top: 1rem;
    }
    .header-content {
        flex-direction: column;
        align-items: center; /* Force all header items to act as a center column */
        text-align: center;
        gap: 1rem;
    }
    .brand {
        justify-content: center;
        width: 100%;
    }
    .file-details {
        width: 100%;
        max-width: none;
        justify-content: center;
    }
    .download-link {
        width: 100%;
        border-radius: 999px; /* Make it a full row CTA on mobile for easy thumb tapping */
    }
    .glass-container {
        padding: 1rem; /* Tighten media padding */
    }
}

/* PDF.js Viewer - Natural Flow (page scrolls, not inner box) */
.pdf-viewer-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.pdf-controls {
    position: sticky;
    top: 4rem; /* Sits just below the sticky navbar */
    z-index: 40;
    flex-shrink: 0;
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: center;
    background: rgba(246, 245, 225, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 0.6rem 1.5rem;
    border-radius: 999px;
    margin: 0 auto 1.5rem auto;
    box-shadow: var(--ambient-shadow);
    color: var(--on-surface-variant);
    font-weight: 500;
    font-size: 0.9rem;
    width: fit-content;
    max-width: 100%;
}

.pdf-page-info {
    min-width: 80px;
    text-align: center;
    white-space: nowrap;
}

.pdf-nav-btn {
    background: linear-gradient(to bottom, var(--primary), var(--primary-container));
    color: #ffffff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--ambient-shadow);
    font-size: 0.8rem;
}

.pdf-nav-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.pdf-nav-btn:disabled {
    background: var(--surface-container-highest);
    color: var(--on-surface-variant);
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.5;
}

.pdf-canvas-container {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 0.5rem;
    /* No overflow constraints — let the page grow naturally */
}

.pdf-loader-msg {
    color: var(--primary);
    font-size: 1.1rem;
    font-weight: 500;
    padding: 2rem;
    text-align: center;
}

#pdf-render-canvas {
    display: block;
    border-radius: 0.375rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    background: #fff;
    
    /* Security: Prevent OS-level text selection or URL clicking (e.g. iOS Live Text) */
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    
    /* Width/height set explicitly in JS to match PDF page dimensions */
}
