/**
 * Global Base Styles and CSS Variables
 * Core foundation styles for the entire theme
 * Version: 1.0.0 - Modular Global System
 * CSP-Safe: No inline styles, external resources validated
 */

/* ============================================
   CSS CUSTOM PROPERTIES
   ============================================ */

:root {
    /* Gradients */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --surface-gradient: linear-gradient(145deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    --body-bg-gradient: linear-gradient(135deg, #0a0a1f 0%, #1a1a2e 25%, #16213e 50%, #0f3460 75%, #0a0a1f 100%);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-light: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    --shadow-heavy: 0 25px 50px rgba(0, 0, 0, 0.25);
    --shadow-xl: 0 0 80px rgba(59, 130, 246, 0.15);
    
    /* Border Radius */
    --border-radius-lg: 20px;
    --border-radius-md: 16px;
    --border-radius-sm: 8px;
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    
    /* Colors */
    --primary-bg: #0a0a0a;
    --card-bg: #111111;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-gold: #f59e0b;
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --border-color: #1f1f23;
    
    /* Animations */
    --transition-base: 0.3s ease;
    --animation-gradient: 25s;
    --animation-flow: 30s;
    --animation-texture: 40s;
    
    /* Device-specific variables */
    --vh: 1vh;
    --android-vh: 1vh;
    --safe-area-inset-top: env(safe-area-inset-top, 0px);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-inset-left: env(safe-area-inset-left, 0px);
    --safe-area-inset-right: env(safe-area-inset-right, 0px);
    
    /* Container */
    --container-max-width: 1400px;
}

/* Fallback for browsers without custom property support */
@supports not (--css: variables) {
    body {
        background: linear-gradient(135deg, #0a0a1f 0%, #1a1a2e 25%, #16213e 50%, #0f3460 75%, #0a0a1f 100%);
        animation: ultraModernGradient 25s ease infinite;
    }
}

/* ============================================
   GLOBAL RESET
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ============================================
   BODY STYLES
   ============================================ */

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--body-bg-gradient) !important;
    background-size: 600% 600% !important;
    background-attachment: fixed !important;
    min-height: 100vh;
    color: var(--text-primary);
    overflow-x: hidden;
    position: relative;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* SECURITY: Override any injected inline background styles */
body[style*="background"] {
}

/* ============================================
   BACKGROUND OVERLAYS - STATIC ONLY
   ============================================ */

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 15% 85%, rgba(168, 85, 247, 0.12) 0%, transparent 45%),
        radial-gradient(circle at 85% 15%, rgba(236, 72, 153, 0.10) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(34, 197, 94, 0.06) 0%, transparent 65%),
        radial-gradient(circle at 20% 20%, rgba(249, 115, 22, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(59, 130, 246, 0.10) 0%, transparent 55%),
        radial-gradient(circle at 40% 40%, rgba(139, 92, 246, 0.08) 0%, transparent 45%),
        linear-gradient(135deg, transparent 0%, rgba(99, 102, 241, 0.05) 50%, transparent 100%);
    z-index: -1;
    pointer-events: none;
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle at 75% 75%, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
    background-size: 50px 50px;
    z-index: -1;
    pointer-events: none;
    opacity: 0.7;
}

/* ============================================
   KEYFRAME ANIMATIONS - DISABLED
   ============================================ */

/* REMOVED: @keyframes ultraModernGradient - not used anymore */
/* REMOVED: @keyframes modernBackgroundFlow - caused scroll lag */
/* REMOVED: @keyframes textureFloat - caused scroll stutter */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 30px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes statPulse {
    0%, 100% { 
        transform: scale(1);
        opacity: 1;
    }
    50% { 
        transform: scale(1.02);
        opacity: 0.9;
    }
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

p {
    line-height: 1.6;
    color: var(--text-secondary);
}

a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: color var(--transition-base);
}

a:hover {
    color: var(--accent-purple);
}

a:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ============================================
   BUTTON STYLES
   ============================================ */

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    text-align: center;
    transition: all var(--transition-base);
    cursor: pointer;
    border: none;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    backface-visibility: hidden;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn:hover {
    transform: translate3d(0, -2px, 0);
    box-shadow: var(--shadow-lg);
}

.btn:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

.btn:active {
    transform: translate3d(0, 0, 0);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-1 { margin-bottom: var(--spacing-xs); }
.mb-2 { margin-bottom: var(--spacing-sm); }
.mb-3 { margin-bottom: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-lg); }

.mt-1 { margin-top: var(--spacing-xs); }
.mt-2 { margin-top: var(--spacing-sm); }
.mt-3 { margin-top: var(--spacing-md); }
.mt-4 { margin-top: var(--spacing-lg); }

.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 2rem;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

*:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

/* ============================================
   SMOOTH SCROLLING
   ============================================ */

html {
    scroll-behavior: smooth;
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */

.about-page,
.site-main,
#main-content {
    margin: 0 !important;
}

/* UNIVERSAL: All pages get header spacing via padding */
body:not(.home):not(.front-page) .site-main,
body:not(.home):not(.front-page) #main-content,
body:not(.home):not(.front-page) .lens-categories-page,
body:not(.home):not(.front-page) .blog-page,
body:not(.home):not(.front-page) .cameras-page,
body:not(.home):not(.front-page) .archive-main {
    padding-top: 70px !important;
}

/* Front page - hero has its own padding */
.home .site-main,
.home #main-content,
.front-page .site-main,
.front-page #main-content {
    padding-top: 0 !important;
}

/* Other pages - add spacing for fixed header */
body:not(.home):not(.front-page) .site-main,
body:not(.home):not(.front-page) #main-content {
    padding-top: 0; /* Header spacing handled by body padding */
}

.scrolling body::before,
.scrolling body::after {
    /* Pause animations during scroll */
    animation-play-state: paused;
}

/* ============================================
   REDUCED MOTION SUPPORT
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    body,
    body::before,
    body::after {
        animation: none !important;
    }
    
    .btn:hover {
        transform: none;
    }
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */

@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
    
    *:focus-visible {
        outline-width: 3px;
    }
}

/* ============================================
   DARK MODE SUPPORT
   ============================================ */

@media (prefers-color-scheme: dark) {
    :root {
        --body-bg-gradient: linear-gradient(135deg, #050510 0%, #0a0a1e 25%, #0c1230 50%, #082350 75%, #050510 100%);
    }
}

/* ============================================
   MOBILE OPTIMIZATIONS
   ============================================ */

@media (max-width: 1024px) {
    body::before,
    body::after {
        animation-duration: 60s !important;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    body::before,
    body::after {
        display: none !important;
    }
    
    body {
        background: #ffffff !important;
        color: #000000 !important;
        animation: none !important;
    }
    
    .btn {
        border: 1px solid #000000 !important;
        background: #ffffff !important;
        color: #000000 !important;
    }
    
    a {
        color: #0000ff !important;
        text-decoration: underline;
    }
    
    h1, h2, h3, h4, h5, h6 {
        color: #000000 !important;
    }
    
    p {
        color: #000000 !important;
    }
}
