/* ============================================================
   mobile.css — responsive overrides for Anxiety + Science pages.
   The pages are built with React components that use INLINE styles
   tuned for desktop (huge headlines, multi-column grids, 120px
   section padding, 48px gutters). This file overrides those at
   ≤900px so the pages read correctly on phones and tablets.
   We rely on !important because inline styles outrank stylesheet
   rules; that's the trade-off for not rewriting every component.
   ============================================================ */

/* ---------- Studies row collapse: hide body column on mobile so
              the right-side body cell doesn't add empty space.
              The same body is rendered inline beneath the toggle. */
@media (max-width: 900px) {
  .science-study-body-desktop { display: none !important; }
}
@media (min-width: 901px) {
  /* Desktop: body lives in the right column; the inline mobile copy is hidden */
  .science-study-body-mobile { display: none !important; }
  /* On desktop the body should always be visible regardless of toggle —
     but per spec the toggle is for shortening pages on mobile. Keep
     desktop showing body whenever rendered. We accomplish this by
     only collapsing on mobile via the body-mobile rule above. */
}

/* ---------- TABLET BREAKPOINT (≤ 900px) ---------- */
@media (max-width: 900px) {
  /* Sections — tame the giant 120/112px vertical padding and
     48px horizontal gutters down to something humane. */
  section[data-screen-label],
  footer[data-screen-label] {
    padding-left: 22px !important;
    padding-right: 22px !important;
    padding-top: 64px !important;
    padding-bottom: 64px !important;
  }

  /* Hero gets less vertical space — user feedback: hero looks
     too thin on mobile because of excess top/bottom padding. */
  section[data-screen-label="Science · Hero"] {
    padding-top: 28px !important;
    padding-bottom: 0 !important;
  }
  section[data-screen-label="Science · Hero"] > div:first-child {
    padding-top: 28px !important;
    padding-bottom: 36px !important;
    padding-left: 18px !important;
    padding-right: 18px !important;
  }
  section[data-screen-label="Anxiety · Hero"] {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* Anxiety Hero — keep the original full-bleed dark stage but
     pull padding way down. */
  section[data-screen-label="Anxiety · Hero"] [style*="padding: 96px 48px 110px"] {
    padding: 56px 22px 56px !important;
  }

  /* Constrain inner wrappers so they don't have their own 48px gutter
     stacked on top of the section's 22px gutter. */
  section[data-screen-label] > div[style*="padding: 80px 48px 120px"],
  section[data-screen-label] > div[style*="padding: 80px 48px"] {
    padding: 0 !important;
  }
  /* Inner content wrappers: kill horizontal padding so the section's
     22px is the single source of truth — fixes the "modules feel
     extra-thin" issue on the Anxiety Protocol section. */
  section[data-screen-label] > div > div[style*="padding: 0 48px"],
  section[data-screen-label] > div[style*="padding: 0 48px"],
  section[data-screen-label] > div[style*="padding: 0 48px 120px"] {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* Nav — smaller horizontal padding so the logo + CTA fit. */
  header[data-screen-label] {
    padding: 12px 16px !important;
    gap: 12px !important;
  }

  /* Collapse every two/three/four/five-column inner grid to one
     column. The pages use direct child grids of <section>. */
  section[data-screen-label] > div > div[style*="grid-template-columns"]:not(.credential-logos):not(.science-cta-grid),
  section[data-screen-label] > div > div > div[style*="grid-template-columns"]:not(.credential-logos):not(.science-cta-grid),
  section[data-screen-label] > div[style*="grid-template-columns"]:not(.credential-logos):not(.science-cta-grid) {
    grid-template-columns: 1fr !important;
    gap: 32px !important;
  }

  /* Top-level wrapper grids inside sections (the ones that hold
     a left text column + right image, etc). */
  section[data-screen-label] [style*="grid-template-columns: 1.05fr"],
  section[data-screen-label] [style*="grid-template-columns: 1fr 0.55fr"],
  section[data-screen-label] [style*="grid-template-columns: 1fr 1fr"],
  section[data-screen-label] [style*="grid-template-columns: 0.55fr 1fr"],
  section[data-screen-label] [style*="grid-template-columns: 0.6fr 1fr"],
  section[data-screen-label] [style*="grid-template-columns: 0.9fr 1.1fr"],
  section[data-screen-label] [style*="grid-template-columns: 200px 1fr"],
  section[data-screen-label] [style*="grid-template-columns: 220px 1fr"],
  section[data-screen-label] [style*="grid-template-columns: 120px 1fr 0.7fr"],
  section[data-screen-label] [style*="grid-template-columns: repeat(3"]:not(.credential-logos):not(.science-cta-grid),
  section[data-screen-label] [style*="grid-template-columns: repeat(4"]:not(.credential-logos):not(.science-cta-grid),
  section[data-screen-label] [style*="grid-template-columns: repeat(5"]:not(.credential-logos):not(.science-cta-grid) {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
  }

  /* Footer — same column-collapse treatment. */
  footer[data-screen-label] [style*="grid-template-columns: 1.4fr 1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 28px !important;
  }
  footer[data-screen-label] [style*="grid-template-columns: 1.4fr 1fr 1fr 1fr"] > div:first-child {
    grid-column: 1 / -1;
  }
  footer[data-screen-label] [style*="justify-content: space-between"][style*="display: flex"] {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start !important;
  }

  /* HEADINGS — drop the giant display sizes. */
  section[data-screen-label] h1 { font-size: 44px !important; line-height: 1.0 !important; }
  section[data-screen-label] h2 { font-size: 36px !important; line-height: 1.05 !important; }
  section[data-screen-label] h3 { font-size: 22px !important; line-height: 1.2 !important; }

  /* "No doctor's office" — the inline span has whiteSpace:nowrap
     which forces horizontal overflow on phones. Force wrap. */
  section[data-screen-label="Anxiety · No meds"] h2 span {
    white-space: normal !important;
  }

  /* Massive numeric stat displays (e.g. ½, 20%, 144px "52%") */
  section[data-screen-label] [style*="font-size: 180"],
  section[data-screen-label] [style*="font-size: 144"],
  section[data-screen-label] [style*="font-size: 88"],
  section[data-screen-label] [style*="font-size: 96"],
  section[data-screen-label] [style*="font-size: 84"],
  section[data-screen-label] [style*="font-size: 80"],
  section[data-screen-label] [style*="font-size: 72"] {
    font-size: 72px !important;
    line-height: 0.95 !important;
  }

  /* Body paragraphs that were sized 19-22px */
  section[data-screen-label] p[style*="font-size: 22"],
  section[data-screen-label] p[style*="font-size: 21"],
  section[data-screen-label] p[style*="font-size: 20"],
  section[data-screen-label] p[style*="font-size: 19"] {
    font-size: 17px !important;
    max-width: 100% !important;
  }

  /* Heroes get a touch more breathing room than other sections */
  section[data-screen-label="Anxiety · Hero"] > div:first-child {
    min-height: auto !important;
  }
  section[data-screen-label="Anxiety · Hero"] [style*="padding: 28px 48px"],
  section[data-screen-label="Science · Hero"] [style*="padding: 28px 48px"] {
    padding: 22px 18px !important;
  }
  /* Credential band: stacks label above the logo row on mobile.
     Uses class names so it beats the attribute-selector catch-all. */
  .credential-band-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
    padding: 18px 18px !important;
  }
  .credential-band-label {
    border-right: none !important;
    padding-right: 0 !important;
    padding-bottom: 0 !important;
  }
  /* Logos: 4-up (2 rows of 4) on mobile per user request. Chain
     with section selector so specificity beats the catch-all rules
     above, and add a defensive grid display in case anything inline
     would set otherwise. */
  section[data-screen-label] .credential-logos,
  div .credential-logos {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    column-gap: 12px !important;
    row-gap: 16px !important;
  }
  section[data-screen-label] .credential-logos img {
    height: 28px !important;
    max-height: 28px !important;
  }

  /* Science · CTA grid: 2x2x1 layout on mobile per user request. */
  section[data-screen-label] .science-cta-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }
  section[data-screen-label] .science-cta-grid > a:nth-child(5) {
    grid-column: 1 / -1 !important;
  }

  /* Anxiety hero headline: avoid the orphan "a" — let the line
     wrap naturally on mobile by hiding the desktop <br>s and
     restoring inline space. */
  .anxiety-hero-headline .hide-on-mobile { display: none !important; }
  .anxiety-hero-headline .hide-on-mobile-inline { display: inline !important; }
  .anxiety-hero-headline {
    font-size: 44px !important;
    line-height: 1.05 !important;
  }

  /* Anxiety hero — remove the white frame around the dark stage
     by killing the section's padding entirely. The dark stage
     itself keeps its inner padding. */
  section[data-screen-label="Anxiety · Hero"] {
    padding: 0 !important;
  }

  /* The 14-day banner inside Anxiety Protocol — stack the
     headline + "Three modules" eyebrow vertically. */
  section[data-screen-label="Anxiety · 14-day protocol"] [style*="height: 72px"] {
    height: auto !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
    padding-top: 18px !important;
    padding-bottom: 18px !important;
  }
  section[data-screen-label="Anxiety · 14-day protocol"] h2 {
    font-size: 22px !important;
  }
  /* The blue banner in 14-day protocol has its own 48px h-padding;
     reduce so it matches the section's 22px gutter. */
  section[data-screen-label="Anxiety · 14-day protocol"] > div[style*="padding: 0 48px"] {
    padding-left: 22px !important;
    padding-right: 22px !important;
  }

  /* Drop the chunky offset shadows on cards on small screens */
  section[data-screen-label] [style*="box-shadow: 12px 12px 0"] {
    box-shadow: 6px 6px 0 0 rgba(0,0,0,0.18) !important;
  }
  section[data-screen-label] [style*="box-shadow: 8px 8px 0"] {
    box-shadow: 4px 4px 0 0 rgba(0,0,0,0.14) !important;
  }

  /* Mech-row: the 3-up illustrated mechanism cards have left/right
     borders that look weird when stacked. Reset them and add
     vertical separators instead. */
  section[data-screen-label="Anxiety · Mechanisms"] [style*="border-right: 1px solid"][style*="padding: 36px"],
  section[data-screen-label="Science · Mechanisms"] [style*="border-right: 1px solid"][style*="padding: 36px"] {
    border-right: none !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    padding-bottom: 28px !important;
    border-bottom: 1px solid rgba(0,0,0,0.18);
  }

  /* Studies sequence (Science page) — the "120px 1fr 0.7fr"
     grid: stack number above title above body */
  section[data-screen-label="Science · Studies sequence"] [style*="grid-template-columns: 120px 1fr 0.7fr"] {
    padding: 28px 0 !important;
    gap: 16px !important;
  }
  section[data-screen-label="Science · Studies sequence"] [style*="font-size: 64"] {
    font-size: 48px !important;
  }

  /* Buttons / CTAs — keep within viewport, allow wrap */
  section[data-screen-label] a[style*="border-radius: 999"] {
    font-size: 14px !important;
  }

  /* The orange VIP CTA — let the form sit full-width below */
  section[data-screen-label="Anxiety · VIP CTA"] form input,
  section[data-screen-label="Anxiety · VIP CTA"] form button {
    width: 100% !important;
  }

  /* Other-protocols 4-up grid → 2-up */
  section[data-screen-label="Anxiety · Other protocols"] [style*="grid-template-columns: repeat(4, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 14px !important;
  }

  /* Conditions cards (Science) — 5-up → 1-up, but keep shorter */
  section[data-screen-label="Science · Evidence by condition"] [style*="min-height: 360"] {
    min-height: auto !important;
  }

  /* Science · CTA grid 5-up → 2x2x1 layout per user request */
  section[data-screen-label="Science · CTA"] [style*="grid-template-columns: repeat(5, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }
  /* The 5th card spans both columns, centered, to make the bottom row */
  section[data-screen-label="Science · CTA"] [style*="grid-template-columns: repeat(5, 1fr)"] > a:nth-child(5) {
    grid-column: 1 / -1;
  }

  /* Don't let any image overflow */
  section img, footer img { max-width: 100%; }

  /* Defensive: prevent horizontal page scroll. */
  html, body { overflow-x: hidden; }
}

/* ---------- PHONE BREAKPOINT (≤ 560px) ---------- */
@media (max-width: 560px) {
  /* Hide the desktop nav links on phones — keep just the logo +
     primary CTA. The dropdown is hover-only so it's unusable on
     touch anyway. */
  header[data-screen-label] > nav {
    display: none !important;
  }
  header[data-screen-label] {
    padding: 10px 14px !important;
    gap: 8px !important;
  }
  header[data-screen-label] a[href*="assessment-flow"] {
    padding: 9px 14px !important;
    font-size: 13px !important;
  }

  /* Even tighter section padding */
  section[data-screen-label],
  footer[data-screen-label] {
    padding-left: 18px !important;
    padding-right: 18px !important;
    padding-top: 52px !important;
    padding-bottom: 52px !important;
  }

  /* Headlines smaller still */
  section[data-screen-label] h1 { font-size: 36px !important; }
  section[data-screen-label] h2 { font-size: 30px !important; }
  section[data-screen-label] h3 { font-size: 20px !important; }

  /* "No meds. No huge bills. No doctor's office." headline:
     30px is still risky with the long nowrap span. Force smaller. */
  section[data-screen-label="Anxiety · No meds"] h2 {
    font-size: 28px !important;
    word-break: break-word;
  }

  /* Big stat numbers cap a bit smaller */
  section[data-screen-label] [style*="font-size: 180"],
  section[data-screen-label] [style*="font-size: 144"],
  section[data-screen-label] [style*="font-size: 96"],
  section[data-screen-label] [style*="font-size: 88"],
  section[data-screen-label] [style*="font-size: 84"],
  section[data-screen-label] [style*="font-size: 80"],
  section[data-screen-label] [style*="font-size: 72"] {
    font-size: 56px !important;
  }

  /* Conditions — 5 cards: switch to 1-up on phones (text is too
     small at 2-up for the stat + body to read) */
  section[data-screen-label="Science · Evidence by condition"] [style*="grid-template-columns: repeat(5, 1fr)"]:not(.science-cta-grid) {
    grid-template-columns: 1fr !important;
  }

  /* Science · CTA stays 2x2x1 even on phone (per user request) */
  /* — already set above at ≤900px and persists */

  /* Other protocols 4-up → 1-up so cards aren't tiny */
  section[data-screen-label="Anxiety · Other protocols"] [style*="grid-template-columns: repeat(4, 1fr)"] {
    grid-template-columns: 1fr !important;
  }

  /* Logo grid stays 4-up but tighter so wordmarks fit */
  section[data-screen-label] .credential-logos {
    column-gap: 8px !important;
    row-gap: 12px !important;
  }
  section[data-screen-label] .credential-logos img {
    height: 22px !important;
    max-height: 22px !important;
  }
  /* Phone: kill section gutters around hero entirely */
  section[data-screen-label="Anxiety · Hero"] {
    padding: 0 !important;
  }

  /* Footer columns: 2 → 1 */
  footer[data-screen-label] [style*="grid-template-columns: 1.4fr 1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* CTA pills: full width buttons feel better on phones */
  section[data-screen-label="Anxiety · Hero"] a[href*="assessment-flow"],
  section[data-screen-label="Anxiety · Hero"] a[href="#science"] {
    width: 100%;
    text-align: center;
  }
}
