/* ==========================================================================
   Axomiya Puthi Archive v2.0 - Design System, Themes & Mobile Responsiveness
   ========================================================================== */

/* Dark Theme (Default) */
:root,
[data-theme="dark"] {
    --bg-base: #090d16;
    --bg-surface: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.75);
    --bg-card-hover: rgba(30, 41, 59, 0.98);
    --bg-input: rgba(30, 41, 59, 0.7);
    --cover-bg: radial-gradient(circle at 50% 30%, #1e293b 0%, #090d16 100%);
    --header-bg: linear-gradient(180deg, rgba(15, 23, 42, 0.85) 0%, rgba(9, 13, 22, 0) 100%);
    --modal-dialog-bg: #0f172a;
    --modal-topbar-bg: #0b1120;
    
    --primary: #10b981;
    --primary-glow: rgba(16, 185, 129, 0.35);
    --primary-light: #34d399;
    --primary-hover: #059669;
    
    --accent: #06b6d4;
    --accent-glow: rgba(6, 182, 212, 0.35);
    --accent-blue: #3b82f6;
    
    --gold: #f59e0b;
    --gold-glow: rgba(245, 158, 11, 0.3);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(16, 185, 129, 0.4);
    
    --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --shadow-hover: 0 20px 40px -10px rgba(0, 0, 0, 0.8), 0 0 25px rgba(56, 189, 248, 0.2);
    
    --theme-btn-bg: rgba(255, 255, 255, 0.08);
    --theme-btn-border: rgba(255, 255, 255, 0.15);
}

/* Light Theme */
[data-theme="light"] {
    --bg-base: #f8fafc;
    --bg-surface: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-card-hover: #ffffff;
    --bg-input: #ffffff;
    --cover-bg: radial-gradient(circle at 50% 30%, #e2e8f0 0%, #cbd5e1 100%);
    --header-bg: linear-gradient(180deg, rgba(241, 245, 249, 0.95) 0%, rgba(248, 250, 252, 0) 100%);
    --modal-dialog-bg: #ffffff;
    --modal-topbar-bg: #f1f5f9;
    
    --primary: #059669;
    --primary-glow: rgba(5, 150, 105, 0.25);
    --primary-light: #059669;
    --primary-hover: #047857;
    
    --accent: #0284c7;
    --accent-glow: rgba(2, 132, 199, 0.25);
    --accent-blue: #2563eb;
    
    --gold: #d97706;
    --gold-glow: rgba(217, 119, 6, 0.25);
    
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-dim: #64748b;
    
    --border-color: rgba(0, 0, 0, 0.09);
    --border-glow: rgba(5, 150, 105, 0.3);
    
    --shadow-card: 0 4px 20px -4px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 16px 32px -8px rgba(0, 0, 0, 0.15), 0 0 20px rgba(2, 132, 199, 0.15);
    
    --theme-btn-bg: rgba(0, 0, 0, 0.05);
    --theme-btn-border: rgba(0, 0, 0, 0.12);
}

:root {
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Noto Sans Bengali', 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-body);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ==========================================================================
   Full-Screen Celestial Sun & Moon Horizon Transition Overlay
   ========================================================================== */
.celestial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 999999;
    display: none;
    overflow: hidden;
}

.celestial-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.celestial-sky-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
}

/* Star bursts during moonrise */
.celestial-stars-burst {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    z-index: 2;
}

.c-star {
    position: absolute;
    font-size: 2.2rem;
    filter: drop-shadow(0 0 16px #ffffff);
}

.c-s1 { top: 22%; left: 22%; animation: starFloat 1.8s ease-out forwards; }
.c-s2 { top: 30%; right: 18%; font-size: 2.8rem; animation: starFloat 2s ease-out forwards 0.15s; }
.c-s3 { top: 52%; left: 16%; animation: starFloat 1.9s ease-out forwards 0.25s; }
.c-s4 { top: 20%; right: 28%; font-size: 3rem; animation: starFloat 2.1s ease-out forwards 0.1s; }
.c-s5 { top: 62%; right: 22%; font-size: 2.4rem; animation: starFloat 1.8s ease-out forwards 0.35s; }

@keyframes starFloat {
    0% { transform: scale(0) rotate(0deg); opacity: 0; }
    40% { transform: scale(1.6) rotate(180deg); opacity: 1; }
    80% { transform: scale(1.2) rotate(300deg); opacity: 0.9; }
    100% { transform: scale(0.6) rotate(360deg); opacity: 0; }
}

.celestial-orb-stage {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
}

/* Giant Sun Styles */
.giant-sun {
    position: absolute;
    width: 240px;
    height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(80vh);
}

.solar-corona {
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(245, 158, 11, 0.75) 0%, rgba(251, 191, 36, 0.45) 40%, rgba(254, 240, 138, 0.1) 70%, rgba(0,0,0,0) 80%);
    filter: blur(35px);
    animation: coronaPulse 2s ease-in-out infinite alternate;
}

@keyframes coronaPulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    100% { transform: scale(1.3); opacity: 1; }
}

