/* ==========================================================================
   COMPREHENSIVE MOBILE RESPONSIVE ENGINE (responsive.css)
   Optimized sitewide for all mobile devices (320px - 768px), tablets & desktops
   ========================================================================== */

/* 1. Global Container & Overflow Control */
html, body {
  overflow-x: hidden !important;
  width: 100% !important;
  max-width: 100vw !important;
}

@media (max-width: 768px) {
  :root {
    --container-padding-x: 0.85rem;
    --section-padding-y: 2.25rem;
  }

  .container {
    padding-left: 0.85rem !important;
    padding-right: 0.85rem !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .section {
    padding-top: 2rem !important;
    padding-bottom: 2rem !important;
    overflow-x: hidden !important;
  }

  /* Section Headings on Mobile */
  .section-heading {
    margin-bottom: 1.5rem !important;
  }

  .section-heading h2 {
    font-size: clamp(1.3rem, 5vw, 1.7rem) !important;
    line-height: 1.25 !important;
  }

  .section-heading__subtitle {
    font-size: 0.85rem !important;
    line-height: 1.5 !important;
  }

  .flourish {
    width: 36px !important;
    height: 12px !important;
  }

  /* Text & Image Safety */
  p, h1, h2, h3, h4, h5, h6, span, a {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  img, video, iframe, canvas {
    max-width: 100% !important;
    height: auto !important;
  }
}

/* 2. Responsive Hero Section (Mobile < 768px) */
@media (max-width: 768px) {
  .hero {
    height: auto !important;
    min-height: 420px !important;
    padding-top: 1.5rem !important;
    padding-bottom: 3rem !important;
    background-position: center center !important;
  }

  .hero__overlay {
    background: linear-gradient(180deg, rgba(253, 246, 233, 0.96) 0%, rgba(253, 246, 233, 0.88) 60%, rgba(253, 246, 233, 0.7) 100%) !important;
  }

  .arch-hero-panel {
    max-width: 100% !important;
    padding: 1.4rem 1.1rem 1.1rem !important;
    border-radius: 36px 36px 12px 12px !important;
    margin: 0 auto !important;
    text-align: center !important;
  }

  .arch-hero-panel::before {
    top: -8px !important;
    width: 14px !important;
    height: 14px !important;
  }

  .hero__headline {
    font-size: clamp(1.4rem, 5.2vw, 1.8rem) !important;
    line-height: 1.22 !important;
    margin-bottom: 0.65rem !important;
  }

  .hero__subtext {
    font-size: 0.82rem !important;
    line-height: 1.5 !important;
    margin-bottom: 1.15rem !important;
    max-width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  .hero__actions {
    flex-direction: column !important;
    width: 100% !important;
    gap: 0.5rem !important;
  }

  .hero__btn {
    width: 100% !important;
    justify-content: center !important;
    padding: 0.6rem 0.85rem !important;
    font-size: 0.78rem !important;
    height: 40px !important;
  }

  .hero-short {
    padding: 1.35rem 0 1.6rem !important;
  }

  .hero-short__title {
    font-size: 1.35rem !important;
  }
}

/* 3. Header, Utility Bar & Mobile Actions Engine */
@media (max-width: 768px) {
  .utility-bar {
    padding: 0.3rem 0.5rem !important;
  }

  .utility-bar__inner {
    flex-wrap: wrap !important;
    gap: 0.35rem !important;
    justify-content: center !important;
  }

  .utility-bar__info {
    gap: 0.5rem !important;
  }

  .utility-bar__item {
    font-size: 0.68rem !important;
  }

  .site-header__inner {
    height: 56px !important;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  .site-logo img {
    max-height: 38px !important;
    width: auto !important;
  }

  .header-actions {
    gap: 0.4rem !important;
  }

  .lang-switch {
    padding: 1.5px !important;
    border-width: 1px !important;
  }

  .lang-switch__option {
    padding: 0.18rem 0.45rem !important;
    font-size: 0.68rem !important;
  }

  .header-donate-btn {
    padding: 0.35rem 0.65rem !important;
    font-size: 0.68rem !important;
    letter-spacing: 0.02em !important;
  }

  .mobile-nav-trigger {
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
  }
}

@media (max-width: 480px) {
  .utility-bar__info span:first-child {
    display: none !important; /* Hide address line on smallest screens */
  }

  .site-header__inner {
    height: 52px !important;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }

  .site-logo img {
    max-height: 34px !important;
  }

  .header-actions {
    gap: 0.28rem !important;
  }

  .lang-switch__option {
    padding: 0.15rem 0.38rem !important;
    font-size: 0.65rem !important;
  }

  .header-donate-btn {
    padding: 0.3rem 0.5rem !important;
    font-size: 0.65rem !important;
  }

  .mobile-nav-trigger {
    width: 34px !important;
    height: 34px !important;
  }
}

/* 4. Grid Adaptations & Card Layouts */
@media (max-width: 768px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr !important;
    gap: 1.15rem !important;
  }

  /* 4-Metric Bar in Who We Are Section */
  .stat-grid-mini,
  div[style*="grid-template-columns: repeat(4, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
    padding: 0.65rem 0.4rem !important;
  }

  /* Heritage Frame Images on Mobile */
  .heritage-frame img {
    height: 220px !important;
  }

  /* Photo Stack V2 Safety Fix */
  .photo-stack-v2 {
    max-width: 100% !important;
    margin: 0 auto !important;
    overflow: visible !important;
  }

  .photo-stack-v2__inset {
    width: 46% !important;
    top: -8px !important;
    right: 0 !important;
  }

  .photo-stack-v2__badge {
    left: 0 !important;
    bottom: -12px !important;
    padding: 0.45rem 0.85rem !important;
    font-size: 0.72rem !important;
  }
}

@media (max-width: 576px) {
  /* What We Do 6-Card Grid on Small Mobile */
  .what-we-do-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.55rem !important;
  }

  .arch-card {
    padding: 1.1rem 0.4rem 0.75rem !important;
    min-height: 155px !important;
    border-radius: 46px 46px 8px 8px !important;
  }

  .arch-card__title {
    font-size: 0.76rem !important;
    line-height: 1.25 !important;
  }

  .arch-card__icon-wrap {
    width: 36px !important;
    height: 36px !important;
    margin-bottom: 0.3rem !important;
  }

  .arch-card__icon-wrap svg {
    width: 18px !important;
    height: 18px !important;
  }

  /* Impact Stat Band on Small Mobile */
  .impact-band__grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.55rem !important;
  }

  /* 5th Stat Card Centered on 2-Column Grid */
  .impact-band__grid .arch-card--stat:nth-child(5) {
    grid-column: span 2 !important;
    max-width: 200px !important;
    margin: 0 auto !important;
    width: 100% !important;
  }

  .arch-card--stat {
    min-height: 145px !important;
    padding: 1.1rem 0.4rem 0.65rem !important;
  }

  .arch-card--stat .stat-number {
    font-size: 1.2rem !important;
  }

  .arch-card--stat .stat-label {
    font-size: 0.68rem !important;
  }

  /* Gallery Preview 6-Grid on Small Mobile */
  div[style*="grid grid-3"][style*="gap: 1.25rem"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.55rem !important;
  }

  div[style*="grid grid-3"][style*="gap: 1.25rem"] img {
    height: 115px !important;
  }

  /* Get Involved 4-Icon Band on Mobile */
  .get-involved-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.55rem !important;
  }

  .get-involved-card {
    padding: 0.85rem 0.4rem !important;
  }

  .get-involved-card__icon svg {
    width: 22px !important;
    height: 22px !important;
  }

  .get-involved-card__title {
    font-size: 0.72rem !important;
  }

  .get-involved-card__sub {
    font-size: 0.65rem !important;
  }

  /* Filter Bar & Chips on Mobile */
  .filter-bar {
    gap: 0.35rem !important;
    margin-bottom: 1.5rem !important;
  }

  .filter-chip {
    padding: 0.35rem 0.75rem !important;
    font-size: 0.72rem !important;
  }

  /* Gallery Grid on Mobile */
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.55rem !important;
  }
}

