/* ============ Loader / door curtains ============ */
#loader { position: fixed; inset: 0; z-index: 9000; pointer-events: all; }
#loader .half {
  position: absolute; top: 0; bottom: 0; width: 50.5%;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.55), transparent 55%),
    linear-gradient(160deg, #ffd6e2, #f9b9cd 55%, #f2a2bd);
  transition: transform 1.25s cubic-bezier(.77, 0, .18, 1);
  box-shadow: 0 0 60px rgba(176, 84, 112, 0.35);
}
#loader .half { will-change: transform; }
#loader .half::before { /* soft damask shimmer (moved with transform, so it never repaints) */
  content: ""; position: absolute; inset: -180px 0 0 -90px; opacity: .5;
  background-image:
    radial-gradient(circle at 20% 25%, #fff8 0 2px, transparent 3px),
    radial-gradient(circle at 70% 60%, #fff8 0 2px, transparent 3px),
    radial-gradient(circle at 40% 85%, #fff8 0 2px, transparent 3px);
  background-size: 90px 90px;
  animation: drift 14s linear infinite;
}
#loader .left { left: 0; border-right: 3px solid var(--gold-soft); }
#loader .right { right: 0; border-left: 3px solid var(--gold-soft); }
#loader.open .left { transform: translateX(-102%); }
#loader.open .right { transform: translateX(102%); }
#loader.open { pointer-events: none; }
#loader.gone { display: none; }

.loader-core {
  position: absolute; z-index: 2; left: 50%; top: 50%; width: 150px; height: 150px;
  margin: -75px 0 0 -75px; transition: opacity .6s, transform 1s var(--ease);
}
#loader.open .loader-core { opacity: 0; transform: scale(2.2); }
.loader-heart {
  position: absolute; inset: 38px; background: #fff;
  clip-path: path("M37 66 C-8 32 8 -4 37 14 C66 -4 82 32 37 66Z");
  animation: heartbeat 1.3s ease-in-out infinite;
  filter: drop-shadow(0 0 14px #fff);
}
.loader-ring { position: absolute; inset: 0; animation: spin 5s linear infinite; }
.loader-ring i {
  position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px;
  background: #fff; opacity: .95;
  clip-path: path("M8 15 C-3 7 2 -1 8 3 C14 -1 19 7 8 15Z");
  transform: rotate(calc(var(--i) * 45deg)) translateY(-66px);
  animation: petalPulse 1.6s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.12s);
}

/* ============ Welcome intro ============ */
#welcome {
  position: fixed; inset: 0; z-index: 9500; display: grid; place-items: center;
  background:
    radial-gradient(circle at 50% 45%, #fff0f4, #ffd3e0 60%, #f6a9c1);
  transition: opacity 1.2s ease, visibility 1.2s;
  overflow: hidden;
}
#welcome.hide { opacity: 0; visibility: hidden; }
#welcome canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.welcome-text {
  position: relative; z-index: 2; text-align: center;
  font-family: var(--script); font-size: clamp(3.4rem, 13vw, 9rem); line-height: 1.05; color: #fff;
  text-shadow: 0 3px 6px rgba(190, 80, 120, .5), 0 0 40px rgba(255, 255, 255, .9);
  padding: 0 12px;
}
.welcome-text .line { display: block; }
.welcome-text .ch {
  display: inline-block; opacity: 0; transform: translateY(40px) scale(.4) rotate(-12deg); filter: blur(10px);
  animation: letterIn 1.1s var(--ease) forwards; animation-delay: calc(var(--d) * 0.09s + 2.6s);
}
.welcome-text .sp { width: .3em; }
.welcome-skip {
  position: absolute; z-index: 3; bottom: max(28px, env(safe-area-inset-bottom)); left: 50%; margin-left: -26px;
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, .55); border: 1px solid #fff; box-shadow: var(--shadow);
  opacity: 0; animation: fadeUp 1s var(--ease) 5.2s forwards;
}
.welcome-skip svg { width: 22px; height: 22px; fill: var(--rose-deep); animation: heartbeat 1.3s infinite; }

