/**
 * DING! Mascot Experience Stylesheet
 * High-performance styles for the official 3D Bell Mascot,
 * scroll-driven kinematics, speech bubbles, and sonic shockwaves.
 */

/* ── 1. MASCOT STAGE CONTAINER (FIXED FULLSCREEN VIEWPORT LAYER) ─────────── */
.mascot-stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1200;
  overflow: hidden;
}

/* ── 2. MASCOT ENTITY (POSITIONED BY JS LERP TRANSFORM) ──────────────────── */
.mascot-entity {
  position: absolute;
  top: 0;
  left: 0;
  width: 124px;
  height: 136px;
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  will-change: transform, opacity;
  transition: opacity 0.3s ease;
}

.mascot-entity.is-hidden {
  opacity: 0;
  pointer-events: none;
}

/* ── 3. SHADOW & AMBIENT GLOW ────────────────────────────────────────────── */
.mascot-shadow {
  position: absolute;
  bottom: -12px;
  left: 50%;
  width: 72px;
  height: 18px;
  margin-left: -36px;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
  transform-origin: center center;
  transition: transform 0.2s ease, opacity 0.2s ease;
  z-index: 1;
}

.mascot-aura {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 140px;
  height: 140px;
  margin-top: -70px;
  margin-left: -70px;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.28) 0%, rgba(255, 107, 0, 0.12) 45%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  animation: mascotAuraPulse 3.2s ease-in-out infinite alternate;
  z-index: 2;
}

@keyframes mascotAuraPulse {
  0% {
    transform: scale(0.92);
    opacity: 0.65;
  }
  100% {
    transform: scale(1.15);
    opacity: 0.95;
    filter: blur(3px);
  }
}

/* ── 4. CLIMAX SONIC SHOCKWAVE RING ───────────────────────────────────────── */
.mascot-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 80px;
  height: 80px;
  margin-top: -40px;
  margin-left: -40px;
  border-radius: 50%;
  border: 3px solid #FFD700;
  box-shadow: 0 0 30px #FFD700, inset 0 0 18px rgba(255, 215, 0, 0.6);
  pointer-events: none;
  opacity: 0;
  transform: scale(0.2);
  z-index: 2;
}

.mascot-ring.is-blasting {
  animation: mascotRingBlast 1.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes mascotRingBlast {
  0% {
    transform: scale(0.2);
    opacity: 1;
    border-width: 6px;
  }
  50% {
    opacity: 0.85;
  }
  100% {
    transform: scale(5.2);
    opacity: 0;
    border-width: 1px;
  }
}

/* Screen Climax Flare */
.mascot-climax-backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(255, 215, 0, 0.22) 0%, rgba(255, 107, 0, 0.08) 50%, transparent 80%);
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 1150;
}

.mascot-climax-backdrop.is-active {
  opacity: 1;
}

/* ── 5. MASCOT BODY & SPRITE ─────────────────────────────────────────────── */
.mascot-body-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  transform-origin: 50% 18%; /* Top loop of the bell */
  z-index: 3;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.mascot-sprite {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 16px rgba(255, 215, 0, 0.32));
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Interactive Tap Jiggle Animation */
.mascot-entity.is-jiggling .mascot-body-wrapper {
  animation: mascotBellRingSwing 0.75s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes mascotBellRingSwing {
  0% { transform: scale(1) rotate(0deg); }
  15% { transform: scale(1.12) rotate(-18deg); }
  35% { transform: scale(1.08) rotate(15deg); }
  55% { transform: scale(1.04) rotate(-10deg); }
  75% { transform: scale(1.02) rotate(6deg); }
  90% { transform: scale(1.01) rotate(-3deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* Hover effect on desktop */
@media (hover: hover) and (pointer: fine) {
  .mascot-entity:hover .mascot-sprite {
    transform: scale(1.06);
    filter: drop-shadow(0 18px 35px rgba(0, 0, 0, 0.65)) drop-shadow(0 0 24px rgba(255, 215, 0, 0.55));
  }
}

/* ── 6. MASCOT SPEECH BUBBLE (FUMETTO NARRATIVO) ─────────────────────────── */
.mascot-speech-bubble {
  position: fixed;
  top: 0;
  left: 0;
  margin: 0;
  width: max-content;
  max-width: 250px;
  background: rgba(14, 14, 18, 0.94);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1px solid rgba(255, 215, 0, 0.32);
  border-radius: 16px;
  padding: 0.68rem 0.85rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 25px rgba(255, 215, 0, 0.14);
  color: #F5F5F7;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.32s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.32s;
  z-index: 10000;
}

.mascot-speech-bubble.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  cursor: pointer;
}

/* Bubble Tails by side */
.mascot-speech-bubble.bubble-side-left .mascot-bubble-tail {
  position: absolute;
  top: 50%;
  right: -8px;
  margin-top: -8px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 9px solid rgba(14, 14, 18, 0.92);
  filter: drop-shadow(2px 0 0 rgba(255, 215, 0, 0.32));
}

.mascot-speech-bubble.bubble-side-right .mascot-bubble-tail {
  position: absolute;
  top: 50%;
  left: -8px;
  margin-top: -8px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 9px solid rgba(14, 14, 18, 0.92);
  filter: drop-shadow(-2px 0 0 rgba(255, 215, 0, 0.32));
}

.mascot-speech-bubble.bubble-side-top .mascot-bubble-tail {
  position: absolute;
  bottom: -8px;
  left: 50%;
  margin-left: -8px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 9px solid rgba(14, 14, 18, 0.92);
  filter: drop-shadow(0 2px 0 rgba(255, 215, 0, 0.32));
}
  border-top: 9px solid rgba(14, 14, 18, 0.92);
  filter: drop-shadow(0 2px 0 rgba(255, 215, 0, 0.32));
}

/* Bubble Header & Typography */
.mascot-bubble-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.35rem;
  width: 100%;
}

.mascot-bubble-tag {
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #000000;
  background: #FFD700;
  padding: 0.15rem 0.45rem;
  border-radius: 980px;
}

.mascot-bubble-sub {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
}

.mascot-bubble-close {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #8E8E93;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.2s ease;
}

.mascot-bubble-close:hover {
  background: rgba(255, 255, 255, 0.25);
  color: #FFFFFF;
}

.mascot-bubble-text {
  font-size: 0.80rem;
  font-weight: 500;
  line-height: 1.32;
  line-height: 1.36;
  color: #FFFFFF;
  margin: 0;
}

/* ── 7. INTERACTIVE GOLDEN SPARKLES ───────────────────────────────────────── */
.mascot-sparkle {
  position: absolute;
  pointer-events: none;
  font-size: 1.2rem;
  user-select: none;
  animation: sparkleFlyOut 0.85s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  z-index: 20;
}

@keyframes sparkleFlyOut {
  0% {
    transform: translate(0, 0) scale(0.3) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) scale(1.2) rotate(var(--rot));
    opacity: 0;
  }
}