.giant-sun-svg {
    width: 240px;
    height: 240px;
    filter: drop-shadow(0 0 50px rgba(245, 158, 11, 1)) drop-shadow(0 0 100px rgba(251, 191, 36, 0.8));
    animation: giantSunSpin 18s linear infinite;
}

@keyframes giantSunSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Giant Moon Styles */
.giant-moon {
    position: absolute;
    width: 240px;
    height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(80vh);
}

.lunar-corona {
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.7) 0%, rgba(147, 197, 253, 0.4) 45%, rgba(199, 210, 254, 0.1) 70%, rgba(0,0,0,0) 80%);
    filter: blur(40px);
    animation: coronaPulse 2.5s ease-in-out infinite alternate;
}

.giant-moon-svg {
    width: 240px;
    height: 240px;
    filter: drop-shadow(0 0 50px rgba(96, 165, 250, 1)) drop-shadow(0 0 90px rgba(129, 140, 248, 0.8));
}

/* Celestial Center Banner */
.celestial-banner {
    position: absolute;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%) translateY(30px);
    background: rgba(15, 23, 42, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 14px 32px;
    border-radius: var(--radius-full);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.7), 0 0 30px rgba(245, 158, 11, 0.4);
    opacity: 0;
    pointer-events: none;
    z-index: 10;
}

.banner-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

/* ==========================================================================
   SUNRISE ANIMATION SEQUENCE (Switching to Light Mode)
   ========================================================================== */
.celestial-overlay.animating-sunrise .celestial-sky-backdrop {
    background: radial-gradient(circle at 50% 50%, rgba(254, 240, 138, 0.6) 0%, rgba(56, 189, 248, 0.5) 45%, rgba(15, 23, 42, 0.7) 100%);
    animation: sunriseBackdrop 2.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes sunriseBackdrop {
    0% { opacity: 0; transform: scale(0.7); }
    30% { opacity: 1; transform: scale(1.05); }
    70% { opacity: 1; transform: scale(1.1); }
    100% { opacity: 0; transform: scale(1.3); }
}

.celestial-overlay.animating-sunrise .giant-sun {
    animation: sunRisingSequence 2.2s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

@keyframes sunRisingSequence {
    0% {
        opacity: 0;
        transform: translateY(75vh) scale(0.3) rotate(-60deg);
    }
    30% {
        opacity: 1;
        transform: translateY(0vh) scale(1.15) rotate(0deg);
    }
    65% {
        opacity: 1;
        transform: translateY(-8vh) scale(1.05) rotate(20deg);
    }
    85% {
        opacity: 0.9;
        transform: translateY(-30vh) scale(0.9) rotate(40deg);
    }
    100% {
        opacity: 0;
        transform: translateY(-60vh) scale(0.6) rotate(60deg);
    }
}

.celestial-overlay.animating-sunrise .giant-moon {
    animation: moonSettingSequence 1.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes moonSettingSequence {
    0% {
        opacity: 1;
        transform: translateY(0vh) scale(1) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(80vh) scale(0.3) rotate(-90deg);
    }
}

.celestial-overlay.animating-sunrise .celestial-banner {
    animation: bannerPop 2.1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ==========================================================================
   MOONRISE ANIMATION SEQUENCE (Switching to Dark Mode)
   ========================================================================== */
.celestial-overlay.animating-moonrise .celestial-sky-backdrop {
    background: radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.6) 0%, rgba(30, 27, 75, 0.75) 50%, rgba(9, 13, 22, 0.85) 100%);
    animation: moonriseBackdrop 2.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes moonriseBackdrop {
    0% { opacity: 0; transform: scale(0.7); }
    30% { opacity: 1; transform: scale(1.05); }
    70% { opacity: 1; transform: scale(1.1); }
    100% { opacity: 0; transform: scale(1.3); }
}

.celestial-overlay.animating-moonrise .celestial-stars-burst {
    opacity: 1;
}

.celestial-overlay.animating-moonrise .giant-moon {
    animation: moonRisingSequence 2.2s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

@keyframes moonRisingSequence {
    0% {
        opacity: 0;
        transform: translateY(75vh) scale(0.3) rotate(60deg);
    }
    30% {
        opacity: 1;
        transform: translateY(0vh) scale(1.15) rotate(0deg);
    }
    65% {
        opacity: 1;
        transform: translateY(-8vh) scale(1.05) rotate(-15deg);
    }
    85% {
        opacity: 0.9;
        transform: translateY(-30vh) scale(0.9) rotate(-30deg);
    }
    100% {
        opacity: 0;
        transform: translateY(-60vh) scale(0.6) rotate(-45deg);
    }
}

.celestial-overlay.animating-moonrise .giant-sun {
    animation: sunSettingSequence 1.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes sunSettingSequence {
    0% {
        opacity: 1;
        transform: translateY(0vh) scale(1) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(80vh) scale(0.3) rotate(90deg);
    }
}

.celestial-overlay.animating-moonrise .celestial-banner {
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.7), 0 0 30px rgba(96, 165, 250, 0.4);
    animation: bannerPop 2.1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes bannerPop {
    0% { opacity: 0; transform: translateX(-50%) translateY(30px) scale(0.85); }
    20% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
    75% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-20px) scale(0.95); }
}

/* Background Ambient Lighting Effect */
.ambient-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.glow-circle-1 {
    position: absolute;
    top: -15%;
    left: 20%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--primary-glow) 0%, rgba(0, 0, 0, 0) 70%);
    filter: blur(90px);
    animation: floatGlow 14s ease-in-out infinite alternate;
}

.glow-circle-2 {
    position: absolute;
    top: 30%;
    right: -10%;
    width: 550px;
    height: 550px;
    background: radial-gradient(circle, var(--accent-glow) 0%, rgba(0, 0, 0, 0) 70%);
    filter: blur(100px);
    animation: floatGlow 18s ease-in-out infinite alternate-reverse;
}

@keyframes floatGlow {
    0% { transform: translateY(0) scale(1); }
    100% { transform: translateY(80px) scale(1.15); }
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    position: relative;
    z-index: 1;
    width: 100%;
}

/* ==========================================================================
   Header & Top Utility Bar
   ========================================================================== */
.header {
    padding: 24px 0 30px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: background 0.3s ease;
}

.top-nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 14px;
    flex-wrap: wrap;
}

