/* ============================================
   MOBILE BOOK CARD SIZES & LAYOUT
   3D Style Matching Splash Screen
   ============================================ */

/* ===== MOBILE HEADER & NAVIGATION FIXES ===== */
@media (max-width: 768px) {

    /* Shorten header title for mobile */
    header h1 {
        font-size: 1rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    header h1 i {
        font-size: 0.9rem !important;
    }

    header p {
        font-size: 0.7rem !important;
    }

    /* Compact header container */
    header .container {
        padding: 0.5rem 12px !important;
    }

    /* Navigation fixes */
    nav {
        padding: 0.5rem 0 !important;
    }

    nav .container {
        padding: 0.5rem 12px !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 8px !important;
    }

    /* Hide desktop nav-links on mobile (only in menu) */
    nav .nav-links {
        display: none !important;
    }

    /* SHOW search box on mobile - make it compact */
    nav .search-box {
        display: flex !important;
        flex: 1 !important;
        max-width: none !important;
        margin: 0 !important;
    }

    nav .search-box input {
        font-size: 0.85rem !important;
        padding: 0.5rem !important;
        height: 36px !important;
    }

    nav .search-box button {
        height: 36px !important;
        width: 36px !important;
        padding: 0 !important;
        font-size: 0.9rem !important;
    }

    /* Hide donate button on mobile */
    nav .donate-btn {
        display: none !important;
    }

    /* Show user nav on mobile (contains theme toggle) */
    .user-nav {
        display: flex !important;
        align-items: center !important;
    }

    .username-badge {
        display: none !important;
    }

    .btn-profile {
        display: none !important;
    }

    .btn-logout {
        display: none !important;
    }

    /* Compact nav-right for mobile - ONLY theme toggle and menu */
    .nav-right {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        margin-left: 0 !important;
    }

    /* Theme toggle button - visible */
    .theme-toggle-btn {
        display: flex !important;
        width: 36px !important;
        height: 36px !important;
        padding: 0 !important;
        font-size: 1.1rem !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Ensure menu button is always visible */
    .mobile-menu-btn {
        display: flex !important;
        background: none !important;
        border: none !important;
        font-size: 1.4rem !important;
        color: var(--white) !important;
        cursor: pointer !important;
        padding: 0.5rem !important;
        margin-left: 0 !important;
        align-items: center !important;
        justify-content: center !important;
        width: 36px !important;
        height: 36px !important;
    }
}

/* ===== HIDE SEARCH BAR ON SPECIFIC PAGES ===== */
/* Hide search bar on listen page */
body[data-page="listen"] nav .search-box,
body.listen-page nav .search-box {
    display: none !important;
}

/* Hide search bar on admin page */
body[data-page="admin"] nav .search-box,
body.admin-page nav .search-box {
    display: none !important;
}

/* ===== MOBILE BOOK CARD BASE STYLES ===== */
@media (max-width: 768px) {

    /* Book Card Container - 3:4 Aspect Ratio */
    .book-card {
        width: 120px !important;
        min-width: 120px !important;
        flex-shrink: 0;
        border-radius: 10px !important;
        box-shadow: 0 5px 15px rgba(123, 31, 162, 0.25),
            0 2px 8px rgba(0, 0, 0, 0.15) !important;
        transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        overflow: hidden;
        position: relative;
        cursor: pointer !important;
    }

    /* 3D Hover Effect - Scale Up 2-3% */
    .book-card:hover,
    .book-card:active {
        transform: translateY(-4px) scale(1.025) !important;
        box-shadow: 0 8px 25px rgba(123, 31, 162, 0.35),
            0 4px 12px rgba(0, 0, 0, 0.2) !important;
    }

    /* Book Cover - 3:4 Aspect Ratio */
    .book-cover {
        width: 120px !important;
        height: 120px !important;
        /* Visibly shorter as requested */
        position: relative;
        overflow: hidden;
        background: var(--bg-surface);
        border-radius: 10px 10px 0 0 !important;
    }

    .cover-image {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        transition: transform 0.3s ease !important;
    }

    .book-card:hover .cover-image {
        transform: scale(1.05) !important;
    }

    /* Book Info Section - More compact without buttons */
    .book-info {
        padding: 4px 8px 8px 8px !important;
        min-height: 50px;
    }

    .book-card h3 {
        font-size: 0.65rem !important;
        line-height: 1.2 !important;
        margin-bottom: 8px !important;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        font-weight: 700 !important;
        color: var(--text-color) !important;
    }

    .book-author {
        font-size: 0.65rem !important;
        margin-bottom: 0 !important;
        opacity: 0.8;
        color: var(--primary-color) !important;
    }

    .book-summary {
        display: none !important;
        /* Hide on mobile to save space */
    }

    /* Buttons removed from DOM, styles no longer needed */

    /* Audio Badge */
    .audio-badge {
        position: absolute !important;
        top: 6px !important;
        right: 6px !important;
        width: 24px !important;
        height: 24px !important;
        border-radius: 50% !important;
        background: var(--primary-dark) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 0.7rem !important;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5) !important;
    }

    /* Share Button */
    .btn-share {
        position: absolute !important;
        top: 6px !important;
        left: 6px !important;
        width: 24px !important;
        height: 24px !important;
        border-radius: 50% !important;
        background: var(--bg-card) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 0.7rem !important;
        color: var(--primary-color) !important;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important;
    }
}

/* ===== HOME PAGE - NEW ARRIVALS ROW ===== */
@media (max-width: 768px) {

    .new-arrivals-section,
    .featured-section {
        margin-bottom: 16px !important;
    }

    .new-arrivals-section h2,
    .featured-section h2 {
        margin-bottom: 14px !important;
        font-size: 1.3rem !important;
    }

    /* Horizontal Scroll Container */
    .book-grid,
    .genre-slider,
    .slider {
        display: flex !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        gap: 30px !important;
        padding: 8px 10px 40px 10px !important;
        scroll-snap-type: x mandatory !important;
        -webkit-overflow-scrolling: touch !important;
        padding-bottom: 40px !important;
        /* Forced extreme space for 12px scrollbar */
    }

    /* Mobile scrollbars now handled by global styles in style.css */


    .book-grid .book-card {
        scroll-snap-align: start !important;
    }
}

/* ===== GENRE PAGE - GRID LAYOUT ===== */
@media (max-width: 768px) {

    .genres-page .book-grid,
    .genre-books-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 30px !important;
        padding: 16px 0 !important;
        overflow-x: visible !important;
    }

    .genres-page .book-card,
    .genre-books-grid .book-card {
        width: 100% !important;
        min-width: unset !important;
    }

    .genre-header {
        padding-top: 18px !important;
        margin-bottom: 16px !important;
    }
}

