/* CSS for Premium Animated Header */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@600;800&family=Inter:wght@400;500&family=Playfair+Display:ital,wght@0,600;0,700;0,800;1,600;1,700;1,800&display=swap');

/* Apply Stylish Font to Header only on larger screens */
@media (min-width: 768px) {
    header .leading-tight {
        font-family: 'Playfair Display', serif !important;
    }
    header .leading-tight .text-gold {
        font-style: italic;
    }
}

.premium-header-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: transparent;
    font-family: 'Poppins', sans-serif;
    overflow: hidden;
    position: relative;
    min-height: 200px;
}

.header-main-title {
    font-size: 4rem;
    font-weight: 800;
    color: #2c3e50;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    margin: 0;
    line-height: 1.2;
}

.apex-text {
    color: #e67e22; /* Vibrant orange for APEX */
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.animated-word-container {
    overflow: hidden;
    position: relative;
    display: inline-block;
    padding: 10px 90px 10px 0px; /* Extra padding right to prevent image cutoff */
}

.animated-word {
    display: inline-block;
    color: #34495e;
    transform: translateX(-100%); /* Start hidden behind APEX/left edge */
    transition: transform 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    will-change: transform;
}

.y-letter {
    position: relative;
    display: inline-block;
    color: #27ae60; /* Highlight the Y to match the mascot interaction */
}

.mascot-character {
    position: absolute;
    width: 90px;
    height: 90px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    bottom: -15px; /* Moved character lower */
    left: 100%; /* Position right after the Y */
    margin-left: -30px; /* Negative margin to pull mascot hands onto the Y */
    transform-origin: bottom center;
    transition: all 0.5s ease;
    z-index: 10;
    will-change: transform, background-image;
}

/* --- ANIMATION STATES --- */

/* ENTERING (Pulling) */
.state-entering .animated-word {
    transform: translateX(0);
}
.state-entering .y-letter {
    animation: y-wobble 1.5s ease-in-out;
}
.state-entering .mascot-character {
    background-image: url('../images/pull.png');
    transform: rotate(20deg) translateX(10px); /* Leaning backward */
}

/* IDLE (10s Stay) */
.state-idle .animated-word {
    transform: translateX(0);
}
.state-idle .mascot-character {
    background-image: url('../images/pull.png');
    animation: float-breathe 4s ease-in-out infinite;
}
.state-idle .y-letter {
    transform: rotate(0deg);
}

/* EXITING (Pushing back into APEX) */
.state-exiting .animated-word {
    transform: translateX(-100%);
    transition: transform 1.5s cubic-bezier(0.6, -0.28, 0.735, 0.045);
}
.state-exiting .y-letter {
    animation: y-compress 1.5s ease-in-out forwards;
}
.state-exiting .mascot-character {
    background-image: url('../images/push.png');
    z-index: -1; /* Move behind Y */
    transform: rotate(-15deg) translateX(-20px); /* Leaning forward, pushing from behind Y */
    /* Removed the explicit left override so it stays near Y instead of going into C */
}

/* --- KEYFRAMES --- */

@keyframes y-wobble {
    0% { transform: rotate(0deg); }
    30% { transform: rotate(-8deg); }
    50% { transform: rotate(5deg); }
    70% { transform: rotate(-3deg); }
    100% { transform: rotate(0deg); }
}

@keyframes y-compress {
    0% { transform: scaleX(1) scaleY(1); }
    50% { transform: scaleX(0.85) scaleY(0.95); }
    100% { transform: scaleX(1) scaleY(1); }
}

@keyframes float-breathe {
    0%, 100% { 
        transform: rotate(0deg) scaleY(1); 
    }
    48% { 
        transform: rotate(2deg) scaleY(1.02); 
    }
    50% { 
        /* Quick blink effect */
        transform: rotate(2deg) scaleY(0.8); 
    }
    52% { 
        transform: rotate(2deg) scaleY(1.02); 
    }
}

/* Subtitle */
.header-subtitle {
    font-family: 'Inter', sans-serif;
    font-size: 1.2rem;
    color: #7f8c8d;
    margin-top: 15px;
    letter-spacing: 1px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 1s ease 0.5s; /* Delay to appear after title */
}

.state-idle ~ .header-subtitle,
.state-entering ~ .header-subtitle {
    opacity: 1;
    transform: translateY(0);
}

/* Responsive */
@media (max-width: 768px) {
    .header-main-title {
        font-size: 2.5rem;
    }
    .mascot-character {
        width: 60px;
        height: 60px;
        bottom: -10px; /* Moved character lower on mobile */
        margin-left: -20px; /* Less negative margin since text is smaller on mobile */
    }
    .state-exiting .mascot-character {
        transform: rotate(-15deg) translateX(-5px); /* Push less deeply on mobile to stay on Y */
    }
    .header-subtitle {
        font-size: 1rem;
        text-align: center;
    }
    .animated-word-container {
        padding: 5px 65px 5px 0px; /* Reduced right padding and top/bottom padding for mobile */
    }
}
