/* Portfolio Premium UI Styles - Scroll Snap Version */

:root {
    --portfolio-card-width: 320px;
    --portfolio-card-height: 480px;
    --portfolio-gap: 40px;
    --portfolio-ease: cubic-bezier(0.19, 1, 0.22, 1);
}

#portfolio {
    padding: 100px 0;
}

/* Portfolio Section Entrance Animation */
#portfolio .container {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

#portfolio .container.animate-in {
    opacity: 1;
    transform: translateY(0);
}


/* Scroll Container */
.portfolio-horizontal-scroll {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 50px 0;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Firefox */
    cursor: grab;
    cursor: -webkit-grab;
}

.portfolio-horizontal-scroll.dragging {
    cursor: grabbing;
    cursor: -webkit-grabbing;
    scroll-snap-type: none;
    /* Disable snap while dragging */
}

.portfolio-horizontal-scroll::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Edge */
}

.portfolio-track {
    display: flex;
    gap: var(--portfolio-gap);
    padding: 0 50px;
    /* Centered if not overflowing */
    width: max-content;
    margin: 0 auto;
}

/* Card Item */
.portfolio-card-item {
    position: relative;
    width: var(--portfolio-card-width);
    height: var(--portfolio-card-height);
    flex: 0 0 auto;
    border-radius: 1.5rem;
    overflow: hidden;
    /* Force Hardware Acceleration and Clean Clipping */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    transform-style: preserve-3d;
    isolation: isolate;
    -webkit-mask-image: -webkit-radial-gradient(white, black);
    mask-image: radial-gradient(white, black);
    /* Crucial fix for border-radius + overflow clipping */
    background-clip: padding-box;
    outline: 1px solid transparent;
    /* Anti-aliasing fix */
    transition:
        transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.6s var(--portfolio-ease),
        box-shadow 0.3s ease,
        filter 0.6s var(--portfolio-ease);
    cursor: pointer;
    will-change: transform;
    user-select: none;
    -webkit-user-select: none;

    /* Initial state for entrance animation */
    opacity: 0;
    transform: translateX(100px) scale(0.9);
    filter: blur(10px);
    pointer-events: none;
    /* Disable hover until animation completes */
}

/* Animated state */
.portfolio-card-item.animate-in {
    opacity: 1;
    transform: translateX(0) scale(1);
    filter: blur(0);
    transition:
        opacity 1s cubic-bezier(0.16, 1, 0.3, 1),
        filter 1s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.3s ease;
}

/* Staggered animation delays - Only for entrance properties like opacity and filter */
.portfolio-card-item:nth-child(1).animate-in {
    transition-delay: 0.1s, 0.1s, 0s, 0s;
}

.portfolio-card-item:nth-child(2).animate-in {
    transition-delay: 0.2s, 0.2s, 0s, 0s;
}

.portfolio-card-item:nth-child(3).animate-in {
    transition-delay: 0.3s, 0.3s, 0s, 0s;
}

.portfolio-card-item:nth-child(4).animate-in {
    transition-delay: 0.4s, 0.4s, 0s, 0s;
}

.portfolio-card-item:nth-child(5).animate-in {
    transition-delay: 0.5s, 0.5s, 0s, 0s;
}

.portfolio-card-item:nth-child(6).animate-in {
    transition-delay: 0.6s, 0.6s, 0s, 0s;
}

.portfolio-card-item:nth-child(7).animate-in {
    transition-delay: 0.7s, 0.7s, 0s, 0s;
}

.portfolio-card-item:nth-child(8).animate-in {
    transition-delay: 0.8s, 0.8s, 0s, 0s;
}

.portfolio-card-item:nth-child(9).animate-in {
    transition-delay: 0.9s, 0.9s, 0s, 0s;
}

.portfolio-card-item:nth-child(10).animate-in {
    transition-delay: 1s, 1s, 0s, 0s;
}

.portfolio-card-item:nth-child(11).animate-in {
    transition-delay: 1.1s, 1.1s, 0s, 0s;
}

.portfolio-card-item:nth-child(12).animate-in {
    transition-delay: 1.2s, 1.2s, 0s, 0s;
}


/* Hover Effect - Works even before animation */
.portfolio-card-item:hover {
    transform: translateY(-15px) scale(1.03);
    z-index: 10;
}

/* Hover Effect - More reliable and responsive */
.portfolio-card-item.animate-in:hover {
    transform: translateY(-15px) scale(1.03);
    z-index: 10;
    transition:
        transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
        z-index 0s;
}



.portfolio-card-item .card-image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.portfolio-card-item .card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    position: absolute;
    left: -2px;
    /* Increased bleed */
    top: -2px;
    width: calc(100% + 4px);
    height: calc(100% + 4px);
    transition: transform 0.1s linear, opacity 0.3s ease;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    pointer-events: none;
    /* Prevent native image drag */
}

