:root {
    --color-abyss: #010a15;
    --color-ocean: #051c35;
    --color-cyan: #0ff0fc;
    --color-text: #e0f2fe;
    --font-heading: 'Syncopate', sans-serif;
    --font-body: 'Inter', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--color-abyss);
    color: var(--color-text);
    font-family: var(--font-body);
    overflow-x: hidden;
    cursor: none;
    /* Custom cursor */
}

/* Preloader */
.preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--color-abyss);
    z-index: 999999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.preloader-line {
    position: absolute;
    width: 0;
    height: 2px;
    background: var(--color-cyan);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.preloader-text-container {
    display: flex;
    gap: 0px;
    /* Animate spacing */
    font-family: var(--font-heading);
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 700;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 5px;
}

.word-group {
    display: flex;
    align-items: center;
}

.main-letter {
    opacity: 0;
    color: var(--color-cyan);
    /* D and L match brand color */
    display: inline-block;
}

.rest-of-word {
    overflow: hidden;
    width: 0;
    /* JS animates to auto/fixed size */
    opacity: 0;
    white-space: nowrap;
    display: inline-block;
}

/* Background Layer */
.bg-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
}

.bg-layer .bg-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    object-fit: cover;
    transform: scale(1.05);
    /* Slight scale for parallax room */
    will-change: transform;
    /* Hardware Acceleration for mouse parallax */
}

/* Ensure Abyss video starts hidden and behind */
#abyss-bg-video {
    z-index: 1;
    opacity: 0;
}

#hero-bg-video {
    z-index: 2;
}

.bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(to bottom, rgba(1, 10, 21, 0.4) 0%, rgba(1, 10, 21, 0.95) 100%);
    pointer-events: none;
    opacity: 0.5;
    /* Will animate opacity strictly on scroll */
    z-index: 3;
}

/* Glassmorphism Utility */
.glass-panel {
    background: rgba(5, 28, 53, 0.2);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(15, 240, 252, 0.15);
    border-radius: 16px;
}

/* Navbar */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 2rem 4rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    /* mix-blend-mode: difference; Optional: Can cause issues if background is very dark already */
}

.logo {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 2px;
}

nav ul {
    list-style: none;
    display: flex;
    gap: 3rem;
}

nav a {
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    padding: 10px;
    display: inline-block;
}

nav a::after {
    content: '';
    position: absolute;
    width: 0%;
    height: 1px;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--color-cyan);
    transition: width 0.3s ease;
}

nav a:hover::after {
    width: 80%;
}

/* Sections */
.section {
    min-height: 100vh;
    padding: 0 4rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    z-index: 10;
}

.hero {
    align-items: flex-start;
    width: 100%;
    /* Changed from 100vw to prevent scrollbar overflow bug */
}

.hero-content {
    max-width: 100%;
    margin-top: 10vh;
}

.hero-title {
    font-family: var(--font-heading);
    /* Fluid typography: minimum 2rem, scales with vw, maximum 6rem */
    font-size: clamp(2rem, 5vw, 6rem);
    line-height: 1.1;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 2rem;
    width: 100%;
    /* Ensure it spans the container without overflow */
    display: flex;
    flex-wrap: wrap;
    column-gap: 1.5rem;
    /* Space between words */
}

.hero-title .word {
    overflow: visible;
    /* Prevent clipping of 3D transforms */
}

/* Force a line break before DEEP, IMMERSIVE, and EXPERIENCES for the intended stack */
.hero-title .word:nth-child(3),
.hero-title .word:nth-child(4),
.hero-title .word:nth-child(5) {
    flex-basis: 100%;
}

.hero-title .word:nth-child(3) .char,
.hero-title .word:nth-child(5) .char {
    color: transparent;
    -webkit-text-stroke: 1px var(--color-text);
}

/* Desktop Only: Push the 3rd and 5th words inward for staggered look */
@media (min-width: 769px) {

    .hero-title .word:nth-child(3),
    .hero-title .word:nth-child(5) {
        margin-left: max(2rem, 10vw);
    }
}

.hero-subtitle {
    font-size: 1.2rem;
    max-width: 500px;
    opacity: 0.8;
    line-height: 1.6;
    margin-bottom: 3rem;
}

.cta-button {
    display: inline-block;
    padding: 1rem 2.5rem;
    color: var(--color-text);
    text-decoration: none;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    transition: all 0.4s ease;
    overflow: hidden;
    position: relative;
    cursor: none;
}

