/* ==================== 動畫效果 ==================== */

/* 淡入動畫 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* 從下滑入 */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(60px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 從左滑入 */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-60px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 從右滑入 */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(60px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 縮放進入 */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* 旋轉進入 */
@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-10deg) scale(0.8);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

/* 彈跳效果 */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-20px);
    }
    60% {
        transform: translateY(-10px);
    }
}

/* 脈衝效果 */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

/* 光暈效果 */
@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 20px currentColor;
    }
    50% {
        box-shadow: 0 0 40px currentColor;
    }
}

/* 漸變移動 */
@keyframes gradientMove {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* 閃爍效果 */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

/* 浮動效果 */
@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-20px);
    }
}

/* 旋轉 */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ==================== AOS (Animate On Scroll) 樣式 ==================== */

[data-aos] {
    opacity: 0;
    transition-property: opacity, transform;
    transition-duration: 0.8s;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

[data-aos].aos-animate {
    opacity: 1;
}

/* Fade 效果 */
[data-aos="fade"] {
    opacity: 0;
}

[data-aos="fade"].aos-animate {
    opacity: 1;
}

/* Fade Up */
[data-aos="fade-up"] {
    transform: translateY(60px);
}

[data-aos="fade-up"].aos-animate {
    transform: translateY(0);
}

/* Fade Down */
[data-aos="fade-down"] {
    transform: translateY(-60px);
}

[data-aos="fade-down"].aos-animate {
    transform: translateY(0);
}

/* Fade Left */
[data-aos="fade-left"] {
    transform: translateX(60px);
}

[data-aos="fade-left"].aos-animate {
    transform: translateX(0);
}

/* Fade Right */
[data-aos="fade-right"] {
    transform: translateX(-60px);
}

[data-aos="fade-right"].aos-animate {
    transform: translateX(0);
}

/* Zoom In */
[data-aos="zoom-in"] {
    transform: scale(0.8);
}

[data-aos="zoom-in"].aos-animate {
    transform: scale(1);
}

/* Zoom Out */
[data-aos="zoom-out"] {
    transform: scale(1.2);
}

[data-aos="zoom-out"].aos-animate {
    transform: scale(1);
}

/* Flip */
[data-aos="flip-up"] {
    transform: perspective(1000px) rotateX(90deg);
    transform-origin: center bottom;
}

[data-aos="flip-up"].aos-animate {
    transform: perspective(1000px) rotateX(0);
}

/* ==================== 延遲動畫 ==================== */

[data-aos-delay="200"] {
    transition-delay: 0.2s;
}

[data-aos-delay="400"] {
    transition-delay: 0.4s;
}

[data-aos-delay="600"] {
    transition-delay: 0.6s;
}

[data-aos-delay="800"] {
    transition-delay: 0.8s;
}

[data-aos-delay="1000"] {
    transition-delay: 1s;
}

/* ==================== 持續動畫效果 ==================== */

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-bounce {
    animation: bounce 1s infinite;
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

.animate-glow {
    animation: glow 2s ease-in-out infinite;
}

.animate-gradient {
    background-size: 200% 200%;
    animation: gradientMove 3s ease infinite;
}

/* ==================== 懸停動畫 ==================== */

.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.hover-scale {
    transition: transform 0.3s ease;
}

.hover-scale:hover {
    transform: scale(1.05);
}

.hover-rotate {
    transition: transform 0.3s ease;
}

.hover-rotate:hover {
    transform: rotate(5deg);
}

.hover-glow {
    transition: box-shadow 0.3s ease, filter 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 30px currentColor;
    filter: brightness(1.2);
}

/* ==================== 背景動畫 ==================== */

.bg-animate {
    background: linear-gradient(
        -45deg,
        rgba(255, 215, 0, 0.1),
        rgba(147, 51, 234, 0.1),
        rgba(0, 212, 255, 0.1),
        rgba(255, 51, 102, 0.1)
    );
    background-size: 400% 400%;
    animation: gradientMove 15s ease infinite;
}

/* ==================== 文字動畫 ==================== */

.text-shimmer {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.3) 0%,
        rgba(255, 255, 255, 0.8) 50%,
        rgba(255, 255, 255, 0.3) 100%
    );
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    animation: shimmer 3s linear infinite;
}

.text-gradient-animate {
    background: linear-gradient(
        90deg,
        #ffd700,
        #9333ea,
        #00d4ff,
        #ff3366,
        #00ff88,
        #ffd700
    );
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientMove 5s linear infinite;
}

