@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("fonts/barlow-condensed.woff2") format("woff2");
  font-display: swap;
}

:root {
  color-scheme: light;
  --red: #be3038;
  --cream: #fff2d9;
  --pine: #18483c;
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  background: var(--red);
  color: var(--cream);
}
*, *::before, *::after { box-sizing: border-box; }
body, h1, p, form { margin: 0; }
button { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
:focus-visible { outline: 3px solid #fff7d8; outline-offset: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.postcard {
  display: flex; flex-direction: column; align-items: center;
  position: relative; isolation: isolate; min-height: 100svh; overflow: clip;
  background: var(--red);
}
#festivities { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: -1; }
.stage {
  width: min(100%, 46rem);
  padding: max(3.3rem, 7.2svh, env(safe-area-inset-top)) clamp(1.4rem, 5.4vw, 2.9rem) 0;
}
.masthead { text-align: center; }
.masthead h1 {
  font-size: clamp(1.9rem, 9.3vw, 4.8rem);
  font-weight: 800; line-height: .99; letter-spacing: -.04em; color: #ffda76;
}
.title-first {
  display: flex; align-items: center; justify-content: center; gap: .3em;
  margin-bottom: .12em;
}
.title-first::before, .title-first::after {
  content: ""; width: .42em; height: .42em; background: #ffda76;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
}
.title-first::before { transform: rotate(-12deg); }
.title-first::after { transform: rotate(12deg); }
.title-main { display: block; }
.instruction {
  max-width: 32ch; margin: clamp(.8rem, 2.3svh, 1.3rem) auto 0;
  font-size: clamp(1rem, 2.6vw, 1.13rem); font-weight: 550; line-height: 1.3;
  text-wrap: balance;
}

.gifts {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(.8rem, 2.7svh, 1.65rem) clamp(.23rem, 1.25vw, 1rem);
  width: min(100%, 37.75rem); margin: clamp(1.5rem, 4.6svh, 2.75rem) auto 0;
}
.parcel { position: relative; grid-column: span 2; min-width: 0; container-type: inline-size; }
.parcel:nth-child(4) { grid-column: 2 / span 2; }
.parcel:nth-child(5) { grid-column: 4 / span 2; }
.gift {
  --face: #fff0d5; --edge: #cfab83;
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4%; width: 100%; aspect-ratio: 1.06; padding: 6% 2% 7%; border: 0;
  border-radius: clamp(.7rem, 1.7vw, 1.25rem); background: var(--face); color: var(--pine);
  box-shadow: 0 clamp(3px, .45vw, 5px) 0 var(--edge);
  cursor: pointer; user-select: none;
  transition: transform .16s ease;
}
.color-2 { --face: #a8dec5; --edge: #6aa995; }
.color-3 { --face: #ffda80; --edge: #d1a350; }
.color-4 { --face: #ffceb8; --edge: #d39985; }
.color-5 { --face: #a9dee0; --edge: #74a9ac; }
.gift-art { display: block; width: 49%; height: auto; aspect-ratio: 1; object-fit: contain; pointer-events: none; }
.nameplate { display: block; font-size: clamp(.9rem, 14cqi, 1.78rem); line-height: 1.08; font-weight: 800; letter-spacing: -.025em; }
.gift:disabled { --face: #dc8d87; --edge: #ac5756; color: #573c35; cursor: default; }
.gift:disabled .gift-art { visibility: hidden; width: 38%; }
.opened-note { display: none; font-size: clamp(.62rem, 8cqi, 1rem); line-height: 1.15; font-weight: 600; text-wrap: balance; }
.gift:disabled .opened-note { display: block; }
.lock-seal {
  position: absolute; left: 50%; top: 29%; width: 25%; height: 22%;
  transform: translateX(-50%); display: none; border-radius: 20%;
  background: #795651;
}
.gift:disabled .lock-seal { display: block; }
.lock-seal::before {
  content: ""; position: absolute; width: 66%; height: 80%; left: 17%; bottom: 82%;
  border: max(2px, .2em) solid #795651; border-radius: 65% 65% 0 0; border-bottom: 0;
}
.lock-seal i { position: absolute; left: 43%; top: 35%; width: 14%; height: 32%; border-radius: 40%; background: #f8c9ad; }
.gift[aria-busy="true"] { cursor: progress; transform: scale(.97); }
@media (hover: hover) {
  button.gift:not(:disabled):hover { transform: translateY(-3px) rotate(-1.8deg); }
  button.gift:not(:disabled):hover .gift-art { animation: sticker-hop .5s ease-in-out; }
}
button.gift:not(:disabled):active { transform: translateY(2px) scale(.97); }
@keyframes sticker-hop {
  0%, 100% { transform: translateY(0) rotate(0); }
  40% { transform: translateY(-8%) rotate(-10deg); }
  75% { transform: translateY(-2%) rotate(7deg); }
}
.scene-footer { flex: 1 0 clamp(8.5rem, 27svh, 14rem); width: 100%; }

.reveal, .solo-letter { width: min(calc(100% - 1.5rem), 29rem); }
.reveal {
  position: fixed; inset: 0; margin: auto; padding: 0; height: fit-content; max-height: none; max-width: none;
  border: 0; outline: 0; overflow: visible; background: transparent; color: var(--pine);
}
.reveal::backdrop { background: #40252899; }
body:has(.reveal[open]) { overflow: hidden; }
.reveal-move, .solo-letter { aspect-ratio: 1.4; }
.reveal-move { perspective: 1050px; }
.reveal-turn { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transform: rotateY(180deg); }
.reveal-front, .reveal-back { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.reveal-front { display: grid; place-items: center; }
.reveal-front .gift { height: 100%; width: auto; padding: 0; aspect-ratio: 1.06; cursor: default; }
.reveal-front .nameplate { font-size: clamp(1.65rem, 8vw, 3rem); }
.reveal-back { transform: rotateY(180deg); }
.letter {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 1.25rem; background: var(--cream); color: var(--pine); text-align: center;
  box-shadow: 0 6px 0 #ca9e7e;
}
.solo-letter { position: relative; margin: 12svh auto 0; max-width: 100%; }
.holly { width: 3.25rem; height: 1.6rem; position: relative; margin-bottom: .55rem; }
.holly i {
  position: absolute; width: 45%; height: 65%; top: 22%; left: 6%;
  background: #218161; transform: rotate(15deg); border-radius: 0 90% 0 85%;
}
.holly i:last-child { left: auto; right: 6%; transform: rotate(-15deg) scaleX(-1); background: #369970; }
.holly b, .holly b::before, .holly b::after { width: .55rem; height: .55rem; border-radius: 50%; background: #dc4540; }
.holly b { position: absolute; z-index: 1; left: 43%; bottom: 3%; }
.holly b::before, .holly b::after { content: ""; position: absolute; left: -.27rem; top: -.35rem; }
.holly b::after { left: .21rem; }
.letter-intro { font-size: clamp(1.08rem, 4vw, 1.5rem); font-weight: 650; }
.recipient { margin: .06em 0 .16em; font-size: clamp(2.65rem, 14vw, 5rem); line-height: 1.04; font-weight: 800; letter-spacing: -.04em; color: #b82b36; }
.reminder { max-width: calc(100% - 1rem); font: 400 clamp(.875rem, 3.72vw, 1.22rem)/1.22 "Barlow Condensed", system-ui, sans-serif; text-wrap: balance; }
.close-letter {
  position: absolute; right: .1rem; top: .1rem; width: 2.75rem; height: 2.75rem;
  border: 0; border-radius: 50%; background: transparent; cursor: pointer;
}
.close-letter::before, .close-letter::after {
  content: ""; position: absolute; left: 32%; top: calc(50% - 1.5px); width: 36%; height: 3px;
  border-radius: 2px; background: var(--pine); transform: rotate(45deg);
}
.close-letter::after { transform: rotate(-45deg); }
.close-letter:focus-visible { outline-color: var(--pine); outline-offset: -5px; }
.reveal[open] .close-letter { animation: appear .18s .45s both; }
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }
.paper-stars { position: absolute; inset: 0; pointer-events: none; }
.paper-stars i {
  position: absolute; top: 50%; left: 50%; width: .75rem; aspect-ratio: 1; opacity: 0;
  background: #ffda68; clip-path: polygon(50% 0, 62% 36%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 36%);
}
.paper-stars i:nth-child(3n) { background: #97e2c3; }
.paper-stars i:nth-child(3n+1) { background: var(--cream); }

@media (min-width: 900px) and (min-height: 520px) {
  .stage { width: min(56vw, 47rem); padding-inline: 0; padding-top: max(4.5rem, 10svh); }
  .gifts { width: min(100%, 37.75rem, 75svh); }
  .scene-footer { flex-basis: 5rem; }
}
@media (max-height: 520px) and (min-aspect-ratio: 1/1) {
  .stage { padding-top: 2.2rem; width: min(70%, 37rem); }
  .masthead h1 { font-size: clamp(1.8rem, 7.2vh, 2.7rem); }
  .title-first { display: inline; font-size: 1em; }
  .title-first::before, .title-first::after { content: none; }
  .title-main { display: inline; }
  .instruction { font-size: 1rem; margin-top: .55rem; }
  .gifts { width: min(100%, 70svh); margin-top: .85rem; row-gap: .7rem; }
  .scene-footer { flex-basis: 3.5rem; }
  .reveal { width: min(90vw, 29rem); }
  .reveal-move { max-height: 80svh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
