/* ==========================================
   SR&C — Responsive design refinements
   Loaded after site.css and pages.css
   ========================================== */


/* ---------- Fluid layout foundation ---------- */

:root {
  --gutter: clamp(16px, 3.5vw, 72px);
  --max: clamp(1200px, 88vw, 1800px);
}

body {
  font-size: 1rem;
  font-size: clamp(1rem, 0.9rem + 0.2vw, 1.2rem);
  overflow-wrap: break-word;
}

.wrap {
  width: 100%;
  max-width: var(--max);
}

.wrap > *,
article,
figure,
.form-field {
  min-width: 0;
}

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

input,
select,
textarea,
fieldset {
  min-width: 0;
  max-width: 100%;
}

.btn {
  max-width: 100%;
  text-align: center;
  line-height: 1.3;
}

.section-title {
  font-size: clamp(2rem, 1.4rem + 2vw, 4rem);
}


/* ---------- Responsive navigation ---------- */

.header-inner {
  gap: clamp(12px, 2vw, 32px);
}

.header-inner,
.hero-brand-bar {
  min-height: 72px;
}

.brand,
.hero-clean .hero-logo {
  width: clamp(150px, 15vw, 220px);
}

.brand {
  flex-shrink: 0;
  max-width: 55%;
}

.site-nav {
  gap: clamp(12px, 1.8vw, 32px);
}

.site-nav a {
  font-size: clamp(0.9rem, 0.8rem + 0.15vw, 1.15rem);
  white-space: nowrap;
}

/* Switch to the existing mobile menu before
   the desktop navigation gets cramped. */

@media (max-width: 64em) {

  .js .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    margin: 0;
    padding: 12px var(--gutter) 18px;
    background: #fff;
    box-shadow: 0 12px 20px rgba(14, 36, 64, 0.12);

    max-height: calc(100vh - 72px);
    max-height: calc(100dvh - 72px);
    overflow-y: auto;
  }

  .js .site-nav.is-open {
    display: flex;
  }

  @media (prefers-reduced-motion: no-preference) {
    .js .site-nav.is-open { animation: mobile-nav-in var(--interaction-duration) var(--ease); }
  }

  .js .site-nav a:not(.nav-cta) { transition: background-color var(--interaction-duration); }
  .js .site-nav a:not(.nav-cta):is(:hover, :focus-visible, :active) { background-color: var(--mist); }

  .js .menu-toggle {
    display: inline-flex;
    margin-left: auto;
  }

  .js .site-nav a,
  .js .site-nav a:not(.nav-cta) {
    display: block;
    padding: 12px 10px;
    color: var(--navy);
    white-space: normal;
  }

  .site-nav a::after {
    display: none;
  }

}

/* Usable navigation even without JavaScript. */

