/* ===================================
   PROJECTS SECTION - MODERN SCROLL-SNAP CAROUSEL

   This file contains all styles for the projects carousel.
   Separated for better organization and analysis.

   Features:
   - Native CSS scroll-snap for smooth scrolling
   - Advanced glassmorphism cards
   - 3D perspective transforms
   - Progressive enhancement with JavaScript
   - Full accessibility support
   - Responsive design for all devices
   - PREMIUM HEADER with multi-layer title effects
   =================================== */

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

.projects-section {
    background: var(--color-bg-tertiary);
    position: relative;
    padding: var(--space-32) 0;
    overflow: hidden;
}

/* Mobile override - reduce top spacing */
@media (max-width: 768px) {
    .projects-section {
        padding: var(--space-12) 0;
    }
}

/* ===== PREMIUM SECTION HEADER ===== */

.projects-section .section-header {
    position: relative;
    padding: 80px 20px 60px;
    margin-bottom: 40px;
    text-align: center;
    overflow: visible;
    z-index: 1;
}

/* Static Background Orbs - NO ANIMATION */
.projects-section .section-header::before,
.projects-section .section-header::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.2;
    pointer-events: none;
    z-index: -1;
}

.projects-section .section-header::before {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle,
        rgba(89, 127, 215, 0.6) 0%,
        rgba(137, 207, 240, 0.3) 50%,
        transparent 100%);
    top: -150px;
    left: -100px;
}

.projects-section .section-header::after {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle,
        rgba(137, 207, 240, 0.5) 0%,
        rgba(89, 127, 215, 0.3) 50%,
        transparent 100%);
    top: -100px;
    right: -80px;
}

/* Section Title - Clean and simple */
.projects-section .section-title {
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 900;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-6);
    line-height: 1.1;
    color: #597fd7; /* Primary Blue from palette */
}

/* Hide Section Subtitle */
.projects-section .section-subtitle {
    display: none;
}

/* ===== CAROUSEL WRAPPER ===== */

/* Carousel Wrapper - Container with 3D perspective */
.carousel-wrapper {
    position: relative;
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    padding: 0;
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.8s var(--ease-out-expo) 0.3s forwards;

    /* Remove 3D perspective to avoid WebGL conflicts */
    /* perspective: removed for performance */
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== CAROUSEL TRACK ===== */

/* Scroll-Snap Container */
.carousel-track {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    gap: var(--space-6);

    /* FIXED: Padding accounts for gap in centering calculation
     * Formula: (viewport - card - gap) / 2 - offset
     * Adjusted to move cards slightly left
     */
    padding: var(--space-8) max(calc((100vw - 500px - var(--space-6)) / 2 - 80px), var(--space-4));

    /* FIXED: Scroll-padding offsets container padding for accurate snap points
     * This tells scroll-snap where the "visual center" is
     */
    scroll-padding-inline: max(calc((100vw - 500px - var(--space-6)) / 2 - 80px), var(--space-4));

    cursor: grab;

    /* FIXED: Re-enable GPU acceleration for smooth scrolling
     * preserve-3d is safe when not mixing with WebGL on same element
     */
    transform-style: preserve-3d;
    will-change: scroll-position;

    /* FIXED: Isolate from WebGL contexts to prevent GPU layer contention */
    isolation: isolate;
    contain: layout style paint;
}

.carousel-track:active {
    cursor: grabbing;
}

/* Hide scrollbar for Chrome/Safari/Edge */
.carousel-track::-webkit-scrollbar {
    display: none;
}

/* ===== PROJECT CARDS ===== */

/* Project Cards - Simplified for better scroll-snap compatibility */
.project-card {
    scroll-snap-align: center;
    scroll-snap-stop: always;

    /* FIXED: Use fixed 500px width on desktop, only scale down on mobile
     * This ensures padding calculations match actual card width
     */
    flex: 0 0 500px;
    width: 500px;
    max-width: 500px;
    min-width: 500px;

    display: flex;
    flex-direction: column;
    padding: var(--space-8);
    position: relative;

    /* Advanced Glassmorphism - Optimized for performance */
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.1) 0%,
        rgba(255, 255, 255, 0.05) 100%);
    backdrop-filter: blur(10px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 24px;

    /* Initial state - inactive cards with reduced opacity
     * Animation will set this to 0.3, then .entered class will maintain it
     */
    transform: translateY(10px);
    opacity: 0;

    /* Transitions with spring physics */
    transition:
        transform 0.6s var(--ease-spring),
        opacity 0.5s var(--ease-out-expo),
        background 0.3s var(--ease-out-expo),
        border-color 0.3s var(--ease-out-expo),
        box-shadow 0.5s var(--ease-out-expo);

    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);

    /* FIXED: Stable GPU layer for smooth rendering */
    will-change: transform, opacity;
    backface-visibility: hidden;

    /* Staggered entrance animation */
    animation: cardEnter var(--duration-slowest) var(--ease-spring) forwards;
}

