/* =========================================================
   IUW — Responsive overrides for inline-styled React layouts
   Targets common patterns produced by camelCased React inline
   styles (which serialize as `style="prop-name: value;"`).
   Loaded site-wide via <link> in every HTML page.
   ========================================================= */

html, body { max-width: 100%; }
body { overflow-x: hidden; }
img, svg, video { max-width: 100%; height: auto; }
section, header, footer { max-width: 100vw; }

/* ── Tablet (≤1024) ───────────────────────────────────────
   Collapse the “hero + secondary panel” style two-column
   layouts that don't fit comfortably below ~1024.
   ───────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  [style*="grid-template-columns: 1.25fr 1fr"],
  [style*="grid-template-columns: 1.15fr 1fr"],
  [style*="grid-template-columns: 1.1fr 1fr"],
  [style*="grid-template-columns: 1.2fr 1fr"],
  [style*="grid-template-columns: 1.4fr 1fr"],
  [style*="grid-template-columns: 1.5fr 1fr"],
  [style*="grid-template-columns: 2fr 1fr"],
  [style*="grid-template-columns: 1fr 1.15fr"],
  [style*="grid-template-columns: 1fr 1.25fr"],
  [style*="grid-template-columns: 1fr 1.5fr"],
  [style*="grid-template-columns: 1fr 2fr"],
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 40px !important;
  }
  /* 4-col footers/strips → 2x2 */
  [style*="grid-template-columns: 1.4fr 1fr 1fr 1fr"],
  [style*="grid-template-columns: repeat(4,1fr)"],
  [style*="grid-template-columns: repeat(4, 1fr)"] {
    grid-template-columns: repeat(2, minmax(0,1fr)) !important;
    gap: 32px !important;
  }
  /* 3-col card grids → 2-up on tablet */
  [style*="grid-template-columns: repeat(3,1fr)"],
  [style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: repeat(2, minmax(0,1fr)) !important;
  }
  /* Maxwidth caps off */
  [style*="max-width: 1440"],
  [style*="max-width: 1360"],
  [style*="max-width: 1280"] {
    max-width: 100% !important;
  }
  /* Reduce huge horizontal padding */
  [style*="padding: 100px 40px"],
  [style*="padding: 120px 40px"],
  [style*="padding: 140px 40px"],
  [style*="padding: 80px 40px"],
  [style*="padding: 96px 40px"],
  [style*="padding: 72px 60px"],
  [style*="padding: 80px 60px"] {
    padding-left: 28px !important;
    padding-right: 28px !important;
  }
}

