/* ==========================================================================
   KURDSON INDUSTRIES - 3D FLIPBOOK CATALOGUE STYLES
   Glassmorphic UI | Smooth 3D Page Flip | Responsive Layout
   ========================================================================== */

/* Variables */
:root {
    --bg-dark: #07070f;
    --bg-dark-accent: #0f0f1e;
    --primary-blue: #002366;
    --primary-blue-glow: #0066FF;
    --primary-red: #D32F2F;
    --primary-red-glow: #FF4444;
    --white: #FFFFFF;
    
    /* Book dimensions */
    --book-ratio: 1.4142; /* A4 double-page aspect ratio (width / height) */
    --book-height: 75vh;
    --book-width: calc(var(--book-height) * var(--book-ratio));
    
    /* Shadows & Transitions */
    --shadow-premium: 0 30px 70px rgba(0, 0, 0, 0.6), 0 10px 20px rgba(0, 0, 0, 0.4);
    --shadow-page-left: inset -10px 0 20px rgba(0,0,0,0.15), 5px 0 10px rgba(0,0,0,0.1);
    --shadow-page-right: inset 10px 0 20px rgba(0,0,0,0.15), -5px 0 10px rgba(0,0,0,0.1);
    --transition-page: transform 0.8s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Base resets for Catalogue Viewport */
.catalogue-body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 30% 20%, rgba(0, 102, 255, 0.12), transparent 45%),
        radial-gradient(circle at 70% 80%, rgba(255, 68, 68, 0.08), transparent 45%);
    font-family: 'Inter', sans-serif;
    color: #e0e0ed;
    display: flex;
    flex-direction: column;
}

/* Glassmorphism utility */
.glass-panel {
    background: rgba(15, 15, 30, 0.6);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Header UI */
.catalogue-header {
    height: 70px;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #b0b0cb;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: all 0.3s ease;
}

.back-btn:hover {
    color: var(--white);
    background: rgba(255, 68, 68, 0.15);
    border-color: rgba(255, 68, 68, 0.3);
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.2);
}

.catalogue-logo {
    height: 42px;
    width: auto;
}

.catalogue-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--white);
    letter-spacing: 0.5px;
    text-shadow: 0 0 10px rgba(0, 102, 255, 0.2);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Main Viewport */
.catalogue-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 1.5rem;
    overflow: hidden;
}

/* 3D Book Layout */
.book-viewport {
    perspective: 2200px;
    width: var(--book-width);
    height: var(--book-height);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s ease; /* For Zoom */
    transform-origin: center center;
}

.book {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
    box-shadow: var(--shadow-premium);
    border-radius: 8px;
    background: #111122; /* Book interior block background */
}

/* Center book alignment when closed vs open */
.book.cover-view-left {
    transform: translateX(25%);
}

.book.cover-view-right {
    transform: translateX(-25%);
}

/* Page Container */
.page {
    background-color: var(--white);
    box-shadow: inset 0 0 30px rgba(0,0,0,0.05), 0 0 10px rgba(0,0,0,0.1);
    overflow: hidden;
    display: none; /* Hide during loading before page-flip wraps them */
}

/* Page content wrapper */
.page-content {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f7f9fa;
}

.page-content canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: white;
}

/* Hard Cover Styles */
.page[data-density="hard"] {
    background-color: #0d1e3d !important; /* Dark premium leather-like blue cover */
    color: white;
    border: 3px solid #002366;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.8), 0 10px 30px rgba(0,0,0,0.5);
}

.page[data-density="hard"]::before {
    content: '';
    position: absolute;
    inset: 10px;
    border: 1px solid rgba(255, 215, 0, 0.18); /* Gold framing line */
    border-radius: 4px;
    pointer-events: none;
}

.page[data-density="hard"] .page-content {
    background-color: #0d1e3d !important;
}

/* Loading Placeholder inside pages */
.page-loader {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: #8f8f9e;
}

.page-loader .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 102, 255, 0.1);
    border-top-color: var(--primary-blue-glow);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.page-number-indicator {
    position: absolute;
    bottom: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #999;
    letter-spacing: 1px;
    z-index: 10;
}

/* Float numbers based on odd/even page alignment */
.page:nth-child(odd) .page-number-indicator {
    right: 20px;
}

.page:nth-child(even) .page-number-indicator {
    left: 20px;
}

