/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6b4ce6;
    --background: #2a2a2a;
    --surface: #ffffff;
    --text-primary: #ffffff;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-strong: rgba(0, 0, 0, 0.6);
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Magazine Container */
.magazine-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Loading Indicator */
.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1000;
    color: var(--text-primary);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-indicator p {
    color: var(--text-primary);
    font-size: 1rem;
}

.loading-indicator.hidden {
    display: none;
}

/* Canvas Container */
.canvas-container {
    position: relative;
    max-width: 100%;
    max-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 40px var(--shadow-strong);
}

#pdfCanvas {
    display: block;
    max-width: 100vw;
    max-height: 100vh;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Link Overlay */
.link-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.pdf-link {
    position: absolute;
    cursor: pointer;
    pointer-events: auto;
    transition: background-color 0.2s;
    border: 2px solid transparent;
}

.pdf-link:hover {
    background-color: rgba(107, 76, 230, 0.15);
    border-color: rgba(107, 76, 230, 0.4);
}

/* Navigation Zones */
.nav-zone {
    position: absolute;
    top: 0;
    height: 100%;
    width: 50%;
    display: flex;
    align-items: center;
    z-index: 50;
    cursor: pointer;
}

.nav-zone-left {
    left: 0;
    justify-content: flex-start;
    padding-left: 2rem;
}

.nav-zone-right {
    right: 0;
    justify-content: flex-end;
    padding-right: 2rem;
}

/* Make canvas and links block clicks from nav zones */
.canvas-container {
    position: relative;
    max-width: 100%;
    max-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 40px var(--shadow-strong);
    z-index: 100;
    pointer-events: auto;
    opacity: 1;
    transition: opacity 0.2s ease-in-out;
}

.canvas-container.fade-out {
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.canvas-container.fade-in {
    opacity: 0;
}

.canvas-container.fade-in-active {
    animation: cozyFadeIn 0.3s ease-in-out forwards;
}

@keyframes cozyFadeIn {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

/* Navigation Buttons */
.nav-button {
    background: rgba(255, 255, 255, 0.95);
    border: none;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--primary-color);
    transition: var(--transition);
    box-shadow: 0 4px 20px var(--shadow-strong);
    opacity: 0;
    transform: scale(0.8);
}

.nav-zone:hover .nav-button:not(:disabled) {
    opacity: 1;
    transform: scale(1);
}

.nav-button:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

.nav-button:disabled {
    opacity: 0 !important;
    cursor: default;
    pointer-events: none;
}

.nav-arrow {
    display: block;
    line-height: 1;
    user-select: none;
}

/* Page Indicator */
.page-indicator {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 0.75rem 1.5rem;
    border-radius: 2rem;
    box-shadow: 0 4px 20px var(--shadow-strong);
    z-index: 100;
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

.page-indicator:hover {
    opacity: 1;
}

.page-info {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Volume Control */
.volume-control {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.volume-button {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: var(--transition);
    box-shadow: 0 4px 12px var(--shadow-strong);
    order: 2;
}

.volume-button:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.volume-icon {
    display: block;
    user-select: none;
}

.volume-slider-container {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 1rem 0.75rem;
    border-radius: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 12px var(--shadow-strong);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: var(--transition);
    order: 1;
}

.volume-control:hover .volume-slider-container,
.volume-slider-container:hover {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#volumeSlider {
    width: 4px;
    height: 120px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    -webkit-appearance: slider-vertical;
    appearance: slider-vertical;
    writing-mode: bt-lr;
    direction: rtl;
}

#volumeSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

#volumeSlider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: #8b6ce8;
}

#volumeSlider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

#volumeSlider::-moz-range-thumb:hover {
    transform: scale(1.2);
    background: #8b6ce8;
}

.volume-value {
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
}

/* Music Attribution */
.music-attribution {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    z-index: 100;
    max-width: 300px;
}

.attribution-details {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px var(--shadow-strong);
    font-size: 0.75rem;
    color: var(--text-primary);
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.attribution-details:hover {
    opacity: 1;
}

.attribution-summary {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    list-style: none;
    user-select: none;
    font-weight: 500;
}

.attribution-summary::-webkit-details-marker {
    display: none;
}

.attribution-summary::before {
    content: 'ℹ️ ';
    margin-right: 0.25rem;
}

.attribution-content {
    padding: 0.75rem;
    padding-top: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    line-height: 1.6;
}

.attribution-content p {
    margin: 0.5rem 0;
}

.attribution-content a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

.attribution-content a:hover {
    color: #8b6ce8;
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .nav-button {
        width: 60px;
        height: 60px;
        font-size: 2.5rem;
    }
    
    .nav-zone-left {
        padding-left: 1rem;
    }
    
    .nav-zone-right {
        padding-right: 1rem;
    }
}

@media (max-width: 768px) {
    .nav-zone {
        width: 25%;
    }
    
    .nav-button {
        width: 50px;
        height: 50px;
        font-size: 2rem;
    }
    
    .nav-zone-left {
        padding-left: 0.5rem;
    }
    
    .nav-zone-right {
        padding-right: 0.5rem;
    }
    
    .page-indicator {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        bottom: 1rem;
    }
    
    .volume-control {
        bottom: 1rem;
        right: 1rem;
    }
    
    .volume-button {
        width: 45px;
        height: 45px;
        font-size: 1.25rem;
    }
    
    .volume-slider-container {
        padding: 0.75rem 0.5rem;
    }
    
    #volumeSlider {
        height: 100px;
    }
    
    .volume-value {
        font-size: 0.75rem;
    }
    
    .music-attribution {
        bottom: 0.5rem;
        left: 0.5rem;
        max-width: 250px;
    }
    
    .attribution-details {
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .nav-zone {
        width: 30%;
    }
    
    .nav-button {
        width: 45px;
        height: 45px;
        font-size: 1.75rem;
    }
    
    .page-indicator {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
        bottom: 0.75rem;
    }
    
    .volume-control {
        bottom: 0.75rem;
        right: 0.75rem;
    }
    
    .volume-button {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    #volumeSlider {
        height: 80px;
    }
    
    .music-attribution {
        max-width: 200px;
    }
}

/* Touch devices - show navigation on tap */
@media (hover: none) and (pointer: coarse) {
    .nav-button {
        opacity: 0.7;
    }
    
    .nav-zone:active .nav-button:not(:disabled) {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* Print Styles */
@media print {
    .nav-zone,
    .page-indicator {
        display: none;
    }
    
    .canvas-container {
        box-shadow: none;
        page-break-inside: avoid;
    }
}