/* Staggered animation delays */
.project-card:nth-child(1) { animation-delay: 0.5s; }
.project-card:nth-child(2) { animation-delay: 0.6s; }
.project-card:nth-child(3) { animation-delay: 0.7s; }
.project-card:nth-child(4) { animation-delay: 0.8s; }
.project-card:nth-child(5) { animation-delay: 0.9s; }

@keyframes cardEnter {
    0% {
        opacity: 0;
        transform: translateY(80px);
    }
    60% {
        transform: translateY(-10px);
    }
    100% {
        opacity: 0.3;
        transform: translateY(10px);
    }
}

/* FIXED: Prevent re-triggering entrance animation after it completes
 * Once a card has animated in, it should only use CSS transitions
 * Force inactive cards to have low opacity
 */
.project-card.entered:not(.active) {
    animation: none !important;
    opacity: 0.3 !important;
    transform: translateY(10px);
}

/* Active Card - Clear and crisp with strong visual emphasis */
.project-card.active {
    /* FIXED: No scale on root to preserve scroll-snap centering */
    transform: translateY(0);
    opacity: 1 !important; /* Override animation-fill-mode forwards */

    /* Enhanced glassmorphism for active - more visible */
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.15) 0%,
        rgba(255, 255, 255, 0.10) 100%);
    backdrop-filter: blur(20px) saturate(200%);

    /* ADDED: Blue accent border for clear activation signal (2025 UX best practice) */
    border: 2px solid rgba(0, 122, 255, 0.6);

    /* ENHANCED: Multi-layer shadow with strong visible blue glow */
    box-shadow:
        0 30px 90px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset,
        0 0 80px rgba(0, 122, 255, 0.4),  /* Stronger glow (was 0.15) */
        0 0 0 4px rgba(0, 122, 255, 0.15); /* Outer glow ring */

    /* Clear entrance animation to prevent opacity conflict */
    animation: none;
}

/* Scale effect applied to inner content only - doesn't affect scroll-snap centering */
.project-card.active .project-content {
    transform: scale(1.03);
    transition: transform 0.3s var(--ease-out-expo);
}

/* DISABLED: activePulse causes scroll-snap to recalculate constantly */
/* @keyframes activePulse {
    0%, 100% {
        transform: scale(1) translateY(0);
    }
    50% {
        transform: scale(1.01) translateY(-5px);
    }
} */

/* Hover Effect - Subtle lift (inactive cards get slightly more visible and clickable) */
.project-card.entered:not(.active):hover {
    opacity: 0.5 !important;
    transform: translateY(5px) scale(1.02);
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.15) 0%,
        rgba(255, 255, 255, 0.1) 100%);
    border-color: rgba(255, 255, 255, 0.3);
    cursor: pointer;

    box-shadow:
        0 35px 100px rgba(0, 0, 0, 0.35),
        0 0 0 1px rgba(255, 255, 255, 0.15) inset,
        0 0 60px rgba(0, 122, 255, 0.2);
}

