/**
 * Pinestone Academy - Pinnie The Scholar Owl Mascot
 * Luxury academic palette (Midnight Navy & Champagne Gold),
 * Frosted speech bubble, flight physics, graduation cap toss, fireworks & School Portal.
 */

:root {
  --mascot-size: 105px;
  --pa-navy-dark: #0a1c2b;
  --pa-navy-mid: #102b40;
  --pa-navy-light: #1b3d5c;
  --pa-gold-soft: #dfbe76;
  --pa-gold-deep: #b88d3b;
  --pa-gold-glow: rgba(223, 190, 118, 0.35);
  --pa-cream: #fdfbf7;
}

/* Floating mascot container */
.pa-mascot-container {
  position: fixed;
  bottom: 22px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pa-mascot-container * {
  box-sizing: border-box;
}

/* Elegant Frosted Glass Speech Bubble */
.pa-mascot-speech {
  pointer-events: auto;
  position: relative;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(226, 232, 240, 0.85);
  box-shadow: 0 16px 36px -10px rgba(10, 28, 43, 0.15), 0 0 1px 1px rgba(255, 255, 255, 0.6) inset;
  border-radius: 16px;
  padding: 12px 15px;
  max-width: 265px;
  min-width: 210px;
  margin-bottom: 10px;
  transform-origin: bottom right;
  animation: paSpeechPop 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 1;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.pa-mascot-speech.hidden,
.pa-mascot-speech[hidden],
.pa-mascot-speech[aria-hidden="true"] {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: scale(0.8) translateY(12px) !important;
}

.pa-mascot-speech::after {
  content: "";
  position: absolute;
  bottom: -8px;
  right: 44px;
  width: 16px;
  height: 16px;
  background: rgba(255, 255, 255, 0.94);
  border-right: 1px solid rgba(226, 232, 240, 0.85);
  border-bottom: 1px solid rgba(226, 232, 240, 0.85);
  transform: rotate(45deg);
  border-radius: 0 0 3px 0;
}

.pa-mascot-speech-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 8px;
}

.pa-mascot-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, #0d2235 0%, #15344f 100%);
  color: #dfbe76;
  border: 1px solid rgba(223, 190, 118, 0.4);
  font-size: 0.675rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2.5px 8px;
  border-radius: 20px;
}

.pa-mascot-close {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 3px 6px;
  font-size: 15px;
  line-height: 1;
  border-radius: 6px;
  transition: all 0.15s ease;
}
.pa-mascot-close:hover {
  color: #0f172a;
  background: #f1f5f9;
}

.pa-mascot-text {
  font-size: 0.82rem;
  line-height: 1.45;
  color: #1e293b;
  margin: 0;
  font-weight: 500;
}

.pa-mascot-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.pa-mascot-btn {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
}
.pa-mascot-btn:hover {
  background: #102b40;
  color: #dfbe76;
  border-color: #b88d3b;
}

/* Mascot Avatar Wrap */
.pa-mascot-avatar-wrap {
  pointer-events: auto;
  position: relative;
  width: var(--mascot-size);
  height: var(--mascot-size);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s ease;
}

.pa-mascot-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 10px 18px rgba(10, 28, 43, 0.16));
  animation: paOwlBreathe 4.5s ease-in-out infinite;
  transform-origin: center bottom;
}

.pa-mascot-avatar-wrap:hover .pa-mascot-svg {
  animation: paOwlCheer 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pa-mascot-avatar-wrap.flipping .pa-mascot-svg {
  animation: paOwlSpin 0.75s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Rest / Folded Wings Animation */
.pinnie-arm-right {
  transform-origin: 85px 64px;
  animation: paWingWave 3.5s ease-in-out infinite;
}

/* Flapping Spread Flight Wings during Takeoff & Flight */
.pa-mascot-avatar-wrap.flapping #owlFoldedWings {
  display: none !important;
}

.pa-mascot-avatar-wrap.flapping #owlFlightWings {
  display: block !important;
}

.pa-mascot-avatar-wrap.flapping #owlBookPerch,
.pa-mascot-avatar-wrap.flapping .pinnie-shadow {
  opacity: 0;
  transition: opacity 0.25s ease;
}

.pa-mascot-avatar-wrap.flapping #owlTalons {
  transform: translateY(-3px) scale(0.92);
  transform-origin: 60px 110px;
  transition: transform 0.25s ease;
}

.pa-mascot-avatar-wrap.flapping #owlFlightWingLeft {
  transform-origin: 38px 66px;
  animation: paFlapLeftWing 0.16s ease-in-out infinite alternate !important;
}

.pa-mascot-avatar-wrap.flapping #owlFlightWingRight {
  transform-origin: 82px 66px;
  animation: paFlapRightWing 0.16s ease-in-out infinite alternate !important;
}

/* Graduation Mortarboard Cap Toss */
.pinnie-mortarboard.cap-tossed {
  animation: paCapToss 2.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards !important;
}

@keyframes paCapToss {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(1);
    opacity: 1;
  }
  25% {
    transform: translate(-30px, -90px) rotate(-160deg) scale(1.25);
    opacity: 1;
  }
  55% {
    transform: translate(-60px, -150px) rotate(-380deg) scale(1.1);
    opacity: 0.95;
  }
  85% {
    transform: translate(-80px, -180px) rotate(-600deg) scale(0.8);
    opacity: 0.7;
  }
  100% {
    transform: translate(-90px, -200px) rotate(-720deg) scale(0.3);
    opacity: 0;
  }
}

