/* ==========================================================================
   MEA PRESENCE BLOB — Emotional Mascot
   The organic, breathing heart of the app.
   States: calm (default), stress, crisis
   ========================================================================== */

/* --- 1. Breathing Keyframes ------------------------------------------------
   Each emotional state has its own rhythm and shape language.
   Calm = slow & organic, Stress = tighter & faster, Crisis = soothing glow. */

/* CALM: 4s cycle, wide organic morph, gentle rotation */
@keyframes blobBreatheCalm {
  0%   { border-radius: 60% 40% 55% 45% / 45% 55% 50% 50%; transform: scale(1) rotate(0deg); }
  20%  { border-radius: 50% 50% 45% 55% / 55% 45% 60% 40%; transform: scale(1.05) rotate(1.5deg); }
  50%  { border-radius: 42% 58% 62% 38% / 40% 60% 44% 56%; transform: scale(1.13) rotate(0deg); }
  80%  { border-radius: 55% 45% 48% 52% / 58% 42% 56% 44%; transform: scale(1.05) rotate(-1.5deg); }
  100% { border-radius: 60% 40% 55% 45% / 45% 55% 50% 50%; transform: scale(1) rotate(0deg); }
}

/* STRESS: 2.5s cycle, smaller morph range, no rotation */
@keyframes blobBreatheStress {
  0%   { border-radius: 55% 45% 50% 50% / 50% 50% 48% 52%; transform: scale(1); }
  50%  { border-radius: 48% 52% 58% 42% / 44% 56% 50% 50%; transform: scale(1.09); }
  100% { border-radius: 55% 45% 50% 50% / 50% 50% 48% 52%; transform: scale(1); }
}

/* CRISIS: 5s cycle, near-circle, calming glow expansion */
@keyframes blobBreatheCrisis {
  0%   { border-radius: 50%; transform: scale(1); box-shadow: 0 0 60px rgba(24,122,108,.18); }
  50%  { border-radius: 46% 54% 56% 44% / 44% 56% 46% 54%; transform: scale(1.1); box-shadow: 0 0 100px rgba(24,122,108,.32); }
  100% { border-radius: 50%; transform: scale(1); box-shadow: 0 0 60px rgba(24,122,108,.18); }
}

/* --- 2. Glow & Highlight Effects ------------------------------------------ */

@keyframes glowPulse {
  0%, 100% { opacity: .35; transform: scale(1); }
  50%      { opacity: .6;  transform: scale(1.18); }
}

@keyframes presenceTextFade {
  0%, 100% { opacity: .5; }
  50%      { opacity: 1; }
}

/* --- 3. Core Blob Element ------------------------------------------------- */

.presence-blob {
  position: relative;
  width: 140px;
  height: 140px;
  border-radius: 60% 40% 55% 45% / 45% 55% 50% 50%;
  background: radial-gradient(circle at 38% 36%, #7fd8ce 0%, #2eb8a8 38%, #187a6c 68%, #0e5248 100%);
  will-change: border-radius, transform;
  animation: blobBreatheCalm 4s cubic-bezier(.45,.05,.55,.95) infinite;
  margin: 0 auto;
}

/* White highlight — mimics a soft light reflection on top-left */
.presence-blob::before {
  content: "";
  position: absolute;
  inset: 12%;
  border-radius: inherit;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.38) 0%, transparent 60%);
  pointer-events: none;
}

/* Glow ring — pulsing halo behind the blob */
.presence-blob::after {
  content: "";
  position: absolute;
  inset: -18%;
  border-radius: inherit;
  background: radial-gradient(circle, rgba(46,184,168,.25) 0%, transparent 70%);
  animation: glowPulse 4s ease-in-out infinite;
  pointer-events: none;
  z-index: -1;
}

/* --- 4. State-Specific Colors --------------------------------------------- */

