@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,500;0,600;1,500&family=Great+Vibes&display=swap");

:root {
  --paper: #0f4f52;
  --paper-deep: #0b3f42;
  --paper-front: #13585b;
  --paper-inside: #092e31;
  --scene: #071c20;
  --gold: #b8944a;
  --ivory: #f4ecde;
  --ink: #2c2418;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: "Cormorant Garamond", Georgia, serif;
  background: var(--scene);
  color: var(--ink);
  overflow: hidden;
}

html.is-unlocked,
body.is-unlocked {
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
}

html.is-unlocked {
  scroll-behavior: smooth;
}

.cover {
  position: relative;
  width: 100%;
  min-height: 100svh;
  display: grid;
  place-items: center;
  isolation: isolate;
  overflow: hidden;
}

.cover.is-open {
  overflow: visible;
}

.cover-atmosphere {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 70% 55% at 50% 48%, #0a3336 0%, var(--scene) 72%);
}

.stage {
  position: relative;
  z-index: 1;
  perspective: 1600px;
  perspective-origin: 50% 40%;
}

.envelope {
  --w: min(86vw, 430px);
  --h: calc(var(--w) * 0.66);
  position: relative;
  width: var(--w);
  height: var(--h);
  transform-style: preserve-3d;
  transform: rotateX(6deg);
  overflow: hidden;
}

.envelope.is-open {
  overflow: visible;
}

.envelope-shadow {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -18px;
  height: 28px;
  z-index: 0;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.48), transparent 72%);
  pointer-events: none;
}

.paper {
  background-color: var(--paper);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='5' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E"),
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.03) 0 1px,
      transparent 1px 3px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(0, 0, 0, 0.04) 0 1px,
      transparent 1px 4px
    );
  background-size: 160px 160px, auto, auto;
  background-blend-mode: multiply, overlay, soft-light;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 -14px 22px rgba(0, 0, 0, 0.14);
}

.fold-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.envelope-body {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 2px 2px 8px 8px;
  background-color: var(--paper-deep);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 18px 28px rgba(0, 0, 0, 0.18);
}

.card {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 14%;
  height: 78%;
  z-index: 2;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  padding: 12% 12px 16px;
  background-color: var(--ivory);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)' opacity='0.22'/%3E%3C/svg%3E"),
    repeating-linear-gradient(
      0deg,
      rgba(44, 36, 24, 0.025) 0 1px,
      transparent 1px 3px
    );
  background-blend-mode: multiply, overlay;
  border: 1px solid rgba(184, 148, 74, 0.55);
  box-shadow:
    inset 0 0 0 5px var(--ivory),
    inset 0 0 0 6px rgba(184, 148, 74, 0.45),
    0 4px 10px rgba(0, 0, 0, 0.12);
  transform: translateY(10%);
  transition: transform 1.3s cubic-bezier(0.19, 1, 0.22, 1) 0.5s;
}

.envelope.is-open .card {
  transform: translateY(-52%);
  z-index: 8;
  overflow: visible;
}

.card-ornament {
  width: min(88%, 210px);
  height: 18px;
  color: var(--gold);
  margin-bottom: 6px;
  flex-shrink: 0;
}

.card-ornament-bottom {
  margin: 8px 0 6px;
}

.card-kicker {
  letter-spacing: 0.42em;
  text-transform: uppercase;
  font-size: clamp(0.55rem, 2.4vw, 0.68rem);
  color: #7a6a54;
  margin-bottom: 4px;
}

.card-names {
  font-family: "Great Vibes", cursive;
  font-size: clamp(1.7rem, 7.2vw, 2.7rem);
  font-weight: 400;
  color: #7d5324;
  line-height: 1.05;
  margin: 0;
}

.card-amp {
  display: block;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-size: 0.42em;
  letter-spacing: 0.12em;
  color: var(--gold);
  line-height: 1;
  margin: 1px 0;
}

.card-date {
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: clamp(0.58rem, 2.6vw, 0.72rem);
  color: #6b5e4e;
}

.pocket {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  box-shadow: inset 0 12px 15px -6px rgba(0, 0, 0, 0.45);
}

.pocket-panel {
  position: absolute;
  overflow: hidden;
}

.pocket-left {
  left: 0;
  top: 0;
  width: 54%;
  height: 100%;
  clip-path: polygon(0 0, 0 100%, 100% 50%);
  background-color: var(--paper-deep);
  box-shadow: inset -14px 0 22px rgba(0, 0, 0, 0.28);
}

.pocket-left .fold-shade {
  background: linear-gradient(90deg, transparent 55%, rgba(0, 0, 0, 0.22) 100%);
}

.pocket-right {
  right: 0;
  top: 0;
  width: 54%;
  height: 100%;
  clip-path: polygon(100% 0, 0 50%, 100% 100%);
  background-color: var(--paper-deep);
  box-shadow: inset 14px 0 22px rgba(0, 0, 0, 0.28);
}

