/**
 * Projects Showcase Component - Floating Cards Screensaver
 * 
 * Features:
 * - Cards float from bottom to top at random X positions
 * - Multiple cards visible simultaneously with staggered timing
 * - Individual card hover stops and highlights that card only
 * - Continuous screensaver-like animation
 * - Cards avoid overlapping and cycle with position variety
 */

/* ==========================================================================
   MAIN COMPONENT STYLES
   ========================================================================== */

.projects-showcase {
    position: relative;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 0;
    overflow: hidden;
    height: 100vh;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

/* Subtle dark/pink overlay for contrast */
.projects-showcase::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(15, 23, 42, 0.15) 0%,
        rgba(244, 63, 94, 0.08) 50%,
        rgba(15, 23, 42, 0.12) 100%
    );
    z-index: 2;
    pointer-events: none;
}

/* ==========================================================================
   CENTERED CONTENT LAYOUT
   ========================================================================== */

.projects-showcase__center {
    position: relative;
    z-index: 40;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    max-width: 800px;
    padding: 2rem;
}

.projects-showcase__header {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Enhanced text readability with shadows */
.projects-showcase__header .section-header__label {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: inline-block;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgb(225 29 72);
    margin-bottom: 1rem;
}

.projects-showcase__header .section-header__title {
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    font-size: 3.5rem;
    font-weight: bold;
    color: rgb(225 29 72);
    margin-bottom: 1.5rem;
    position: relative;
}

.projects-showcase__header .section-header__subtitle {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    max-width: 600px;
    margin: 0 auto;
    color: rgb(71 85 105);
    font-size: 1.125rem;
    line-height: 1.75;
}

/* ==========================================================================
   FLOATING CARDS CONTAINER
   ========================================================================== */

.projects-showcase__carousel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2;
    overflow: hidden;
    pointer-events: none;
    
    /* Gradient masks for top and bottom fade */
    mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(0, 0, 0, 0.2) 8%,
        rgba(0, 0, 0, 0.8) 20%,
        black 30%,
        black 70%,
        rgba(0, 0, 0, 0.8) 80%,
        rgba(0, 0, 0, 0.2) 92%,
        transparent 100%
    );
    -webkit-mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(0, 0, 0, 0.2) 8%,
        rgba(0, 0, 0, 0.8) 20%,
        black 30%,
        black 70%,
        rgba(0, 0, 0, 0.8) 80%,
        rgba(0, 0, 0, 0.2) 92%,
        transparent 100%
    );
}

/* ==========================================================================
   FLOATING CARDS ANIMATION SYSTEM
   ========================================================================== */