/* Stress: warm amber gradient */
[data-state="stress"] .presence-blob {
  background: radial-gradient(circle at 38% 36%, #e8c870 0%, #c8a840 38%, #a88820 68%, #806800 100%);
  animation: blobBreatheStress 2.5s cubic-bezier(.45,.05,.55,.95) infinite;
}

/* Crisis: bright teal with intense glow */
[data-state="crisis"] .presence-blob {
  background: radial-gradient(circle at 38% 36%, #5ce8d0 0%, #28c0a8 38%, #187a6c 68%, #0a4840 100%);
  animation: blobBreatheCrisis 5s cubic-bezier(.45,.05,.55,.95) infinite;
}

/* --- 5. Presence Screen (crisis full-screen overlay) ---------------------- */

.mea-presence-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 600;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0b1610;
  gap: 24px;
}

[data-state="crisis"] .mea-presence-screen { display: flex; }

/* Breathing instruction text */
.mea-presence-screen .presence-text {
  font-size: 1.15rem;
  color: rgba(200,240,230,.75);
  letter-spacing: .04em;
  animation: presenceTextFade 5s ease-in-out infinite;
  text-align: center;
}

/* Action buttons row */
.mea-presence-screen .presence-actions {
  display: flex;
  gap: 16px;
  margin-top: 12px;
}

.mea-presence-screen .presence-actions button {
  padding: 10px 22px;
  border: 1px solid rgba(46,184,168,.4);
  border-radius: 24px;
  background: rgba(46,184,168,.12);
  color: #7fd8ce;
  font-size: .95rem;
  cursor: pointer;
  transition: background .25s, border-color .25s;
}

.mea-presence-screen .presence-actions button:hover {
  background: rgba(46,184,168,.24);
  border-color: rgba(46,184,168,.7);
}

/* Emergency link */
.mea-presence-screen .presence-emergency {
  margin-top: 20px;
  font-size: .85rem;
  color: rgba(200,240,230,.45);
  text-decoration: underline;
  cursor: pointer;
}

/* --- 6. Blob Name Label --------------------------------------------------- */

.blob-name {
  text-align: center;
  margin-top: 10px;
  font-size: .78rem;
  letter-spacing: .06em;
  color: rgba(200,240,230,.55);
  animation: presenceTextFade 6s ease-in-out infinite;
}

/* --- 7. Mini Blob (header / compact contexts) ----------------------------- */

.presence-blob--mini {
  width: 48px;
  height: 48px;
  border-radius: 60% 40% 55% 45% / 45% 55% 50% 50%;
  background: radial-gradient(circle at 38% 36%, #7fd8ce 0%, #2eb8a8 40%, #187a6c 100%);
  will-change: border-radius, transform;
  animation: blobBreatheCalm 4s cubic-bezier(.45,.05,.55,.95) infinite;
  flex-shrink: 0;
}

[data-state="stress"] .presence-blob--mini {
  background: radial-gradient(circle at 38% 36%, #e8c870 0%, #c8a840 40%, #a88820 100%);
  animation: blobBreatheStress 2.5s cubic-bezier(.45,.05,.55,.95) infinite;
}

[data-state="crisis"] .presence-blob--mini {
  background: radial-gradient(circle at 38% 36%, #5ce8d0 0%, #28c0a8 40%, #187a6c 100%);
  animation: blobBreatheCrisis 5s cubic-bezier(.45,.05,.55,.95) infinite;
}

/* --- 8. Immersive Breathing Guide ----------------------------------------- */

.breathing-guide {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 700;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(11,22,16,.96);
  gap: 32px;
}

.breathing-guide.active { display: flex; }

/* Phase label: inhale / hold / exhale */
.breathing-guide .phase-label {
  font-size: 1.4rem;
  color: rgba(200,240,230,.8);
  letter-spacing: .08em;
  text-transform: uppercase;
  animation: presenceTextFade 5s ease-in-out infinite;
}

/* Guide blob — larger version synced to a dedicated breathing rhythm */
@keyframes guideBreathe {
  0%        { transform: scale(1);    opacity: .85; }   /* inhale start  */
  30%       { transform: scale(1.25); opacity: 1;   }   /* inhale peak   */
  50%       { transform: scale(1.25); opacity: 1;   }   /* hold          */
  80%       { transform: scale(1);    opacity: .85; }   /* exhale end    */
  100%      { transform: scale(1);    opacity: .85; }   /* pause         */
}

.breathing-guide .guide-blob {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 36%, #5ce8d0 0%, #28c0a8 40%, #187a6c 80%, #0a4840 100%);
  animation: guideBreathe 8s cubic-bezier(.45,.05,.55,.95) infinite;
  box-shadow: 0 0 80px rgba(24,122,108,.25);
}

/* Close / dismiss button */
.breathing-guide .guide-close {
  position: absolute;
  top: 24px;
  right: 24px;
  background: none;
  border: none;
  color: rgba(200,240,230,.5);
  font-size: 1.6rem;
  cursor: pointer;
}

/* --- Accessibility: respect reduced-motion preference --------------------- */
@media (prefers-reduced-motion: reduce) {
  .presence-blob,
  .presence-blob--mini,
  .breathing-guide .guide-blob {
    animation: none;
  }
  .presence-blob::after { animation: none; opacity: .35; }
  .blob-name,
  .mea-presence-screen .presence-text,
  .breathing-guide .phase-label {
    animation: none;
    opacity: .75;
  }
}
