* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  --background: #F3EEE7;
  --sections: #EAE1D6;
  --surface: #F8F4EF;
  --lines: #D8CEC2;
  --shadow: #BEB3A7;
  --accent: #C9AB87;
  --accent-active: #B8926C;
  --script: #9B8169;
  --text: #5F4E40;
  --muted: #8A7562;
  --highlight: #9FA58D;
  --icon-stroke: 1.4;
  --sans: Poppins, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --serif: "Cormorant Garamond", Georgia, serif;
  --hand: Corinthia, "Segoe Script", cursive;
  --header-height: clamp(130px, 16dvh, 170px);
  --footer-padding-y: 4px;
  --footer-padding-x: 10px;
  --footer-gap: 24px;
  --footer-min-height: clamp(70px, 7.8dvh, 86px);
  --footer-max-height: clamp(124px, 14dvh, 150px);
  height: 100dvh;
  max-height: 100dvh;
  display: grid;
  grid-template-rows: var(--header-height) minmax(0, 1fr) fit-content(var(--footer-max-height));
  font-family: var(--sans);
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(243, 238, 231, 0.88) 0%, rgba(243, 238, 231, 0.48) 48%, rgba(243, 238, 231, 0.08) 100%),
    url("/assets/img/background.webp");
  background-size: cover;
  background-position: right center;
  background-repeat: no-repeat;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background: rgba(248, 244, 239, 0.28);
  pointer-events: none;
}

.page-header,
.page-content,
.page-footer {
  position: relative;
  z-index: 1;
  width: 100%;
}

.page-header {
  min-height: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 20px;
}

.header-logo {
  display: block;
  width: auto;
  height: 90%;
  filter: brightness(0) saturate(100%) invert(40%) sepia(13%) saturate(922%) hue-rotate(348deg) brightness(95%) contrast(88%);
}

