/* ===========================================================
   MAGIC BENTO SECTION - LIGHT THEME
   - GlitchText Heading
   - Spotlight Effect
   - Background Images
   - CountUp Stats
=========================================================== */

:root {
    --bento-bg: #ffffff;
    --bento-card-bg: #f8fafc;
    --bento-border: #e2e8f0;
    --bento-text: #1e293b;
    --bento-text-muted: #64748b;
    --bento-glow-color: 59, 130, 246;
    --bento-glow-color-2: 6, 182, 212;
}

.bento-section {
    background: var(--bento-bg);
    padding: 100px 0;
    position: relative;
    user-select: none;
}

.bento-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ===========================================================
   GLITCH TEXT HEADING
=========================================================== */

.bento-header {
    text-align: center;
    margin-bottom: 60px;
}

.glitch-wrapper {
    display: inline-block;
    margin-bottom: 16px;
}

.glitch {
    color: #1e293b;
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 900;
    position: relative;
    margin: 0;
    cursor: default;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.glitch::after,
.glitch::before {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    clip-path: inset(0 0 0 0);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.glitch::after {
    color: #3b82f6;
    text-shadow: -3px 0 #3b82f6;
    animation: glitch-after 3s infinite linear alternate-reverse;
    animation-play-state: paused;
}

.glitch::before {
    color: #06b6d4;
    text-shadow: 3px 0 #06b6d4;
    animation: glitch-before 2s infinite linear alternate-reverse;
    animation-play-state: paused;
}

.glitch:hover::after,
.glitch:hover::before {
    opacity: 1;
    animation-play-state: running;
}

@keyframes glitch-after {
    0% { clip-path: inset(20% 0 50% 0); left: 3px; }
    5% { clip-path: inset(10% 0 60% 0); left: -3px; }
    10% { clip-path: inset(15% 0 55% 0); left: 3px; }
    15% { clip-path: inset(25% 0 35% 0); left: -3px; }
    20% { clip-path: inset(30% 0 40% 0); left: 3px; }
    25% { clip-path: inset(40% 0 20% 0); left: -3px; }
    30% { clip-path: inset(10% 0 60% 0); left: 3px; }
    35% { clip-path: inset(15% 0 55% 0); left: -3px; }
    40% { clip-path: inset(25% 0 35% 0); left: 3px; }
    45% { clip-path: inset(30% 0 40% 0); left: -3px; }
    50% { clip-path: inset(20% 0 50% 0); left: 3px; }
    55% { clip-path: inset(10% 0 60% 0); left: -3px; }
    60% { clip-path: inset(15% 0 55% 0); left: 3px; }
    65% { clip-path: inset(25% 0 35% 0); left: -3px; }
    70% { clip-path: inset(30% 0 40% 0); left: 3px; }
    75% { clip-path: inset(40% 0 20% 0); left: -3px; }
    80% { clip-path: inset(20% 0 50% 0); left: 3px; }
    85% { clip-path: inset(10% 0 60% 0); left: -3px; }
    90% { clip-path: inset(15% 0 55% 0); left: 3px; }
    95% { clip-path: inset(25% 0 35% 0); left: -3px; }
    100% { clip-path: inset(30% 0 40% 0); left: 3px; }
}

@keyframes glitch-before {
    0% { clip-path: inset(50% 0 20% 0); left: -3px; }
    5% { clip-path: inset(60% 0 10% 0); left: 3px; }
    10% { clip-path: inset(55% 0 15% 0); left: -3px; }
    15% { clip-path: inset(35% 0 25% 0); left: 3px; }
    20% { clip-path: inset(40% 0 30% 0); left: -3px; }
    25% { clip-path: inset(20% 0 40% 0); left: 3px; }
    30% { clip-path: inset(60% 0 10% 0); left: -3px; }
    35% { clip-path: inset(55% 0 15% 0); left: 3px; }
    40% { clip-path: inset(35% 0 25% 0); left: -3px; }
    45% { clip-path: inset(40% 0 30% 0); left: 3px; }
    50% { clip-path: inset(50% 0 20% 0); left: -3px; }
    55% { clip-path: inset(60% 0 10% 0); left: 3px; }
    60% { clip-path: inset(55% 0 15% 0); left: -3px; }
    65% { clip-path: inset(35% 0 25% 0); left: 3px; }
    70% { clip-path: inset(40% 0 30% 0); left: -3px; }
    75% { clip-path: inset(20% 0 40% 0); left: 3px; }
    80% { clip-path: inset(50% 0 20% 0); left: -3px; }
    85% { clip-path: inset(60% 0 10% 0); left: 3px; }
    90% { clip-path: inset(55% 0 15% 0); left: -3px; }
    95% { clip-path: inset(35% 0 25% 0); left: 3px; }
    100% { clip-path: inset(40% 0 30% 0); left: -3px; }
}

.bento-subheading {
    font-size: 1.1rem;
    color: var(--bento-text-muted);
    margin: 0;
}

/* ===========================================================
   BENTO GRID
=========================================================== */

.card-grid {
    display: grid;
    gap: 16px;
    font-size: clamp(1rem, 0.9rem + 0.5vw, 1.25rem);
}

/* Desktop: 4 columns */
@media (min-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    /* Card 3 - Our Blogs (large) */
    .magic-bento-card:nth-child(3) {
        grid-column: span 2;
        grid-row: span 2;
    }
    
    /* Card 4 - Case Studies (large) */
    .magic-bento-card:nth-child(4) {
        grid-column: 1 / span 2;
        grid-row: 2 / span 2;
    }
    
    /* Card 6 - Active Clients */
    .magic-bento-card:nth-child(6) {
        grid-column: 4;
        grid-row: 3;
    }
}

/* Tablet: 2 columns */
@media (min-width: 600px) and (max-width: 1023px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .magic-bento-card:nth-child(3),
    .magic-bento-card:nth-child(4) {
        grid-column: span 2;
    }
}

/* Mobile: 1 column */
@media (max-width: 599px) {
    .card-grid {
        grid-template-columns: 1fr;
    }
}

/* ===========================================================
   BENTO CARD
=========================================================== */

.magic-bento-card {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    position: relative;
    aspect-ratio: 4/3;
    min-height: 200px;
    padding: 24px;
    border-radius: 20px;
    border: 1px solid var(--bento-border);
    background-color: var(--bento-card-bg);
    background-size: cover;
    background-position: center;
    overflow: hidden;
    transition: all 0.3s ease;
    
    --glow-x: 50%;
    --glow-y: 50%;
    --glow-intensity: 0;
    --glow-radius: 200px;
}

.magic-bento-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
    border-color: rgba(59, 130, 246, 0.3);
}

/* Large cards */
.magic-bento-card[data-size="large"] {
    aspect-ratio: auto;
    min-height: 300px;
}

@media (min-width: 1024px) {
    .magic-bento-card[data-size="large"] {
        min-height: 420px;
    }
}

/* ===========================================================
   BACKGROUND IMAGE CARDS
=========================================================== */

.magic-bento-card.has-bg-image {
    border: none;
}

.magic-bento-card.has-bg-image .card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.85) 0%,
        rgba(0, 0, 0, 0.5) 40%,
        rgba(0, 0, 0, 0.2) 100%
    );
    z-index: 1;
    transition: background 0.3s ease;
}

