/* * FluxPlayer Pro - Ultimate Stylesheet (Final Fixed Edition)
 * Features: 10+ Persian Fonts, Stable Subtitles, Fixed Play Animation
 */

/* --- 1. Fonts --- */
/* Switched to system fonts to stay fully offline (no Google Fonts). */

/* --- 2. Global Variables --- */
:root {
    /* Dynamic Settings (Updated by JS) */
    --caption-size: 20px;
    --caption-color: #ffffff;
    --caption-bg: rgba(0, 0, 0, 0.75); /* Darker background for readability */
    --caption-font: 'Segoe UI', 'Helvetica Neue', system-ui, sans-serif; /* Default */
    
    /* Brand Colors */
    --brand-primary: #3b82f6;
    --brand-secondary: #8b5cf6;
    --bg-dark: #020617;
    
    /* Effects */
    --glass-bg: rgba(15, 23, 42, 0.95);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
}

/* --- 3. Base Resets --- */
body {
    font-family: 'Segoe UI', 'Helvetica Neue', system-ui, sans-serif;
    background-color: var(--bg-dark);
    color: #e2e8f0;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* --- 4. Plyr Video Player Overrides --- */

.plyr {
    border-radius: 16px;
    font-family: var(--caption-font);
    height: 100%;
    box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.7);
    overflow: hidden;
    transform: translateZ(0); 
}

/* * ★ SUBTITLE RENDERING FIX (STABLE VERSION) ★ 
 * Uses inline-block to keep subtitles in one cohesive box with proper spacing.
 */
.plyr__captions {
    width: 100% !important;
    max-width: 90% !important; /* Prevent sticking to edges */
    left: 50% !important;
    transform: translateX(-50%) !important;
    margin-bottom: 40px; /* Lift from bottom */
    text-align: center;
    pointer-events: none; /* Let clicks pass through to video */
}

.plyr__caption {
    /* Typography */
    font-size: var(--caption-size) !important;
    color: var(--caption-color) !important;
    font-family: var(--caption-font) !important;
    font-weight: 500 !important;
    text-shadow: 0 2px 4px rgba(0,0,0,0.9);
    
    /* Background & Layout */
    background: var(--caption-bg) !important;
    padding: 8px 16px !important; /* Generous padding */
    border-radius: 8px !important;
    
    /* Critical Fixes for Line Overlap */
    line-height: 1.8 !important; 
    display: inline-block !important; /* Keeps text in one block */
    white-space: pre-wrap !important;
    
    /* Reset decoration break to standard to avoid glitching */
    box-decoration-break: slice !important; 
    -webkit-box-decoration-break: slice !important;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .plyr__caption {
        font-size: calc(var(--caption-size) * 0.85) !important;
        padding: 6px 12px !important;
        line-height: 1.6 !important;
    }
    .plyr__captions {
        margin-bottom: 20px;
        max-width: 95% !important;
    }
}

/* Native Track Fallback */
video::cue {
    background: var(--caption-bg);
    color: var(--caption-color);
    font-family: var(--caption-font);
}

/* --- 5. Plyr Controls & Animations --- */

/* Range Inputs Color */
.plyr--full-ui input[type=range] {
    color: var(--brand-primary) !important;
}

/* ★ PLAY BUTTON ZOOM FIX ★ */
.plyr__control--overlaid {
    background: rgba(59, 130, 246, 0.85) !important;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.1);
    /* Transition for smooth animation */
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.3s !important;
}

.plyr__control--overlaid:hover {
    background: var(--brand-primary) !important;
    /* Important: Preserve the center alignment (-50%, -50%) during scale */
    transform: translate(-50%, -50%) scale(1.15) !important; 
    box-shadow: 0 0 40px rgba(59, 130, 246, 0.5);
}

/* Settings Menu */
.plyr__menu__container {
    background: rgba(15, 23, 42, 0.95) !important;
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px !important;
    color: #f1f5f9;
}
.plyr__menu__container .plyr__control:hover {
    background: rgba(59, 130, 246, 0.15);
    color: var(--brand-primary);
}

/* --- 6. General UI Components --- */

/* Font Grid in Settings */
.font-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.font-btn {
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(30, 41, 59, 0.5);
    color: #cbd5e1;
    font-size: 0.9rem;
    transition: all 0.2s;
    text-align: center;
}

.font-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
}

.font-btn.active {
    background: var(--brand-primary);
    color: white;
    border-color: var(--brand-primary);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Lightweight texture to replace remote patterns */
.texture-overlay {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 120'%3E%3Cdefs%3E%3CradialGradient id='g' cx='20%25' cy='20%25' r='80%25'%3E%3Cstop offset='0%25' stop-color='%23ffffff' stop-opacity='0.05'/%3E%3Cstop offset='100%25' stop-color='%23000000' stop-opacity='0'/%3E%3C/radialGradient%3E%3C/defs%3E%3Crect width='120' height='120' fill='url(%23g)'/%3E%3C/svg%3E");
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #3b82f6; }

/* Drop Zone Styles */
.drop-zone {
    background-image: url("data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' rx='16' ry='16' stroke='%23334155' stroke-width='2' stroke-dasharray='12%2c 12' stroke-dashoffset='0' stroke-linecap='square'/%3e%3c/svg%3e");
    transition: all 0.3s ease;
}
.drop-zone:hover { transform: translateY(-3px); background-color: rgba(30, 41, 59, 0.3); }
.drop-zone.active { background-color: rgba(59, 130, 246, 0.08); transform: scale(1.01); }

/* Fade Animation */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.subtitle-item { animation: fadeIn 0.3s ease-out; }

/* Range Slider */
input[type=range] {
    -webkit-appearance: none;
    background: transparent;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 18px; width: 18px;
    border-radius: 50%;
    background: var(--brand-primary);
    cursor: pointer;
    margin-top: -7px;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    transition: all 0.2s;
}
input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: #fff;
    box-shadow: 0 0 10px var(--brand-primary);
}
input[type=range]::-webkit-slider-runnable-track {
    width: 100%; height: 4px; cursor: pointer;
    background: #334155; border-radius: 2px;
}

/* Splash Screen */
#splash-screen {
    background: radial-gradient(circle at center, #1e293b 0%, #020617 100%);
}
.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.8s;
}

/* Glassmorphism Helper */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: var(--glass-border);
}