@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,500;0,600;1,400&family=Great+Vibes&family=Jost:wght@400;500&display=swap");

/* Self-contained gift envelope. Image URLs are relative to this file. */
.envx {
  --ink: #3c1424;
  --gold: #b8956a;
  --gold-deep: #8c6b38;
  --paper: #f7f1e6;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  color: var(--ink);
  background: #efe6dc url("./stone.jpg") center / cover no-repeat;
  min-height: 100%;
}
.envx[data-season="default"] {
  background: #efe6dc url("./stone.jpg") center / cover no-repeat;
}
.envx[data-season="birthday"] {
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 214, 206, .85), transparent 42%),
    linear-gradient(180deg, #f8ebe6 0%, #f3ece4 100%);
}
.envx[data-season="christmas"],
body[data-season="christmas"] .envx:not([data-season]) {
  background-color: #1a120c;
  background-image: url("./table.jpg");
  background-image: image-set(
    url("./table.avif") type("image/avif"),
    url("./table.webp") type("image/webp"),
    url("./table.jpg") type("image/jpeg")
  );
  background-position: center 36%;
  background-size: cover;
}
.envx-bokeh,
.envx-vignette,
.envx-snow { display: none; }
.envx[data-season="christmas"] .envx-bokeh,
.envx[data-season="christmas"] .envx-vignette,
.envx[data-season="christmas"] .envx-snow,
body[data-season="christmas"] .envx:not([data-season]) .envx-bokeh,
body[data-season="christmas"] .envx:not([data-season]) .envx-vignette,
body[data-season="christmas"] .envx:not([data-season]) .envx-snow { display: block; }

.envx-bokeh {
  position: absolute;
  inset: -8%;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at 16% 30%, rgba(255, 214, 140, .75) 0 2px, transparent 9px),
    radial-gradient(circle at 22% 22%, rgba(255, 236, 190, .55) 0 1px, transparent 6px),
    radial-gradient(circle at 74% 18%, rgba(255, 220, 160, .7) 0 2px, transparent 8px),
    radial-gradient(circle at 82% 28%, rgba(255, 196, 110, .45) 0 1px, transparent 7px),
    radial-gradient(circle at 64% 34%, rgba(255, 228, 170, .4) 0 2px, transparent 8px),
    radial-gradient(circle at 38% 16%, rgba(255, 210, 140, .35) 0 1px, transparent 5px);
  mix-blend-mode: screen;
  animation: envx-drift 9s ease-in-out infinite;
}
@keyframes envx-drift {
  0%, 100% { transform: translate3d(0, 0, 0); opacity: .45; }
  50% { transform: translate3d(-10px, 6px, 0); opacity: .8; }
}
.envx-vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 72%, rgba(12, 8, 4, .42), transparent 58%),
    linear-gradient(to bottom, rgba(12, 8, 4, .05), rgba(12, 8, 4, .2) 78%);
}
.envx-snow {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
  opacity: .75;
}
.envx-snow i {
  position: absolute;
  top: -8%;
  left: var(--x, 50%);
  width: var(--s, 3px);
  height: var(--s, 3px);
  border-radius: 50%;
  background: rgba(255, 255, 255, .85);
  opacity: .7;
  animation: envx-snow var(--t, 12s) linear infinite;
  animation-delay: var(--d, 0s);
}
@keyframes envx-snow {
  from { transform: translate3d(0, -4vh, 0); }
  to { transform: translate3d(12px, 108vh, 0); }
}
.envx[data-season="birthday"] .flora-xmas,
.envx[data-season="christmas"] .flora-birth,
.envx[data-season="default"] .flora-birth { display: none; }

.envx-scene {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  min-height: inherit;
  perspective: 1600px;
  perspective-origin: 50% 42%;
}
.envx-overlay .envx-scene,
.envx:not(.envx-inline):not(.envx-overlay) .envx-scene { height: 100vh; min-height: 100vh; }
.envx-pack { visibility: hidden; }
.envx-inline { min-height: 680px; border-radius: 18px; }
.envx-inline .envx-scene { height: 680px; }