/* Click feedback for inactive cards */
.project-card.entered:not(.active):active {
    transform: translateY(8px) scale(0.98);
    opacity: 0.6 !important;
}

.project-card.active:hover {
    transform: translateY(-12px);
    border-color: rgba(0, 122, 255, 0.8); /* Brighter border on hover */

    box-shadow:
        0 40px 120px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.15) inset,
        0 0 100px rgba(0, 122, 255, 0.5),  /* Even stronger glow on hover */
        0 0 0 4px rgba(0, 122, 255, 0.25); /* Brighter outer ring */
}

.project-card.active:hover .project-content {
    transform: scale(1.05);
}

/* ===== PROJECT MEDIA & IMAGES ===== */

/* Project Media - Enhanced with parallax */
.project-media {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    background: var(--color-bg-card);
    border-radius: 20px;
    border: 1px solid var(--color-border);
    margin-bottom: var(--space-6);
    overflow: hidden;
    flex-shrink: 0;
    transform-style: flat;

    /* Subtle gradient overlay */
    box-shadow: inset 0 -50px 50px -50px rgba(0, 122, 255, 0.2);
}

/* Project Image - Real images with premium effects */
.project-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    position: absolute;
    inset: 0;
    z-index: 2;
    transition: transform 0.8s var(--ease-out-expo);
    will-change: transform;
}

/* Pill DB image - positioned lower */
#project-2 .project-image {
    object-position: center 24%;
}

/* WaddleGo image - larger scale and positioned higher */
#project-1 .project-image {
    transform: scale(1.5);
    object-position: center 45%;
}

/* Zoom effect on hover */
.project-card:hover .project-image {
    transform: scale(1.08);
}

/* WaddleGo hover - maintain larger scale */
#project-1:hover .project-image {
    transform: scale(1.4);
}

/* Active card image - animation disabled for scroll-snap stability */
/* .project-card.active .project-image {
    animation: imageFloat 8s ease-in-out infinite;
} */

@keyframes imageFloat {
    0%, 100% {
        transform: scale(1.02) translate(0, 0);
    }
    25% {
        transform: scale(1.03) translate(-2px, -2px);
    }
    50% {
        transform: scale(1.02) translate(0, -3px);
    }
    75% {
        transform: scale(1.03) translate(2px, -2px);
    }
}

/* Animated background gradient - for cards with images */
.project-image-placeholder {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg,
        rgba(0, 122, 255, 0.15) 0%,
        rgba(88, 86, 214, 0.15) 50%,
        rgba(255, 159, 10, 0.15) 100%);
    opacity: 0.3;
    z-index: 1;
    transition: opacity 0.4s var(--ease-out-expo);
    mix-blend-mode: overlay;
    pointer-events: none;
}

/* Less visible on hover to see image better */
.project-card:hover .project-image-placeholder {
    opacity: 0.15;
}

/* Slightly more visible on active */
.project-card.active .project-image-placeholder {
    opacity: 0.25;
}

/* For cards with emojis (no img), make placeholder more visible */
.project-media:has(.project-icon):not(:has(.project-image)) .project-image-placeholder {
    opacity: 0.5;
    mix-blend-mode: normal;
}

.project-card:hover .project-media:has(.project-icon):not(:has(.project-image)) .project-image-placeholder {
    transform: scale(1.1);
}

/* DISABLED: gradientShift interferes with scroll-snap */
/* .project-card.active .project-media:has(.project-icon):not(:has(.project-image)) .project-image-placeholder {
    animation: gradientShift 8s ease-in-out infinite;
} */

@keyframes gradientShift {
    0%, 100% {
        transform: translate(0, 0);
    }
    25% {
        transform: translate(-5px, 5px);
    }
    50% {
        transform: translate(0, 10px);
    }
    75% {
        transform: translate(5px, 5px);
    }
}

/* ===== PROJECT ICONS ===== */

