/* ==========================================================================
   Showcase Reader - Homepage Storybook Display
   A simplified, white-themed reader for featuring a storybook on the landing page
   ========================================================================== */

/* Section Container - Hidden on mobile */
.showcase-section {
    padding: 80px 0;
    background: #f8f9fa;
    display: none; /* Hidden on mobile by default */
}

@media (min-width: 768px) {
    .showcase-section {
        display: block;
    }
}

/* Section Header */
.showcase-section .section-header {
    text-align: center;
    margin-bottom: 40px;
}

.showcase-section .section-header h2 {
    font-size: 2.5rem;
    color: #2d2d2d;
    margin-bottom: 12px;
}

.showcase-section .section-subtitle {
    font-size: 1.1rem;
    color: #666;
    max-width: 500px;
    margin: 0 auto;
}

/* ==========================================================================
   Reader Container
   ========================================================================== */

.showcase-reader {
    width: 100%;
    max-width: 900px;
    min-height: 400px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.1);
    overflow: visible;
    position: relative;
}

/* Responsive sizing */
@media (min-width: 1024px) {
    .showcase-reader {
        max-width: 1000px;
        min-height: 450px;
    }
}

@media (min-width: 1200px) {
    .showcase-reader {
        max-width: 1100px;
        min-height: 500px;
    }
}

/* Book container inside reader */
.showcase-book {
    width: 100%;
}

/* ==========================================================================
   Loading & Error States
   ========================================================================== */

.showcase-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
    font-size: 18px;
    gap: 16px;
}

.showcase-loading::before {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: showcase-spin 1s linear infinite;
}

@keyframes showcase-spin {
    to { transform: rotate(360deg); }
}

.showcase-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
    font-size: 18px;
    text-align: center;
    padding: 40px;
}

.showcase-error i {
    font-size: 48px;
    color: #e74c3c;
    margin-bottom: 16px;
}

/* ==========================================================================
   StPageFlip Library Overrides
   ========================================================================== */

/* Let PageFlip fill the container properly */
.showcase-reader .stf__parent {
    width: 100% !important;
    height: auto !important;
}

/* Center the book block */
.showcase-reader .stf__block {
    margin: 0 auto !important;
}

/* ==========================================================================
   Page Styling (StPageFlip)
   ========================================================================== */

/* Individual pages */
.showcase-reader .stf__item {
    background: white;
}

.showcase-reader .page {
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

/* Hard pages (covers, endpapers) */
.showcase-reader .page-hard {
    background: #fafafa;
}

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

/* ==========================================================================
   Cover Pages
   ========================================================================== */

.showcase-reader .page-front_cover .page-content,
.showcase-reader .page-back_cover .page-content {
    padding: 0;
}

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

/* Back cover - matches main reader with featured books */
.showcase-reader .page-back_cover .page-content {
    background: white;
    color: #2d2d2d;
    text-align: center;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

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

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

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

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

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

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

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

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

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

/* Back Cover - Branding Section */
.showcase-reader .back-cover-branding {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
}

.showcase-reader .back-cover-logo {
    max-width: 100px;
    margin-bottom: 12px;
}

.showcase-reader .back-cover-text {
    font-size: 14px;
    margin: 4px 0;
    line-height: 1.5;
}

.showcase-reader .back-cover-text-secondary {
    font-size: 11px;
    color: #666;
    margin-top: 8px;
}

/* ==========================================================================
   Endpapers
   ========================================================================== */

.showcase-reader .page-front_endpaper .page-content,
.showcase-reader .page-rear_endpaper .page-content {
    padding: 0;
}

.showcase-reader .endpaper-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Fallback pattern if no image */
.showcase-reader .endpaper-pattern {
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
                linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
                linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
                linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #fafafa;
}

/* ==========================================================================
   Title Page
   ========================================================================== */

.showcase-reader .page-title_page .page-content {
    padding: 40px 30px;
    text-align: center;
    background: white;
}

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

.showcase-reader .title-treatment-img {
    max-width: 85%;
    max-height: 55%;
    object-fit: contain;
    margin-bottom: 30px;
}

.showcase-reader .book-title {
    font-size: clamp(22px, 3.5vw, 32px);
    font-weight: 700;
    color: #D94A1F;
    margin-bottom: 16px;
    line-height: 1.2;
}

.showcase-reader .book-author {
    font-size: clamp(14px, 1.8vw, 18px);
    color: #666;
    margin-bottom: 20px;
}

.showcase-reader .dedication {
    font-size: clamp(12px, 1.4vw, 15px);
    color: #888;
    font-style: italic;
    max-width: 280px;
}

/* ==========================================================================
   Text Pages
   ========================================================================== */

.showcase-reader .page-text_page .page-content {
    padding: 50px 40px;
    align-items: center;
    justify-content: center;
}

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

/* ==========================================================================
   Image Pages
   ========================================================================== */

.showcase-reader .page-image_page .page-content {
    padding: 0;
}

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

/* ==========================================================================
   Publisher Notes
   ========================================================================== */

.showcase-reader .page-publisher_notes .page-content {
    padding: 50px 40px;
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
}

.showcase-reader .publisher-text {
    font-family: 'Georgia', serif;
    font-size: clamp(9px, 0.6vw, 12px);
    line-height: 1.8;
    color: #555;
    text-align: left;
    white-space: pre-line;
    max-width: 90%;
}

/* ==========================================================================
   Control Bar
   ========================================================================== */

.showcase-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 24px 16px;
    margin-top: 16px;
}

/* Navigation & Action Buttons */
.showcase-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: white;
    color: #2d2d2d;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.showcase-btn:hover:not(:disabled) {
    background: #6366f1;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.showcase-btn:active:not(:disabled) {
    transform: translateY(0);
}

.showcase-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Page Counter */
.showcase-page-counter {
    font-size: 15px;
    color: #666;
    font-weight: 500;
    min-width: 70px;
    text-align: center;
}

/* Narration Button States */
.showcase-btn.narration-btn.active {
    background: #6366f1;
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.showcase-btn.narration-btn.active:hover {
    background: #5558e3;
}

/* Narration playing indicator */
.showcase-btn.narration-btn.playing {
    animation: showcase-pulse 1.5s ease-in-out infinite;
}

@keyframes showcase-pulse {
    0%, 100% { box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3); }
    50% { box-shadow: 0 2px 16px rgba(99, 102, 241, 0.5); }
}

/* ==========================================================================
   Scroll Reveal Animation
   ========================================================================== */

.showcase-section[data-scroll-reveal] {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.showcase-section[data-scroll-reveal].scroll-revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ==========================================================================
   Touch/Click Hints
   ========================================================================== */

/* Optional: Show click hint on first visit */
.showcase-click-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    pointer-events: none;
    opacity: 0;
    animation: showcase-hint-fade 3s ease-in-out 2s forwards;
}

@keyframes showcase-hint-fade {
    0%, 100% { opacity: 0; }
    20%, 80% { opacity: 1; }
}

/* ==========================================================================
   High Contrast / Accessibility
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .showcase-loading::before,
    .showcase-btn.narration-btn.playing,
    .showcase-section[data-scroll-reveal] {
        animation: none;
    }

    .showcase-section[data-scroll-reveal] {
        opacity: 1;
        transform: none;
    }
}

/* Focus states for keyboard navigation */
.showcase-btn:focus {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

.showcase-btn:focus:not(:focus-visible) {
    outline: none;
}
