/**
 * Lens Categories Section Styling System
 * Professional lens category cards and navigation
 * Version: 1.0.0 - Modular Lens System
 * CSP-Safe: No inline styles, external resources validated
 */

/* ============================================
   CSS CUSTOM PROPERTIES
   ============================================ */

:root {
    --lens-cat-grid-columns: repeat(4, minmax(272px, 323px));
    --lens-cat-gap: 25px;
    --lens-cat-padding: 40px;
    --lens-cat-card-bg: linear-gradient(145deg, rgba(30, 35, 41, 0.95) 0%, rgba(45, 52, 71, 0.9) 50%, rgba(55, 65, 81, 0.85) 100%);
    --lens-cat-border: transparent;
    --lens-cat-border-hover: rgba(99, 102, 241, 0.4);
    --lens-cat-gradient: linear-gradient(45deg, #3b82f6 0%, #8b5cf6 25%, #06d6a0 50%, #f59e0b 75%, #ef4444 100%);
    --lens-cat-title-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6, #06b6d4);
    --lens-cat-section-bg: linear-gradient(135deg, rgba(15, 23, 42, 0.95) 0%, rgba(30, 41, 59, 0.9) 50%, rgba(15, 23, 42, 0.95) 100%);
    --lens-cat-btn-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --lens-cat-btn-hover: linear-gradient(135deg, #2563eb, #7c3aed);
    --lens-cat-text-primary: var(--text-primary, #ffffff);
    --lens-cat-text-secondary: var(--text-secondary, #a1a1aa);
    --lens-cat-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    --lens-cat-shadow-hover: 0 25px 50px rgba(0, 0, 0, 0.4);
    --lens-cat-transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --lens-cat-card-min-height: 400px;
    --lens-cat-border-radius: 24px;
    --lens-cat-icon-size: 5rem;
}

/* Fallback for browsers without custom property support */
@supports not (--css: variables) {
    .lens-categories-grid {
        grid-template-columns: repeat(4, minmax(272px, 323px));
        gap: 25px;
    }
}

/* ============================================
   LENS CATEGORIES SECTION
   ============================================ */

.lens-categories-section {
    margin: 80px auto 0 !important;
    margin-bottom: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    padding: 0 40px 0 40px !important;
}

/* SECURITY: Override any injected inline styles */
.lens-categories-section[style*="margin"],
.lens-categories-section[style*="padding"] {
    animation: none !important;
}

.lens-categories-grid {
    display: grid !important;
    grid-template-columns: var(--lens-cat-grid-columns) !important;
    gap: var(--lens-cat-gap) !important;
    max-width: 1600px !important;
    width: 100% !important;
    margin: 0 auto !important;
    padding: 0 var(--lens-cat-padding) !important;
    box-sizing: border-box !important;
    justify-content: center !important;
}

.lens-categories-section .lens-categories-grid {
    display: grid !important;
    grid-template-columns: var(--lens-cat-grid-columns) !important;
    gap: var(--lens-cat-gap) !important;
    max-width: 1600px !important;
    width: 100% !important;
    margin: 0 auto !important;
    padding: 0 var(--lens-cat-padding) !important;
    box-sizing: border-box !important;
    justify-content: center !important;
}

.lens-categories-header {
    text-align: center;
    margin-bottom: 60px;
    overflow: visible;
    width: 100%;
}

.lens-categories-title {
    font-size: clamp(2rem, 4vw, 2.8rem);
    font-weight: 800;
    background: var(--lens-cat-title-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 20px;
    text-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
    white-space: nowrap;
    overflow: visible;
    width: 100%;
    display: block;
}

.lens-categories-subtitle {
    font-size: clamp(1rem, 2vw, 1.3rem);
    color: var(--lens-cat-text-secondary);
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ============================================
   LENS CATEGORY CARDS
   ============================================ */

.lens-category-card {
    background: var(--lens-cat-card-bg);
    border-radius: var(--lens-cat-border-radius);
    min-height: var(--lens-cat-card-min-height) !important;
    padding: 50px 25px !important;
    margin-bottom: 40px !important;
    text-align: center;
    border: 2px solid var(--lens-cat-border);
    background-clip: padding-box;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--lens-cat-shadow), 0 0 0 1px rgba(99, 102, 241, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
}

.lens-category-card::before {
    content: '';
    position: absolute;
    inset: -2px;
    padding: 2px;
    background: var(--lens-cat-gradient);
    background-size: 200% 200%;
    border-radius: var(--lens-cat-border-radius);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: xor;
    -webkit-mask-composite: xor;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.lens-category-card:hover::before {
    opacity: 1;
}

.lens-category-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
    border-color: rgba(99, 102, 241, 0.4);
}

.lens-category-card:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

.lens-category-icon {
    font-size: var(--lens-cat-icon-size) !important;
    margin-bottom: 25px !important;
    position: relative;
    z-index: 2;
    color: #6366f1 !important;
    text-align: center !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    pointer-events: none;
}

.lens-category-title {
    font-size: 1.4rem !important;
    font-weight: 700;
    color: var(--lens-cat-text-primary);
    margin-bottom: 18px !important;
    position: relative;
    z-index: 2;
}

.lens-category-description {
    font-size: 0.95rem !important;
    color: var(--lens-cat-text-secondary);
    line-height: 1.6;
    margin-bottom: 25px !important;
    position: relative;
    z-index: 2;
    flex-grow: 1 !important;
}

.lens-category-highlight {
    display: inline-block;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(139, 92, 246, 0.2));
    color: #60a5fa;
    padding: 10px 18px !important;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 30px !important;
    border: 1px solid rgba(59, 130, 246, 0.3);
    position: relative;
    z-index: 2;
}

.lens-category-btn {
    background: var(--lens-cat-btn-gradient);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    z-index: 2;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    margin: 0 auto !important;
    display: block !important;
    width: fit-content !important;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.lens-category-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
    background: var(--lens-cat-btn-hover);
}

.lens-category-btn:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fadeInLensGrid {
    to { opacity: 1; }
}

/* =================================== */
/*         LENS SECTION STYLES        */
/* =================================== */

.lens-section {
    background: linear-gradient(135deg, 
        rgba(15, 23, 42, 0.95) 0%,
        rgba(30, 41, 59, 0.9) 50%,
        rgba(15, 23, 42, 0.95) 100%
    );
    border-radius: 24px;
    padding: 50px 40px;
    margin: 60px 0;
    border: 1px solid rgba(99, 102, 241, 0.3);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(20px);
}

.lens-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #a855f7, #ec4899, #6366f1);
    background-size: 200% 100%;
    animation: lensGlow 3s ease-in-out infinite;
}

@keyframes lensGlow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.lens-section-header {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
}

.lens-section-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 20px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    color: #a855f7;
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 25px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 auto 20px auto;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    width: fit-content;
    max-width: 200px;
    white-space: nowrap;
}

.lens-section-badge:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 20px rgba(168, 85, 247, 0.3);
    border-color: rgba(168, 85, 247, 0.5);
}

.lens-section-title {
    font-size: 2.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 25%, #a855f7 50%, #ec4899 75%, #6366f1 100%);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: lensTextShine 4s ease-in-out infinite;
    margin-bottom: 20px;
    text-shadow: none;
}

@keyframes lensTextShine {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.lens-section-subtitle {
    font-size: 1.1rem;
    color: #e2e8f0;
    line-height: 1.6;
    max-width: 700px;
    margin: 0 auto 30px auto;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.lens-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
    max-width: 1400px;
    margin: 0 auto;
}

.lens-card {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.9), rgba(45, 55, 72, 0.8));
    border-radius: 20px;
    border: 1px solid rgba(99, 102, 241, 0.3);
    padding: 30px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.lens-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #a855f7);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lens-card:hover {
    transform: translateY(-8px);
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 20px 60px rgba(99, 102, 241, 0.3);
    background: linear-gradient(145deg, rgba(40, 50, 70, 0.9), rgba(55, 65, 85, 0.8));
}

.lens-card:hover::before {
    opacity: 1;
}

.lens-card-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}

