/**
 * LuminaNote Studio - Luxury 3D Photorealistic Interactive Book Viewer CSS
 */

.flipbook-modal {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, #111827 0%, #030712 100%);
    backdrop-filter: blur(28px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.flipbook-modal.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* Header */
.flipbook-header {
    height: 60px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 20;
}

/* 3D Stage */
.flipbook-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1800px;
    overflow: hidden;
    position: relative;
    padding: 30px;
}

/* Ambient Studio Floor Reflection & Shadow */
.flipbook-stage::before {
    content: '';
    position: absolute;
    bottom: 40px;
    width: 800px;
    height: 120px;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 70%);
    pointer-events: none;
    z-index: 1;
    filter: blur(12px);
}

/* 3D Book Container */
.book-3d-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-style: preserve-3d;
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 5;
}

/* Normal 2D Flat Mode: Vertical PDF-Style Continuous Scroll Flow */
.flipbook-stage.mode-flat {
    overflow-y: hidden !important;
    overflow-x: hidden !important;
    perspective: none !important;
    padding: 0 !important;
    align-items: stretch;
    justify-content: center;
}

.flipbook-pdf-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    width: 100%;
    max-width: 1100px;
    height: calc(100vh - 100px);
    max-height: calc(100vh - 100px);
    overflow-y: auto !important;
    overflow-x: hidden;
    padding: 24px 20px 80px 20px;
    margin: 0 auto;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(59, 130, 246, 0.6) rgba(15, 23, 42, 0.8);
    z-index: 10;
}

.pdf-page-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 650px;
    transition: max-width 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.pdf-page-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    font-size: 11px;
    color: #94A3B8;
    font-family: monospace;
}

.pdf-page-canvas-wrapper {
    width: 100%;
    aspect-ratio: 1 / 1.414;
    background: #FFFFFF;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.1);
    position: relative;
}

.pdf-page-canvas-wrapper canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* All Pages Grid Gallery Mode */
.flipbook-gallery-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    width: 100%;
    max-width: 1440px;
    height: calc(100vh - 110px);
    max-height: calc(100vh - 110px);
    overflow-y: auto !important;
    scroll-behavior: smooth;
    padding: 24px;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    backdrop-filter: blur(20px);
    z-index: 10;
    scrollbar-width: thin;
    scrollbar-color: rgba(59, 130, 246, 0.5) rgba(15, 23, 42, 0.8);
}

.gallery-page-card {
    background: #0F172A;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.gallery-page-card:hover {
    border-color: #3B82F6;
    transform: translateY(-4px);
    box-shadow: 0 12px 28px -6px rgba(0, 0, 0, 0.8), 0 0 16px rgba(59, 130, 246, 0.3);
}

.gallery-page-card.is-current {
    border-color: #3B82F6;
    box-shadow: 0 0 0 2px #3B82F6;
}

.gallery-canvas-wrapper {
    width: 100%;
    aspect-ratio: 1 / 1.414;
    background: #FFFFFF;
    overflow: hidden;
    position: relative;
}

.gallery-canvas-wrapper canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.gallery-card-footer {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: #94A3B8;
    background: rgba(15, 23, 42, 0.9);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Open Book Spread */
.book-spread-container {
    position: relative;
    display: flex;
    transform-style: preserve-3d;
    box-shadow: 0 35px 80px -15px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    background: #0F172A;
}

/* Page Spreads */
.page-spread-left,
.page-spread-right {
    width: 400px;
    height: 566px;
    background: #FFFFFF;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.04);
}

.page-spread-left {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
    box-shadow: inset -15px 0 20px -10px rgba(0, 0, 0, 0.15);
}

.page-spread-right {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    box-shadow: inset 15px 0 20px -10px rgba(0, 0, 0, 0.15);
}

/* Single Page Mode (Cover / Back Cover Presentation) */
.book-single-container {
    width: 400px;
    height: 566px;
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 
        0 40px 90px -15px rgba(0, 0, 0, 0.95), 
        -12px 10px 25px rgba(0, 0, 0, 0.6), 
        0 0 0 1px rgba(255, 255, 255, 0.15);
    transform: rotateY(-8deg) rotateX(4deg);
    transition: transform 0.3s ease;
}

.book-single-container:hover {
    transform: rotateY(0deg) rotateX(0deg) scale(1.02);
}

/* Center Spine Gutter & Lighting */
.spine-gutter-shadow {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 32px;
    transform: translateX(-50%);
    background: linear-gradient(to right, 
        rgba(0, 0, 0, 0.3) 0%, 
        rgba(0, 0, 0, 0.6) 45%, 
        rgba(0, 0, 0, 0.7) 50%, 
        rgba(0, 0, 0, 0.6) 55%, 
        rgba(0, 0, 0, 0.3) 100%);
    pointer-events: none;
    z-index: 10;
}

/* Spiral Wire-O Binding Visualizer */
.spiral-binding-wire {
    position: absolute;
    top: 15px;
    bottom: 15px;
    left: 50%;
    width: 24px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
    z-index: 15;
}

.spiral-ring {
    width: 24px;
    height: 10px;
    background: linear-gradient(135deg, #F1F5F9 0%, #94A3B8 50%, #475569 100%);
    border-radius: 5px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

/* Spread Canvas */
.spread-canvas {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

/* Bottom Controls */
.flipbook-controls-bar {
    height: 72px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 20;
}

.flip-nav-btn {
    padding: 9px 18px;
    border-radius: 12px;
    background: #1E293B;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #F8FAFC;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.flip-nav-btn:hover:not(:disabled) {
    background: #2563EB;
    border-color: #60A5FA;
    color: #FFFFFF;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

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

/* Scrubber Slider */
.spread-scrubber {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 320px;
}

.spread-scrubber input[type="range"] {
    flex: 1;
    accent-color: #3B82F6;
    cursor: pointer;
}