.projects-carousel {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

/* Individual floating cards with different positions and timing */
.projects-carousel__item {
    position: absolute;
    width: 240px;
    height: 280px;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    opacity: 1;
    cursor: pointer;
    transform-origin: center center;
    will-change: transform, opacity;
    pointer-events: auto;
}

/* Left side cards - float DOWN */
.projects-carousel__item[data-direction="down"] {
    /* Start from top of screen */
    transform: translateY(-120vh);
}

/* Right side cards - float UP */
.projects-carousel__item[data-direction="up"] {
    /* Start from bottom of screen */
    transform: translateY(120vh);
}

/* Mobile-specific keyframes that avoid the top header zone */
@media (max-width: 768px) {
    /* reserve ~28vh from the top as a safe zone for text */
    .projects-carousel__item[data-direction="up"] {
        transform: translateY(100vh);
    }
    .projects-carousel__item[data-direction="down"] {
        transform: translateY(-100vh);
    }

    @keyframes m-float-up-1 { from { transform: translateY(100vh) translateX(0) rotate(0);} to { transform: translateY(-60vh) translateX(20px) rotate(2deg);} }
    @keyframes m-float-up-2 { from { transform: translateY(100vh) translateX(0) rotate(0);} to { transform: translateY(-60vh) translateX(-15px) rotate(-1deg);} }
    @keyframes m-float-up-3 { from { transform: translateY(100vh) translateX(0) rotate(0);} to { transform: translateY(-60vh) translateX(30px) rotate(3deg);} }
    @keyframes m-float-up-4 { from { transform: translateY(100vh) translateX(0) rotate(0);} to { transform: translateY(-60vh) translateX(-20px) rotate(-2deg);} }

    @keyframes m-float-down-1 { from { transform: translateY(-60vh) translateX(0) rotate(0);} to { transform: translateY(100vh) translateX(15px) rotate(1deg);} }
    @keyframes m-float-down-2 { from { transform: translateY(-60vh) translateX(0) rotate(0);} to { transform: translateY(100vh) translateX(-10px) rotate(-2deg);} }
    @keyframes m-float-down-3 { from { transform: translateY(-60vh) translateX(0) rotate(0);} to { transform: translateY(100vh) translateX(25px) rotate(2deg);} }
    @keyframes m-float-down-4 { from { transform: translateY(-60vh) translateX(0) rotate(0);} to { transform: translateY(100vh) translateX(-18px) rotate(-1deg);} }
}

/* Floating animation - continuous loop with proper staggering */
/* LEFT SIDE - DOWN ANIMATIONS */
.projects-carousel__item[data-direction="down"]:nth-child(4n+1) {
    animation: float-down-1 30s linear infinite;
    animation-delay: 0s;
}

.projects-carousel__item[data-direction="down"]:nth-child(4n+2) {
    animation: float-down-2 30s linear infinite;
    animation-delay: -5s;
}

.projects-carousel__item[data-direction="down"]:nth-child(4n+3) {
    animation: float-down-3 30s linear infinite;
    animation-delay: -10s;
}

.projects-carousel__item[data-direction="down"]:nth-child(4n+4) {
    animation: float-down-4 30s linear infinite;
    animation-delay: -15s;
}

/* RIGHT SIDE - UP ANIMATIONS */
.projects-carousel__item[data-direction="up"]:nth-child(4n+1) {
    animation: float-up-1 30s linear infinite;
    animation-delay: -2.5s;
}

.projects-carousel__item[data-direction="up"]:nth-child(4n+2) {
    animation: float-up-2 30s linear infinite;
    animation-delay: -7.5s;
}

.projects-carousel__item[data-direction="up"]:nth-child(4n+3) {
    animation: float-up-3 30s linear infinite;
    animation-delay: -12.5s;
}

.projects-carousel__item[data-direction="up"]:nth-child(4n+4) {
    animation: float-up-4 30s linear infinite;
    animation-delay: -17.5s;
}

/* Keyframes for different floating paths - UP direction */
@keyframes float-up-1 {
    from { transform: translateY(120vh) translateX(0px) rotate(0deg); }
    to { transform: translateY(-120vh) translateX(30px) rotate(2deg); }
}

@keyframes float-up-2 {
    from { transform: translateY(120vh) translateX(0px) rotate(0deg); }
    to { transform: translateY(-120vh) translateX(-20px) rotate(-1deg); }
}

@keyframes float-up-3 {
    from { transform: translateY(120vh) translateX(0px) rotate(0deg); }
    to { transform: translateY(-120vh) translateX(40px) rotate(3deg); }
}

@keyframes float-up-4 {
    from { transform: translateY(120vh) translateX(0px) rotate(0deg); }
    to { transform: translateY(-120vh) translateX(-30px) rotate(-2deg); }
}

/* Keyframes for different floating paths - DOWN direction */
@keyframes float-down-1 {
    from { transform: translateY(-120vh) translateX(0px) rotate(0deg); }
    to { transform: translateY(120vh) translateX(25px) rotate(1deg); }
}

@keyframes float-down-2 {
    from { transform: translateY(-120vh) translateX(0px) rotate(0deg); }
    to { transform: translateY(120vh) translateX(-15px) rotate(-2deg); }
}

@keyframes float-down-3 {
    from { transform: translateY(-120vh) translateX(0px) rotate(0deg); }
    to { transform: translateY(120vh) translateX(35px) rotate(2deg); }
}

@keyframes float-down-4 {
    from { transform: translateY(-120vh) translateX(0px) rotate(0deg); }
    to { transform: translateY(120vh) translateX(-25px) rotate(-1deg); }
}

/* Hover effects - only affect the hovered card */
.projects-carousel__item:hover {
    animation-play-state: paused;
    opacity: 1;
    transform: scale(1.1);
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.4),
        0 0 0 3px rgba(244, 63, 94, 0.6),
        0 0 30px rgba(244, 63, 94, 0.3);
    z-index: 50;
    background: rgba(255, 255, 255, 0.98);
}

