:root {
  color-scheme: light;
  --paper: #F5F2EA;
  --forest: #173D31;
  --pine: #203A30;
  --bronze: #A48A62;
  --art-width: 540px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  scroll-behavior: smooth;
  scroll-padding-top: env(safe-area-inset-top);
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--pine);
  font-family: "Segoe UI", Arial, sans-serif;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: max(8px, env(safe-area-inset-top));
  left: 8px;
  padding: 12px 16px;
  transform: translateY(-160%);
  border-radius: 999px;
  background: var(--paper);
  color: var(--forest);
  font-size: 14px;
  text-decoration: underline;
}

.skip-link:focus-visible {
  transform: translateY(0);
  outline: 2px solid var(--bronze);
  outline-offset: 2px;
}

.envelope-stage {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: max(24px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
  background: var(--paper);
  opacity: 1;
  transition: opacity 720ms cubic-bezier(.22, .61, .36, 1);
}

.envelope-stage.is-departing {
  opacity: 0;
  pointer-events: none;
}

.envelope-trigger {
  display: grid;
  width: min(100%, 420px);
  justify-items: center;
  gap: 22px;
  padding: 12px 0;
  border: 0;
  background: transparent;
  color: var(--forest);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.envelope-trigger:focus-visible {
  outline: 2px solid var(--bronze);
  outline-offset: 12px;
  border-radius: 6px;
}

.envelope-art {
  position: relative;
  display: block;
  width: min(90vw, 380px);
  aspect-ratio: 3 / 2;
  isolation: isolate;
}

.envelope-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition:
    opacity 650ms cubic-bezier(.22, .61, .36, 1),
    transform 550ms cubic-bezier(.22, .61, .36, 1),
    filter 550ms ease;
}

.envelope-closed {
  z-index: 2;
  opacity: 1;
  filter: brightness(1);
}

.envelope-open {
  z-index: 1;
  opacity: 0;
}

.envelope-stage.is-seal-responding .envelope-closed {
  transform: scale(.985);
  filter: brightness(1.1);
}

.envelope-stage.is-flap-open .envelope-closed {
  opacity: 0;
  transform: translateY(-5px) scale(.99);
}

.envelope-stage.is-flap-open .envelope-open {
  opacity: 1;
}

.cover-slip {
  position: absolute;
  z-index: 3;
  top: 28%;
  left: 50%;
  display: block;
  width: 35%;
  aspect-ratio: 1080 / 1640;
  overflow: hidden;
  opacity: 0;
  transform: translate(-50%, 78px) scale(.96);
  transform-origin: 50% 100%;
  filter: drop-shadow(0 4px 8px rgba(32, 58, 48, .18));
  transition:
    opacity 650ms ease,
    transform 850ms cubic-bezier(.22, .61, .36, 1);
}

.cover-slip img {
  display: block;
  width: 100%;
  height: auto;
}

.envelope-stage.is-card-emerging .cover-slip {
  opacity: 1;
  transform: translate(-50%, -28px) scale(1);
}

.open-prompt {
  display: block;
  color: #8D7959;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 11px;
  letter-spacing: .2em;
  line-height: 1.5;
}

.invitation {
  width: min(100%, var(--art-width));
  margin-inline: auto;
  background: var(--paper);
}

.master-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.master-svg a.hotspot {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.master-svg a.hotspot rect {
  fill: transparent;
  pointer-events: all;
}

.master-svg a.hotspot:focus-visible rect {
  fill: var(--bronze);
  fill-opacity: .16;
  stroke: var(--bronze);
  stroke-width: 5;
  stroke-dasharray: 8 7;
}

.master-svg .motion-frame {
  clip-path: inset(0);
  transition: clip-path 1050ms cubic-bezier(.22, .61, .36, 1);
}

.master-svg.motion-ready .motion-frame.motion-pending:not(.is-visible) {
  clip-path: inset(100% 0 0);
}

.audio-toggle {
  position: fixed;
  z-index: 12;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  display: grid;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--bronze);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.audio-symbol {
  display: block;
  margin-top: -2px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  line-height: 1;
  text-shadow: 0 0 3px var(--paper), 0 0 7px var(--paper);
}

.audio-toggle:focus-visible {
  outline: 2px solid var(--bronze);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .envelope-stage,
  .envelope-image,
  .cover-slip,
  .master-svg .motion-frame {
    transition-duration: .01ms !important;
  }

  .master-svg .motion-frame {
    clip-path: inset(0) !important;
  }
}