/* Liquid/Wave Hover Effect on Button */
.cta-button::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-cyan);
    transition: top 0.4s cubic-bezier(0.7, 0, 0.3, 1);
    z-index: -1;
}

.cta-button:hover {
    color: var(--color-abyss);
    border-color: var(--color-cyan);
}

.cta-button:hover::before {
    top: 0;
}

/* Services */
.services {
    align-items: center;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 3rem;
    margin-bottom: 4rem;
    text-align: center;
    text-transform: uppercase;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    width: 100%;
    max-width: 1200px;
}

.service-card {
    padding: 3rem 2rem;
    text-align: center;
    transition: transform 0.4s ease, border-color 0.4s ease;
    cursor: none;
    /* Keep custom cursor working */
}

.service-card:hover {
    transform: translateY(-10px);
    border-color: var(--color-cyan);
}

.service-card h3 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--color-cyan);
}

.spacer {
    height: 100vh;
}

/* Canvas Sequence Section */
.sequence-section {
    min-height: 100vh;
    /* Extra scroll space to scrub through 80 images */
    position: relative;
    padding: 0;
    display: flex;
}

.sequence-container {
    width: 350px;
    height: 200px;
    border-radius: 20px;
    overflow: hidden;
    position: absolute;
    /* Switched to absolute against the sticky section */
    top: calc(100vh - 250px);
    left: 50px;
    /* Anchor directly to the left edge */
    box-shadow:
        0 0 30px rgba(15, 240, 252, 0.4),
        /* Neon outer glow */
        inset 0 0 20px rgba(15, 240, 252, 0.3),
        /* Neon inner glow */
        10px 20px 50px rgba(1, 10, 21, 0.9);
    /* Deep drop shadow */
    border: 2px solid rgba(15, 240, 252, 0.6);
    /* Thicker cyan border */
    background: rgba(1, 10, 21, 0.5);
    /* Slight dark tint for glass effect */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    will-change: transform, width, height, border-radius;
    /* GPU pre-allocation for huge sequence tween */
}

#sequence-canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    /* Hide Veo watermark by scaling slightly and shifting the bottom-right out of view */
    transform-origin: top left;
    transform: scale(1.12);
}

.sequence-text {
    position: absolute;
    /* Using absolute relative to GSAP's pinned section is safer */
    top: 50vh;
    left: 50vw;
    transform: translate(-50%, -50%);
    width: 90%;
    text-align: center;
    font-family: var(--font-heading);
    font-size: clamp(2rem, 4vw, 5rem);
    font-weight: 700;
    text-transform: uppercase;
    color: #fff;
    text-shadow: 0 5px 25px rgba(1, 10, 21, 0.9);
    z-index: 50;
    /* Must be 1 so animating character children are visible! */
    opacity: 1;
    pointer-events: none;
}

/* Allow overflow visible on .word to prevent cutting off 3D rotation */
.sequence-text .word {
    overflow: visible;
}

/* Work & Flow Section */
.work-section {
    position: relative;
    padding-top: 0;
    margin-top: -50vh;
    /* Pull the section violently upward to remove the scrub pin gap */
    padding-bottom: 5rem;
}

.flow-container {
    position: relative;
    width: 100vw;
    /* Take up entire screen width for massive curve */
    left: 50%;
    transform: translateX(-50%);
    min-height: 1200px;
    overflow: hidden;
    /* Hide horizontal scrolling if curve goes too wide */
}

.flow-line-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    overflow: visible;
}

#flow-path {
    filter: drop-shadow(0 0 15px rgba(15, 240, 252, 0.4));
}

.flow-points {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    max-width: 1200px;
    /* Constrain content width */
    height: 100%;
    margin: 0 auto;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    /* Add this! Overrides SVG z-index: 1 */
}

.flow-point {
    position: absolute;
    /* Absolute positioning for manual placement over curve */
    display: flex;
    align-items: center;
    z-index: 2;
}

.point-tracker.solid-dot {
    position: absolute;
    left: -40px;
    /* Position strictly relative to the card */
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    background: var(--color-cyan);
    /* Solid dot instead of ring */
    border-radius: 50%;
    box-shadow: 0 0 15px var(--color-cyan);
    border: none;
}

