/*
# morphing.css
# Written by: 广州羲驭科技有限公司
# Description: Morphing shape animations for Vista Geometric Glass.
# Copyright: © 2024-2025 广州羲驭科技有限公司. All rights reserved. | 粤ICP备2025458335号
*/

/* ===== Morphing 形状变形动画系统 ===== */

/* ===== 基础变形效果 ===== */

/* 液态形状变形 */
.morphing-shape {
  background: linear-gradient(135deg, var(--geo-primary), var(--geo-secondary));
  animation: morph 8s ease-in-out infinite;
  will-change: border-radius, transform;
}

@keyframes morph {
  0%, 100% {
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    transform: rotate(0deg);
  }
  25% {
    border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
    transform: rotate(90deg);
  }
  50% {
    border-radius: 50% 60% 30% 60% / 30% 60% 70% 40%;
    transform: rotate(180deg);
  }
  75% {
    border-radius: 70% 30% 40% 60% / 40% 70% 60% 30%;
    transform: rotate(270deg);
  }
}

/* 快速变形 */
.morphing-shape-fast {
  animation: morph 4s ease-in-out infinite;
}

/* 慢速变形 */
.morphing-shape-slow {
  animation: morph 12s ease-in-out infinite;
}

/* ===== 液态玻璃效果 ===== */

/* 液态玻璃卡片 */
.liquid-glass {
  background: var(--glass-layer-3);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
  animation: liquid 10s ease-in-out infinite;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow:
    0 0 40px rgba(0, 217, 199, 0.15),
    inset 0 0 30px rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
  will-change: border-radius, box-shadow;
}

.liquid-glass:hover {
  box-shadow:
    0 0 60px rgba(0, 217, 199, 0.25),
    inset 0 0 40px rgba(255, 255, 255, 0.15);
}

@keyframes liquid {
  0%, 100% {
    border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    transform: translate(0, 0) rotate(0deg);
  }
  25% {
    border-radius: 58% 42% 75% 25% / 76% 46% 54% 24%;
    transform: translate(5px, -5px) rotate(2deg);
  }
  50% {
    border-radius: 50% 50% 33% 67% / 55% 27% 73% 45%;
    transform: translate(-5px, 5px) rotate(-2deg);
  }
  75% {
    border-radius: 33% 67% 58% 42% / 63% 68% 32% 37%;
    transform: translate(5px, 5px) rotate(1deg);
  }
}

/* ===== 弹性变形效果 ===== */

/* 弹性按钮 */
.elastic-button {
  position: relative;
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.elastic-button:hover {
  transform: scale(1.1);
}

.elastic-button:active {
  transform: scale(0.95);
}

/* 弹性卡片 */
.elastic-card {
  transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55),
              box-shadow 0.4s ease;
}

.elastic-card:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3);
}

.elastic-card:active {
  transform: translateY(-5px) scale(0.99);
}

/* ===== 脉冲变形 ===== */

/* 脉冲圆环 */
.pulse-ring {
  position: relative;
}

.pulse-ring::before {
  content: '';
  position: absolute;
  inset: -10px;
  border: 2px solid var(--vista-glass-teal);
  border-radius: inherit;
  animation: pulse-ring 2s ease-out infinite;
  opacity: 0;
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.8);
    opacity: 1;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* 脉冲扩散 */
.pulse-expand {
  animation: pulse-expand 2s ease-in-out infinite;
}

@keyframes pulse-expand {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

/* ===== 波浪效果 ===== */

/* 波浪容器 */
.wave-container {
  position: relative;
  overflow: hidden;
}

.wave-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 200%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 100%
  );
  animation: wave 3s ease-in-out infinite;
}

@keyframes wave {
  0%, 100% {
    transform: translateX(-50%);
  }
  50% {
    transform: translateX(0%);
  }
}

/* 底部波浪装饰 */
.wave-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 200%;
  height: 100px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 120' preserveAspectRatio='none'%3E%3Cpath d='M321.39,56.44c58-10.79,114.16-30.13,172-41.86,82.39-16.72,168.19-17.73,250.45-.39C823.78,31,906.67,72,985.66,92.83c70.05,18.48,146.53,26.09,214.34,3V0H0V27.35A600.21,600.21,0,0,0,321.39,56.44Z' fill='%231A365D' opacity='0.3'/%3E%3C/svg%3E");
  background-size: 1200px 100px;
  animation: wave-scroll 20s linear infinite;
}

@keyframes wave-scroll {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

/* ===== 3D 翻转效果 ===== */

/* 3D 翻转卡片 */
.flip-3d {
  perspective: 1000px;
  transform-style: preserve-3d;
}

.flip-3d-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.flip-3d:hover .flip-3d-inner {
  transform: rotateY(180deg);
}

.flip-3d-front,
.flip-3d-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: inherit;
}

.flip-3d-front {
  background: var(--glass-layer-3);
  backdrop-filter: blur(10px);
}