.top-nav-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-radius: var(--radius-full);
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: var(--primary-light);
    font-size: 0.85rem;
    font-weight: 600;
}

.visitor-counter-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    background: rgba(56, 189, 248, 0.08);
    border: 1px solid rgba(56, 189, 248, 0.22);
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 600;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.visitor-counter-badge:hover {
    border-color: #38bdf8;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.25);
    transform: translateY(-1px);
}

.visitor-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #38bdf8;
    box-shadow: 0 0 8px #38bdf8;
    animation: visitorDotPulse 1.6s ease-in-out infinite;
}

@keyframes visitorDotPulse {
    0%, 100% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.35); opacity: 1; box-shadow: 0 0 12px #38bdf8; }
}

.visitor-icon {
    font-size: 0.95rem;
}

.visitor-label {
    color: var(--text-dim);
    font-size: 0.82rem;
    font-weight: 500;
}

.visitor-number {
    color: #38bdf8;
    font-weight: 700;
    font-family: 'Outfit', 'Noto Sans Bengali', sans-serif;
    letter-spacing: 0.3px;
}

/* Footer Visitor Bar */
.footer-visitor-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 0.92rem;
    color: var(--text-dim);
    flex-wrap: wrap;
}

.footer-visitor-item strong {
    color: var(--primary-light);
    font-weight: 700;
}

.footer-visitor-dot {
    opacity: 0.4;
}

/* ==========================================================================
   Celestial Sun & Moon Animated Day/Night Toggle
   ========================================================================== */
.celestial-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 5px 14px 5px 6px;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
}

.celestial-toggle-btn:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: 0 6px 20px var(--primary-glow);
}

/* The Animated Sky Capsule */
.sky-track {
    position: relative;
    width: 48px;
    height: 28px;
    border-radius: var(--radius-full);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: background 0.6s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.4s ease, box-shadow 0.4s ease;
}