/* Project Icon - For emoji fallbacks */
.project-icon {
    font-size: 4rem;
    z-index: 3;
    position: relative;
    transition:
        transform 0.6s var(--ease-spring),
        filter 0.4s var(--ease-out-expo);
    filter: drop-shadow(0 4px 12px rgba(0, 122, 255, 0.3));

    /* Entrance animation */
    animation: iconEnter 1s var(--ease-bounce) backwards;
}

@keyframes iconEnter {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Icon on hover - simple scale (only for emoji cards) */
.project-card:hover .project-media:not(:has(.project-image)) .project-icon {
    transform: scale(1.1);
    filter: drop-shadow(0 8px 20px rgba(0, 122, 255, 0.5));
}

/* Active icon with subtle pulse (only for emoji cards) */
.project-card.active .project-media:not(:has(.project-image)) .project-icon {
    transform: scale(1.1);
    filter: drop-shadow(0 6px 16px rgba(0, 122, 255, 0.6));
    animation: iconPulse 3s var(--ease-smooth) infinite;
}

@keyframes iconPulse {
    0%, 100% {
        transform: scale(1.1);
    }
    50% {
        transform: scale(1.15);
    }
}

/* ===== PROJECT CONTENT ===== */

/* Project Content */
.project-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.project-title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    margin-bottom: var(--space-3);
    background: linear-gradient(135deg, var(--color-text-primary) 0%, var(--color-text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.project-description {
    color: var(--color-text-secondary);
    margin-bottom: var(--space-4);
    line-height: 1.6;
    font-size: var(--font-size-base);
    flex-grow: 1;
}

.project-tech {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.tech-tag {
    padding: var(--space-2) var(--space-3);
    background: rgba(0, 122, 255, 0.15);
    color: var(--color-primary);
    border: 1px solid rgba(0, 122, 255, 0.3);
    border-radius: 12px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    transition: all var(--duration-fast) var(--ease-out-expo);
    white-space: nowrap;
}

.tech-tag:hover {
    background: rgba(0, 122, 255, 0.25);
    transform: translateY(-2px);
}

/* ===== PROJECT ACTIONS ===== */

/* Project Actions */
.project-actions {
    display: flex;
    justify-content: center;
    gap: var(--space-3);
    margin-top: auto;
    width: 100%;
}

.project-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    font-size: var(--font-size-sm);
    transition: all var(--duration-normal) var(--ease-out-expo);
    position: relative;
    overflow: hidden;
}

.project-link.primary {
    background: var(--color-primary);
    color: white;
    border: 1px solid var(--color-primary);
}

.project-link.primary:hover {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 122, 255, 0.4);
}

.project-link svg {
    transition: transform var(--duration-fast) var(--ease-out-expo);
}

.project-link:hover svg {
    transform: translateX(3px);
}

/* ===== NAVIGATION BUTTONS ===== */

/* Navigation Buttons */
.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: rgba(10, 25, 41, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid var(--color-border);
    border-radius: 50%;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out-expo);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: var(--z-content);
    opacity: 0;
    animation: fadeIn 0.5s var(--ease-out-expo) 1s forwards;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

/* Hidden state for navigation buttons at carousel limits */
.carousel-nav.hidden {
    opacity: 0 !important;
    pointer-events: none;
}

.carousel-nav:hover:not(:disabled):not(.hidden) {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--color-border-hover);
    transform: translateY(-50%) scale(1.1);
}

.carousel-nav:active:not(:disabled):not(.hidden) {
    transform: translateY(-50%) scale(0.95);
}

.carousel-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.carousel-prev {
    left: -24px;
}

.carousel-next {
    right: -5000px;
}

/* ===== CAROUSEL INDICATORS ===== */

/* Carousel Indicators - Ultra Enhanced */
.carousel-indicators {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    margin-top: var(--space-8);
    opacity: 0;
    animation: fadeIn 0.5s var(--ease-out-expo) 1.2s forwards;
    position: relative;
}

/* Counter with flip animation */
.carousel-counter {
    display: flex;
    align-items: baseline;
    gap: var(--space-1);
    font-size: var(--font-size-lg);
    color: var(--color-text-secondary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    position: relative;
}

.current-slide {
    color: var(--color-primary);
    font-size: 1.5em;
    font-weight: 700;
    display: inline-block;
    transition: transform 0.3s var(--ease-spring);
    filter: drop-shadow(0 0 8px rgba(0, 122, 255, 0.5));
}

/* Flip animation when changing */
.current-slide.changing {
    animation: flipNumber 0.6s var(--ease-spring);
}

@keyframes flipNumber {
    0% {
        transform: rotateX(0deg) scale(1);
    }
    50% {
        transform: rotateX(90deg) scale(0.8);
        opacity: 0;
    }
    51% {
        transform: rotateX(-90deg) scale(0.8);
        opacity: 0;
    }
    100% {
        transform: rotateX(0deg) scale(1);
        opacity: 1;
    }
}

.separator {
    color: var(--color-text-tertiary);
    opacity: 0.6;
}

.total-slides {
    font-size: 1em;
}

/* Indicator dots container with progress bar */
.indicator-dots {
    display: flex;
    gap: var(--space-2);
    position: relative;
    padding: var(--space-2);
}

/* Animated progress bar behind dots */
.indicator-dots::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: linear-gradient(90deg,
        var(--color-primary) 0%,
        rgba(0, 122, 255, 0.5) 100%);
    border-radius: 1px;
    transition: all 0.6s var(--ease-spring);
    box-shadow: 0 0 10px rgba(0, 122, 255, 0.5);
}

/* Progress bar animation based on active dot */
.carousel-indicators:has(.indicator-dot:nth-child(1).active) .indicator-dots::before {
    width: 20%;
    left: 0%;
}
.carousel-indicators:has(.indicator-dot:nth-child(2).active) .indicator-dots::before {
    width: 40%;
    left: 20%;
}
.carousel-indicators:has(.indicator-dot:nth-child(3).active) .indicator-dots::before {
    width: 60%;
    left: 40%;
}
.carousel-indicators:has(.indicator-dot:nth-child(4).active) .indicator-dots::before {
    width: 80%;
    left: 60%;
}
.carousel-indicators:has(.indicator-dot:nth-child(5).active) .indicator-dots::before {
    width: 100%;
    left: 80%;
}

/* Enhanced indicator dots */
.indicator-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--color-border);
    background: transparent;
    cursor: pointer;
    transition:
        all 0.4s var(--ease-spring),
        box-shadow 0.3s var(--ease-out-expo);
    padding: 0;
    position: relative;
    z-index: 1;
}