/* Golden Tassel & Spectacles */
.pinnie-cap-tassel {
  transform-origin: 32px 30px;
  animation: paTasselSway 3s ease-in-out infinite;
}

.pinnie-eyelid {
  transform-origin: center;
  animation: paOwlBlink 5s ease-in-out infinite;
}

.pinnie-sparkle {
  transform-origin: center;
  animation: paSoftGlow 2.5s ease-in-out infinite alternate;
}

/* ==========================================================================
   FLIGHT SEQUENCE, PINESTONE SCHOOL PORTAL & FIREWORKS
   ========================================================================== */

/* Owl Flying Animation Across Screen */
.pa-mascot-avatar-wrap.flying-away {
  position: fixed;
  z-index: 10001;
  pointer-events: none;
  animation: paOwlFlightSweep 3.0s cubic-bezier(0.42, 0, 0.58, 1) forwards;
}

@keyframes paOwlFlightSweep {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
  }
  20% {
    transform: translate(-70px, -160px) scale(1.12) rotate(-16deg);
  }
  45% {
    transform: translate(-210px, -240px) scale(1.05) rotate(-6deg);
  }
  70% {
    transform: translate(-330px, -170px) scale(0.9) rotate(12deg);
  }
  88% {
    transform: translate(-265px, -55px) scale(0.55) rotate(4deg);
    opacity: 1;
  }
  100% {
    transform: translate(-245px, -38px) scale(0.14) rotate(0deg);
    opacity: 0;
  }
}

/* Classical Pinestone School Building Portal */
.pa-school-portal {
  position: fixed;
  bottom: 20px;
  right: 175px;
  width: 170px;
  height: 150px;
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.7) translateY(20px);
  filter: drop-shadow(0 15px 35px rgba(10, 28, 43, 0.35));
  transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.pa-school-portal.visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.pa-school-portal.dissolving {
  opacity: 0;
  transform: scale(1.1) translateY(-14px);
  filter: blur(10px) drop-shadow(0 0 35px rgba(223, 190, 118, 0.9));
  transition: all 1.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.pa-school-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Expanding Magical 'PA' Crest Celebration Shield */
.pa-expanding-crest {
  opacity: 0;
  transform: scale(0.3);
  pointer-events: none;
  transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pa-expanding-crest.bursting {
  opacity: 1;
  transform: scale(1.35);
  filter: drop-shadow(0 0 20px #dfbe76) drop-shadow(0 0 35px rgba(245, 158, 11, 0.7));
  animation: paCrestPulse 1.2s ease-in-out infinite alternate;
}

@keyframes paCrestPulse {
  0% { transform: scale(1.25) rotate(-2deg); }
  100% { transform: scale(1.4) rotate(2deg); }
}

/* Celebratory Fireworks Spark */
.pa-firework-spark {
  position: fixed;
  pointer-events: none;
  z-index: 10003;
  border-radius: 50%;
  animation: paFireworkSparkFade 1.3s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes paFireworkSparkFade {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--fx), var(--fy)) scale(0.2);
  }
}

/* Prominent Stardust Particles */
.pa-stardust {
  position: fixed;
  pointer-events: none;
  z-index: 10002;
  border-radius: 50%;
  animation: paStardustFade 1.3s ease-out forwards;
}

@keyframes paStardustFade {
  0% {
    opacity: 1;
    transform: scale(1) translate(0, 0);
  }
  100% {
    opacity: 0;
    transform: scale(0.15) translate(var(--dx), var(--dy));
  }
}

/* Keyframes */
@keyframes paSpeechPop {
  0% { opacity: 0; transform: scale(0.7) translateY(12px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes paOwlBreathe {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-7px) rotate(1deg); }
}

@keyframes paOwlCheer {
  0% { transform: scale(1, 1) translateY(0); }
  35% { transform: scale(1.12, 0.88) translateY(0); }
  65% { transform: scale(0.92, 1.12) translateY(-12px); }
  100% { transform: scale(1, 1) translateY(0); }
}

@keyframes paOwlSpin {
  0% { transform: scale(1) rotate(0deg); }
  45% { transform: scale(1.15) rotate(180deg) translateY(-20px); }
  100% { transform: scale(1) rotate(360deg) translateY(0); }
}

@keyframes paWingWave {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-20deg); }
  50% { transform: rotate(10deg); }
  75% { transform: rotate(-15deg); }
}

@keyframes paFlapLeftWing {
  0% { transform: rotate(38deg) scaleY(0.85); }
  100% { transform: rotate(-32deg) scaleY(1.12); }
}

@keyframes paFlapRightWing {
  0% { transform: rotate(-38deg) scaleY(0.85); }
  100% { transform: rotate(32deg) scaleY(1.12); }
}

@keyframes paTasselSway {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(18deg); }
}

@keyframes paOwlBlink {
  0%, 93%, 100% { transform: scaleY(1); }
  95%, 97% { transform: scaleY(0.08); }
}

@keyframes paSoftGlow {
  0% { opacity: 0.35; transform: scale(0.8) rotate(0deg); }
  100% { opacity: 1; transform: scale(1.15) rotate(45deg); }
}

/* Responsive adjustments */
@media (max-width: 640px) {
  :root {
    --mascot-size: 88px;
  }
  .pa-mascot-container {
    bottom: 16px;
    right: 14px;
  }
  .pa-mascot-speech {
    max-width: 220px;
    padding: 10px 12px;
  }
  .pa-mascot-speech::after {
    right: 36px;
  }
  .pa-school-portal {
    right: 90px;
    bottom: 16px;
    width: 130px;
    height: 115px;
  }
}