.magic-bento-card.has-bg-image:hover .card-overlay {
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.9) 0%,
        rgba(0, 0, 0, 0.4) 50%,
        rgba(0, 0, 0, 0.1) 100%
    );
}

.magic-bento-card.has-bg-image .magic-bento-card__content {
    position: relative;
    z-index: 2;
}

.magic-bento-card.has-bg-image .magic-bento-card__title,
.magic-bento-card.has-bg-image .magic-bento-card__description {
    color: #fff;
}

.magic-bento-card.has-bg-image:hover .magic-bento-card__title {
    color: #fff;
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
}

/* ===========================================================
   CARD CONTENT
=========================================================== */

.magic-bento-card__content {
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 2;
}

/* Stat Number with CountUp */
.magic-bento-card__stat {
    display: flex;
    align-items: baseline;
    margin-bottom: 8px;
}

.count-up {
    font-size: clamp(2.5rem, 6vw, 4rem);
    font-weight: 800;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    line-height: 1;
}

.stat-suffix {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 700;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-left: 4px;
}

.magic-bento-card__title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--bento-text);
    margin: 0 0 8px;
    transition: all 0.3s ease;
}

.magic-bento-card:not(.has-bg-image):hover .magic-bento-card__title {
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.magic-bento-card__description {
    font-size: 14px;
    line-height: 1.5;
    color: var(--bento-text-muted);
    margin: 0;
}

/* Link Button */
.magic-bento-card__link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    border-radius: 50px;
    text-decoration: none;
    transition: all 0.3s ease;
    width: fit-content;
}

