/*
  Responsive overrides for mobile and tablet only.
  Contract:
  - Must not change desktop (≥ 1025px). All rules live under max-width queries.
  - Respect existing Tailwind classes and inline <style> blocks by scoping carefully.
  - Fix overflow, stacking, tap sizes, and readable typography.
*/

/* Base safe defaults (applies to all) */
img,
video {
  max-width: 100%;
  height: auto;
}
iframe {
  max-width: 100%;
}

/* Small phones: ≤ 640px */
@media (max-width: 640px) {
  /* Overlay text above embedded video */
  .overlay-text {
    padding: 0.75rem 0.875rem !important;
    border-radius: 1rem !important;
  }
  .overlay-text .overlay-top {
    font-size: 1rem !important;
    margin-bottom: 0.35rem !important;
  }
  .overlay-text .overlay-middle {
    font-size: clamp(2rem, 12vw, 2.75rem) !important;
    letter-spacing: -1px !important;
    line-height: 1.05 !important;
    margin-bottom: 0.35rem !important;
    font-weight: 800 !important;
  }
  .overlay-text .overlay-bottom {
    font-size: 1rem !important;
  }

  /* Sticky enroll bar: ensure no overlap and keep button at right */
  #sticky-enroll {
    width: calc(100vw - 1rem) !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    bottom: 0.75rem !important;
  }
  #sticky-enroll .sticky-bar {
    position: relative !important;
    padding-right: 0.5rem !important;
    padding-left: 0.75rem !important;
  }
  #sticky-enroll .sticky-enroll-btn {
    position: absolute !important;
    right: 0 !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    padding: 0.625rem 0.875rem !important;
  }
  #sticky-enroll span {
    max-width: 58% !important;
    font-size: 0.95rem !important;
  }
  /* Containers and paddings */
  .container {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  /* Navigation: allow wrapping and spacing */
  nav .container > div {
    gap: 0.75rem;
  }
  nav img[alt='BeOutlier Logo'] {
    max-width: 150px !important;
    height: auto;
  }

  /* Generic grid to single-column when explicitly 2/3 cols via Tailwind at lg */
  .grid {
    row-gap: 1rem;
  }

  /* Hero adjustments in course.html */
  section .max-w-7xl.mx-auto > .grid {
    grid-template-columns: 1fr !important;
  }
  .video-container {
    border-radius: 1rem;
  }

  /* Headings scale down subtly to prevent wrapping overflow */
  h1 {
    font-size: clamp(1.75rem, 7vw, 2.25rem) !important;
    line-height: 1.2;
  }
  h2 {
    font-size: clamp(1.375rem, 6vw, 1.875rem) !important;
    line-height: 1.25;
  }
  h3 {
    font-size: clamp(1.125rem, 5.2vw, 1.25rem) !important;
  }

  /* Badges and buttons spacing */
  .notification-badge {
    font-size: 0.75rem !important;
    padding: 0.25rem 0.5rem !important;
  }
  .btn-primary,
  .btn-secondary {
    padding: 0.625rem 1rem !important;
    border-radius: 0.875rem !important;
  }

  /* Social proof row wraps nicely */
  .flex.items-center.gap-2.sm\:gap-3 {
    flex-wrap: wrap;
  }

  /* Moving logos row height */
  .h-36 {
    height: 6.5rem !important;
  }
  .h-24.w-24,
  .w-24.h-24 {
    width: 4.5rem !important;
    height: 4.5rem !important;
  }

  /* Three-point list spacing in Struggle section */
  .grid.lg\:grid-cols-3 {
    grid-template-columns: 1fr !important;
  }

  /* Comparison cards spacing */
  .grid.lg\:grid-cols-2 {
    grid-template-columns: 1fr !important;
  }
  .p-8 {
    padding: 1.25rem !important;
  }

  /* Sessions stack and sticky tuning */
  .sessions-container {
    /* keep (and slightly increase) height so sticky stacking has scroll room */
    min-height: 120vh !important;
  }
  .session-card {
    /* restore sticky behavior for stacking animation - keep original offset */
    position: sticky !important;
    top: 100px !important; /* match desktop so JS calculations remain consistent */
    padding: 1.25rem !important; /* slightly tighter but OK */
    margin-bottom: 2rem !important; /* original space needed to create scroll distance */
  }
  .session-progress {
    /* keep visible but tighter on mobile */
    right: 0.5rem !important;
  }

  /* FAQ buttons wrap without overflow */
  .faq-button h3 {
    font-size: 1rem !important;
  }
  .faq-button {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  /* Testimonial video height */
  .h-96 {
    height: 14rem !important;
  }

  /* Index hero text sizing and emoji */
  #typewriter-text {
    font-size: clamp(1.75rem, 9vw, 2.5rem) !important;
  }
  #typewriter-emoji {
    font-size: clamp(2rem, 10vw, 2.75rem) !important;
    right: -0.75rem !important;
    top: -0.75rem !important;
  }

  /* Navigation chips in index */
  .nav-category-btn {
    padding: 0.5rem 0.625rem !important;
    font-size: 0.75rem !important;
    gap: 0.25rem !important;
  }
  .nav-category-btn .w-5 {
    display: none !important;
  }

  /* Program cards tighten */
  .program-card {
    padding: 1rem !important;
  }

  /* Generic utility to prevent horizontal scrollbars */
  body,
  html {
    overflow-x: hidden;
  }
}

/* Tablets: 641px–1024px */
@media (max-width: 1024px) and (min-width: 641px) {
  /* Reduce giant headings a touch */
  h1 {
    font-size: clamp(2.25rem, 4.5vw, 3rem) !important;
  }
  h2 {
    font-size: clamp(1.5rem, 3.6vw, 2.25rem) !important;
  }

  /* Two-column sections become 1fr at md when lg specified */
  .grid.lg\:grid-cols-2 {
    grid-template-columns: 1fr !important;
  }
  .grid.lg\:grid-cols-3 {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Sessions sticky less aggressive */
  .session-card {
    top: 60px;
  }
  .session-progress {
    right: 0.5rem;
  }

  /* Testimonial video comfortable height */
  .h-96 {
    height: 18rem !important;
  }
}

/* Very small devices: tighten gaps to avoid overflow */
@media (max-width: 360px) {
  .gap-4 {
    gap: 0.5rem !important;
  }
  .px-6 {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
}