/* Dark Sky Track */
[data-theme="dark"] .sky-track {
    background: linear-gradient(135deg, #090d16 0%, #1e1b4b 50%, #0f172a 100%);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
}

/* Light Sky Track (Sunny Daylight) */
[data-theme="light"] .sky-track {
    background: linear-gradient(135deg, #0284c7 0%, #38bdf8 50%, #bae6fd 100%);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.15), 0 0 10px rgba(56, 189, 248, 0.4);
    border-color: rgba(56, 189, 248, 0.5);
}

/* Sky Clouds (Daytime) */
.sky-clouds {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.cloud {
    position: absolute;
    background: rgba(255, 255, 255, 0.75);
    border-radius: 10px;
}

.cloud-1 {
    width: 14px;
    height: 5px;
    top: 6px;
    right: 6px;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
    animation: cloudDrift 6s ease-in-out infinite alternate;
}

.cloud-2 {
    width: 10px;
    height: 4px;
    bottom: 5px;
    left: 6px;
    opacity: 0.8;
    animation: cloudDrift 8s ease-in-out infinite alternate-reverse;
}

@keyframes cloudDrift {
    0% { transform: translateX(0); }
    100% { transform: translateX(3px); }
}

[data-theme="dark"] .sky-clouds {
    opacity: 0;
    transform: translateY(8px) scale(0.7);
}

[data-theme="light"] .sky-clouds {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Sky Stars (Nighttime) */
.sky-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.star {
    position: absolute;
    color: #e0e7ff;
    font-size: 7px;
    line-height: 1;
}

.star-1 {
    top: 5px;
    left: 6px;
    animation: starPulse 2.5s ease-in-out infinite;
}

.star-2 {
    bottom: 6px;
    right: 8px;
    font-size: 6px;
    color: #fbbf24;
    animation: starPulse 3.5s ease-in-out infinite 0.8s;
}

.star-3 {
    top: 8px;
    right: 18px;
    font-size: 5px;
    animation: starPulse 2s ease-in-out infinite 1.4s;
}

@keyframes starPulse {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

[data-theme="dark"] .sky-stars {
    opacity: 1;
    transform: translateY(0);
}

[data-theme="light"] .sky-stars {
    opacity: 0;
    transform: translateY(-8px);
}

/* Horizon Frame */
.celestial-horizon {
    position: relative;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.celestial-body {
    position: absolute;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sun-svg, .moon-svg {
    width: 100%;
    height: 100%;
}

/* Sun Rising & Setting Physics */
.sun-body {
    filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.7));
}

[data-theme="light"] .sun-body {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(1);
    transition: transform 0.65s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
}

[data-theme="dark"] .sun-body {
    opacity: 0;
    transform: translateY(32px) rotate(90deg) scale(0.5); /* Sun goes down below horizon */
    transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

.sun-rays {
    animation: spinSunRays 14s linear infinite;
    transform-origin: 16px 16px;
}

@keyframes spinSunRays {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Moon Rising & Setting Physics */
.moon-body {
    filter: drop-shadow(0 0 6px rgba(96, 165, 250, 0.8));
}

[data-theme="dark"] .moon-body {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(1); /* Moon rises up into the night sky */
    transition: transform 0.65s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
    animation: moonHover 4s ease-in-out infinite alternate;
}

[data-theme="light"] .moon-body {
    opacity: 0;
    transform: translateY(32px) rotate(-90deg) scale(0.5); /* Moon sets down below horizon */
    transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

@keyframes moonHover {
    0% { transform: translateY(0) rotate(0deg); }
    100% { transform: translateY(-1.5px) rotate(4deg); }
}

.theme-text {
    font-size: 0.85rem;
    font-weight: 700;
}

.hero-title {
    font-family: var(--font-heading);
    font-size: clamp(2.2rem, 5vw, 3.4rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin-bottom: 12px;
}

.gradient-text {
    background: linear-gradient(135deg, #10b981 0%, #0284c7 50%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    color: var(--text-muted);
    font-size: clamp(0.95rem, 2vw, 1.15rem);
    max-width: 720px;
    margin: 0 auto 24px;
    line-height: 1.5;
}

.hero-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-main);
    background: var(--theme-btn-bg);
    border: 1px solid var(--border-color);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-pill:hover {
    transform: translateY(-2px);
}

.btn-pill.coffee {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.3);
    color: #f59e0b;
}

.btn-pill.coffee:hover {
    box-shadow: 0 0 20px var(--gold-glow);
}

.btn-pill.telegram {
    background: rgba(2, 132, 199, 0.15);
    border-color: rgba(2, 132, 199, 0.35);
    color: #0284c7;
}

.btn-pill.telegram:hover {
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-pill.sync {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.35);
    color: var(--primary);
}

.btn-pill.sync:hover {
    box-shadow: 0 0 20px var(--primary-glow);
}

/* ==========================================================================
   Interactive Controls & Search
   ========================================================================== */
.controls-section {
    margin: 30px 0 20px;
}

.search-container {
    position: relative;
    max-width: 820px;
    margin: 0 auto 20px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 10px 20px;
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow), var(--shadow-card);
}

.search-icon {
    font-size: 1.3rem;
    margin-right: 14px;
    color: var(--primary);
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-size: 1.05rem;
    font-family: inherit;
    min-height: 28px;
}

.search-input::placeholder {
    color: var(--text-dim);
}

.search-clear-btn {
    background: var(--theme-btn-bg);
    border: none;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.search-clear-btn:hover {
    color: var(--text-main);
}

/* Category Filter Pills */
.category-scroller {
    display: flex;
    justify-content: center;
    gap: 10px;
    overflow-x: auto;
    padding: 6px 4px 16px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.category-scroller::-webkit-scrollbar {
    display: none;
}

.category-chip {
    background: var(--theme-btn-bg);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 9px 18px;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.category-chip:hover {
    color: var(--text-main);
    border-color: var(--primary);
}

.category-chip.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    border-color: var(--primary);
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 4px 15px var(--primary-glow);
}

/* Secondary Meta Bar */
.meta-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    padding: 12px 6px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.results-stats {
    font-size: 0.95rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.stat-count {
    color: var(--primary);
    font-weight: 700;
}

.sort-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sort-group label {
    font-size: 0.88rem;
    color: var(--text-dim);
}

.custom-select {
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 0.88rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.custom-select:focus {
    border-color: var(--primary);
}

/* ==========================================================================
   Book Cards Grid & 3D Cards
   ========================================================================== */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.book-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: relative;
    opacity: 0;
    transform: translateY(36px) scale(0.94) rotateX(10deg);
    transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
                border-color 0.3s ease,
                box-shadow 0.3s ease;
    will-change: transform, opacity;
}

.book-card.revealed {
    opacity: 1;
    transform: translateY(0) scale(1) rotateX(0deg);
}

.book-card.revealed:hover {
    transform: translateY(-8px) scale(1.015);
    border-color: var(--accent);
    box-shadow: var(--shadow-hover);
}

.cover-wrapper {
    position: relative;
    height: 240px;
    background: var(--cover-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.cover-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 140px;
    height: 180px;
    background: radial-gradient(circle, var(--accent-glow) 0%, rgba(0, 0, 0, 0) 70%);
    filter: blur(25px);
    pointer-events: none;
}

.book-3d-frame {
    position: relative;
    height: 100%;
    max-width: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 800px;
}

.book-thumb {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    border-radius: 4px 7px 7px 4px;
    box-shadow: -4px 6px 16px rgba(0, 0, 0, 0.4), 2px 2px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.book-card:hover .book-thumb {
    transform: scale(1.06) rotateY(-4deg);
}

.book-spine-line {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(90deg, rgba(255,255,255,0.3) 0%, rgba(0,0,0,0.3) 100%);
    pointer-events: none;
    border-radius: 2px 0 0 2px;
}

.cover-badges-top {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 2;
}

.badge-cat {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    backdrop-filter: blur(8px);
    max-width: 110px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.badge-year {
    background: rgba(16, 185, 129, 0.18);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    backdrop-filter: blur(8px);
}

.cover-badge-downloads {
    position: absolute;
    bottom: 10px;
    left: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--gold);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.card-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 10px;
}

.book-title {
    font-family: var(--font-heading);
    font-size: 1.08rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.38;
    margin-bottom: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.76em;
    transition: color 0.2s;
}

.book-card:hover .book-title {
    color: var(--accent);
}

.author-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--theme-btn-bg);
    border: 1px solid var(--border-color);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
}

.author-avatar {
    font-size: 0.95rem;
}

.author-meta {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.author-label {
    font-size: 0.68rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.author-name {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tags-container {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    min-height: 22px;
}

.topic-pill {
    font-size: 0.72rem;
    color: var(--text-muted);
    background: var(--theme-btn-bg);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.card-actions {
    margin-top: auto;
    padding-top: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.btn-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 10px;
    min-height: 44px; /* Touch target standard */
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-read {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.2) 0%, rgba(2, 132, 199, 0.35) 100%);
    color: var(--accent-blue);
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.btn-read:hover {
    background: linear-gradient(135deg, #2563eb 0%, #0284c7 100%);
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
    transform: translateY(-2px);
}

.btn-download {
    background: linear-gradient(135deg, rgba(5, 150, 105, 0.2) 0%, rgba(16, 185, 129, 0.35) 100%);
    color: var(--primary);
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.btn-download:hover {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
    transform: translateY(-2px);
}

/* ==========================================================================
   Catalog Scanner Banner & 3D Holographic Skeleton Loading Cards
   ========================================================================== */
.catalog-scanner-container {
    width: 100%;
    margin-bottom: 24px;
    animation: fadeInUp 0.4s ease both;
}

.catalog-scanner-banner {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 0 25px var(--primary-glow);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    animation: scannerBannerPulse 2.5s ease-in-out infinite alternate;
}

[data-theme="dark"] .catalog-scanner-banner {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.95) 0%, rgba(30, 41, 59, 0.85) 100%);
    border-color: rgba(16, 185, 129, 0.35);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.8), 0 0 30px rgba(16, 185, 129, 0.25);
}

@keyframes scannerBannerPulse {
    0% { border-color: var(--border-color); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); }
    100% { border-color: var(--primary); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 30px var(--primary-glow); }
}

.scanner-orb-icon {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--theme-btn-bg);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

[data-theme="dark"] .scanner-orb-icon {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.35);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.scanner-radar-ring {
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    border: 2px dashed var(--primary);
    animation: radarSpin 8s linear infinite;
}

@keyframes radarSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.scanner-book-icon {
    font-size: 1.8rem;
    animation: bookFloatPulse 2s ease-in-out infinite alternate;
}

@keyframes bookFloatPulse {
    0% { transform: translateY(0) scale(1); }
    100% { transform: translateY(-3px) scale(1.1); filter: drop-shadow(0 0 10px var(--primary)); }
}

.scanner-sparkle {
    position: absolute;
    font-size: 0.9rem;
}

.s-1 { top: -2px; right: -2px; animation: sparkleBlink 1.5s ease-in-out infinite; }
.s-2 { bottom: -2px; left: -2px; color: #fbbf24; animation: sparkleBlink 1.8s ease-in-out infinite 0.4s; }

@keyframes sparkleBlink {
    0%, 100% { transform: scale(0.6); opacity: 0.4; }
    50% { transform: scale(1.3); opacity: 1; filter: drop-shadow(0 0 6px #fbbf24); }
}

.scanner-text-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.scanner-main-msg {
    display: flex;
    align-items: center;
    gap: 8px;
}

.scanner-pulse-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary);
    animation: dotPulse 1.2s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.4); opacity: 1; }
}

.scanner-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
}

.scanner-bar-container {
    width: 100%;
    height: 6px;
    background: var(--theme-btn-bg);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-color);
}

.scanner-progress-fill {
    position: absolute;
    top: 0;
    left: -40%;
    width: 40%;
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #06b6d4 50%, #3b82f6 100%);
    box-shadow: 0 0 14px var(--primary);
    border-radius: var(--radius-full);
    animation: scannerBeamSlide 1.6s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

@keyframes scannerBeamSlide {
    0% { left: -40%; width: 30%; }
    50% { width: 60%; }
    100% { left: 100%; width: 30%; }
}

.scanner-sub-msg {
    font-size: 0.82rem;
    color: var(--text-dim);
}

/* 3D Holographic Skeleton Cards (High Contrast in Dark Mode) */
.skeleton-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 480px;
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: relative;
    animation: skeletonFloat 3s ease-in-out infinite alternate;
}

[data-theme="dark"] .skeleton-card {
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.85) 0%, rgba(15, 23, 42, 0.95) 100%);
    border-color: rgba(56, 189, 248, 0.25);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.75), 0 0 20px rgba(6, 182, 212, 0.15);
}

@keyframes skeletonFloat {
    0% { transform: translateY(0); }
    100% { transform: translateY(-4px); }
}

.skeleton-cover {
    height: 240px;
    background: var(--cover-bg);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid var(--border-color);
}

.skeleton-3d-book {
    width: 120px;
    height: 170px;
    background: linear-gradient(135deg, var(--theme-btn-bg) 0%, rgba(255, 255, 255, 0.05) 100%);
    border-radius: 4px 8px 8px 4px;
    border: 1px solid var(--border-color);
    box-shadow: -4px 6px 16px rgba(0, 0, 0, 0.3);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

[data-theme="dark"] .skeleton-3d-book {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
    border-color: rgba(56, 189, 248, 0.3);
    box-shadow: -6px 8px 24px rgba(0, 0, 0, 0.6), 0 0 15px rgba(6, 182, 212, 0.2);
}

.skeleton-spine {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--primary) 0%, #06b6d4 100%);
    border-radius: 2px 0 0 2px;
    box-shadow: 0 0 10px var(--primary-glow);
}

.skeleton-book-icon {
    font-size: 2.2rem;
    opacity: 0.45;
    animation: bookFloatPulse 2s ease-in-out infinite alternate;
}

.skeleton-body {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.skeleton-line {
    border-radius: 6px;
    position: relative;
    overflow: hidden;
    background: var(--theme-btn-bg);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .skeleton-line {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
}

.skeleton-line::after {
    content: '';
    position: absolute;
    top: 0;
    left: -150%;
    width: 150%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(56, 189, 248, 0.35) 25%, rgba(16, 185, 129, 0.5) 50%, rgba(147, 51, 234, 0.35) 75%, transparent 100%);
    animation: holoShimmer 1.8s infinite;
}

[data-theme="light"] .skeleton-line::after {
    background: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.08) 50%, transparent 100%);
}

.skeleton-line.title { height: 22px; width: 88%; }
.skeleton-line.short { height: 14px; width: 55%; }
.skeleton-line.author-box { height: 38px; border-radius: var(--radius-sm); }
.skeleton-actions-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: auto;
    padding-top: 6px;
}
.skeleton-line.btn-shimmer { height: 42px; border-radius: var(--radius-sm); }

@keyframes holoShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(200%); }
}

/* ==========================================================================
   Pagination
   ========================================================================== */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 30px 0 60px;
    flex-wrap: wrap;
}

.page-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    min-width: 44px;
    height: 44px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--primary);
    background: var(--theme-btn-bg);
}

