:root {
    --christmas-red: #D42426;
    --christmas-green: #165B33;
    --gold: #F8B229;
    --snow: #F0F0F0;
    --dark-bg: #0F0F0F;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Open Sans', sans-serif;
    background-color: var(--christmas-green);
    color: var(--snow);
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.christmas-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background: radial-gradient(circle at center, #1a6d41 0%, #0d3823 100%);
}

.container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 1200px;
    /* Max width for desktop */
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
    flex-grow: 1;
}

.header {
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.header h1 {
    font-family: 'Mountains of Christmas', cursive;
    font-size: 3rem;
    margin: 0;
    color: var(--gold);
}

.header p {
    font-size: 1.2rem;
    margin: 5px 0 0;
    opacity: 0.9;
}

.flipbook-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1500px;
    flex-grow: 1;
    margin-bottom: 20px;
}

/* Flipbook Container */
/* Important: PageFlip needs a container with specific sizing or it defaults */
#flipbook {
    width: 100%;
    /* Will be controlled by JS for ratio */
    height: auto;
    /* Basic shadow for the book */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    max-width: 100vw;
    overflow: hidden;
    touch-action: pan-y !important;
    /* Allow vertical scroll even when touching book */
}

@media (max-width: 768px) {
    .flipbook-wrapper {
        padding: 0;
        width: 100%;
    }

    .container {
        padding: 10px 0;
        width: 100%;
        overflow-x: hidden;
    }

    #flipbook {
        box-shadow: none;
    }
}

.page {
    background-color: white;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    /* Optional: Border for festive look on pages */
    border: 1px solid #ddd;
}

.page canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cover {
    background: var(--christmas-red);
    color: white;
}

.loader {
    text-align: center;
    font-size: 1.5rem;
    color: white;
}

.spinner {
    font-size: 3rem;
    animation: spin 2s linear infinite;
    margin-top: 10px;
}

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

/* Controls */
.controls {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.nav-btn {
    background: var(--christmas-red);
    color: white;
    border: 2px solid var(--gold);
    padding: 10px 20px;
    font-family: 'Mountains of Christmas', cursive;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 50px;
    transition: transform 0.2s, background 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.nav-btn:hover {
    transform: scale(1.05);
    background: #e63946;
}

.nav-btn:active {
    transform: scale(0.95);
}

#pageInfo {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--gold);
}

/* Snowflake Animation */
.snowflakes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.snowflake {
    position: absolute;
    color: #fff;
    font-size: 1em;
    opacity: 0.8;
    top: -10%;
    animation: snow-fall 10s linear infinite, snow-shake 3s ease-in-out infinite;
}

.snowflake:nth-child(1) {
    left: 10%;
    animation-delay: 0s, 1s;
}

.snowflake:nth-child(2) {
    left: 20%;
    animation-delay: 5s, 0.5s;
}

.snowflake:nth-child(3) {
    left: 30%;
    animation-delay: 2s, 2s;
}

.snowflake:nth-child(4) {
    left: 40%;
    animation-delay: 8s, 2.5s;
}

.snowflake:nth-child(5) {
    left: 50%;
    animation-delay: 4s, 1s;
}

.snowflake:nth-child(6) {
    left: 60%;
    animation-delay: 2.5s, 0s;
}

.snowflake:nth-child(7) {
    left: 70%;
    animation-delay: 6s, 2s;
}

.snowflake:nth-child(8) {
    left: 80%;
    animation-delay: 1s, 1s;
}

.snowflake:nth-child(9) {
    left: 90%;
    animation-delay: 3s, 3s;
}

.snowflake:nth-child(10) {
    left: 25%;
    animation-delay: 2s, 0s;
}

@keyframes snow-fall {
    0% {
        top: -10%;
    }

    100% {
        top: 100%;
    }
}

@keyframes snow-shake {

    0%,
    100% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(20px);
    }
}

/* Responsiveness */
@media (max-width: 768px) {
    .header h1 {
        font-size: 2rem;
    }

    .container {
        padding: 10px;
    }

    .controls {
        gap: 5px;
        /* Tighter gap */
        flex-wrap: wrap;
        /* Allow wrap if absolutely needed */
        justify-content: center;
    }

    .nav-btn {
        padding: 8px 12px;
        font-size: 0.9rem;
        /* Smaller text */
    }

    /* Make specifically "Previous/Next" smaller to fit Zoom */
}

.web-btn {
    display: inline-block;
    margin-top: 15px;
    padding: 10px 25px;
    background-color: var(--gold);
    color: var(--christmas-green);
    text-decoration: none;
    font-family: 'Mountains of Christmas', cursive;
    font-weight: bold;
    font-size: 1.4rem;
    border-radius: 50px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    border: 2px solid #fff;
    transition: all 0.3s ease;
}

.web-btn:hover {
    background-color: #fff;
    color: var(--christmas-red);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
}

/* Logo Stamp */
.logo-stamp {
    position: absolute;
    width: 150px;
    /* Adjust size as needed */
    height: auto;
    opacity: 0.7;
    /* Tenue */
    mix-blend-mode: multiply;
    /* Blends nicely like a stamp */
    pointer-events: none;
    filter: sepia(0.5) contrast(1.2);
    /* Slight vintage stamp look */
    z-index: 2;
}

/* Positioning for Cover - Bottom Center or User preference? 
   "Sello" often looks good in a corner or center. Let's try bottom right for flair. */
.page:nth-of-type(1) .logo-stamp {
    bottom: 20px;
    right: 20px;
    transform: rotate(-10deg);
}

/* Positioning for Back Cover - Center maybe? */
.page:last-of-type .logo-stamp {
    bottom: 20px;
    left: 20px;
    transform: rotate(10deg);
}

/* Dedicated Cover Pages */
.page.cover-page {
    background-color: var(--christmas-green);
    border: 5px solid var(--gold);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    /* Texture for the cover to look like leather or paper */
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23134d2b' fill-opacity='0.4' fill-rule='evenodd'/%3E%3C/svg%3E");
}

.cover-logo {
    width: 60%;
    max-width: 300px;
    height: auto;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
    z-index: 5;
}

/* Centering reinforcement - Absolute Position Fallback */
.cover-logo {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    display: block !important;
}

.page.cover-page {
    position: relative !important;
    display: block !important;
    /* Ensure block for relative positioning context */
}

/* Zoom Overlay */
.zoom-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.zoom-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.zoom-container canvas,
.zoom-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.close-zoom {
    position: absolute;
    top: 20px;
    right: 20px;
    background: white;
    border: none;
    border-radius: 5px;
    padding: 10px 15px;
    font-size: 1.2rem;
    z-index: 1001;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* Add Zoom Button to controls */
#zoomBtn {
    background: var(--christmas-green);
    border-color: var(--gold);
}