@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=IM+Fell+English:ital@0;1&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    background: radial-gradient(circle at center, #0a0e1a 0%, #000 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-family: 'IM Fell English', serif;
    color: #f5e6c4;
    overflow-x: hidden;
    padding: 20px;
    position: relative;
}

/* Starry background */
.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(2px 2px at 20% 30%, white, transparent),
        radial-gradient(2px 2px at 60% 70%, white, transparent),
        radial-gradient(1px 1px at 50% 50%, white, transparent),
        radial-gradient(1px 1px at 80% 10%, white, transparent),
        radial-gradient(2px 2px at 90% 60%, white, transparent);
    background-size: 200% 200%;
    animation: twinkle 8s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Floating candles */
.candle {
    position: fixed;
    width: 8px;
    height: 50px;
    pointer-events: none;
    z-index: 1;
    animation: floatCandle 8s ease-in-out infinite;
}

.candle::before {
    content: '🕯️';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 24px;
    filter: drop-shadow(0 0 15px rgba(148, 107, 84, 0.8));
}

.candle1 {
    top: 10%;
    left: 10%;
}

.candle2 {
    top: 20%;
    right: 10%;
    animation-delay: 3s;
}

@keyframes floatCandle {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

/* Book container */
.book-container {
    position: relative;
    z-index: 10;
    margin-bottom: 30px;
}

.book-wrapper {
    perspective: 2500px;
    width: 700px;
    height: 500px;
    position: relative;
}

@media (max-width: 768px) {
    .book-wrapper {
        width: 90vw;
        height: calc(90vw * 0.7);
        max-width: 500px;
        max-height: 350px;
    }
}

/* The Book */
.book {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    box-shadow: 
        0 30px 60px rgba(0, 0, 0, 0.8),
        0 0 40px rgba(14, 26, 64, 0.3);
}

/* Page wrapper for flip effect */
.page-wrapper {
    position: absolute;
    width: 50%;
    height: 100%;
    top: 0;
    left: 50%;
    transform-origin: left center;
    transform-style: preserve-3d;
    transition: transform 1.2s cubic-bezier(0.645, 0.045, 0.355, 1);
}

/* Set z-index for proper stacking - ADD MORE PAGES */
.page-wrapper#cover {
    z-index: 13;
}

.page-wrapper#page1 {
    z-index: 12;
}

.page-wrapper#page2 {
    z-index: 11;
}

.page-wrapper#page3 {
    z-index: 10;
}

.page-wrapper#page4 {
    z-index: 9;
}

.page-wrapper#page5 {
    z-index: 8;
}

.page-wrapper#page6 {
    z-index: 7;
}

.page-wrapper#page7 {
    z-index: 6;
}

.page-wrapper#page8 {
    z-index: 5;
}

.page-wrapper#page9 {
    z-index: 4;
}

.page-wrapper#page10 {
    z-index: 3;
}

.page-wrapper#page11 {
    z-index: 2;
}

.page-wrapper#backcover {
    z-index: 1;
}

.page-wrapper.flipped {
    transform: rotateY(-180deg);
    z-index: 0 !important;
}
/* Individual pages */
.page {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background: linear-gradient(135deg, #f5f0e8 0%, #e8dcc4 100%);
    border: 2px solid #946b54;
    box-shadow: 
        inset 0 0 30px rgba(14, 26, 64, 0.1),
        -5px 0 15px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.page.back-side {
    transform: rotateY(180deg);
    box-shadow: 
        inset 0 0 30px rgba(14, 26, 64, 0.1),
        5px 0 15px rgba(0, 0, 0, 0.3);
}

/* Paper texture */
.page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 25px,
            rgba(139, 111, 71, 0.03) 25px,
            rgba(139, 111, 71, 0.03) 26px
        );
    pointer-events: none;
}

/* Page content */
.page-content {
    width: 100%;
    height: 100%;
    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 1;
}

/* Front Cover */
.front-cover {
    background: linear-gradient(135deg, #0e1a40 0%, #05050a 100%);
    border: 3px solid #946b54;
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.8),
        inset 0 0 50px rgba(148, 107, 84, 0.2);
    z-index: 10;
}

/* Make sure front cover stays on top initially */
.page-wrapper#cover .page.front-cover {
    z-index: 100;
}

.cover-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.cover-emblem {
    width: 100px;
    height: 100px;
    margin-bottom: 30px;
    border: 3px solid #946b54;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 
        0 0 30px rgba(148, 107, 84, 0.5),
        inset 0 0 20px rgba(14, 26, 64, 0.3);
    background: #f5f0e8;
    padding: 8px;
}

.cover-emblem img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cover-title {
    font-family: 'Cinzel', serif;
    font-size: 36px;
    color: #946b54;
    margin-bottom: 20px;
    text-shadow: 
        0 0 20px rgba(148, 107, 84, 0.6),
        0 2px 4px rgba(0, 0, 0, 0.8);
    letter-spacing: 2px;
}

