/*
 * 🎨 涟漪式页面过渡动画样式
 * 💫 从点击位置圆形扩散放大，加载完成后渐隐退出
 /* 🟠 横向排列的圆点动画，参考来源 https://juejin.cn/post/7020064738956705823 的弹珠动画
 */

/* 🔗 页面涟漪过渡动画容器 */
.page-ripple-transition {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* 💧 激活状态 */
.page-ripple-transition.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
}

/* 💧 退出状态 */
.page-ripple-transition.is-exiting {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* 🔘 遮罩层 */
.page-ripple-transition__overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.page-ripple-transition.is-active .page-ripple-transition__overlay {
  opacity: 1;
}

/* 🌊 涟漪层 - 从点击位置扩散 */
.page-ripple-transition__ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 32px rgba(248, 195, 205, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
}

.page-ripple-transition.is-active .page-ripple-transition__ripple {
  transform: translate(-50%, -50%) scale(1);
}

/* 📦 内容层 */
.page-ripple-transition__content {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease 0.5s;
}

.page-ripple-transition.is-active .page-ripple-transition__content {
  opacity: 1;
  pointer-events: auto;
}

/* 🔮 横板弹珠加载动画 */
.page-ripple-transition__marbles {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
  height: 50px;
  padding-bottom: 10px;
}

.page-ripple-transition__marble {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  animation: marble-bounce 1s ease-in-out infinite;
  box-shadow: 0 2px 8px rgba(255, 255, 255, 0.4);
}

.page-ripple-transition__marble:nth-child(1) { animation-delay: 0s; animation-duration: 0.8s; }
.page-ripple-transition__marble:nth-child(2) { animation-delay: 0.1s; animation-duration: 1.1s; }
.page-ripple-transition__marble:nth-child(3) { animation-delay: 0.25s; animation-duration: 0.9s; }
.page-ripple-transition__marble:nth-child(4) { animation-delay: 0.15s; animation-duration: 1.2s; }
.page-ripple-transition__marble:nth-child(5) { animation-delay: 0.3s; animation-duration: 0.85s; }

@keyframes marble-bounce {
  0%, 100% {
    transform: translateY(0) scale(1);
    opacity: 0.6;
  }
  25% {
    transform: translateY(-20px) scale(1.1);
    opacity: 1;
  }
  50% {
    transform: translateY(-8px) scale(0.95);
    opacity: 0.8;
  }
  75% {
    transform: translateY(-25px) scale(1.05);
    opacity: 1;
  }
}

/* ⏳ 加载器 */
.page-ripple-transition__loader {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 8px 32px rgba(248, 195, 205, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.page-ripple-transition__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e0e0e0;
  animation: dot-pulse 1.2s ease-in-out infinite;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.page-ripple-transition__dot:nth-child(1) { animation-delay: 0s; }
.page-ripple-transition__dot:nth-child(2) { animation-delay: 0.15s; }
.page-ripple-transition__dot:nth-child(3) { animation-delay: 0.3s; }
.page-ripple-transition__dot:nth-child(4) { animation-delay: 0.45s; }
.page-ripple-transition__dot:nth-child(5) { animation-delay: 0.6s; }
.page-ripple-transition__dot:nth-child(6) { animation-delay: 0.75s; }
.page-ripple-transition__dot:nth-child(7) { animation-delay: 0.9s; }
.page-ripple-transition__dot:nth-child(8) { animation-delay: 1.05s; }

@keyframes dot-pulse {
  0%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
    background: #e0e0e0;
  }
  40% {
    transform: scale(1);
    opacity: 1;
    background: #f8c3cd;
    box-shadow: 0 0 10px rgba(248, 195, 205, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  }
}

/* 📊 百分比显示 */
.page-ripple-transition__percentage {
  font-size: 18px;
  font-weight: 700;
  color: #e75480;
  margin-left: 16px;
  min-width: 50px;
  text-align: right;
  font-family: 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, sans-serif;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* 📊 进度条容器 */
.page-ripple-transition__progress-wrapper {
  width: 280px;
  margin-top: 16px;
}

/* 🎯 目标URL显示 */
.page-ripple-transition__target {
  margin-top: 24px;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  max-width: 90%;
  text-align: center;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease 0.5s, transform 0.4s ease 0.5s;
}

.page-ripple-transition.is-active .page-ripple-transition__target {
  opacity: 1;
  transform: translateY(0);
}

.page-ripple-transition__target-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, sans-serif;
}

.page-ripple-transition__target-url {
  font-size: 14px;
  color: #fff;
  word-break: break-all;
  line-height: 1.6;
  font-weight: 500;
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
}

/* ✅ 成功状态 */
.page-ripple-transition__success {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.page-ripple-transition__success.is-visible {
  opacity: 1;
}

.page-ripple-transition__success-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: success-pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes success-pop {
  0% {
    transform: scale(0);
  }
  100% {
    transform: scale(1);
  }
}

.page-ripple-transition__success-icon::after {
  content: '✓';
  font-size: 28px;
  color: #f8c3cd;
  font-weight: bold;
}

.page-ripple-transition__success-text {
  font-size: 16px;
  color: #fff;
  font-family: 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 500;
}

/* 🌆 暗色模式适配 */
[data-bs-theme="dark"] .page-ripple-transition__ripple {
  background: rgba(30, 41, 59, 0.4);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .page-ripple-transition__marble {
  background: #e8e8e8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] .page-ripple-transition__loader {
  background: rgba(30, 41, 59, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .page-ripple-transition__dot {
  background: #475569;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] .page-ripple-transition__percentage {
  color: #f4a6b5;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* 🌆 暗色模式dot动画 */
[data-bs-theme="dark"] @keyframes dot-pulse {
  0%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
    background: #475569;
  }
  40% {
    transform: scale(1);
    opacity: 1;
    background: #f4a6b5;
    box-shadow: 0 0 10px rgba(244, 166, 181, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  }
}

[data-bs-theme="dark"] .page-ripple-transition__target {
  background: rgba(30, 41, 59, 0.5);
  border-color: rgba(255, 255, 255, 0.15);
}

[data-bs-theme="dark"] .page-ripple-transition__target-label {
  color: rgba(255, 255, 255, 0.6);
}

/* 📱 移动端适配 */
@media (max-width: 768px) {
  .page-ripple-transition__marbles {
    gap: 6px;
  }

  .page-ripple-transition__marble {
    width: 10px;
    height: 10px;
  }

  .page-ripple-transition__dot {
    width: 6px;
    height: 6px;
  }

  .page-ripple-transition__percentage {
    font-size: 16px;
    margin-left: 8px;
    min-width: 40px;
  }

  .page-ripple-transition__target {
    padding: 12px 16px;
    margin-top: 16px;
  }

  .page-ripple-transition__target-url {
    font-size: 12px;
  }

  .page-ripple-transition__progress-wrapper {
    width: 240px;
  }
}

/* ♿ 减少动画偏好适配 */
@media (prefers-reduced-motion: reduce) {
  .page-ripple-transition,
  .page-ripple-transition__ripple,
  .page-ripple-transition__content,
  .page-ripple-transition__marble,
  .page-ripple-transition__dot {
    animation: none !important;
    transition: none !important;
  }
}
