/**
 * Secure PDF Flipbook Reader — Core CSS Design System
 * 
 * Implements a premium, modern digital library style.
 * Key techniques used: CSS Grid, custom properties, SVG paper noise filters,
 * glassmorphism, hardware-accelerated transforms, and radial dark-room lighting.
 */

/* 1. Design Variables & Global Styling */
:root {
    --bg-main: radial-gradient(circle at center, #1e293b 0%, #0f172a 60%, #020617 100%);
    --bg-header: rgba(15, 23, 42, 0.75);
    --bg-control: rgba(15, 23, 42, 0.7);
    --border-color: rgba(217, 119, 6, 0.25); /* Accent Amber/Gold border */
    
    --accent-color: #d97706; /* Amber-600 */
    --accent-hover: #f59e0b; /* Amber-500 */
    --text-primary: #f8fafc; /* Slate-50 */
    --text-secondary: #94a3b8; /* Slate-400 */
    --text-dark: #0f172a;
    
    --card-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    --page-shadow-left: -5px 5px 15px rgba(0, 0, 0, 0.25);
    --page-shadow-right: 5px 5px 15px rgba(0, 0, 0, 0.25);
    --spine-shadow: linear-gradient(to right, 
        rgba(0, 0, 0, 0.35) 0%, 
        rgba(0, 0, 0, 0.1) 40%, 
        rgba(0, 0, 0, 0) 50%, 
        rgba(0, 0, 0, 0.1) 60%, 
        rgba(0, 0, 0, 0.35) 100%
    );

    --font-heading: 'Outfit', 'Inter', sans-serif;
    --font-body: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-user-select: none; /* Block selecting on everything by default */
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

body {
    font-family: var(--font-body);
    background: var(--bg-main);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography styles */
h1, h2, h3, select, button {
    font-family: var(--font-heading);
}

/* 2. Page Header Layout */
.app-header {
    background-color: var(--bg-header);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-badge {
    background: linear-gradient(135deg, var(--accent-color) 0%, #b45309 100%);
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--text-primary);
    box-shadow: 0 0 10px rgba(217, 119, 6, 0.4);
}

.logo-text h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(to right, #ffffff, #e2e8f0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text p {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

.select-wrapper {
    position: relative;
}

.select-wrapper select {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 2.25rem 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    transition: all 0.25s ease;
    appearance: none;
}

.select-wrapper select:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
}

.select-wrapper::after {
    content: "▼";
    font-size: 0.65rem;
    color: var(--accent-color);
    position: absolute;
    right: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

/* 3. Main Book Reading Room */
.reading-room {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    overflow: hidden;
    perspective: 1200px; /* Crucial for 3D page curls */
}

/* Viewport container holding the flipbook structure */
#book-container {
    width: 100%;
    max-width: 1050px;
    height: 100%;
    max-height: 720px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    transition: filter 0.4s ease;
    position: relative;
}

/* The element StPageFlip binds to */
#book {
    box-shadow: var(--card-shadow);
    background-color: #0c0f16;
    border-radius: 8px;
    transform: scale(1.0); /* Modified dynamically by zoom */
    transition: transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    will-change: transform;
}

/* 4. Realistic Page Aesthetics */
.book-page {
    background-color: #faf9f6; /* Premium off-white paper color */
    box-shadow: var(--page-shadow-right);
    overflow: hidden;
    position: relative;
    border-radius: 0 4px 4px 0;
}

/* Different shadow for left pages in StPageFlip */
.book-page.--left {
    box-shadow: var(--page-shadow-left);
    border-radius: 4px 0 0 4px;
}

/* Container inside pages containing canvases */
.page-content {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* Hardware-accelerated canvas pages */
.page-content canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    will-change: transform;
}

/* Hardcover page overlays */
.book-page[data-density="hard"] {
    background: linear-gradient(135deg, #1e1b18 0%, #100e0d 100%) !important; /* Leather textures */
    border-right: 4px solid var(--accent-color);
    box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.1), 
                inset -1px -1px 0 rgba(0, 0, 0, 0.5),
                var(--page-shadow-right);
}

.book-page[data-density="hard"].--left {
    border-right: none;
    border-left: 4px solid var(--accent-color);
    box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.1), 
                inset -1px -1px 0 rgba(0, 0, 0, 0.5),
                var(--page-shadow-left);
}

/* Front Cover Book Title Styling (Simple aesthetic block) */
.book-page[data-page-index="1"] .page-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 2rem;
    color: #f59e0b;
    border: 3px double #d97706;
    margin: 10px;
    height: calc(100% - 20px);
}

/* Paper texture graphic overlay */
.book-page::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    opacity: 0.05; /* Configurable opacity */
    /* Embedded high-density SVG fractal noise texture */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' result='noise'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    z-index: 10;
}

