/* Reading Mode Styles */

#view-reading {
    background-image: url('../assets/library-bg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    position: relative;
    min-height: 100vh;
    overflow-y: auto;
    perspective: 1500px;
    /* For 3D effects */
}

#view-reading::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.05);
    /* Very light overlay instead of dark */
    z-index: 0;
}

#view-reading>* {
    position: relative;
    z-index: 1;
}

.game-header-bar {
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.15);
    /* Much lighter glass effect */
    backdrop-filter: blur(15px);
    border-bottom: 1px solid rgba(241, 196, 15, 0.3);
    /* Gold tint border */
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

/* --- PHYSICAL BOOKSHELF --- */
.library-grid {
    display: flex;
    flex-direction: column;
    gap: 5rem;
    /* Increased gap */
    padding: 3rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.shelf-group {
    position: relative;
    padding-bottom: 20px;
}

.shelf-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: white;
    /* Changed from gold for better contrast on lighter bg */
    margin-bottom: 1.5rem;
    margin-left: 2rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.shelf-row {
    display: flex;
    flex-wrap: wrap;
    gap: 3rem;
    padding: 1rem 2rem 3rem 2rem;
    /* Adjusted padding */
    background: transparent;
    /* Removed dark background */
    border-radius: 10px;
    position: relative;
    justify-content: center;
}


/* The Wooden Shelf Ledge */
.shelf-ledge {
    position: absolute;
    bottom: -10px;
    left: 10px;
    right: 10px;
    height: 15px;
    background: linear-gradient(to bottom, #5d4037, #3e2723);
    border-radius: 4px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.6);
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.book-card {
    position: relative;
    width: 160px;
    /* Slightly smaller as requested */
    height: 240px;
    cursor: pointer;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
    box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.5);
    z-index: 5;
}

.book-card:hover {
    transform: rotateY(25deg) translateY(-15px);
    z-index: 10;
}

.book-card::before {
    /* Spine */
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 25px;
    height: 100%;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.3), rgba(255, 255, 255, 0.1));
    transform: rotateY(-90deg);
    transform-origin: left;
    background-color: inherit;
    z-index: 2;
}

.book-card {
    background: #2d3436;
    border-radius: 2px 4px 4px 2px;
}

.book-level-badge {
    display: none;
    /* Grouped by shelf now */
}

.book-cover {
    height: 55%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    pointer-events: none;
}

.book-title {
    padding: 0 10px;
    font-size: 1rem;
    font-weight: bold;
    color: white;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.2;
}

.book-author {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    margin-top: 4px;
}


/* Show in tooltip or expanded view if needed */

/* --- PROFESSIONAL BOOK READER --- */
.reader-container {
    max-width: 1000px;
    margin: 1rem auto;
    /* Reduced margin */
    perspective: 2000px;
}


.book-frame {
    background: #fdf6e3;
    /* Paper color */
    background-image:
        linear-gradient(90deg, transparent 50%, rgba(0, 0, 0, 0.05) 50%),
        radial-gradient(rgba(0, 0, 0, 0.02) 1px, transparent 0);
    background-size: 100% 100%, 20px 20px;
    height: 75vh;
    /* Fixed height for consistent book feel */
    min-height: 500px;
    border-radius: 12px;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.6), inset 0 0 100px rgba(0, 0, 0, 0.03);
    position: relative;
    display: flex;
    overflow: hidden;
    border: 10px solid #3d2b1f;
    /* Wood/Leather frame */
}

/* Spine shadow in middle */
.book-frame::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(0, 0, 0, 0.1);
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.4);
    z-index: 10;
}

.reader-content {
    width: 100%;
    height: 100%;
    /* Fill the frame */
    padding: 3rem 5rem 6rem 5rem;
    /* Reduced bottom padding */
    font-family: 'Outfit', serif;
    font-size: 1.4rem;
    line-height: 1.8;
    color: #2c3e50;
    transition: opacity 0.4s ease, transform 0.4s ease;
    transform-origin: center;
    overflow-y: auto;
    scroll-behavior: smooth;
}


/* Custom Scrollbar for Paper */
.reader-content::-webkit-scrollbar {
    width: 6px;
}

.reader-content::-webkit-scrollbar-track {
    background: transparent;
}

.reader-content::-webkit-scrollbar-thumb {
    background: rgba(61, 43, 31, 0.2);
    border-radius: 10px;
}

.reader-content::-webkit-scrollbar-thumb:hover {
    background: rgba(61, 43, 31, 0.4);
}

/* --- PAGE FLIP ANIMATIONS --- */
.flip-next {
    animation: flipNext 0.6s ease-in-out forwards;
}

.flip-prev {
    animation: flipPrev 0.6s ease-in-out forwards;
}

@keyframes flipNext {
    0% {
        transform: rotateY(0deg);
        opacity: 1;
    }

    50% {
        transform: rotateY(-90deg);
        opacity: 0.5;
    }

    100% {
        transform: rotateY(0deg);
        opacity: 1;
    }
}

@keyframes flipPrev {
    0% {
        transform: rotateY(0deg);
        opacity: 1;
    }

    50% {
        transform: rotateY(90deg);
        opacity: 0.5;
    }

    100% {
        transform: rotateY(0deg);
        opacity: 1;
    }
}

