/* Storybook Reader - Interactive Flipbook Component (StPageFlip) */

/* Reader Container - Fixed dimensions with responsive breakpoints */
.reader-container {
    width: 100%;
    height: 600px;
    background: #2d2d2d;
    position: relative;
    margin: 20px auto;
}

/* Tablet - medium pages */
@media (min-width: 768px) {
    .reader-container {
        width: 800px;
        height: 700px;
    }
}

/* Desktop - larger spread */
@media (min-width: 1024px) {
    .reader-container {
        width: 1200px;
        height: 800px;
    }
}

/* Large screens - maximum size */
@media (min-width: 1440px) {
    .reader-container {
        width: 1400px;
        height: 900px;
    }
}

/* Book Container */
.book-container {
    width: 100%;
    height: 100%;
}

/* Loading/Error States */
.reader-loading,
.reader-error {
    color: white;
    font-size: 20px;
    text-align: center;
    padding: 40px;
}

.reader-error p:first-child {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 12px;
}

/* Page Content Wrapper */
.page-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    background: white;
    overflow: hidden;
}

/* Individual Page Styling */
.page {
    background: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Hard Pages */
.page-hard {
    background: #f9f9f9;
}

/* Front Cover */
.page-front_cover .page-content {
    padding: 0;
    position: relative;
}

.cover-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Back Cover */
.page-back_cover .page-content {
    background: white;
    color: #2d2d2d;
    text-align: center;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

/* Back Cover - Featured Books Section */
.back-cover-featured {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 20px 0;
}

.back-cover-featured .featured-label {
    font-size: 16px;
    color: #888;
    margin-bottom: 20px;
    font-weight: 500;
}

.back-cover-featured .featured-books-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    width: 85%;
    max-width: none;
}

/* Dynamic grid based on number of books */
.back-cover-featured .featured-books-grid.featured-count-1 {
    grid-template-columns: 1fr;
    width: 28%;
}

.back-cover-featured .featured-books-grid.featured-count-2 {
    grid-template-columns: repeat(2, 1fr);
    width: 56%;
}

.back-cover-featured .featured-books-grid.featured-count-4,
.back-cover-featured .featured-books-grid.featured-count-5,
.back-cover-featured .featured-books-grid.featured-count-6 {
    grid-template-columns: repeat(3, 1fr);
    width: 85%;
}

.back-cover-featured .featured-book-card {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s, box-shadow 0.2s;
    display: block;
}

.back-cover-featured .featured-book-card:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.back-cover-featured .featured-book-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.back-cover-branding {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
}

.back-cover-logo {
    max-width: 150px;
    margin-bottom: 24px;
}

.back-cover-text {
    font-size: 18px;
    margin: 8px 0;
    line-height: 1.6;
}

.back-cover-text-secondary {
    font-size: 14px;
    color: #666;
    margin-top: 16px;
}

/* Endpapers */
.page-front_endpaper .page-content,
.page-rear_endpaper .page-content {
    padding: 0;
}

.endpaper-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Publisher Notes */
.page-publisher_notes .page-content {
    padding: 50px 60px;
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
}

.publisher-text {
    font-family: 'Georgia', serif;
    font-size: clamp(10px, 0.7vw, 14px);
    line-height: 1.8;
    color: #333;
    text-align: left;
    white-space: pre-line;
    width: 100%;
    max-width: 600px;
    overflow-y: auto;
}

/* Title Page */
.page-title_page .page-content {
    padding: 60px 50px;
    text-align: center;
}

.title-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.title-treatment-img {
    max-width: 90%;
    max-height: 60%;
    object-fit: contain;
    margin-bottom: 40px;
}

.book-title {
    font-size: 42px;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--primary-color, #D94A1F);
    line-height: 1.3;
}

.book-author {
    font-size: 24px;
    color: #666;
    margin-bottom: 32px;
}

.dedication {
    font-style: italic;
    font-size: 16px;
    color: #888;
    max-width: 400px;
    margin-top: 20px;
}

/* Text Pages */
.page-text_page .page-content {
    padding: 60px 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-text {
    font-family: 'Georgia', serif;
    font-size: clamp(14px, 1.5vw, 28px);
    line-height: 1.8;
    color: #2d2d2d;
    text-align: left;
    white-space: pre-line;
    width: 100%;
    max-width: 800px;
    overflow-y: auto;
}

/* Image Pages */
.page-image_page .page-content {
    padding: 0;
}

.story-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Navigation Controls */
.reader-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    background: rgba(0, 0, 0, 0.7);
    padding: 12px 24px;
    border-radius: 30px;
    overflow: visible; /* Allow tooltips to show above */
    margin: 20px auto 0;
    width: fit-content;
    position: relative;
    z-index: 100;
}

.main-controls-row {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Narration Settings Row (expandable) */
.narration-settings-row {
    display: flex;
    align-items: center;
    gap: 16px;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
    margin-top: 0;
}

.narration-settings-row[style*="max-height: 60px"] {
    margin-top: 12px;
}

/* Compact Voice Selector */
.voice-select-compact {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    color: #2d2d2d;
    cursor: pointer;
    transition: background 0.2s;
}

.voice-select-compact:hover {
    background: rgba(255, 255, 255, 1);
}

.voice-select-compact:focus {
    outline: none;
    background: rgba(255, 255, 255, 1);
}

/* Share Row (expandable) */
.share-row {
    display: flex;
    align-items: center;
    gap: 16px;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
    margin-top: 0;
}

.share-row[style*="max-height: 60px"] {
    margin-top: 12px;
    overflow: visible; /* Allow tooltips to show above buttons */
}

.share-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 8px 12px;
    transition: opacity 0.2s, transform 0.2s, color 0.2s;
    line-height: 1;
}

.share-btn:hover {
    opacity: 0.8;
    transform: scale(1.1);
}

/* Individual social media button colors on hover */
.share-btn.facebook:hover {
    color: #1877f2;
}

.share-btn.twitter:hover {
    color: #1da1f2;
}

.share-btn.pinterest:hover {
    color: #e60023;
}

.share-btn.whatsapp:hover {
    color: #25d366;
}

.share-btn.email:hover {
    color: #ea4335;
}

.share-btn.copy:hover {
    color: #4CAF50;
}

.share-btn.copy.copied {
    color: #4CAF50;
    background: rgba(76, 175, 80, 0.2);
}

.share-btn.pdf:hover {
    color: #dc2626;
}

.share-btn.qr-slip:hover {
    color: #8b5cf6; /* Purple - distinctive for QR code */
}

/* Custom Tooltips for Share Buttons */
.share-btn {
    position: relative;
}

.share-btn .tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease;
    pointer-events: none;
    margin-bottom: 8px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Tooltip arrow */
.share-btn .tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

/* Show tooltip on hover */
.share-btn:hover .tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-4px);
}

