/* Strategic CX: phone and small-tablet layout.
   Pages are built with inline styles (rendered by React, so values appear normalized, e.g.
   "padding: 0px 44px"). These rules override them below 760px only; desktop is untouched. */

@media (max-width: 760px) {

  /* ---- Page gutters: 44px desktop margins become 20px ---- */
  [style*="max-width: 1320px"],
  [style*="max-width: 760px"] {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }

  /* ---- Vertical rhythm: big desktop section spacing is halved ---- */
  section[style*="padding: 104px 0px"], section[style*="padding: 96px 0px"],
  section[style*="padding: 112px 0px"], section[style*="padding: 120px 0px"],
  section[style*="padding: 88px 0px"] {
    padding-top: 56px !important;
    padding-bottom: 60px !important;
  }
  [style*="padding: 88px 44px"], [style*="padding: 96px 44px"],
  [style*="padding: 104px 44px"] {
    padding-top: 48px !important;
    padding-bottom: 44px !important;
  }
  [style*="padding: 128px 44px"] { padding-top: 56px !important; }

  /* ---- Cards and callouts: tighter inner padding ---- */
  [style*="padding: 44px 40px"], [style*="padding: 44px 32px"],
  [style*="padding: 52px 48px"] {
    padding: 28px 20px !important;
  }

  /* ---- Side-by-side layouts stack into one column ---- */
  [style*="grid-template-columns: 1.4fr 0.6fr 0.6fr"],
  [style*="grid-template-columns: minmax(0px, 200px) minmax(0px, 1fr)"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns: 0.9fr 1.1fr"],
  [style*="grid-template-columns: 1.05fr 0.95fr"],
  [style*="grid-template-columns: 1.2fr 0.8fr"],
  [style*="grid-template-columns: 1.15fr 0.85fr"],
  [style*="grid-template-columns: 1.3fr 0.7fr"],
  [style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 28px !important;
  }

  /* Case-study steps: number | heading | text  ->  number beside heading, text underneath */
  [style*="grid-template-columns: 80px minmax(0px, 1fr) minmax(0px, 1.3fr)"] {
    grid-template-columns: 40px minmax(0, 1fr) !important;
    gap: 10px 14px !important;
  }
  [style*="grid-template-columns: 80px minmax(0px, 1fr) minmax(0px, 1.3fr)"] > :nth-child(3) {
    grid-column: 2 !important;
  }

  /* ---- Readable type: nothing below 12px on a phone ---- */
  [style*="font-size: 10px"], [style*="font-size: 10.5px"],
  [style*="font-size: 11px"], [style*="font-size: 11.5px"] {
    font-size: 12px !important;
  }
  /* Form fields at 16px so iOS doesn't zoom in when you tap them */
  input, select, textarea { font-size: 16px !important; }

  /* ---- Data tables become cards (Charter Watch, Bank M&A Tracker) ---- */
  [style*="min-width: 880px"], [style*="min-width: 1180px"] { min-width: 0 !important; }

  /* Column headers are replaced by labels inside each card */
  [style*="min-width: 880px"] > :not([role="button"]):first-child,
  [style*="min-width: 1180px"] > :not([role="button"]):first-child { display: none !important; }

  [style*="min-width: 880px"] > [role="button"],
  [style*="min-width: 1180px"] > [role="button"] {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    gap: 14px 18px !important;
    padding: 18px 0 !important;
    align-items: start !important;
  }
  [style*="min-width: 880px"] > [role="button"] > :nth-child(1),
  [style*="min-width: 1180px"] > [role="button"] > :nth-child(1),
  [style*="min-width: 1180px"] > [role="button"] > :nth-child(2) {
    grid-column: 1 / -1 !important;
  }
  [style*="min-width: 880px"] > [role="button"] > :nth-child(n+2),
  [style*="min-width: 1180px"] > [role="button"] > :nth-child(n+2) {
    text-align: left !important;
    flex-wrap: wrap !important;
  }
  [style*="min-width: 880px"] > [role="button"] > :nth-child(n+2)::before,
  [style*="min-width: 1180px"] > [role="button"] > :nth-child(n+2)::before {
    display: block;
    flex-basis: 100%;
    margin-bottom: 4px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(17, 17, 17, 0.5);
  }
  [style*="min-width: 880px"] > [role="button"] > :nth-child(2)::before { content: 'Charter'; }
  [style*="min-width: 880px"] > [role="button"] > :nth-child(3)::before { content: 'Regulator'; }
  [style*="min-width: 880px"] > [role="button"] > :nth-child(4)::before { content: 'Filed'; }
  [style*="min-width: 880px"] > [role="button"] > :nth-child(5)::before { content: 'Status'; }
  [style*="min-width: 1180px"] > [role="button"] > :nth-child(2)::before { content: 'Target'; }
  [style*="min-width: 1180px"] > [role="button"] > :nth-child(3)::before { content: 'Charter'; }
  [style*="min-width: 1180px"] > [role="button"] > :nth-child(4)::before { content: 'Type'; }
  [style*="min-width: 1180px"] > [role="button"] > :nth-child(5)::before { content: 'Assets'; }
  [style*="min-width: 1180px"] > [role="button"] > :nth-child(6)::before { content: 'Value'; }
  [style*="min-width: 1180px"] > [role="button"] > :nth-child(7)::before { content: 'Announced'; }
  [style*="min-width: 1180px"] > [role="button"] > :nth-child(8)::before { content: 'Status'; }

  /* Items told to span 2-3 columns would force phantom columns once a layout stacks */
  [style*="grid-column: span 2"], [style*="grid-column: span 3"] { grid-column: auto !important; }

  /* Wide figure tables that still scroll sideways keep their first column pinned */
  table[style*="min-width: 860px"] th:first-child,
  table[style*="min-width: 860px"] td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    box-shadow: 1px 0 0 rgba(17, 17, 17, 0.12);
  }
  table[style*="min-width: 860px"] td:first-child { background: #FFFFFF; }
  table[style*="min-width: 860px"] th:first-child { background: #232634; }

  /* Home stat strip ($3M+ / 70yrs / 20+): stays three across, sized to fit */
  [style*="grid-template-columns: repeat(3, minmax(0px, 1fr))"] > * { padding: 28px 6px !important; }
  [style*="grid-template-columns: repeat(3, minmax(0px, 1fr))"] > * > [style*="font-size: 56px"] { font-size: 34px !important; }
}
