/* ============================================================
   云能官网 - 首页入场过渡动画
   设计：品牌渐变帷幕（上下两片）→ logo/标题/进度条 → 帷幕拉开 → hero 内容错峰入场
   兼容：桌面端 + 移动端（clamp/视口单位 + 媒体查询微调）
   ============================================================ */

/* ---------- 动画期间锁定页面滚动 ---------- */
html.intro-lock,
html.intro-lock body {
    overflow: hidden;
    height: 100%;
}

/* ============================================================
   1. 全屏遮罩容器
   ============================================================ */
#intro-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483000; /* 高于一切导航/内容 */
    overflow: hidden;
    pointer-events: auto; /* 动画期间拦截点击，避免误操作 */
    visibility: visible;
    opacity: 1;
}

/* ---------- 上下两片帷幕 ---------- */
.intro-curtain {
    position: absolute;
    left: 0;
    right: 0;
    height: 50.5%;
    will-change: transform;
    transition: transform 0.7s cubic-bezier(0.76, 0, 0.24, 1);
    backface-visibility: hidden;
}

.intro-curtain--top {
    top: 0;
    background:
        radial-gradient(120% 140% at 20% 0%, rgba(255, 255, 255, 0.10) 0%, transparent 55%),
        radial-gradient(90% 120% at 85% 15%, rgba(0, 190, 255, 0.25) 0%, transparent 60%),
        linear-gradient(160deg, #082f7d 0%, #0066cc 55%, #0052a8 100%);
}

.intro-curtain--bottom {
    bottom: 0;
    background:
        radial-gradient(120% 140% at 80% 100%, rgba(255, 255, 255, 0.08) 0%, transparent 55%),
        radial-gradient(90% 120% at 15% 85%, rgba(0, 190, 255, 0.20) 0%, transparent 60%),
        linear-gradient(-160deg, #082f7d 0%, #0066cc 55%, #0052a8 100%);
}

/* 帷幕上的流动光泽（高级感：缓慢扫过的柔光） */
.intro-curtain::after {
    content: '';
    position: absolute;
    left: -30%;
    top: -20%;
    width: 45%;
    height: 140%;
    background: linear-gradient(105deg, transparent 0%, rgba(255, 255, 255, 0.14) 45%, rgba(255, 255, 255, 0.28) 50%, rgba(255, 255, 255, 0.14) 55%, transparent 100%);
    transform: rotate(12deg);
    animation: introSheen 2.6s cubic-bezier(0.4, 0, 0.2, 1) both;
    pointer-events: none;
}

@keyframes introSheen {
    0%   { left: -45%; opacity: 0; }
    18%  { opacity: 1; }
    55%  { left: 130%; opacity: 0; }
    100% { left: 130%; opacity: 0; }
}

/* ---------- 中央内容（logo / 标题 / 标语 / 进度条） ---------- */
.intro-content {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(10px, 1.6vw, 16px);
    color: #fff;
    text-align: center;
    transform: translateZ(0);
}

/* logo 图标 + 扩散光环 */
.intro-logo {
    position: relative;
    width: clamp(84px, 9vw, 108px);
    height: clamp(84px, 9vw, 108px);
    margin-bottom: clamp(6px, 0.8vw, 10px);
}

.intro-logo img {
    width: 100%;
    height: 100%;
    border-radius: 26%;
    object-fit: cover;
    box-shadow: 0 clamp(12px, 2vw, 26px) clamp(30px, 5vw, 60px) rgba(0, 0, 0, 0.35);
    animation: introLogoIn 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.intro-logo-ring {
    position: absolute;
    inset: -18%;
    border-radius: 32%;
    border: 1.5px solid rgba(255, 255, 255, 0.55);
    animation: introRing 2.1s cubic-bezier(0.22, 1, 0.36, 1) 0.35s infinite;
    pointer-events: none;
}

@keyframes introLogoIn {
    0%   { opacity: 0; transform: scale(0.55) translateY(14px); }
    60%  { opacity: 1; transform: scale(1.06) translateY(-2px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes introRing {
    0%   { transform: scale(1);    opacity: 0.7; }
    70%  { transform: scale(1.75); opacity: 0; }
    100% { transform: scale(1.75); opacity: 0; }
}

/* 标题 / 标语 */
.intro-name {
    font-size: clamp(28px, 4vw, 40px);
    font-weight: 800;
    letter-spacing: clamp(6px, 1.4vw, 12px);
    text-indent: clamp(6px, 1.4vw, 12px); /* 抵消字距导致的视觉偏移，保持居中 */
    text-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
    animation: introFadeUp 0.85s cubic-bezier(0.22, 1, 0.36, 1) 0.12s both;
}

.intro-tagline {
    font-size: clamp(13px, 1.6vw, 16px);
    letter-spacing: clamp(2px, 0.5vw, 4px);
    opacity: 0.88;
    animation: introFadeUp 0.85s cubic-bezier(0.22, 1, 0.36, 1) 0.26s both;
}

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

/* 底部进度条 */
.intro-progress {
    width: clamp(150px, 22vw, 220px);
    height: 3px;
    margin-top: clamp(18px, 2.5vw, 26px);
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.22);
    overflow: hidden;
}

.intro-progress-bar {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 99px;
    background: linear-gradient(90deg, #ffffff, #bfe3ff);
    animation: introProgress 1.05s cubic-bezier(0.65, 0, 0.35, 1) 0.1s both;
    will-change: width;
}

@keyframes introProgress {
    0%   { width: 0; }
    100% { width: 100%; }
}

/* ============================================================
   2. 揭幕阶段（JS 在 1.15s 时给遮罩加 is-revealing）
   ============================================================ */
#intro-overlay.is-revealing .intro-content {
    animation: introFadeOut 0.42s cubic-bezier(0.55, 0, 0.55, 0.2) both;
}

#intro-overlay.is-revealing .intro-curtain--top {
    transform: translateY(-101%);
}

#intro-overlay.is-revealing .intro-curtain--bottom {
    transform: translateY(101%);
}

@keyframes introFadeOut {
    to { opacity: 0; transform: scale(0.92) translateY(-10px); }
}

/* ============================================================
   3. Hero 内容错峰入场（entrance-ready 隐藏 -> entrance-done 浮现）
      通用规则仅使用 opacity + transform（全平台稳定）；
      模糊聚焦只在桌面端（≥768px）启用，规避移动端 WebKit 的 filter 残留 bug
   ============================================================ */
html.entrance-ready .hero-content h1,
html.entrance-ready .hero-content h2,
html.entrance-ready .hero-content p,
html.entrance-ready .hero-buttons,
html.entrance-ready .hero-image {
    opacity: 0;
    transform: translateY(28px);
    will-change: opacity, transform;
}

html.entrance-done .hero-content h1,
html.entrance-done .hero-content h2,
html.entrance-done .hero-content p,
html.entrance-done .hero-buttons,
html.entrance-done .hero-image {
    opacity: 1;
    transform: translateY(0);
    transition:
        opacity 0.75s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.75s cubic-bezier(0.22, 1, 0.36, 1);
}

/* 桌面端增强：模糊聚焦（仅在 ≥768px 启用） */
@media (min-width: 768px) {
    html.entrance-ready .hero-content h1,
    html.entrance-ready .hero-content h2,
    html.entrance-ready .hero-content p,
    html.entrance-ready .hero-buttons,
    html.entrance-ready .hero-image {
        filter: blur(10px);
    }

    html.entrance-done .hero-content h1,
    html.entrance-done .hero-content h2,
    html.entrance-done .hero-content p,
    html.entrance-done .hero-buttons,
    html.entrance-done .hero-image {
        filter: blur(0);
        transition:
            opacity 0.75s cubic-bezier(0.22, 1, 0.36, 1),
            transform 0.75s cubic-bezier(0.22, 1, 0.36, 1),
            filter 0.75s ease;
    }
}

/* 错峰时间 */
html.entrance-done .hero-content h1        { transition-delay: 0.10s; }
html.entrance-done .hero-content h2        { transition-delay: 0.20s; }
html.entrance-done .hero-content p         { transition-delay: 0.30s; }
html.entrance-done .hero-content .hero-buttons { transition-delay: 0.40s; }
html.entrance-done .hero-image             { transition-delay: 0.28s; }

/* ============================================================
   4. 移动端适配（< 768px）：更紧凑、更快、更稳
   ============================================================ */
@media (max-width: 767px) {
    #intro-overlay.is-revealing .intro-curtain--top,
    #intro-overlay.is-revealing .intro-curtain--bottom {
        transition-duration: 0.55s; /* 移动端揭幕略快 */
    }

    /* 移动端 Hero 错峰幅度更小，减少小屏上的位移感（不使用 filter，规避移动端渲染 bug） */
    html.entrance-ready .hero-content h1,
    html.entrance-ready .hero-content h2,
    html.entrance-ready .hero-content p,
    html.entrance-ready .hero-buttons,
    html.entrance-ready .hero-image {
        transform: translateY(18px);
    }

    html.entrance-done .hero-content h1        { transition-delay: 0.08s; }
    html.entrance-done .hero-content h2        { transition-delay: 0.16s; }
    html.entrance-done .hero-content p         { transition-delay: 0.24s; }
    html.entrance-done .hero-content .hero-buttons { transition-delay: 0.32s; }
    html.entrance-done .hero-image             { transition-delay: 0.22s; }
}

/* 小屏（< 480px）进一步压缩间距，避免首屏拥挤 */
@media (max-width: 479px) {
    .intro-content { gap: 8px; }
    .intro-logo { margin-bottom: 2px; }
    .intro-progress { margin-top: 14px; }
}

/* ============================================================
   6. 无 JS 兜底：entrance.js 未加载时，用纯 CSS 自动落幕
      （entrance.js 运行后会给 <html> 添加 .js-entrance，本段自动失效）
   ============================================================ */
html:not(.js-entrance) #intro-overlay {
    animation: introAutoHide 0.01s linear 2.3s forwards;
}

html:not(.js-entrance) .intro-content {
    animation: introFadeOut 0.4s cubic-bezier(0.55, 0, 0.55, 0.2) 1.7s both;
}

html:not(.js-entrance) .intro-curtain--top {
    animation: introCurtainTop 0.7s cubic-bezier(0.76, 0, 0.24, 1) 1.7s both;
}

html:not(.js-entrance) .intro-curtain--bottom {
    animation: introCurtainBottom 0.7s cubic-bezier(0.76, 0, 0.24, 1) 1.7s both;
}

@keyframes introCurtainTop {
    to { transform: translateY(-101%); }
}

@keyframes introCurtainBottom {
    to { transform: translateY(101%); }
}

@keyframes introAutoHide {
    to { visibility: hidden; pointer-events: none; }
}

/* ============================================================
   7. 无障碍：用户偏好减少动效时，直接跳过动画
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    #intro-overlay { display: none !important; }

    html.entrance-ready .hero-content h1,
    html.entrance-ready .hero-content h2,
    html.entrance-ready .hero-content p,
    html.entrance-ready .hero-buttons,
    html.entrance-ready .hero-image {
        opacity: 1;
        transform: none;
        filter: none;
    }
}