.pocket-right .fold-shade {
  background: linear-gradient(270deg, transparent 55%, rgba(0, 0, 0, 0.22) 100%);
}

.pocket-bottom {
  left: 0;
  right: 0;
  bottom: 0;
  height: 56%;
  clip-path: polygon(0 100%, 50% 0, 100% 100%);
  background-color: var(--paper-front);
  box-shadow:
    0 -8px 16px rgba(0, 0, 0, 0.18),
    inset 0 10px 14px rgba(255, 255, 255, 0.04);
}

.pocket-bottom .fold-shade {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.28) 0%, rgba(0, 0, 0, 0.08) 28%, transparent 52%);
}

.flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 54%;
  z-index: 6;
  transform-origin: top center;
  transform-style: preserve-3d;
  transform: rotateX(0deg);
  transition: transform 1.2s cubic-bezier(0.25, 1, 0.5, 1);
}

.envelope.is-open .flap {
  transform: rotateX(178deg);
  z-index: 1;
}

.flap-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  overflow: hidden;
}

.flap-front {
  transform: rotateX(0deg);
  background-color: var(--paper-front);
  box-shadow:
    0 8px 16px rgba(0, 0, 0, 0.22),
    inset 0 -10px 14px rgba(0, 0, 0, 0.12);
  filter:
    drop-shadow(0 10px 8px rgba(0, 0, 0, 0.28))
    drop-shadow(0 18px 16px rgba(0, 0, 0, 0.16));
  transition: filter 1.05s cubic-bezier(0.4, 0.02, 0.2, 1);
}

.envelope.is-open .flap-front {
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.18));
}

.flap-front .fold-shade {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, transparent 40%, rgba(0, 0, 0, 0.22) 100%);
}

.flap-back {
  transform: rotateX(180deg);
  background-color: var(--paper-inside);
  box-shadow: inset 0 8px 18px rgba(0, 0, 0, 0.35);
}

.seal {
  position: absolute;
  left: 50%;
  top: 100%;
  z-index: 12;
  width: calc(var(--w) * 0.3);
  height: calc(var(--w) * 0.3);
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform: translate(-50%, -50%);
  transform-origin: center center;
  opacity: 1;
  transition: opacity 0.5s ease 0.2s, transform 0.3s ease;
}

.seal-wax {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
}

.seal-wax::after {
  content: "";
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(
    circle at 32% 26%,
    rgba(255, 255, 255, 0.28),
    transparent 58%
  );
  mix-blend-mode: soft-light;
}

.seal img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(2px 6px 8px rgba(0, 0, 0, 0.35));
}

.seal:hover,
.seal:focus-visible {
  transform: translate(-50%, -50%) scale(1.035);
  outline: none;
}

.envelope.is-open .seal {
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.08);
  opacity: 0;
}

.scroll-hint {
  position: absolute;
  bottom: 28px;
  left: 0;
  right: 0;
  z-index: 3;
  text-align: center;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: rgba(232, 220, 196, 0.72);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.7s ease, transform 0.7s ease;
  pointer-events: none;
}

.scroll-hint.is-visible {
  opacity: 1;
  transform: none;
}

.story {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(48px, 8vw, 96px) 24px;
  background-color: var(--ivory);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(15, 79, 82, 0.06), transparent 58%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23s)' opacity='0.16'/%3E%3C/svg%3E");
  color: var(--ink);
}

.story-inner {
  width: min(92vw, 520px);
  text-align: center;
  padding: clamp(36px, 7vw, 64px) clamp(22px, 5vw, 48px);
  background: rgba(244, 236, 222, 0.72);
  border: 1px solid rgba(184, 148, 74, 0.5);
  box-shadow:
    inset 0 0 0 7px var(--ivory),
    inset 0 0 0 8px rgba(184, 148, 74, 0.4);
}

.story-kicker {
  letter-spacing: 0.4em;
  text-transform: uppercase;
  font-size: clamp(0.68rem, 2vw, 0.78rem);
  color: #7a6a54;
}

.story-title {
  font-family: "Great Vibes", cursive;
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  font-weight: 400;
  color: #7d5324;
  margin: 8px 0 4px;
}

.story-rule {
  display: block;
  width: 72px;
  height: 1px;
  margin: 18px auto;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.story-lead {
  font-size: clamp(1.05rem, 3vw, 1.2rem);
  line-height: 1.7;
  font-style: italic;
}

.story-meta {
  margin-top: 22px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: clamp(0.72rem, 2.2vw, 0.85rem);
  color: #6b5e4e;
}

@media (max-width: 480px) {
  .seal {
    width: calc(var(--w) * 0.32);
    height: calc(var(--w) * 0.32);
  }

  .card {
    padding: 10% 10px 12px;
  }

  .card-names {
    font-size: clamp(1.55rem, 8.5vw, 2.2rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .flap,
  .card,
  .seal,
  .scroll-hint {
    transition-duration: 0.01ms !important;
  }
}