/* Auto-advance Toggle Button */
.auto-advance-btn {
    position: relative;
}

.auto-advance-btn[data-active="true"] {
    opacity: 1;
    color: #4CAF50;
}

.auto-advance-btn[data-active="false"] {
    opacity: 0.5;
}

/* Fullscreen Mode Adaptations */
.reader-controls.fullscreen-mode {
    position: fixed;
    top: 20px;
    right: 20px;
    margin: 0;
    z-index: 10000;
    opacity: 0.6;
    transform: scale(0.85);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.reader-controls.fullscreen-mode:hover {
    opacity: 1;
    transform: scale(1);
}

.reader-controls.fullscreen-mode .page-counter {
    display: none;
}

.control-btn {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 8px 16px;
    transition: opacity 0.2s, transform 0.2s;
    line-height: 1;
}

.control-btn:hover {
    opacity: 0.7;
    transform: scale(1.1);
}

.control-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.page-counter {
    color: white;
    font-size: 16px;
    min-width: 80px;
    text-align: center;
    font-weight: 500;
}

/* Responsive Styles */
@media (max-width: 1024px) {
    .book-title {
        font-size: 32px;
    }

    .story-text {
        padding: 40px;
    }

    .publisher-text {
        padding: 40px;
    }
}

@media (max-width: 768px) {
    .page-content {
        font-size: 14px;
    }

    .book-title {
        font-size: 28px;
    }

    .book-author {
        font-size: 20px;
    }

    .story-text {
        padding: 30px;
    }

    .publisher-text {
        padding: 30px;
    }

    .reader-controls {
        padding: 10px 20px;
        margin: 15px auto 0;
    }

    .control-btn {
        font-size: 24px;
        padding: 6px 12px;
    }

    .page-counter {
        font-size: 14px;
        min-width: 60px;
    }

    .back-cover-logo {
        max-width: 100px;
    }

    .back-cover-text {
        font-size: 16px;
    }

    .back-cover-text-secondary {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .book-title {
        font-size: 24px;
    }

    .book-author {
        font-size: 18px;
    }

    .dedication {
        font-size: 14px;
    }

    .story-text {
        padding: 20px;
    }

    .publisher-text {
        padding: 20px;
    }
}

/* StPageFlip Library Overrides */
.stf__parent {
    width: 100% !important;
    height: auto !important;
}

/* Let StPageFlip handle its own positioning - don't override wrapper */

.stf__block {
    margin: 0 auto;
}

/* Ensure pages are visible during flipping */
.stf__item {
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Hard page styling */
.stf__item[data-density="hard"] {
    background: #f4f4f4;
}

/* Fullscreen Mode */
.reader-container.fullscreen-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    margin: 0;
    z-index: 9999;
    background: #2d2d2d;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reader-container.fullscreen-mode .book-container {
    width: calc(90vw - 40px);
    height: 90vh;
    margin: 0 20px;
}

/* Child Lock Feature */

/* Child Lock Modal */
.child-lock-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
}

.child-lock-modal .modal-content {
    background: white;
    padding: 40px;
    border-radius: 16px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.child-lock-modal h2 {
    margin: 0 0 24px 0;
    font-size: 24px;
    color: #2d2d2d;
}

.child-lock-modal .pin-input {
    font-size: 32px;
    text-align: center;
    letter-spacing: 8px;
    padding: 16px;
    border: 2px solid #ccc;
    border-radius: 8px;
    width: 100%;
    margin: 12px 0;
    box-sizing: border-box;
    font-family: monospace;
}

.child-lock-modal .pin-input:focus {
    outline: none;
    border-color: var(--primary-color, #D94A1F);
}

.child-lock-modal .error-message {
    color: #e74c3c;
    font-size: 14px;
    min-height: 20px;
    margin: 10px 0;
}

.child-lock-modal .modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.child-lock-modal .btn {
    flex: 1;
    padding: 12px 24px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.child-lock-modal .btn:active {
    transform: scale(0.98);
}

.child-lock-modal .btn-primary {
    background: var(--primary-color, #D94A1F);
    color: white;
}

.child-lock-modal .btn-primary:hover {
    background: #c43f14;
}

.child-lock-modal .btn-secondary {
    background: #e0e0e0;
    color: #2d2d2d;
}

.child-lock-modal .btn-secondary:hover {
    background: #d0d0d0;
}

/* Child Lock Active State - Hide specific controls */
.reader-controls.child-lock-active #share-btn,
.reader-controls.child-lock-active #narration-btn,
.reader-controls.child-lock-active #fullscreen-btn,
.reader-controls.child-lock-active .page-counter {
    display: none !important;
}

/* Keep only essential controls visible in child lock mode */
.reader-controls.child-lock-active {
    /* Ensure controls are always visible in child lock mode */
    opacity: 1 !important;
    transform: scale(1) !important;
}