.page-content {
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.content-layout {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
}

.verse-box,
.stream-box {
  width: 100%;
  min-height: 0;
}

.verse-box {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 24px;
  overflow: hidden;
  /*background: #f8e08e;*/
}

.verse-inner {
  position: relative;
  z-index: 1;
  font-family: var(--serif);
  font-size: clamp(17px, min(2.7dvh, 3vw), 30px);
  line-height: 1.1;
  font-weight: 500;
  color: var(--text);
  opacity: 1;
  transition: opacity 1500ms ease;
}

.verse-inner.is-measuring {
  opacity: 0;
}

.verse-inner.is-visible {
  opacity: 1;
}

.verse-text {
  margin: 0;
  white-space: pre-line;
}

.verse-rule {
  display: block;
  width: 48px;
  height: 1.5px;
  margin: 10px 0 12px;
  background: var(--script);
}

.verse-ref {
  margin: 0;
  font-family: var(--sans);
  font-size: clamp(11px, min(1.5dvh, 1.2vw), 14px);
  font-weight: 600;
  line-height: 1;
  text-transform: uppercase;
  color: var(--muted);
}

.verse-box.is-hidden {
  display: none;
}

.stream-box {
  display: grid;
  place-items: center;
  /*background: #b8f2c2;*/
}

.stream-placeholder {
  display: grid;
  justify-items: center;
  gap: 16px;
  transform: translateY(-8dvh);
}

.stream-button,
.stream-offline-state {
  width: clamp(80px, 9dvh, 110px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 0;
  background: #c9ab87;
  color: #fff;
}

.stream-button {
  position: relative;
  padding: 0;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.stream-button:hover {
  background: var(--accent-active);
  transform: scale(1.025);
}

.stream-button:focus-visible {
  outline: 3px solid var(--highlight);
  outline-offset: 5px;
}

.stream-button[hidden],
.stream-offline-state[hidden] {
  display: none;
}

.stream-icon {
  width: 46%;
  height: 46%;
  color: inherit;
  fill: none;
  stroke: currentColor;
  stroke-width: var(--icon-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stream-icon-play,
.stream-icon-pause {
  position: absolute;
  inset: 27%;
  width: 46%;
  height: 46%;
  transition: opacity 140ms ease, transform 160ms ease;
}

.stream-icon-play {
  opacity: 1;
  transform: scale(1);
}

.stream-icon-pause {
  opacity: 0;
  transform: scale(0.75);
}

.stream-button.is-playing .stream-icon-play {
  opacity: 0;
  transform: scale(0.75);
}

.stream-button.is-playing .stream-icon-pause {
  opacity: 1;
  transform: scale(1);
}

.stream-placeholder p {
  margin: 0;
  font-family: var(--sans);
  font-size: clamp(13px, 1.3dvh, 17px);
  font-weight: 500;
  color: var(--text);
}

@media (orientation: landscape) {
  .stream-box {
    grid-column: 2;
    grid-row: 1;
    width: min(420px, 34vw);
  }

  .verse-box {
    grid-column: 1;
    grid-row: 1;
    padding-bottom: clamp(40px, 8dvh, 90px);
  }
}

.page-footer {
  min-height: 0;
  display: grid;
  place-items: center;
  min-height: var(--footer-min-height);
  max-height: var(--footer-max-height);
  padding: var(--footer-padding-y) var(--footer-padding-x);
  background: rgba(248, 244, 239, 0.78);
  border-top: 1px solid rgba(216, 206, 194, 0.82);
  backdrop-filter: blur(2px);
}

.footer-layout {
  width: min(100%, 900px);
  height: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: max-content;
  gap: var(--footer-gap);
  align-items: start;
}

.footer-box {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  justify-content: center;
  gap: 18px;
  padding: clamp(7px, 0.9dvh, 10px) 28px;
  color: var(--text);
}

.footer-box + .footer-box {
  border-left: 1px solid rgba(216, 206, 194, 0.9);
}

.footer-icon {
  width: clamp(42px, 5.2dvh, 54px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--script);
  background: rgba(234, 225, 214, 0.92);
}

.footer-icon svg {
  width: 52%;
  height: 52%;
  fill: none;
  stroke: currentColor;
  stroke-width: var(--icon-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.footer-text {
  min-width: 0;
}

.footer-events-content {
  min-width: 0;
  width: max-content;
  max-width: 100%;
  display: block;
}

.footer-text p {
  margin: 0;
  font-size: clamp(13px, 1.2dvh, 17px);
  font-family: var(--sans);
  line-height: 1.35;
  color: var(--text);
}

.footer-text p + p {
  margin-top: 5px;
}

.footer-text strong {
  font-weight: 500;
  color: var(--text);
}

.footer-event-title,
.footer-event-description,
.footer-event-location,
.footer-event-meta,
.footer-location-title,
.footer-location-address {
  display: block;
}

.footer-event-description {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 1px;
  font-size: 0.88em;
  line-height: 1.25;
  color: var(--muted);
}

.footer-event-meta {
  margin-top: 2px;
}

.footer-location-address {
  margin-top: 2px;
}

.footer-event-location {
  margin-top: 1px;
  font-size: 0.9em;
  font-weight: 500;
  color: var(--muted);
}

.footer-more-text,
.footer-subtle-link {
  appearance: none;
  display: block;
  margin: 7px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: clamp(11px, 1dvh, 13px);
  line-height: 1.1;
  font-weight: 400;
  text-align: left;
  color: rgba(138, 117, 98, 0.62);
  cursor: pointer;
  text-decoration: none;
}

.footer-more-text:hover,
.footer-more-text:focus-visible,
.footer-subtle-link:hover,
.footer-subtle-link:focus-visible {
  color: var(--muted);
}

.footer-more-text:focus-visible,
.footer-subtle-link:focus-visible {
  outline: 2px solid rgba(159, 165, 141, 0.75);
  outline-offset: 3px;
}

.events-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: min(620px, calc(100dvh - 40px));
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(216, 206, 194, 0.95);
  border-radius: 8px;
  color: var(--text);
  background: rgba(248, 244, 239, 0.94);
  box-shadow: 0 18px 48px rgba(95, 78, 64, 0.2);
  backdrop-filter: blur(6px);
}

.events-dialog::backdrop {
  background: rgba(95, 78, 64, 0.18);
}

.events-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: clamp(24px, 4dvh, 42px) clamp(28px, 4.5vw, 56px) 10px;
}

.events-dialog-header h2 {
  margin: 0;
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.2;
  font-weight: 500;
  color: var(--text);
}

.events-dialog-close {
  width: 36px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(216, 206, 194, 0.85);
  border-radius: 50%;
  color: var(--script);
  background: rgba(234, 225, 214, 0.72);
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(159, 165, 141, 0.35);
}

.events-dialog-close:focus-visible {
  outline: 2px solid var(--highlight);
  outline-offset: 3px;
}

.events-dialog-close svg {
  width: 50%;
  height: 50%;
  stroke-width: var(--icon-stroke);
}

.events-dialog-list {
  max-height: min(550px, calc(100dvh - 112px));
  overflow: auto;
  padding: 0 clamp(28px, 4.5vw, 56px) clamp(28px, 4dvh, 42px);
}

.events-dialog-section {
  min-width: 0;
}

.events-dialog-section-special {
  margin-top: clamp(34px, 5dvh, 58px);
}

.events-dialog-item {
  padding: 14px 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.35;
}

.events-dialog-item + .events-dialog-item {
  border-top: 1px solid rgba(216, 206, 194, 0.75);
}

.events-dialog-section-title {
  margin: 0;
  padding: 0 0 18px;
  border-bottom: 0;
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.2;
  font-weight: 500;
  color: var(--text);
}

.events-dialog-header h2::after,
.events-dialog-section-title::after {
  content: "";
  display: block;
  width: 48px;
  height: 1.5px;
  margin-top: 14px;
  background: var(--script);
}

.events-dialog-section-title + .events-dialog-item {
  border-top: 0;
}

.events-dialog-item strong,
.events-dialog-item span {
  display: block;
}

.events-dialog-item strong {
  font-weight: 500;
  color: var(--text);
}

.events-dialog-item span {
  color: var(--text);
}

.events-dialog-item .events-dialog-muted,
.events-dialog-item p {
  color: var(--muted);
}

.events-dialog-item p {
  margin: 4px 0 0;
}

@media (max-height: 400px) {
  body {
    grid-template-rows: var(--header-height) minmax(0, 1fr) 0;
  }

  .page-footer {
    display: none;
  }
}

.debug-label {
  padding: 16px;
  font-size: 20px;
  font-weight: 600;
}

@media (orientation: portrait) {
  .content-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1.2fr) minmax(0, 0.8fr);
  }

  .stream-box {
    grid-row: 1;
  }

  .verse-box {
    grid-row: 2;
  }

  .stream-placeholder {
    transform: translateY(2dvh);
  }

  .page-content::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 45%;
    z-index: 0;
    background: linear-gradient(180deg, rgba(248, 244, 239, 0) 0%, rgba(248, 244, 239, 0.52) 42%, rgba(248, 244, 239, 0.72) 100%);
    pointer-events: none;
  }

  .content-layout.verse-hidden {
    grid-template-rows: minmax(0, 1fr);
  }
}

@media (max-width: 700px) {
  body {
    --footer-gap: 8px;
    --footer-padding-y: 4px;
    --footer-events-min-height: clamp(82px, 10dvh, 102px);
    --footer-location-min-height: clamp(46px, 5.8dvh, 60px);
    --footer-min-height: calc(var(--footer-events-min-height) + var(--footer-location-min-height) + var(--footer-gap) + (var(--footer-padding-y) * 2));
    grid-template-rows: var(--header-height) minmax(0, 1fr) auto;
  }

  .page-footer {
    max-height: none;
  }

  .footer-layout {
    grid-template-columns: 1fr;
    grid-template-rows: max-content max-content;
  }

  .footer-box + .footer-box {
    border-left: 0;
    border-top: 1px solid rgba(216, 206, 194, 0.9);
  }

  .footer-box {
    gap: 10px;
    padding: clamp(5px, 0.8dvh, 8px) clamp(8px, 3.5vw, 18px);
  }

  .footer-icon {
    width: clamp(40px, 5.2dvh, 52px);
  }

  .footer-text p {
    line-height: 1.25;
  }

  .footer-text p + p {
    margin-top: 3px;
  }

  .footer-location-address {
    margin-top: 2px;
  }

  .footer-subtle-link {
    margin-top: 7px;
  }

  .footer-event-description {
    line-height: 1.18;
  }

  .events-dialog-header {
    padding: 14px 16px 12px;
  }

  .events-dialog-list {
    padding: 2px 16px 16px;
  }

  .stream-placeholder {
    transform: none;
  }
}
