/**
 * Africa's Pocket Tutorial System
 * Floating button and portrait video modal styles
 */

/* =====================================================
   FLOATING TUTORIAL BUTTON
   ===================================================== */

.ap-tutorial-fab {
  position: fixed;
  bottom: 30px; /* Default position when no WhatsApp button */
  right: 30px; /* Match WhatsApp button alignment */
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #083E5B 0%, #0a5a84 100%);
  color: #fff;
  border: none;
  border-radius: 50px;
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(8, 62, 91, 0.4);
  transition: all 0.3s ease;
  text-decoration: none;
}

/* When WhatsApp button exists, stack tutorial button above it */
.ap-tutorial-fab--with-whatsapp {
  bottom: 100px; /* Positioned above WhatsApp button (30px + ~60px button height + 10px gap) */
}

.ap-tutorial-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(8, 62, 91, 0.5);
  background: linear-gradient(135deg, #0a5a84 0%, #083E5B 100%);
}

.ap-tutorial-fab:active {
  transform: translateY(0);
}

.ap-tutorial-fab__icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.ap-tutorial-fab__text {
  white-space: nowrap;
}

/* Tablet adjustments */
@media (max-width: 991px) {
  .ap-tutorial-fab {
    bottom: 20px;
    right: 20px; /* Match WhatsApp button */
  }
  
  .ap-tutorial-fab--with-whatsapp {
    bottom: 85px; /* Positioned above WhatsApp button */
  }
}

/* Mobile adjustments */
@media (max-width: 767px) {
  .ap-tutorial-fab {
    bottom: 15px;
    right: 15px; /* Match WhatsApp button */
  }
  
  .ap-tutorial-fab--with-whatsapp {
    bottom: 80px; /* Positioned above WhatsApp button */
  }
}

/* Small mobile: Icon only */
@media (max-width: 480px) {
  .ap-tutorial-fab {
    padding: 14px;
    border-radius: 50%;
  }
  
  .ap-tutorial-fab__text {
    display: none;
  }
  
  .ap-tutorial-fab__icon {
    width: 24px;
    height: 24px;
  }
}

/* =====================================================
   PORTRAIT VIDEO MODAL
   ===================================================== */

.ap-tutorial-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.ap-tutorial-modal.is-open {
  display: flex;
  opacity: 1;
}

.ap-tutorial-modal__content {
  position: relative;
  width: 100%;
  max-width: 400px;
  max-height: calc(100vh - 80px);
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: ap-tutorial-slide-up 0.3s ease;
}

@keyframes ap-tutorial-slide-up {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Portrait video container - 9:16 aspect ratio */
.ap-tutorial-modal__video-wrapper {
  position: relative;
  width: 100%;
  padding-top: 177.78%; /* 16:9 inverted = 9:16 = 177.78% */
  background: #111;
}

.ap-tutorial-modal__iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* Close button */
.ap-tutorial-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ap-tutorial-modal__close:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: scale(1.1);
}

.ap-tutorial-modal__close-icon {
  width: 20px;
  height: 20px;
  fill: #fff;
}

/* Loading state */
.ap-tutorial-modal__loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #fff;
}

.ap-tutorial-modal__spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ap-tutorial-spin 0.8s linear infinite;
}

@keyframes ap-tutorial-spin {
  to {
    transform: rotate(360deg);
  }
}

/* =====================================================
   LANDSCAPE VIDEO MODAL VARIANT
   ===================================================== */

.ap-tutorial-modal--landscape .ap-tutorial-modal__content {
  max-width: 800px;
  width: 100%;
}

/* Landscape video container - 16:9 aspect ratio */
.ap-tutorial-modal--landscape .ap-tutorial-modal__video-wrapper {
  padding-top: 56.25%; /* 16:9 = 56.25% */
}

/* Responsive adjustments for landscape */
@media (max-width: 768px) {
  .ap-tutorial-modal--landscape .ap-tutorial-modal__content {
    max-width: 100%;
  }
}

@media (min-width: 768px) {
  .ap-tutorial-modal--landscape .ap-tutorial-modal__content {
    max-height: none;
  }
  
  .ap-tutorial-modal--landscape .ap-tutorial-modal__video-wrapper {
    padding-top: 56.25%;
    height: auto;
    aspect-ratio: 16 / 9;
  }
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .ap-tutorial-modal {
    padding: 8px;
  }
  
  .ap-tutorial-modal__content {
    max-width: 100%;
    max-height: calc(100vh - 40px);
    border-radius: 12px;
  }
  
  .ap-tutorial-modal__close {
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
  }
}

/* Larger screens: limit height to prevent overly tall modal */
@media (min-width: 768px) {
  .ap-tutorial-modal__content {
    max-height: min(85vh, 750px);
  }
  
  .ap-tutorial-modal__video-wrapper {
    /* Ensure video fits within max-height */
    padding-top: 0;
    height: 100%;
    aspect-ratio: 9 / 16;
  }
}

/* =====================================================
   INTEGRATION WITH EXISTING WEBFLOW MODALS
   ===================================================== */

/* Ensure our modal works alongside Webflow's how-modal */
.how-modal.ap-portrait-modal {
  display: none;
  place-items: center;
}

.how-modal.ap-portrait-modal[style*="display: flex"],
.how-modal.ap-portrait-modal.is-open {
  display: flex !important;
}

.how-modal.ap-portrait-modal .how_content {
  width: 100%;
  max-width: 400px;
  padding: 0;
  background: transparent;
}

.how-modal.ap-portrait-modal .w-embed.w-iframe {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

/* Portrait aspect ratio for Webflow embedded iframes */
.how-modal.ap-portrait-modal .w-embed.w-iframe > div {
  position: relative;
  padding-top: 177.78% !important; /* 9:16 portrait */
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}

.how-modal.ap-portrait-modal .w-embed.w-iframe > div > iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 12px;
}

