/**
 * ==========================================================================
 * One Agency - Hero Kinetic Typography Entrance
 * File: hero-typography.css
 * ==========================================================================
 * 
 * TWEAKABLE VARIABLES
 * You can adjust durations, staggers, and delays directly below.
 */
:root {
    /* Line 1 ("We don't just sell homes.") */
    --hero-l1-duration: 0.70s;
    --hero-l1-stagger: 0.09s;
    --hero-l1-easing: cubic-bezier(0.16, 1, 0.3, 1);

    /* Line 2 ("We tell stories.") */
    --hero-l2-start-delay: 0.40s;
    --hero-l2-duration: 0.52s;
    --hero-l2-stagger: 0.035s;
    --hero-l2-easing: cubic-bezier(0.16, 1, 0.3, 1);

    /* Underline Draw */
    --hero-underline-delay: 1.15s;
    --hero-underline-duration: 0.60s;
    --hero-underline-easing: cubic-bezier(0.16, 1, 0.3, 1);

    /* Supporting Content (Badge, Paragraph, Action Buttons) */
    --hero-followup-start: 1.25s;
    --hero-followup-stagger: 0.12s;
    --hero-followup-duration: 0.65s;
    --hero-followup-easing: cubic-bezier(0.16, 1, 0.3, 1);

    /* Shimmer Sweep */
    --hero-shimmer-duration: 1.25s;
}

/* ==========================================================================
   1. Anti-FOUC & Initial States
   ========================================================================== */

/* Failsafe: if JS fails to run or is blocked, reveal headline after 1.2s */
@keyframes heroFailsafeReveal {
    to {
        opacity: 1 !important;
        visibility: visible !important;
    }
}

html.hero-loading #hero-section h1[data-pa-skip]:not(.hero-split-ready) {
    opacity: 0;
    animation: heroFailsafeReveal 0.1s forwards;
    animation-delay: 1.2s;
}

/* Prevent parent container's generic fade-in from clashing with kinetic sequence */
#hero-section .animate-fade-in-up {
    animation: none !important;
}

/* Base headline styling overrides for kinetic wrapping */
#hero-section h1[data-pa-skip] {
    overflow: visible;
}

/* Kinetic wrapper holding split content */
.hero-kinetic-wrapper {
    display: inline;
}

/* ==========================================================================
   2. Line 1: Word Masks & Rising Words
   ========================================================================== */

.hero-word-mask {
    display: inline-block;
    overflow: hidden;
    vertical-align: top;
    /* Add slight bottom padding to prevent clipping letters with descenders (j, y, p) */
    padding-bottom: 0.16em;
    margin-bottom: -0.16em;
    perspective: 800px;
}

.hero-word {
    display: inline-block;
    transform-origin: 50% 100%;
    transform: translateY(0) rotateX(0deg) skewY(0deg);
    opacity: 1;
    filter: blur(0px);
    will-change: transform, opacity, filter;
    animation: heroWordSlideUp var(--hero-l1-duration) var(--hero-l1-easing) both;
    animation-delay: calc(var(--word-idx, 0) * var(--hero-l1-stagger));
}

@keyframes heroWordSlideUp {
    0% {
        transform: translateY(115%) rotateX(-18deg) skewY(2deg);
        opacity: 0;
        filter: blur(7px);
    }
    40% {
        opacity: 1;
    }
    100% {
        transform: translateY(0) rotateX(0deg) skewY(0deg);
        opacity: 1;
        filter: blur(0px);
    }
}

/* ==========================================================================
   3. Line 2: Letter-by-Letter Entrance
   ========================================================================== */

.hero-line-2 {
    display: inline-block;
    position: relative;
}

.hero-l2-word {
    display: inline-block;
    white-space: nowrap;
}

.hero-char {
    display: inline-block;
    opacity: 1;
    transform: translateY(0) scale(1);
    transform-origin: 50% 80%;
    color: #f27321;
    -webkit-text-fill-color: #f27321;
    will-change: transform, opacity;
    animation: heroCharSettle var(--hero-l2-duration) var(--hero-l2-easing) both;
    animation-delay: calc(var(--hero-l2-start-delay) + var(--char-idx, 0) * var(--hero-l2-stagger));
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
                color 0.28s ease,
                filter 0.28s ease;
}

@keyframes heroCharSettle {
    0% {
        opacity: 0;
        transform: translateY(18px) scale(1.35);
    }
    45% {
        opacity: 1;
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Space between Line 2 words */
.hero-space {
    display: inline-block;
    width: 0.28em;
}

/* ==========================================================================
   4. Line 2: Shimmer Highlight Sweep
   ========================================================================== */

.hero-line-2.hero-shimmer-run .hero-char {
    background-image: linear-gradient(
        115deg,
        #f27321 0%,
        #f27321 35%,
        #ffd8be 50%,
        #f27321 65%,
        #f27321 100%
    );
    background-size: 260% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 1 !important;
    animation: heroCharShimmer var(--hero-shimmer-duration) cubic-bezier(0.25, 1, 0.5, 1) both;
    animation-delay: calc(var(--char-idx, 0) * 0.035s);
}

@keyframes heroCharShimmer {
    0% {
        background-position: 130% 0;
        opacity: 1;
    }
    100% {
        background-position: -130% 0;
        opacity: 1;
    }
}

/* ==========================================================================
   5. Peach Underline Left-to-Right Draw
   ========================================================================== */

.hero-underline-draw {
    transform-origin: left center !important;
    transform: scaleX(1);
    will-change: transform;
    animation: heroUnderlineExpand var(--hero-underline-duration) var(--hero-underline-easing) both;
    animation-delay: var(--hero-underline-delay);
}

@keyframes heroUnderlineExpand {
    0% {
        transform: scaleX(0);
    }
    100% {
        transform: scaleX(1);
    }
}

/* ==========================================================================
   6. Supporting Content Sequence (Badge, Paragraph, Buttons)
   ========================================================================== */

.hero-followup {
    opacity: 1;
    transform: translateY(0);
    will-change: transform, opacity;
    animation: heroFollowupEntrance var(--hero-followup-duration) var(--hero-followup-easing) both;
    animation-delay: calc(var(--hero-followup-start) + var(--followup-idx, 0) * var(--hero-followup-stagger));
}

@keyframes heroFollowupEntrance {
    0% {
        opacity: 0;
        transform: translateY(14px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   7. Optional Desktop Hover Polish
   ========================================================================== */

@media (hover: hover) and (pointer: fine) {
    .hero-char:hover {
        transform: translateY(-4px) !important;
        color: #ffa163 !important;
        -webkit-text-fill-color: #ffa163 !important;
        filter: drop-shadow(0 2px 8px rgba(242, 115, 33, 0.4));
    }
}

/* ==========================================================================
   8. Accessibility: Prefers-Reduced-Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    html.hero-loading #hero-section h1[data-pa-skip],
    #hero-section h1[data-pa-skip],
    .hero-word,
    .hero-char,
    .hero-underline-draw,
    .hero-followup {
    opacity: 1;
    transform: translateY(0);
    will-change: transform, opacity;
    animation: heroFollowupEntrance var(--hero-followup-duration) var(--hero-followup-easing) both;
    animation-delay: calc(var(--hero-followup-start) + var(--followup-idx, 0) * var(--hero-followup-stagger));
}
}