.page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ==========================================================================
   In-App Flipbook Reader Modal & macOS Native Window Physics
   ========================================================================== */
.reader-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(3, 7, 18, 0.82);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.32s cubic-bezier(0.32, 0.72, 0, 1), backdrop-filter 0.32s ease, -webkit-backdrop-filter 0.32s ease;
}

.reader-modal.show {
    display: flex;
}

.reader-modal.show.visible {
    opacity: 1;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.reader-modal.closing {
    opacity: 0;
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
}

.modal-dialog {
    background: var(--modal-dialog-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 1160px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 30px 80px -15px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.1);
    overflow: hidden;
    transform-origin: center 75%;
    transform: scale(0.82) translateY(30px);
    opacity: 0;
    filter: blur(10px);
    transition: transform 0.36s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                filter 0.3s ease,
                max-width 0.3s ease,
                height 0.3s ease,
                border-radius 0.3s ease;
    will-change: transform, opacity, filter;
}

/* macOS Window Open State */
.reader-modal.show.visible:not(.closing) .modal-dialog {
    transform: scale(1) translateY(0);
    opacity: 1;
    filter: blur(0px);
}

/* macOS Window Close State (Smooth Shrink & Sinking Dissolve) */
.reader-modal.closing .modal-dialog {
    transform: scale(0.68) translateY(70px);
    opacity: 0;
    filter: blur(14px);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1),
                opacity 0.25s cubic-bezier(0.32, 0.72, 0, 1),
                filter 0.25s ease;
}

