/* ============================================================
   motion-fixes.css — visual audit corrections (R-fixes #1..#4)
   Loads after motion.min.css.
   ============================================================ */

/* ---------- #1 Hero text contrast overlay ----------
   Brand heroes (home/donate/programs/news) are intentionally bright/luminous.
   White text on them is hard to read without a darker gradient overlay.
   We layer a teal→transparent gradient using ::before pseudo across all hero variants.
*/
/* Apply to .page-hero + .audit-head (brand-image sections).
   Skip .hero-section — home already has the hero-carousel + hero-shade machinery. */
.page-hero,
.audit-head {
  position: relative;
  isolation: isolate;
}
.page-hero::after,
.audit-head::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(10, 42, 61, 0.78) 0%,
    rgba(10, 42, 61, 0.55) 45%,
    rgba(10, 42, 61, 0.65) 100%
  );
  z-index: 0;
  pointer-events: none;
}
.page-hero > *,
.audit-head > * {
  position: relative;
  z-index: 1;
}
/* Stronger overlay on mobile where text wraps and image dominates */
@media (max-width: 640px) {
  .page-hero::after,
  .audit-head::after {
    background: linear-gradient(
      135deg,
      rgba(10, 42, 61, 0.88) 0%,
      rgba(10, 42, 61, 0.72) 50%,
      rgba(10, 42, 61, 0.82) 100%
    );
  }
}

/* Tighten hero typography rhythm on mobile so titles don't wrap orphans */
@media (max-width: 640px) {
  .page-hero h1,
  .hero-section h1,
  .audit-head h1,
  .page-hero-inner h1 {
    text-wrap: balance;
    max-width: 16ch;
    margin-inline: auto;
  }
  .page-hero p.lead,
  .hero-section .hero-copy,
  .audit-head p,
  .page-hero-inner p.lead {
    text-wrap: pretty;
    max-width: 38ch;
    margin-inline: auto;
  }
}

/* ---------- #2 Hide home-switch + dual-version chrome on mobile ---------- */
@media (max-width: 640px) {
  .home-switch,
  .header-tools .home-switch,
  .header-tools .language-switch {
    display: none !important;
  }
}

/* ---------- #3 Footer newsletter button can't truncate ---------- */
.mb-news-row {
  align-items: stretch;
}
.mb-news-row button {
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 92px;
  padding-inline: 14px;
}
@media (max-width: 420px) {
  .mb-news-row {
    flex-direction: column;
  }
  .mb-news-row button {
    width: 100%;
    min-height: 44px;
  }
}

/* ---------- #4 Footer license + contact tidier ---------- */
.mb-footer-license p {
  text-wrap: pretty;
  max-width: 880px;
  margin-inline: auto;
}
.mb-footer-contact address a[dir="ltr"] {
  direction: ltr;
  unicode-bidi: isolate;
}

/* ---------- Small polish: hotline strip emerald is a touch loud, tone ---------- */
.hotline-strip b {
  /* Was mint #6FE2A4 for a dark strip; the strip is light now, so the mint
     read at 1.4:1. The strip's own strong ink instead. */
  color: var(--ubar-ink-strong, #0A2A3D) !important;
}

/* ---------- Hero parallax was applying via background-position but heroes
   use inline style background-image. Force the overlay to not double-darken. */
.audit-head {
  background-blend-mode: normal;
}

/* ---------- Reduced-motion respects ---------- */
@media (prefers-reduced-motion: reduce) {
  .page-hero::after,
  .hero-section::after,
  .audit-head::after {
    background: rgba(10, 42, 61, 0.78);
  }
}

/* ---------- R-fix-2 PATCH (2026-05-22): mobile dock vs sticky CTA + global H1 balance ---------- */

/* Apply text-wrap: balance to all H1s, not just mobile */
h1,
.page-hero h1,
.hero-section h1,
.audit-head h1,
.page-hero-inner h1 {
  text-wrap: balance;
}

/* When mobile sticky CTA is visible, push the action-dock up so they don't overlap.
   The sticky CTA sits at bottom: 76px; the dock is below it. We shift the dock up when CTA is shown. */
@media (max-width: 640px) {
  body:has(.mb-sticky-cta.is-shown) .action-dock {
    transform: translateY(-44px);
    transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
  }
}

/* Mobile micro-rhythm: tighten hero padding */
@media (max-width: 640px) {
  .page-hero,
  .hero-section,
  .audit-head {
    padding-block: 60px 36px !important;
  }
  .page-hero-inner,
  .hero-content {
    padding-inline: 18px !important;
  }
  /* Crumbs less prominent on mobile */
  .crumbs {
    font-size: 12px;
    opacity: 0.78;
  }
  /* Eyebrow consistency */
  .page-hero .eyebrow,
  .hero-content .eyebrow,
  .audit-head .eyebrow {
    margin: 0 0 8px;
  }
  /* Single-column page-grid on mobile (some pages set 2-col inline) */
  .page-grid-2 {
    grid-template-columns: 1fr !important;
  }
  /* Section spacing tighter on mobile */
  .page-section, .section-block {
    padding-block: 40px !important;
  }
}

/* Tap-friendly form fields */
@media (max-width: 640px) {
  .form-stack input,
  .form-stack select,
  .form-stack textarea,
  .dv2-form input,
  .dv2-form select,
  .dv2-form textarea,
  .zv2-fields input {
    min-height: 44px;
    font-size: 16px; /* iOS Safari won't zoom into 16px+ inputs */
  }
}

/* Boot loader: shorter cap visual on slow links */
.mb-boot__bar { width: 160px; }

/* Action dock — avoid clipping on long Arabic labels */
.action-dock { flex-wrap: nowrap; }
@media (max-width: 640px) {
  .action-dock {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .action-dock::-webkit-scrollbar { display: none; }
}

/* Legal pages: tighten max width on mobile to prevent text reaching edges */
@media (max-width: 640px) {
  .legal-shell {
    padding-inline: 18px !important;
  }
}

/* ---------- a11y patch (axe-core 2026-05-22) ---------- */
/* Increase contrast of inactive language switch */
.language-switch button {
  color: #0a2a3d;
  border: 1px solid rgba(15, 68, 89, 0.25);
}
.language-switch button.active {
  background: #0a2a3d;
  color: #fff;
}
/* Focus rings everywhere — visible for keyboard nav */
:focus-visible {
  outline: 3px solid var(--mb-emerald, #12525C);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus-visible,
a:focus-visible {
  outline-offset: 3px;
}
/* Skip-link visible when focused */
.skip-link:focus {
  position: fixed;
  top: 12px;
  inset-inline-start: 12px;
  background: var(--mb-teal-deep, #0F4459);
  color: #fff;
  padding: 10px 16px;
  z-index: 99999;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
}
