/* assets/style.css */
body { margin: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f8f9fa; color: #333; }
.header { background-color: #1a252f; color: white; padding: 15px 40px; display: flex; align-items: center; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.logo { font-size: 24px; font-weight: bold; letter-spacing: 1px;}
.library-section { padding: 40px; max-width: 1200px; margin: 0 auto; }
.library-header { text-align: center; margin-bottom: 40px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 30px; }
.card { background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.05); cursor: pointer; transition: transform 0.3s; }
.card:hover { transform: translateY(-5px); box-shadow: 0 8px 25px rgba(0,0,0,0.1); }
.card-image { height: 250px; position: relative; background-color: #e9ecef; }
.card h3 { text-align: center; padding: 15px; margin: 0; font-size: 16px; color: #2c3e50; border-top: 1px solid #eee; }
.lock-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.6); display: flex; flex-direction: column; justify-content: center; align-items: center; color: white; opacity: 0.8; transition: 0.3s; }
.card:hover .lock-overlay { opacity: 1; background: rgba(0,0,0,0.8); }
.lock-icon { font-size: 40px; margin-bottom: 10px; }
.lock-text { font-weight: bold; letter-spacing: 1px; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 1000; justify-content: center; align-items: center; }
.modal-content { background: white; padding: 40px; border-radius: 8px; width: 100%; max-width: 450px; position: relative; }
.close-btn { position: absolute; top: 15px; right: 15px; font-size: 24px; background: none; border: none; cursor: pointer; color: #7f8c8d; }
.form-group { margin-bottom: 15px; text-align: left; }
.form-group input { width: 100%; padding: 12px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }
.consent-group { display: flex; align-items: flex-start; gap: 10px; margin-bottom:15px; }
.consent-group label { font-size: 12px; color: #555; }
.submit-btn { width: 100%; background: #e3000f; color: white; border: none; padding: 12px; border-radius: 4px; font-size: 16px; font-weight: bold; cursor: pointer; }
.submit-btn:hover { background: #cc000d; }

/* Viewer */
.viewer-section { height: 100vh; background-color: #2c3e50; display: flex; flex-direction: column; }
.viewer-header { padding: 15px 40px; display: flex; justify-content: space-between; align-items: center; background: #1a252f; color: white; }
.btn-back { color: white; text-decoration: none; padding: 8px 15px; border: 1px solid white; border-radius: 4px;}
.btn-back:hover { background: rgba(255,255,255,0.1); }
.container { flex: 1; display: flex; justify-content: center; align-items: center; position: relative; }
.flip-book { display: none; box-shadow: 0 0 30px rgba(0,0,0,0.6); background: white;}
canvas { width: 100%; height: 100%; object-fit: contain; }

/* 3D Flipbook Responsive Viewport & Immersive Full-Size Reading Scale */
#viewer-section {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    flex-direction: column !important;
    z-index: 99999 !important;
    overflow: hidden !important;
    background-color: #0b101e !important;
}

#viewer-section:not(.active) {
    display: none !important;
}

#viewer-section.active {
    display: flex !important;
}

#viewer-section .flex-grow {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: calc(100vh - 65px) !important;
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
    padding: 10px 20px !important;
    box-sizing: border-box !important;
    position: relative !important;
}

#flipbook-wrapper {
    width: 100% !important;
    max-width: 1800px !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 auto !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    position: relative !important;
}

#flipbook-zoom-container {
    transform-origin: 0 0;
    transition: transform 0.16s cubic-bezier(0.25, 1, 0.5, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    will-change: transform;
    user-select: none;
    -webkit-user-select: none;
}

#flipbook-zoom-container.is-zoomed {
    cursor: grab;
}

#flipbook-zoom-container.is-zoomed.is-dragging {
    cursor: grabbing;
}

#flipbook-zoom-container.is-animating {
    transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
}

/* ==============================================================================
   ANIMATED GESTURE ONBOARDING TOAST (PINCH & TAP AFFORDANCE)
   ============================================================================== */
.gesture-hint-toast {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(11, 16, 30, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.6), 0 0 1px 1px rgba(255, 255, 255, 0.1);
    padding: 10px 18px;
    border-radius: 9999px;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.gesture-hint-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.gesture-hint-toast.hide {
    opacity: 0;
    transform: translateX(-50%) translateY(15px);
}

.gesture-hint-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(227, 38, 54, 0.15);
    border: 1px solid rgba(227, 38, 54, 0.35);
    border-radius: 50%;
    color: #e32636;
    flex-shrink: 0;
}

.gesture-hint-icon svg {
    width: 20px;
    height: 20px;
}