.modal-dialog.fullscreen {
    max-width: 100vw;
    height: 100vh;
    border-radius: 0;
    border: none;
}

.modal-topbar {
    padding: 12px 18px;
    background: var(--modal-topbar-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* macOS Traffic Light Dots */
.mac-window-controls {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-right: 6px;
}

.mac-dot {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s ease, filter 0.15s ease;
}

.mac-dot:hover {
    transform: scale(1.15);
    filter: brightness(1.15);
}

.mac-dot-close {
    background: #ff5f56;
    box-shadow: 0 0 6px rgba(255, 95, 86, 0.4);
}

.mac-dot-min {
    background: #ffbd2e;
    box-shadow: 0 0 6px rgba(255, 189, 46, 0.4);
}

.mac-dot-max {
    background: #27c93f;
    box-shadow: 0 0 6px rgba(39, 201, 63, 0.4);
}

.modal-title-box {
    flex: 1;
    min-width: 160px;
    overflow: hidden;
}

.modal-book-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-view-modes {
    display: flex;
    background: var(--theme-btn-bg);
    padding: 3px;
    border-radius: var(--radius-sm);
    gap: 4px;
    border: 1px solid var(--border-color);
}

.mode-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 12px;
    min-height: 36px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    color: var(--text-main);
}

.mode-btn.active {
    background: var(--accent-blue);
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.35);
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-modal-action {
    background: var(--theme-btn-bg);
    color: var(--text-main);
    padding: 8px 12px;
    min-height: 36px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
    border: 1px solid var(--border-color);
}

.btn-modal-dl {
    background: var(--primary);
    color: #ffffff;
    padding: 8px 14px;
    min-height: 36px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-modal-close {
    background: var(--theme-btn-bg);
    border: none;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-modal-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.modal-body-container {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
    background: #000000;
    overflow: hidden;
}

/* ==========================================================================
   3D Magical Flipping Book & Holographic PDF Loader
   ========================================================================== */
.modal-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-dialog-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    z-index: 100;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.modal-loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.pdf-hologram-aura {
    position: absolute;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--primary-glow) 0%, var(--accent-glow) 40%, rgba(0, 0, 0, 0) 70%);
    filter: blur(40px);
    pointer-events: none;
    animation: auraPulse 3s ease-in-out infinite alternate;
}

@keyframes auraPulse {
    0% { transform: scale(0.85); opacity: 0.5; }
    100% { transform: scale(1.15); opacity: 0.9; }
}

/* 3D Book Container */
.book-loader-3d {
    position: relative;
    width: 160px;
    height: 110px;
    perspective: 1200px;
    transform-style: preserve-3d;
    filter: drop-shadow(0 15px 25px rgba(0, 0, 0, 0.4));
}

.book-spine {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 8px;
    transform: translateX(-50%);
    background: linear-gradient(90deg, #059669 0%, #10b981 50%, #047857 100%);
    border-radius: 3px;
    z-index: 15;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}

.book-page {
    position: absolute;
    top: 0;
    width: 80px;
    height: 110px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .book-page {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.12);
}

.page-left {
    left: 0;
    border-radius: 8px 3px 3px 8px;
    transform-origin: right center;
    box-shadow: -6px 6px 16px rgba(0, 0, 0, 0.3);
}

.page-right {
    right: 0;
    border-radius: 3px 8px 8px 3px;
    transform-origin: left center;
    box-shadow: 6px 6px 16px rgba(0, 0, 0, 0.3);
}

.flipping-page {
    right: 0;
    border-radius: 3px 8px 8px 3px;
    transform-origin: left center;
    transform-style: preserve-3d;
    backface-visibility: visible;
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-surface) 100%);
}

