/* ============================================================
   Mobile Shim — preserves the original cinematic scroll-scrub
   on mobile, fixes ONLY: viewport math, touch targets, grid
   widths, typography sizing. The 121-frame canvas + sticky
   hero + multi-phase text overlay all stay intact.
   ============================================================ */

/* ---------- Global horizontal-overflow lockdown ----------
   Applies on every viewport so the page can never slide L/R.
   `overflow-x: clip` is stronger than `hidden`: it doesn't create
   a new scroll container and works even with `position: sticky`
   inside the body. */
html, body {
  overflow-x: clip !important;
  max-width: 100%;
  width: 100%;
}

@media (max-width: 820px), (hover: none) and (pointer: coarse) {

  /* Defensive: nothing on mobile may exceed viewport width.
     Targets the usual culprits — transformed/marquee elements,
     wide tables, and oversized inline videos. */
  body, main, section, .container,
  .marquee-section, .partner-strip,
  .nav, footer, .hero, .cinematic-mid {
    max-width: 100vw;
    overflow-x: clip;
  }

  /* ---------- Touch responsiveness ---------- */
  a, button, summary, .niche-card, .problem-card, .spot-card,
  .stat-card, .agent, .tier, .trust-item, .mid-cta-btn,
  .nav-cta, .nav-phone, .cta-btn, .tier-cta,
  .rail-dot, details {
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(230, 57, 70, 0.15);
  }

  /* ---------- Viewport math: 100vh → 100dvh ----------
     Fixes iOS Safari URL-bar overflow without changing
     the sticky scroll-scrub behavior. */
  .hero-sticky,
  .cinematic-mid-sticky,
  .cinematic-stage {
    height: 100dvh !important;
  }

  /* ---------- Cinematic backdrop for width-fit canvas ----------
     With width-fit scaling, the cinematic frame goes edge-to-edge
     horizontally; vertical empty space (if any) sits over a soft
     cinematic vignette so the frame around the video feels intentional. */
  .hero-sticky,
  .cinematic-mid-sticky {
    background:
      radial-gradient(ellipse 90% 60% at 50% 50%, rgba(230,57,70,0.05), transparent 70%),
      linear-gradient(180deg, #050505 0%, #0a0a0c 50%, #050505 100%) !important;
  }
  #heroCanvas,
  #midCanvas {
    background: transparent !important;
  }

  /* ---------- Hero text readability scrim ----------
     A soft radial darken behind each active hero-phase block.
     This kills the "white text on bright frame area" problem
     without adding a hard-edged box. */
  .hero-phase {
    position: relative;
  }
  .hero-phase::before {
    content: '';
    position: absolute;
    inset: -28px -32px;
    background: radial-gradient(ellipse at center,
      rgba(0,0,0,0.78) 0%,
      rgba(0,0,0,0.55) 35%,
      rgba(0,0,0,0.25) 65%,
      transparent 90%);
    filter: blur(8px);
    z-index: -1;
    pointer-events: none;
    border-radius: 24px;
  }
  .hero-phase h1,
  .hero-content h1 {
    text-shadow:
      0 2px 8px rgba(0,0,0,0.95),
      0 4px 24px rgba(0,0,0,0.85),
      0 0 60px rgba(0,0,0,0.6) !important;
  }
  .hero-phase p,
  .hero-content .subtitle {
    text-shadow:
      0 2px 6px rgba(0,0,0,0.9),
      0 1px 3px rgba(0,0,0,0.95) !important;
    color: #f5f5f5 !important;
  }
  .hero-phase .ph-time {
    background: rgba(0,0,0,0.7) !important;
    backdrop-filter: blur(10px);
  }

  /* ---------- Hero text sizing on small screens ----------
     Phase titles + body shrink + read as the camera dollies. */
  .hero-phase h1,
  .hero-content h1,
  .phase-title h1 {
    font-size: clamp(28px, 8.5vw, 44px) !important;
    line-height: 1.06 !important;
    letter-spacing: -1px;
  }
  .hero-phase p,
  .hero-content .subtitle,
  .phase-title p {
    font-size: 15px !important;
    line-height: 1.55 !important;
    max-width: 92vw !important;
  }
  .hero-phase .ph-time,
  .hero-phase .eyebrow,
  .phase-title .ph-time {
    font-size: 10.5px !important;
    margin-bottom: 14px !important;
  }
  .hero-phase .cta-row,
  .hero-content .cta-row {
    margin-top: 22px !important;
    flex-direction: column !important;
    gap: 10px !important;
    align-items: stretch !important;
    width: 88vw;
    max-width: 360px;
  }
  .hero-phase .cta,
  .hero-content .cta {
    width: 100% !important;
    text-align: center;
  }

  /* ---------- Mid-section text sizing ---------- */
  .cinematic-mid-copy h2 {
    font-size: clamp(26px, 7.5vw, 42px) !important;
    line-height: 1.06 !important;
  }
  .cinematic-mid-copy p {
    font-size: 15px !important;
    line-height: 1.55 !important;
    max-width: 92vw !important;
  }
  .cinematic-mid-copy .mid-label {
    font-size: 10.5px !important;
  }

  /* ---------- Nav: collapse links, keep CTA + phone ---------- */
  nav.top {
    padding: 0 !important;
  }
  nav.top .row {
    padding: 12px 16px !important;
    gap: 8px;
  }
  nav.top .links {
    display: none !important;
  }
  .nav-right {
    gap: 6px !important;
  }
  .nav-cta {
    padding: 10px 16px !important;
    font-size: 13px !important;
    min-height: 44px;
    display: inline-flex !important;
    align-items: center;
  }
  .nav-phone {
    padding: 10px !important;
    min-height: 44px;
    min-width: 44px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }
  .nav-phone .ph-num {
    display: none;
  }

  /* ---------- CTA buttons: full-width, min touch height ---------- */
  .cta-btn,
  .mid-cta-btn,
  .tier-cta,
  .btn-primary,
  .btn-ghost {
    min-height: 48px !important;
    width: 100% !important;
    box-sizing: border-box;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }

  /* Mid-CTA card: vertical stack */
  .mid-cta-card {
    flex-direction: column !important;
    align-items: stretch !important;
    text-align: left;
    padding: 24px 22px !important;
    gap: 16px !important;
  }
  .mid-cta-card h3 {
    font-size: 18px !important;
  }

  /* ---------- Grids: collapse to 1-col ---------- */
  .niche-grid,
  .industries-grid,
  .agents,
  .pricing,
  .problems-grid,
  .snapshot-grid,
  .trust-strip,
  .proof-grid {
    grid-template-columns: 1fr !important;
  }
  .funnel-strip,
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Day-in-the-life: stack timestamp + content */
  .day-row {
    grid-template-columns: 1fr !important;
    gap: 6px !important;
    padding: 22px 0 !important;
  }
  .day-row .day-when,
  .day-row .when {
    font-size: 11.5px;
    letter-spacing: 0.04em;
  }

  /* ---------- Section spacing tighten ---------- */
  section {
    padding: 80px 20px !important;
  }
  section.compact {
    padding: 60px 20px !important;
  }
  .container {
    padding: 0 20px !important;
  }

  /* Section heads: stack columns, smaller titles */
  .section-head {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
    margin-bottom: 36px !important;
  }
  .section-title,
  .section-head h2,
  h2 {
    font-size: clamp(28px, 7vw, 38px) !important;
    line-height: 1.05 !important;
  }
  .section-desc,
  .section-head p {
    font-size: 14.5px !important;
    line-height: 1.6 !important;
  }

  /* ---------- Niche card sizing ---------- */
  .niche-card {
    min-height: 180px !important;
    padding: 24px 22px 20px !important;
  }
  .niche-card .glyph {
    width: 40px;
    height: 40px;
    margin-bottom: 16px;
  }
  .niche-card h3 {
    font-size: 18px !important;
  }
  .niche-card .hook {
    font-size: 14px !important;
  }

  /* ---------- Explainer card ---------- */
  .explainer-card video {
    aspect-ratio: 16/9;
  }
  .explainer-meta {
    padding: 16px 18px !important;
  }
  .explainer-meta .meta-text h3 {
    font-size: 14px !important;
    line-height: 1.3;
  }
  .podcast-toggle {
    padding: 16px 18px 20px !important;
  }

  /* ---------- Comparison table: horizontal scroll ---------- */
  .compare-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .compare-table table {
    min-width: 580px;
    font-size: 12.5px !important;
  }
  .compare-table th, .compare-table td {
    padding: 12px 14px !important;
  }

  /* ---------- Territory chips ---------- */
  .territory-zones {
    gap: 8px !important;
  }
  .zone-chip {
    font-size: 11.5px !important;
    padding: 8px 14px !important;
  }

  /* ---------- FAQ ---------- */
  .faq-item summary {
    padding: 18px 20px !important;
    font-size: 15px !important;
  }
  .faq-item .faq-body {
    padding: 0 20px 20px !important;
    font-size: 14px !important;
  }

  /* ---------- Partnership credibility strip ---------- */
  .partner-strip-inner {
    flex-direction: column !important;
    gap: 12px !important;
    padding: 16px 22px !important;
    border-radius: 18px !important;
  }
  .partner-strip .partner-divider {
    display: none !important;
  }
  .partner-strip .partner-logos {
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px !important;
  }

  /* ---------- Scramble + marquee ---------- */
  .scramble-section {
    padding: 60px 20px !important;
  }
  .scramble-text {
    font-size: clamp(22px, 6vw, 36px) !important;
  }
  .marquee-section {
    padding: 24px 0 !important;
  }
  .marquee-item {
    font-size: 12px !important;
  }

  /* ---------- Scroll progress dot rail: hide on small screens ---------- */
  .scroll-rail {
    display: none !important;
  }

  /* ---------- Footer ---------- */
  footer {
    padding: 32px 20px 48px !important;
  }
  footer .row {
    flex-direction: column !important;
    gap: 10px !important;
    text-align: center;
  }

  /* ---------- Disable cursor-glow on touch ----------
     The rAF loop runs unnecessarily on touch devices. */
  #glow {
    display: none !important;
  }
}

/* ============================================================
   Very small phones (≤380px)
   ============================================================ */
@media (max-width: 380px) {
  .hero-phase h1,
  .hero-content h1 {
    font-size: 26px !important;
  }
  .section-title,
  .section-head h2,
  h2 {
    font-size: 24px !important;
  }
  .cinematic-mid-copy h2 {
    font-size: 24px !important;
  }
  section {
    padding: 60px 16px !important;
  }
  .container {
    padding: 0 16px !important;
  }
}