.envx-rig {
  position: absolute;
  left: 50%;
  top: 68%;
  width: min(1080px, 62vw);
  aspect-ratio: 1.72 / 1;
  transform: translate(-50%, -50%);
}
.envx-shadow {
  position: absolute;
  left: 50%;
  bottom: -7%;
  width: 78%;
  height: 22%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(18, 10, 4, .55), transparent 70%);
  filter: blur(1px);
  pointer-events: none;
  z-index: 0;
}
.envx-flip {
  position: absolute;
  inset: 0;
  transform: rotateX(13deg);
  transform-style: preserve-3d;
}
.envx-sealed,
.envx-pack {
  position: absolute;
  inset: 0;
}
.envx-pack { transform-style: flat; }
.envx-sealed { z-index: 3; transform-origin: 50% 50%; }
.envx-pack { z-index: 2; transform-origin: 50% 50%; }

.envx-paper {
  background-color: var(--paper);
  background-image:
    repeating-linear-gradient(0deg, rgba(92, 72, 52, .045) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(92, 72, 52, .03) 0 1px, transparent 1px 5px),
    linear-gradient(180deg, rgba(255, 255, 255, .35), transparent 40%);
}
.envx-sealed,
.envx-back,
.envx-pocket,
.envx-flap-out {
  border-radius: 2px;
  box-shadow:
    0 16px 22px rgba(18, 10, 4, .32),
    0 2px 3px rgba(18, 10, 4, .28);
}
.envx-back,
.envx-liner,
.envx-pocket,
.envx-flap,
.envx-card,
.envx-spark,
.envx-behind,
.envx-front {
  position: absolute;
  inset: 0;
}
.envx-behind { z-index: 1; }
.envx-front { z-index: 4; pointer-events: none; }
.envx-back { inset: 0; }
.envx-liner {
  left: 0; right: 0; top: 0; bottom: auto;
  height: 40%;
  z-index: 1;
  clip-path: polygon(0 0, 100% 0, 82% 100%, 18% 100%);
  background:
    linear-gradient(115deg, transparent 32%, rgba(255, 255, 255, .55) 48%, transparent 60%),
    linear-gradient(168deg, #f8e7b0, #e2c27a 30%, #c6a15a 58%, #8c6a32 82%, #ead7a2);
  background-size: 220% 100%, 100% 100%;
  box-shadow: none;
}
.envx.is-open .envx-liner { animation: envx-sheen 1.3s ease .15s both; }
@keyframes envx-sheen {
  from { background-position: 130% 0, 0 0; }
  to { background-position: -30% 0, 0 0; }
}
.envx-pocket {
  z-index: 8;
  clip-path: polygon(0 34%, 50% 62%, 100% 34%, 100% 100%, 0 100%);
  filter: drop-shadow(0 -1px 0 rgba(74, 56, 38, .55));
  box-shadow: none;
}
.envx-pocket::before {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(0 34%, 50% 62%, 100% 34%, 100% 48%, 50% 76%, 0 48%);
  background: linear-gradient(to bottom, rgba(48, 32, 18, .2), transparent 70%);
  pointer-events: none;
}
.envx-flap {
  left: 0; right: 0; top: 0; bottom: auto;
  height: 58%;
  z-index: 6;
  transform-origin: 50% 0%;
}
.envx-flap-out,
.envx-flap-in {
  position: absolute;
  inset: 0;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.envx-flap-in {
  transform: rotateX(180deg);
  background:
    linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .45) 48%, transparent 62%),
    linear-gradient(168deg, #f8e7b0, #c6a15a 55%, #8c6a32);
  box-shadow: none;
}

.envx-stamp {
  position: absolute;
  top: 9%;
  right: 6%;
  width: 28%;
  aspect-ratio: 1.15 / 1;
  padding: 8% 7% 7%;
  background: #fbf7f1;
  border: 1px dashed rgba(122, 101, 82, .65);
  box-shadow: 0 0 0 4px var(--paper), 0 0 0 5px rgba(122, 101, 82, .4);
}
.envx-stamp img { display: block; width: 100%; height: auto; }
.envx-stamp { z-index: 1; }
.envx-postmark {
  position: absolute;
  top: -4%;
  right: -1%;
  width: 46%;
  z-index: 2;
  opacity: .9;
  mix-blend-mode: multiply;
  pointer-events: none;
  transform: rotate(12deg);
}
.envx-postmark svg { width: 100%; height: auto; display: block; }
.envx-script {
  position: absolute;
  left: 8%;
  bottom: 10%;
  margin: 0;
  max-width: 54%;
  font-family: "Great Vibes", cursive;
  font-size: clamp(40px, 4.6vw, 54px);
  font-weight: 400;
  line-height: .9;
  color: var(--ink);
  transform: rotate(-8deg);
}

.envx-card {
  z-index: 3;
  left: 13%;
  right: 13%;
  top: 18%;
  bottom: auto;
  width: auto;
  height: auto;
  min-height: 0;
  padding: 28px 22px 22px;
  text-align: center;
  background: #fbf7f0;
  color: var(--ink);
  box-shadow: 0 16px 30px rgba(20, 12, 6, .28);
  pointer-events: none;
  transform-origin: 50% 62%;
}
.envx.is-settled .envx-card { pointer-events: auto; }
.envx-card .envx-rule {
  position: absolute;
  inset: 8px;
  border: 1px solid var(--gold);
  pointer-events: none;
}
.envx-card .envx-rule::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(184, 149, 106, .85);
}
.envx-flora {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 78%;
  height: auto;
  transform: translate(-50%, -50%);
  opacity: .22;
  pointer-events: none;
}
.envx-crest {
  position: relative;
  width: 64px;
  margin: 0 auto 4px;
  display: block;
}
.envx-kicker {
  position: relative;
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  letter-spacing: .22em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--gold-deep);
}
.envx-name {
  position: relative;
  margin: 2px 0 6px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  font-size: clamp(40px, 5vw, 58px);
  line-height: .9;
  color: var(--ink);
}
.envx-msg {
  position: relative;
  margin: 0 auto;
  max-width: 16em;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-size: 16px;
  line-height: 1.3;
  color: #3a2a24;
}
.envx-value {
  position: relative;
  margin: 8px 0 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  font-size: 36px;
  line-height: 1;
  color: var(--ink);
}
.envx-fine {
  position: relative;
  margin: 8px 0 0;
  font-family: Jost, "Helvetica Neue", sans-serif;
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #6e584c;
}
.envx-book {
  position: relative;
  display: inline-block;
  margin-top: 10px;
  font-family: Jost, "Helvetica Neue", sans-serif;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink);
  border-bottom: 1px solid var(--gold);
  text-decoration: none;
}

