/* Fit the home header, invitation and credits into the visible screen.
   The portrait grows or shrinks within the space left by the header and footer. */
@media (orientation: landscape) {
  body:has(#home-welcome:not([hidden])) > header.site-header {
    position: relative;
    padding-block: max(4px, env(safe-area-inset-top)) 4px;
  }

  body:has(#home-welcome:not([hidden])) > main {
    flex: 1 1 0;
    min-height: 0;
    overflow: visible;
  }

  body #home-welcome:not([hidden]) {
    display: grid !important;
    flex: 1 1 0;
    grid-template-columns: minmax(0, .75fr) minmax(0, 1.25fr);
    grid-template-rows: minmax(min-content, 1fr) minmax(min-content, 1fr);
    align-items: center;
    column-gap: clamp(12px, 4vw, 54px);
    row-gap: clamp(4px, 1.7dvh, 14px);
    width: min(100%, 1080px);
    min-height: 0;
    margin: 0 auto;
    padding: clamp(4px, 1.7dvh, 16px) max(16px, env(safe-area-inset-right))
      clamp(4px, 1.7dvh, 16px) max(16px, env(safe-area-inset-left));
  }

  body #home-welcome #welcome-title {
    grid-area: 1 / 2;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .12em .35em;
    justify-self: stretch;
    align-self: end;
    font-size: clamp(18px, min(3.7vw, 7dvh), 42px);
    line-height: 1.06;
    text-wrap: balance;
  }

  body #home-welcome #welcome-title > span {
    display: inline-block;
    margin: 0;
  }

  body #home-welcome .welcome-portrait-frame {
    grid-area: 1 / 1 / 3 / 2;
    justify-self: center;
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: min(72dvh, 520px);
  }

  body #home-welcome .welcome-invitation {
    grid-area: 2 / 2;
    display: block;
    align-self: start;
    width: 100%;
    max-width: 580px;
    margin-inline: auto;
  }

  body #home-welcome .welcome-intro {
    font-size: clamp(13px, min(2.15vw, 4.2dvh), 18px);
    line-height: 1.2;
    text-wrap: balance;
  }

  #home-welcome .welcome-prayers #prayer-start {
    padding-block: 3px;
    font-size: clamp(18px, min(3vw, 5.8dvh), 26px);
    text-align: center;
  }

  body #home-welcome .welcome-gathering {
    margin-top: 0;
  }

  #home-welcome .welcome-gathering p:nth-child(-n+2) {
    display: inline;
    font-size: clamp(12px, min(2.25vw, 4.15dvh), 17px);
    line-height: 1.15;
  }

  #home-welcome .welcome-gathering p:first-child {
    margin-inline-end: .4em;
  }

  #home-welcome .welcome-live {
    display: flex;
    width: fit-content;
    margin-inline: auto;
    min-height: 44px;
    padding-block: 3px;
    font-size: clamp(15px, min(2.5vw, 5dvh), 21px);
    line-height: 1.15;
  }

  #home-welcome .welcome-gathering .welcome-meet-note {
    font-size: clamp(11px, min(1.85vw, 3.5dvh), 15px);
    line-height: 1.2;
    text-wrap: balance;
  }

  body:has(#home-welcome:not([hidden])) > footer {
    padding: 4px max(12px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  body:has(#home-welcome:not([hidden])) > footer > p.site-attribution {
    font-size: clamp(10px, 1.65vw, 13px);
    line-height: 1.24;
  }
}

/* Keep all copy and both full-size tap targets visible with browser bars open. */
@media (orientation: landscape) and (max-height: 340px) {
  body #home-welcome:not([hidden]) {
    grid-template-columns: minmax(0, .56fr) minmax(0, 1.44fr);
    column-gap: clamp(10px, 2.8vw, 22px);
  }

  body #home-welcome .welcome-invitation {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.16fr);
    align-items: center;
    gap: 4px 10px;
  }

  body #home-welcome .welcome-intro {
    grid-area: 1 / 1 / 2 / -1;
  }

  body #home-welcome .welcome-prayers {
    grid-area: 2 / 1;
    margin: 0;
  }

  body #home-welcome .welcome-gathering {
    grid-area: 2 / 2;
  }

  body:has(#home-welcome:not([hidden])) > footer > p.site-attribution br {
    display: none;
  }

  body:has(#home-welcome:not([hidden])) > footer > p.site-attribution span {
    display: inline-block;
    margin-inline: .25em;
  }
}

@media (orientation: landscape) and (max-height: 275px) {
  body #home-welcome .welcome-gathering {
    display: contents;
  }

  body #home-welcome .welcome-gathering p:first-child {
    grid-area: 2 / 1;
    justify-self: end;
    margin: 0;
  }

  body #home-welcome .welcome-gathering p:nth-child(2) {
    grid-area: 2 / 2;
    justify-self: start;
  }

  body #home-welcome .welcome-prayers {
    grid-area: 3 / 1;
  }

  #home-welcome .welcome-prayers #prayer-start {
    font-size: clamp(16px, 2.85vw, 18px);
  }

  #home-welcome .welcome-gathering .welcome-live {
    grid-area: 3 / 2;
  }

  #home-welcome .welcome-gathering .welcome-meet-note {
    grid-area: 4 / 1 / 5 / -1;
    margin: 0;
  }
}