/* Glow effect on dots */
.indicator-dot::before {
    content: '';
    position: absolute;
    inset: -4px;
    background: radial-gradient(circle,
        rgba(0, 122, 255, 0.4) 0%,
        transparent 70%);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s var(--ease-out-expo);
}

.indicator-dot.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    transform: scale(1.4);
    box-shadow: 0 0 12px rgba(0, 122, 255, 0.6);
}

.indicator-dot.active::before {
    opacity: 1;
    animation: glowPulse 2s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.3);
        opacity: 1;
    }
}

.indicator-dot:hover:not(.active) {
    border-color: var(--color-border-hover);
    transform: scale(1.2);
    box-shadow: 0 0 8px rgba(0, 122, 255, 0.3);
}

.indicator-dot:hover::before {
    opacity: 0.5;
}

/* ===== ACCESSIBILITY ===== */

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Accessibility - Focus States */
.carousel-track:focus {
    outline: 3px solid var(--color-primary);
    outline-offset: 4px;
}

.carousel-track:focus:not(:focus-visible) {
    outline: none;
}

.project-card:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 4px;
    box-shadow: 0 0 0 6px rgba(89, 127, 215, 0.2);
}

.carousel-nav:focus-visible,
.indicator-dot:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
}

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

/* Reduced Motion Support */
/* ===== RESPONSIVE HEADER STYLES ===== */

