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

body {
    font-family: 'Nunito', sans-serif;
    background: linear-gradient(135deg, #ffeaa7 0%, #fab1a0 50%, #fd79a8 100%);
    min-height: 100vh;
    color: #2d3436;
    line-height: 1.6;
}

/* Container */
.storybook-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.story-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.story-title {
    font-family: 'Fredoka One', cursive;
    font-size: 3rem;
    color: #6c5ce7;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 10px;
}

.story-subtitle {
    font-size: 1.2rem;
    color: #636e72;
    font-weight: 600;
}

/* Story Content */
.story-content {
    flex: 1;
    position: relative;
}

.story-page {
    display: none;
    animation: fadeIn 0.5s ease-in-out;
}

.story-page.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: start;
    min-height: 600px;
}

/* Illustration */
.illustration-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.story-illustration {
    width: 100%;
    max-width: 500px;
    height: auto;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.story-illustration:hover {
    transform: scale(1.02);
}

/* Text Content */
.text-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.page-title {
    font-family: 'Fredoka One', cursive;
    font-size: 2rem;
    color: #6c5ce7;
    text-align: center;
    margin-bottom: 20px;
}

.story-text {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.text-segment {
    position: relative;
    padding: 15px 20px;
    background: rgba(116, 185, 255, 0.1);
    border-radius: 12px;
    border-left: 4px solid #74b9ff;
    transition: all 0.3s ease;
}

.text-segment:hover {
    background: rgba(116, 185, 255, 0.2);
    transform: translateX(5px);
}

.text-segment p {
    margin: 0;
    font-size: 1.1rem;
    line-height: 1.7;
}

/* Character Voices */
.character-luna {
    background: rgba(45, 52, 54, 0.1) !important;
    border-left-color: #2d3436 !important;
    font-style: italic;
}

.character-snow {
    background: rgba(255, 255, 255, 0.8) !important;
    border-left-color: #ddd !important;
    font-style: italic;
}

/* Audio Controls */
.play-audio {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #00b894;
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 184, 148, 0.3);
}

.play-audio:hover {
    background: #00a085;
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 184, 148, 0.4);
}

.play-audio:active {
    transform: scale(0.95);
}

.play-audio.playing {
    background: #e17055;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Navigation */
.story-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: #6c5ce7;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}

.nav-btn:hover:not(:disabled) {
    background: #5f3dc4;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.4);
}

.nav-btn:disabled {
    background: #b2bec3;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.page-indicator {
    font-size: 1.2rem;
    font-weight: 600;
    color: #6c5ce7;
    background: rgba(108, 92, 231, 0.1);
    padding: 10px 20px;
    border-radius: 20px;
}

/* Global Audio Controls */
.audio-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.audio-control-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: #00b894;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 184, 148, 0.3);
}

.audio-control-btn:hover {
    background: #00a085;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 184, 148, 0.4);
}

/* Responsive Design */
@media (max-width: 768px) {
    .storybook-container {
        padding: 15px;
    }
    
    .story-title {
        font-size: 2.5rem;
    }
    
    .page-content {
        grid-template-columns: 1fr;
        gap: 25px;
        padding: 20px;
        min-height: auto;
    }
    
    .story-illustration {
        max-width: 100%;
    }
    
    .page-title {
        font-size: 1.5rem;
    }
    
    .text-segment p {
        font-size: 1rem;
    }
    
    .story-navigation {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav-btn {
        width: 100%;
        justify-content: center;
    }
    
    .audio-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .audio-control-btn {
        width: 200px;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .story-title {
        font-size: 2rem;
    }
    
    .page-content {
        padding: 15px;
    }
    
    .text-segment {
        padding: 12px 15px;
    }
    
    .play-audio {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }
    
    .story-navigation,
    .audio-controls,
    .play-audio {
        display: none;
    }
    
    .story-page {
        display: block !important;
        page-break-after: always;
    }
    
    .page-content {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus,
.nav-btn:focus,
.play-audio:focus {
    outline: 3px solid #fd79a8;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .text-segment {
        border-left-width: 6px;
    }
    
    .story-header,
    .page-content,
    .story-navigation {
        border: 2px solid #2d3436;
    }
}