/* Spine shadow Overlay down the middle */
.book-spine {
    position: absolute;
    top: 0;
    left: 50%;
    width: 24px;
    height: 100%;
    transform: translateX(-50%);
    background: linear-gradient(90deg, 
        rgba(0, 0, 0, 0.25) 0%, 
        rgba(0, 0, 0, 0.05) 25%,
        rgba(0, 0, 0, 0.45) 50%, 
        rgba(0, 0, 0, 0.05) 75%, 
        rgba(0, 0, 0, 0.25) 100%);
    z-index: 99;
    pointer-events: none;
    mix-blend-mode: multiply;
}

/* Control Bar UI */
.catalogue-controls {
    height: 75px;
    width: min(90%, 850px);
    margin-bottom: 1rem;
    border-radius: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    z-index: 100;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.control-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #c0c0d8;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.control-btn:hover {
    color: var(--white);
    background: rgba(0, 102, 255, 0.2);
    border-color: rgba(0, 102, 255, 0.4);
    box-shadow: 0 0 12px rgba(0, 102, 255, 0.3);
    transform: translateY(-2px);
}

.control-btn:active {
    transform: translateY(0);
}

.control-btn.active {
    background: var(--primary-blue-glow);
    border-color: var(--primary-blue-glow);
    color: var(--white);
    box-shadow: 0 0 15px rgba(0, 102, 255, 0.4);
}

.page-navigation {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    padding: 0.3rem 0.8rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.page-input {
    width: 45px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.3);
    color: var(--white);
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
}

.page-input:focus {
    outline: none;
    border-color: var(--primary-blue-glow);
    box-shadow: 0 0 8px rgba(0, 102, 255, 0.3);
}

.page-total {
    font-size: 0.85rem;
    color: #8f8f9e;
    font-weight: 500;
}

/* Quick Page Navigation Slider */
.slider-track-container {
    width: min(90%, 850px);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    background: rgba(15, 15, 30, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.page-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.08);
    height: 6px;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.page-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-blue-glow);
    border: 2px solid white;
    box-shadow: 0 0 10px rgba(0, 102, 255, 0.5);
    transition: transform 0.2s ease;
}

.page-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Floating Loading Screen */
.catalogue-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    gap: 1.5rem;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.catalogue-loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(0, 102, 255, 0.05);
    border-top-color: var(--primary-blue-glow);
    border-bottom-color: var(--primary-red-glow);
    border-radius: 50%;
    animation: spin 1.2s cubic-bezier(0.5, 0.1, 0.4, 0.9) infinite;
}

.loader-text {
    font-size: 1.1rem;
    font-weight: 500;
    letter-spacing: 1px;
    color: var(--white);
    text-shadow: 0 0 10px rgba(0, 102, 255, 0.4);
}

.loader-progress {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.loader-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-blue-glow), var(--primary-red-glow));
    transition: width 0.2s ease;
    box-shadow: 0 0 10px var(--primary-blue-glow);
}

/* Animations */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Zoom state styles */
.catalogue-main.zoomed {
    overflow: auto; /* Enable scrollbars when zoomed in */
}

.catalogue-main.zoomed .book-viewport {
    cursor: zoom-out;
}

/* Mobile & Tablet Responsiveness */
@media (max-width: 992px) {
    :root {
        --book-height: 60vh;
    }
    .catalogue-controls {
        width: 95%;
        padding: 0 1rem;
    }
    .slider-track-container {
        width: 95%;
    }
}

/* Mobile single-page view */
@media (max-width: 768px) {
    :root {
        --book-ratio: 0.7071; /* A4 vertical single page aspect ratio */
        --book-height: 65vh;
    }
    
    .book.cover-view-left, 
    .book.cover-view-right {
        transform: translateX(0); /* Center spine shift disabled on mobile */
    }
    
    .sheet {
        width: 100%;
        left: 0;
        right: auto;
        transform-origin: left center; /* Custom transitions for mobile */
    }
    
    .book-spine {
        display: none; /* Hide center spine in single page view */
    }
    
    /* Modify flipping behaviour in single page view */
    .sheet.flipped {
        transform: rotateY(-180deg) translateX(-100%);
        transform-origin: left center;
        opacity: 0;
        pointer-events: none;
    }
    
    .catalogue-header {
        padding: 0 1rem;
    }
    .catalogue-title {
        font-size: 0.9rem;
    }
    
    /* Simplify control panel for smaller screens */
    .control-btn.zoom-btn,
    .control-btn.autoplay-btn,
    .control-btn.sound-btn {
        display: none; /* Hide advanced tools on small mobiles to save space */
    }
}
