/* TribeTruth — mobile CSS.
   Strategy: aggressive universal selectors first (these can't miss),
   then targeted overrides for specific layout problems. !important
   throughout because React components are styled inline. */

/* ============================================================
   ANY VIEWPORT — defensive defaults
   ============================================================ */
html, body { max-width: 100vw; overflow-x: hidden; }

/* ============================================================
   ≤ 900px — TABLET + PHONE
   ============================================================ */
@media (max-width: 900px) {
  /* Bulletproof overflow guard */
  html, body { overflow-x: hidden !important; }
  * { box-sizing: border-box !important; min-width: 0 !important; }
  body * { max-width: 100% !important; }
  img, video, svg { max-width: 100% !important; height: auto; }

  /* Wrap all text */
  h1, h2, h3, h4, h5, h6, p, span, div, button, a, li, blockquote {
    overflow-wrap: anywhere !important;
    word-wrap: break-word !important;
    hyphens: auto;
  }

  /* Sections — predictable horizontal padding */
  section { padding-left: 18px !important; padding-right: 18px !important; }

  /* Inner containers — fill width */
  div[style*="maxWidth: 1"] { max-width: 100% !important; }
  div[style*="maxWidth: 9"] { max-width: 100% !important; }
  div[style*="maxWidth: 8"] { max-width: 100% !important; }
  div[style*="maxWidth: 7"] { max-width: 100% !important; }
  div[style*="maxWidth: 6"] { max-width: 100% !important; }
  div[style*="maxWidth: 5"] { max-width: 100% !important; }

  /* Multi-col grids collapse */
  div[style*="repeat(6, 1fr)"],
  div[style*="repeat(5, 1fr)"],
  div[style*="repeat(4, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }
  div[style*="repeat(3, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }
  div[style*="repeat(2, 1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  /* Any non-repeat grid → stack */
  div[style*="gridTemplateColumns"]:not([style*="repeat("]) {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
  /* Sticky player exception */
  div.tt-player-grid {
    grid-template-columns: auto 1fr auto !important;
    gap: 10px !important;
  }

  /* Typography — fluid clamp values */
  [style*="fontSize: 124"], [style*="fontSize: 116"],
  [style*="fontSize: 108"], [style*="fontSize: 100"],
  [style*="fontSize: 96"],  [style*="fontSize: 88"],
  [style*="fontSize: 84"],  [style*="fontSize: 80"],
  [style*="fontSize: 76"],  [style*="fontSize: 72"] {
    font-size: clamp(26px, 7.5vw, 40px) !important;
    line-height: 1.05 !important;
    letter-spacing: 0.01em !important;
  }
  [style*="fontSize: 64"], [style*="fontSize: 56"],
  [style*="fontSize: 52"], [style*="fontSize: 48"],
  [style*="fontSize: 44"] {
    font-size: clamp(20px, 5.5vw, 28px) !important;
    line-height: 1.15 !important;
  }
  [style*="fontSize: 40"], [style*="fontSize: 36"],
  [style*="fontSize: 32"] {
    font-size: clamp(17px, 4.5vw, 22px) !important;
    line-height: 1.25 !important;
  }
  [style*="fontSize: 28"], [style*="fontSize: 26"],
  [style*="fontSize: 24"], [style*="fontSize: 22"] {
    font-size: clamp(14px, 4vw, 17px) !important;
    line-height: 1.5 !important;
  }
  [style*="fontSize: 20"], [style*="fontSize: 19"], [style*="fontSize: 18"] {
    font-size: 15px !important; line-height: 1.55 !important;
  }

  /* Card paddings — collapse */
  div[style*='padding: "120px'],
  div[style*='padding: "100px'],
  div[style*='padding: "80px'],
  div[style*='padding: "72px'],
  div[style*='padding: "60px'],
  div[style*='padding: "56px'],
  div[style*='padding: "48px'],
  div[style*='padding: "44px'],
  div[style*='padding: "40px'],
  div[style*='padding: "36px'] {
    padding: 22px 16px !important;
  }
  div[style*="padding: 56"],
  div[style*="padding: 48"],
  div[style*="padding: 44"],
  div[style*="padding: 40"],
  div[style*="padding: 36"] {
    padding: 22px !important;
  }

  /* Explicit-width images */
  img[style*="width: 4"], img[style*="width: 3"],
  img[style*="width: 280"], img[style*="width: 260"],
  img[style*="width: 240"], img[style*="width: 200"],
  img[style*="width: 180"], img[style*="width: 170"],
  img[style*="width: 160"], img[style*="width: 140"] {
    width: clamp(120px, 55vw, 240px) !important;
    height: auto !important;
  }

  /* Logos */
  img[alt="The Shadow of God"], img[alt="TribeTruth"] {
    width: clamp(110px, 55vw, 220px) !important;
    height: auto !important;
  }

  /* Section min-heights */
  section[style*="minHeight: 1"],
  section[style*="minHeight: 9"], section[style*="minHeight: 8"],
  section[style*="minHeight: 7"], section[style*="minHeight: 6"],
  section[style*="minHeight: 5"], section[style*="minHeight: 4"] {
    min-height: auto !important;
  }

  /* Home hero — let it grow with content */
  .tt-hero-home { min-height: auto !important; padding: 0 !important; }
  .tt-hero-video { object-position: center 30% !important; }

  /* Section vertical padding */
  section {
    padding-top: 48px !important;
    padding-bottom: 48px !important;
  }

  /* Buttons — keep tappable but not huge */
  button[style*='padding: "20px'],
  button[style*='padding: "18px'],
  button[style*='padding: "16px'],
  a[style*='padding: "20px'],
  a[style*='padding: "18px'],
  a[style*='padding: "16px'] {
    padding: 12px 18px !important;
    font-size: 11px !important;
  }

  /* Flex rows with gap → stack on phones */
  div[style*='display: "flex"'][style*="gap: 36"],
  div[style*='display: "flex"'][style*="gap: 48"],
  div[style*='display: "flex"'][style*="gap: 56"],
  div[style*='display: "flex"'][style*="gap: 64"] {
    flex-direction: column !important;
    gap: 18px !important;
  }

  /* Position: sticky elements with top values for desktop need reset */
  div[style*="position: \"sticky\""][style*="top: 100"],
  div[style*="position: \"sticky\""][style*="top: 110"],
  div[style*="position: \"sticky\""][style*="top: 120"],
  div[style*="position: \"sticky\""][style*="top: 140"] {
    position: relative !important;
    top: auto !important;
  }
}

/* ============================================================
   ≤ 640px — PHONE — further compress, 1 col where useful
   ============================================================ */
@media (max-width: 640px) {
  section { padding-left: 14px !important; padding-right: 14px !important; padding-top: 40px !important; padding-bottom: 40px !important; }
  /* Video grids stay at 2 cols, all others collapse to 1 */
  div[style*="repeat(6, 1fr)"],
  div[style*="repeat(5, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  div[style*="repeat(4, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  div[style*="repeat(3, 1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }
  /* Card padding minimum */
  div[style*='padding: "120px'],
  div[style*='padding: "100px'],
  div[style*='padding: "80px'],
  div[style*='padding: "72px'],
  div[style*='padding: "60px'],
  div[style*='padding: "56px'],
  div[style*='padding: "48px'],
  div[style*='padding: "44px'],
  div[style*='padding: "40px'],
  div[style*='padding: "36px'] {
    padding: 18px 14px !important;
  }
  /* Even tighter typography */
  [style*="fontSize: 124"], [style*="fontSize: 116"],
  [style*="fontSize: 108"], [style*="fontSize: 100"],
  [style*="fontSize: 96"],  [style*="fontSize: 88"],
  [style*="fontSize: 84"],  [style*="fontSize: 80"],
  [style*="fontSize: 76"],  [style*="fontSize: 72"] {
    font-size: clamp(24px, 8vw, 32px) !important;
  }
}
