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

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

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

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 50% 60%, rgba(0, 120, 255, 0.35) 0%, transparent 100%);
    pointer-events: none;
    z-index: 0;
}

/* ============================================
   Dotted Surface
   ============================================ */
#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;
    }
}

/* ============================================
   Navigation
   ============================================ */
.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;
}

.hamburger {
    display: none;
}

.mobile-menu {
    display: none;
}

.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-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; }

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

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

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

/* Nav exit */
.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; }

/* ============================================
   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;
}

/* ============================================
   Carousel (replicated from home page)
   ============================================ */
.carousel-viewport {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    perspective: 1200px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

/* ============================================
   Project Cards (3D Carousel)
   ============================================ */
.project-card {
    position: absolute;
    width: 956px;
    max-width: 58%;
    height: 599px;
    max-height: 36.3vw;
    border-radius: 8px;
    overflow: hidden;
    opacity: 1;
    transform: translateX(0) rotateY(0deg) scale(0.5);
    z-index: 0;
    pointer-events: none;
    cursor: pointer;
}

/* Dimming overlay */
.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);
}

/* Back card (hidden behind center) */
.project-card.pos-back {
    transform: translateX(0) rotateY(0deg) scale(0.5);
    z-index: 0;
}

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

/* Placeholder for empty cards */
.project-placeholder {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Video on card */
.project-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    /* object-fit: cover; */
    border-radius: 8px;
    z-index: 1;
    background: black;
}

/* Full-height card (Clarity) — desktop only */
.project-card.card-full-height {
    height: 100%;
}

/* Hover: scale (center card only) */
.project-card.pos-center:hover {
    transform: translateX(0) rotateY(0deg) scale(1.02);
}

/* Page exit */
.page-exit-active .carousel-viewport,
.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 .nav-logo {
    opacity: 0 !important;
    transition: opacity 0.5s cubic-bezier(0.25, 0.1, 0.25, 1) !important;
}

/* ============================================
   Social Links
   ============================================ */
.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);
}

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

.modal-overlay.modal-open {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    position: relative;
    width: 80%;
    max-height: 85vh;
    background: #fff;
    border: none;
    border-radius: 12px;
    overflow-y: auto;
    transform: translateY(30px) scale(0.96);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    scrollbar-width: none;
}

.modal-content::-webkit-scrollbar {
    display: none;
}

.modal-overlay.modal-open .modal-content {
    transform: translateY(0) scale(1);
}

/* When opening via card animation, snap content to final position immediately */
.modal-overlay.modal-animated .modal-content {
    transform: translateY(0) scale(1);
    transition: none;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.06);
    color: #030b2a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    z-index: 10;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.12);
}

.modal-body {
    padding: 50px 80px 80px;
    font-family: 'Parkinsans', sans-serif;
    color: #030b2a;
    display: flex;
    flex-direction: column;
    gap: 40px;
    line-height: 1.5;
    font-size: 16px;
}

.modal-label {
    color: #AA37F2;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 0;
}

/* Non-Neon-Drift modals — black titles and labels */
.modal-body > .modal-label:first-child:not(.modal-fade-in) {
    color: #030b2a;
}

.modal-body > .modal-label:first-child:not(.modal-fade-in) ~ .modal-meta .modal-label {
    color: #030b2a;
}

/* Reduce gap between title and video */
.modal-label + .modal-video-target {
    margin-top: -20px;
}

/* Target slot where the flying video lands */
.modal-video-target {
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
}

.modal-video-target video {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 10px;
    background: black;
}

.modal-video-short {
    width: 100%;
    background: #dde3ec;
    border-radius: 10px;
    overflow: hidden;
}

.modal-video-short video {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 10px;
}

/* Flying video — animates from card to modal */
.flying-video {
    position: fixed;
    z-index: 300;
    border-radius: 10px;
    overflow: hidden;
    /* Force clipping during GPU-composited animation */
    -webkit-mask-image: -webkit-radial-gradient(white, black);
    mask-image: radial-gradient(white, black);
    transition: left 0.5s cubic-bezier(0.16, 1, 0.3, 1),
                top 0.5s cubic-bezier(0.16, 1, 0.3, 1),
                width 0.5s cubic-bezier(0.16, 1, 0.3, 1),
                height 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.flying-video video {
    width: 100%;
    height: 100%;
    display: block;
    background: black;
}

/* Modal content fade-in for elements after the video */
.modal-fade-in {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.modal-overlay.modal-open .modal-fade-in.revealed {
    opacity: 1;
    transform: translateY(0);
}

.modal-video-short p,
.modal-video-large p {
    font-size: 36px;
    font-weight: 400;
}

.modal-meta {
    display: flex;
    gap: 129px;
    align-items: flex-start;
}

.modal-meta-overview {
    flex: 1;
    min-width: 0;
}

.modal-meta-overview p:not(.modal-label) {
    margin-bottom: 8px;
}

.modal-meta-sidebar {
    width: 197px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 24px;
}

.modal-meta-sidebar p:not(.modal-label) {
    margin-bottom: 0;
}

.modal-video-large {
    width: 100%;
    height: 500px;
    background: #dde3ec;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

}

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

    .nav-logo {
        left: 24px;
    }

    .bg-controls {
        right: 24px;
    }

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

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

}

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

    .nav-logo {
        left: 16px;
    }

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

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

    .nav-links {
        display: none !important;
    }

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

    .project-card {
        width: 90vw;
        max-width: 90vw;
        height: 70vh;
        max-height: none;
    }

    .project-card.card-full-height {
        height: 70vh;
    }

    .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;
    }

    .social-links {
        display: none;
    }

    /* Modal — mobile scaling */
    .modal-content {
        width: 95%;
        max-height: 90vh;
        border-radius: 10px;
    }

    .modal-body {
        padding: 40px 20px 32px;
        gap: 24px;
        font-size: 14px;
    }

    .modal-label {
        font-size: 14px;
    }

    .modal-close {
        top: 12px;
        right: 12px;
        width: 32px;
        height: 32px;
    }

    .modal-close svg {
        width: 18px;
        height: 18px;
    }

    .modal-meta {
        flex-direction: column;
        gap: 24px;
    }

    .modal-meta-sidebar {
        width: 100%;
    }

    .modal-video-short p,
    .modal-video-large p {
        font-size: 20px;
    }

    .modal-label + .modal-video-target {
        margin-top: -12px;
    }

    /* Hamburger button */
    .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);
    }

    .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);
        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;
        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.active {
        color: #1180f9;
        background: rgba(17, 128, 249, 0.08);
    }

    /* Nav exit — fade hamburger */
    .nav-exiting .hamburger {
        opacity: 0 !important;
        transition: opacity 0.4s ease;
    }
}
