/* Story Play Mode - 3D Book Animation Styles */

.story-play-mode {
    width: 100%;
    height: 100%;
    position: relative;
    /* background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.story-play-header {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.btn-close-play {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    color: #333;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.btn-close-play:hover {
    background: white;
    transform: scale(1.05);
}

/* 1. SCENE - THE CAMERA */
.scene {
    width: 100%;
    height: calc(100% - 120px);
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1500px; /* The Anthropomorphic Sweet Spot */
    margin-top: 60px;
    margin-bottom: 60px;
}

/* 2. BOOK - THE WORLD OBJECT */
.book {
    position: relative;
    width: 600px;
    height: 800px;
    transform-style: preserve-3d; /* Critical for 3D children */
    transition: transform 1s ease-in-out;
    /* Initial position: centered (book is closed) */
    transform: translateX(0%) rotateX(10deg);
    box-shadow: 0 20px 40px rgba(0,0,0,0.5); /* Ambient shadow */
}

/* When book is open: shift right to make room for left (flipped) pages */
.book.book-opened {
    transform: translateX(50%) rotateX(10deg);
}

/* 3. PAGE - THE KINEMATIC UNIT */
.page {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    transform-origin: left center; /* The Spine */
    transform-style: preserve-3d;
    transition: transform 1.2s cubic-bezier(0.645, 0.045, 0.355, 1); /* "Page Turn" Easing */
    
    /* Z-Index Logic: 
       We calculate initial z-index based on page number (--i). 
       Page 1 (i=1) gets high index. Page 3 (i=3) gets low index. */
    z-index: calc(10 - var(--i));
}

/* 4. FACES - THE TEXTURE */
.face {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    padding: 30px;
    background-color: #fdfaf7; /* Off-white paper color */
    backface-visibility: hidden; /* Hide the back when facing away */
    border: 1px solid #e0e0e0; /* Subtle edge definition */
    
    /* Optical Curvature: Spine Gradient */
    /* This creates the illusion of the page bending into the spine */
    /* background-image: linear-gradient(to right, #e3dace 0%, #fdfaf7 15%); */
    /* background image로 paper.png 사용 */
    overflow: hidden;
}
.sheet {
    background-image: url('../paper.png');
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
}
.cover-front {
    background-image: url('../cover.png');
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
}
.cover-back {
    background-image: url('../cover.png');
}

/* THE FRONT FACE */
/* Front faces naturally. No rotation needed. */
/* .front {
} */

/* THE BACK FACE */
.back {
    /* Rotated 180 degrees to face "inward" */
    transform: rotateY(180deg);
    /* Reverse the spine gradient for the back side */
    /* background-image: linear-gradient(to left, #e3dace 0%, #fdfaf7 15%); */
}

/* STYLING CLASSES */
.cover {
    background-color: #e74c3c; /* Red cover */
    color: white;
    border: 2px solid #c0392b;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background-image: linear-gradient(to right, #c0392b 0%, #e74c3c 15%);
}

.cover-back {
    background-color: #e74c3c;
    background-image: linear-gradient(to left, #c0392b 0%, #e74c3c 15%);
}

.page-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    color: #333;
    overflow-y: auto;
    padding: 50px 30px 30px 30px;
    /* Transparent scrollbar – 페이지와 통합된 느낌 */
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.25) transparent;
}
.page-content::-webkit-scrollbar {
    width: 8px;
}
.page-content::-webkit-scrollbar-track {
    background: transparent;
}
.page-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 4px;
}
.page-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.35);
}

.page-content h2 {
    font-size: 1.8rem;
    margin-bottom: 20px;
    color: #2c3e50;
    font-family: 'Cafe24 Ssurround', 'Georgia', serif;
}

.page-content h3 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: #34495e;
    font-family: 'Cafe24 Ssurround', 'Georgia', serif;
}

.page-content p {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 15px;
    color: #555;
    font-family: 'Georgia', serif;
}

.overview-content {
    margin-top: 20px;
}

.characters-list {
    margin-top: 20px;
}

.character-item {
    margin-bottom: 25px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.character-avatar {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    background: rgba(255, 255, 255, 0.8);
}

.character-item h3 {
    margin-bottom: 8px;
    color: #2c3e50;
    font-size: 1.4rem;
}

.character-role {
    font-size: 1rem;
    color: #667eea;
    font-weight: bold;
    margin-bottom: 10px;
}

.character-description {
    font-size: 1rem;
    line-height: 1.6;
    color: #555;
    margin-top: 8px;
}

.content-img {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    margin-top: 20px;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.page-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    -webkit-mask-image: radial-gradient(ellipse 50% 50% at center, rgb(0 0 0 / 28%) 40%, transparent 100%);
    mask-image: radial-gradient(ellipse 50% 50% at center, rgb(0 0 0 / 28%) 40%, transparent 100%);
}

.cover-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    -webkit-mask-image: radial-gradient(
        circle, 
        rgb(0 0 0 / 28%) 50%,
        rgb(0 0 0 / 0%) 65%, 
        rgb(0 0 0 / 0%) 80%, 
        rgb(0 0 0 / 0%) 100%
    );
    mask-image: radial-gradient(
        circle, 
        rgb(0 0 0 / 28%) 50%,
        rgb(0 0 0 / 0%) 65%, 
        rgb(0 0 0 / 0%) 80%, 
        rgb(0 0 0 / 0%) 100%
    );
}

.cover-title {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    font-family: 'Cafe24 Ssurround', 'Georgia', serif;
    z-index: 10;
}

.end-page {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 2rem;
    color: #2c3e50;
    font-family: 'Cafe24 Ssurround', 'Georgia', serif;
    width: 100%;
    padding: 0 30px;
}

/* Book Controls */
.book-controls {
    position: absolute;
    bottom: 1px;
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    padding: 15px 30px;
    border-radius: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.btn-book-control {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.3s ease;
    min-width: 100px;
}

.btn-book-control:hover:not(:disabled) {
    background: #764ba2;
    transform: scale(1.05);
}

.btn-book-control:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.page-indicator {
    font-size: 1rem;
    font-weight: bold;
    color: #333;
    min-width: 80px;
    text-align: center;
}

/* ANIMATION STATES */

/* When flipped, rotate -180 degrees (Open to Left) */
.page.flipped {
    transform: rotateY(-180deg);
}

/* Increase z-index of the active moving page to prevent clipping */
.page.flipping {
    z-index: 100!important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .book {
        width: 90vw;
        height: calc(90vw * 1.33);
        max-width: 400px;
        max-height: 533px;
    }
    
    .cover-title {
        font-size: 1.8rem;
        bottom: 60px;
    }
    
    .page-content {
        padding: 20px;
    }
    
    .page-content h2 {
        font-size: 1.4rem;
    }
    
    .page-content h3 {
        font-size: 1.2rem;
    }
    
    .page-content p {
        font-size: 1rem;
    }
}
