:root {
  --forest: #173527;
  --sage: #9cac97;
  --cream: #f2ead9;
  --paper: #fffaf0;
  --ink: #14251d;
  --glass: rgba(242, 234, 217, 0.16);
  --transition-duration: 1400ms;
  --px: 0;
  --py: 0;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--forest);
  color: var(--cream);
  font-family: "Helvetica Neue", "Noto Sans CJK SC", sans-serif;
}

button {
  color: inherit;
  font: inherit;
}

.album {
  isolation: isolate;
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  min-height: 100svh;
  padding: clamp(18px, 2.8vw, 42px) clamp(20px, 4vw, 64px);
  overflow: hidden;
}

.ambient,
.ambient__image,
.ambient__drift,
.ambient__wash,
.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ambient {
  z-index: -3;
  overflow: hidden;
  background: var(--forest);
}

.ambient__image {
  overflow: hidden;
  opacity: 0;
  transform: translate3d(calc(var(--px) * 12px), calc(var(--py) * 9px), 0);
  transition: opacity var(--transition-duration) cubic-bezier(0.4, 0, 0.2, 1);
  will-change: opacity, transform;
}

.ambient__drift {
  inset: -12%;
  background: url("assets/images/hero-wedding-bg.jpg") center 58% / cover no-repeat;
  filter: blur(42px) saturate(0.76) brightness(0.58);
  transform: scale(1.16);
  will-change: transform;
}

.ambient__image.is-current {
  opacity: 1;
}

.ambient__wash {
  z-index: 1;
  background:
    radial-gradient(circle at 76% 18%, rgba(242, 234, 217, 0.34), transparent 37%),
    linear-gradient(105deg, rgba(20, 52, 37, 0.76) 0%, rgba(23, 53, 39, 0.32) 47%, rgba(156, 172, 151, 0.3) 100%);
  backdrop-filter: blur(2px);
  animation: light-breathe 3.8s ease-in-out infinite alternate;
  will-change: opacity, transform;
}

.masthead,
.footer {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.masthead {
  font-size: 10px;
}

.masthead__index {
  opacity: 0.74;
}

.masthead__title {
  font-family: Didot, "Bodoni 72", serif;
  font-size: 12px;
  letter-spacing: 0.2em;
}

.frame {
  position: relative;
  display: grid;
  min-height: 0;
  place-items: center;
  padding: clamp(27px, 4vh, 48px) 0 clamp(18px, 2.8vh, 32px);
}

.portrait-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  max-height: calc(100svh - clamp(126px, 16vh, 176px));
  margin: 0;
  overflow: visible;
  opacity: 0;
  transform: translateY(18px) scale(0.985);
  animation: image-arrive 1.45s 0.16s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.portrait {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  filter: drop-shadow(0 36px 48px rgba(6, 24, 15, 0.22));
  transform: translate3d(0, 9px, 0) scale(0.988);
  transition:
    opacity var(--transition-duration) cubic-bezier(0.4, 0, 0.2, 1),
    transform var(--transition-duration) cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}

.portrait.is-current {
  z-index: 2;
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

.portrait.is-leaving {
  z-index: 1;
  opacity: 0;
  transform: translate3d(0, -3px, 0) scale(1.012);
}

.footer {
  min-height: 24px;
}

.footer__controls {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2vw, 28px);
}

.slide-status {
  font-size: 8px;
  letter-spacing: 0.19em;
  opacity: 0.58;
}

.slide-status[hidden] {
  display: none;
}

.footer__copy {
  margin: 0;
  font-family: STKaiti, KaiTi, serif;
  font-size: clamp(13px, 1.2vw, 16px);
  letter-spacing: 0.06em;
  text-transform: none;
}

.motion-toggle {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0;
  border: 0;
  outline-offset: 5px;
  background: transparent;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 220ms ease;
}

.motion-toggle:hover,
.motion-toggle:focus-visible {
  opacity: 1;
}

.motion-toggle:active {
  opacity: 0.5;
}

.motion-toggle__label {
  font-size: 8px;
  letter-spacing: 0.19em;
}

.motion-toggle__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 14px rgba(242, 234, 217, 0.72);
  animation: dot-breathe 2.8s ease-in-out infinite;
}

.grain {
  z-index: 9;
  opacity: 0.22;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.4'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.album.is-paused .motion-toggle__dot {
  opacity: 0.38;
  animation-play-state: paused;
}

@keyframes light-breathe {
  0% {
    opacity: 0.62;
    transform: scale(1.01);
  }
  100% {
    opacity: 1;
    transform: scale(1.12);
  }
}

.album[data-performance="low"] .ambient__drift {
  filter: blur(28px) saturate(0.7) brightness(0.54);
  transform: scale(1.1);
}

.album[data-performance="low"] .ambient__wash {
  animation: none;
}

.album[data-performance="low"] .grain {
  opacity: 0.1;
}

.album[data-page-hidden="true"] .motion-toggle__dot {
  animation-play-state: paused;
}

@keyframes image-arrive {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes dot-breathe {
  50% {
    opacity: 0.42;
    transform: scale(0.72);
  }
}

@media (orientation: portrait) {
  .album {
    padding-inline: clamp(14px, 4vw, 28px);
  }

  .frame {
    padding-top: 30px;
    padding-bottom: 20px;
  }

  .portrait-wrap {
    width: 100%;
    height: 100%;
    max-height: calc(100svh - 142px);
  }

  .portrait {
    width: 100%;
    height: 100%;
  }

}

@media (max-width: 640px) {
  .masthead__index,
  .motion-toggle__label,
  .slide-status {
    display: none;
  }

  .footer__copy {
    max-width: 72%;
    line-height: 1.65;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .ambient__image,
  .motion-toggle__dot {
    animation: none !important;
  }
}
