/* ==========================================================================
   Magazine / E-Book Viewer Styles
   ========================================================================== */

.magazine-wrapper {
    text-align: center;
    padding: 30px 0 60px;
    background: #f5f5f0;
    min-height: 80vh;
}

.magazine-wrapper h2 {
    font-size: 24px;
    color: #333;
    margin-bottom: 20px;
    font-weight: bold;
}

/* Flipbook container */
.flipbook-viewport {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    overflow: hidden;
    perspective: 2000px;
    margin: 0 auto;
}

.flipbook-container {
    position: relative;
    margin: 0 auto;
    padding-top: 40px;
}

#flipbook {
    margin: 0 auto;
}

/* Individual page styling */
#flipbook .page {
    background-color: #fff;
    overflow: hidden;
}

#flipbook .page-wrapper {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-repeat: no-repeat;
}

/* Single page (cover, back cover) */
#flipbook .page-wrapper.single {
    background-size: contain;
    background-position: center;
}

/* Spread page - left half */
#flipbook .page-wrapper.spread-left {
    background-size: 200% 100%;
    background-position: left center;
}

/* Spread page - right half */
#flipbook .page-wrapper.spread-right {
    background-size: 200% 100%;
    background-position: right center;
}

/* Hard cover pages */
#flipbook .hard {
    background: #fff;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.1);
}

/* Contact modal popup */
.magazine-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 20000;
    justify-content: center;
    align-items: center;
}

.magazine-modal-overlay[style*="block"] {
    display: flex !important;
}

.magazine-modal {
    background: #fff;
    border-radius: 10px;
    padding: 40px 50px;
    max-width: 520px;
    width: 95%;
    text-align: center;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
}

.magazine-modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

.magazine-modal-close:hover {
    color: #333;
}

.magazine-modal-text {
    font-size: 16px;
    color: #555;
    margin-top: 20px;
    margin-bottom: 25px;
}

.magazine-modal-btn,
.magazine-modal-btn:link,
.magazine-modal-btn:visited,
.magazine-modal-btn:hover,
.magazine-modal-btn:active,
.magazine-modal-btn:focus {
    display: inline-block;
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    background: #4a8c3f;
    padding: 16px 40px;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.3s;
}

.magazine-modal-btn:hover {
    background: #3a7030;
}

.magazine-modal-btn .sp-only {
    display: none;
}

@media print, screen and (max-width: 767px) {
    .magazine-modal-btn .sp-only {
        display: inline;
    }
}

@media print, screen and (max-width: 767px) {
    .magazine-modal {
        padding: 30px 20px;
        width: 95% !important;
        max-width: none !important;
    }

    .magazine-modal-btn {
        font-size: 16px;
        padding: 14px 24px;
        display: block;
        width: 100%;
        box-sizing: border-box;
    }
}

/* Navigation controls */
.magazine-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 30px;
    padding: 20px 0;
    flex-wrap: wrap;
}

.magazine-controls button {
    background: #4a8c3f;
    color: #fff;
    border: none;
    padding: 10px 24px;
    font-size: 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
    font-weight: bold;
}

.magazine-controls button:hover {
    background: #3a7030;
}

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

.page-indicator {
    font-size: 16px;
    color: #666;
    min-width: 120px;
    text-align: center;
}

/* Fullscreen button - positioned top-left outside flipbook */
.btn-fullscreen {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    background: #666 !important;
    color: #fff;
    border: none;
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
    font-weight: bold;
}

.btn-fullscreen:hover {
    background: #555 !important;
}

/* Fullscreen mode */
.magazine-wrapper.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    background: #1a1a1a;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    justify-content: center;
}

.magazine-wrapper.fullscreen .flipbook-viewport {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.magazine-wrapper.fullscreen .magazine-controls {
    margin: 0;
    padding: 15px 0;
    flex-shrink: 0;
}

.magazine-wrapper.fullscreen .magazine-controls button {
    padding: 8px 20px;
}

.magazine-wrapper.fullscreen .page-indicator {
    color: #ccc;
}

.magazine-wrapper.fullscreen h2 {
    display: none;
}

/* Loading overlay */
.magazine-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    font-size: 18px;
    color: #888;
}

.magazine-loading::after {
    content: '';
    width: 30px;
    height: 30px;
    border: 3px solid #ddd;
    border-top-color: #4a8c3f;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 10px;
}

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

/* Page shadow effect */
#flipbook .page {
    box-shadow: 0 0 10px rgba(0,0,0,0.15);
}

/* Responsive - Tablet */
@media screen and (max-width: 1024px) {
    .magazine-wrapper {
        padding: 20px 0 40px;
    }

    .magazine-wrapper h2 {
        font-size: 20px;
    }
}

/* Responsive - Mobile */
@media print, screen and (max-width: 767px) {
    .magazine-wrapper {
        padding: 15px 0 30px;
    }

    .magazine-wrapper h2 {
        font-size: 18px;
        margin-bottom: 15px;
    }

    .magazine-controls {
        gap: 10px;
        margin-top: 15px;
    }

    .magazine-controls button {
        padding: 8px 16px;
        font-size: 14px;
    }

    .page-indicator {
        font-size: 14px;
        min-width: 80px;
    }
}
