/* Full-site mobile responsiveness — MUST load last */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  overflow-x: hidden;
  width: 100%;
}

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

.container,
.container-wide,
.ad-slot,
.ad-grid,
.spotlight,
.rail {
  width: min(100% - 1.25rem, var(--container));
  margin-inline: auto;
}

/* Force partners grid not locked by inline styles */
.partners-row {
  grid-template-columns: repeat(6, 1fr);
}

/* ========== Tablet ≤1100px ========== */
@media (max-width: 1100px) {
  .rail,
  .spotlight-grid,
  .ad-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  .partners-row {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  .hero-panel,
  .map-shell,
  .newsletter,
  .minister-block,
  .footer-grid,
  .contact-cta,
  .layout-sidebar {
    grid-template-columns: 1fr !important;
  }

  .hero-stats {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .overview-grid,
  .grid-3,
  .grid-4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .grid-2 {
    grid-template-columns: 1fr 1fr !important;
  }

  .minister-photo {
    min-height: 240px !important;
  }
}

/* ========== Mobile ≤960px ========== */
@media (max-width: 960px) {
  .top-bar-inner {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.5rem;
    padding-block: 0.55rem;
  }

  .top-meta {
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    font-size: 0.68rem;
  }

  .header-main {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem;
    min-height: auto !important;
    padding-block: 0.75rem !important;
  }

  .brand-group,
  .header-tools {
    width: 100%;
  }

  .header-tools {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
  }

  .header-search {
    display: flex !important;
    flex: 1 !important;
    width: auto !important;
    min-width: 0 !important;
  }

  .nav-toggle {
    display: inline-flex !important;
    flex-shrink: 0;
  }

  .nav-wrap {
    display: none !important;
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    max-width: 100%;
    z-index: 1200;
    background: #fff;
    border-inline-end: 1px solid var(--color-border, #d7e3db);
    box-shadow: -12px 0 40px rgba(15, 20, 25, 0.18);
    padding: 1rem 0 5.5rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-wrap.is-open {
    display: block !important;
  }

  .main-nav {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    gap: 0.25rem;
    padding: 0.5rem 1rem 1rem !important;
    overflow: visible !important;
  }

  .main-nav a {
    width: 100%;
    min-height: 48px;
    display: flex !important;
    align-items: center;
    padding: 0.75rem 1rem !important;
    font-size: 0.95rem !important;
    border-radius: 12px;
  }

  .home-hero {
    min-height: auto !important;
  }

  .home-hero-content {
    padding-block: 2.25rem 1.75rem !important;
    width: min(100% - 1rem, var(--container)) !important;
  }

  .home-hero h1,
  .home-hero h1 a {
    font-size: 1.15rem !important;
    max-width: 100% !important;
  }

  .home-hero .lede {
    font-size: 0.9rem !important;
  }

  .hero-actions {
    width: 100%;
    flex-direction: column;
  }

  .hero-actions .btn {
    width: 100%;
  }

  .hero-panel {
    grid-template-columns: 1fr !important;
    gap: 0.85rem;
    margin-top: 1rem;
  }

  .hero-stats {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem;
  }

  .hero-search-card {
    padding: 1rem !important;
  }

  /* ALL multi-column layouts → 1 column */
  .rail,
  .spotlight-grid,
  .ad-banner,
  .ad-grid,
  .partners-row,
  .overview-grid,
  .grid-2,
  .grid-3,
  .grid-4,
  .footer-grid,
  .minister-block,
  .newsletter,
  .contact-cta,
  .layout-sidebar,
  .map-shell,
  .project-meta {
    grid-template-columns: 1fr !important;
  }

  .rail {
    margin-top: 1rem !important;
    gap: 0.65rem;
    width: min(100% - 1rem, var(--container)) !important;
  }

  .rail-item a {
    grid-template-columns: 88px 1fr !important;
    padding: 0.65rem;
  }

  .rail-item img {
    width: 88px !important;
    height: 68px !important;
  }

  .section {
    padding-block: 2.25rem !important;
  }

  .section-head {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.85rem;
  }

  .section-head .btn {
    width: 100%;
  }

  .minister-photo {
    min-height: 200px !important;
  }

  .minister-content {
    padding: 1.15rem !important;
  }

  .ad-slot,
  .ad-grid,
  .spotlight {
    width: min(100% - 1rem, var(--container)) !important;
  }

  .ad-banner {
    min-height: 0 !important;
    padding: 1.1rem !important;
  }

  .ad-banner .ad-visual {
    justify-content: flex-start;
    order: -1;
    margin-bottom: 0.35rem;
  }

  .ad-banner .ad-visual img {
    max-height: 52px !important;
  }

  .ad-banner h3 {
    font-size: 1.05rem !important;
  }

  .ad-full img.ad-gif {
    height: clamp(210px, 50vw, 300px) !important;
  }

  .spotlight {
    margin: 1.25rem auto !important;
    padding: 1rem !important;
  }

  .spotlight-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .newsletter {
    padding: 1.35rem !important;
  }

  .newsletter-form {
    flex-direction: column !important;
  }

  .newsletter-form input,
  .newsletter-form .btn,
  .contact-cta .btn,
  .article-end .btn,
  .hero-actions .btn {
    width: 100% !important;
  }

  .contact-cta {
    padding: 1.15rem !important;
  }

  .page-hero {
    padding: 1.75rem 0 1.5rem !important;
  }

  .page-hero h1 {
    font-size: 1.25rem !important;
  }

  .card-body {
    padding: 1rem !important;
  }

  .btn {
    min-height: 44px;
  }

  .search-box {
    flex-wrap: wrap;
  }

  .search-box .btn {
    width: 100%;
  }

  .filter-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
  }

  .filter-bar .chip {
    flex: 0 0 auto;
  }

  .table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .alert {
    font-size: 0.85rem;
    line-height: 1.6;
  }

  .alert a {
    display: inline;
  }
}

/* ========== Phones ≤640px ========== */
@media (max-width: 640px) {
  .container,
  .container-wide,
  .ad-slot,
  .ad-grid,
  .spotlight,
  .rail {
    width: min(100% - 0.85rem, var(--container)) !important;
  }

  .brand-text span {
    display: none !important;
  }

  .brand-logo-img {
    width: 40px;
    height: 40px;
  }

  .brand-text strong {
    font-size: 0.9rem !important;
  }

  .top-actions {
    width: 100%;
  }

  .hero-stat {
    padding: 0.7rem;
  }

  .hero-stat strong {
    font-size: 0.95rem !important;
  }

  .hero-stat span {
    font-size: 0.62rem;
    line-height: 1.35;
  }

  .partners-row {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .ad-full img.ad-gif {
    height: 190px !important;
  }

  .article-top {
    padding: 1.5rem 0 1.25rem !important;
  }

  .article-top h1 {
    font-size: 1.1rem !important;
  }

  .article-deck {
    font-size: 0.88rem !important;
  }

  .article-prose {
    padding: 0.95rem !important;
  }

  .article-prose p {
    font-size: 0.94rem !important;
    line-height: 1.75 !important;
  }

  .article-featured {
    aspect-ratio: 16 / 10;
  }

  .article-tools .btn {
    flex: 1 1 calc(50% - 0.35rem);
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
  }

  .site-footer {
    margin-top: 2.5rem !important;
    padding-top: 2rem !important;
  }

  .cat-flow a {
    font-size: 0.78rem;
    padding: 0.45rem 0.75rem;
  }

  .service-tile,
  .overview-card,
  .stat-card {
    padding: 1rem !important;
  }

  .map-canvas {
    min-height: 260px !important;
  }
}

/* ========== Tiny phones ≤380px ========== */
@media (max-width: 380px) {
  .hero-stats {
    grid-template-columns: 1fr !important;
  }

  .main-nav a {
    padding: 0.5rem 0.7rem !important;
    font-size: 0.72rem !important;
  }

  .ad-full img.ad-gif {
    height: 160px !important;
  }
}

/* Safe areas */
@supports (padding: max(0px)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

/* ========== Mobile menu drawer + bottom bar ========== */
.nav-backdrop {
  display: none;
}

.bottom-nav {
  display: none;
}

@media (max-width: 960px) {
  body {
    padding-bottom: calc(4.25rem + env(safe-area-inset-bottom, 0px));
  }

  body.nav-open {
    overflow: hidden;
  }

  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(15, 20, 25, 0.45);
    border: 0;
    padding: 0;
    cursor: pointer;
  }

  .nav-backdrop[hidden] {
    display: none !important;
  }

  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1300;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    border-top: 1px solid #d7e3db;
    padding: 0.35rem 0.25rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 28px rgba(15, 20, 25, 0.08);
  }

  .bottom-nav a,
  .bottom-nav button {
    appearance: none;
    border: 0;
    background: transparent;
    color: #4a5a52;
    font: inherit;
    font-size: 0.68rem;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: 52px;
    padding: 0.25rem;
    text-decoration: none;
    border-radius: 12px;
    cursor: pointer;
  }

  .bottom-nav a.is-active,
  .bottom-nav button[aria-expanded="true"] {
    color: var(--color-primary-dark, #004d27);
    background: #eef7f1;
  }

  .bottom-nav .bn-ico {
    font-size: 1.05rem;
    line-height: 1;
  }
}