.lens-card-icon {
    font-size: 2rem;
    margin-right: 15px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 2px 4px rgba(99, 102, 241, 0.3));
}

.lens-card-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #f1f5f9;
    margin: 0;
    line-height: 1.3;
}

.lens-card-description {
    color: #cbd5e1;
    line-height: 1.6;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.lens-specs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    padding: 20px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 12px;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.lens-spec {
    text-align: center;
}

.lens-spec-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #a855f7;
    margin-bottom: 4px;
    text-shadow: 0 2px 4px rgba(168, 85, 247, 0.3);
}

.lens-spec-label {
    font-size: 0.8rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.lens-features {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.lens-feature-tag {
    padding: 6px 12px;
    background: rgba(99, 102, 241, 0.1);
    color: #c4b5fd;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid rgba(99, 102, 241, 0.2);
    transition: all 0.3s ease;
}

.lens-feature-tag:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.lens-actions {
    display: flex;
    gap: 12px;
    margin-top: auto;
}

.lens-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    text-align: center;
    display: inline-block;
}

.lens-btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
}

.lens-btn-secondary {
    background: rgba(99, 102, 241, 0.1);
    color: #c4b5fd;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.lens-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

/* =================================== */
/*      PROFESSIONAL LENS SECTION     */
/* =================================== */

.professional-lens-section {
    background: linear-gradient(135deg, 
        rgba(10, 10, 25, 0.95) 0%,
        rgba(20, 20, 40, 0.9) 25%,
        rgba(30, 30, 55, 0.85) 50%,
        rgba(40, 40, 70, 0.8) 75%,
        rgba(20, 20, 40, 0.9) 100%
    );
    border-radius: 24px;
    padding: 60px 40px;
    margin: 80px 0;
    border: 1px solid rgba(139, 92, 246, 0.3);
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(25px);
}

.professional-lens-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #8b5cf6, #a855f7, #ec4899, #f59e0b, #8b5cf6);
    background-size: 200% 100%;
    animation: professionalGlow 4s ease-in-out infinite;
}

