/* ===================================================
   animations.css — Framer-quality animations + Safari fixes
   =================================================== */

/* ===================================================
   Background Gradient Spheres
   =================================================== */
.hero-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
    padding-top: 5rem;
}

.hero-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    pointer-events: none;
    overflow: hidden;
    /* GPU compositing layer — prevents Safari repaint */
    will-change: transform;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.gradient-sphere {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.12;
    pointer-events: none;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
}

.sphere-1 {
    width: 65vw;
    height: 65vw;
    max-width: 750px;
    max-height: 750px;
    background: var(--accent-blue);
    top: -20%;
    left: -15%;
    animation: drift-1 16s infinite ease-in-out;
}

.sphere-2 {
    width: 55vw;
    height: 55vw;
    max-width: 650px;
    max-height: 650px;
    background: var(--accent-violet);
    bottom: -20%;
    right: -15%;
    animation: drift-2 19s infinite ease-in-out;
    animation-delay: -7s;
}

.sphere-3 {
    width: 60vw;
    height: 60vw;
    max-width: 700px;
    max-height: 700px;
    background: var(--accent-pink);
    top: 35%;
    left: 35%;
    animation: drift-3 22s infinite ease-in-out;
    animation-delay: -11s;
}

@keyframes drift-1 {
    0% {
        transform: translate(0, 0) scale(1);
    }

    20% {
        transform: translate(18vw, 12vh) scale(1.12);
    }

    45% {
        transform: translate(28vw, 38vh) scale(0.95);
    }

    70% {
        transform: translate(5vw, 48vh) scale(1.15);
    }

    100% {
        transform: translate(0, 0) scale(1);
    }
}

@keyframes drift-2 {
    0% {
        transform: translate(0, 0) scale(1);
    }

    20% {
        transform: translate(-14vw, -18vh) scale(1.18);
    }

    45% {
        transform: translate(-32vw, -8vh) scale(0.85);
    }

    70% {
        transform: translate(-18vw, -34vh) scale(1.12);
    }

    100% {
        transform: translate(0, 0) scale(1);
    }
}

@keyframes drift-3 {
    0% {
        transform: translate(0, 0) scale(0.9);
    }

    25% {
        transform: translate(-30vw, 20vh) scale(1.35);
    }

    50% {
        transform: translate(20vw, -15vh) scale(1.05);
    }

    75% {
        transform: translate(10vw, 30vh) scale(0.8);
    }

    100% {
        transform: translate(0, 0) scale(0.9);
    }
}

/* On Safari iOS, complex blur animations cause scroll jank — use reduced motion */
@media (max-width: 768px) {
    .gradient-sphere {
        filter: blur(60px);
        opacity: 0.18;
        will-change: auto;
    }

    .sphere-1 {
        animation-duration: 20s;
    }

    .sphere-2 {
        animation-duration: 24s;
    }

    .sphere-3 {
        animation-duration: 27s;
    }
}

/* ===================================================
   Hero Content
   =================================================== */
.hero-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 900px;
}

@media (max-width: 600px) {
    .hero-content {
        align-items: center;
        text-align: center;
    }

    .hero-cta {
        align-items: center;
    }

    .open-to-work-badge {
        align-self: center;
    }

    .rotating-text-wrapper {
        justify-content: center;
        font-size: 1.25rem;
        margin-bottom: 2rem;
    }

    .hero-title {
        font-size: clamp(2.6rem, 11vw, 3.8rem);
        margin-bottom: 1rem;
    }

    .hero-subtitle {
        font-size: 0.78rem;
        margin-bottom: 0.75rem;
    }

    .open-to-work-badge {
        margin-bottom: 1rem;
        font-size: 0.8rem;
    }

    .hero-section {
        padding-top: 8rem;
        align-items: flex-start;
        padding-bottom: 3rem;
    }
}

.hero-subtitle {
    font-size: 1.1rem;
    font-family: var(--font-heading);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-blue);
    margin-bottom: 1rem;
    font-weight: 600;
}

.hero-title {
    font-size: clamp(3.5rem, 8vw, 6rem);
    margin-bottom: 1.5rem;
}

/* ===================================================
   Typewriter Text Effect
   =================================================== */
.rotating-text-wrapper {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-family: var(--font-heading);
    font-weight: 500;
    margin-bottom: 3rem;
    color: var(--text-secondary);
}

.static-text {
    margin-right: 12px;
}

.typewriter-text {
    display: inline-block;
    transition: opacity 0.5s ease;
    border-right: 3px solid var(--accent-blue);
    padding-right: 5px;
    animation: blinkCursor 0.75s step-end infinite;
    white-space: nowrap;
    min-width: 20px;
}

.typewriter-text.fade-out {
    opacity: 0;
}

@keyframes blinkCursor {
    50% {
        border-color: transparent;
    }
}

/* ===================================================
   Hero CTA Buttons
   =================================================== */
.hero-cta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.hero-cta .btn {
    min-width: 140px;
}

@media (max-width: 600px) {
    .hero-cta {
        flex-direction: column;
        gap: 0.85rem;
        width: 100%;
    }

    .hero-cta .btn {
        width: 75%;
        min-width: unset;
        justify-content: center;
        padding: 1rem 1.5rem;
        font-size: 1rem;
    }
}

/* ===================================================
   Utility
   =================================================== */
.mobile-only {
    display: none !important;
}

@media (max-width: 768px) {
    .mobile-only {
        display: inline-block !important;
    }

    .desktop-only {
        display: none !important;
    }
}

