/**
 * Adventure Draw Flipbook Styles
 * Matches the Adventure Draw website aesthetic with Courier New font and playful colors
 */

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

body {
    font-family: "Courier New", Courier, monospace;
    background-color: #f5f5f5;
    background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAPklEQVQYV2NkYGD4z8DAwMgABXAwauT4+fOnCZ8iWFhkZGR8/fqVAUkRTDEjI6MMumJYBdAQg+UwKgYrBgBvFCQKKPEoXQAAAABJRU5ErkJggg==');
    overflow: hidden;
    padding: 20px;
}

/* Main Wrapper */
#flipbook-wrapper {
    max-width: 100%;
    margin: 0 auto;
    text-align: center;
}

/* Flipbook Container */
#flipbook-container {
    margin: 0 auto 20px;
    padding: 20px;
    background: transparent;
    display: inline-block;
}

/* Flipbook Element */
#flipbook {
    width: 900px;
    height: 600px;
    margin: 0 auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    background: white;
}

/* Individual Pages */
#flipbook .page {
    width: 450px;  /* Half of 900px for double-page spread */
    height: 600px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#flipbook .page img {
    max-width: 100%;
    max-height: 100%;
    display: block;
    margin: 0 auto;
}

/* Navigation Controls */
#controls {
    margin: 30px auto;
    text-align: center;
    padding: 20px;
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

/* Navigation Buttons */
.nav-button {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 15px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 0 10px;
    cursor: pointer;
    border-radius: 5px;
    font-family: "Courier New", Courier, monospace;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.nav-button:hover {
    background-color: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

.nav-button:active {
    background-color: #3d8b40;
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
    box-shadow: none;
}

/* Page Counter */
#page-counter {
    display: inline-block;
    padding: 0 20px;
    font-size: 18px;
    font-weight: bold;
    color: #333;
    vertical-align: middle;
}

#current-page {
    color: #4CAF50;
    font-size: 22px;
}

/* Loading Indicator */
#loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(245, 245, 245, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#loader p {
    margin-top: 20px;
    font-size: 20px;
    font-weight: bold;
    color: #4CAF50;
}

/* Spinner Animation */
.loader-spinner {
    border: 8px solid #f3f3f3;
    border-top: 8px solid #4CAF50;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
}

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


/* Responsive Design for FancyBox Modal */
@media screen and (max-width: 1024px) {
    #flipbook {
        width: 700px;
        height: 467px;  /* Maintain aspect ratio */
    }

    #flipbook .page {
        width: 350px;
        height: 467px;
    }

    .nav-button {
        padding: 12px 24px;
        font-size: 14px;
    }

    #page-counter {
        font-size: 16px;
    }
}

@media screen and (max-width: 768px) {
    body {
        padding: 10px;
    }

    #flipbook {
        width: 500px;
        height: 333px;
    }

    #flipbook .page {
        width: 250px;
        height: 333px;
    }

    .nav-button {
        padding: 10px 20px;
        font-size: 12px;
        margin: 0 5px;
    }

    #page-counter {
        font-size: 14px;
        padding: 0 10px;
    }

    #current-page {
        font-size: 18px;
    }

    #controls {
        padding: 15px 5px;
        margin: 20px auto;
    }
}

@media screen and (max-width: 550px) {
    #flipbook {
        width: 100%;
        max-width: 400px;
        height: auto;
        min-height: 267px;
    }

    #flipbook .page {
        width: 50%;
        height: auto;
        min-height: 267px;
    }

    .nav-button {
        padding: 8px 16px;
        font-size: 11px;
        display: block;
        margin: 5px auto;
        width: 120px;
    }

    #page-counter {
        display: block;
        margin: 10px 0;
        font-size: 13px;
    }
}

/* Turn.js Specific Overrides */
.turn-page {
    background-color: white;
}

/* Ensure proper layering */
.flipbook-viewport {
    overflow: visible !important;
}

/* Print Styles (if needed) */
@media print {
    body {
        background: white;
    }

    #controls,
    #loader {
        display: none;
    }

    #flipbook {
        box-shadow: none;
        page-break-inside: avoid;
    }
}