.magic-bento-card__link:hover {
    transform: translateX(4px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
}

.magic-bento-card__link svg {
    transition: transform 0.3s ease;
}

.magic-bento-card__link:hover svg {
    transform: translateX(4px);
}

/* ===========================================================
   BORDER GLOW EFFECT
=========================================================== */

.magic-bento-card--border-glow:not(.has-bg-image)::after {
    content: '';
    position: absolute;
    inset: 0;
    padding: 2px;
    background: radial-gradient(
        var(--glow-radius) circle at var(--glow-x) var(--glow-y),
        rgba(var(--bento-glow-color), calc(var(--glow-intensity) * 0.6)) 0%,
        rgba(var(--bento-glow-color-2), calc(var(--glow-intensity) * 0.3)) 30%,
        transparent 60%
    );
    border-radius: inherit;
    -webkit-mask: 
        linear-gradient(#fff 0 0) content-box, 
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: 
        linear-gradient(#fff 0 0) content-box, 
        linear-gradient(#fff 0 0);
    mask-composite: exclude;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.magic-bento-card--border-glow:not(.has-bg-image):hover {
    box-shadow: 
        0 8px 30px rgba(59, 130, 246, 0.15),
        0 0 40px rgba(59, 130, 246, 0.1);
}

/* ===========================================================
   PARTICLES
=========================================================== */

.particles-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 3;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.8);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.6);
    pointer-events: none;
}

.has-bg-image .particle {
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

/* ===========================================================
   GLOBAL SPOTLIGHT
=========================================================== */

.global-spotlight {
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    pointer-events: none;
    background: radial-gradient(circle,
        rgba(59, 130, 246, 0.08) 0%,
        rgba(6, 182, 212, 0.05) 20%,
        rgba(59, 130, 246, 0.02) 40%,
        transparent 60%
    );
    z-index: 200;
    opacity: 0;
    transform: translate(-50%, -50%);
    mix-blend-mode: multiply;
    will-change: transform, opacity;
}

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

@media (max-width: 768px) {
    .bento-section {
        padding: 60px 0;
    }
    
    .bento-header {
        margin-bottom: 40px;
    }
    
    .bento-container {
        padding: 0 16px;
    }
    
    .magic-bento-card {
        padding: 20px;
        min-height: 180px;
    }
    
    .magic-bento-card[data-size="large"] {
        min-height: 220px;
    }
    
    .count-up {
        font-size: 2.5rem;
    }
    
    .stat-suffix {
        font-size: 1.5rem;
    }
    
    .glitch {
        font-size: 2rem;
    }
}

/* ===========================================================
   REDUCED MOTION
=========================================================== */

@media (prefers-reduced-motion: reduce) {
    .magic-bento-card,
    .magic-bento-card__link,
    .particle,
    .glitch::before,
    .glitch::after {
        transition: none !important;
        animation: none !important;
    }
    
    .magic-bento-card:hover {
        transform: none !important;
    }
    
    .glitch:hover::before,
    .glitch:hover::after {
        opacity: 0 !important;
    }
}