.portfolio-card-item .card-image-hover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    position: absolute;
    left: -2px;
    /* Increased bleed */
    top: -2px;
    width: calc(100% + 4px);
    height: calc(100% + 4px);
    opacity: 0;
    transition: transform 0.1s linear, opacity 0.3s ease;
    will-change: transform, opacity;
    pointer-events: none;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
}

.portfolio-card-item:hover .card-image {
    opacity: 0;
}

.portfolio-card-item:hover .card-image-hover {
    opacity: 1;
}

/* Logo-style cards — image is a brand logo, not a screenshot */
.portfolio-card-item[data-image-style="logo"] .card-image-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--card-bg, #1a2332);
}

.portfolio-card-item[data-image-style="logo"] .card-image,
.portfolio-card-item[data-image-style="logo"] .card-image-hover {
    position: relative;
    left: unset;
    top: unset;
    width: 55%;
    height: auto;
    max-height: 55%;
    object-fit: contain;
    object-position: center;
}

/* Text Overlay on Card */
.portfolio-card-item .card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2.5rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.4) 50%, transparent 100%);
    color: white;
    z-index: 2;
}

.portfolio-card-item .card-category {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 0.5rem;
}

.portfolio-card-item .card-title {
    font-size: 1.5rem;
    font-weight: 700;
    text-transform: uppercase;
    color: white;
    margin: 0;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

/* Expanded View Container */
.portfolio-expanded-view {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: none;
    opacity: 0;
    transition: opacity 0.5s var(--portfolio-ease);
    overscroll-behavior: contain;
}

.portfolio-expanded-view.active {
    display: flex;
    opacity: 1;
}

/* Backdrop */
.portfolio-expanded-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
}

