/* --- Base Styles --- */
body { 
    font-family: system-ui, sans-serif; 
    background: #1a1a1a; 
    color: white; 
    margin: 0; 
    padding: 20px; 
}

.grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); 
    gap: 25px; 
}

.card { 
    background: #2a2a2a; 
    border-radius: 8px; 
    cursor: pointer; 
    padding: 10px; 
    transition: 0.3s; 
    border: 1px solid #333; 
    text-align: center; 
}

.card:hover { 
    border-color: #555; 
    background: #333; 
}

.card img { 
    width: 100%; 
    height: 230px; 
    object-fit: cover; 
    border-radius: 4px; 
}

/* --- Storybook Modal & Leather Cover --- */
#readerModal { 
    display: none; 
    position: fixed; 
    inset: 0; 
    background: radial-gradient(circle, #2c2c2c 0%, #000000 100%); 
    z-index: 1000; 
    align-items: center;
    justify-content: center;
    perspective: 1500px; /* Required for page-turn feel */
}

.reader-container { 
    width: 95vw;
    height: 85vh; 
    max-width: 1200px;

    /* Storybook cloth cover */
    background:
        radial-gradient(circle at top left, #f6d7a7 0%, #cfa26a 45%, #8a5a2f 100%),
        repeating-linear-gradient(
            45deg,
            rgba(255,255,255,0.04) 0px,
            rgba(255,255,255,0.04) 2px,
            rgba(0,0,0,0.04) 4px,
            rgba(0,0,0,0.04) 6px
        );

    position: relative; 
    border-radius: 18px; 
    padding: 18px; 

    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* thick, soft storybook depth */
    box-shadow:
        0 2px 2px rgba(255,255,255,0.25),
        0 10px 20px rgba(0,0,0,0.35),
        0 30px 60px rgba(0,0,0,0.55),
        inset 0 2px 4px rgba(255,255,255,0.35),
        inset 0 -10px 18px rgba(0,0,0,0.35);

    
}

.




@keyframes openBook {
    from { transform: rotateY(-20deg) scale(0.9); opacity: 0; }
    to { transform: rotateY(0deg) scale(1); opacity: 1; }
}

/* --- Paper Pages & Texture --- */
#viewer { 
    width: 100%; 
    height: 100%;
    
    /* Paper Texture Overlay */
    background-image: 
        url("https://www.transparenttextures.com/patterns/paper-fibers.png"),
        linear-gradient(to right, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0) 5%, rgba(0,0,0,0) 95%, rgba(0,0,0,0.05) 100%);
    display: block;
    position: relative; 
    background: #fff6df;
    box-shadow:
        inset 0 0 0 1px rgba(120,80,40,0.25),
        inset 0 10px 16px rgba(0,0,0,0.08),
        inset 0 -12px 20px rgba(0,0,0,0.18),
        0 6px 14px rgba(0,0,0,0.35);

    border-radius: 10px;
    overflow-y: auto;

}


#viewer {
    position: relative;
}

/* shared corner style */
#viewer::before,
#viewer::after {
    content: "";
    position: absolute;
    inset: 18px;
    pointer-events: none;
    border-radius: 8px;
}

/* subtle inner frame */
#viewer::before {
    border: 2px solid rgba(160,110,50,0.35);
    box-shadow: inset 0 0 12px rgba(120,70,20,0.15);
}

/* illustrated corners */
#viewer::after {
    background:
        /* top left */
        radial-gradient(circle at top left, rgba(160,110,50,0.55) 0%, transparent 60%),
        /* top right */
        radial-gradient(circle at top right, rgba(160,110,50,0.55) 0%, transparent 60%),
        /* bottom left */
        radial-gradient(circle at bottom left, rgba(160,110,50,0.55) 0%, transparent 60%),
        /* bottom right */
        radial-gradient(circle at bottom right, rgba(160,110,50,0.55) 0%, transparent 60%);
    background-size: 70px 70px;
    background-repeat: no-repeat;
    background-position:
        top left,
        top right,
        bottom left,
        bottom right;
}


/* Central Binding Crease */
.reader-container::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 15px;
    bottom: 15px;
    width: 40px;
    transform: translateX(-50%);
    background: linear-gradient(to right, 
        rgba(0,0,0,0) 0%, 
        rgba(0,0,0,0.1) 40%, 
        rgba(0,0,0,0.2) 50%, 
        rgba(0,0,0,0.1) 60%, 
        rgba(0,0,0,0) 100%);
    z-index: 5;
    pointer-events: none;
}

/* --- Highlights --- */
.word-highlight {
    background-color: rgba(184, 134, 11, 0.2) !important; /* Muted Gold */
    border-bottom: 2px solid #b8860b;
    color: #000 !important;
}

/* --- Controls (Brass & Mahogany Style) --- */
.audio-bar { 
    position: absolute; 
    bottom: 20px; 
    left: 50%; 
    transform: translateX(-50%);
    display: flex; 
    align-items: center; 
    gap: 15px; 
    background: #3d2b1f; 
    padding: 10px 30px; 
    border-radius: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5); 
    z-index: 10;
    border: 1px solid #b8860b; 
}

.btn { 
    background: #5d4037; 
    color: #fff; 
    border: 1px solid #b8860b; 
    padding: 8px 18px; 
    cursor: pointer; 
    border-radius: 20px; 
    font-weight: bold; 
    transition: 0.3s;
}

.btn:hover { 
    background: #b8860b; 
    color: #3d2b1f;
    transform: translateY(-1px);
}

.close-btn { 
    position: absolute; 
    top: 25px; 
    right: 25px; 
    color: #333; 
    font-size: 24px; 
    background: #eee; 
    width: 35px; 
    height: 35px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    border-radius: 50%; 
    transition: 0.3s;
    z-index: 20;
}

.progress-container {
    width: 250px;
    height: 6px;
    background: #2a1e16;
    border-radius: 4px;
}

.progress-bar {
    height: 100%;
    background: #b8860b;
}

/* --- Responsive Layout --- */
@media (max-width: 900px) {
    .reader-container {
        width: 100vw;
        height: 100vh;
        margin: 0;
        border-radius: 0;
        padding: 5px;
    }
    .reader-container::after { display: none; }
    .ebook-content {
        column-count: 1;
        padding: 40px 20px;
    }
}