/* Realistic center folding spine shadow overlay */
.page-ambient-shadow {
    position: absolute;
    top: 0;
    width: 60px;
    height: 100%;
    z-index: 8;
    pointer-events: none;
}

/* Spine shadow on left pages faces right */
.book-page.--left .page-ambient-shadow {
    right: 0;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0) 100%);
}

/* Spine shadow on right pages faces left */
.book-page.--right .page-ambient-shadow {
    left: 0;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0) 100%);
}

/* 5. Navigation Control HUD bar */
.control-hud {
    background: var(--bg-control);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 2rem;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1.5rem;
    z-index: 90;
}

.hud-section.left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.hud-section.center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    min-width: 320px;
}

.hud-section.right {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
}

/* Glassmorphism Buttons */
.btn-control {
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    outline: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-control:hover {
    background-color: var(--accent-color);
    border-color: var(--accent-hover);
    color: var(--text-primary);
    box-shadow: 0 0 12px rgba(217, 119, 6, 0.4);
    transform: translateY(-2px);
}

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

/* Navigation Slider Style */
.slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.nav-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    cursor: pointer;
    transition: background 0.3s ease;
}

.nav-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--accent-color);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.nav-slider::-webkit-slider-thumb:hover {
    transform: scale(1.25);
    background-color: var(--accent-hover);
}

.page-counter {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 70px;
    text-align: center;
    letter-spacing: 0.5px;
}

/* Zoom display widget */
.zoom-widget {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 0.25rem 0.25rem 0.25rem 0.75rem;
}

.zoom-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 35px;
    text-align: center;
    font-weight: bold;
}

/* 6. Sidebar Controls Panel */
.sidebar-panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    background-color: #0b0f19;
    border-right: 1px solid var(--border-color);
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 15px 0 30px rgba(0, 0, 0, 0.5);
}

.sidebar-panel.open {
    transform: translateX(0);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 1rem;
    font-weight: bold;
    color: var(--text-primary);
}

.sidebar-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
}

.sidebar-content {
    padding: 1.5rem;
}

.sidebar-section {
    margin-bottom: 2rem;
}

.sidebar-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-color);
    margin-bottom: 0.75rem;
}

.sidebar-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 1rem;
}

/* Security list display */
.security-status-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.security-status-list li {
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.security-status-list li::before {
    content: "🛡️";
    font-size: 0.75rem;
}

/* 7. Security Interruption Overlays & Shields */

/* Blurred shield helper */
.blurred-shield {
    filter: blur(18px) grayscale(40%);
    pointer-events: none !important;
}

.hard-blurred-shield {
    filter: blur(35px) brightness(50%) grayscale(100%);
    pointer-events: none !important;
}

/* Tab blur focus overlay */
.security-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(2, 6, 23, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.overlay-content {
    background-color: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2.5rem;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.overlay-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    animation: pulse 2s infinite;
}

.overlay-content h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 0.75rem;
}

.overlay-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* PrintScreen flash shield */
#printscreen-shield {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #020617;
    z-index: 999;
}

/* Helper utilities */
.hidden {
    display: none !important;
}

.toast-notice {
    position: fixed;
    bottom: 5.5rem;
    left: 50%;
    transform: translate(-50%, 20px);
    background-color: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--accent-color);
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0;
    pointer-events: none;
    z-index: 300;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast-notice.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.toast-text {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* 8. Render Errors */
.render-error {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #faf9f6;
    color: #b91c1c;
    padding: 2rem;
    text-align: center;
}

.error-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.error-msg {
    font-size: 0.85rem;
    font-weight: bold;
}