/* Expanded Content */
.portfolio-expanded-content {
    position: absolute;
    /* Use a rich deep gradient background instead of solid black */
    background: radial-gradient(circle at 70% 30%, #1e293b 0%, #0f172a 60%, #020617 100%);
    overflow: hidden;
    display: flex;
    transition: all 0.8s var(--portfolio-ease);
    will-change: top, left, width, height, border-radius;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.portfolio-expanded-view.active .portfolio-expanded-content.full {
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100vh !important;
    border-radius: 0 !important;
}

/* Left Side - Image Container */
.portfolio-expanded-image-container {
    flex: 0 0 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10%;
    background: transparent;
    /* Remove stark white background */
}

/* The actual image floating in the center */
.portfolio-expanded-image {
    position: relative;
    width: 100%;
    height: 100%;
    max-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1200px;
    transform-style: preserve-3d;
}

.portfolio-expanded-image img,
.portfolio-slide {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: translateX(0) scale(0.8) translateZ(-100px);
    opacity: 0;
    z-index: 1;
    transition: all 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
    pointer-events: none;
}

/* Base states */
.portfolio-expanded-view.active .portfolio-slide.active {
    transform: translateX(0) scale(1) translateZ(0);
    opacity: 1;
    z-index: 3;
    pointer-events: auto;
}

.portfolio-expanded-view.active .portfolio-slide.prev {
    transform: translateX(-40%) scale(0.7) translateZ(-50px);
    opacity: 0.6;
    z-index: 2;
    cursor: pointer;
    pointer-events: auto;
}

.portfolio-expanded-view.active .portfolio-slide.next {
    transform: translateX(40%) scale(0.7) translateZ(-50px);
    opacity: 0.6;
    z-index: 2;
    cursor: pointer;
    pointer-events: auto;
}

/* Removing redundant active class overwrite since we declared it above */

/* Carousel Controls */
.portfolio-carousel-controls {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
    z-index: 10;
}

.portfolio-carousel-prev,
.portfolio-carousel-next {
    background: rgba(0, 0, 0, 0.4);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    pointer-events: auto;
    transition: all 0.3s ease;
    margin: 0 1rem;
    opacity: 0;
}

.portfolio-expanded-image-container:hover .portfolio-carousel-prev,
.portfolio-expanded-image-container:hover .portfolio-carousel-next {
    opacity: 1;
}

.portfolio-carousel-prev:hover,
.portfolio-carousel-next:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.portfolio-carousel-dots {
    position: absolute;
    bottom: 1.5rem;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    pointer-events: auto;
}

.portfolio-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
}

.portfolio-dot:hover {
    background: rgba(255, 255, 255, 0.6);
}

.portfolio-dot.active {
    background: white;
    transform: scale(1.3);
}

.portfolio-expanded-view.active .portfolio-expanded-image img {
    transform: scale(1);
}

/* Right Side - Details */
.portfolio-expanded-details {
    flex: 1;
    padding: 5% 8% 10% 0;
    /* Less left padding since image has its own breathing room */
    overflow-y: auto;
    background: transparent;
    /* Use parent gradient */
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    /* Keeps things accessible if overflow */
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s var(--portfolio-ease) 0.4s, transform 0.8s var(--portfolio-ease) 0.4s;
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
    overscroll-behavior: contain;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.portfolio-expanded-details::-webkit-scrollbar {
    display: none;
}

.portfolio-expanded-view.active .portfolio-expanded-details {
    opacity: 1;
    transform: translateY(0);
}

.portfolio-expanded-category {
    font-size: 0.75rem;
    /* Smaller */
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--primary-400, #60a5fa);
    margin-bottom: 0.5rem;
}

.portfolio-expanded-title {
    font-size: 3rem;
    /* Restored closer to original size */
    font-weight: 700;
    text-transform: uppercase;
    color: var(--slate-50, #f8fafc);
    margin-bottom: 1.5rem;
    line-height: 1.1;
    letter-spacing: -0.02em;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.portfolio-expanded-divider {
    width: 60px;
    height: 3px;
    background: var(--primary-500, #3b82f6);
    margin-bottom: 2rem;
    border-radius: 2px;
}

.portfolio-expanded-description {
    font-size: 1.125rem;
    /* Smaller, matches better */
    line-height: 1.6;
    color: var(--slate-300, #cbd5e1);
    margin-bottom: 2.5rem;
    max-width: 600px;
    font-weight: 400;
}

.portfolio-expanded-tech h4 {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--slate-500, #64748b);
    /* Replaced old #666 */
    margin-bottom: 1.25rem;
    opacity: 0.8;
}

.portfolio-tech-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 3rem;
}

/* Modern Glass Pill Badges */
.portfolio-tech-badge {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    color: var(--slate-200, #e2e8f0);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 100px;
    /* Fully rounded */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
}

.portfolio-tech-badge:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    color: white;
}

/* Action Buttons */
.portfolio-expanded-actions {
    display: flex;
    gap: 1rem;
}

.portfolio-action-btn {
    padding: 1.25rem 2.5rem;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.portfolio-action-btn.primary {
    background: #f3e5ab;
    color: #111;
}

.portfolio-action-btn.primary:hover {
    background: #fff;
    transform: translateY(-2px);
}

.portfolio-action-btn.secondary {
    background: transparent;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.portfolio-action-btn.secondary:hover {
    border-color: white;
    background: rgba(255, 255, 255, 0.05);
}

/* Close Button - Frosted Glass */
.portfolio-close-btn {
    position: absolute;
    top: 2.5rem;
    right: 3rem;
    width: 3.5rem;
    height: 3.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: var(--slate-300, #cbd5e1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 100;
    opacity: 0;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.portfolio-expanded-view.active .portfolio-close-btn {
    opacity: 1;
}

.portfolio-close-btn:hover {
    transform: rotate(90deg) scale(1.1);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

/* Responsive */
@media (max-width: 1024px) {
    :root {
        --portfolio-card-width: 320px;
        --portfolio-card-height: 440px;
    }

    .portfolio-expanded-title {
        font-size: 2.5rem;
    }
}

@media (max-width: 768px) {
    :root {
        --portfolio-card-width: 280px;
        --portfolio-card-height: 400px;
    }

    .portfolio-expanded-content {
        flex-direction: column;
        overflow-y: auto;
    }

    .portfolio-expanded-image-container {
        flex: 0 0 40vh;
        padding: 2rem;
    }

    .portfolio-expanded-details {
        padding: 0 2rem 2rem 2rem;
        /* Adjusted for mobile */
    }

    .portfolio-expanded-title {
        font-size: 2rem;
    }

    .portfolio-expanded-actions {
        flex-direction: column;
    }

    .portfolio-action-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    :root {
        --portfolio-card-width: 240px;
        --portfolio-card-height: 330px;
        --portfolio-gap: 20px;
    }

    #portfolio {
        padding: 60px 0;
    }

    .portfolio-track {
        padding: 0 20px;
    }

    .portfolio-card-item .card-overlay {
        padding: 1.5rem;
    }

    .portfolio-card-item .card-category {
        font-size: 0.65rem;
    }

    .portfolio-card-item .card-title {
        font-size: 1.1rem;
    }

    .portfolio-expanded-image-container {
        flex: 0 0 35vh;
        padding: 1.5rem;
    }

    .portfolio-expanded-details {
        padding: 0 1.5rem 1.5rem 1.5rem;
    }

    .portfolio-expanded-category {
        font-size: 0.75rem;
    }

    .portfolio-expanded-title {
        font-size: 2rem;
        margin-bottom: 1.5rem;
    }

    .portfolio-expanded-description {
        font-size: 1rem;
        margin-bottom: 2rem;
    }

    .portfolio-tech-badge {
        font-size: 0.65rem;
        padding: 0.3rem 0.6rem;
    }

    .portfolio-close-btn {
        top: 1rem;
        right: 1rem;
        width: 3rem;
        height: 3rem;
        padding: 0.5rem;
    }
}