/* Modern Responsive Flipbook Viewer */

:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --accent: #38bdf8;
    --text: #f8fafc;
    --book-width: 400px; 
    --book-height: 560px;
    --anim-speed: 0.6s;
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg-gradient);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* --- Loader --- */
.loader-container {
    position: absolute;
    top: 0; 
    left: 0; 
    right: 0; 
    bottom: 0;
    background: var(--bg-gradient);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    transition: opacity 0.5s;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 15px;
}

.loading-text {
    color: white; 
    font-size: 0.9rem;
}

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

/* --- UI: Header --- */
.ui-header {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 24px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    width: max-content;
    max-width: 100%;
}

.book-title {
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--accent);
    color: #0f172a;
}

/* --- UI: Controls --- */
.ui-controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 20px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.control-btn {
    background: rgba(255,255,255,0.05);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 1rem;
}

.control-btn:hover {
    background: var(--accent);
    color: #0f172a;
    transform: scale(1.1);
}

.control-btn:active {
    transform: scale(0.95);
}

.page-counter {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    margin: 0 10px;
    background: rgba(0,0,0,0.3);
    padding: 5px 10px;
    border-radius: 4px;
    min-width: 60px;
    text-align: center;
}

.divider {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.2);
    margin: 0 5px;
}

.info-badge {
    font-size: 0.85rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* --- Stage Area --- */
.stage {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    perspective: 1500px;
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* --- Book Container --- */
.book-container {
    position: relative;
    width: var(--book-width);
    height: var(--book-height);
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.645, 0.045, 0.355, 1);
}

/* --- Leaf (Page) --- */
.leaf {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: left center;
    transform-style: preserve-3d;
    transition: transform var(--anim-speed) cubic-bezier(0.645, 0.045, 0.355, 1);
}

.leaf.flipped {
    transform: rotateY(-180deg);
}

/* --- Page Faces --- */
.page-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background-color: white;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.1);
}

.page-face.front {
    transform: rotateY(0deg);
    background: linear-gradient(to right, #e3e3e3 0%, #ffffff 10%);
}

.page-face.back {
    transform: rotateY(180deg);
    background: linear-gradient(to left, #e3e3e3 0%, #ffffff 10%);
}

.mobile-layout .page-face.front {
    background: white;
}

.mobile-layout .page-face.back {
    background: transparent;
    box-shadow: none;
    border: none;
}

.page-face canvas,
.page-face img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

/* --- Responsive --- */

/* Desktop - Large screens */
@media (min-width: 1025px) {
    .ui-controls {
        padding: 12px 20px;
        gap: 12px;
        bottom: 30px;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .page-counter {
        font-size: 0.9rem;
        min-width: 60px;
        margin: 0 10px;
        padding: 5px 10px;
    }
    
    .divider {
        height: 20px;
        margin: 0 5px;
    }
    
    .info-badge {
        font-size: 0.85rem;
        gap: 6px;
    }
}

/* Tablet - Medium screens */
@media (max-width: 1024px) and (min-width: 601px) {
    .ui-controls {
        width: 90%;
        padding: 10px 16px;
        gap: 10px;
        bottom: 25px;
        border-radius: 40px;
    }
    
    .control-btn {
        width: 38px;
        height: 38px;
        font-size: 0.95rem;
    }
    
    .page-counter {
        font-size: 0.85rem;
        min-width: 55px;
        margin: 0 8px;
        padding: 4px 9px;
    }
    
    .divider {
        height: 18px;
        margin: 0 4px;
    }
    
    .info-badge {
        font-size: 0.8rem;
        gap: 5px;
    }
}

/* Mobile - Small screens */
@media (max-width: 600px) {
    .ui-controls { 
        width: 96%;
        max-width: 100%;
        justify-content: center;
        padding: 8px 10px;
        gap: 5px;
        bottom: 15px;
        flex-wrap: nowrap;
        overflow-x: auto;
        border-radius: 30px;
    }
    
    .control-btn {
        width: 34px;
        height: 34px;
        font-size: 0.85rem;
        flex-shrink: 0;
    }
    
    .control-btn:hover {
        transform: scale(1.05);
    }
    
    .control-btn i {
        font-size: 0.85rem;
    }
    
    .page-counter { 
        margin: 0 3px;
        min-width: 42px;
        font-size: 0.75rem;
        padding: 4px 7px;
        flex-shrink: 0;
    }
    
    .divider {
        height: 16px;
        margin: 0 2px;
        flex-shrink: 0;
    }
    
    .info-badge {
        font-size: 0.72rem;
        gap: 4px;
        flex-shrink: 0;
        padding: 0 2px;
    }
    
    .info-badge i {
        font-size: 0.7rem;
    }
}

/* Extra small mobile devices */
@media (max-width: 400px) {
    .ui-controls {
        width: 98%;
        padding: 6px 8px;
        gap: 3px;
        bottom: 10px;
        border-radius: 25px;
    }
    
    .control-btn {
        width: 30px;
        height: 30px;
        font-size: 0.75rem;
    }
    
    .control-btn i {
        font-size: 0.75rem;
    }
    
    .page-counter {
        min-width: 38px;
        font-size: 0.65rem;
        padding: 3px 5px;
        margin: 0 1px;
    }
    
    .divider {
        height: 12px;
        margin: 0 1px;
    }
    
    .info-badge {
        font-size: 0.65rem;
        gap: 2px;
        padding: 0 1px;
    }
    
    .info-badge i {
        font-size: 0.65rem;
    }
}

