/* responsive.css — Enablers United mobile layout
   The pages are inline-styled by design; media queries can't be inline, so all
   small-screen overrides live here. Selectors match the RUNTIME (React-
   serialized) form of the inline styles: "padding: 56px 48px", "rgb(...)".
   Breakpoints: 900px (tablet/phone), 560px (small phone). */

/* Nav toggle is mobile-only; hidden on desktop via inline display:none. */
#nav-toggle button {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid #CBD5E1;
  background: transparent;
  color: #334155;
}
html.dark #nav-toggle button { border-color: #33475C; color: #CBD5E1; }
#nav-toggle button:focus-visible { outline: 2px solid #0E7490; outline-offset: 2px; }

/* Native <select> ignores padding/height in WebKit (iOS Safari) unless the
   default appearance is removed — without this, form dropdowns collapse to
   ~24px and become untappable. Scoped to named form selects so the language
   switcher (which draws its own chevron) is untouched. */
select[name] {
  -webkit-appearance: none;
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="6" viewBox="0 0 10 6"><path d="M1 1l4 4 4-4" fill="none" stroke="%23475569" stroke-width="1.6" stroke-linecap="round"/></svg>') !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  padding-right: 34px !important;
}
html.dark select[name] {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="6" viewBox="0 0 10 6"><path d="M1 1l4 4 4-4" fill="none" stroke="%23A2B3C6" stroke-width="1.6" stroke-linecap="round"/></svg>') !important;
}

/* Dark mode for form controls. theme.js remaps colours by matching authored
   inline values, but the fields are authored `border: 1.5px solid` (its map
   only covers 1px) and inputs/textareas carry no inline background at all — so
   they fell through to the UA's color-scheme: dark fill with a light border.
   Set the surface here instead, width-agnostic and for all three control types. */
html.dark input,
html.dark select,
html.dark textarea {
  background-color: #132433 !important;
  border-color: #33475C !important;
  color: #E2E8F0 !important;
}
html.dark input::placeholder,
html.dark textarea::placeholder { color: #7C8EA3; }
/* Same 1.5px blind spot for the chip buttons: remap only the light authored
   border, so a selected chip keeps its accent outline. */
html.dark button[style*="solid rgb(226, 232, 240)"],
html.dark a[style*="solid rgb(226, 232, 240)"] { border-color: #33475C !important; }

@media (max-width: 1079px) {
  /* overflow-x:hidden on <body> forces the other axis to compute `auto`, which
     turns body into its own scroll container and breaks window.scrollY /
     window.scrollTo / anchor jumps / iOS momentum scrolling. `clip` on <html>
     guards against stray horizontal overflow without creating a scroller.
     (Pre-16 Safari ignores clip — harmless, since nothing overflows anyway.) */
  html { max-width: 100%; overflow-x: clip; }
  body { max-width: 100%; overflow-wrap: break-word; }

  /* Grid/flex children must be allowed to shrink below their min-content width,
     or long strings (account numbers, emails) push the layout past the screen. */
  [style*="display: grid"] > *, [style*="display: flex"] > * { min-width: 0; }

  /* 1. Root stops forcing a desktop canvas. */
  [data-screen-label] { min-width: 0 !important; width: 100% !important; }

  /* 2. Full-bleed sections: 48px side padding → 20px. Skips the 5px accent bar. */
  [data-screen-label] > *:where(:not([style*="height: 5px"])) {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }

  /* 3. Multi-column grids collapse. Exceptions: the accent bar, label/value
        pairs (auto 1fr), and amount pickers (kept 2-up).
        :where() keeps this at (0,1,0) so the specific overrides below — and the
        tablet tier — can beat it. A bare :not() inherits its argument's
        specificity and would silently win over all of them. */
  [style*="grid-template-columns"]:where(:not([style*="height: 5px"])):where(:not([style*="auto 1fr"])) {
    grid-template-columns: 1fr !important;
  }
  [style*="repeat(4, 1fr)"][style*="gap: 8px"],
  [style*="repeat(4, 1fr)"][style*="gap: 6px"] {
    grid-template-columns: 1fr 1fr !important;
  }
  /* The CSR card's chip grid and name/email row both fit 2-up even at 320px —
     collapsing them made the card taller, which is the opposite of the intent. */
  #csr [style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr 1fr !important; }

  /* 4. Big vertical rhythm tightens up. */
  [style*="padding: 72px 48px 64px"],
  [style*="padding: 64px 48px 56px"] { padding-top: 40px !important; padding-bottom: 36px !important; }
  [style*="padding: 56px 48px"],
  [style*="padding: 56px 48px 20px"] { padding-top: 36px !important; }
  [style*="padding: 48px"] { padding-top: 32px !important; padding-bottom: 32px !important; }
  [style*="gap: 56px"], [style*="gap: 48px"] { gap: 28px !important; }
  [style*="gap: 32px"] { gap: 22px !important; }

  /* 5. Rows that would otherwise push past the viewport. */
  [style*="justify-content: space-between"] { flex-wrap: wrap; }
  [style*="row-gap"] { row-gap: 14px; }
  [data-screen-label] > [style*="display: flex"][style*="justify-content: space-between"] { row-gap: 16px; }

  /* 6. Type scale — headline sizes tuned for a 360–430px viewport. */
  [style*="font-size: 52px"] { font-size: 32px !important; }
  [style*="font-size: 44px"], [style*="font-size: 42px"] { font-size: 28px !important; }
  [style*="font-size: 38px"] { font-size: 28px !important; }
  [style*="font-size: 32px"], [style*="font-size: 30px"] { font-size: 24px !important; }
  [style*="font-size: 26px"] { font-size: 21px !important; }
  [style*="font-size: 22px"] { font-size: 19px !important; }
  [style*="font-size: 17px"], [style*="font-size: 16.5px"] { font-size: 15.5px !important; }

  /* 7. Fixed gutters inside collapsed cards / rows. */
  [style*="padding: 26px 28px 26px 0"] { padding: 20px !important; }
  [style*="padding: 28px"] { padding: 20px !important; }
  [style*="min-width: 150px"] { min-width: 84px !important; }
  [style*="min-height: 320px"] { min-height: 220px !important; }
  [style*="height: 230px"], [style*="height: 240px"] { height: 200px !important; }

  /* 8. Sticky header → logo + Donate + menu button; links become a panel. */
  [style*="position: sticky"][style*="display: flex"] {
    position: relative !important;
    padding-top: 10px !important;
    padding-bottom: 10px !important;
    gap: 10px;
  }
  #nav-toggle { display: flex !important; }
  #nav-links {
    display: none !important;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 2px !important;
    background: #fff;
    border-bottom: 1px solid #E2E8F0;
    padding: 8px 16px 14px;
    box-shadow: 0 16px 34px rgba(2, 8, 20, 0.14);
    z-index: 60;
  }
  html.dark #nav-links { background: #132433; border-bottom-color: #243A52; }
  html[data-nav="open"] #nav-links { display: flex !important; }
  #nav-links > a { padding: 12px !important; box-sizing: border-box; min-height: 48px; }
  #nav-extras {
    margin: 8px 0 0 !important;
    padding-top: 12px;
    border-top: 1px solid #E2E8F0;
  }
  html.dark #nav-extras { border-top-color: #243A52; }

  /* 9. Tap targets: 44px minimum. Only text-only controls get their display
        changed — forcing inline-flex on a control that wraps element children
        (the fund pickers, which stack a title over a description) would lay
        them out as a row. Everything else just gets the min-height. */
  [style*="position: sticky"] > a,
  [style*="position: sticky"] a[style*="border-radius"],
  a[style*="font-size: 14px"][style*="font-weight: 700"],
  a[style*="font-size: 14.5px"][style*="font-weight: 700"],
  div > a[style*="color: rgb(148, 163, 184)"] {
    min-height: 44px;
    box-sizing: border-box;
    display: inline-flex !important;
    align-items: center;
  }
  a[style*="border-radius"],
  button[style*="border-radius"] {
    min-height: 44px;
    box-sizing: border-box;
  }
  [style*="position: sticky"] > a { gap: 11px; }

  /* 10. Form controls: 44px targets and 16px text so iOS doesn't auto-zoom. */
  input, select, textarea {
    min-height: 44px;
    font-size: 16px !important;
    box-sizing: border-box;
    max-width: 100%;
  }
  textarea { min-height: 104px; }
}