[data-theme="light"] .flipping-page {
    background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);
}

.flip-1 {
    animation: pageFlipMotion 1.8s cubic-bezier(0.645, 0.045, 0.355, 1) infinite;
    animation-delay: 0s;
    z-index: 5;
}

.flip-2 {
    animation: pageFlipMotion 1.8s cubic-bezier(0.645, 0.045, 0.355, 1) infinite;
    animation-delay: 0.3s;
    z-index: 4;
}

.flip-3 {
    animation: pageFlipMotion 1.8s cubic-bezier(0.645, 0.045, 0.355, 1) infinite;
    animation-delay: 0.6s;
    z-index: 3;
}

@keyframes pageFlipMotion {
    0% {
        transform: rotateY(0deg);
        box-shadow: 2px 4px 8px rgba(0, 0, 0, 0.2);
    }
    50% {
        transform: rotateY(-90deg) scale(1.06);
        box-shadow: 0 10px 25px var(--primary-glow);
    }
    100% {
        transform: rotateY(-180deg);
        box-shadow: -2px 4px 8px rgba(0, 0, 0, 0.2);
    }
}

.page-lines {
    display: flex;
    flex-direction: column;
    gap: 6px;
    opacity: 0.6;
}

.page-lines span {
    height: 3px;
    background: var(--text-muted);
    border-radius: 2px;
    display: block;
}

.page-lines span:nth-child(1) { width: 85%; }
.page-lines span:nth-child(2) { width: 100%; }
.page-lines span:nth-child(3) { width: 75%; }
.page-lines span:nth-child(4) { width: 90%; }
.page-lines span:nth-child(5) { width: 60%; }