/* ==================== 載入動畫 ==================== */

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #fff;
    border-radius: 50%;
    animation: rotate 1s linear infinite;
}

.loading-dots {
    display: flex;
    gap: 8px;
}

.loading-dots span {
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

/* ==================== 粒子動畫 ==================== */

@keyframes particleFloat {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) rotate(360deg);
        opacity: 0;
    }
}

/* ==================== 視差效果類 ==================== */

.parallax-slow {
    transform: translateY(var(--scroll-slow, 0));
    transition: transform 0.1s linear;
}

.parallax-medium {
    transform: translateY(var(--scroll-medium, 0));
    transition: transform 0.1s linear;
}

.parallax-fast {
    transform: translateY(var(--scroll-fast, 0));
    transition: transform 0.1s linear;
}

/* ==================== 頁面轉場效果 ==================== */

/* Legend 模型 - 聚焦縮放 */
.legend-theme .model-content {
    opacity: 0;
}

.legend-theme.visible .model-content {
    animation: focusZoom 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes focusZoom {
    0% {
        opacity: 0;
        transform: scale(2) blur(10px);
        filter: blur(20px);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.3);
        filter: blur(5px);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        filter: blur(0);
    }
}

/* Legend 背景聚焦效果 */
.legend-theme .model-background {
    animation: focusGlow 1.2s ease-out, pulse 4s ease-in-out 1.2s infinite;
}

@keyframes focusGlow {
    0% {
        opacity: 0;
        transform: scale(3);
        filter: blur(50px);
    }
    100% {
        opacity: 0.05;
        transform: scale(1);
        filter: blur(0);
    }
}

/* Core 模型 - 從左滑入 + 縮放 */
.core-theme .model-content {
    opacity: 0;
}

.core-theme.visible .model-content {
    animation: slideInLeftScale 1s ease-out forwards;
}

