/* ============================================
   CATEGORIES SECTION - ENTERPRISE EDITION
   Inti Wasi Global - E-commerce International

   Full Enterprise Features:
   - Triple shadow system for premium depth
   - Glassmorphism backgrounds (blur 20px, saturation 180%)
   - GPU acceleration (translate3d, backface-visibility)
   - Crystal curtain effect (animated shine on hover)
   - Premium glow animation (pulsating brand color)
   - Advanced gradients (135Â°, multiple stops)
   - Fixed 3-column grid for balanced layout
   ============================================ */

/* ============================================
   CATEGORIES SECTION CONTAINER
   ============================================ */

.categories-section {
    padding: var(--section-padding-vertical) 0; /* OPTIMIZED: Reduced from 5xl (128px) to 3xl (64px) */
    background: var(--color-cream);
    position: relative;
    overflow: hidden;
}

/* ============================================
   CATEGORIES GRID - OPTIMIZED LAYOUT
   ============================================ */

.categories-grid {
    display: grid;

    /* RESTORED: Original auto-fit grid for flexible responsive layout
       - Automatically adjusts columns based on available space
       - Maintains minimum 320px card width for readability */
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));

    /* ENTERPRISE: Reduced gap from original 48px to 32px for better proportion */
    gap: var(--spacing-xl);
}

/* RESTORED: Large card distinction for featured category (Retablos)
   Creates visual hierarchy with featured category spanning 2 columns */
.category-card.large {
    grid-column: span 2;
}

/* ============================================
   CATEGORY CARDS - ENTERPRISE PREMIUM
   ============================================ */

.category-card {
    position: relative;

    /* OPTIMIZED: Solid gradient background (removed expensive backdrop-filter) */
    background: linear-gradient(
        135deg,
        #FFFFFF 0%,
        #F8F6F3 50%,
        #FFFFFF 100%
    );

    border-radius: var(--radius-2xl);
    border: 1px solid rgba(217, 118, 66, 0.12);

    /* ENTERPRISE: Triple shadow system + Premium Glow */
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.08),
        0 3px 8px rgba(217, 118, 66, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        0 0 25px rgba(217, 118, 66, 0.12); /* Premium glow */

    /* OPTIMIZED: GPU acceleration with paint containment for better scroll performance */
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    contain: layout style paint; /* CSS containment for performance */

    /* ENTERPRISE: Advanced cubic-bezier transitions */
    transition:
        transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        background 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.4s cubic-bezier(0.4, 0, 0.2, 1);

    overflow: hidden; /* Contain shine and overlay effects */

    /* OPTIMIZED: Removed infinite animation - only glow on hover for better performance */
}

/* PREMIUM: Crystal curtain effect on hover - glass pane sweeping across */
.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -150%; /* Start further left for smoother entrance */
    width: 150%; /* Wider curtain for more visible effect */
    height: 100%;

    /* Multi-layer gradient to simulate crystal/glass - INTENSIFIED */
    background: linear-gradient(
        110deg, /* Slight angle for dynamic crystal effect */
        transparent 0%,
        transparent 20%,
        rgba(255, 255, 255, 0.2) 30%,
        rgba(255, 255, 255, 0.5) 40%,
        rgba(255, 255, 255, 0.85) 50%, /* Peak brightness - crystal center */
        rgba(255, 255, 255, 0.5) 60%,
        rgba(255, 255, 255, 0.2) 70%,
        transparent 80%,
        transparent 100%
    );

    /* Slower, elegant sweep */
    transition: left 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 10; /* Above image but below overlay button */
    border-radius: var(--radius-2xl);
    pointer-events: none; /* Don't interfere with card interactions */

    /* Reduced blur for sharper, more visible crystal effect */
    filter: blur(0.5px);
}

.category-card:hover::before {
    left: 100%; /* Sweep crystal curtain across card */
}

/* ENTERPRISE: Enhanced hover state */
.category-card:hover {
    /* GPU-accelerated 3D transform */
    transform: translate3d(0, -12px, 0);
    will-change: transform; /* Only hint during interaction */

    /* ENTERPRISE: Triple shadow elevation on hover + Enhanced Glow */
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.14),
        0 10px 20px rgba(217, 118, 66, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 1),
        0 0 45px rgba(217, 118, 66, 0.35); /* Enhanced glow on hover */

    /* Optimized solid gradient on hover */
    background: linear-gradient(
        135deg,
        #FFFFFF 0%,
        #FAF8F6 50%,
        #FFFFFF 100%
    );

    border-color: rgba(217, 118, 66, 0.22);
}

/* ============================================
   CATEGORY IMAGE - ENHANCED
   ============================================ */

.category-image {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
}

