/* ========================================================
   TrainSmart V3: Contextual Slide-Out Drawer Guide (CSS)
   Strictly Mobile-Only (@media max-width: 640px)
   ======================================================== */



/* Floating Pull-Tab on Right Edge - Option A: Sleek & Compact Ergonomic Handle */
#mobile-guide-pull-tab {
  width: 32px !important;
  min-height: 90px !important;
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 85;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.99));
  border: 1.5px solid rgba(251, 191, 36, 0.8);
  border-right: none;
  border-radius: 16px 0 0 16px;
  padding: 10px 4px 10px 8px;
  box-shadow: -4px 0 20px rgba(251, 191, 36, 0.4), -2px 0 10px rgba(0, 0, 0, 0.9);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
  animation: guideTabNudge 3.5s infinite ease-in-out;
}

/* Floating Pull-Tab follows the Drawer when open */
#mobile-guide-pull-tab.drawer-open {
  animation: none !important;
  transform: translateY(-50%) translateX(calc(-1 * min(86vw, 380px))) !important;
  z-index: 95 !important;
  box-shadow: -8px 0 25px rgba(0, 0, 0, 0.85), -3px 0 12px rgba(251, 191, 36, 0.6) !important;
}

#mobile-guide-pull-tab.drawer-open .guide-tab-chevron {
  transform: rotate(180deg) !important;
  animation: none !important;
}

/* Extended invisible touch hit-box for thumb reach */
#mobile-guide-pull-tab::before {
  content: '';
  position: absolute;
  top: -15px;
  bottom: -15px;
  right: 0;
  width: 58px;
  pointer-events: auto;
}

#mobile-guide-pull-tab.hidden {
  display: none !important;
}

#mobile-guide-pull-tab:active {
  transform: translateY(-50%) scale(0.93);
  box-shadow: -8px 0 28px rgba(251, 191, 36, 0.7);
}

@keyframes guideTabNudge {
  0%, 100% {
    transform: translateY(-50%) translateX(0);
    box-shadow: -5px 0 20px rgba(251, 191, 36, 0.35);
  }
  50% {
    transform: translateY(-50%) translateX(-4px);
    box-shadow: -8px 0 30px rgba(251, 191, 36, 0.65);
  }
}

.guide-tab-chevron {
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  color: #fbbf24;
  animation: chevronSlide 1.8s infinite ease-in-out;
}

@keyframes chevronSlide {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-3px); }
}

.guide-tab-bulb {
  font-size: 19px;
  line-height: 1;
  filter: drop-shadow(0 0 7px rgba(251, 191, 36, 0.75));
  animation: bulbPulse 2.4s infinite ease-in-out;
}

@keyframes bulbPulse {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.6));
  }
  50% {
    transform: scale(1.15);
    filter: drop-shadow(0 0 14px rgba(251, 191, 36, 0.95)) drop-shadow(0 0 22px rgba(245, 158, 11, 0.7));
  }
}

/* Backdrop */
#mobile-guide-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 85;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

#mobile-guide-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Drawer Container */
#mobile-guide-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 86vw;
  max-width: 380px;
  z-index: 90;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(2, 6, 23, 0.99));
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-left: 1px solid rgba(244, 63, 94, 0.35);
  box-shadow: -15px 0 45px rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

#mobile-guide-drawer.open {
  transform: translateX(0);
}

/* Timeline Vertical Line */
.guide-step-connector {
  position: absolute;
  top: 28px;
  bottom: -12px;
  left: 15px;
  width: 2px;
  background: linear-gradient(180deg, rgba(244, 63, 94, 0.8), rgba(245, 158, 11, 0.5), rgba(56, 189, 248, 0.3));
}

.guide-step-item:last-child .guide-step-connector {
  display: none;
}

/* Spotlight Focus Pulse on Target Element */
@keyframes guideSpotlightPulse {
  0% {
    outline: 3px solid rgba(244, 63, 94, 0);
    box-shadow: 0 0 0 0 rgba(244, 63, 94, 0);
    transform: scale(1);
  }
  20% {
    outline: 3.5px solid rgba(244, 63, 94, 0.95);
    box-shadow: 0 0 28px 6px rgba(244, 63, 94, 0.7);
    transform: scale(1.02);
  }
  50% {
    outline: 3.5px solid rgba(245, 158, 11, 0.95);
    box-shadow: 0 0 35px 8px rgba(245, 158, 11, 0.75);
    transform: scale(1.01);
  }
  80% {
    outline: 3px solid rgba(244, 63, 94, 0.8);
    box-shadow: 0 0 20px 4px rgba(244, 63, 94, 0.5);
    transform: scale(1);
  }
  100% {
    outline: 3px solid rgba(244, 63, 94, 0);
    box-shadow: 0 0 0 0 rgba(244, 63, 94, 0);
    transform: scale(1);
  }
}

.guide-target-spotlight {
  animation: guideSpotlightPulse 2.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards !important;
  position: relative !important;
  z-index: 35 !important;
}

/* Ensure modals always appear on top of guide drawer and pull-tab */
#modals-root,
div[id^="modal-"]:not(.hidden) {
  z-index: 1000 !important;
}

/* When any modal is open, hide the pull-tab so it never interferes */
body:has(div[id^="modal-"]:not(.hidden)) #mobile-guide-pull-tab {
  display: none !important;
}
