/* Safari may extend the page canvas color into its own control areas.
   Match both document backgrounds, while retaining the paper within the site. */
html, body { background-color: var(--navy); }
body > main { background-color: var(--paper); }

/* Wide handhelds: keep the narrow phone and regular desktop layouts unchanged.
   The second band catches short landscape viewports just past the tablet break.
   Safari owns the browser chrome and hardware safe areas; nothing is drawn under them. */
@media (min-width: 620px) and (max-width: 900px),
       (min-width: 900px) and (max-width: 980px) and (max-height: 660px) {
  :root {
    --wide-mobile-gutter: clamp(1.75rem, 5vw, 3rem);
    --wide-mobile-header: 78px;
  }

  .site-header { height: var(--wide-mobile-header); padding-inline: var(--wide-mobile-gutter); }
  .site-header:not([data-nav-ready]) { min-height: var(--wide-mobile-header); }
  .hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(min-content, 1fr) auto;
    row-gap: clamp(1.25rem, 3vh, 2rem);
    height: auto;
    max-height: none;
    min-height: calc(100vh - var(--wide-mobile-header));
    min-height: calc(100svh - var(--wide-mobile-header));
    min-height: calc(100dvh - var(--wide-mobile-header));
    padding: clamp(2rem, 5vh, 3.75rem) var(--wide-mobile-gutter) clamp(1.5rem, 4vh, 2.75rem);
  }
  .hero-content {
    align-self: center;
    width: 100%;
    max-width: 42rem;
    margin: 0;
    padding: 0;
  }
  .hero h1 { max-width: 15ch; font-size: clamp(3.4rem, 8vw, 5.1rem); text-wrap: balance; }
  .hero-actions { flex-wrap: wrap; gap: 0.875rem clamp(1rem, 3vw, 1.75rem); }
  .hero-actions .button { min-height: 48px; }
  .hero-actions .text-link { display: inline-flex; align-items: center; min-height: 44px; }
  .hero > img { object-position: 66% center; }
  .hero-shade {
    background: linear-gradient(0deg, rgba(3, 13, 25, .58), transparent 30%),
                linear-gradient(90deg, rgba(3, 13, 25, .95) 0%, rgba(4, 15, 28, .7) 47%, rgba(4, 15, 28, .32) 100%);
  }
  /* Keep the verse in the layout, so small heights and larger text cannot make
     it overlap the buttons. The photo still fills the entire hero. */
  .hero > .verse {
    position: relative;
    inset: auto;
    align-self: end;
    width: 100%;
    max-width: 29rem;
    text-align: left;
  }

  .section { padding: clamp(3.25rem, 7vw, 5rem) var(--wide-mobile-gutter); }
  .welcome { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1rem clamp(1.125rem, 3vw, 2rem); }
  .welcome .section-label { grid-column: 1 / -1; margin-bottom: 0; }
  .welcome .scripture-card { margin-top: 0; padding: clamp(1rem, 2.6vw, 1.6rem); }
  .beliefs { grid-template-columns: minmax(0, 1fr); gap: clamp(1.5rem, 4vw, 2.75rem); }
  .belief-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .belief-grid article { padding: clamp(1.125rem, 3vw, 1.75rem); }
  .folder-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.35rem;
    padding-left: 0;
  }
  .folder-tabs button { min-width: 0; padding-inline: 0.375rem; letter-spacing: 0.06em; }
  .visit-card, .kids-card { padding: clamp(1.5rem, 4.5vw, 3.5rem); }
  .kids-schedule { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kids-program-heading { flex-direction: column; gap: 0.25rem; }
}

@media (min-width: 800px) and (max-width: 900px) and (max-height: 660px),
       (min-width: 900px) and (max-width: 980px) and (max-height: 660px) {
  .hero {
    padding-block: clamp(1.375rem, 4vh, 2.5rem);
    row-gap: 0.875rem;
  }
  .hero h1 { max-width: 18ch; font-size: clamp(3.4rem, 6.5vw, 4.5rem); }
  .hero-actions { margin-top: 1.25rem; }
  .visit-verse-actions { flex-flow: row wrap; }
  #info-panel { grid-template-columns: minmax(0, 1.8fr) minmax(0, 0.68fr); }
}

/* The folded display and side-by-side tabs have unusually short content
   viewports. Let hero content use the available height naturally instead of
   reserving a 710px mobile poster with its controls below the first screen. */
@media (min-width: 340px) and (max-width: 450px) and (max-height: 660px),
       (min-width: 500px) and (max-width: 619px) and (max-height: 460px) {
  .hero {
    --compact-header: 78px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(min-content, 1fr) auto;
    row-gap: 0.75rem;
    height: auto;
    max-height: none;
    min-height: calc(100vh - var(--compact-header));
    min-height: calc(100svh - var(--compact-header));
    min-height: calc(100dvh - var(--compact-header));
    padding: clamp(1.125rem, 3vh, 1.75rem) 1rem;
  }
  .hero-content { align-self: center; width: 100%; max-width: none; margin: 0; padding: 0; }
  .hero .eyebrow { margin: 0 0 0.4rem; letter-spacing: 0.18em; }
  .hero h1 { font-size: clamp(2.45rem, 11vw, 3.2rem); line-height: 1; margin: 0.5rem 0 0.8rem; text-wrap: balance; }
  .hero-copy { margin: 0.75rem 0 0; line-height: 1.48; }
  .hero-actions { max-width: none; margin-top: 1.1rem; gap: 0.4rem; }
  .visit-verse-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
  .hero-actions .button {
    min-height: 48px;
    min-width: 0;
    padding: 0.65rem 0.35rem;
    justify-content: center;
    text-align: center;
    letter-spacing: 0.045em;
    white-space: normal;
  }
  .hero-actions .text-link { display: inline-flex; align-items: center; min-height: 44px; }
  .hero > .verse {
    position: relative;
    inset: auto;
    align-self: end;
    width: 100%;
    max-width: 29rem;
    margin: 0;
    text-align: left;
    line-height: 1.38;
  }
}

/* Keep every primary action reachable in the very short folded landscape.
   Rows may wrap and the hero can grow when text is enlarged. */
@media (min-width: 500px) and (max-width: 619px) and (max-height: 460px) {
  .site-header { height: 64px; }
  .site-header:not([data-nav-ready]) { min-height: 64px; }
  .site-header nav { max-height: calc(100vh - 80px); max-height: calc(100dvh - 80px); }
  .hero { --compact-header: 64px; padding-block: 0.875rem; row-gap: 0.5rem; }
  .hero h1 { font-size: clamp(2rem, 6.2vw, 2.8rem); max-width: none; margin: 0.45rem 0 0.6rem; }
  .hero-copy { font-size: 1rem; margin-top: 0.4rem; }
  /* The short landscape text crosses the brighter window and book; darken
     those edges enough to retain the established white-on-navy readability. */
  .hero-shade {
    background: linear-gradient(0deg, rgba(3, 13, 25, .5), transparent 30%),
                linear-gradient(90deg, rgba(3, 13, 25, .95) 0%, rgba(4, 15, 28, .74) 58%, rgba(4, 15, 28, .42) 100%);
  }
  .hero-actions { flex-direction: row; align-items: center; flex-wrap: wrap; margin-top: 0.875rem; gap: 0.5rem; }
  .visit-verse-actions { display: flex; flex-flow: row wrap; }
  .hero-actions .button { padding-inline: 0.875rem; }
  .hero > .verse { font-size: 0.9rem; }
}
