/**
 * Grace Music School - Editorial Motion & Interaction Styles
 * Controlled, performant, and sophisticated scroll-driven animations.
 */

/* 1. Progressive Text & Block Reveals */
.gm-reveal,
.fade-up {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.85s cubic-bezier(0.16, 1, 0.3, 1), transform 0.85s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.gm-reveal.is-revealed,
.fade-up.is-revealed {
  opacity: 1;
  transform: translateY(0);
}

.gm-reveal-fade,
.fade-in {
  opacity: 0;
  transition: opacity 1s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity;
}

.gm-reveal-fade.is-revealed,
.fade-in.is-revealed {
  opacity: 1;
}

.slide-left {
  opacity: 0;
  transform: translateX(-50px);
  transition: opacity 0.9s cubic-bezier(0.16, 1, 0.3, 1), transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.slide-left.is-revealed {
  opacity: 1;
  transform: translateX(0);
}

.slide-right {
  opacity: 0;
  transform: translateX(50px);
  transition: opacity 0.9s cubic-bezier(0.16, 1, 0.3, 1), transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.slide-right.is-revealed {
  opacity: 1;
  transform: translateX(0);
}

.scale-in {
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 0.85s cubic-bezier(0.16, 1, 0.3, 1), transform 0.85s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.scale-in.is-revealed {
  opacity: 1;
  transform: scale(1);
}

.text-reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.text-reveal.is-revealed {
  opacity: 1;
  transform: translateY(0);
}

/* 2. Image Reveal - Safe progressive enhancement (never hide images permanently) */
.gm-reveal-mask,
.image-reveal {
  opacity: 1;
  transform: none;
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

/* When JS is active, apply smooth subtle reveal */
.js-ready .gm-reveal-mask:not(.is-revealed),
.js-ready .image-reveal:not(.is-revealed) {
  opacity: 0.15;
  transform: scale(0.98);
}

.gm-reveal-mask.is-revealed,
.image-reveal.is-revealed,
.is-revealed .gm-reveal-mask,
.is-revealed .image-reveal,
.gm-course-chapter.is-revealed .gm-course-chapter-media,
.gm-course-chapter.is-revealed .image-reveal {
  opacity: 1 !important;
  transform: scale(1) !important;
  clip-path: none !important;
}

/* 3. Staggered Delays for Sequential Elements */
.gm-stagger > *:nth-child(1) { transition-delay: 0.05s; }
.gm-stagger > *:nth-child(2) { transition-delay: 0.15s; }
.gm-stagger > *:nth-child(3) { transition-delay: 0.25s; }
.gm-stagger > *:nth-child(4) { transition-delay: 0.35s; }
.gm-stagger > *:nth-child(5) { transition-delay: 0.45s; }
.gm-stagger > *:nth-child(6) { transition-delay: 0.55s; }

/* 4. Subtle Desktop Custom Cursor */
@media (hover: hover) and (pointer: fine) {
  body.has-custom-cursor {
    cursor: none;
  }
  
  body.has-custom-cursor a,
  body.has-custom-cursor button,
  body.has-custom-cursor [role="button"] {
    cursor: none;
  }

  /* CRITICAL FIX: Ensure inputs, textareas, selects, and modals ALWAYS have natural visible cursors */
  body.has-custom-cursor input,
  body.has-custom-cursor textarea,
  body.has-custom-cursor select,
  body.has-custom-cursor .gm-form-input,
  body.has-custom-cursor .gm-form-textarea {
    cursor: text !important;
    caret-color: var(--gm-primary, #FF5722) !important;
  }

  body.has-custom-cursor select,
  body.has-custom-cursor .gm-form-select {
    cursor: pointer !important;
  }

  body.has-custom-cursor .gm-modal-overlay,
  body.has-custom-cursor .gm-modal-dialog {
    cursor: default;
  }

  body.has-custom-cursor .gm-modal-close,
  body.has-custom-cursor .gm-modal-submit-btn,
  body.has-custom-cursor .gm-quick-contact-item,
  body.has-custom-cursor .gm-fab,
  body.has-custom-cursor .gm-testi-btn,
  body.has-custom-cursor .gm-testi-dot,
  body.has-custom-cursor .gm-hero-dot,
  body.has-custom-cursor .gm-hero-prev,
  body.has-custom-cursor .gm-hero-next {
    cursor: pointer !important;
  }

  .gm-cursor-dot {
    position: fixed;
    top: 0;
    left: 0;
    width: 8px;
    height: 8px;
    background-color: var(--gm-primary);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    transition: width 0.2s ease, height 0.2s ease, opacity 0.2s ease;
  }

  .gm-cursor-ring {
    position: fixed;
    top: 0;
    left: 0;
    width: 36px;
    height: 36px;
    border: 1.5px solid rgba(255, 94, 30, 0.5);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9998;
    transform: translate(-50%, -50%);
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), height 0.3s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s ease, background-color 0.3s ease;
  }

  .gm-cursor-ring.is-hovered {
    width: 58px;
    height: 58px;
    border-color: var(--gm-primary);
    background-color: rgba(255, 94, 30, 0.1);
  }

  /* When modal is open or focusing input, hide custom cursor dots so native I-beam cursor is fully visible */
  body.has-custom-cursor.modal-is-open .gm-cursor-dot,
  body.has-custom-cursor.modal-is-open .gm-cursor-ring,
  body.has-custom-cursor.is-typing .gm-cursor-dot,
  body.has-custom-cursor.is-typing .gm-cursor-ring {
    opacity: 0 !important;
  }
}

/* 5. Video Modal Player */
.gm-video-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 8, 10, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.35s ease;
  padding: 2rem;
}

.gm-video-modal.is-active {
  opacity: 1;
  visibility: visible;
}

.gm-video-modal-container {
  width: 100%;
  max-width: 1020px;
  position: relative;
  background: #000000;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 30px 70px rgba(0,0,0,0.6);
}

.gm-video-modal-close {
  position: absolute;
  top: -48px;
  right: 0;
  color: #FFFFFF;
  font-size: 2.25rem;
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.gm-video-modal-close:hover {
  opacity: 1;
  color: var(--gm-primary);
}

.gm-video-wrapper {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 ratio */
  height: 0;
}

.gm-video-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* 6. Prefers Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .gm-reveal,
  .gm-reveal-fade,
  .gm-reveal-mask {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
  }

  .gm-cursor-dot,
  .gm-cursor-ring {
    display: none !important;
  }
}

/* ==================================================
   7. Subtle Music Waveform Page Transition
   Fast, elegant, and non-blocking (350ms)
   ================================================== */
.gm-page-transition-overlay {
  position: fixed;
  inset: 0;
  background: var(--gm-dark-base, #111111);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.gm-page-transition-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

.gm-music-wave-container {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 48px;
}

.gm-wave-bar {
  width: 4px;
  background: var(--gm-primary, #FF5722);
  border-radius: 4px;
  animation: gmWaveEqualizer 0.8s ease-in-out infinite alternate;
}

.gm-wave-bar:nth-child(1) { height: 16px; animation-delay: 0.0s; }
.gm-wave-bar:nth-child(2) { height: 32px; animation-delay: 0.15s; }
.gm-wave-bar:nth-child(3) { height: 48px; animation-delay: 0.3s; }
.gm-wave-bar:nth-child(4) { height: 28px; animation-delay: 0.1s; }
.gm-wave-bar:nth-child(5) { height: 40px; animation-delay: 0.25s; }
.gm-wave-bar:nth-child(6) { height: 20px; animation-delay: 0.4s; }

@keyframes gmWaveEqualizer {
  0% {
    transform: scaleY(0.3);
    opacity: 0.5;
  }
  100% {
    transform: scaleY(1);
    opacity: 1;
  }
}

/* ==================================================
   8. Cute Animated Guitarist Mascot (Desktop Only)
   Fixed bottom-left, subtle movements, dismissable
   ================================================== */
.gm-guitarist-mascot {
  position: fixed;
  bottom: 22px;
  left: 24px;
  z-index: 850;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  pointer-events: auto;
  user-select: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

@media (max-width: 1024px) {
  .gm-guitarist-mascot {
    display: none !important;
  }
}

.gm-guitarist-mascot.is-hidden {
  opacity: 0 !important;
  transform: translateY(24px) scale(0.8) !important;
  pointer-events: none !important;
}

.gm-mascot-figure {
  position: relative;
  width: 96px;
  height: 108px;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.35));
  cursor: pointer;
  transition: transform 0.25s ease;
}

.gm-mascot-figure:hover {
  transform: translateY(-3px) scale(1.04);
}

.gm-mascot-speech {
  background: #181B24;
  color: #FFFFFF;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 6px 12px;
  border-radius: 14px;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.12);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  margin-bottom: 8px;
  position: relative;
}

.gm-mascot-speech::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 20px;
  width: 8px;
  height: 8px;
  background: #181B24;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  transform: rotate(45deg);
}

.gm-guitarist-mascot:hover .gm-mascot-speech {
  opacity: 1;
  transform: translateY(0);
}

.gm-mascot-dismiss {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(24, 27, 36, 0.85);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease;
  z-index: 10;
}

.gm-guitarist-mascot:hover .gm-mascot-dismiss {
  opacity: 1;
}

.gm-mascot-dismiss:hover {
  background: var(--gm-primary, #FF5722);
  border-color: var(--gm-primary, #FF5722);
}

/* Mascot Head Bob */
.gm-mascot-head-group {
  transform-origin: 50px 52px;
  animation: gmMascotHeadBob 2.5s ease-in-out infinite alternate;
}

@keyframes gmMascotHeadBob {
  0% {
    transform: rotate(-1.5deg) translateY(0);
  }
  50% {
    transform: rotate(2deg) translateY(1.5px);
  }
  100% {
    transform: rotate(-1.5deg) translateY(0);
  }
}

/* Mascot Strumming Arm */
.gm-mascot-strum-group {
  transform-origin: 60px 64px;
  animation: gmMascotStrum 0.75s ease-in-out infinite alternate;
}

@keyframes gmMascotStrum {
  0% {
    transform: rotate(-3deg);
  }
  50% {
    transform: rotate(4deg);
  }
  100% {
    transform: rotate(-2deg);
  }
}

/* Floating Musical Notes */
.gm-mascot-note {
  position: absolute;
  color: var(--gm-primary, #FF5722);
  font-size: 13px;
  font-weight: 800;
  pointer-events: none;
  opacity: 0;
  z-index: 5;
}

.gm-note-1 {
  bottom: 65px;
  left: 20px;
  animation: gmNoteFloat 2.6s ease-in-out infinite;
}

.gm-note-2 {
  bottom: 70px;
  left: 45px;
  animation: gmNoteFloat 3.0s ease-in-out 0.9s infinite;
}

.gm-note-3 {
  bottom: 62px;
  left: 60px;
  animation: gmNoteFloat 3.4s ease-in-out 1.8s infinite;
}

@keyframes gmNoteFloat {
  0% {
    transform: translate(0, 0) scale(0.6);
    opacity: 0;
  }
  40% {
    opacity: 0.85;
  }
  100% {
    transform: translate(-12px, -32px) scale(1.1);
    opacity: 0;
  }
}