.envx-spark {
  z-index: 6;
  pointer-events: none;
}
.envx-spark i {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 7px;
  height: 7px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 20%, #f3dd9a 45%, transparent 72%);
  opacity: 0;
  transform: scale(0);
}

.envx-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 22px;
  z-index: 8;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}
.envx-open,
.envx-mute,
.envx-close {
  font-family: Jost, "Helvetica Neue", sans-serif;
  letter-spacing: .18em;
  text-transform: uppercase;
  font-size: 12px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 44px;
}
.envx-open {
  color: var(--ink);
  background: rgba(255, 251, 245, .92);
  border: 1px solid rgba(60, 20, 36, .28);
  padding: 12px 22px;
}
.envx[data-season="christmas"] .envx-open,
body[data-season="christmas"] .envx:not([data-season]) .envx-open {
  color: #fffaf3;
  background: rgba(28, 16, 12, .42);
  border-color: rgba(255, 236, 210, .6);
}
.envx-mute,
.envx-close {
  background: rgba(255, 251, 245, .88);
  border: 1px solid rgba(60, 40, 30, .25);
  color: #2c1814;
  padding: 10px 14px;
}
.envx.is-open .envx-open { visibility: hidden; }
.envx-overlay {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: none;
  min-height: 100vh;
}
.envx-overlay.is-shown { display: block; }
.envx-close {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 44px;
  height: 44px;
  padding: 0;
  z-index: 9;
  border-radius: 50%;
}

@media (max-width: 800px), (max-aspect-ratio: 4/5) {
  .envx-rig { top: 64%; width: 86vw; }
  .envx-inline { min-height: 560px; }
  .envx-inline .envx-scene { height: 560px; }
  .envx-script { font-size: 44px; }
  .envx-card { padding: 22px 16px 16px; }
  .envx-name { font-size: 40px; }
  .envx-value { font-size: 30px; }
  .envx-msg { font-size: 15px; }
}
@media (max-aspect-ratio: 9/16) {
  .envx[data-season="christmas"],
  body[data-season="christmas"] .envx:not([data-season]) { background-position: center 58%; }
  .envx-rig { top: 73%; }
}

@media (prefers-reduced-motion: reduce) {
  .envx-bokeh,
  .envx-snow,
  .envx-snow i,
  .envx.is-open .envx-liner { animation: none; }
  .envx-snow { opacity: .35; }
}

body.record-mode .envx-actions,
body.record-mode .envx-close { display: none !important; }