/* Headers and UX */
.reader-header {
    background: rgba(15, 23, 42, 0.9);
    padding: 0.8rem 2rem;
    border-radius: 50px;
    margin: 1rem auto;
    max-width: 900px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
    gap: 1.5rem;
    position: relative;
    z-index: 100;
    /* Ensure header and its dropdown are above book */
}

.reader-header-title {
    flex: 1;
}

.reader-header-title h3 {
    font-size: 1rem;
    margin: 0;
    color: white;
}

.reader-header-title span {
    font-size: 0.75rem;
    color: var(--accent-gold);
}

/* Dictionary Search Bar */
.reader-search-box {
    position: relative;
    flex: 1.5;
    max-width: 350px;
}

.reader-search-box input {
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-glass);
    padding: 0.6rem 1.2rem;
    padding-right: 3rem;
    border-radius: 30px;
    color: white;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.reader-search-box input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--accent-gold);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.2);
}

.search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent-gold);
    pointer-events: none;
}

.search-suggestions {
    position: absolute;
    top: 110%;
    left: 0;
    width: 180%;
    /* Widen for full words/meanings */
    min-width: 300px;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid var(--border-glass);
    border-radius: 15px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.8);
    display: none;
}

@media (max-width: 768px) {
    .search-suggestions {
        width: 100%;
        left: 0;
    }
}

.search-suggestions.show {
    display: block;
}

.suggestion-item {
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    color: #cbd5e1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s;
    display: flex;
    /* Flex layout for text and star */
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.suggestion-item:hover {
    background: rgba(139, 92, 246, 0.2);
    color: white;
}

.suggestion-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Fallback for very long meanings */
}

.suggestion-match {
    color: var(--accent-gold);
    font-weight: bold;
}

.suggestion-star {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.3);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    transition: all 0.2s;
}

.suggestion-star.active {
    color: var(--accent-gold);
}

.suggestion-star:hover {
    transform: scale(1.2);
}

/* Back Button */
.reader-back-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-glass);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.reader-back-btn:hover {
    background: var(--neon-purple);
    transform: scale(1.1);
}

.reader-pagination {
    position: fixed;
    bottom: 1rem;
    /* Moved lower */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    padding: 0.4rem 1rem;
    /* Sleeker padding */
    border-radius: 50px;
    display: flex;
    gap: 1rem;
    align-items: center;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 1000;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
    width: auto;
}

.pagination-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 40px;
    /* Reduced size */
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-size: 1.2rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.pagination-btn:hover:not(:disabled) {
    background: var(--neon-purple);
    border-color: white;
    transform: scale(1.1);
}

.pagination-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.pagination-btn:disabled {
    opacity: 0.3;
    /* Adjusted for better visibility */
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.05);
}

.page-indicator {
    font-size: 0.85rem;
    /* Slightly smaller text */
    font-weight: 800;
    color: var(--accent-gold);
    min-width: 70px;
    text-align: center;
}



@media (max-width: 768px) {
    .reader-content {
        padding: 2rem;
        font-size: 1.1rem;
    }

    .book-frame {
        border-width: 4px;
        min-height: 400px;
    }
}

/* Series Badge */
.series-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.6);
    color: var(--accent-gold);
    border: 1px solid var(--accent-gold);
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 8px;
    backdrop-filter: blur(4px);
    font-weight: bold;
}

/* Volume Selector Modal */
.volume-selector-content {
    max-width: 400px;
    width: 90%;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.5rem;
}

.volume-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.volume-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.volume-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.volume-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    border-color: var(--accent-gold) !important;
}

.vol-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.vol-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.vol-label {
    color: white;
    font-weight: bold;
    font-size: 1rem;
}

.vol-sub {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.vol-arrow {
    color: var(--accent-gold);
    font-size: 1.2rem;
    opacity: 0.7;
}


/* --- BOOKMARK RIBBON --- */
.bookmark-ribbon {
    position: absolute;
    top: -10px;
    right: 30px;
    width: 35px;
    height: 40px;
    /* Initial short state */
    background: #bdc3c7;
    /* Gray when inactive */
    z-index: 100;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.bookmark-ribbon.active {
    height: 100px;
    /* Slides down when active */
    background: linear-gradient(to bottom, #e74c3c, #c0392b);
    /* Royal Red */
    box-shadow: 0 5px 15px rgba(192, 57, 43, 0.4);
}

.bookmark-ribbon::after {
    content: '🔖';
    font-size: 1.2rem;
    margin-top: 5px;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.bookmark-ribbon.active::after {
    opacity: 1;
    content: '👑';
    /* Kingly touch when active */
}

/* Ribbon Tail (V-shape at bottom) */
.ribbon-tail {
    position: absolute;
    bottom: -15px;
    left: 0;
    width: 0;
    height: 0;
    border-left: 17.5px solid transparent;
    border-right: 17.5px solid transparent;
    border-top: 15px solid #bdc3c7;
    transition: border-top-color 0.4s;
}

.bookmark-ribbon.active .ribbon-tail {
    border-top-color: #c0392b;
}

.bookmark-ribbon:hover {
    transform: translateY(5px);
}