/* ===================================================
   Framer-style Hero Slide-up Animation
   Desktop: keyframe animation with spring easing
   Mobile: CSS transition (Safari iOS drops keyframe animations
           triggered by class changes; transitions are reliable)
   =================================================== */
.slide-up {
    opacity: 0;
    transform: translateY(32px);
    /* Don't use translateZ(0) here — causes compositing issues in Safari
       when combined with animation delay on many children */
}

body.hero-animated .slide-up,
.hero-animated .slide-up {
    animation: slideUpFade 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUpFade {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {

    /* Use transition instead of animation — Safari iOS handles transitions
       much more reliably when triggered via classList changes */
    .slide-up {
        opacity: 0;
        transform: translateY(16px);
        transition: opacity 0.6s ease-out, transform 0.6s ease-out;
        /* transition-delay is set inline on each element via hero.php */
    }

    body.hero-animated .slide-up,
    .hero-animated .slide-up {
        /* Override animation with final state — transition handles the fade */
        animation: none;
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===================================================
   Scroll Indicator
   =================================================== */
.scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    z-index: 10;
    /* Managed by JS — starts hidden, fades in after intro */
    opacity: 0;
    pointer-events: none;
    transition: opacity 1s ease-out;
}

.mouse {
    width: 26px;
    height: 40px;
    border: 2px solid var(--text-primary);
    border-radius: 20px;
    position: relative;
}

.wheel {
    width: 4px;
    height: 8px;
    background: var(--text-primary);
    border-radius: 4px;
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    animation: scrollWheel 2s infinite cubic-bezier(0.15, 0.41, 0.69, 0.94);
}

@keyframes scrollWheel {
    0% {
        top: 8px;
        opacity: 1;
    }

    100% {
        top: 24px;
        opacity: 0;
    }
}

.scroll-text {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-family: var(--font-heading);
}

@media (max-width: 768px),
(max-height: 700px) {
    .scroll-indicator {
        display: none;
    }
}

/* ===================================================
   Framer-style Scroll Reveals
   Card: rises + fades with spring easing
   =================================================== */
.reveal {
    opacity: 0;
    transform: translateY(40px);
    transition:
        opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
    /* Safari: do NOT use translateZ here — it can freeze sub-elements */
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 768px) {
    .reveal {
        transform: translateY(18px);
        transition:
            opacity 0.5s ease-out,
            transform 0.5s ease-out;
    }

    .reveal.active {
        transform: translateY(0);
    }
}

/* ===================================================
   Staggered Children (Framer-style)
   Use class="stagger-container" on the parent,
   and "stagger-child" on each child element.
   JS adds .active with a per-child delay.
   =================================================== */
.stagger-child {
    opacity: 0;
    transform: translateY(30px) scale(0.97);
    transition:
        opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.stagger-child.active {
    opacity: 1;
    transform: translateY(0) scale(1);
}

@media (max-width: 768px) {

    /* Simplify: all children visible immediately */
    .stagger-child,
    .stagger-child.active {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

/* ===================================================
   OLD staggered nested reveals (simplified, Safari safe)
   =================================================== */
.reveal.active .about-text,
.reveal.active .education-card,
.reveal.active .skill-card:nth-child(1),
.reveal.active .skill-card:nth-child(2),
.reveal.active .skill-card:nth-child(3),
.reveal.active .product-content,
.reveal.active .product-visual {
    animation: slideUpFade 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
}

.reveal.active .about-text {
    animation-delay: 0.1s;
}

.reveal.active .education-card {
    animation-delay: 0.25s;
}

.reveal.active .skill-card:nth-child(1) {
    animation-delay: 0.05s;
}

.reveal.active .skill-card:nth-child(2) {
    animation-delay: 0.15s;
}

.reveal.active .skill-card:nth-child(3) {
    animation-delay: 0.25s;
}

.reveal.active .product-content {
    animation-delay: 0.1s;
}

.reveal.active .product-visual {
    animation-delay: 0.25s;
}

@media (max-width: 768px) {

    /* Disable sub-animations on mobile to prevent Safari GPU stall */
    .reveal.active .about-text,
    .reveal.active .education-card,
    .reveal.active .skill-card,
    .reveal.active .product-content,
    .reveal.active .product-visual {
        animation: none;
        opacity: 1;
        transition: none;
    }
}

/* ===================================================
   Cursor Trail
   =================================================== */
.cursor-trail {
    position: fixed;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(140, 82, 255, 0.18);
    pointer-events: none;
    z-index: 10000;
    transform: translate(-50%, -50%);
    box-shadow:
        0 0 16px rgba(140, 82, 255, 0.5),
        0 0 32px rgba(0, 240, 255, 0.3),
        0 0 48px rgba(140, 82, 255, 0.15);
    mix-blend-mode: screen;
    filter: blur(1.5px);
    transition: opacity 0.08s linear;
    /* Safari: isolate each dot */
    -webkit-transform: translate(-50%, -50%);
    will-change: transform, opacity;
}

/* ===================================================
   Navbar — Framer-style entrance
   =================================================== */
.navbar {
    /* Starts at 0 — JS sets opacity:1 after intro */
    transition: opacity 0.8s ease-out, background 0.4s ease, transform 0.3s ease;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 100;
}

.mobile-menu-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: center;
}

/* Animated state — X icon */
.mobile-menu-btn.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.mobile-menu-btn.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
    }
}