/* Mobile - Small Screens (< 480px) */
@media (max-width: 480px) {
    .projects-section .section-header {
        padding: 30px 16px 30px;
        margin-bottom: 20px;
        text-align: center !important;
    }

    .projects-section .section-header::before {
        width: 250px;
        height: 250px;
        top: -100px;
        left: -80px;
    }

    .projects-section .section-header::after {
        width: 200px;
        height: 200px;
        top: -60px;
        right: -60px;
    }

    .projects-section .section-title {
        font-size: clamp(2rem, 8vw, 2.5rem);
        margin-bottom: var(--space-4);
        text-align: center !important;
    }

    .projects-section .section-title::after {
        width: 80px;
        height: 3px;
        bottom: -8px;
    }

    .projects-section .section-subtitle {
        font-size: 0.95rem;
        padding: 12px 20px;
        border-radius: 16px;
    }
}

/* Tablet (481px - 1024px) */
@media (min-width: 481px) and (max-width: 1024px) {
    .projects-section .section-header {
        padding: 40px 24px 35px;
        margin-bottom: 28px;
        text-align: center !important;
    }

    .projects-section .section-header::before {
        width: 320px;
        height: 320px;
        top: -120px;
        left: -70px;
    }

    .projects-section .section-header::after {
        width: 280px;
        height: 280px;
        top: -80px;
        right: -60px;
    }

    .projects-section .section-title {
        font-size: clamp(2.25rem, 6vw, 3.5rem);
        text-align: center !important;
    }

    .projects-section .section-title::after {
        width: 100px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .carousel-track {
        scroll-behavior: auto;
    }

    .project-card,
    .carousel-nav,
    .indicator-dot {
        transition: none;
        animation: none;
    }

    .carousel-wrapper {
        animation: none;
        opacity: 1;
        transform: none;
    }
}

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

/* Small Mobile (<480px) */
@media (max-width: 480px) {
    .carousel-wrapper {
        padding: 0 var(--space-4);
    }

    .carousel-track {
        gap: var(--space-4);
        /* FIXED: Mobile cards are 320px, padding accounts for gap - moved left */
        padding: var(--space-6) max(calc((100vw - 320px - var(--space-4)) / 2 - 40px), var(--space-2));
        scroll-padding-inline: max(calc((100vw - 320px - var(--space-4)) / 2 - 40px), var(--space-2));
    }

    .project-card {
        /* FIXED: Fixed width for consistent centering */
        flex: 0 0 320px;
        width: 320px;
        max-width: 320px;
        min-width: 320px;
        padding: var(--space-6);
    }

    .project-media {
        height: 140px;
    }

    .project-icon {
        font-size: 3rem;
    }

    .project-title {
        font-size: var(--font-size-xl);
    }

    .project-description {
        font-size: var(--font-size-sm);
    }

    .carousel-nav {
        width: 40px;
        height: 40px;
    }

    .carousel-prev {
        left: -16px;
    }

    .carousel-next {
        right: -38px;
    }
}

/* Mobile (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .carousel-wrapper {
        padding: 0 var(--space-6);
    }

    .carousel-track {
        /* FIXED: Tablet cards are 420px, padding accounts for gap - moved left */
        padding: var(--space-8) max(calc((100vw - 420px - var(--space-6)) / 2 - 60px), var(--space-4));
        scroll-padding-inline: max(calc((100vw - 420px - var(--space-6)) / 2 - 60px), var(--space-4));
    }

    .project-card {
        /* FIXED: Fixed width for consistent centering */
        flex: 0 0 420px;
        width: 420px;
        max-width: 420px;
        min-width: 420px;
    }

    .project-media {
        height: 160px;
    }

    .carousel-prev {
        left: -20px;
    }

    .carousel-next {
        right: -45px;
    }
}

/* Tablet (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .carousel-wrapper {
        padding: 0 var(--space-8);
    }

    .carousel-track {
        /* FIXED: Tablet cards are 480px, padding accounts for gap - moved left */
        padding: var(--space-8) max(calc((100vw - 480px - var(--space-6)) / 2 - 70px), var(--space-4));
        scroll-padding-inline: max(calc((100vw - 480px - var(--space-6)) / 2 - 70px), var(--space-4));
    }

    .project-card {
        /* FIXED: Fixed width for consistent centering */
        flex: 0 0 480px;
        width: 480px;
        max-width: 480px;
        min-width: 480px;
    }
}

