@font-face {
  font-family: Gloock;
  src: url("assets/fonts/gloock.ttf") format("truetype");
  font-display: swap;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: #231710; }
body, button { font-family: Gloock, Georgia, serif; color: #fff0d8; }
main { position: relative; isolation: isolate; height: 100vh; height: 100dvh; overflow: hidden; }
.photos, .shade, .letter-stage { position: absolute; inset: 0; }
.photos {
  display: flex; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; scrollbar-width: none;
}
.photos::-webkit-scrollbar { display: none; }
.photos > img, .photos > picture {
  width: 100%; flex: 0 0 100%; min-width: 0; height: 100%; object-fit: cover;
  object-position: var(--focus, center); scroll-snap-align: start; scroll-snap-stop: always;
}
.photos picture img { display: block; width: 100%; height: 100%; object-fit: cover; }
.shade {
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 48%, #1c100c4f, transparent 75%),
    linear-gradient(180deg, #1c100c33, #1c100c3b 65%, #100807b8);
}
.letter-stage { display: grid; place-items: center; pointer-events: none;
  --envelope-width: min(92vw, 108svh, 50rem); }
button, .hint { background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.envelope {
  position: relative; grid-area: 1 / 1; width: var(--envelope-width); aspect-ratio: 1.72;
  border: 0; padding: 0; pointer-events: auto; touch-action: pan-y;
  overflow: visible; text-shadow: 0 2px 14px #190d03;
}
.turn, .side { position: absolute; inset: 0; }
.turn { perspective: 1200px; }
.side {
  display: grid; place-content: center; justify-items: center;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border: 1px solid #ecd4a8dc; border-radius: 3px;
  background: #25160d1a; box-shadow: 0 1px 16px #140b071a;
}
.addressed::before {
  content: ''; position: absolute; inset: 5px; border: 1px solid #f2d3a147; pointer-events: none;
}
.recipient { font-size: clamp(1.8rem, min(7vw, 9svh), 5rem); white-space: nowrap; letter-spacing: -.045em; line-height: 1.15; }
.flourish { width: 36%; min-width: 66px; height: 18px; margin-top: 10px; stroke: #e8c997; stroke-width: 1.1; }
.reverse { visibility: hidden; }
.seams, .flap { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.seams path, .flap path { fill: none; stroke: #efd2a4; stroke-width: 1; vector-effect: non-scaling-stroke; }
.flap { height: 58%; transform-origin: top; }
.seal {
  position: absolute; left: 50%; top: 55%; width: clamp(42px, 8%, 62px);
  height: auto; transform: translate(-50%, -50%); filter: drop-shadow(0 2px 2px #28150da6);
}
.open-label, .replay, .counter { font-size: .91rem; letter-spacing: .045em; }
.open-label { position: absolute; bottom: clamp(14px, 5%, 26px); left: 0; width: 100%; }
.envelope:hover .addressed { border-color: #fff3d4; }
/* Each side turns only as far as edge-on. Only the reverse is painted during the exit. */
[data-state="opening"] .addressed { animation: face-away .38s ease-in both; }
[data-state="opening"] .reverse { animation: face-up .42s .38s ease-out both, slide-away .62s 1.62s ease-in both; }
[data-state="opening"] .flap { animation: lift .58s 1.20s ease-in-out both; }
[data-state="opening"] .seal { animation: vanish .47s .80s ease-out both; }
[data-state="opening"] .open-label { visibility: hidden; }
@keyframes face-away {
  from { transform: rotateY(0); visibility: visible; }
  99% { visibility: visible; }
  to { transform: rotateY(90deg); visibility: hidden; }
}
@keyframes face-up {
  from { transform: rotateY(-90deg); visibility: hidden; }
  1% { visibility: visible; }
  to { transform: rotateY(0); visibility: visible; }
}
@keyframes slide-away {
  from { translate: 0 0; opacity: 1; }
  to { translate: 0 22%; opacity: 0; }
}
@keyframes lift { to { transform: rotateX(160deg); } }
@keyframes vanish { to { opacity: 0; } }
.date {
  position: relative; grid-area: 1 / 1; width: calc(var(--envelope-width) * .94);
  aspect-ratio: 1.68; display: grid; place-items: center; margin: 0;
  padding: 16px; color: #4b3225; font-weight: 400;
  font-size: clamp(1.08rem, min(5vw, 6svh), 3.35rem);
  letter-spacing: -.025em; white-space: nowrap;
  background:
    linear-gradient(180deg, transparent 49%, #a58d6214 49.85%, #fff9ec80 50.1%, transparent 52%),
    linear-gradient(120deg, #faf1df, #f2e7cf 65%, #f8efdd);
  border: 1px solid #e2cfaf;
  box-shadow: 0 2px 3px #180d0636, 0 16px 35px #180d0655;
}
.paper-trim { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; pointer-events: none; }
.paper-trim path { vector-effect: non-scaling-stroke; }
.outer-rule { stroke: #a47e50; stroke-width: 1; }
.inner-rule { stroke: #bfa178; stroke-width: .7; }
[data-state="opening"] .date { animation: draw-sheet .68s 1.58s cubic-bezier(.2,.7,.25,1) both; }
[data-state="closing"] .date { animation: put-away .32s ease-in both; }
[data-state="closing"] .envelope { animation: return-envelope .34s .16s ease-out both; pointer-events: none; }
@keyframes put-away {
  to { opacity: 0; translate: 0 7px; }
}
@keyframes return-envelope {
  from { opacity: 0; translate: 0 4px; }
  to { opacity: 1; translate: 0 0; }
}
@keyframes draw-sheet {
  from { opacity: 0; transform: translateY(18%) scale(.94); clip-path: inset(0 0 98%); }
  to { opacity: 1; transform: none; clip-path: inset(0); }
}
.controls {
  position: absolute; left: max(14px, 3.8vw, env(safe-area-inset-left)); right: max(14px, 3.8vw, env(safe-area-inset-right));
  bottom: max(12px, 3vh, env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between; pointer-events: none;
}
.controls > * { pointer-events: auto; }
.pager { display: flex; align-items: center; }
.pager button, .hint, .replay { min-width: 44px; min-height: 44px; }
.pager button { display: grid; place-items: center; padding: 0; }
.pager svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.counter, .replay, .hint { text-shadow: 0 2px 7px #150a03; }
.hint {
  position: absolute; top: max(12px, 3vh, env(safe-area-inset-top)); right: max(14px, 3.8vw, env(safe-area-inset-right));
  display: grid; place-items: center; color: inherit; text-decoration: none; font-size: 1.6rem;
}
:focus-visible { outline: 2px solid #ffe0aa; outline-offset: 4px; }
.photos:focus-visible { outline-offset: -4px; }
.flip-paper:focus-visible { outline: 2px solid #efc994; outline-offset: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) {
  *, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; }
}

[data-state="opened"] .date { pointer-events: auto; touch-action: pan-y; }
.date-side, .hint-side { display: grid; place-items: center; }
.date-side { gap: clamp(.4rem, 1.4svh, .95rem); transform: translateY(-.25rem); }
.weekend-dates { font-size: max(.9rem, .58em); line-height: 1.3; letter-spacing: .035em; }
.hint-side {
  width: 100%; gap: clamp(3px, 1.2svh, 13px); padding: 3% 2%;
  white-space: normal; text-align: center; text-wrap: balance;
  letter-spacing: 0; font-size: clamp(.91rem, min(2.5vw, 3.2svh), 1.38rem); line-height: 1.35;
}
.hint-title { display: block; height: 2.4em; max-width: 78%; object-fit: contain; margin-bottom: .25em; }
.paper-cue {
  display: inline-flex; align-items: center; gap: .28em; color: rgb(75 50 37 / 72%);
  font-size: .78rem; line-height: 1; letter-spacing: .01em; pointer-events: none;
  position: absolute; right: max(26px, 5.5%); bottom: max(20px, 6%);
}
.paper-arrow {
  width: clamp(15px, 1.6vw, 20px); fill: none; stroke: currentColor;
  stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; pointer-events: none;
}
.hint-side:not([hidden]) ~ .paper-cue > span { display: none; }
.hint-side:not([hidden]) ~ .paper-cue .paper-arrow { transform: scaleX(-1); }
@media (max-width: 600px) and (orientation: portrait) {
  .date { min-height: min(17rem, 66svh); }
}


@media (max-width: 600px) {
  .hint-side { font-size: clamp(.80rem, 3.48vw, 1rem); padding-inline: 0; }
}


@font-face { font-family: "Allura"; src: url("assets/fonts/allura.ttf"); font-style: normal; font-display: swap; }
@font-face { font-family: "Miama Nueva"; src: url("assets/fonts/miama.otf"); font-style: normal; font-display: swap; }
@font-face { font-family: "TeX Gyre Chorus"; src: url("assets/fonts/texgyrechorus-mediumitalic.otf"); font-style: normal; font-display: swap; }
@font-face { font-family: "EB Garamond"; src: url("assets/fonts/EBGaramond-Regular.otf"); font-style: normal; font-display: swap; }
@font-face { font-family: "EB Garamond"; src: url("assets/fonts/EBGaramond-Italic.otf"); font-style: italic; font-display: swap; }
@font-face { font-family: "Cormorant Garamond"; src: url("assets/fonts/CormorantGaramond-Regular.ttf"); font-style: normal; font-display: swap; }
@font-face { font-family: "Cormorant Garamond"; src: url("assets/fonts/CormorantGaramond-Italic.ttf"); font-style: italic; font-display: swap; }
@font-face { font-family: "Libre Baskerville"; src: url("assets/fonts/LibreBaskerville-Regular.ttf"); font-style: normal; font-display: swap; }
@font-face { font-family: "Libre Baskerville"; src: url("assets/fonts/LibreBaskerville-Italic.ttf"); font-style: italic; font-display: swap; }
body, button { font-family: "Cormorant Garamond", Georgia, serif; }
.recipient { font-family: "Allura", cursive; font-size: clamp(2.75rem,min(10vw,12svh),6.5rem); letter-spacing: 0; }
.hint-side { gap: .42em; font-size: clamp(.85rem, min(3.85vw, 4svh), 1.55rem); }

@media(max-width:700px) { .letter-stage { --envelope-width: min(92vw,85svh,50rem); } }

.date-side { position: relative; width: 100%; min-width: 0; z-index: 1; pointer-events: none; }
.invitation-heading { position: relative; width: min(78%, 28rem); height: clamp(3.4rem, 14vw, 6.8rem); }
.invitation-heading img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  opacity: 1; transition: opacity .28s ease-out .14s;
}
.invitation-heading img[aria-hidden="true"] { opacity: 0; transition: opacity .18s ease-in; }
.flip-paper { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; }
.rsvp {
  position: absolute; left: 50%; top: calc(100% + clamp(0px, 1svh, 8px)); transform: translateX(-50%);
  display: grid; grid-template-columns: 1em auto 1em; align-items: center; column-gap: .35em;
  pointer-events: auto; min-width: 60px; min-height: 44px; padding: 0 .65em;
  color: #734831; font-family: inherit; font-size: clamp(1rem, 2.2vw, 1.3rem);
  font-weight: 400; letter-spacing: .035em;
}
.rsvp-mark { width: 1em; height: 1em; }
.rsvp-rings, .rsvp-heart { transition: opacity .24s ease-in-out; }
.rsvp-heart, .rsvp[aria-pressed="true"] .rsvp-rings { opacity: 0; }
.rsvp[aria-pressed="true"] .rsvp-heart { opacity: 1; }
.rsvp:focus-visible { outline: 1px solid #805033; outline-offset: 0; }
@media (prefers-reduced-motion: reduce) {
  .invitation-heading img, .invitation-heading img[aria-hidden="true"], .rsvp-rings, .rsvp-heart { transition: none; }
}