.point-content {
    width: 450px;
    /* Slightly wider cards for Lusion style content */
    padding: 2.5rem;
    transition: transform 0.4s ease, box-shadow 0.4s ease;
}

.solid-card {
    background: var(--color-abyss) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: 1px solid rgba(15, 240, 252, 0.3);
    border-radius: 16px;
    z-index: 10;
}

.point-content:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(15, 240, 252, 0.2);
}

.point-content h3 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--color-cyan);
}

.link-highlight {
    color: var(--color-cyan);
    font-weight: bold;
    text-decoration: underline;
    text-underline-offset: 4px;
    transition: color 0.3s ease;
    display: inline-block;
    margin-top: 1rem;
}

.link-highlight:hover {
    color: #fff;
    text-shadow: 0 0 10px var(--color-cyan);
}

/* Contact Section */
.contact-section {
    position: relative;
    z-index: 50;
    /* Force above the background video overlay */
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: linear-gradient(to top, rgba(1, 10, 21, 1), rgba(1, 10, 21, 0));
    padding-bottom: 5rem;
    margin-top: 25vh;
    /* Massive gap to clear the previous section entirely */
}

.contact-subtitle {
    font-size: 1.2rem;
    color: var(--color-text);
    opacity: 0.7;
    margin-bottom: 2rem;
}

.contact-email {
    display: block;
    text-decoration: none;
    padding: 2rem;
    position: relative;
    /* GSAP strictly handles transform and opacity entrance, CSS handles absolutely no transitions here to prevent lockups */
}

.email-text {
    display: inline-block;
    font-family: var(--font-heading);
    font-size: clamp(1.2rem, 3vw, 3rem);
    font-weight: 700;
    color: var(--color-cyan);
    transition: color 0.4s ease, text-shadow 0.4s ease, transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    text-shadow: 0 0 20px rgba(15, 240, 252, 0.4);
    /* Safe internal hover transitions that won't fight GSAP parent tweens */
}

.contact-email:hover .email-text {
    color: #fff;
    text-shadow: 0 0 40px rgba(15, 240, 252, 0.8);
    transform: scale(1.05);
}

/* Custom Cursor */
.cursor {
    width: 8px;
    height: 8px;
    background: var(--color-cyan);
    border-radius: 50%;
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 9999;
    will-change: transform;
}

.cursor-follower {
    width: 40px;
    height: 40px;
    border: 1px solid rgba(15, 240, 252, 0.5);
    border-radius: 50%;
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 9998;
    transition: width 0.3s, height 0.3s, background 0.3s;
    /* Removed transform transition! GSAP handles it now */
    will-change: transform, width, height;
}

