/* ═══════════════════════════════════════════════════════════════════════════════
   MOBILE QA FIXES — Task #1031238
   Comprehensive audit + fix for all marketing/landing pages at 375px, 390px, 428px.
   Loaded last in layout-head.ejs for maximum specificity.
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ────────────────────────────────────────────────────────────────────────────
   1. GLOBAL — PREVENT HORIZONTAL SCROLL (critical baseline)
   Any rogue fixed-width element would cause page-level horizontal scroll.
   overflow-x: clip preferred over hidden so scroll anchoring still works.
   ──────────────────────────────────────────────────────────────────────────── */

html {
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
  /* Ensure max content width never bleeds */
  max-width: 100vw;
}

/* ────────────────────────────────────────────────────────────────────────────
   2. TRUST BADGE ROW — rs-trust-bar (Homepage trust strip)
   On mobile, badges wrap. Remove border-right separators so wrapping badges
   don't get dangling right-borders. Use consistent padding instead.
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .rs-trust-bar {
    padding: 12px 1rem;
  }

  .rs-trust-bar-inner {
    gap: 0;
    justify-content: center;
  }

  .rs-trust-badge {
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
    width: 100%;
    justify-content: center;
    padding: 8px 12px;
    font-size: 0.82rem;
  }

  .rs-trust-badge:last-child {
    border-bottom: none;
  }

  .rs-trust-badge-icon {
    width: 24px;
    height: 24px;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   3. SEO CLASS ACTION LANDING PAGE — Countdown grid
   .ca-countdown-wrap uses repeat(4, 1fr) with no mobile breakpoint.
   At 375px, 4 columns = ~82px each which is too cramped for countdown numbers.
   Switch to 2×2 grid at 480px.
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  /* SEO landing body padding tighter on mobile */
  .ca-body {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  /* Section cards: reduce padding on mobile */
  .ca-section {
    padding: 1.25rem 1rem !important;
  }

  /* Countdown: switch to 2x2 grid */
  .ca-countdown-wrap {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }

  .ca-countdown-cell {
    padding: 12px 8px !important;
  }

  .ca-countdown-num {
    font-size: 1.6rem !important;
  }

  /* Related grid: single column */
  .ca-related-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   4. HM BANNER SECTION — CTA minimum height
   .hm-banner-cta padding gives ~43px height. Ensure proper 44px touch target.
   ──────────────────────────────────────────────────────────────────────────── */

.hm-banner-cta {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 600px) {
  .hm-banner-inner {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .hm-banner-text {
    min-width: 0;
  }

  .hm-banner-cta-wrap {
    align-items: stretch;
  }

  .hm-banner-cta {
    width: 100%;
    text-align: center;
    justify-content: center;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   5. NEWSLETTER / EMAIL CAPTURE FORMS — Proper input+button stacking
   Ensure email forms stack input above button on mobile.
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  /* HQ email section */
  .hq-email-form,
  .hq-form-row {
    flex-direction: column !important;
    gap: 8px !important;
  }

  .hq-email-input,
  .inline-cta-input {
    width: 100% !important;
    min-width: 0 !important;
  }

  .hq-email-btn,
  .inline-cta-btn {
    width: 100% !important;
    min-height: 48px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   6. HOW IT WORKS — Steps stack on mobile, connectors hidden
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  /* Old flex-based HIW layout */
  .hiw-steps {
    flex-direction: column !important;
    gap: 16px !important;
    align-items: stretch !important;
  }

  .hiw-step {
    max-width: 100% !important;
  }

  .hiw-connector {
    display: none !important;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   7. TESTIMONIALS / SOCIAL PROOF — Stack on mobile
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .trust-stats-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .trust-stat-divider {
    display: none;
  }

  /* Community wins stack */
  .community-wins-grid {
    grid-template-columns: 1fr !important;
  }

  /* Latest additions stack */
  .latest-additions-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   8. BRACKET PAGE — mobile improvements
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .bracket-round {
    min-width: 0 !important;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   9. PRICING PAGE — Ensure single-column at small screens
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .prc-grid {
    grid-template-columns: 1fr !important;
  }

  .prc-card {
    min-width: 0 !important;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   10. HOMEPAGE — Inline trust strip separator fix
   The inline trust strip in home.ejs (4 spans with border-right and flex-wrap)
   needs clean wrapping at 375px.
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  /* The sr-trust-strip container — inline in home.ejs */
  .sr-trust-strip {
    flex-wrap: wrap !important;
  }

  /* When trust items wrap on mobile, normalize their layout */
  .sr-trust-strip > span,
  .sr-trust-strip > a {
    border-right: none !important;
    width: 50% !important;
    justify-content: center !important;
    padding: 0.4rem 0.5rem !important;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   11. URGENCY STRIP — Overflow containment
   Already has overflow:hidden but inner items must not extend past boundary.
   ──────────────────────────────────────────────────────────────────────────── */

.urgency-strip,
.urgency-strip-inner {
  overflow: hidden !important;
  min-width: 0;
}

/* ────────────────────────────────────────────────────────────────────────────
   12. SECTION CONTAINERS — overflow protection
   Animated sections that use translateX transforms for marquees/tickers must
   have overflow:hidden to prevent horizontal bleed.
   ──────────────────────────────────────────────────────────────────────────── */

.payout-ticker-section,
.activity-feed-section,
.trust-bar-wrapper,
.rs-trust-bar {
  overflow: hidden;
}

/* ────────────────────────────────────────────────────────────────────────────
   13. B2B PAGES (for-law-firms, employers) — Hero CTA mobile improvements
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  /* Law firms page hero CTA */
  .pe-hero-ctas,
  .rs-hero-ctas-redesigned,
  .hero-cta-group {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  /* Ensure all hero CTAs are full-width on mobile */
  .pe-hero-cta,
  .rs-btn-primary-dominant,
  .f-hero-cta,
  .emp-hero-cta,
  [class*="-hero"] .btn,
  [class*="-hero"] a[class*="-cta"] {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 48px !important;
    text-align: center !important;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   14. FREE COURSE PAGE — Form stacking
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .fc-form-row,
  .course-form-row,
  .f-cta-form {
    flex-direction: column !important;
    gap: 8px !important;
  }

  .fc-input,
  .course-email-input {
    width: 100% !important;
    min-width: 0 !important;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   15. GUIDES HUB & TOOLS HUB — Grid layout
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .guides-grid,
  .tools-grid,
  .guide-cards,
  .tool-cards {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   16. ABOUT PAGE — Avatar + Story grid
   The .ab-avatar is 150px diameter, centered above text at ≤640px via existing
   CSS. This rule ensures it stays centered and has proper spacing.
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .ab-avatar,
  .ab-founder-avatar {
    display: block !important;
    margin: 0 auto 1.5rem !important;
  }

  .ab-story-grid,
  .about-founder-grid {
    grid-template-columns: 1fr !important;
    text-align: center !important;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   17. MAP PAGE — Rankings + Filters
   Map page already handles mobile well. Extra safety for filter scroll.
   ──────────────────────────────────────────────────────────────────────────── */

.map-filter-inner {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.map-filter-inner::-webkit-scrollbar {
  display: none;
}

/* ────────────────────────────────────────────────────────────────────────────
   18. STATS BAR (Homepage) — Prevent overflow at 375px
   .rs-stats-bar has inline mobile breakpoints. These reinforce it.
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 390px) {
  .rs-stats-bar {
    margin-left: 0.75rem !important;
    margin-right: 0.75rem !important;
    max-width: calc(100% - 1.5rem) !important;
  }

  .rs-stat {
    min-width: 0 !important;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   19. TRUST PROOF SECTION — Mobile tweaks at 375px
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .trust-badges-row {
    gap: 8px !important;
  }

  .trust-proof-pill {
    font-size: 0.75rem !important;
    padding: 4px 10px !important;
  }

  .trust-stat-num {
    font-size: 1.4rem !important;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   20. GENERAL CTA TOUCH TARGETS — All buttons ≥44px at mobile
   Complements css-polish.css. Ensures any CTA class not covered gets 44px.
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  /* Minimum tap targets */
  .hiw-cta-btn,
  .sotw-cta-btn,
  .fs-hero-cta,
  .lf-plan-cta,
  .emp-plan-cta,
  .fms-widget-btn,
  .hm-banner-cta,
  .cas-link,
  .sidebar-btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   21. HORIZONTAL SCROLL DEBUGGING — Extra insurance on section wrappers
   Ensures no section ever creates horizontal scrollbar.
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 430px) {
  /* Force all inner containers to stay in bounds */
  .rs-hero-redesigned,
  .rs-features-section,
  .hiw-section,
  .trust-proof-section,
  .community-wins-section,
  .rs-featured-section,
  .hm-banner-section,
  .bbc-section,
  .fms-widget-section,
  .sotd-section,
  .sotw-section,
  .recently-closed-section,
  .cas-explainer {
    overflow-x: hidden;
    max-width: 100%;
  }

  /* Prevent min-width from causing flex overflow */
  .fs-hero-left,
  .sotw-card-left,
  .hm-banner-text,
  .fms-widget-text,
  .lf-hero-text,
  .emp-hero-content {
    min-width: 0 !important;
    width: 100% !important;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   22. 375px — iPhone SE SPECIFIC
   Final cleanup for the smallest common viewport.
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 375px) {
  /* Ensure hero CTAs never overflow */
  .rs-btn-primary-dominant,
  .rs-btn-ghost-redesigned {
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
    white-space: normal !important;
  }

  /* Stats bar tighter on 375px SE */
  .rs-stat-number {
    font-size: 1.15rem !important;
  }

  /* Leaderboard cards: prevent rank number from pushing content */
  .sr-lb-rank {
    width: 28px !important;
    font-size: 1.1rem !important;
  }

  /* Trust pills wrap properly */
  .trust-proof-pill {
    white-space: normal !important;
    text-align: center !important;
  }

  /* SOTw/SOTd right column goes full width */
  .fs-hero-right,
  .sotw-card-right {
    width: 100% !important;
    min-width: 0 !important;
  }
}
