/**
 * Das Gesellschaftsspiel - Graphic Novel Viewer
 * Main Stylesheet
 * 
 * This stylesheet controls the visual presentation of a multi-layer
 * parallax graphic novel with keyboard navigation.
 */

/* ==========================================================================
   Reset & Base Styles
   ========================================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #000;
    overflow: hidden;
    /* Prevent scrolling - single page view */
    font-family: system-ui, sans-serif;
}

/* ==========================================================================
   Frame Container
   Each frame represents one "page" of the graphic novel
   ========================================================================== */

.frame {
    position: fixed;
    inset: 0;
    /* Full viewport coverage */
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
}

.frame.active {
    display: flex;
    /* Only active frame is visible */
}

.frame-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    /* Clip any texture overflow */
}

/* 
 * Invisible overlay removed to allow interaction
 */

/* ==========================================================================
   Image Layers
   Multiple images stacked with parallax effect on mouse movement
   ========================================================================== */

.layer {
    position: absolute;
    top: 50%;
    left: 50%;

    /* 
     * Center the image and apply 1.2x scale to prevent 
     * edge visibility during parallax movement
     */
    transform: translate(-50%, -50%) scale(1.2);

    /* Responsive sizing while maintaining aspect ratio */
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;

    /* Performance optimization for parallax transforms */
    will-change: transform;

    /* Smooth ease-out transition for parallax movement */
    transition: transform 0.15s cubic-bezier(0.25, 0.1, 0.25, 1);

    /* Download deterrent - prevent user interaction with images */
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
}

/* ==========================================================================
   Paper Texture Overlay
   Animated video texture applied over all frames, clipped to image bounds
   ========================================================================== */

/* 
 * Texture overlay - uses IDENTICAL sizing/positioning as .layer
 * This ensures the texture exactly matches the image bounds
 */
.texture-overlay {
    position: absolute;
    top: 50%;
    left: 50%;

    /* Centered with 1.2x scale to match .layer parallax scaling */
    transform: translate(-50%, -50%) scale(1.2);

    /* IDENTICAL sizing constraints as .layer */
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;

    z-index: 999;
    pointer-events: none;

    /* 
     * Original blend mode - multiply makes white areas transparent
     * and tints the underlying artwork
     */
    mix-blend-mode: overlay;
    opacity: 0.2;
}

/* ==========================================================================
   UI Elements
   Navigation hints and page indicators
   ========================================================================== */

.nav-hint {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    pointer-events: none;
    /* Don't interfere with page interaction */
    z-index: 100;
}

/* Volume Control - Minimal horizontal slider top-left */
.volume-control {
    position: fixed;
    left: 20px;
    top: 20px;
    height: 40px;
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Control icons (volume & filter) */
.control-icon {
    width: 20px;
    height: 20px;
    color: rgba(255, 255, 255, 0.7);
    flex-shrink: 0;
}

/* Volume waves - hidden by default, shown based on volume level */
.control-icon .wave {
    opacity: 0;
    transition: opacity 0.15s ease;
}

.control-icon.vol-low .wave-1 {
    opacity: 1;
}

.control-icon.vol-med .wave-1,
.control-icon.vol-med .wave-2 {
    opacity: 1;
}

.control-icon.vol-high .wave-1,
.control-icon.vol-high .wave-2,
.control-icon.vol-high .wave-3 {
    opacity: 1;
}

/* Custom styling for the range input to look like a volume bar */
.volume-control input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 120px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    border-radius: 2px;
    cursor: pointer;
}

.volume-control input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    transition: transform 0.1s;
}

.volume-control input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Hi-Cut Filter Control - Below volume slider */
.filter-control {
    position: fixed;
    left: 20px;
    top: 60px;
    height: 40px;
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-control input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 120px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    border-radius: 2px;
    cursor: pointer;
}

.filter-control input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    transition: transform 0.1s;
}

.filter-control input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* 
 * Audio Unlock Overlay
 * Full-screen transparent overlay to capture first click
 */
.audio-unlock-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.3);
    /* Subtle dimming */
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.audio-unlock-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.unlock-message {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-size: 24px;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.9);
    text-transform: uppercase;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    pointer-events: none;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

.volume-control input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.page-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    z-index: 100;
}

/* ==========================================================================
   Split Layout & Slider (Added for 7-Page Restructure)
   ========================================================================== */

/* 
 * Split Layer Container
 * Allows two frames to coexist on one page.
 * They are stacked absolutely, but clipped via clip-path.
 */
.split-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* 
 * Slider Handle
 * Center line with a "Volume Logic" style handle
 */
.split-slider {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    /* Interaction area */
    height: 100%;
    /* Full vertical height */
    cursor: col-resize;
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* The visual line of the slider */
.split-slider::before {
    content: '';
    position: absolute;
    width: 1px;
    /* Half thickness */
    height: 100%;
    background: rgba(255, 255, 255, 0.5);
    /* 50% more opacity */
}

/* The thumb/handle of the slider */
.split-slider::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 30px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    transition: transform 0.1s;
}

/* ==========================================================================
   Text Overlay Styles
   ========================================================================== */

/* Toggle Button */
.icon-btn {
    position: fixed;
    left: 20px;
    top: 50%;
    /* Vertically centered */
    transform: translateY(-50%);
    background: transparent;
    border: none;
    outline: none;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    z-index: 1002;
    padding: 0;
    margin: 0;
    transition: color 0.3s, transform 0.2s;
}

.icon-btn:hover,
.icon-btn.active {
    color: #fff;
    transform: translateY(-50%) scale(1.1);
}

.icon-btn svg {
    display: block;
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.5));
}

/* Overlay Container */
.text-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: visible;
    /* Instant visibility when showing */
    transition: visibility 0s 0s;
}

.text-overlay.hidden {
    visibility: hidden;
    pointer-events: none;
    /* Delay visibility change until fade-out completes (0.3s) */
    transition: visibility 0s 0.3s;
}

.text-overlay.hidden .text-content {
    opacity: 0;
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    transform: scale(0.98);
}

/* Actual Text Content Box */
.text-content {
    /* Animate opacity, transform, AND backdrop-filter together */
    transition:
        opacity 0.3s ease,
        transform 0.3s ease,
        backdrop-filter 0.3s ease,
        -webkit-backdrop-filter 0.3s ease;

    opacity: 1;
    transform: scale(1);

    pointer-events: auto;
    width: 40%;
    max-width: 600px;
    overflow-y: auto;

    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);

    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);

    /* Typography */
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    /* Clean reader style */
    color: #fff;
    line-height: 1.6;
    text-align: left;

    /* Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.8) transparent;
}

.text-content::-webkit-scrollbar {
    width: 8px;
    /* Increased to allow 'padding' via border */
}

.text-content::-webkit-scrollbar-track {
    background: transparent;
}

.text-content::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    border: 2px solid transparent;
    /* Creates the gap */
    background-clip: content-box;
    /* Ensures background only paints in the inner 4px */
}

.text-content h2 {
    font-weight: 300;
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 10px;
}

.text-content p,
.text-content div {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.85);
}

.split-slider:hover::after,
.frame.dragging .split-slider::after {
    transform: scale(1.2);
}

/* While dragging, force cursor on entire page */
.frame.dragging {
    cursor: col-resize;
}