.flip-3d-back {
  background: var(--glass-layer-4);
  transform: rotateY(180deg);
}

/* ===== 螺旋效果 ===== */

/* 螺旋形状 */
.spiral-shape {
  animation: spiral 10s linear infinite;
  will-change: transform;
}

@keyframes spiral {
  0% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(180deg) scale(1.1);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

/* ===== 抖动/震颤效果 ===== */

/* 轻微抖动 */
.shake-subtle {
  animation: shake-subtle 0.5s ease-in-out;
}

@keyframes shake-subtle {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-2px) rotate(-1deg);
  }
  75% {
    transform: translateX(2px) rotate(1deg);
  }
}

/* 中等抖动 */
.shake-medium {
  animation: shake-medium 0.5s ease-in-out;
}

@keyframes shake-medium {
  0%, 100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-5px) rotate(-2deg);
  }
  40% {
    transform: translateX(5px) rotate(2deg);
  }
  60% {
    transform: translateX(-3px) rotate(-1deg);
  }
  80% {
    transform: translateX(3px) rotate(1deg);
  }
}

/* ===== 悬浮变形效果 ===== */

/* Hover 时的平滑变形 */
.morph-hover {
  transition: border-radius 0.5s ease, transform 0.3s ease;
}

.morph-hover:hover {
  border-radius: 50%;
  transform: scale(1.05);
}

/* ===== 渐变边界动画 ===== */

/* 动态渐变边框 */
.gradient-border {
  position: relative;
  background: var(--glass-layer-3);
  border-radius: var(--radius-xl);
}

.gradient-border::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(135deg,
    var(--vista-glass-teal),
    var(--vista-glass-blue),
    var(--vista-accent-green),
    var(--vista-glass-teal)
  );
  background-size: 300% 300%;
  border-radius: inherit;
  z-index: -1;
  animation: gradient-border-move 4s ease infinite;
}

@keyframes gradient-border-move {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* ===== 霓虹灯效果 ===== */

/* 霓虹发光边框 */
.neon-border {
  border: 2px solid var(--vista-glass-teal);
  box-shadow:
    0 0 5px var(--vista-glass-teal),
    0 0 10px var(--vista-glass-teal),
    inset 0 0 5px var(--vista-glass-teal);
  animation: neon-pulse 2s ease-in-out infinite;
}

@keyframes neon-pulse {
  0%, 100% {
    box-shadow:
      0 0 5px var(--vista-glass-teal),
      0 0 10px var(--vista-glass-teal),
      inset 0 0 5px var(--vista-glass-teal);
  }
  50% {
    box-shadow:
      0 0 10px var(--vista-glass-teal),
      0 0 20px var(--vista-glass-teal),
      inset 0 0 10px var(--vista-glass-teal);
  }
}

/* ===== 变形进度条 ===== */

/* 动态进度条 */
.morph-progress {
  height: 8px;
  background: var(--glass-layer-2);
  border-radius: 10px;
  overflow: hidden;
}

.morph-progress-bar {
  height: 100%;
  background: linear-gradient(90deg,
    var(--vista-glass-teal),
    var(--vista-glass-blue)
  );
  border-radius: 10px;
  animation: morph-progress 2s ease-in-out infinite;
}

@keyframes morph-progress {
  0%, 100% {
    border-radius: 10px;
  }
  50% {
    border-radius: 50%;
  }
}

/* ===== 变形加载器 ===== */

/* 变形加载圆环 */
.morph-loader {
  width: 50px;
  height: 50px;
  border: 3px solid var(--glass-layer-2);
  border-top-color: var(--vista-glass-teal);
  border-radius: 50%;
  animation: morph-loader 1s linear infinite;
}

@keyframes morph-loader {
  0% {
    border-radius: 50%;
    transform: rotate(0deg);
  }
  50% {
    border-radius: 30%;
    transform: rotate(180deg);
  }
  100% {
    border-radius: 50%;
    transform: rotate(360deg);
  }
}

/* ===== 响应式变形动画 ===== */
@media (max-width: 768px) {
  .morphing-shape {
    animation-duration: 6s;
  }

  .liquid-glass {
    animation-duration: 8s;
  }

  .pulse-ring::before {
    inset: -5px;
  }
}

/* ===== 减少动画偏好设置 ===== */
@media (prefers-reduced-motion: reduce) {
  .morphing-shape,
  .liquid-glass,
  .pulse-ring::before,
  .wave-container::before,
  .gradient-border::before,
  .neon-border,
  .morph-progress-bar,
  .morph-loader {
    animation: none;
  }

  .elastic-button:hover,
  .elastic-button:active,
  .elastic-card:hover,
  .elastic-card:active {
    transform: none;
  }

  .flip-3d:hover .flip-3d-inner {
    transform: none;
  }
}

/* ===== 高对比度模式 ===== */
@media (prefers-contrast: high) {
  .liquid-glass {
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid white;
  }

  .neon-border {
    border-width: 3px;
    box-shadow: none;
  }
}
