/* Shared effects: confetti canvas, typewriter caret, floating music button. Prefix: .fx- */

/* ---------- confetti ---------- */
.fx-confetti {
  position: fixed; inset: 0; width: 100vw; height: 100vh; max-width: none;
  pointer-events: none; z-index: var(--z-fx);
}

/* ---------- typewriter ---------- */
.fx-typing { cursor: pointer; }
.fx-caret {
  display: inline-block; width: 2px; height: 1.05em; margin-left: 2px;
  vertical-align: -0.15em; border-radius: 1px;
  background: currentColor; opacity: 0.75;
  animation: fx-blink 1s steps(1, end) infinite;
}
@keyframes fx-blink { 50% { opacity: 0; } }

/* ---------- music button ---------- */
.fx-music {
  position: fixed; z-index: var(--z-music);
  right: calc(14px + env(safe-area-inset-right));
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 46px; height: 46px; padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, 0.28); border-radius: var(--radius-pill);
  background: rgba(24, 20, 28, 0.62); color: #fff;
  -webkit-backdrop-filter: blur(10px) saturate(1.4); backdrop-filter: blur(10px) saturate(1.4);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.28);
  font: 600 14px/1 var(--font-sans); letter-spacing: 0.01em;
  transition: transform var(--dur) var(--ease-spring), background var(--dur);
  animation: fx-pop-in 420ms var(--ease-spring) both;
}
.fx-music:hover { background: rgba(24, 20, 28, 0.78); }
.fx-music:active { transform: scale(0.92); }
@keyframes fx-pop-in { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }

.fx-music-off { width: 22px; height: 22px; display: none; }
.fx-music-label { display: none; white-space: nowrap; }

.fx-music-eq { display: inline-flex; align-items: flex-end; gap: 3px; height: 16px; }
.fx-music-eq i {
  display: block; width: 3px; height: 100%; border-radius: 2px; background: currentColor;
  transform-origin: bottom; transform: scaleY(0.3);
}
.fx-music[data-state="playing"] .fx-music-eq i { animation: fx-eq 900ms ease-in-out infinite alternate; }
.fx-music-eq i:nth-child(2) { animation-delay: -300ms !important; animation-duration: 700ms !important; }
.fx-music-eq i:nth-child(3) { animation-delay: -550ms !important; animation-duration: 1100ms !important; }
.fx-music-eq i:nth-child(4) { animation-delay: -150ms !important; animation-duration: 800ms !important; }
@keyframes fx-eq {
  0% { transform: scaleY(0.25); } 40% { transform: scaleY(1); } 70% { transform: scaleY(0.5); } 100% { transform: scaleY(0.85); }
}

.fx-music[data-state="muted"] .fx-music-eq { display: none; }
.fx-music[data-state="muted"] .fx-music-off { display: block; }
.fx-music[data-state="muted"] { background: rgba(24, 20, 28, 0.45); }

/* Autoplay refused: an inviting pill. */
.fx-music[data-state="blocked"] {
  background: linear-gradient(135deg, #ff5d8f, #ff9a5a); border-color: transparent;
  animation: fx-pop-in 420ms var(--ease-spring) both, fx-nudge 2.4s 1s ease-in-out infinite;
}
.fx-music[data-state="blocked"] .fx-music-label { display: inline; }
.fx-music[data-state="blocked"] .fx-music-eq i { transform: scaleY(0.45); }
@keyframes fx-nudge { 0%, 70%, 100% { transform: none; } 80% { transform: scale(1.07); } 90% { transform: scale(0.98); } }

@media (prefers-reduced-motion: reduce) {
  .fx-music[data-state="playing"] .fx-music-eq i { animation: none; transform: scaleY(0.7); }
}

/* ---------- lightbox (body-level overlay) ---------- */
.fx-lb {
  position: fixed; inset: 0; z-index: var(--z-overlay);
  display: grid; grid-template-rows: 1fr auto;
  background: rgba(14, 10, 18, 0.96);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  touch-action: none; overscroll-behavior: contain;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  animation: fx-lb-in 240ms var(--ease-out) both;
}
.fx-lb--out { animation: fx-lb-out 220ms ease-in both; pointer-events: none; }
@keyframes fx-lb-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fx-lb-out { to { opacity: 0; } }

.fx-lb-stage {
  min-height: 0; display: grid; place-items: center;
  padding: 64px 12px 8px;
}
.fx-lb-frame {
  position: relative; display: grid; place-items: center;
  width: 100%; height: 100%;
  transform: translate(var(--dx, 0px), var(--dy, 0px));
  transition: transform 260ms var(--ease-out);
}
.fx-lb-frame.is-dragging { transition: none; }
.fx-lb-img {
  width: auto; height: auto; max-width: min(100%, 1400px); object-fit: contain;
  max-height: calc(100dvh - 128px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  border-radius: 6px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  opacity: 0; transition: opacity 260ms var(--ease-out);
  user-select: none; -webkit-user-drag: none;
}
.fx-lb-frame.is-ready .fx-lb-img { opacity: 1; }
.fx-lb-spin { position: absolute; border-color: rgba(255, 255, 255, 0.2); border-top-color: #fff; }
.fx-lb-frame.is-ready .fx-lb-spin { display: none; }
.fx-lb-frame.from-r .fx-lb-img { animation: fx-from-r 300ms var(--ease-out); }
.fx-lb-frame.from-l .fx-lb-img { animation: fx-from-l 300ms var(--ease-out); }
@keyframes fx-from-r { from { transform: translateX(40px); } }
@keyframes fx-from-l { from { transform: translateX(-40px); } }

.fx-lb-count {
  margin: 0; padding: 12px 0 18px; text-align: center;
  color: rgba(255, 255, 255, 0.8); font-size: 14px; letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

.fx-lb-btn {
  position: absolute; display: grid; place-items: center;
  width: 46px; height: 46px; padding: 0;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.14); color: #fff;
  transition: background var(--dur), transform var(--dur) var(--ease-out);
}
.fx-lb-btn:hover { background: rgba(255, 255, 255, 0.24); }
.fx-lb-btn:active { transform: scale(0.92); }
.fx-lb-btn:focus-visible { outline-color: #fff; }
.fx-lb-close { top: calc(12px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right)); }
.fx-lb-prev, .fx-lb-next { bottom: calc(8px + env(safe-area-inset-bottom)); }
.fx-lb-prev { left: calc(16px + env(safe-area-inset-left)); }
.fx-lb-next { right: calc(16px + env(safe-area-inset-right)); }
@media (min-width: 760px) {
  .fx-lb-stage { padding: 64px 88px 8px; }
  .fx-lb-prev, .fx-lb-next { bottom: auto; top: 50%; transform: translateY(-50%); }
  .fx-lb-prev:active, .fx-lb-next:active { transform: translateY(-50%) scale(0.92); }
}