/* Hovering active state */
.cursor-follower.active {
    width: 80px;
    height: 80px;
    background: rgba(15, 240, 252, 0.1);
    border: 1px solid rgba(15, 240, 252, 0.8);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* --- Mobile Responsiveness --- */

/* Hide Custom Cursor completely on ANY screen smaller than a laptop */
@media (max-width: 1024px) {

    .cursor,
    .cursor-follower {
        display: none !important;
    }
}

@media (max-width: 768px) {

    /* Base Resets to Prevent Horizontal Chop */
    html,
    body {
        overflow-x: hidden !important;
        width: 100% !important;
        margin: 0;
        padding: 0;
    }

    /* ===== NAVBAR ===== */
    .navbar {
        padding: 1.2rem 1rem;
        flex-direction: column;
        gap: 0.8rem;
        background: linear-gradient(to bottom, rgba(1, 10, 21, 0.95) 0%, rgba(1, 10, 21, 0) 100%);
        width: 100%;
    }

    .logo {
        font-size: 1.4rem;
    }

    nav ul {
        gap: 1.5rem;
        flex-wrap: nowrap;
        justify-content: center;
    }

    nav a {
        font-size: 0.85rem;
        padding: 6px 4px;
    }

    /* ===== SECTIONS ===== */
    .section {
        padding: 0 1.2rem;
    }

    section.section {
        padding-top: 110px;
    }

    /* CRITICAL: Section titles must NEVER break mid-word.
       Use white-space: nowrap + fluid sizing to keep "OUR EXPERTISE" on one line. */
    .section-title {
        font-size: clamp(1.6rem, 7vw, 3rem);
        margin-bottom: 2rem;
        word-break: keep-all;
        white-space: nowrap;
        overflow: visible;
    }

    /* ===== HERO ===== */
    .hero {
        padding: 0 1rem;
    }

    .hero-content {
        padding: 0 0.5rem;
        width: 100%;
        margin-top: 5vh;
    }

    .hero-title {
        /* Fluid size that prevents "IMMERSIVE" and "EXPERIENCES" from breaking mid-word.
           On a 375px phone: 9vw ≈ 33px ≈ 2.1rem, which fits the longest word comfortably. */
        font-size: clamp(2rem, 9vw, 4rem);
        line-height: 1.15;
        word-break: keep-all;
        overflow-wrap: normal;
        column-gap: 0.6rem;
    }

    /* Remove the forced line-break (flex-basis: 100%) on mobile —
       let words flow naturally so they don't each sit on their own line
       and cause ugly mid-word splits */
    .hero-title .word:nth-child(3),
    .hero-title .word:nth-child(4),
    .hero-title .word:nth-child(5) {
        flex-basis: auto;
    }

    .hero-subtitle {
        font-size: 0.95rem;
        max-width: 100%;
        line-height: 1.5;
        margin-bottom: 2rem;
    }

    .hero-desc {
        width: 100%;
        font-size: 1rem;
        margin-top: 1rem;
    }

    .cta-button {
        padding: 0.8rem 1.8rem;
        font-size: 0.8rem;
    }

    /* ===== PRELOADER ===== */
    .preloader-text-container {
        width: 100vw;
        max-width: 100%;
        overflow: hidden;
        justify-content: center;
    }

    .main-letter,
    .rest-of-word {
        font-size: clamp(1.5rem, 6vw, 3rem);
    }

    /* ===== SERVICES / EXPERTISE ===== */
    .services {
        padding: 4rem 1rem;
    }

    .services-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .service-card {
        padding: 2rem 1.5rem;
        min-height: auto;
    }

    .service-card h3 {
        font-size: 1.1rem;
    }

    .service-card p {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    /* ===== CANVAS SEQUENCE ===== */
    .sequence-container {
        width: 90vw;
        left: 5vw;
        height: auto;
        min-height: 200px;
    }

    .sequence-text {
        font-size: clamp(1.4rem, 5.5vw, 2.5rem);
        width: 90%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    /* ===== WORK / FLOW SECTION =====
       On mobile the absolute-positioned cards overflow the viewport.
       Switch to a column layout where cards stack vertically. */
    .work-section {
        margin-top: -30vh;
        padding-bottom: 3rem;
    }

    .flow-container {
        width: 100%;
        left: 0;
        transform: none;
        min-height: auto;
        overflow: visible;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 0 1rem;
    }

    /* Hide the SVG curvy line on mobile — it doesn't scale well */
    .flow-line-svg {
        display: none;
    }

    .flow-points {
        position: relative;
        width: 100%;
        max-width: 100%;
        left: 0;
        transform: none;
        height: auto;
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
        padding: 0;
    }

    .flow-point {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    /* Hide the dot tracker on mobile — not meaningful without the SVG line */
    .point-tracker.solid-dot {
        display: none;
    }

    .point-content {
        width: 100%;
        padding: 1.8rem 1.5rem;
    }

    .point-content h3 {
        font-size: 1.1rem;
        margin-bottom: 0.8rem;
    }

    .point-content p {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    /* ===== CONTACT ===== */
    .contact-section {
        margin-top: 10vh;
        padding: 2rem 1rem;
        min-height: auto;
        padding-bottom: 4rem;
    }

    .contact-subtitle {
        font-size: 1rem;
    }

    .contact-email .email-text {
        font-size: clamp(0.85rem, 5vw, 1.3rem);
        word-break: break-all;
    }

    /* ===== SPACER ===== */
    .spacer {
        height: 50vh;
    }
}

/* ===== Extra small phones (below 400px) ===== */
@media (max-width: 400px) {

    .hero-title {
        font-size: clamp(1.7rem, 8.5vw, 2.5rem);
        column-gap: 0.4rem;
    }

    .section-title {
        font-size: clamp(1.3rem, 6.5vw, 2rem);
    }

    .logo {
        font-size: 1.2rem;
    }

    nav ul {
        gap: 1rem;
    }

    nav a {
        font-size: 0.78rem;
    }

    .point-content {
        padding: 1.5rem 1.2rem;
    }
}