@keyframes professionalGlow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.professional-header {
    text-align: center;
    margin-bottom: 50px;
    position: relative;
}

.professional-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 25px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(168, 85, 247, 0.2));
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 auto 25px auto;
    backdrop-filter: blur(15px);
    transition: all 0.3s ease;
    width: fit-content;
    white-space: nowrap;
}

.professional-badge:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 30px rgba(245, 158, 11, 0.4);
    border-color: rgba(245, 158, 11, 0.6);
}

.professional-title {
    font-size: 3.2rem;
    font-weight: 900;
    background: linear-gradient(135deg, #8b5cf6 0%, #a855f7 25%, #ec4899 50%, #f59e0b 75%, #8b5cf6 100%);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: professionalTextShine 5s ease-in-out infinite;
    margin-bottom: 25px;
    text-shadow: none;
}

@keyframes professionalTextShine {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.professional-subtitle {
    font-size: 1.2rem;
    color: #e2e8f0;
    line-height: 1.7;
    max-width: 800px;
    margin: 0 auto 40px auto;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.professional-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 35px;
    max-width: 1600px;
    margin: 0 auto;
}

.professional-lens-card {
    background: linear-gradient(145deg, rgba(20, 20, 35, 0.95), rgba(30, 30, 50, 0.9));
    border-radius: 24px;
    border: 1px solid rgba(139, 92, 246, 0.4);
    padding: 35px 30px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(15px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

.professional-lens-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #8b5cf6, #a855f7, #ec4899, #f59e0b);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.professional-lens-card:hover {
    transform: translateY(-12px) scale(1.02);
    border-color: rgba(139, 92, 246, 0.7);
    box-shadow: 0 30px 80px rgba(139, 92, 246, 0.4);
    background: linear-gradient(145deg, rgba(30, 30, 50, 0.95), rgba(40, 40, 65, 0.9));
}

.professional-lens-card:hover::before {
    opacity: 1;
}

/* PREVENT FLASH OF UNSTYLED CONTENT FOR LENS SLIDESHOW */
.lens-section .lens-grid {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.lens-section.lens-slideshow-enabled .lens-grid {
    opacity: 1;
}

/* 2-second fallback if JS doesn't initialize */
.lens-section .lens-grid {
    animation: fadeInLensGrid 0.5s ease-in-out 2s forwards;
}

@keyframes fadeInLensGrid {
    to {
        opacity: 1;
    }
}

.lens-section.lens-slideshow-enabled .lens-grid {
    animation: none;
}

/* Responsive Design */
@media (max-width: 1400px) {
    .lens-categories-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        padding: 0 30px !important;
    }
}

@media (max-width: 1024px) {
    .lens-categories-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px !important;
        padding: 0 20px !important;
    }
    
    .lens-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 25px;
    }
    
    .professional-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        gap: 25px;
    }
}

@media (max-width: 768px) {
    .lens-categories-section {
        padding: 0 20px !important;
    }
    
    .lens-categories-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
        padding: 0 !important;
    }
    
    .lens-section,
    .professional-lens-section {
        padding: 40px 25px;
        margin: 40px 0;
    }
    
    .lens-section-title,
    .professional-title {
        font-size: 2.2rem;
    }
    
    .lens-grid,
    .professional-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

@media (max-width: 480px) {
    .lens-category-card,
    .lens-card,
    .professional-lens-card {
        padding: 20px 15px;
    }
    
    .lens-icon {
        font-size: 2.8rem;
    }
    
    .lens-category-title,
    .lens-card-title {
        font-size: 1.2rem;
    }
    
    .lens-specs {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 15px;
    }
}

/* Print Styles */
@media print {
    .lens-categories-section,
    .lens-section,
    .professional-lens-section {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .lens-categories-grid,
    .lens-grid,
    .professional-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .lens-category-card::before {
        display: none;
    }
}

/* Performance Optimizations */
.lens-category-card,
.lens-card,
.professional-lens-card {
    contain: layout style paint;
    will-change: transform;
}

/* ============================================
   REDUCED MOTION SUPPORT
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .lens-category-card,
    .lens-category-btn,
    .lens-card,
    .professional-lens-card {
        transition: none;
        animation: none;
    }
    
    .lens-category-card::before {
        animation: none;
    }
    
    .lens-category-card:hover {
        transform: none;
    }
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */

@media (prefers-contrast: high) {
    .lens-category-card,
    .lens-card,
    .professional-lens-card {
        border: 2px solid currentColor;
    }
    
    .lens-category-card:focus-visible,
    .lens-category-btn:focus-visible {
        outline-width: 3px;
    }
}

/* ============================================
   DARK MODE SUPPORT
   ============================================ */

@media (prefers-color-scheme: dark) {
    :root {
        --lens-cat-card-bg: linear-gradient(145deg, rgba(20, 25, 31, 0.98) 0%, rgba(35, 42, 61, 0.95) 50%, rgba(45, 55, 71, 0.9) 100%);
    }
}
