<template>
    <div id="section1" class="section hero-section">
        <div class="hero-bg" aria-hidden="true">
            <div class="hero-bg-gradient" />
            <div class="hero-bg-shimmer" />
            <div class="hero-bg-orb hero-bg-orb--1" />
            <div class="hero-bg-orb hero-bg-orb--2" />
            <div class="hero-bg-orb hero-bg-orb--3" />
            <div class="hero-bg-orb hero-bg-orb--4" />
        </div>
        <Header color="#1b3022" />
        <div class="hero-inner">
            <Center />
            <div class="hero-visual" aria-hidden="true">
                <img
                    class="hero-illustration"
                    src="@/assets/img/homePage/figma/hero-illustration.png"
                    alt=""
                />
            </div>
        </div>

        <a-button
            shape="circle"
            class="floating-button"
            size="large"
            @click="scrollToSection('section2')"
        >
            <IconDown />
        </a-button>
    </div>

    <div id="section2" class="section features-wrap">
        <div class="features-bg" aria-hidden="true">
            <div class="features-bg-gradient" />
            <div class="features-bg-orb" />
        </div>
        <Section2 />
    </div>
    <footer class="site-footer">
        <span>© {{ new Date().getFullYear() }} RunForge - 智能校园乐跑平台</span>
    </footer>
</template>

<script setup>
import Header from '@/components/Header/index.vue'
import Center from './components/center.vue'
import Section2 from './components/section2.vue'

const scrollToSection = (sectionId) => {
    const section = document.getElementById(sectionId)
    if (section) {
        section.scrollIntoView({ behavior: 'smooth' })
    }
}
</script>

<style lang="less" scoped>
@import './theme.less';
@import '@/styles/store-theme.less';

.section {
    padding: 0;
    margin: 0;
    width: 100%;
    min-height: 100dvh;
    position: relative;
    box-sizing: border-box;
}

.hero-section {
    display: flex;
    user-select: none;
    flex-direction: column;
    background: @home-gradient-pale;
    overflow: hidden;
}

.hero-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.hero-bg-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        125deg,
        @home-gradient-pale 0%,
        fade(@home-gradient-mint, 92%) 16%,
        fade(@home-gradient-teal, 78%) 34%,
        fade(@home-gradient-green, 82%) 52%,
        fade(@home-gradient-lime, 55%) 68%,
        fade(@home-gradient-mint, 88%) 84%,
        fade(@home-gradient-emerald, 72%) 100%
    );
    background-size: 320% 320%;
    animation: heroGradientFlow 12s ease-in-out infinite;
}

.hero-bg-shimmer {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 140%;
    height: 140%;
    transform: translate(-50%, -50%);
    background: conic-gradient(
        from 0deg at 50% 50%,
        fade(@home-gradient-teal, 0%) 0deg,
        fade(@home-gradient-aqua, 28%) 72deg,
        fade(@home-gradient-lime, 18%) 144deg,
        fade(@home-gradient-emerald, 24%) 216deg,
        fade(@home-gradient-mint, 14%) 288deg,
        fade(@home-gradient-teal, 0%) 360deg
    );
    opacity: 0.55;
    filter: blur(48px);
    animation: shimmerRotate 18s linear infinite;
}

.hero-bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(64px);
    opacity: 0.55;
    will-change: transform, opacity;
}

.hero-bg-orb--1 {
    width: clamp(260px, 38vw, 520px);
    height: clamp(260px, 38vw, 520px);
    top: -14%;
    right: -8%;
    background: radial-gradient(circle, fade(@home-gradient-emerald, 72%) 0%, fade(@home-gradient-green, 38%) 42%, transparent 72%);
    animation: orbFloatOne 10s ease-in-out infinite;
}

.hero-bg-orb--2 {
    width: clamp(240px, 34vw, 420px);
    height: clamp(240px, 34vw, 420px);
    bottom: 0%;
    left: -12%;
    background: radial-gradient(circle, fade(@home-gradient-aqua, 68%) 0%, fade(@home-gradient-teal, 32%) 48%, transparent 74%);
    animation: orbFloatTwo 13s ease-in-out infinite;
}

