/* Resonance motion layer. Pairs with static/resonance-motion.js.
   State is exposed as body[data-resonance-state="idle|creating|playing"]. */

#resonance-field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.8s var(--ease, ease);
}
#resonance-field.ready { opacity: 1; }

:root { --res-energy: 0; }

/* Orb: stays the same object, gains depth and responds to the state of the session */
.breath-orb {
  transition: filter 1.2s var(--ease, ease);
  filter: saturate(calc(1 + var(--res-energy) * 0.5)) brightness(calc(1 + var(--res-energy) * 0.12));
}
.breath-orb-wrap { position: relative; }
.breath-orb-wrap::before,
.breath-orb-wrap::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 72px; height: 72px;
  margin: -36px 0 0 -36px;
  border-radius: 50%;
  border: 1px solid rgba(201, 168, 76, 0.16);
  opacity: 0;
  pointer-events: none;
}
body[data-resonance-state="creating"] .breath-orb-wrap::before { animation: resRipple 2.8s var(--ease, ease-out) infinite; }
body[data-resonance-state="creating"] .breath-orb-wrap::after  { animation: resRipple 2.8s var(--ease, ease-out) infinite 1.4s; }
body[data-resonance-state="playing"]  .breath-orb-wrap::before { animation: resRipple 5.2s var(--ease, ease-out) infinite; }
body[data-resonance-state="creating"] .breath-orb { animation-duration: 2.4s; }

@keyframes resRipple {
  0%   { transform: scale(1);   opacity: 0.55; }
  100% { transform: scale(4.2); opacity: 0; }
}

/* Hero: a slow gold light passing through the title, once every few breaths */
.hero-title {
  background: linear-gradient(100deg, var(--text) 0%, var(--text) 42%, #E8CE86 50%, var(--text) 58%, var(--text) 100%);
  background-size: 260% 100%;
  background-position: 120% 0;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: resTitleSheen 11s ease-in-out infinite 1.5s;
}
@keyframes resTitleSheen {
  0%, 55%  { background-position: 120% 0; }
  100%     { background-position: -20% 0; }
}

/* Generate button: a pulse of intent while idle, a living glow while creating */
#generate-button:not(:disabled):not(.cooking) { animation: resCtaPulse 4.6s ease-in-out infinite; }
@keyframes resCtaPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(198, 40, 40, 0); }
  50%      { box-shadow: 0 0 28px 2px rgba(198, 40, 40, 0.22); }
}
#generate-button.cooking { box-shadow: 0 0 36px 4px rgba(198, 40, 40, 0.32); }

/* Phase caption shown under the button while a session is being made (decorative) */
#res-phase {
  min-height: 1.5em;
  margin: 14px 0 0;
  text-align: center;
  font-family: var(--font-display, serif);
  font-style: italic;
  font-size: 1.05em;
  letter-spacing: 0.04em;
  color: var(--gold, #C9A84C);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.9s var(--ease, ease), transform 0.9s var(--ease, ease);
}
#res-phase.show { opacity: 0.9; transform: none; }
#res-phase.swap { opacity: 0; transform: translateY(-6px); }

/* Scroll reveal: elements start hidden only once JS has tagged them */
.res-reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.9s var(--ease, ease), transform 0.9s var(--ease, ease);
  transition-delay: var(--res-delay, 0ms);
}
.res-reveal.in { opacity: 1; transform: none; }

/* Meditation cards lift toward the cursor a little more than before */
.meditation-card { transition: transform 0.45s var(--ease, ease), border-color 0.45s, box-shadow 0.45s; }
.meditation-card:hover { transform: translateY(-4px); box-shadow: 0 14px 44px rgba(198, 40, 40, 0.14); }

/* Player: the whole card takes on a soft glow while a session plays */
body[data-resonance-state="playing"] #audio-player-container {
  box-shadow: 0 0 60px rgba(198, 40, 40, 0.12), inset 0 0 0 1px rgba(201, 168, 76, 0.14);
  transition: box-shadow 1.6s var(--ease, ease);
}

@media (prefers-reduced-motion: reduce) {
  #resonance-field { display: none; }
  .hero-title { animation: none; -webkit-text-fill-color: currentColor; background: none; color: var(--text); }
  #generate-button:not(:disabled):not(.cooking) { animation: none; }
  .breath-orb-wrap::before, .breath-orb-wrap::after { animation: none !important; }
  .res-reveal { opacity: 1; transform: none; transition: none; }
  #res-phase { transition: none; }
}