@keyframes slideInLeftScale {
    from {
        opacity: 0;
        transform: translateX(-100px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* Ultimate 模型 - 分裂進入 */
.ultimate-theme .model-content {
    opacity: 0;
}

.ultimate-theme.visible .model-content {
    animation: splitIn 1s ease-out forwards;
}

@keyframes splitIn {
    from {
        opacity: 0;
        transform: scaleX(0.3) scaleY(1.2);
    }
    to {
        opacity: 1;
        transform: scaleX(1) scaleY(1);
    }
}

/* Fast 模型 - 閃電進入 */
.fast-theme .model-content {
    opacity: 0;
}

.fast-theme.visible .model-content {
    animation: lightningIn 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes lightningIn {
    0% {
        opacity: 0;
        transform: translateY(-50px) translateX(50px) rotate(5deg);
    }
    50% {
        opacity: 0.5;
        transform: translateY(25px) translateX(-25px) rotate(-3deg);
    }
    100% {
        opacity: 1;
        transform: translateY(0) translateX(0) rotate(0);
    }
}

/* Pro 模型 - 翻轉進入 */
.pro-theme .model-content {
    opacity: 0;
}

.pro-theme.visible .model-content {
    animation: flipIn 1s ease-out forwards;
}

@keyframes flipIn {
    from {
        opacity: 0;
        transform: perspective(1000px) rotateY(-90deg);
    }
    to {
        opacity: 1;
        transform: perspective(1000px) rotateY(0);
    }
}

/* ==================== 區塊轉場效果 ==================== */

/* 移除 section 的 opacity 控制，讓 CSS 動畫自然播放 */
.section {
    opacity: 1;
}

/* ==================== 模型特性卡片動畫 ==================== */

/* Legend - 波浪進入 */
.legend-theme .feature-card {
    animation: waveIn 0.6s ease-out backwards;
}

.legend-theme .feature-card:nth-child(1) { animation-delay: 0.1s; }
.legend-theme .feature-card:nth-child(2) { animation-delay: 0.2s; }
.legend-theme .feature-card:nth-child(3) { animation-delay: 0.3s; }
.legend-theme .feature-card:nth-child(4) { animation-delay: 0.4s; }

@keyframes waveIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Core - 從中心擴散 */
.core-theme .feature-card {
    animation: expandIn 0.6s ease-out backwards;
}

.core-theme .feature-card:nth-child(1) { animation-delay: 0.1s; }
.core-theme .feature-card:nth-child(2) { animation-delay: 0.2s; }
.core-theme .feature-card:nth-child(3) { animation-delay: 0.3s; }
.core-theme .feature-card:nth-child(4) { animation-delay: 0.4s; }

@keyframes expandIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Ultimate - 旋轉進入 */
.ultimate-theme .feature-card {
    animation: spinIn 0.6s ease-out backwards;
}

.ultimate-theme .feature-card:nth-child(1) { animation-delay: 0.1s; }
.ultimate-theme .feature-card:nth-child(2) { animation-delay: 0.2s; }
.ultimate-theme .feature-card:nth-child(3) { animation-delay: 0.3s; }
.ultimate-theme .feature-card:nth-child(4) { animation-delay: 0.4s; }

@keyframes spinIn {
    from {
        opacity: 0;
        transform: rotate(-180deg) scale(0.5);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

/* Fast - 閃現進入 */
.fast-theme .feature-card {
    animation: flashIn 0.4s ease-out backwards;
}

.fast-theme .feature-card:nth-child(1) { animation-delay: 0.05s; }
.fast-theme .feature-card:nth-child(2) { animation-delay: 0.1s; }
.fast-theme .feature-card:nth-child(3) { animation-delay: 0.15s; }
.fast-theme .feature-card:nth-child(4) { animation-delay: 0.2s; }

@keyframes flashIn {
    0% {
        opacity: 0;
        transform: translateX(-50px);
    }
    50% {
        opacity: 1;
        transform: translateX(10px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Pro - 彈跳進入 */
.pro-theme .feature-card {
    animation: bounceIn 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) backwards;
}

.pro-theme .feature-card:nth-child(1) { animation-delay: 0.1s; }
.pro-theme .feature-card:nth-child(2) { animation-delay: 0.2s; }
.pro-theme .feature-card:nth-child(3) { animation-delay: 0.3s; }
.pro-theme .feature-card:nth-child(4) { animation-delay: 0.4s; }

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: translateY(-100px);
    }
    60% {
        opacity: 1;
        transform: translateY(20px);
    }
    80% {
        transform: translateY(-10px);
    }
    100% {
        transform: translateY(0);
    }
}

/* ==================== 區塊背景動畫 ==================== */

/* Legend 背景已在上面定義 focusGlow + pulse */

.core-theme .model-background {
    animation: coreRotate 20s linear infinite;
}

@keyframes coreRotate {
    from {
        transform: rotate(0deg) scale(1);
    }
    to {
        transform: rotate(360deg) scale(1);
    }
}

.ultimate-theme .model-background {
    animation: ultimateFloat 6s ease-in-out infinite;
}

@keyframes ultimateFloat {
    0%, 100% {
        transform: translateY(0px) translateX(0px);
    }
    25% {
        transform: translateY(-15px) translateX(10px);
    }
    50% {
        transform: translateY(-10px) translateX(-10px);
    }
    75% {
        transform: translateY(5px) translateX(5px);
    }
}

.fast-theme .model-background {
    animation: fastShake 0.5s ease-in-out infinite;
}

@keyframes fastShake {
    0%, 100% { 
        transform: translateX(0) translateY(0); 
    }
    10% { 
        transform: translateX(-2px) translateY(2px); 
    }
    20% { 
        transform: translateX(2px) translateY(-2px); 
    }
    30% { 
        transform: translateX(-2px) translateY(-2px); 
    }
    40% { 
        transform: translateX(2px) translateY(2px); 
    }
    50% { 
        transform: translateX(-1px) translateY(-1px); 
    }
    60% { 
        transform: translateX(1px) translateY(1px); 
    }
    70% { 
        transform: translateX(-1px) translateY(1px); 
    }
    80% { 
        transform: translateX(1px) translateY(-1px); 
    }
    90% { 
        transform: translateX(-1px) translateY(0); 
    }
}

.pro-theme .model-background {
    animation: proGradientMove 10s ease infinite;
    background-size: 400% 400%;
}

@keyframes proGradientMove {
    0% {
        background-position: 0% 50%;
        transform: scale(1);
    }
    25% {
        background-position: 50% 75%;
        transform: scale(1.05);
    }
    50% {
        background-position: 100% 50%;
        transform: scale(1);
    }
    75% {
        background-position: 50% 25%;
        transform: scale(0.95);
    }
    100% {
        background-position: 0% 50%;
        transform: scale(1);
    }
}

/* ==================== Ultimate Code 主題動畫 ==================== */

/* Ultimate Code - 分裂進入 (保留原 Ultimate 的動畫) */
.ultimate-code-theme .model-content {
    opacity: 0;
}

.ultimate-code-theme.visible .model-content {
    animation: splitIn 1s ease-out forwards;
}

/* Ultimate Code - 特性卡片旋轉進入 */
.ultimate-code-theme .feature-card {
    animation: spinIn 0.6s ease-out backwards;
}

.ultimate-code-theme .feature-card:nth-child(1) { animation-delay: 0.1s; }
.ultimate-code-theme .feature-card:nth-child(2) { animation-delay: 0.2s; }
.ultimate-code-theme .feature-card:nth-child(3) { animation-delay: 0.3s; }
.ultimate-code-theme .feature-card:nth-child(4) { animation-delay: 0.4s; }

/* Ultimate Code 背景動畫 */
.ultimate-code-theme .model-background {
    animation: ultimateCodeFloat 6s ease-in-out infinite;
}

@keyframes ultimateCodeFloat {
    0%, 100% {
        transform: translateY(0px) translateX(0px);
    }
    25% {
        transform: translateY(-15px) translateX(10px);
    }
    50% {
        transform: translateY(-10px) translateX(-10px);
    }
    75% {
        transform: translateY(5px) translateX(5px);
    }
}

/* ==================== 新 Ultimate 主題動畫 ==================== */

/* Ultimate - 螺旋進入 */
.ultimate-theme .model-content {
    opacity: 0;
}

.ultimate-theme.visible .model-content {
    animation: spiralIn 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes spiralIn {
    0% {
        opacity: 0;
        transform: scale(0.3) rotate(-360deg) translateY(100px);
    }
    60% {
        opacity: 0.8;
        transform: scale(1.1) rotate(20deg) translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0) translateY(0);
    }
}

/* Ultimate - 特性卡片螺旋展開 */
.ultimate-theme .feature-card {
    animation: spiralExpand 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.ultimate-theme .feature-card:nth-child(1) { animation-delay: 0.15s; }
.ultimate-theme .feature-card:nth-child(2) { animation-delay: 0.25s; }
.ultimate-theme .feature-card:nth-child(3) { animation-delay: 0.35s; }
.ultimate-theme .feature-card:nth-child(4) { animation-delay: 0.45s; }

@keyframes spiralExpand {
    0% {
        opacity: 0;
        transform: scale(0) rotate(-180deg);
    }
    70% {
        opacity: 1;
        transform: scale(1.1) rotate(10deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0);
    }
}

/* Ultimate 背景動畫 - 脈衝旋轉 */
.ultimate-theme .model-background {
    animation: ultimatePulseRotate 8s ease-in-out infinite;
}

@keyframes ultimatePulseRotate {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        opacity: 0.05;
    }
    50% {
        transform: scale(1.2) rotate(180deg);
        opacity: 0.08;
    }
}

/* ==================== Thinking 主題動畫 ==================== */

/* Thinking - 思考波紋擴散 */
.thinking-theme .model-content {
    opacity: 0;
}

.thinking-theme.visible .model-content {
    animation: thinkingRipple 1.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes thinkingRipple {
    0% {
        opacity: 0;
        transform: scale(0.5);
        filter: blur(20px);
    }
    30% {
        opacity: 0.3;
        transform: scale(0.8);
        filter: blur(10px);
    }
    60% {
        opacity: 0.7;
        transform: scale(1.05);
        filter: blur(3px);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        filter: blur(0);
    }
}

/* Thinking - 特性卡片波紋進入 */
.thinking-theme .feature-card {
    animation: rippleIn 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.thinking-theme .feature-card:nth-child(1) { animation-delay: 0.2s; }
.thinking-theme .feature-card:nth-child(2) { animation-delay: 0.3s; }
.thinking-theme .feature-card:nth-child(3) { animation-delay: 0.4s; }
.thinking-theme .feature-card:nth-child(4) { animation-delay: 0.5s; }

@keyframes rippleIn {
    0% {
        opacity: 0;
        transform: scale(0.7);
        box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.7);
    }
    50% {
        box-shadow: 0 0 0 30px rgba(6, 182, 212, 0);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(6, 182, 212, 0);
    }
}

/* Thinking 背景動畫 - 思考脈衝 */
.thinking-theme .model-background {
    animation: thinkingPulse 6s ease-in-out infinite;
}

@keyframes thinkingPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.05;
    }
    25% {
        transform: scale(1.1);
        opacity: 0.08;
    }
    50% {
        transform: scale(0.95);
        opacity: 0.03;
    }
    75% {
        transform: scale(1.05);
        opacity: 0.07;
    }
}

/* ==================== 性能優化 ==================== */

.will-animate {
    will-change: transform, opacity;
}

.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}
