/* CSS Variables - Kids UI Design System */
:root {
    --color-primary: #4ECDC4;
    --color-secondary: #FFE66D;
    --color-accent: #FF6B6B;
    --color-bg: #FAFAFA;
    --color-text: #2D3436;
    --radius: 16px;
    --shadow: 0 4px 12px rgba(0,0,0,0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Nunito', 'Quicksand', 'Comic Sans MS', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.7;
    height: 100vh;
    overflow: hidden;
}

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

header {
    text-align: center;
    padding: 15px 0;
    flex-shrink: 0;
}

h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--color-text);
}

#story-subtitle {
    font-size: 1.2rem;
    color: #666666;
}

.viewer {
    background-color: #ffffff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.image-container {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    overflow: hidden;
    background-color: #f8f8f8;
    min-height: 0;
}

.image-container img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
}

.text-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 15px;
    flex-shrink: 0;
}

#current-text {
    font-size: 1.2rem;
    text-align: center;
    color: var(--color-text);
    white-space: pre-line;
    line-height: 1.7;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    margin: 15px 0;
    flex-shrink: 0;
}

.nav-button {
    background-color: var(--color-primary);
    border: none;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: filter 0.2s ease, transform 0.1s ease;
    color: #ffffff;
    box-shadow: var(--shadow);
}

.nav-button:hover:not(:disabled) {
    filter: brightness(1.1);
}

.nav-button:active:not(:disabled) {
    transform: scale(0.95);
}

.nav-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-indicator {
    font-size: 1.2rem;
    color: #666666;
    min-width: 100px;
    text-align: center;
    font-weight: 600;
}

#current-page {
    font-weight: 700;
    color: var(--color-text);
}

.progress-bar {
    width: 100%;
    height: 6px;
    background-color: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
    margin-top: 5px;
}

.progress-fill {
    height: 100%;
    background-color: var(--color-accent);
    transition: width 0.3s ease;
    border-radius: 3px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    h1 {
        font-size: 1.8rem;
    }

    #story-subtitle {
        font-size: 1.1rem;
    }

    .viewer {
        padding: 15px;
    }

    .text-container {
        padding: 15px 10px;
    }

    #current-text {
        font-size: 1.1rem;
    }

    .controls {
        gap: 30px;
        margin: 12px 0;
    }

    .nav-button {
        width: 52px;
        height: 52px;
    }

    .page-indicator {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 12px;
        padding-bottom: 20px; /* Extra padding to prevent buttons from being cut off */
    }

    h1 {
        font-size: 1.5rem;
        margin-bottom: 5px;
    }

    #story-subtitle {
        font-size: 1rem;
    }

    header {
        padding: 10px 0;
    }

    .viewer {
        padding: 12px;
        margin-bottom: 10px; /* Ensure space at bottom */
    }

    .text-container {
        padding: 12px 8px;
    }

    #current-text {
        font-size: 1rem;
    }

    .controls {
        gap: 25px;
        margin: 10px 0 12px 0; /* Extra bottom margin */
        padding-bottom: 5px; /* Additional padding */
    }

    .nav-button {
        width: 48px;
        height: 48px;
    }

    .page-indicator {
        font-size: 1rem;
        min-width: 80px;
    }

    .progress-bar {
        margin-bottom: 5px; /* Ensure progress bar has space */
    }
}

/* Touch device improvements - Ensure minimum 48px touch targets */
@media (hover: none) and (pointer: coarse) {
    .nav-button {
        min-width: 52px;
        min-height: 52px;
    }
}

/* Keyboard navigation focus states - High visibility for kids */
.nav-button:focus-visible {
    outline: 3px solid var(--color-secondary);
    outline-offset: 3px;
}

/* Loading state */
.image-container img {
    opacity: 1;
    transition: opacity 0.2s ease;
}

.image-container img.loading {
    opacity: 0.5;
}