@media (min-width: 700px) and (max-width: 1079px) {
  /* Tablet tier: the gap between phone and the 1080px desktop floor. Cards go
     2-up rather than full-width so nothing looks stretched, and the side
     gutters open back up. */
  [data-screen-label] > *:where(:not([style*="height: 5px"])) {
    padding-left: 32px !important;
    padding-right: 32px !important;
  }
  [style*="repeat(3, 1fr)"],
  [style*="repeat(4, 1fr)"]:where(:not([style*="gap: 8px"])):where(:not([style*="gap: 6px"])),
  [style*="repeat(5, 1fr)"] { grid-template-columns: 1fr 1fr !important; }
  [style*="grid-template-columns: 380px 1fr"] { grid-template-columns: 300px 1fr !important; }
  [style*="grid-template-columns: 110px 1fr"] { grid-template-columns: 110px 1fr !important; }
  [style*="padding: 26px 28px 26px 0"] { padding: 24px 26px 24px 0 !important; }
  [style*="font-size: 52px"] { font-size: 42px !important; }
  [style*="font-size: 44px"], [style*="font-size: 42px"] { font-size: 36px !important; }
  [style*="font-size: 32px"], [style*="font-size: 30px"] { font-size: 27px !important; }
}

@media (max-width: 560px) {
  /* Label/value pairs stack so nothing is forced wider than the screen. */
  [style*="grid-template-columns: auto 1fr"] { grid-template-columns: 1fr !important; }
  [data-screen-label] > *:where(:not([style*="height: 5px"])) {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
  /* Amount pickers go 1-up so the ₹ label never truncates. */
  [style*="repeat(4, 1fr)"][style*="gap: 8px"] { grid-template-columns: 1fr 1fr !important; }
  [style*="font-size: 52px"] { font-size: 28px !important; }
  [style*="font-size: 44px"], [style*="font-size: 42px"] { font-size: 25px !important; }
  /* Header: shrink the CTA so row 1 fits a 320px viewport. The logo is a full
     lockup (crest + wordmark + tagline) — scale by height only, never squash it. */
  [style*="position: sticky"] img { height: 54px !important; width: auto !important; }
  [style*="position: sticky"] a[style*="background: rgb(190, 24, 93)"],
  [style*="position: sticky"] a[style*="background: rgb(14, 116, 144)"] {
    padding: 12px 16px !important;
    font-size: 13px !important;
  }
  /* "CSR collaboration" is too long for one header row on a phone. */
  #cta-full { display: none !important; }
  #cta-short { display: inline !important; }
  /* Stat clusters stack instead of squeezing. */
  [style*="gap: 28px"] { gap: 16px !important; }
  [style*="min-width: 150px"] { min-width: 0 !important; }
}

@media (prefers-reduced-motion: reduce) {
  [data-anim] { animation: none !important; }
  * { scroll-behavior: auto !important; }
}