/* ============ Page entrance ============ */
.hero .hero-img { animation: walkIn 3.4s var(--ease) both; animation-play-state: paused; }
body.ready .hero .hero-img { animation-play-state: running; }
body.ready .hero .hero-img.settled { animation: breathe 22s ease-in-out infinite alternate; }

.room-title span { opacity: 0; transform: translateY(30px) scale(.6); filter: blur(8px); }
body.ready .room-title span { animation: letterIn 1.2s var(--ease) forwards; animation-delay: calc(var(--d) * .08s + .9s); }

.stage { opacity: 0; }
body.ready .stage { animation: stageIn 1.4s var(--ease) .7s forwards; }
.door { opacity: 0; }
body.ready .door { animation: doorIn 1.3s var(--ease) forwards, floaty 6s ease-in-out 3s infinite; }
body.ready .door:nth-child(1) { animation-delay: 1.2s, 3s; }
body.ready .door:nth-child(2) { animation-delay: 1.5s, 4s; }

.show, .dots { opacity: 0; }
body.ready .show { animation: fadeIn 1.2s ease 1.1s forwards; }
body.ready .dots { animation: fadeIn 1s ease 1.8s forwards; }

/* ============ Keyframes ============ */
@keyframes heartbeat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.22); } 30% { transform: scale(1); } 45% { transform: scale(1.14); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes petalPulse { 0%, 100% { opacity: .35; scale: .6; } 50% { opacity: 1; scale: 1.2; } }
@keyframes drift { to { transform: translate(90px, 180px); } }
@keyframes letterIn { to { opacity: 1; transform: none; filter: blur(0); } }
@keyframes fadeUp { from { opacity: 0; transform: translate(var(--tx, 0), 24px); } to { opacity: 1; transform: translate(var(--tx, 0), 0); } }
@keyframes fadeIn { to { opacity: 1; } }
@keyframes dockIn { from { opacity: 0; transform: translate(var(--dock-x, -50%), 90px) scale(.8); } to { opacity: 1; transform: translate(var(--dock-x, -50%), 0) scale(1); } }
@keyframes dockIn2 { from { opacity: 0; transform: scale(.3) rotate(-90deg); } to { opacity: 1; transform: none; } }
@keyframes walkIn { from { transform: scale(1.3) translateY(3%); opacity: .6; } to { transform: scale(1.06); opacity: 1; } }
@keyframes breathe { from { transform: scale(1.06); } to { transform: scale(1.13) translate(-0.8%, -0.6%); } }
@keyframes stageIn { from { opacity: 0; transform: translate(-50%, -44%) scale(.85); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes doorIn { from { opacity: 0; transform: translateY(70px) scale(.7); } to { opacity: 1; transform: none; } }
@keyframes floaty { 0%, 100% { translate: 0 0; } 50% { translate: 0 -8px; } }
@keyframes ring { 0% { transform: scale(1); opacity: .95; } 100% { transform: scale(1.18); opacity: 0; } }
@keyframes chatGlow { from { filter: drop-shadow(0 8px 16px rgba(176, 84, 112, .4)); } to { filter: drop-shadow(0 10px 26px rgba(233, 138, 166, .95)); } }
@keyframes frameGlow { from { box-shadow: 0 30px 80px rgba(176, 84, 112, .5), 0 0 40px rgba(255, 255, 255, .5); } to { box-shadow: 0 30px 90px rgba(233, 138, 166, .85), 0 0 80px rgba(255, 255, 255, .95); } }
@keyframes fillBar { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes eq { 0%, 100% { height: 25%; } 50% { height: 100%; } }
@keyframes noteUp { 0% { opacity: 0; transform: translate(0, 0) rotate(0); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--nx, 30px), 130px) rotate(25deg); } }
@keyframes spark { to { transform: translateY(-34px) scale(0); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
  .welcome-text .ch, .room-title span, .door, .stage, .show, .dots { opacity: 1; transform: none; filter: none; }
}
