/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
}

body {
    font-family: 'Inter', sans-serif;
    background: #000002;
    color: #fff;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container — no scrolling, all managed by JS */
.scroll-container {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    position: relative;
}

/* Sections — stacked on top of each other */
.section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
}

/* ============================================
   Dotted Surface (Three.js background)
   ============================================ */
#dotted-surface {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

#dotted-surface.dots-hidden {
    opacity: 0;
}

/* ============================================
   Background Paths (SVG flowing curves)
   ============================================ */
#background-paths {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

#background-paths.paths-visible {
    opacity: 0.1;
}

/* ============================================
   Background Grid (CSS pattern)
   ============================================ */
#background-grid {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    background-image:
        linear-gradient(to right, rgba(255, 255, 255, 0.06) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
    background-size: 24px 24px;
    -webkit-mask-image: radial-gradient(ellipse at center, black, transparent);
    mask-image: radial-gradient(ellipse at center, black, transparent);
}

#background-grid.grid-visible {
    opacity: 1;
}

@keyframes path-flow {
    from {
        stroke-dashoffset: 0;
    }
    to {
        stroke-dashoffset: 2;
    }
}

/* ============================================
   Radial Glow
   ============================================ */
.glow {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 150vw;
    height: 150vh;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    transform: translate(-50%, -50%) scale(1);
    filter: hue-rotate(0deg) brightness(1);
    background: radial-gradient(
        circle,
        rgba(0, 120, 255, 0.95) 0%,
        rgba(0, 90, 220, 0.7) 20%,
        rgba(0, 60, 180, 0.35) 38%,
        rgba(0, 35, 130, 0.12) 52%,
        rgba(0, 20, 80, 0.04) 66%,
        rgba(0, 10, 40, 0.01) 80%,
        transparent 100%
    );
    /* Entry animation */
    animation: glow-enter 1.8s cubic-bezier(0.16, 1, 0.3, 1) 0.3s forwards;
    /* Start hidden for entry */
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6);
}

.glow.glow-ready {
    animation: glow-breathe 4s ease-in-out infinite;
    transition: filter 0.7s cubic-bezier(0.25, 0.1, 0.25, 1),
                transform 0.7s cubic-bezier(0.25, 0.1, 0.25, 1),
                opacity 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* Hero state — centered, full brightness */
.glow.glow-ready:not(.glow-dimmed) {
    filter: hue-rotate(0deg) brightness(1);
    transform: translate(-50%, -50%) scale(1);
}

/* Carousel state — shifted down, colored per project */
.glow.glow-ready.glow-dimmed {
    transform: translate(-50%, -44%) scale(1);
}

.glow.glow-ready.glow-dimmed.glow-blue {
    filter: hue-rotate(0deg) brightness(1);
}

.glow.glow-ready.glow-dimmed.glow-green {
    filter: hue-rotate(-100deg) brightness(1) saturate(1.2);
}

.glow.glow-ready.glow-dimmed.glow-gold {
    filter: hue-rotate(-170deg) brightness(1) saturate(1.5);
}

.glow.glow-ready.glow-dimmed.glow-orange {
    filter: hue-rotate(-190deg) brightness(1) saturate(1.3);
}

@keyframes glow-enter {
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes glow-breathe {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 1;
    }
}

/* ============================================
   Navigation (fixed) — matches case study navbar style
   ============================================ */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px 60px;
}

/* Progressive blur behind navbar — full blur at top, fading to none */
.navbar::before {
    content: '';
    position: absolute;
    inset: 0;
    bottom: -20px;
    z-index: -1;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    -webkit-mask-image: linear-gradient(to bottom, black 0%, black 85%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 0%, black 85%, transparent 100%);
    transition: opacity 0.4s ease;
}

.nav-logo {
    position: absolute;
    left: 60px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    animation: nav-enter-logo 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.15s forwards;
}

@keyframes nav-enter-logo {
    to {
        opacity: 1;
    }
}