/* ===== ALL BOOKS PAGE - VERTICAL GRID ===== */
@media (max-width: 768px) {

    .all-books-page .book-grid,
    .books-page .book-grid,
    .library-page .book-grid,
    .genre-books-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 30px 20px !important;
        padding: 12px 0 !important;
        overflow-x: visible !important;
    }

    .all-books-page .book-card,
    .books-page .book-card {
        width: 100% !important;
        min-width: unset !important;
    }

    /* Adjust card width to ~45-48% of screen */
    .all-books-page .book-cover,
    .books-page .book-cover {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 3 / 4 !important;
    }
}

/* ===== MY LIBRARY PAGE - VERTICAL SCROLL ===== */
@media (max-width: 768px) {

    .library-page .book-grid,
    #libraryGrid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 30px !important;
        padding: 12px 0 !important;
        overflow-x: visible !important;
    }

    .library-page .book-card,
    #libraryGrid .book-card {
        width: 100% !important;
        min-width: unset !important;
    }
}

/* ===== AUTHOR CARDS (HOME PAGE) ===== */
@media (max-width: 768px) {
    .author-card {
        width: 100px !important;
        min-width: 100px !important;
        flex-shrink: 0;
        text-align: center;
        border-radius: 12px !important;
        padding: 12px 8px !important;
        background: var(--bg-surface);
        border: 1px solid var(--border-color);
        box-shadow: 0 4px 12px rgba(123, 31, 162, 0.2) !important;
        transition: all 0.3s ease !important;
    }

    .author-card:hover {
        transform: translateY(-3px) scale(1.02) !important;
        box-shadow: 0 6px 18px rgba(123, 31, 162, 0.3) !important;
    }

    .author-photo {
        width: 70px !important;
        height: 70px !important;
        border-radius: 50% !important;
        margin: 0 auto 8px !important;
        border: 3px solid var(--primary-color) !important;
    }

    .author-name {
        font-size: 0.75rem !important;
        font-weight: 600 !important;
        line-height: 1.2 !important;
    }

    .authors-grid {
        display: flex !important;
        overflow-x: auto !important;
        gap: 12px !important;
        padding: 8px 4px 12px 4px !important;
        scroll-snap-type: x mandatory !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .authors-grid::-webkit-scrollbar {
        display: none !important;
    }
}

/* ===== DECORATIVE FLOATING BOOKS (HOME PAGE FOOTER) ===== */
@media (max-width: 768px) {
    .footer-decorative-books {
        display: flex !important;
        justify-content: center !important;
        gap: 10px !important;
        padding: 20px 0 !important;
        overflow: hidden;
    }

    .floating-book-mini {
        width: 70px !important;
        height: 93px !important;
        /* 70 * 4/3 */
        border-radius: 6px !important;
        box-shadow: 0 4px 10px rgba(123, 31, 162, 0.25) !important;
        animation: floatMini 3s ease-in-out infinite !important;
        opacity: 0.8;
    }

    .floating-book-mini:nth-child(1) {
        animation-delay: 0s;
    }

    .floating-book-mini:nth-child(2) {
        animation-delay: 0.5s;
    }

    .floating-book-mini:nth-child(3) {
        animation-delay: 1s;
    }

    @keyframes floatMini {

        0%,
        100% {
            transform: translateY(0) rotate(0deg);
        }

        50% {
            transform: translateY(-8px) rotate(2deg);
        }
    }
}

/* ===== SPACING ADJUSTMENTS ===== */
@media (max-width: 768px) {
    .container {
        padding: 0 12px !important;
    }

    section {
        margin-bottom: 20px !important;
    }

    h2 {
        margin-bottom: 14px !important;
    }

    /* Top margin from section title to cards */
    .book-grid {
        margin-top: 0 !important;
    }
}

/* ===== ENSURE 3D ELEVATION CONSISTENCY ===== */
@media (max-width: 768px) {

    .book-card,
    .author-card {
        position: relative;
        z-index: 1;
    }

    /* Enhanced 3D depth on tap/touch */
    .book-card:active {
        transform: translateY(-2px) scale(1.02) !important;
        box-shadow: 0 6px 20px rgba(123, 31, 162, 0.3) !important;
    }
}