/* ============================================
   HERO SECTION
============================================ */
.hero {
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height - accounts for mobile browser chrome */
    min-height: 100vh;
    min-height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: #0a0a0a;
    /* Prevent content from pushing hero taller */
    flex-shrink: 0;
    /* Isolate stacking context to prevent rendering artifacts from other layers */
    isolation: isolate;
}

.hero-video-frame {
    position: absolute;
    inset: 2rem;
    /* Use box-shadow instead of border to avoid sub-pixel rendering glitches */
    border: none;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    overflow: hidden;
    z-index: 1;
    /* Ensure video frame stays within hero bounds */
    max-height: calc(100% - 4rem);
    /* Chrome fix: force new compositing layer to prevent edge artifacts */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
    /* Ensure clean edges in Chrome */
    -webkit-perspective: 1000;
    perspective: 1000;
}

.hero-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Prevent iOS video controls and expansion */
    -webkit-playsinline: true;
    /* Prevent video from expanding container */
    max-width: 100%;
    max-height: 100%;
    /* Force GPU rendering to prevent artifacts */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

.hero h1 {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    letter-spacing: 0.05em;
    color: white;
    font-weight: 500;
}

.hero h1 span {
    display: block;
}

/* ============================================
   GIANT GENCTX TEXT - MASKED INVERTED VIDEO
============================================ */
.hero-giant-text {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    pointer-events: none;
    height: 22vw;
    max-height: 200px;
    min-height: 80px;
    /* Chrome fix: force new compositing layer to prevent edge artifacts */
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
}

.giant-text-svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
    /* Prevent SVG rendering artifacts */
    shape-rendering: geometricPrecision;
}

.giant-text-svg .mask-text {
    font-family: var(--font-display), 'Arial Black', sans-serif;
    font-size: 110px;
    font-weight: 600;
    letter-spacing: -0.04em;
}

.giant-text-svg foreignObject {
    overflow: visible;
    /* Chrome fix: prevent rendering artifacts at foreignObject boundaries */
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
}

.inverted-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Invert the video colors */
    filter: invert(1);
    /* iOS compatibility */
    -webkit-playsinline: true;
    /* Prevent edge artifacts */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Fallback text - hidden when SVG works, shown on Safari */
/* Now positioned inside hero-video-frame for proper blend mode */
.giant-text-fallback {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 5;
    pointer-events: none;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.giant-text-fallback .giant-logo-icon {
    width: clamp(2rem, 8vw, 5.5rem);
    height: clamp(2rem, 8vw, 5.5rem);
    min-width: 2rem;
    flex-shrink: 0;
    display: inline-block;
}

.giant-text-fallback .giant-text {
    font-family: var(--font-display), 'Arial Black', sans-serif;
    font-size: clamp(3.5rem, 17vw, 12rem);
    font-weight: 600;
    letter-spacing: -0.04em;
    line-height: 1;
    color: white;
    display: inline-block;
    white-space: nowrap;
}

/* Safari-specific: ensure blend mode works */
.is-safari .hero-video-frame {
    isolation: isolate;
    /* Ensure no background interferes with blend */
    background: transparent;
    /* Transform hack to force GPU layer in Safari */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.is-safari .giant-text-fallback {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    /* exclusion often works better than difference in Safari */
    mix-blend-mode: exclusion;
}

.is-safari .hero-giant-text {
    display: none;
}

/* Chrome fallback - use blend mode instead of buggy foreignObject */
.is-chrome .hero-video-frame {
    isolation: isolate;
    background: transparent;
}

.is-chrome .giant-text-fallback {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    mix-blend-mode: difference;
}

.is-chrome .hero-giant-text {
    display: none;
}

/* Show fallback if foreignObject not supported (detected via @supports or JS) */
@supports not ((-webkit-mask: url('#')) or (mask: url('#'))) {
    .hero-giant-text {
        display: none;
    }
    .giant-text-fallback {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 0.5rem;
    }
}

/* ============================================
   HERO RESPONSIVE
============================================ */
@media (max-width: 768px) {
    .hero {
        height: 100svh;
        height: 100dvh;
        min-height: 100svh;
        min-height: 100dvh;
        max-height: 100svh;
        max-height: 100dvh;
        /* Prevent any overflow on mobile */
        overflow: hidden;
    }

    .hero-video-frame {
        inset: 1rem;
        max-height: calc(100% - 2rem);
    }

    .hero h1 {
        font-size: 0.9rem;
        padding: 0 1rem;
    }

    /* GenCTX text - 40% bigger on mobile, moved up */
    .hero-giant-text {
        height: 28vw;
        min-height: 100px;
        max-height: 170px;
        bottom: 3rem;
    }

    .giant-text-svg .mask-text {
        font-size: 160px;
    }

    .giant-text-fallback {
        bottom: 2rem;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: center !important;
        align-items: center !important;
        width: 100% !important;
        text-align: center !important;
    }

    .giant-text-fallback .giant-text {
        font-size: clamp(4rem, 18vw, 10rem);
        display: inline-block !important;
        white-space: nowrap !important;
    }

    .giant-text-fallback .giant-logo-icon {
        width: clamp(2.5rem, 10vw, 6rem);
        height: clamp(2.5rem, 10vw, 6rem);
        display: inline-block !important;
        flex-shrink: 0 !important;
    }
}

@media (max-width: 480px) {
    .hero-video-frame {
        inset: 0.75rem;
        max-height: calc(100% - 1.5rem);
    }

    .hero h1 {
        font-size: 0.75rem;
        line-height: 1.5;
    }

    /* GenCTX text - 40% bigger, moved up */
    .hero-giant-text {
        height: 25vw;
        min-height: 85px;
        max-height: 140px;
        bottom: 2.5rem;
    }

    .giant-text-svg .mask-text {
        font-size: 140px;
    }

    .giant-text-fallback {
        bottom: 1.5rem;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: center !important;
        align-items: center !important;
        width: 100% !important;
        text-align: center !important;
    }

    .giant-text-fallback .giant-text {
        font-size: clamp(3rem, 16vw, 7rem);
        display: inline-block !important;
        white-space: nowrap !important;
    }

    .giant-text-fallback .giant-logo-icon {
        width: clamp(2rem, 8vw, 4.5rem);
        height: clamp(2rem, 8vw, 4.5rem);
        display: inline-block !important;
        flex-shrink: 0 !important;
    }
}

/* Very small screens */
@media (max-width: 380px) {
    .hero-giant-text {
        height: 22vw;
        min-height: 70px;
        max-height: 115px;
        bottom: 2rem;
    }

    .giant-text-svg .mask-text {
        font-size: 125px;
    }

    .giant-text-fallback {
        bottom: 1rem;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: center !important;
        align-items: center !important;
        width: 100% !important;
        text-align: center !important;
    }

    .giant-text-fallback .giant-text {
        font-size: clamp(2.5rem, 14vw, 6rem);
        display: inline-block !important;
        white-space: nowrap !important;
    }

    .giant-text-fallback .giant-logo-icon {
        width: clamp(1.8rem, 7vw, 3.5rem);
        height: clamp(1.8rem, 7vw, 3.5rem);
        display: inline-block !important;
        flex-shrink: 0 !important;
    }

    .hero h1 {
        font-size: 0.7rem;
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        height: 100vh;
        height: 100dvh;
        min-height: 100vh;
        max-height: 100vh;
    }

    .hero-giant-text {
        height: 22vh;
        min-height: 50px;
        max-height: 90px;
    }

    .hero h1 {
        font-size: 0.8rem;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .hero {
        height: -webkit-fill-available;
        min-height: -webkit-fill-available;
    }
}