/* Large Desktop (>1441px) */
@media (min-width: 1441px) {
    .carousel-wrapper {
        max-width: 1400px;
    }

    .carousel-track {
        /* FIXED: Large desktop cards are 550px, padding accounts for gap - moved left */
        padding: var(--space-8) max(calc((100vw - 550px - var(--space-6)) / 2 - 90px), var(--space-4));
        scroll-padding-inline: max(calc((100vw - 550px - var(--space-6)) / 2 - 90px), var(--space-4));
    }

    .project-card {
        /* FIXED: Fixed width for consistent centering */
        flex: 0 0 550px;
        width: 550px;
        max-width: 550px;
        min-width: 550px;
        padding: var(--space-10);
    }

    .project-media {
        height: 220px;
    }

    .project-icon {
        font-size: 5rem;
    }

    .project-title {
        font-size: var(--font-size-3xl);
    }

    .carousel-prev {
        left: -32px;
    }

    .carousel-next {
        right: -80px;
    }
}

/* ========================================
   iPHONE XR / 11 OPTIMIZATION (376px-480px)
   ======================================== */
@media (min-width: 376px) and (max-width: 480px) {
    /* Carousel track - Adjust for medium mobile cards */
    .carousel-track {
        flex: 0 0 360px;
        width: 360px;
        padding: var(--space-6) max(calc((100vw - 360px - var(--space-4)) / 2 - 30px), var(--space-3));
        scroll-padding-inline: max(calc((100vw - 360px - var(--space-4)) / 2 - 30px), var(--space-3));
    }

    /* Project Cards - Medium size */
    .project-card {
        flex: 0 0 360px;
        width: 360px;
        max-width: 360px;
        min-width: 360px;
        padding: var(--space-6);
    }

    .project-media {
        height: 150px;
    }

    .project-icon {
        font-size: 2.75rem;
    }

    .project-title {
        font-size: var(--font-size-xl);
    }

    .project-description {
        font-size: var(--font-size-sm);
    }

    /* Navigation - Better touch targets */
    .carousel-nav {
        width: 44px;
        height: 44px;
    }

    .carousel-prev {
        left: -18px;
    }

    .carousel-next {
        right: -40px;
    }
}

/* ========================================
   iPHONE SE OPTIMIZATION (320px-375px)
   ======================================== */
@media (max-width: 375px) {
    /* Carousel track - Adjust for smaller cards */
    .carousel-track {
        flex: 0 0 300px;
        width: 300px;
        padding: var(--space-6) max(calc((100vw - 300px - var(--space-4)) / 2 - 30px), var(--space-2));
        scroll-padding-inline: max(calc((100vw - 300px - var(--space-4)) / 2 - 30px), var(--space-2));
    }

    /* Project Cards - Smaller */
    .project-card {
        flex: 0 0 300px;
        width: 300px;
        max-width: 300px;
        min-width: 300px;
        padding: var(--space-5);
    }

    .project-media {
        height: 120px;
    }

    .project-icon {
        font-size: 2.5rem;
    }

    .project-title {
        font-size: var(--font-size-lg);
    }

    .project-description {
        font-size: 0.8125rem;
        line-height: 1.6;
    }

    .tech-tag {
        padding: var(--space-1) var(--space-2);
        font-size: 0.6875rem;
    }

    /* Navigation - Increase to 44×44px for proper touch target */
    .carousel-nav {
        width: 44px;
        height: 44px;
    }

    .carousel-prev {
        left: -18px;
    }

    .carousel-next {
        right: -38px;
    }

    /* Carousel indicators - Slightly larger for better touch */
    .carousel-indicator {
        width: 8px;
        height: 8px;
    }

    .carousel-indicator.active {
        width: 24px;
    }
}