.nav-logo img {
    height: 48px;
    width: auto;
    display: block;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Nav exit — staggered slide up (reverse of entrance) */
.nav-exiting .nav-link {
    opacity: 0 !important;
    transform: translateY(-20px) !important;
}

.nav-exiting .nav-link:nth-child(4) { transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1) !important; transition-delay: 0s !important; }
.nav-exiting .nav-link:nth-child(3) { transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important; transition-delay: 0.05s !important; }
.nav-exiting .nav-link:nth-child(2) { transition: opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1), transform 0.45s cubic-bezier(0.16, 1, 0.3, 1) !important; transition-delay: 0.1s !important; }
.nav-exiting .nav-link:nth-child(1) { transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1) !important; transition-delay: 0.15s !important; }

/* ============================================
   Hamburger Menu (hidden on desktop)
   ============================================ */
.hamburger {
    display: none;
}

.mobile-menu {
    display: none;
}

/* ============================================
   Background Controls — right side of navbar
   ============================================ */
.bg-controls {
    position: absolute;
    right: 60px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 10;
    opacity: 0;
    animation: nav-enter-logo 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.35s forwards;
}

.bg-switch,
.bg-visibility {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
}

.bg-switch:hover,
.bg-visibility:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Tooltip — appears below on hover */
.bg-switch::before,
.bg-visibility::before {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.bg-switch:hover::before,
.bg-visibility:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Dimmed when animation is hidden */
.bg-switch.bg-hidden {
    color: rgba(255, 255, 255, 0.3);
}

/* Nav exit — fade controls */
.nav-exiting .bg-controls {
    opacity: 0 !important;
    transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* ============================================
   Social Links — bottom right corner
   ============================================ */
.social-links {
    position: fixed;
    bottom: 40px;
    right: 40px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 50;
}

.social-link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    color: rgba(255, 255, 255, 1);
    font-size: 24px;
    text-decoration: none;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
    opacity: 0;
    animation: social-enter cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.social-link:nth-child(1) { animation-delay: 0.4s; animation-duration: 1.0s; }
.social-link:nth-child(2) { animation-delay: 0.5s; animation-duration: 0.9s; }
.social-link:nth-child(3) { animation-delay: 0.6s; animation-duration: 0.8s; }

@keyframes social-enter {
    from {
        opacity: 0;
        transform: translateX(16px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.social-link:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.08);
}

/* Tooltip — appears to the left on hover */
.social-link::before {
    content: attr(data-tooltip);
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%) translateX(4px);
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.social-link:hover::before {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

@keyframes nav-enter {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    border-radius: 1000px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 16px;
    color: #fff;
    text-decoration: none;
    transition: color 0.2s ease, background 0.2s ease;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(-20px);
    animation: nav-enter cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.nav-link:nth-child(1) { animation-delay: 0.2s; animation-duration: 0.5s; }
.nav-link:nth-child(2) { animation-delay: 0.25s; animation-duration: 0.45s; }
.nav-link:nth-child(3) { animation-delay: 0.3s; animation-duration: 0.4s; }
.nav-link:nth-child(4) { animation-delay: 0.35s; animation-duration: 0.35s; }

.nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
}

.nav-link.active {
    color: #1180f9;
    background: rgba(17, 128, 249, 0.08);
}

/* ============================================
   Hero Section
   ============================================ */
.section-hero {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1;
}

.section-hero.section-hidden {
    pointer-events: none;
}

.hero-content {
    text-align: center;
    width: 824px;
    max-width: 90%;
    opacity: 0;
    transform: scale(0.85);
    animation: hero-enter 1.1s cubic-bezier(0.16, 1, 0.3, 1) 0.3s forwards;
    transition: opacity 0.7s cubic-bezier(0.25, 0.1, 0.25, 1),
                transform 0.7s cubic-bezier(0.25, 0.1, 0.25, 1);
}

@keyframes hero-enter {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.hero-content.entered {
    animation: none;
    opacity: 1;
    transform: scale(1);
}

.hero-content.hero-hidden {
    opacity: 0 !important;
    transform: scale(0.85) !important;
}

.hero-heading {
    font-family: 'Gabarito', sans-serif;
    font-weight: 700;
    font-size: 64px;
    line-height: 1.15;
    color: #fff;
}

.code-icon {
    display: inline-block;
    vertical-align: middle;
    margin-left: 8px;
    width: 31px;
    height: 25px;
}

.footer-info {
    position: absolute;
    bottom: 80px;
    left: 20vw;
    right: 20vw;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    opacity: 0;
    transform: translateY(40px);
    animation: footer-enter 1.1s cubic-bezier(0.16, 1, 0.3, 1) 0.3s forwards;
    transition: opacity 0.7s cubic-bezier(0.25, 0.1, 0.25, 1),
                transform 0.7s cubic-bezier(0.25, 0.1, 0.25, 1);
}

@keyframes footer-enter {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.footer-info.entered {
    animation: none;
    opacity: 1;
    transform: translateY(0);
}

.footer-info.footer-hidden {
    opacity: 0 !important;
    transform: translateY(40px) !important;
}

.footer-text {
    font-family: 'Poppins', sans-serif;
    font-weight: 400;
    font-size: 20px;
    color: #fff;
    max-width: 353px;
    line-height: 1.5;
}

.footer-text:last-child {
    max-width: 285px;
    text-align: end;
}

.footer-link {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: opacity 0.2s ease;
}

.footer-link:hover {
    opacity: 0.7;
}

/* ============================================
   Carousel Section
   ============================================ */
.section-carousel {
    z-index: 1;
    pointer-events: none;
}

.section-carousel.section-active {
    pointer-events: auto;
    z-index: 2;
}

.carousel-viewport {
    position: relative;
    width: 100%;
    height: 100%;
    perspective: 1200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   Project Cards (3D Carousel)
   ============================================ */
a.project-card {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

/* Page exit — fade out content but keep navbar visible */
.page-exit-active .section,
.page-exit-active .social-links {
    opacity: 0;
    transition: opacity 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.page-exit-active #dotted-surface,
.page-exit-active #background-paths,
.page-exit-active #background-grid {
    opacity: 0;
    transition: opacity 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.page-exit-active .glow {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0) !important;
    transition: opacity 0.5s cubic-bezier(0.25, 0.1, 0.25, 1),
                transform 0.5s cubic-bezier(0.25, 0.1, 0.25, 1) !important;
}

.page-exit-active .nav-logo {
    opacity: 0 !important;
    transition: opacity 0.5s cubic-bezier(0.25, 0.1, 0.25, 1) !important;
}

.project-card {
    position: absolute;
    width: 956px;
    max-width: 58%;
    aspect-ratio: 956 / 599;
    border-radius: 8px;
    overflow: hidden;
    /* Default: hidden far right */
    opacity: 1;
    transform: translateX(200%) rotateY(-45deg) scale(0.6);
    z-index: 1;
    pointer-events: none;
}

/* Dimming overlay — avoids using opacity on the card so backdrop-filter works */
.project-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 10;
    border-radius: inherit;
    pointer-events: none;
}

/* Enable transitions after initial positioning */
.carousel-ready .project-card {
    transition: transform 0.7s cubic-bezier(0.25, 0.1, 0.25, 1),
                z-index 0s linear 0.2s;
}

.carousel-ready .project-card::after {
    transition: background 0.7s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* Active center card */
.project-card.pos-center {
    transform: translateX(0) rotateY(0deg) scale(1);
    z-index: 4;
    pointer-events: auto;
}

.project-card.pos-center::after {
    background: rgba(0, 0, 0, 0);
}

/* Left peek card */
.project-card.pos-left {
    transform: translateX(-105%) rotateY(30deg) scale(0.75);
    z-index: 3;
}

.project-card.pos-left::after {
    background: rgba(0, 0, 0, 0.45);
}

/* Right peek card */
.project-card.pos-right {
    transform: translateX(105%) rotateY(-30deg) scale(0.75);
    z-index: 3;
}

.project-card.pos-right::after {
    background: rgba(0, 0, 0, 0.45);
}

/* Far left (hidden) */
.project-card.pos-far-left {
    transform: translateX(-200%) rotateY(45deg) scale(0.6);
    z-index: 1;
}

.project-card.pos-far-left::after {
    background: rgba(0, 0, 0, 1);
}

/* Hero peek — first card visible on the right edge */
.project-card.pos-hero-peek {
    transform: translateX(105%) rotateY(-30deg) scale(0.75);
    z-index: 3;
}

/* Entrance animation — only before carousel transitions are enabled */
.section-carousel:not(.carousel-ready) .project-card.pos-hero-peek {
    animation: card-peek-enter 0.8s cubic-bezier(0.16, 1, 0.3, 1) 1.4s both;
}

@keyframes card-peek-enter {
    from {
        opacity: 0;
        transform: translateX(200%) rotateY(-45deg) scale(0.6);
    }
    to {
        opacity: 1;
        transform: translateX(105%) rotateY(-30deg) scale(0.75);
    }
}

.project-card.pos-hero-peek::after {
    background: rgba(0, 0, 0, 0.45);
}

/* Far right (hidden) */
.project-card.pos-far-right {
    transform: translateX(200%) rotateY(-45deg) scale(0.6);
    z-index: 1;
}

.project-card.pos-far-right::after {
    background: rgba(0, 0, 0, 1);
}

.project-image {
    position: absolute;
    /* bottom: -2rem;
    right: -3rem; */
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    transition: transform 0.4s cubic-bezier(0.25, 0.1, 0.25, 1),
                opacity 0.4s ease;
}

/* Hover: image zoom (center card only) */
.project-card.pos-center:hover .project-image {
    transform: scale(1.05);
}

/* Video overlay — hidden by default, shown on hover */
.project-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 1;
}

.project-card.pos-center:hover .project-video {
    opacity: 1;
}

/* Hide the static image and blur when the card has a video and is hovered */
.project-card.pos-center:hover .project-image.has-video {
    opacity: 0;
}

.project-card:has(.project-video).pos-center:hover .project-blur {
    display: none;
}

/* Tags pill (top-right) — hidden by default, revealed on hover */
.project-tags {
    position: absolute;
    top: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-weight: 400;
    font-size: 20px;
    color: #fff;
    z-index: 2;
    opacity: 0;
    transform: translateY(-12px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.project-card.pos-center:hover .project-tags {
    opacity: 1;
    transform: translateY(0);
}

.tag-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.4);
}

/* Bottom overlay container — hidden by default, revealed on hover */
.project-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 316px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 40px 20px;
    z-index: 2;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.project-card.pos-center:hover .project-overlay {
    opacity: 1;
    transform: translateY(0);
}

/* Blurred image copy — uses filter:blur instead of backdrop-filter for 3D compatibility */
.project-blur {
    position: absolute;
    inset: 0;
    /* Extend beyond edges to prevent blur fringing */
    margin: -20px;
    background: var(--card-bg) center / cover no-repeat;
    /* Align to match the card image — offset for overlay position within card */
    background-position: center bottom;
    filter: blur(12px);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, black 100%);
}

/* Gradient darkening layer */
.project-overlay-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.55) 60%, rgba(0,0,0,0.7) 100%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 40%);
    mask-image: linear-gradient(to bottom, transparent 0%, black 40%);
}

.project-info {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 677px;
}

.project-title {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 48px;
    line-height: 1.5;
    color: #fff;
}

.project-description {
    font-family: 'Poppins', sans-serif;
    font-weight: 400;
    font-size: 20px;
    line-height: 1.5;
    color: #fff;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1200px) {
    .navbar {
        padding: 16px 40px;
    }

    .nav-link {
        padding: 8px 16px;
        font-size: 13px;
    }

    .hero-heading {
        font-size: 52px;
    }

    .footer-info {
        left: 40px;
        right: 40px;
    }

    .project-card {
        max-width: 55%;
    }

    .project-title {
        font-size: 40px;
    }

    .project-description {
        font-size: 18px;
    }

    .project-tags {
        font-size: 16px;
    }
}

@media (max-width: 900px) {
    .navbar {
        padding: 12px 24px;
    }

    .nav-logo {
        left: 24px;
    }

    .bg-controls {
        right: 24px;
    }

    .social-links {
        bottom: 24px;
        right: 24px;
    }

    .nav-link {
        padding: 6px 12px;
        font-size: 12px;
    }

    .nav-logo img {
        height: 40px;
    }

    .hero-content {
        width: 90%;
    }

    .hero-heading {
        font-size: 40px;
    }

    .footer-info {
        left: 24px;
        right: 24px;
        bottom: 50px;
        gap: 40px;
    }

    .footer-text {
        font-size: 16px;
        max-width: 280px;
    }

    .footer-text:last-child {
        max-width: 240px;
    }

    .project-card {
        max-width: 60%;
    }

    .project-card.pos-left {
        transform: translateX(-95%) rotateY(25deg) scale(0.7);
    }

    .project-card.pos-right {
        transform: translateX(95%) rotateY(-25deg) scale(0.7);
    }

    .project-title {
        font-size: 32px;
    }

    .project-description {
        font-size: 16px;
    }

    .project-tags {
        font-size: 14px;
        gap: 8px;
        padding: 6px 12px;
    }

    .project-overlay {
        height: 240px;
        padding: 24px 16px;
    }
}

@media (max-width: 640px) {
    .navbar {
        padding: 2rem;
        z-index: 110;
    }

    .nav-logo {
        left: 16px;
    }

    .social-links {
        bottom: 16px;
        right: 16px;
        gap: 8px;
    }

    .social-link {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .nav-link {
        padding: 1rem;
        font-size: 12px;
    }

    .nav-logo img {
        height: 3rem;
    }

    .hero-heading {
        font-size: 2rem;
    }

    .code-icon {
        width: 20px;
        height: 16px;
    }

    .footer-info {
        flex-direction: column;
        gap: 16px;
        bottom: 4rem;
        left: 16px;
        right: 16px;
    }

    .footer-text {
        font-size: 16px;
    }

    .project-card {
        width: 90vw;
        max-width: 90vw;
        height: 70vh;
        aspect-ratio: auto;
    }

    .project-card.pos-left {
        transform: translateX(-85%) rotateY(20deg) scale(0.65);
        opacity: 0.4;
    }

    .project-card.pos-right {
        transform: translateX(85%) rotateY(-20deg) scale(0.65);
        opacity: 0.4;
    }

    .project-title {
        font-size: 24px;
    }

    .project-description {
        font-size: 14px;
    }

    /* Show tags, overlay, and info by default on center card (no hover on mobile) */
    .project-card.pos-center .project-tags {
        opacity: 1;
        transform: translateY(0);
    }

    .project-card.pos-center .project-overlay {
        opacity: 1;
        transform: translateY(0);
    }

    .project-tags {
        font-size: 14px;
        top: 12px;
        right: 12px;
        background-color: rgba(0, 0, 0, 0.2);
    }

    .project-overlay {
        height: 50%;
        padding: 20px 12px;
    }

    .project-blur {
        -webkit-mask-image: linear-gradient(to bottom, transparent 50%, black 100%);
        mask-image: linear-gradient(to bottom, transparent 50%, black 100%);
    }

    .project-overlay-gradient {
        -webkit-mask-image: linear-gradient(to bottom, transparent 50%, black 100%);
        mask-image: linear-gradient(to bottom, transparent 50%, black 100%);
    }

    .project-info {
        gap: 8px;
    }

    /* Social links — animate from column to row when leaving hero */
    .social-link {
        animation: none;
        opacity: 1;
        transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease,
                    transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    }

    /* Column order: 1 (top), 2 (middle), 3 (bottom-right anchor).
       Move 1 and 2 down+left so all three form a row ending at bottom-right.
       36px icon + 8px gap = 44px per slot. */
    .social-links.social-hidden .social-link:nth-child(1) {
        transform: translate(-88px, 88px);
    }

    .social-links.social-hidden .social-link:nth-child(2) {
        transform: translate(-44px, 44px);
    }

    .bg-controls {
        position: static;
        transform: none;
    }

    .bg-switch,
    .bg-visibility {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }

    /* Hide desktop nav-links, show hamburger */
    .nav-links {
        display: none !important;
    }

    .hamburger {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        position: absolute;
        right: 16px;
        top: 50%;
        transform: translateY(-50%);
        width: 40px;
        height: 40px;
        padding: 8px;
        background: none;
        border: none;
        cursor: pointer;
        z-index: 110;
        opacity: 0;
        animation: nav-enter-logo 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.2s forwards;
    }

    .hamburger-line {
        display: block;
        width: 100%;
        height: 2px;
        background: #fff;
        border-radius: 2px;
        transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                    opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1);
        transform-origin: center;
    }

    /* Hamburger → X animation */
    .hamburger.is-open .hamburger-line:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    .hamburger.is-open .hamburger-line:nth-child(2) {
        opacity: 0;
    }

    .hamburger.is-open .hamburger-line:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    /* Mobile menu overlay */
    .mobile-menu {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2rem;
        position: fixed;
        inset: 0;
        z-index: 105;
        background: rgba(0, 0, 2, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .mobile-menu.menu-open {
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-menu-link {
        font-family: 'Inter', sans-serif;
        font-weight: 600;
        font-size: 24px;
        color: #fff;
        text-decoration: none;
        padding: 1rem 3rem;
        border-radius: 1000px;
        transition: color 0.2s ease, background 0.2s ease;
        opacity: 0;
        transform: translateY(20px);
    }

    .mobile-menu.menu-open .mobile-menu-link {
        animation: nav-enter 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }

    .mobile-menu.menu-open .mobile-menu-link:nth-child(1) { animation-delay: 0.1s; }
    .mobile-menu.menu-open .mobile-menu-link:nth-child(2) { animation-delay: 0.15s; }
    .mobile-menu.menu-open .mobile-menu-link:nth-child(3) { animation-delay: 0.2s; }

    /* Close animation — links slide down + fade out, overlay fades simultaneously */
    .mobile-menu.menu-closing {
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.15s;
    }

    .mobile-menu.menu-closing .mobile-menu-link {
        opacity: 1;
        transform: translateY(0);
        animation: menu-exit 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }

    .mobile-menu.menu-closing .mobile-menu-link:nth-child(3) { animation-delay: 0s; }
    .mobile-menu.menu-closing .mobile-menu-link:nth-child(2) { animation-delay: 0.05s; }
    .mobile-menu.menu-closing .mobile-menu-link:nth-child(1) { animation-delay: 0.1s; }

    @keyframes menu-exit {
        from {
            opacity: 1;
            transform: translateY(0);
        }
        to {
            opacity: 0;
            transform: translateY(12px);
        }
    }

    .mobile-menu-link:hover {
        background: rgba(255, 255, 255, 0.06);
    }

    .mobile-menu-link.active {
        color: #1180f9;
        background: rgba(17, 128, 249, 0.08);
    }

    /* Nav exit — also animate hamburger out */
    .nav-exiting .hamburger {
        opacity: 0 !important;
        transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1) !important;
    }
}
