/* =============================================================================
   Flip 360 — Global responsive layer
   Loaded everywhere via src/renderer.tsx (which renders /, /for-mathew, /me,
   /chain, /faq, /demo, /solution, /business-case, /blueprint, /architecture,
   /engage and the sweetenerShell pages).
   ADMIN_LAYOUT (/app/*) inlines its own mobile rules — see src/routes/commission.tsx.
   ============================================================================= */

* { box-sizing: border-box; }

html, body {
  /* Stop sideways scrolling caused by oversize inline-styled blocks */
  max-width: 100%;
  overflow-x: hidden;
}

img, video {
  max-width: 100%;
  height: auto;
}

/* ────────────────────────────────────────────────────────────────────────────
   Tablet & below (≤ 900px)
   ──────────────────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  /* Any inline grid with the "auto-fit minmax(320px, 1fr)" pattern stacks
     to a single column earlier so phones don't show one painfully narrow card */
  section [style*="minmax(320px"],
  section [style*="minmax(300px"] {
    grid-template-columns: 1fr !important;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   Phones (≤ 768px) — the main mobile fix
   ──────────────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {

  /* ---- Typography: tame the giant headlines ------------------------------ */
  h1[style*="font-size: 3.5rem"],
  h1[style*="font-size:3.5rem"] {
    font-size: 2.1rem !important;
    line-height: 1.1 !important;
  }
  h2[style*="font-size: 2.5rem"],
  h2[style*="font-size:2.5rem"],
  h2[style*="font-size: 2.4rem"],
  h2[style*="font-size:2.4rem"],
  h2[style*="font-size: 2.25rem"],
  h2[style*="font-size:2.25rem"] {
    font-size: 1.6rem !important;
    line-height: 1.2 !important;
  }
  h2[style*="font-size: 1.85rem"],
  h2[style*="font-size:1.85rem"] {
    font-size: 1.35rem !important;
    line-height: 1.25 !important;
  }
  h3[style*="font-size: 1.5rem"],
  h3[style*="font-size:1.5rem"],
  h3[style*="font-size: 1.4rem"],
  h3[style*="font-size:1.4rem"] {
    font-size: 1.2rem !important;
  }

  /* ---- Reduce huge "The Numbers" digits on phones ------------------------ */
  div[style*="font-size: 2.5rem"][style*="Source Serif"] {
    font-size: 1.9rem !important;
  }

  /* ---- Section padding: claw back screen real estate --------------------- */
  section[style*="padding: 5rem 2rem"],
  section[style*="padding:5rem 2rem"] {
    padding: 2.5rem 1.1rem !important;
  }
  section[style*="padding: 4rem 2rem"],
  section[style*="padding:4rem 2rem"] {
    padding: 2.25rem 1.1rem !important;
  }
  section[style*="padding: 3rem 2rem"],
  section[style*="padding:3rem 2rem"] {
    padding: 2rem 1.1rem !important;
  }
  /* Cinematic opening / hero sub-sections */
  section[style*="padding: 2.5rem 2rem 3rem"] {
    padding: 1.5rem 1.1rem 2rem !important;
  }
  /* Footer */
  footer[style*="padding: 3rem 2rem"] {
    padding: 2rem 1.1rem !important;
  }

  /* ---- Walking metaphor 5-col grid → vertical stack on mobile ----------- */
  div[style*="grid-template-columns: 1fr auto 1fr auto 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }
  /* The + and = symbols become smaller and self-centre */
  div[style*="grid-template-columns: 1fr auto 1fr auto 1fr"] > div[style*="font-size: 1.75rem"] {
    text-align: center;
    margin: 0.25rem 0;
  }

  /* ---- 2-col / 3-col hero meta blocks stack ----------------------------- */
  div[style*="grid-template-columns: 1.05fr 0.95fr"],
  div[style*="grid-template-columns:1.05fr 0.95fr"],
  div[style*="grid-template-columns: 2fr 1fr"],
  div[style*="grid-template-columns:2fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  /* ---- Any minmax pattern stacks to single column ------------------------ */
  div[style*="minmax(320px"],
  div[style*="minmax(300px"],
  div[style*="minmax(280px"] {
    grid-template-columns: 1fr !important;
  }
  /* Smaller cards (member tiles / vertical breakdown) keep 2-up where possible */
  div[style*="minmax(220px"],
  div[style*="minmax(200px"],
  div[style*="minmax(180px"],
  div[style*="minmax(160px"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.6rem !important;
  }

  /* ---- Sticky top nav: shrink padding, smaller font, allow wrap --------- */
  div[style*="position:sticky"][style*="top:0"],
  div[style*="position: sticky"][style*="top: 0"] {
    padding: 8px 12px !important;
  }
  div[style*="position:sticky"] nav a,
  div[style*="position: sticky"] nav a {
    font-size: 11.5px !important;
    padding: 6px 9px !important;
  }

  /* ---- Hero CTAs in cinematic opening — full-width buttons -------------- */
  a[style*="letter-spacing: 0.12em"][style*="padding: 0.85rem"],
  a[style*="letter-spacing:0.12em"][style*="padding:0.85rem"],
  a[style*="letter-spacing: 0.18em"][style*="padding: 0.85rem"] {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  /* ---- Parallax fix-attachment is janky on iOS — make it scroll --------- */
  section[style*="background-attachment: fixed"],
  section[style*="background-attachment:fixed"] {
    background-attachment: scroll !important;
  }

  /* ---- Inner max-width containers should breathe ------------------------- */
  div[style*="max-width: 760px"][style*="padding: 4rem 2rem"] {
    padding: 2.5rem 1.1rem !important;
  }

  /* ---- Body text: slight tighten ---------------------------------------- */
  p[style*="font-size: 1.15rem"],
  p[style*="font-size:1.15rem"] {
    font-size: 1rem !important;
  }
  p[style*="font-size: 1.05rem"],
  p[style*="font-size:1.05rem"],
  p[style*="font-size: 1.02rem"],
  p[style*="font-size:1.02rem"] {
    font-size: 0.95rem !important;
    line-height: 1.55 !important;
  }

  /* ---- sweetenerShell .container: tighten margins ------------------------ */
  .container {
    padding: 18px 14px 60px !important;
  }

  /* ---- sweetenerShell sub-nav: horizontal scroll instead of wrap -------- */
  .subnav {
    padding: 8px 10px !important;
    top: 46px !important;
  }
  .subnav-inner {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .subnav-inner::-webkit-scrollbar { display: none; }
  .subnav-links {
    flex-wrap: nowrap !important;
    white-space: nowrap;
  }
  .subnav-links a {
    flex-shrink: 0;
    font-size: 12px !important;
    padding: 7px 12px !important;
  }
  /* Hide the Print/Save button on mobile — they'll print from desktop */
  .subnav .btn-ghost { display: none !important; }

  /* ---- sweetenerShell h1/h2/h3 ------------------------------------------ */
  .container h1 { font-size: 1.7rem !important; line-height: 1.2 !important; }
  .container h2 { font-size: 1.3rem !important; margin: 1.6rem 0 0.7rem !important; }
  .container h3 { font-size: 1.08rem !important; }

  /* ---- Tables: smaller font + allow horizontal scroll -------------------- */
  table {
    font-size: 12.5px !important;
  }
  .container table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ---- Cards: less padding ---------------------------------------------- */
  .card {
    padding: 16px !important;
  }

  /* ---- The bottom legacy closer / parallax CTA boxes -------------------- */
  div[style*="margin-top: 2.5rem"][style*="padding: 2rem"],
  div[style*="margin-top: 1.25rem"][style*="padding: 2rem"] {
    padding: 1.25rem !important;
    flex-direction: column !important;
    align-items: stretch !important;
    text-align: center;
  }

  /* ---- Brand "team trio" row in the hero --------------------------------- */
  /* It uses display:flex with gap — let it wrap and centre */
  section[id="story"] > div > div[style*="display: flex"][style*="gap"] {
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   The Film section — embedded video player (#the-film)
   ──────────────────────────────────────────────────────────────────────────── */
#the-film #film-wrap {
  /* Smooth shadow + border treatment carries through all viewports */
  transition: box-shadow 220ms ease;
}
#the-film #film-play-overlay:hover span {
  /* Subtle scale on the big gold play button when hovering */
  transform: scale(1.04);
}
#the-film #film-play-overlay span {
  transition: transform 180ms ease;
}

@media (max-width: 768px) {
  /* Tighten the film section padding on phones */
  #the-film {
    padding: 1.5rem 0.85rem 2.25rem !important;
  }
  /* The poster's aspect ratio stays 16:9 — but inner radius/shadow lighter */
  #the-film #film-wrap {
    border-radius: 8px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.45), 0 0 0 1px rgba(201,169,97,0.2);
  }
  /* Big play overlay button: smaller text, same prominence */
  #the-film #film-play-overlay span {
    padding: 0.7rem 1.1rem !important;
    font-size: 0.78rem !important;
    letter-spacing: 0.06em !important;
    gap: 0.5rem !important;
  }
  #the-film #film-play-overlay span i {
    font-size: 0.9rem !important;
  }
  /* Caption strip in the corner of the player */
  #the-film #film-wrap > div[style*="bottom: 12px"] {
    font-size: 8.5px !important;
    padding: 3px 6px !important;
    right: 8px !important;
    bottom: 8px !important;
  }
  /* CTA row underneath: full-width stacked buttons */
  #the-film > div > div[style*="justify-content: center"][style*="margin-top: 1.75rem"] a {
    width: 100%;
    justify-content: center;
    text-align: center;
  }
  /* Transcript block: tighter padding, slightly smaller serif */
  #the-film > div > div[style*="border-radius: 10px"] {
    padding: 1.25rem 1.1rem 1.1rem !important;
    margin-top: 1.75rem !important;
  }
  #the-film > div > div[style*="border-radius: 10px"] p[style*="Source Serif"] {
    font-size: 1rem !important;
    line-height: 1.75 !important;
  }
  #the-film > div > div[style*="border-radius: 10px"] p[style*="font-size: 1.25rem"] {
    font-size: 1.1rem !important;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   Small phones (≤ 420px) — iPhone SE / older Androids
   ──────────────────────────────────────────────────────────────────────────── */
@media (max-width: 420px) {
  h1[style*="font-size: 3.5rem"],
  h1[style*="font-size:3.5rem"] {
    font-size: 1.85rem !important;
  }
  /* Walking metaphor card padding */
  div[style*="grid-template-columns: 1fr auto 1fr auto 1fr"] > div[style*="padding: 2rem 1.5rem"] {
    padding: 1.25rem 1rem !important;
  }
  /* Drop minmax(220px) and similar to single column on tiny screens */
  div[style*="minmax(220px"],
  div[style*="minmax(200px"] {
    grid-template-columns: 1fr !important;
  }
  /* Keep the very small badge grids 2-up */
  div[style*="minmax(160px"],
  div[style*="minmax(180px"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