/* ── 8. RESPONSIVE OPTIMIZATIONS ──────────────────────────────────────────── */

/* Tablets (<= 992px) */
@media (max-width: 992px) {
  .mascot-entity {
    width: 105px;
    height: 115px;
  }
  .mascot-speech-bubble {
    max-width: 250px;
    padding: 0.75rem 0.95rem;
  }
  .mascot-bubble-text {
    font-size: 0.82rem;
  }
}

/* Smartphones (<= 768px) */
@media (max-width: 768px) {
  /* Mascot Entity on Mobile: sleek floating companion docked in bottom-right safe area */
  .mascot-entity {
    width: 60px;
    height: 66px;
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.7));
  }

  .mascot-shadow {
    width: 36px;
    height: 10px;
    margin-left: -18px;
    bottom: -6px;
  }

  .mascot-aura {
    width: 80px;
    height: 80px;
    margin-top: -40px;
    margin-left: -40px;
  }

  /* On mobile, the speech bubble transforms into a top Dynamic Island Notification Capsule */
  .mascot-speech-bubble {
    position: fixed !important;
    top: max(56px, calc(env(safe-area-inset-top) + 48px)) !important;
    left: 14px !important;
    right: 14px !important;
    bottom: auto !important;
    transform: translateY(-25px) scale(0.95) !important;
    width: auto !important;
    max-width: 390px !important;
    margin: 0 auto !important;
    border-radius: 980px !important;
    padding: 0.55rem 0.95rem !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.55rem !important;
    background: rgba(14, 14, 18, 0.94) !important;
    backdrop-filter: blur(28px) saturate(190%) !important;
    -webkit-backdrop-filter: blur(28px) saturate(190%) !important;
    border: 1px solid rgba(255, 215, 0, 0.38) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.9), 0 0 20px rgba(255, 215, 0, 0.16) !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s !important;
    z-index: 1500 !important;
  }

  .mascot-speech-bubble.is-visible {
    transform: translateY(0) scale(1) !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .mascot-bubble-tail {
    display: none !important; /* No tail needed for top capsule notification */
  }

  .mascot-bubble-header {
    margin-bottom: 0 !important;
    width: auto !important;
    flex-shrink: 0;
  }

  .mascot-bubble-sub {
    display: none !important; /* Keep it ultra-clean and compact on mobile */
  }

  .mascot-bubble-tag {
    font-size: 0.62rem !important;
    padding: 0.15rem 0.42rem !important;
  }

  .mascot-bubble-text {
    font-size: 0.80rem !important;
    line-height: 1.25 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    flex: 1 !important;
  }

  .mascot-bubble-close {
    width: 20px !important;
    height: 20px !important;
    font-size: 14px !important;
    flex-shrink: 0;
  }
}

/* Very Small Smartphones (< 360px) */
@media (max-width: 360px) {
  .mascot-entity {
    width: 52px;
    height: 58px;
  }
  .mascot-speech-bubble {
    left: 8px !important;
    right: 8px !important;
    padding: 0.45rem 0.75rem !important;
  }
  .mascot-bubble-text {
    font-size: 0.74rem !important;
  }
}

/* Accessibility: Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .mascot-aura {
    animation: none;
  }
  .mascot-ring.is-blasting {
    animation: none;
  }
  .mascot-entity.is-jiggling .mascot-body-wrapper {
    animation: none;
  }
}