@media (max-width: 64em) {

  .no-js .site-header {
    position: relative;
  }

  .no-js .header-inner {
    flex-wrap: wrap;
  }

  .no-js .site-nav {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .no-js .site-nav a {
    color: var(--navy);
    white-space: normal;
  }

}


@keyframes mobile-nav-in {
  from { opacity: 0.6; transform: translateY(-4px); }
}

/* ---------- Interior page heroes ---------- */

.page-hero {
  height: auto;
  min-height: clamp(300px, 44vh, 520px);
  padding-top: clamp(108px, 15vh, 180px);
  padding-bottom: clamp(36px, 6vh, 90px);
}

.page-hero h1 {
  font-size: clamp(2.2rem, 1.3rem + 3.5vw, 6rem);
}

.page-deck {
  font-size: clamp(1rem, 0.9rem + 0.4vw, 1.5rem);
  max-width: 58ch;
}

.island-hero {
  min-height: clamp(320px, 55vh, 650px);
}

@media (max-height: 500px) {

  .page-hero {
    min-height: 0;
    padding-top: 110px;
    padding-bottom: 36px;
  }

}


/* ---------- Automatically adapting grids ---------- */

/* Columns are determined by available space,
   not the visitor's device model. */

.pillars,
.pilot-list,
.mission-pillars,
.island-community-grid {
  grid-template-columns:
    repeat(auto-fit, minmax(min(100%, 240px), 1fr));

  gap: clamp(18px, 3vw, 40px);
}

.island-program-grid,
.involvement-grid,
.impact-cards {
  grid-template-columns:
    repeat(auto-fit, minmax(min(100%, 215px), 1fr));

  gap: clamp(14px, 2vw, 28px);
}

.founder-cards,
.before-after-grid {
  grid-template-columns:
    repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

.island-facts {
  grid-template-columns:
    repeat(auto-fit, minmax(min(100%, 180px), 1fr));
}

.island-fact {
  border: 0;
}

.island-fact + .island-fact {
  border-left: 0;
}

.island-fact:nth-child(n) {
  border-top: 0;
}

.island-fact strong {
  overflow-wrap: anywhere;
}

/* Cards should expand with their content. */

.work-detail-card,
.involvement-card,
.impact-card {
  min-height: 0;
}

.island-program-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}


/* ---------- Two-column content sections ---------- */

.home-intro-grid,
.home-work-grid,
.mission-grid,
.islands-grid,
.story-grid,
.faq-grid,
.jobs-model-grid,
.in-kind-inner,
.island-teaser-inner,
.island-origin-grid,
.pillar-page-inner {
  grid-template-columns:
    repeat(auto-fit, minmax(min(100%, 320px), 1fr));

  gap: clamp(24px, 4vw, 72px);
}

.island-origin-figure img {
  width: 100%;
  max-height: 540px;
  object-fit: cover;
}


/* ---------- Interactive map ---------- */

.island-map-card {
  min-width: 0;
}

.island-map {
  width: 100%;
  height: clamp(260px, 45vh, 620px);
}

.island-map-header {
  flex-wrap: wrap;
}

.island-map-controls {
  max-width: 100%;
  flex-wrap: wrap;
}

.island-map-button {
  flex: 1 1 auto;
  white-space: normal;
}

@media (max-height: 450px) {

  .island-map {
    height: 260px;
  }

}


/* ---------- Forms ---------- */

.inquiry-layout {
  grid-template-columns:
    repeat(auto-fit, minmax(min(100%, 340px), 1fr));
}

.form-two-col,
.checkbox-grid {
  grid-template-columns:
    repeat(auto-fit, minmax(min(100%, 200px), 1fr));
}

.inquiry-form {
  padding: clamp(16px, 3vw, 34px);
}

.inquiry-aside {
  overflow-wrap: anywhere;
}

@media (max-width: 64em), (max-height: 650px) {

  .inquiry-aside {
    position: static;
  }

}


/* ---------- Floating contact and donate panels ---------- */

.contact-panel {
  left: 12px;
  left: max(12px, env(safe-area-inset-left));
  bottom: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  max-width: calc(100% - 24px);
}

.contact-panel-body {
  max-height: min(480px, calc(100vh - 110px));
  max-height: min(480px, calc(100dvh - 110px));
  overflow-y: auto;
  overflow-wrap: anywhere;
}

.donate-panel {
  max-width: 100%;
  padding-left: clamp(16px, 4vw, 32px);
  padding-right: clamp(16px, 4vw, 32px);
  overflow-y: auto;
}

.donate-close {
  width: 44px;
  height: 44px;
}

.donate-amounts {
  grid-template-columns:
    repeat(auto-fit, minmax(min(100%, 110px), 1fr));
}

@media (max-width: 699px) {

  .contact-panel summary {
    padding: 10px 12px;
    gap: 6px;
  }

  .donate-tab {
    right: 12px;
    padding: 12px 16px;
  }

}

@media (max-width: 300px) {

  .contact-panel {
    bottom: 76px;
  }

}


/* ---------- Older browser fallback ---------- */

@supports not (width: min(100%, 240px)) {

  .pillars,
  .pilot-list,
  .mission-pillars,
  .work-detail-grid,
  .island-community-grid,
  .island-program-grid,
  .involvement-grid,
  .impact-cards,
  .island-facts,
  .inquiry-layout,
  .form-two-col,
  .checkbox-grid,
  .footer-top {
    grid-template-columns: 1fr;
  }

}


/* ---------- Reduced motion accessibility ---------- */

@media (prefers-reduced-motion: reduce) {

  .hero,
  .hero-content,
  .site-nav,
  .contact-panel {
    scroll-behavior: auto;
    transition: none;
  }

}

/* ---------- Extra-wide viewport scaling ---------- */

@media (min-width: 2200px) {

  :root {
    --max: 88vw;
    --gutter: 4vw;
  }

  body {
    font-size: clamp(1.2rem, 1.1vw, 5rem);
  }

  .header-inner,
  .hero-brand-bar {
    min-height: 5vw;
  }

  .site-nav {
    gap: 2vw;
  }

  .site-nav a {
    font-size: 1.1vw;
  }

  .site-nav .nav-cta {
    padding: 0.8vw 1.4vw;
  }

  .section-title {
    font-size: 3.5vw;
  }

}
