/**
 * Lightweight atmosphere effects for the I Ching site.
 * Inspired by pure-CSS particle / ambient backgrounds (no heavy libs).
 * Uses few DOM nodes + CSS transforms; respects prefers-reduced-motion.
 */

/* Shared base */
.fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

/* Soft ink mist — two slow-moving radial gradients */
.fx-mist {
  background:
    radial-gradient(ellipse 55% 40% at 20% 30%, rgba(40, 35, 30, 0.07) 0%, transparent 70%),
    radial-gradient(ellipse 50% 45% at 80% 70%, rgba(30, 28, 40, 0.06) 0%, transparent 65%),
    radial-gradient(ellipse 40% 35% at 50% 90%, rgba(60, 50, 40, 0.05) 0%, transparent 60%);
  animation: fx-mist-drift 28s ease-in-out infinite alternate;
  will-change: transform, opacity;
}

@keyframes fx-mist-drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); opacity: 0.85; }
  50%  { transform: translate3d(2%, -1.5%, 0) scale(1.04); opacity: 1; }
  100% { transform: translate3d(-1.5%, 2%, 0) scale(1.02); opacity: 0.9; }
}

/* Floating ink specks (pure CSS, 6 dots max) */
.fx-specks {
  z-index: 1;
}

.fx-specks span {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(30, 28, 25, 0.35) 0%, rgba(30, 28, 25, 0) 70%);
  opacity: 0.45;
  animation: fx-speck-float linear infinite;
  will-change: transform, opacity;
}

.fx-specks span:nth-child(1) { width: 10px; height: 10px; left: 12%; top: 78%; animation-duration: 22s; animation-delay: 0s; }
.fx-specks span:nth-child(2) { width: 7px;  height: 7px;  left: 28%; top: 55%; animation-duration: 18s; animation-delay: -4s; }
.fx-specks span:nth-child(3) { width: 14px; height: 14px; left: 55%; top: 82%; animation-duration: 26s; animation-delay: -8s; }
.fx-specks span:nth-child(4) { width: 8px;  height: 8px;  left: 72%; top: 48%; animation-duration: 20s; animation-delay: -2s; }
.fx-specks span:nth-child(5) { width: 11px; height: 11px; left: 88%; top: 70%; animation-duration: 24s; animation-delay: -11s; }
.fx-specks span:nth-child(6) { width: 6px;  height: 6px;  left: 40%; top: 90%; animation-duration: 16s; animation-delay: -6s; }

@keyframes fx-speck-float {
  0%   { transform: translate3d(0, 0, 0); opacity: 0; }
  12%  { opacity: 0.5; }
  50%  { opacity: 0.35; }
  88%  { opacity: 0.4; }
  100% { transform: translate3d(12px, -55vh, 0); opacity: 0; }
}

/* ——— Ink-wash Taiji (homepage) ——— */
.taiji-wrap {
  pointer-events: none;
  /* 恢复修改前透明度；禁止 multiply，避免白眼消失 */
  opacity: 0.42;
  mix-blend-mode: normal;
  isolation: isolate;
}

.taiji-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
  /* 轻柔外晕，代替厚描边 */
  filter: drop-shadow(0 0 10px rgba(40, 35, 30, 0.08));
  animation: taiji-spin 60s linear infinite;
  transform-origin: 50% 50%;
  will-change: transform;
}

.taiji-glow {
  position: absolute;
  inset: -8%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(80, 70, 55, 0.12) 0%, transparent 68%);
  animation: taiji-breathe 8s ease-in-out infinite;
}

@keyframes taiji-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes taiji-breathe {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.06); }
}

/* Hero stage: Taiji + buttons share the same center */
body.index-page .hero-stage {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(72vw, 420px);
  height: min(72vw, 420px);
  transform: translate(-50%, -50%);
  z-index: 5;
  display: grid;
  place-items: center;
}

body.index-page .hero-stage .taiji-wrap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

body.index-page .hero-stage .center-pane {
  position: relative;
  z-index: 2;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  width: min(64%, 248px);
  margin: 0;
  padding: 0;
}

/* Reduced motion: freeze animations, keep static ambience */
@media (prefers-reduced-motion: reduce) {
  .fx-mist,
  .fx-specks span,
  .taiji-wrap svg,
  .taiji-glow,
  .meihua-reveal-overlay,
  .meihua-reveal-backdrop,
  .meihua-reveal-taiji {
    animation: none !important;
    display: none !important;
  }
}

/* Very small screens */
@media (max-width: 480px) {
  body.index-page .hero-stage {
    width: min(88vw, 360px);
    height: min(88vw, 360px);
  }

  body.index-page .hero-stage .taiji-wrap {
    opacity: 0.4;
  }
}

/* ——— Meihua Result Loading Modal Popup (参照乾坤有数 popup 风格) ——— */
.meihua-loading-modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 25000;
  padding: 16px;
  box-sizing: border-box;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.5s cubic-bezier(0.25, 1, 0.35, 1), visibility 0.5s ease;
}

.meihua-loading-modal-mask.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.meihua-loading-modal-box {
  background: #fdfaf3;
  width: 100%;
  max-width: 380px;
  border-radius: 14px;
  padding: 26px 20px 22px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  text-align: center;
  border-top: 4px solid #8a5a20;
  border-bottom: 1px solid rgba(138, 90, 32, 0.18);
  position: relative;
  box-sizing: border-box;
}

.meihua-loading-modal-box h2 {
  margin: 0 0 14px;
  font-family: var(--font-brush, cursive, serif);
  color: #2a2218;
  font-size: clamp(1.2rem, 4vw, 1.35rem);
  letter-spacing: 0.1em;
  font-weight: 500;
}

.meihua-loading-taiji-icon {
  width: 76px;
  height: 76px;
  margin: 12px auto 16px;
  animation: meihua-loading-spin 3s linear infinite;
  will-change: transform;
}

.meihua-loading-taiji-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(30, 25, 20, 0.22));
  -webkit-filter: drop-shadow(0 4px 12px rgba(30, 25, 20, 0.22));
}

.meihua-loading-text-main {
  font-family: var(--font-brush, cursive, serif);
  font-size: 1.18rem;
  color: #7a4010;
  margin-bottom: 6px;
  letter-spacing: 0.08em;
}

.meihua-loading-text-sub {
  font-size: 0.92rem;
  color: #665a4c;
  line-height: 1.6;
  letter-spacing: 0.04em;
  margin: 0;
}

@keyframes meihua-loading-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}


