/* ============================================
   UI Enhancements - 春节主题美化
   现代宫廷美学设计
   ============================================ */

/* ─── 一、字体系统升级 ─────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@700;900&display=swap');

:root {
  /* 新增字体变量 */
  --font-display: 'Noto Serif SC', 'STKaiti', 'Kaiti SC', 'FangSong', serif;
}

/* 标题使用宋体/楷体,增加字间距 */
.game-title,
.case-select-heading,
.phase-header h2,
.deduction-question-text,
.finale-revelation,
.ending-card .ending-name {
  font-family: var(--font-display);
  font-weight: 900;
  letter-spacing: 0.15em;
}

/* 证言文字书法感 */
.testimony-line-text {
  font-family: 'Noto Serif SC', 'Songti SC', serif;
  letter-spacing: 0.05em;
  line-height: 1.9;
}

/* ─── 二、色彩系统应用 ─────────────────────────── */

/* 标题渐变金红效果 */
.game-title {
  background: linear-gradient(135deg,
    var(--color-spring-gold) 0%,
    var(--color-accent) 50%,
    var(--color-spring-red) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 4px 20px rgba(244, 165, 35, 0.4);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* 按钮光晕效果 */
.btn-primary {
  background: linear-gradient(135deg,
    var(--color-spring-red),
    var(--color-lantern-orange));
  box-shadow:
    0 4px 12px rgba(198, 30, 58, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  border: 2px solid var(--color-spring-gold);
  transition: all var(--transition-normal);
}

.btn-primary:hover,
.btn-primary:focus {
  box-shadow:
    0 6px 20px rgba(198, 30, 58, 0.5),
    0 0 30px rgba(244, 165, 35, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.btn-primary:active {
  transform: translateY(0) scale(0.98);
}

/* 次要按钮春节风格 */
.btn-secondary {
  background: var(--color-surface-light);
  border: 1px solid var(--color-spring-gold);
  box-shadow: 0 2px 8px rgba(244, 165, 35, 0.15);
}

.btn-secondary:hover {
  border-color: var(--color-spring-red);
  box-shadow: 0 4px 12px rgba(198, 30, 58, 0.25);
}

/* ─── 三、卡片边框流光效果 ─────────────────────────── */

/* 可点击的未完成卡片：金色流光吸引点击 */
.event-card.available {
  position: relative;
  border: 2px solid transparent;
  background:
    linear-gradient(var(--color-card-bg), var(--color-card-bg)) padding-box,
    linear-gradient(135deg,
      var(--color-spring-gold),
      var(--color-accent),
      var(--color-spring-red)) border-box;
  animation: cardInvite 2.5s ease-in-out infinite;
}

@keyframes cardInvite {
  0%, 100% { box-shadow: 0 0 4px rgba(244, 165, 35, 0.1); }
  50% { box-shadow: 0 0 12px rgba(244, 165, 35, 0.25); }
}

/* 已完成的卡片（含 has-evidence、completed）：安静、不抢注意力 */
.event-card.completed,
.event-card.has-evidence {
  border: 2px solid rgba(61, 42, 110, 0.4);
  background: rgba(42, 26, 74, 0.5);
  animation: none;
}

.event-card.available::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 2px;
  background: linear-gradient(90deg,
    transparent,
    var(--color-spring-gold),
    transparent);
  background-size: 200% 100%;
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.event-card.available:hover::after {
  opacity: 1;
  animation: borderFlow 2s linear infinite;
}

@keyframes borderFlow {
  from { background-position: 0% 0%; }
  to { background-position: 200% 0%; }
}

/* refreshed 状态（NPC可交互）也需要动态效果 */
.event-card.refreshed {
  position: relative;
  border: 2px solid transparent;
  background:
    linear-gradient(var(--color-card-bg), var(--color-card-bg)) padding-box,
    linear-gradient(135deg, #3498db, #2980b9, #3498db) border-box;
  animation: cardInvite 2.5s ease-in-out infinite;
}

/* has-evidence 卡片已完成，不需要额外动画 */

/* ─── 四、背景祥云纹样 ─────────────────────────── */

#screen-title::before,
#screen-investigation::before,
#screen-testimony::before,
#screen-deduction::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('../assets/patterns/cloud-pattern.svg');
  background-size: 200px 200px;
  opacity: 0.25;
  pointer-events: none;
  animation: cloudDrift 30s linear infinite;
  z-index: 0;
}

@keyframes cloudDrift {
  from { background-position: 0 0; }
  to { background-position: 200px 200px; }
}

/* 噪点纹理叠加 */
.game-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.05'/%3E%3C/svg%3E");
  pointer-events: none;
  mix-blend-mode: overlay;
  z-index: 1;
}

/* ─── 五、印章盖印效果 ─────────────────────────── */

.stamp-effect {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  animation: stampFadeIn 0.3s ease forwards;
}

.stamp-effect[hidden] {
  display: none;
}

.stamp-circle {
  width: 200px;
  height: 200px;
  border: 8px solid var(--color-spring-red);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(198, 30, 58, 0.15);
  animation: stampIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  box-shadow:
    0 0 0 4px rgba(244, 165, 35, 0.3),
    0 0 40px rgba(198, 30, 58, 0.4);
}

.stamp-text {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 900;
  color: var(--color-spring-red);
  writing-mode: vertical-rl;
  letter-spacing: 0.2em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

@keyframes stampFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes stampIn {
  0% {
    transform: scale(2) rotate(-45deg);
    opacity: 0;
  }
  60% {
    transform: scale(0.9) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

/* ─── 六、按钮涟漪点击效果 ─────────────────────────── */

.btn {
  position: relative;
  overflow: hidden;
}

.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  width: 100px;
  height: 100px;
  transform: translate(-50%, -50%) scale(0);
  animation: rippleEffect 0.6s ease-out;
  pointer-events: none;
}

@keyframes rippleEffect {
  to {
    transform: translate(-50%, -50%) scale(4);
    opacity: 0;
  }
}

/* ─── 七、心形破碎增强 ─────────────────────────── */

.heart.breaking {
  animation: heartBreakEnhanced 0.6s ease forwards;
}

@keyframes heartBreakEnhanced {
  0% {
    transform: scale(1);
    filter: drop-shadow(0 0 0 transparent);
  }
  30% {
    transform: scale(1.4);
    filter: drop-shadow(0 0 20px rgba(231, 76, 60, 0.8));
  }
  60% {
    transform: scale(0.8) rotate(15deg);
    filter: drop-shadow(0 0 10px rgba(231, 76, 60, 0.4));
  }
  100% {
    transform: scale(0.6) rotate(-10deg);
    filter: grayscale(1) drop-shadow(0 0 0 transparent);
  }
}

/* ─── 八、对话气泡卷轴风格 ─────────────────────────── */

.dialogue-box {
  background: rgba(15, 10, 30, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(244, 165, 35, 0.2);
  border-left: 3px solid var(--color-spring-crimson);
  border-radius: var(--border-radius);
  position: relative;
  padding: var(--space-lg);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.dialogue-box::before,
.dialogue-box::after {
  content: '◈';
  position: absolute;
  font-size: 1rem;
  color: rgba(244, 165, 35, 0.4);
  line-height: 1;
}

.dialogue-box::before {
  top: var(--space-sm);
  right: var(--space-sm);
}

.dialogue-box::after {
  bottom: var(--space-sm);
  right: var(--space-sm);
}

/* ─── 九、灯笼装饰动画 ─────────────────────────── */

.lanterns-decoration {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 120px;
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
}

.lantern {
  position: absolute;
  font-size: 3rem;
  animation: lanternSwing 3s ease-in-out infinite;
  filter: drop-shadow(0 8px 16px rgba(255, 107, 53, 0.5));
}

.lantern-left {
  left: 10%;
  top: -20px;
  animation-delay: 0s;
}

.lantern-right {
  right: 10%;
  top: -20px;
  animation-delay: -1.5s;
}

@keyframes lanternSwing {
  0%, 100% {
    transform: rotate(-5deg) translateY(0);
  }
  50% {
    transform: rotate(5deg) translateY(5px);
  }
}

/* ─── 十、证据获取横幅增强 ─────────────────────────── */

.evidence-obtained-banner {
  background: linear-gradient(135deg,
    var(--color-spring-gold),
    var(--color-accent));
  border: 2px solid var(--color-spring-red);
  box-shadow:
    0 4px 16px rgba(244, 165, 35, 0.4),
    0 0 0 2px rgba(198, 30, 58, 0.3);
}

/* ─── 十一、推理选项卡片增强 ─────────────────────────── */

.deduction-option-btn {
  position: relative;
  overflow: hidden;
}

.deduction-option-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%,
    rgba(244, 165, 35, 0.1),
    transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.deduction-option-btn:hover::before {
  opacity: 1;
}

.deduction-option-btn.correct {
  border-color: #4caf50;
  background: rgba(76, 175, 80, 0.12);
  box-shadow:
    0 0 16px rgba(76, 175, 80, 0.2),
    inset 0 0 20px rgba(76, 175, 80, 0.1);
}

.deduction-option-btn.correct::after {
  content: '✓';
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  font-size: 1.5rem;
  color: #4caf50;
  font-weight: 900;
}

/* ─── 十二、响应式动画控制 ─────────────────────────── */

/* 尊重用户偏好: 减少动画 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .event-card.available::after,
  .event-card.available,
  .event-card.refreshed {
    animation: none;
  }

  .lanterns-decoration {
    display: none;
  }
}

/* ─── 十三、性能优化 ─────────────────────────── */

/* GPU加速 */
.btn-primary,
.event-card,
.stamp-circle,
.lantern {
  transform: translateZ(0);
  will-change: transform;
}

/* ─── 十四、结尾卡片金色主题 ─────────────────────────── */

.ending-card {
  border-color: var(--color-spring-gold);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(244, 165, 35, 0.2);
}

.ending-rating.S {
  color: var(--color-spring-gold);
  text-shadow:
    0 0 20px rgba(244, 165, 35, 0.5),
    0 2px 4px rgba(0, 0, 0, 0.3);
}

/* ─── 十五、案件选择卡片优化 ─────────────────────────── */

.case-select-card {
  border: 2px solid rgba(61, 42, 110, 0.6);
  background: rgba(42, 26, 74, 0.8);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: all var(--transition-fast);
}

.case-select-card:not(.locked) {
  border-color: rgba(244, 165, 35, 0.25);
}

.case-select-card:active:not(.locked) {
  border: 2px solid transparent;
  background:
    linear-gradient(var(--color-card-bg), var(--color-card-bg)) padding-box,
    linear-gradient(135deg, var(--color-spring-gold), var(--color-accent)) border-box;
  box-shadow: 0 0 20px rgba(244, 165, 35, 0.3);
}