/* Ensure smooth animation resume */
.projects-carousel__item {
    animation-play-state: running;
}

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

.projects-carousel__item img {
    width: 100%;
    height: 75%;
    object-fit: cover;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    filter: grayscale(100%) brightness(0.8);
}

.projects-carousel__item:hover img {
    transform: scale(1.05);
    filter: grayscale(0%) brightness(1);
}

.projects-carousel__content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(
        to top,
        rgba(255, 255, 255, 0.95) 0%,
        rgba(255, 255, 255, 0.9) 70%,
        transparent 100%
    );
    padding: 0.5rem 0.75rem;
    text-align: center;
    height: 25%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.projects-carousel__title {
    font-weight: 600;
    color: rgb(225 29 72);
    margin: 0;
    line-height: 1.2;
    font-size: 1rem;
}

.projects-carousel__subtitle {
    color: rgb(71 85 105);
    margin: 0.25rem 0 0 0;
    opacity: 0.9;
    font-size: 0.875rem;
}

/* ==========================================================================
   COMPANY BRANDING - CENTERED ON X & Y AXIS
   ========================================================================== */

.projects-showcase__branding {
    text-align: center;
    pointer-events: none;
}

.projects-showcase__logo {
    height: 120px;
    width: auto;
    opacity: 1;
    transition: all 0.3s ease;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.2));
}

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

/* Tablet and below (1024px and down) */
@media (max-width: 1024px) {
    .projects-showcase__center {
        max-width: 700px;
        padding: 1.5rem;
        gap: 1.5rem;
    }

    .projects-carousel__item {
        width: 200px;
        height: 240px;
    }

    .projects-showcase__logo {
        height: 100px;
    }
}

/* Mobile (768px and down) */
@media (max-width: 768px) {
    .projects-showcase__center {
        max-width: 90%;
        padding: 1.25rem;
        gap: 1.25rem;
    }

    /* Keep header clean; no overlay on mobile */
    .projects-showcase__header { background: transparent; border: 0; padding: 0; }

    .projects-carousel__item {
        width: 160px;
        height: 200px;
    }

    .projects-showcase__logo {
        height: 80px;
    }

    /* On mobile we anchor columns, so increase fade edges to avoid clipping */
    .projects-showcase__carousel {
        mask-image: linear-gradient(
            to bottom,
            transparent 0%,
            rgba(0, 0, 0, 0.3) 10%,
            black 28%,
            black 72%,
            rgba(0, 0, 0, 0.3) 90%,
            transparent 100%
        );
        -webkit-mask-image: linear-gradient(
            to bottom,
            transparent 0%,
            rgba(0, 0, 0, 0.3) 10%,
            black 28%,
            black 72%,
            rgba(0, 0, 0, 0.3) 90%,
            transparent 100%
        );
    }
}

/* Small mobile (480px and down) */
@media (max-width: 480px) {
    .projects-showcase__center {
        max-width: 95%;
        padding: 1rem;
        gap: 1rem;
    }

    /* Nothing extra here */

    .projects-carousel__item {
        width: 140px;
        height: 180px;
    }

    .projects-carousel__content {
        padding: 0.5rem;
    }

    .projects-showcase__logo {
        height: 70px;
    }
}

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

/* Pause all animations when user prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
    .projects-carousel__item {
        animation: none;
        position: static;
        display: inline-block;
        margin: 1rem;
        opacity: 0.8;
    }

    .projects-carousel {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
    }
}

/* Performance optimizations */
.projects-carousel__item {
    contain: layout style paint;
}

/* Intersection observer animation states */
.projects-showcase[data-revealed="true"] {
    opacity: 1;
    transform: translateY(0);
}

/* Initial hidden state for scroll animations */
.projects-showcase {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}