/* 5. Mobile Menu Drawer */
.mobile-nav-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 85vw;
  max-width: 320px;
  background-color: #8D1E1E;
  color: #FDF6E9;
  z-index: 9999;
  padding: 1.25rem 1rem;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.35);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
}

.mobile-nav-drawer.is-open {
  transform: translateX(0) !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.mobile-nav-drawer__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.mobile-nav-drawer__link {
  display: block;
  padding: 0.65rem 0.5rem;
  color: #FDF6E9;
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(253, 246, 233, 0.1);
  transition: color 0.2s ease;
}

.mobile-nav-drawer__link.is-active,
.mobile-nav-drawer__link:hover {
  color: #F5C768;
  font-weight: 700;
}

/* 6. Upgraded Footer Responsive Grid */
@media (max-width: 768px) {
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 1.75rem !important;
  }

  .site-footer__main {
    padding-top: 2rem !important;
    padding-bottom: 1.75rem !important;
  }

  .site-footer__bottom-inner {
    flex-direction: column !important;
    gap: 0.65rem !important;
    text-align: center !important;
  }

  .footer-legal-links {
    justify-content: center !important;
    gap: 0.85rem !important;
  }
}

/* 7. Form Fields, Touch Targets & Tables */
@media (max-width: 768px) {
  input, select, textarea, button, .btn {
    font-size: 16px !important; /* Prevents auto-zoom on iOS safari */
  }

  .form-field input,
  .form-field select,
  .form-control {
    min-height: 42px !important;
  }

  .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
  }

  table {
    width: 100%;
    min-width: 480px;
  }
}

/* Target standalone action buttons for touch accessibility */
@media (pointer: coarse) {
  button.btn, a.btn, .mobile-nav-trigger {
    min-height: 44px;
  }
}

/* 8. Print Stylesheet */
@media print {
  .site-header, .site-footer, .utility-bar, .mobile-nav-trigger, .btn {
    display: none !important;
  }
  body {
    background: #FFFFFF !important;
    color: #000000 !important;
  }
}