/* ── Mobile (≤720) ────────────────────────────────────────
   Stack everything. Reduce padding and big type.
   ───────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  /* Collapse every multi-column grid to a single column */
  [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
  /* Rows with leading icon column (e.g. "56px 1fr ...") need a slim 2-col fallback */
  [style*="grid-template-columns: 56px 1fr"],
  [style*="grid-template-columns: 60px 1fr"],
  [style*="grid-template-columns: 32px 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* Tighter section padding on phones */
  [style*="padding: 100px 40px"],
  [style*="padding: 120px 40px"],
  [style*="padding: 140px 40px"],
  [style*="padding: 80px 40px"],
  [style*="padding: 96px 40px"],
  [style*="padding: 60px 40px"],
  [style*="padding: 56px 40px"],
  [style*="padding: 48px 40px"],
  [style*="padding: 40px 40px"],
  [style*="padding: 72px 60px"],
  [style*="padding: 80px 60px"] {
    padding-left: 18px !important;
    padding-right: 18px !important;
  }
  /* Footer / hero with rounded corners look pinched on phones */
  [style*="border-radius: 0px 0px 32px 32px"],
  [style*="border-radius: 32px 32px 0px 0px"] {
    border-radius: 0 !important;
  }
  /* Big inline font sizes -> scale down */
  [style*="font-size: 96px"]      { font-size: 56px !important; line-height: 1 !important; }
  [style*="font-size: 80px"]      { font-size: 48px !important; line-height: 1.05 !important; }
  [style*="font-size: 72px"]      { font-size: 44px !important; }
  [style*="font-size: 64px"]      { font-size: 40px !important; }
  [style*="font-size: 56px"]      { font-size: 36px !important; }
  [style*="font-size: 48px"]      { font-size: 32px !important; }
  [style*="font-size: 44px"]      { font-size: 30px !important; }
  [style*="font-size: 36px"]      { font-size: 26px !important; }
  [style*="font-size: 32px"]      { font-size: 24px !important; }
  [style*="font-size: 28px"]      { font-size: 22px !important; }
  /* Tables / wide bordered cells loose their rigid border-right when stacked */
  [style*="border-right: 1px solid"] {
    border-right: none !important;
  }
  /* Flex rows force-wrap on phones */
  [style*="display: flex"] {
    flex-wrap: wrap;
  }
  /* Don't wrap things that explicitly shouldn't (e.g. compact pills) */
  [style*="white-space: nowrap"] {
    flex-wrap: nowrap;
  }
  /* Cap container widths and remove huge gaps */
  [style*="max-width"] { max-width: 100% !important; }
  [style*="gap: 80px"] { gap: 32px !important; }
  [style*="gap: 64px"] { gap: 28px !important; }
  [style*="gap: 56px"] { gap: 24px !important; }
  [style*="gap: 48px"] { gap: 24px !important; }
  /* Quote / CTA inside blocks have giant inner padding */
  [style*="padding: 72px 60px"] { padding: 36px 22px !important; }
  [style*="padding: 80px 60px"] { padding: 36px 22px !important; }
  [style*="padding: 60px 56px"] { padding: 32px 22px !important; }
  /* Min-heights collapse */
  [style*="min-height: 560"],
  [style*="min-height: 480"],
  [style*="min-height: 420"] {
    min-height: 0 !important;
  }
  /* Sparkline / panels overflow safely */
  [style*="aspect-ratio: 4 / 5"],
  [style*="aspect-ratio: 4/5"] {
    aspect-ratio: 3 / 4 !important;
    max-width: 100%;
  }
  /* Inline-block strip cells: drop left/right padding */
  [style*="padding-right: 32px"] { padding-right: 0 !important; }
  [style*="padding-left: 32px"]  { padding-left: 0 !important; }

  /* === Nav: hide desktop links, show inline menu button === */
  /* Nav.jsx renders the menu button itself; this is a safety net for any
     unmodified page during transition. */
  header[data-iuw-nav] nav.iuw-desktop-links { display: none !important; }
  header[data-iuw-nav] .iuw-cta-login { display: none !important; }
  header[data-iuw-nav] .iuw-cta-signup { display: none !important; }
  header[data-iuw-nav] [style*="padding: 18px 40px"] { padding: 14px 18px !important; gap: 12px !important; }
}

/* ── Very narrow (≤420) ────────────────────────────────── */
@media (max-width: 420px) {
  [style*="padding: 80px 40px"],
  [style*="padding: 100px 40px"],
  [style*="padding: 120px 40px"],
  [style*="padding: 56px 40px"],
  [style*="padding: 60px 40px"],
  [style*="padding: 72px 60px"],
  [style*="padding: 80px 60px"] {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }
  [style*="font-size: 96px"] { font-size: 44px !important; }
  [style*="font-size: 80px"] { font-size: 40px !important; }
  [style*="font-size: 72px"] { font-size: 36px !important; }
  [style*="font-size: 64px"] { font-size: 32px !important; }
}

/* === Mobile nav drawer (cooperates with nav.jsx) ============= */
.iuw-mobile-toggle { display: none; }
.iuw-mobile-drawer { display: none; }
@media (max-width: 720px) {
  .iuw-mobile-toggle {
    display: inline-flex !important;
    align-items: center; justify-content: center;
    width: 40px; height: 40px;
    border: 1px solid var(--line, rgba(29,16,60,0.25));
    border-radius: 999px;
    background: transparent;
    color: var(--ink, #1D103C);
    cursor: pointer;
  }
  .iuw-mobile-toggle svg { width: 18px; height: 18px; }

  .iuw-mobile-drawer {
    display: flex !important;
    flex-direction: column;
    position: fixed; inset: 0;
    background: var(--paper, #FBF8F2);
    color: var(--ink, #1D103C);
    z-index: 100;
    padding: 18px;
    transform: translateY(-101%);
    transition: transform .28s cubic-bezier(.2,.7,.2,1);
  }
  .iuw-mobile-drawer.open { transform: translateY(0); }
  .iuw-mobile-drawer .iuw-drawer-top {
    display: flex; justify-content: space-between; align-items: center;
    padding: 4px 4px 24px;
  }
  .iuw-mobile-drawer .iuw-drawer-links {
    display: flex; flex-direction: column; gap: 4px;
    padding: 8px 0; border-top: 1px solid var(--line, rgba(29,16,60,0.12));
  }
  .iuw-mobile-drawer .iuw-drawer-links a {
    font-size: 28px; font-weight: 600; letter-spacing: -0.02em;
    padding: 18px 4px; border-bottom: 1px solid var(--line, rgba(29,16,60,0.12));
    display: flex; justify-content: space-between; align-items: center;
  }
  .iuw-mobile-drawer .iuw-drawer-links a::after {
    content: ""; width: 16px; height: 16px;
    background: currentColor;
    -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill="none" stroke="black" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" d="M2 8h11M9 4l4 4-4 4"/></svg>') no-repeat center / contain;
            mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill="none" stroke="black" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" d="M2 8h11M9 4l4 4-4 4"/></svg>') no-repeat center / contain;
    opacity: 0.6;
  }
  .iuw-mobile-drawer .iuw-drawer-cta {
    margin-top: auto;
    display: flex; flex-direction: column; gap: 10px;
  }
}
