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

body {
    font-family: 'Open Sans', sans-serif;
    background: linear-gradient(135deg, #87CEEB 0%, #98FB98 50%, #FFE4B5 100%);
    min-height: 100vh;
    color: #2C3E50;
    line-height: 1.6;
}

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

/* Header Styles */
.story-header {
    text-align: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.9);
    padding: 30px;
    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: #E74C3C;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.story-subtitle {
    font-size: 1.5rem;
    color: #3498DB;
    font-weight: 600;
    margin-bottom: 15px;
}

.story-info {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.age-range, .theme {
    background: #F39C12;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

.theme {
    background: #9B59B6;
}

/* Main Content */
.story-main {
    flex: 1;
    margin-bottom: 30px;
}

/* Story Segments */
.story-segment {
    display: none;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.5s ease-in-out;
}

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

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

.story-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: start;
}

/* Illustration Styles */
.illustration-container {
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    background: #f8f9fa;
}

.story-illustration {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 15px;
    transition: transform 0.3s ease;
}

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

/* Text Content */
.text-container {
    padding: 20px 0;
}

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

.story-text {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 20px;
    color: #2C3E50;
    text-align: justify;
}

.story-end {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border-radius: 15px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.the-end {
    font-family: 'Fredoka One', cursive;
    font-size: 2.5rem;
    color: #8B4513;
    margin-bottom: 10px;
}

.story-message {
    font-style: italic;
    color: #654321;
    font-size: 1.1rem;
    font-weight: 600;
}

/* Navigation Styles */
.story-navigation {
    background: rgba(255, 255, 255, 0.95);
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.nav-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 20px;
}

/* Button Styles */
.nav-btn, .audio-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.nav-btn {
    background: linear-gradient(135deg, #3498DB, #2980B9);
    color: white;
}

.nav-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #2980B9, #1F618D);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.nav-btn:disabled {
    background: #BDC3C7;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.audio-btn {
    background: linear-gradient(135deg, #E74C3C, #C0392B);
    color: white;
    font-size: 1.1rem;
}

.audio-btn:hover {
    background: linear-gradient(135deg, #C0392B, #A93226);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.nav-icon, .audio-icon {
    font-size: 1.2rem;
}

/* Progress Indicator */
.progress-indicator {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.progress-dots {
    display: flex;
    gap: 12px;
}

.dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #BDC3C7;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.dot.active {
    background: linear-gradient(135deg, #E74C3C, #C0392B);
    transform: scale(1.3);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

.dot:hover {
    background: #95A5A6;
    transform: scale(1.1);
}

.dot.active:hover {
    background: linear-gradient(135deg, #E74C3C, #C0392B);
    transform: scale(1.3);
}

.page-counter {
    font-weight: 600;
    color: #2C3E50;
    font-size: 1rem;
}

/* Audio Player (Hidden) */
#audioPlayer {
    display: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .storybook-container {
        padding: 15px;
    }
    
    .story-title {
        font-size: 2.2rem;
    }
    
    .story-subtitle {
        font-size: 1.2rem;
    }
    
    .story-info {
        gap: 15px;
    }
    
    .story-content {
        grid-template-columns: 1fr;
        gap: 25px;
    }
    
    .illustration-container {
        order: -1;
    }
    
    .segment-title {
        font-size: 1.6rem;
    }
    
    .story-text {
        font-size: 1rem;
        text-align: left;
    }
    
    .nav-controls {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav-btn, .audio-btn {
        width: 100%;
        justify-content: center;
        padding: 15px 20px;
    }
    
    .progress-indicator {
        flex-direction: column;
        gap: 15px;
    }
    
    .the-end {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .story-header {
        padding: 20px;
    }
    
    .story-title {
        font-size: 1.8rem;
    }
    
    .story-subtitle {
        font-size: 1rem;
    }
    
    .story-segment {
        padding: 20px;
    }
    
    .segment-title {
        font-size: 1.4rem;
    }
    
    .story-text {
        font-size: 0.95rem;
    }
    
    .nav-btn, .audio-btn {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }
    
    .story-navigation {
        display: none;
    }
    
    .story-segment {
        display: block !important;
        page-break-after: always;
        background: white;
        box-shadow: none;
    }
    
    .story-segment:last-child {
        page-break-after: auto;
    }
}

/* 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 */
.nav-btn:focus,
.audio-btn:focus,
.dot:focus {
    outline: 3px solid #F39C12;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .story-segment {
        border: 2px solid #000;
    }
    
    .nav-btn, .audio-btn {
        border: 2px solid #000;
    }
}