.category-image .image-placeholder {
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;

    /* Enhanced gradient background for image placeholder */
    background: linear-gradient(
        135deg,
        rgba(217, 118, 66, 0.08) 0%,
        rgba(232, 145, 95, 0.12) 50%,
        rgba(217, 118, 66, 0.08) 100%
    );

    transition: background 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.category-card:hover .category-image .image-placeholder {
    /* Intensify gradient on hover */
    background: linear-gradient(
        135deg,
        rgba(217, 118, 66, 0.12) 0%,
        rgba(232, 145, 95, 0.18) 50%,
        rgba(217, 118, 66, 0.12) 100%
    );
}

.category-image .image-placeholder svg,
.category-image .image-placeholder i {
    width: 64px;
    height: 64px;
    color: var(--color-primary);
    opacity: 0.6;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.category-card:hover .category-image .image-placeholder svg,
.category-card:hover .category-image .image-placeholder i {
    opacity: 0.8;
    transform: scale(1.1);
}

/* ============================================
   CATEGORY OVERLAY - ENHANCED
   ============================================ */

.category-overlay {
    position: absolute;
    inset: 0;

    /* Enhanced overlay gradient */
    background: linear-gradient(
        135deg,
        rgba(0, 0, 0, 0.5) 0%,
        rgba(217, 118, 66, 0.3) 100%
    );

    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 11; /* Above crystal curtain */
}

.category-card:hover .category-overlay {
    opacity: 1;
}

/* FIX: Stabilize card transform when hovering over overlay button
   Prevents conflict between card 3D tilt (JS) and button hover transform */
.category-overlay:hover ~ *,
.category-overlay:hover {
    pointer-events: auto;
}

/* Ensure button in overlay has proper stacking and doesn't inherit transforms */
.category-overlay .btn-enterprise {
    position: relative;
    z-index: 12;
    /* Prevent transform inheritance issues */
    transform-style: preserve-3d;
}

/* ============================================
   CATEGORY CONTENT - ENHANCED
   ============================================ */

.category-content {
    padding: var(--spacing-xl);
    position: relative;
    z-index: 2; /* Above crystal curtain */
}

.category-title {
    font-size: var(--font-size-2xl);
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--color-gray-900);
    transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.category-card:hover .category-title {
    color: var(--color-primary);
}

.category-description {
    color: var(--color-gray-600);
    margin-bottom: var(--spacing-md);
    line-height: 1.7;
    transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.category-card:hover .category-description {
    color: var(--color-gray-700);
}

.category-count {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-md);
    background: linear-gradient(
        135deg,
        rgba(217, 118, 66, 0.08) 0%,
        rgba(232, 145, 95, 0.12) 100%
    );
    border-radius: var(--radius-lg);
    color: var(--color-primary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.category-count svg,
.category-count i {
    width: 16px;
    height: 16px;
}

.category-card:hover .category-count {
    background: linear-gradient(
        135deg,
        rgba(217, 118, 66, 0.15) 0%,
        rgba(232, 145, 95, 0.2) 100%
    );
    transform: translateX(4px);
}

/* ============================================
   PERFORMANCE OPTIMIZATION
   ============================================ */

/* REMOVED: categoryGlow animation for better scroll performance
   Infinite box-shadow animations on 5+ cards caused scroll lag
   Premium glow effect now only appears on hover for optimal performance */

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Large tablets - maintain 3 columns */
@media (max-width: 1200px) {
    .categories-grid {
        max-width: 100%; /* Use full container width */
    }
}

/* Tablets - switch to 2 columns */
@media (max-width: 900px) {
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-xl);
    }
}

/* Small tablets and large phones - maintain 2 columns */
@media (max-width: 768px) {
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-lg); /* Reduce gap for better space usage */
    }

    .category-content {
        padding: var(--spacing-lg);
    }

    .category-card:hover {
        transform: translate3d(0, -8px, 0); /* Reduced lift on smaller screens */
    }
}

/* Mobile - switch to 1 column */
@media (max-width: 600px) {
    .categories-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
}

/* ============================================
   ACCESSIBILITY & PERFORMANCE
   ============================================ */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .category-card,
    .category-card::before,
    .category-overlay,
    .category-image .image-placeholder svg,
    .category-image .image-placeholder i,
    .category-count {
        transition: none;
        animation: none; /* Disable glow animation */
    }

    .category-card:hover {
        transform: translate3d(0, 0, 0);
    }

    .category-card::before {
        display: none;
    }
}

/* Focus state for keyboard navigation */
.category-card:focus-within {
    outline: 2px solid var(--color-primary);
    outline-offset: 4px;
}

/* Ensure overlay button is keyboard accessible */
.category-overlay button:focus {
    outline: 2px solid var(--color-white);
    outline-offset: 2px;
}