/* Keyframe animations for pinch dots */
.pinch-dot-left, .pinch-dot-right {
    animation: pinchExpand 1.6s ease-in-out infinite;
    transform-origin: center;
}

.pinch-dot-right {
    animation-delay: 0.15s;
}

@keyframes pinchExpand {
    0%, 100% {
        transform: scale(0.9);
        opacity: 0.7;
    }
    50% {
        transform: scale(1.3);
        opacity: 1;
    }
}

.gesture-hint-content {
    display: flex;
    flex-direction: column;
}

.gesture-hint-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #ffffff;
    line-height: 1.2;
}

.gesture-hint-subtitle {
    font-size: 10px;
    font-weight: 500;
    color: #94a3b8;
    line-height: 1.2;
}

/* 3D Flipbook Core Container & Canvas Centering (StPageFlip Engine) */
.stf__wrapper {
    margin: auto !important;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.9), 0 0 50px rgba(0,0,0,0.4) !important;
    border-radius: 4px;
}

.stf__block {
    margin: auto !important;
}

.stf__item {
    background-color: #ffffff;
}

.page {
    background-color: #ffffff !important;
    overflow: hidden !important;
    box-shadow: inset 0 0 25px rgba(0,0,0,0.06) !important;
}

.page canvas {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
}

/* Skeleton Placeholder Page Styling (Pages 6+) */
.page.is-skeleton {
    background: #f8fafc !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px;
}

.page-skeleton-placeholder {
    width: 82%;
    height: 85%;
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite ease-in-out;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px dashed #cbd5e1;
}

@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-badge {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
    background: rgba(255, 255, 255, 0.85);
    padding: 6px 14px;
    border-radius: 9999px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Micro Loader Floating Pill */
.micro-loader-pill {
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.micro-loader-pill.is-ready {
    background: rgba(16, 185, 129, 0.18) !important;
    border-color: rgba(16, 185, 129, 0.45) !important;
}

.micro-loader-pill.is-hidden {
    opacity: 0 !important;
    transform: translateX(-50%) translateY(-15px) !important;
    pointer-events: none !important;
}

/* Top Streaming Progress Line */
#top-streaming-bar {
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(227, 38, 54, 0.7);
}

/* 3D Flipbook Spine & Edge Realistic Lighting */
.stf__item.--left {
    box-shadow: inset -8px 0 20px rgba(0, 0, 0, 0.08) !important;
}

.stf__item.--right {
    box-shadow: inset 8px 0 20px rgba(0, 0, 0, 0.08) !important;
}

/* ==============================================================================
   SUB-5MS INSTANT STAGE & COVER SHELL PIPELINE
   ============================================================================== */
.viewer-instant-shell {
    position: absolute;
    z-index: 25;
    pointer-events: none;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8), 0 0 40px rgba(0, 0, 0, 0.5);
    background: #111625;
    overflow: hidden;
    will-change: opacity, transform;
    animation: instantStageFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

@keyframes instantStageFadeIn {
    from {
        opacity: 0.3;
        transform: scale(0.97);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.instant-stage-cover-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #0f1423;
}

.instant-stage-cover-texture {
    max-width: 100%;
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 15px 30px rgba(0, 0, 0, 0.6));
    border-radius: 4px;
}

.instant-stage-shimmer-sweep {
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.12) 50%, transparent 65%);
    background-size: 200% 100%;
    animation: stageSweep 1.8s infinite linear;
    pointer-events: none;
}

@keyframes stageSweep {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.instant-stage-spine-shadow {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 18px;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.4), transparent);
    pointer-events: none;
}

/* Side Drawer Stylings */
.drawer-open {
    transform: translateX(0) !important;
}

.backdrop-open {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.drawer-cat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.drawer-cat-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(227, 38, 54, 0.5);
    transform: translateX(-2px);
}

.drawer-cat-card.is-active {
    background: rgba(227, 38, 54, 0.12);
    border-color: rgba(227, 38, 54, 0.6);
}

.drawer-cat-thumb {
    width: 48px;
    height: 64px;
    object-fit: cover;
    border-radius: 6px;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.drawer-cat-info {
    flex: 1;
    min-width: 0;
}

.drawer-cat-title {
    font-size: 13px;
    font-weight: 700;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0 0 4px 0;
}

.drawer-cat-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 9999px;
    display: inline-block;
}

.drawer-cat-badge.active-badge {
    background: #E32636;
    color: #ffffff;
}

.drawer-cat-badge.switch-badge {
    background: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
}

.drawer-cat-card:hover .drawer-cat-badge.switch-badge {
    background: rgba(227, 38, 54, 0.2);
    color: #ff6b7a;
}

