/* Shared mobile layout fixes for Cloudflare Pages. */
@media (max-width: 767px) {
  html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body {
    min-width: 0;
    overflow-x: hidden;
  }

  img,
  svg,
  video,
  canvas,
  iframe {
    max-width: 100%;
  }

  .container {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  section:not(.route) {
    padding-top: 40px;
    padding-bottom: 40px;
  }

  h1,
  h2,
  h3,
  h4,
  p,
  li,
  summary,
  a,
  label {
    overflow-wrap: anywhere;
  }

  h1 {
    font-size: clamp(1.9rem, 9vw, 2.5rem) !important;
    line-height: 1.15 !important;
  }

  h2 {
    font-size: clamp(1.6rem, 7vw, 2.1rem) !important;
    line-height: 1.2 !important;
  }

  h3,
  h4 {
    font-size: clamp(1.2rem, 5.5vw, 1.6rem) !important;
    line-height: 1.25 !important;
  }

  p,
  li,
  summary {
    font-size: 1rem;
    line-height: 1.6;
  }

  input,
  select,
  textarea,
  button {
    max-width: 100%;
    font-size: 16px !important;
  }

  input,
  select,
  textarea {
    width: 100%;
  }

  .card,
  .panel,
  .p-card,
  .faq-item {
    width: 100%;
    max-width: 100% !important;
    padding: 20px 16px !important;
  }

  .btn {
    width: 100%;
    max-width: 100%;
    min-width: 0 !important;
    min-height: 44px;
    height: auto !important;
    padding: 12px 16px !important;
    text-align: center;
    white-space: normal;
  }

  /* Mobile navigation: three clear vertical groups with wrapping links. */
  nav[aria-label="Primary"] {
    position: relative !important;
  }

  nav[aria-label="Primary"] .nav-inner,
  nav[aria-label="Primary"] .nav-left,
  nav[aria-label="Primary"] .nav-center,
  nav[aria-label="Primary"] .nav-right {
    width: 100% !important;
    max-width: 100% !important;
  }

  nav[aria-label="Primary"] .nav-inner {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 10px 14px !important;
  }

  nav[aria-label="Primary"] .nav-left,
  nav[aria-label="Primary"] .nav-right {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    gap: 9px !important;
  }

  nav[aria-label="Primary"] .brand {
    width: 100%;
    justify-content: center !important;
  }

  nav[aria-label="Primary"] .brand-logo-wrap img {
    width: 60px !important;
    height: 60px !important;
    object-fit: contain;
  }

  nav[aria-label="Primary"] .brand-wordmark {
    width: min(64vw, 220px) !important;
    height: auto !important;
    max-height: 58px !important;
    object-fit: contain;
  }

  nav[aria-label="Primary"] .nav-links {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 6px 16px !important;
    width: 100% !important;
    margin: 0 !important;
    text-align: center;
  }

  nav[aria-label="Primary"] .nav-links a {
    margin: 0 !important;
    padding: 4px 2px;
    font-size: 0.95rem;
    white-space: normal;
  }

  nav[aria-label="Primary"] .nav-social {
    display: flex;
    justify-content: center;
    gap: 10px;
  }

  nav[aria-label="Primary"] .nav-ctas {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100%;
    max-width: 360px;
  }

  nav[aria-label="Primary"] .nav-btn {
    width: 100% !important;
  }

  /* Stack page and hero columns instead of compressing them side by side. */
  .hero-grid,
  .about-hero .grid,
  #about-page .split,
  .about-split .split,
  #founder-story-section .founder-story-grid,
  .contact-grid .grid {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 20px !important;
  }

  .hero-grid {
    padding: 28px 16px !important;
  }

  .hero-grid > *,
  .about-hero .grid > *,
  .split > *,
  .contact-grid .grid > * {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  header.hero:not(.hero--compact),
  #home-hero,
  .contact-hero {
    min-height: auto !important;
    height: auto !important;
  }

  .hero-copy,
  .hero-copy h1,
  .hero-copy p,
  .about-hero .titles,
  .contact-hero .container {
    width: 100% !important;
    max-width: 100% !important;
    text-align: center !important;
    white-space: normal !important;
  }

  .hero-copy p,
  .mission-blurb {
    font-size: 1.05rem !important;
  }

  .donate-box {
    width: 100% !important;
    max-width: 100% !important;
    justify-self: stretch !important;
    transform: none !important;
    padding: 18px 16px !important;
  }

  .amounts {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .brand-title .brand-acronym {
    max-width: 100%;
    font-size: clamp(3.2rem, 18vw, 5rem) !important;
    line-height: 1 !important;
  }

  /* One-column content layouts for landing, impact, About, Contact and footer. */
  .grid,
  .gethelp-panels,
  .cta-row,
  .facts-grid,
  .stories-grid,
  .footer-grid,
  #fundraise-ways .fund-panels {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  #silent-facts > .container,
  .impact-grid,
  #volunteer-details .vol-icon-row,
  #bottom-apply-cta,
  .gift-ctas,
  .partners-cta {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .impact-grid {
    flex-wrap: nowrap !important;
    gap: 16px !important;
  }

  .impact-grid > *,
  #volunteer-details .vol-icon-row > * {
    width: 100% !important;
    max-width: 280px !important;
  }

  .impact-grid .impact-icon,
  #volunteer-details .vol-icon-row img.vol-icon {
    width: 100% !important;
    max-width: 240px !important;
    height: auto !important;
    object-fit: contain;
  }

  #gifts-help,
  #gifts-help .how-we-help-image {
    width: 100% !important;
    max-width: 100% !important;
  }

  #gifts-help .how-we-help-image {
    height: auto !important;
  }

  #silent-facts > .container {
    gap: 16px !important;
  }

  .facts-grid,
  .stories-grid {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Preserve horizontal carousel movement while stacking each panel's contents. */
  .cards-carousel,
  .cards-carousel .carousel-viewport {
    width: 100%;
    max-width: 100%;
  }

  .cards-carousel .carousel-item {
    padding: 12px !important;
  }

  .p-card h3 {
    flex-direction: column !important;
    gap: 10px !important;
    font-size: 1.35rem !important;
  }

  .p-card h3 .icon {
    width: 64px !important;
    height: 64px !important;
  }

  .p-card p {
    font-size: 1rem !important;
    line-height: 1.6 !important;
  }

  /* How It Works hero and copy. */
  .hero.hero--compact {
    min-height: 220px !important;
    height: clamp(220px, 56vw, 320px) !important;
    max-height: 320px !important;
    padding: 0 !important;
  }

  .hero.hero--compact .hero-bg,
  .hero.hero--compact .hero-bg picture {
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
  }

  .hero.hero--compact .hero-bg img {
    inset: 0 0 auto 0 !important;
    width: 100% !important;
    height: 120% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover !important;
    object-position: center center !important;
  }

  #application-process,
  #application-process .section-body,
  #faq-qa {
    width: 100%;
    max-width: 100%;
  }

  #application-process .container,
  #application-process .section-body {
    display: flex !important;
    flex-direction: column !important;
  }

  #application-process ul {
    margin-left: 0;
    padding-left: 1.25rem;
  }

  #bottom-apply-cta {
    gap: 10px !important;
    padding: 32px 16px !important;
  }

  #faq-qa .faq-item summary {
    padding-right: 8px;
    white-space: normal;
  }

  /* About, Volunteer and Contact page-specific spacing. */
  .about-hero,
  .about-split,
  #rooted-in-hospitality-section,
  .contact-hero,
  .contact-grid,
  #volunteer-details {
    padding-top: 36px !important;
    padding-bottom: 36px !important;
  }

  .about-hero img,
  .about-split img,
  #founder-story-section img {
    width: 100%;
    height: auto !important;
  }

  #volunteer.volunteer-hero,
  #volunteer .volunteer-hero-inner {
    min-height: auto !important;
    height: auto !important;
  }

  #volunteer .volunteer-hero-inner {
    flex-direction: column !important;
    padding: 32px 16px !important;
  }

  .contact-form,
  .contact-form .field,
  .contact-form input,
  .contact-form textarea {
    width: 100% !important;
    max-width: 100% !important;
  }

  footer {
    padding-top: 36px;
    padding-bottom: 24px;
  }

  footer .footer-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 20px !important;
  }

  footer .footer-col,
  footer .footer-tax,
  footer .footer-bottom {
    width: 100%;
    max-width: 100%;
  }

  /* Keep the landing-page donation form compact above the mobile fold. */
  #home-hero .donate-box {
    width: 100% !important;
    max-width: 340px !important;
    padding: 12px !important;
    border-radius: 12px;
  }

  #home-hero .donate-box h2 {
    margin: 0 0 6px !important;
    font-size: 1.125rem !important;
    line-height: 1.25 !important;
  }

  #home-hero .toggle {
    gap: 6px !important;
    margin-bottom: 8px !important;
  }

  #home-hero .seg {
    height: 38px !important;
    min-height: 38px !important;
    padding: 0 6px !important;
    font-size: .875rem !important;
  }

  #home-hero .amounts {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px !important;
    margin: 8px 0 !important;
  }

  #home-hero .amt {
    height: 40px !important;
    min-height: 40px !important;
    padding: 0 6px !important;
    font-size: .95rem !important;
  }

  #home-hero .donate-box .other {
    display: none;
    margin-top: 4px !important;
  }

  #home-hero .donate-box.show-other .other {
    display: flex;
  }

  #home-hero .other input[type="number"] {
    height: 40px !important;
    min-height: 40px !important;
    font-size: 16px !important;
  }

  #home-hero .donate-actions {
    gap: 4px !important;
    margin-top: 8px !important;
  }

  #home-hero .donate-actions .btn {
    height: 42px !important;
    min-height: 42px !important;
    padding: 9px 14px !important;
  }

  #home-hero .donate-box small {
    font-size: .8125rem;
    line-height: 1.3;
  }
}
