/* Magazine Flipbook Styles - Fixed for Layout */

* {
    -webkit-tap-highlight-color: transparent;
}

.magazine-section {
    background: #f8f9fa;
    padding: 20px 0 40px 0;
    min-height: auto;
    position: relative;
    touch-action: pan-y pinch-zoom;
}

.magazine-viewport {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    min-height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.magazine-container {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.magazine {
    width: 1000px;
    height: 700px;
    position: relative;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.magazine .turn-page {
    background-color: white;
    background-size: cover;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.magazine .page {
    width: 500px;
    height: 700px;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.magazine .page img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.magazine .loader {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Controls */
.magazine-controls {
    position: relative;
    margin: 30px auto 0;
    max-width: fit-content;
    background: rgba(0, 0, 0, 0.8);
    padding: 15px 30px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 20px;
    backdrop-filter: blur(10px);
    z-index: 10;
}

.magazine-controls button {
    background: #667eea;
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.magazine-controls button:hover:not(:disabled) {
    background: #764ba2;
    transform: scale(1.1);
}

.magazine-controls button:active:not(:disabled) {
    background: #5a3a7f;
    transform: scale(0.95);
}

.magazine-controls button:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.5;
}

/* Touch-friendly tap area */
@media (hover: none) and (pointer: coarse) {
    .magazine-controls button {
        min-width: 44px;
        min-height: 44px;
    }
}

.magazine-controls .page-info {
    color: white;
    font-size: 16px;
    font-weight: 600;
    min-width: 100px;
    text-align: center;
}

.magazine-controls .download-btn,
.magazine-controls a.download-btn {
    background: transparent;
    color: white;
    border: 2px solid white;
    padding: 10px 20px;
    border-radius: 25px;
    width: auto;
    height: auto;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.magazine-controls .download-btn:hover,
.magazine-controls a.download-btn:hover {
    background: white;
    color: #667eea;
}

/* Loading overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    color: #1f2937;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.loading-overlay .spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(102, 126, 234, 0.2);
    border-top: 6px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-overlay .loading-text {
    margin-top: 20px;
    font-size: 18px;
    font-weight: 500;
}

.loading-overlay .progress {
    margin-top: 10px;
    font-size: 14px;
    opacity: 0.8;
}

/* Responsive */
@media (max-width: 1100px) {
    .magazine {
        width: 800px;
        height: 560px;
    }

    .magazine .page {
        width: 400px;
        height: 560px;
    }
}

@media (max-width: 900px) {
    .magazine {
        width: 600px;
        height: 420px;
    }

    .magazine .page {
        width: 300px;
        height: 420px;
    }

    .magazine-controls {
        padding: 10px 20px;
        gap: 15px;
    }

    .magazine-controls button {
        width: 40px;
        height: 40px;
    }
}

/* Tablet - Landscape */
@media (max-width: 768px) {
    .magazine-section {
        padding: 15px 0 30px 0;
        min-height: auto;
    }

    .magazine {
        width: 90vw;
        max-width: 600px;
        height: calc(90vw * 0.7);
        max-height: 420px;
    }

    .magazine .page {
        width: 45vw;
        max-width: 300px;
        height: calc(90vw * 0.7);
        max-height: 420px;
    }

    .magazine-controls {
        padding: 8px 15px;
        gap: 12px;
    }

    .magazine-controls button {
        width: 45px;
        height: 45px;
    }

    .magazine-controls .page-info {
        font-size: 14px;
        min-width: 80px;
    }

    .magazine-controls .download-btn,
    .magazine-controls a.download-btn {
        padding: 8px 15px;
        font-size: 13px;
    }
}

/* Mobile - Portrait */
@media (max-width: 480px) {
    .magazine-section {
        padding: 10px 0 20px 0;
        min-height: auto;
    }

    .magazine-viewport {
        min-height: auto;
    }

    .magazine {
        width: 95vw;
        max-width: 400px;
        height: calc(95vw * 0.7);
        max-height: 280px;
    }

    .magazine .page {
        width: 47.5vw;
        max-width: 200px;
        height: calc(95vw * 0.7);
        max-height: 280px;
    }

    .magazine-controls {
        padding: 8px 10px;
        gap: 8px;
        border-radius: 30px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .magazine-controls button {
        width: 40px;
        height: 40px;
    }

    .magazine-controls .page-info {
        font-size: 13px;
        min-width: 70px;
    }

    .magazine-controls .download-btn,
    .magazine-controls a.download-btn {
        padding: 8px 12px;
        font-size: 12px;
        width: 100%;
        max-width: 200px;
        justify-content: center;
        margin-top: 5px;
    }

    .loading-overlay .loading-text {
        font-size: 16px;
    }

    .loading-overlay .spinner {
        width: 50px;
        height: 50px;
    }
}

/* Very Small Mobile */
@media (max-width: 360px) {
    .magazine {
        width: 95vw;
        height: calc(95vw * 0.7);
    }

    .magazine .page {
        width: 47.5vw;
        height: calc(95vw * 0.7);
    }

    .magazine-controls button {
        width: 35px;
        height: 35px;
    }

    .magazine-controls .page-info {
        font-size: 12px;
        min-width: 60px;
    }

    .magazine-controls .download-btn,
    .magazine-controls a.download-btn {
        font-size: 11px;
        padding: 6px 10px;
    }
}

/* Shadows */
.magazine .hard {
    background-image: linear-gradient(to right, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0) 100%);
}

.magazine .hard-reverse {
    background-image: linear-gradient(to left, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0) 100%);
}

.magazine .even .gradient {
    background-image: linear-gradient(to right, rgba(0,0,0,0) 0%, rgba(0,0,0,0.2) 100%);
}

.magazine .odd .gradient {
    background-image: linear-gradient(to left, rgba(0,0,0,0) 0%, rgba(0,0,0,0.2) 100%);
}