.cover-divider {
    width: 60%;
    height: 2px;
    background: linear-gradient(to right, transparent, #946b54, transparent);
    margin: 20px 0;
}

.cover-subtitle {
    font-family: 'IM Fell English', serif;
    font-size: 24px;
    color: #946b54;
    font-style: italic;
    margin-bottom: 15px;
}

.cover-date {
    font-size: 16px;
    color: #2e5c8a;
    letter-spacing: 1px;
}

/* Back Cover - make sure it's styled correctly */
.back-cover {
    background: linear-gradient(135deg, #1a0f0a 0%, #0e1a40 100%) !important;
    border: 3px solid #946b54 !important;
}

.back-cover-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.back-cover-text {
    font-family: 'Cinzel', serif;
    font-size: 28px;
    color: #946b54;
    text-align: center;
    margin-top: 20px;
    text-shadow: 0 0 10px rgba(148, 107, 84, 0.5);
}

.back-cover-subtext {
    font-family: 'IM Fell English', serif;
    font-size: 16px;
    color: #2e5c8a;
    text-align: center;
    margin-top: 10px;
    font-style: italic;
}

/* Make sure back cover doesn't show photo styling */
.back-cover .photo-frame {
    display: none;
}

.back-cover::before {
    background-image: none;
}
.back-cover-design {
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 50% 50%, rgba(148, 107, 84, 0.2) 0%, transparent 50%),
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 20px,
            rgba(148, 107, 84, 0.05) 20px,
            rgba(148, 107, 84, 0.05) 40px
        );
}

/* Photo frames */
.photo-frame {
    width: 100%;
    max-width: 280px;
    background: #fff;
    padding: 15px;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.4),
        inset 0 0 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #d4a574;
    position: relative;
}

.photo-frame::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 1px solid #946b54;
    pointer-events: none;
}

.photo-frame img {
    width: 100%;
    height: 280px;
    object-fit: cover;
    display: block;
    filter: sepia(0.15) contrast(1.05);
}

.photo-caption {
    margin-top: 15px;
    font-family: 'IM Fell English', serif;
    font-size: 16px;
    color: #2c1810;
    text-align: center;
    font-style: italic;
}

/* Chapter text */
h2 {
    font-family: 'Cinzel', serif;
    font-size: 28px;
    color: #0e1a40;
    margin-bottom: 20px;
    text-align: center;
}

.chapter-text {
    font-size: 18px;
    color: #2c1810;
    text-align: center;
    font-style: italic;
    line-height: 1.8;
}

.ending-text {
    font-size: 18px;
    color: #2c1810;
    text-align: center;
    line-height: 1.8;
    margin: 20px 0;
    max-width: 250px;
}

.heart {
    font-size: 48px;
    margin-top: 20px;
    animation: heartbeat 2s ease-in-out infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.1); }
    50% { transform: scale(1); }
}

/* Page indicator */
.page-indicator {
    text-align: center;
    margin-top: 20px;
    font-family: 'Cinzel', serif;
    color: #946b54;
    font-size: 16px;
    text-shadow: 0 0 10px rgba(148, 107, 84, 0.5);
}

/* Controls */
.controls {
    display: flex;
    gap: 20px;
    margin: 20px 0;
    z-index: 10;
}

.control-btn {
    background: linear-gradient(135deg, #0e1a40 0%, #2e5c8a 100%);
    color: #946b54;
    border: 2px solid #946b54;
    border-radius: 30px;
    padding: 12px 25px;
    font-family: 'Cinzel', serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 
        0 5px 15px rgba(14, 26, 64, 0.5),
        0 0 20px rgba(148, 107, 84, 0.3);
    transition: all 0.3s ease;
    letter-spacing: 1px;
}

.control-btn:hover {
    background: linear-gradient(135deg, #2e5c8a 0%, #0e1a40 100%);
    transform: translateY(-2px);
    box-shadow: 
        0 7px 20px rgba(14, 26, 64, 0.6),
        0 0 30px rgba(148, 107, 84, 0.5);
}

.control-btn:active {
    transform: translateY(0);
}

.btn-icon {
    font-size: 16px;
}

/* Letter link */
.letter-link {
    margin-top: 20px;
    text-decoration: none;
    color: #946b54;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 1px;
    text-shadow: 
        0 0 10px rgba(148, 107, 84, 0.8),
        0 0 20px rgba(46, 92, 138, 0.5);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10;
}

.letter-link:hover {
    color: #2e5c8a;
    transform: scale(1.05);
}

.sparkle {
    animation: sparkleRotate 2s ease-in-out infinite;
}

@keyframes sparkleRotate {
    0%, 100% { transform: rotate(0deg) scale(1); opacity: 0.7; }
    50% { transform: rotate(180deg) scale(1.2); opacity: 1; }
}

/* Responsive */
@media (max-width: 768px) {
    .cover-title {
        font-size: 24px;
    }
    
    .cover-subtitle {
        font-size: 18px;
    }
    
    .cover-emblem {
        width: 80px;
        height: 80px;
    }
    
    .photo-frame {
        max-width: 200px;
    }
    
    .photo-frame img {
        height: 200px;
    }
    
    .page-content {
        padding: 20px 15px;
    }
    
    h2 {
        font-size: 22px;
    }
    
    .chapter-text, .ending-text {
        font-size: 14px;
    }

    /* Photo page styling - no captions */
.photo-page {
    padding: 20px;
}

.photo-page .photo-frame {
    width: 100%;
    height: 100%;
    max-width: none;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-page .photo-frame img {
    width: 100%;
    height: 100%;
    max-height: 420px;
    object-fit: cover;
}

/* Remove caption styles for photo pages */
.photo-page .photo-caption {
    display: none;
}

/* Back cover content */
.back-cover-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.back-cover-text {
    font-family: 'Cinzel', serif;
    font-size: 24px;
    color: #946b54;
    text-align: center;
    margin-top: 20px;
    text-shadow: 0 0 10px rgba(148, 107, 84, 0.5);
}

@media (max-width: 768px) {
    .photo-page {
        padding: 15px;
    }
    
    .photo-page .photo-frame {
        padding: 8px;
    }
    
    .photo-page .photo-frame img {
        max-height: 280px;
    }
    
    .back-cover-text {
        font-size: 18px;
    }
}
}