/* Cyber Laser Scanner Beam */
.laser-scanner-beam {
    position: absolute;
    left: -10px;
    right: -10px;
    height: 3px;
    background: linear-gradient(90deg, rgba(6, 182, 212, 0) 0%, #10b981 50%, rgba(6, 182, 212, 0) 100%);
    box-shadow: 0 0 12px #10b981, 0 0 24px #06b6d4;
    border-radius: 2px;
    z-index: 20;
    animation: laserScan 2s ease-in-out infinite alternate;
}

@keyframes laserScan {
    0% { top: 0%; opacity: 0.3; }
    50% { opacity: 1; }
    100% { top: 100%; opacity: 0.3; }
}

/* Loading Info & Progress Bar */
.pdf-loading-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    max-width: 360px;
    text-align: center;
    z-index: 10;
}

.pdf-loading-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--theme-btn-bg);
    border: 1px solid var(--border-color);
    padding: 6px 16px;
    border-radius: var(--radius-full);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    backdrop-filter: blur(8px);
}

.pulse-sparkle {
    display: inline-block;
    color: #fbbf24;
    animation: sparklePulse 1.2s ease-in-out infinite;
}

@keyframes sparklePulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 2px #fbbf24); }
    50% { transform: scale(1.3); filter: drop-shadow(0 0 8px #f59e0b); }
}

.pdf-progress-track {
    width: 220px;
    height: 6px;
    background: var(--theme-btn-bg);
    border-radius: var(--radius-full);
    overflow: hidden;
    border: 1px solid var(--border-color);
    position: relative;
}

.pdf-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 60%;
    background: linear-gradient(90deg, #10b981 0%, #06b6d4 50%, #3b82f6 100%);
    border-radius: var(--radius-full);
    box-shadow: 0 0 12px var(--primary-glow);
    animation: progressSlide 1.5s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

@keyframes progressSlide {
    0% { left: -60%; width: 40%; }
    50% { width: 70%; }
    100% { left: 100%; width: 40%; }
}

.pdf-loading-sub {
    font-size: 0.8rem;
    color: var(--text-dim);
    line-height: 1.4;
}

.modal-viewer-frame {
    width: 100%;
    height: 100%;
    background: #000000;
    border: none;
}

/* ==========================================================================
   Floating Scroll-To-Top Button
   ========================================================================== */
.scroll-top-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--primary);
    color: #ffffff;
    border: none;
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 18px var(--primary-glow);
    cursor: pointer;
    z-index: 900;
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.scroll-top-btn.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.scroll-top-btn:hover {
    transform: translateY(-4px) scale(1.05);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.footer {
    margin-top: auto;
    padding: 30px 0;
    border-top: 1px solid var(--border-color);
    background: var(--header-bg);
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.footer a {
    color: var(--primary);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Responsive & Mobile Friendly Adjustments
   ========================================================================== */
@media (max-width: 768px) {
    .container { padding: 0 16px; }
    .header { padding: 18px 0 20px; }
    
    .top-nav-bar {
        flex-direction: row;
        justify-content: space-between;
        margin-bottom: 16px;
    }
    
    .hero-title { font-size: 1.95rem; }
    .hero-subtitle { font-size: 0.92rem; margin-bottom: 16px; }
    
    .hero-actions {
        gap: 8px;
    }
    
    .btn-pill {
        padding: 6px 14px;
        font-size: 0.82rem;
    }

    .category-scroller {
        justify-content: flex-start;
        padding: 4px 0 12px;
    }

    .meta-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .sort-group {
        width: 100%;
        justify-content: space-between;
    }

    .custom-select {
        flex: 1;
    }

    .catalog-scanner-banner {
        padding: 14px 16px;
        gap: 14px;
    }

    .scanner-orb-icon {
        width: 48px;
        height: 48px;
    }

    .scanner-book-icon {
        font-size: 1.4rem;
    }

    .scanner-title {
        font-size: 0.92rem;
    }

    .scanner-sub-msg {
        font-size: 0.76rem;
    }

    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 16px;
    }

    /* Modal Fullscreen on Mobile */
    .reader-modal {
        padding: 0;
    }

    .modal-dialog {
        height: 100dvh;
        width: 100vw;
        border-radius: 0;
        border: none;
    }

    .modal-topbar {
        padding: 10px 14px;
        gap: 8px;
    }

    .modal-book-title {
        font-size: 0.95rem;
    }

    .mode-btn span:last-child {
        display: none; /* Icon-only on mobile for cleaner view */
    }

    .btn-modal-action span:last-child {
        display: none;
    }

    .btn-modal-dl {
        padding: 6px 10px;
        font-size: 0.78rem;
    }
}

@media (max-width: 480px) {
    .book-grid {
        grid-template-columns: 1fr; /* Clean single column for small phones */
    }
    
    .cover-wrapper {
        height: 220px;
    }

    .card-actions {
        grid-template-columns: 1fr 1fr;
    }

    .scroll-top-btn {
        bottom: 18px;
        right: 18px;
        width: 42px;
        height: 42px;
    }
}