.hero-bg-orb--3 {
    width: clamp(200px, 26vw, 340px);
    height: clamp(200px, 26vw, 340px);
    top: 28%;
    left: 26%;
    background: radial-gradient(circle, fade(#fff, 92%) 0%, fade(@home-gradient-lime, 36%) 38%, transparent 72%);
    animation: orbFloatThree 9s ease-in-out infinite;
}

.hero-bg-orb--4 {
    width: clamp(180px, 24vw, 320px);
    height: clamp(180px, 24vw, 320px);
    bottom: 18%;
    right: 12%;
    background: radial-gradient(circle, fade(@home-gradient-lime, 58%) 0%, fade(@home-gradient-deep, 28%) 50%, transparent 76%);
    animation: orbFloatFour 11s ease-in-out infinite;
}

.hero-inner {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(18px, 4vw, 56px);
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
    padding: clamp(88px, 11vh, 124px) @store-page-padding-x clamp(74px, 10vh, 104px);
    box-sizing: border-box;
}

.hero-visual {
    flex: 0 0 auto;
    user-select: none;
    max-width: min(44vw, 460px);
}

.hero-illustration {
    width: 100%;
    max-width: 420px;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 16px 32px rgba(27, 48, 34, 0.12));
}

.floating-button {
    z-index: 2;
    background-color: fade(#fff, 58%);
    color: @home-primary;
    position: absolute;
    bottom: clamp(20px, 5vh, 44px);
    left: 50%;
    transform: translateX(-50%);
    border: 1px solid fade(@home-primary, 16%);
    backdrop-filter: blur(8px);
    transition: transform 0.22s ease, background-color 0.22s ease, color 0.22s ease;

    &:hover {
        transform: translateX(-50%) translateY(-2px);
        background-color: @home-primary;
        color: #fff;
    }
}

.features-wrap {
    min-height: auto;
    background: linear-gradient(180deg, #f2fbf5 0%, #edf8f1 100%);
    overflow: hidden;
}

.features-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.features-bg-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        145deg,
        fade(@home-bg-page, 96%) 0%,
        fade(@home-gradient-mint, 48%) 35%,
        fade(@home-gradient-teal, 38%) 65%,
        fade(@home-gradient-aqua, 28%) 100%
    );
    background-size: 240% 240%;
    animation: featuresGradientFlow 16s ease-in-out infinite alternate;
}

.features-bg-orb {
    position: absolute;
    width: clamp(280px, 42vw, 560px);
    height: clamp(280px, 42vw, 560px);
    top: -20%;
    right: -15%;
    border-radius: 50%;
    background: radial-gradient(circle, fade(@home-gradient-teal, 42%) 0%, fade(@home-gradient-mint, 18%) 50%, transparent 72%);
    filter: blur(72px);
    opacity: 0.5;
    animation: featuresOrbFloat 14s ease-in-out infinite;
}

.features-wrap > :not(.features-bg) {
    position: relative;
    z-index: 1;
}

.site-footer {
    background: linear-gradient(120deg, @home-primary 0%, fade(@home-primary, 88%) 100%);
    color: fade(#fff, 82%);
    font-size: 13px;
    text-align: center;
    padding: 18px 16px;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: @app-breakpoint-lg) {
    .hero-inner {
        flex-direction: column;
        text-align: center;
        justify-content: stretch;
        align-items: stretch;
        min-height: calc(100dvh - 72px);
        padding-top: clamp(34px, 6vh, 58px);
        padding-bottom: clamp(24px, 4vh, 40px);
        gap: 8px;
    }

    .hero-visual {
        display: none;
    }

    .floating-button {
        bottom: 20px;
    }
}

@keyframes heroGradientFlow {
    0% {
        background-position: 0% 0%;
        filter: saturate(1) hue-rotate(0deg);
    }
    33% {
        background-position: 100% 0%;
        filter: saturate(1.12) hue-rotate(6deg);
    }
    66% {
        background-position: 100% 100%;
        filter: saturate(1.18) hue-rotate(-4deg);
    }
    100% {
        background-position: 0% 100%;
        filter: saturate(1.08) hue-rotate(0deg);
    }
}

@keyframes shimmerRotate {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

@keyframes featuresGradientFlow {
    0% {
        background-position: 0% 50%;
    }
    100% {
        background-position: 100% 50%;
    }
}

@keyframes featuresOrbFloat {
    0%,
    100% {
        transform: translate3d(0, 0, 0) scale(1);
        opacity: 0.42;
    }
    50% {
        transform: translate3d(-28px, 24px, 0) scale(1.12);
        opacity: 0.62;
    }
}

@keyframes orbFloatOne {
    0%,
    100% {
        transform: translate3d(0, 0, 0) scale(1);
        opacity: 0.52;
    }
    50% {
        transform: translate3d(-36px, 32px, 0) scale(1.14);
        opacity: 0.78;
    }
}

@keyframes orbFloatTwo {
    0%,
    100% {
        transform: translate3d(0, 0, 0) scale(1);
        opacity: 0.48;
    }
    50% {
        transform: translate3d(40px, -28px, 0) scale(1.16);
        opacity: 0.72;
    }
}

@keyframes orbFloatThree {
    0%,
    100% {
        transform: translate3d(0, 0, 0) scale(1);
        opacity: 0.44;
    }
    50% {
        transform: translate3d(-24px, -22px, 0) scale(1.18);
        opacity: 0.68;
    }
}

@keyframes orbFloatFour {
    0%,
    100% {
        transform: translate3d(0, 0, 0) scale(1);
        opacity: 0.4;
    }
    50% {
        transform: translate3d(20px, 18px, 0) scale(1.1);
        opacity: 0.64;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hero-bg-gradient,
    .hero-bg-shimmer,
    .hero-bg-orb,
    .features-bg-gradient,
    .features-bg-orb {
        animation: none;
    }

    .hero-bg-shimmer {
        opacity: 0.35;
    }
}
</style>
