:root {
  --void: #10040c;
  --plum: #3a1022;
  --wrap: #611833;
  --wrap-lit: #8a2448;
  --wrap-deep: #2a0c1a;
  --ribbon: #e0c15a;
  --ribbon-deep: #8d6a18;
  --tissue: #f3d5c4;
  --spark: #ff7a9c;
  --ink: #f6eee6;
  --mute: #c9aeb4;
  --seal: #8b2230;
  --box: 200px;
  --half: 100px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  min-height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  background: var(--void);
  font-family: Manrope, ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 12vh 1.5rem 18vh;
}

.stage::before {
  content: "";
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(ellipse 50% 42% at 50% 46%, rgba(138, 36, 72, 0.45), transparent 62%),
    radial-gradient(ellipse 80% 70% at 50% 100%, rgba(16, 4, 12, 1), transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  opacity: 0.09;
  mix-blend-mode: overlay;
  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='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.flash {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 48%, #fff6e8 0%, #ff7a9c 18%, transparent 58%);
}

.stage.is-burst .flash {
  animation: flash 720ms ease-out;
}

@keyframes flash {
  0% { opacity: 0.95; }
  100% { opacity: 0; }
}

.shock {
  position: absolute;
  width: 120px;
  height: 120px;
  border: 2px solid rgba(224, 193, 90, 0.0);
  border-radius: 50%;
  pointer-events: none;
  z-index: 3;
}

.stage.is-burst .shock {
  animation: shock 900ms cubic-bezier(0.12, 0.7, 0.2, 1) forwards;
}

@keyframes shock {
  0% { transform: scale(0.4); opacity: 0.9; border-color: rgba(255, 246, 232, 0.8); }
  100% { transform: scale(7); opacity: 0; border-color: rgba(224, 193, 90, 0); }
}

.bits {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.bit {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 8px;
  height: 14px;
  margin: -7px 0 0 -4px;
  background: var(--ribbon);
  transform: translate(0, 0) rotate(0);
  animation: fly 1.15s cubic-bezier(0.12, 0.62, 0.22, 1) forwards;
  animation-delay: var(--delay, 0ms);
}

.bit.is-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.bit.is-foil {
  width: 4px;
  height: 22px;
}

@keyframes fly {
  0% { opacity: 1; }
  80% { opacity: 1; }
  100% {
    transform: translate(var(--dx), var(--dy)) rotate(var(--rot));
    opacity: 0;
  }
}

.caption {
  position: relative;
  z-index: 4;
  display: grid;
  gap: 0.45rem;
  justify-items: center;
  text-align: center;
  pointer-events: none;
}

.eyebrow {
  margin: 0;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--mute);
}

.title {
  margin: 0;
  font-family: Italiana, "Times New Roman", serif;
  font-size: clamp(2.4rem, 7vw, 4.6rem);
  font-weight: 400;
  letter-spacing: 0.28em;
  text-transform: lowercase;
  line-height: 1;
}

.hint {
  margin: 0.35rem 0 0;
  max-width: 22rem;
  color: var(--mute);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  line-height: 1.45;
}

.hint strong {
  color: var(--ink);
  font-weight: 600;
}

.foot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 1.4rem;
  z-index: 4;
  display: flex;
  justify-content: center;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--mute) 80%, transparent);
}

.parcel {
  position: relative;
  z-index: 4;
  width: min(78vw, 340px);
  height: min(78vw, 340px);
  margin: 0 0 2.8rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  appearance: none;
  -webkit-appearance: none;
  cursor: default;
}

.parcel.is-live {
  cursor: pointer;
}

.parcel:focus-visible {
  outline: 2px solid var(--ribbon);
  outline-offset: 10px;
  border-radius: 24px;
}

.shadow {
  position: absolute;
  left: 50%;
  bottom: 18%;
  width: 58%;
  height: 18%;
  translate: -50% 0;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.55), transparent 70%);
  filter: blur(8px);
  z-index: 1;
}

.scene {
  position: absolute;
  inset: 8%;
  perspective: 900px;
  perspective-origin: 50% 42%;
  z-index: 2;
}

.box {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--box);
  height: var(--box);
  margin: calc(var(--half) * -1) 0 0 calc(var(--half) * -1);
  transform-style: preserve-3d;
  transform: rotateX(-22deg) rotateY(32deg);
  animation: idle 5.6s ease-in-out infinite;
}

.parcel.is-live:hover .box {
  animation-duration: 3.2s;
}

@keyframes idle {
  0%, 100% { transform: rotateX(-22deg) rotateY(28deg) translateY(0); }
  50% { transform: rotateX(-16deg) rotateY(38deg) translateY(-8px); }
}

.face {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 28%),
    repeating-linear-gradient(
      90deg,
      transparent 0 18px,
      rgba(16, 4, 12, 0.12) 18px 19px
    ),
    linear-gradient(145deg, var(--wrap-lit), var(--wrap) 42%, var(--wrap-deep));
  box-shadow: inset 0 0 42px rgba(16, 4, 12, 0.45);
  backface-visibility: hidden;
}

.face.front { transform: translateZ(var(--half)); }
.face.back  { transform: rotateY(180deg) translateZ(var(--half)); }
.face.right { transform: rotateY(90deg) translateZ(var(--half)); }
.face.left  { transform: rotateY(-90deg) translateZ(var(--half)); }
.face.bottom {
  transform: rotateX(-90deg) translateZ(var(--half));
  background: var(--wrap-deep);
}

.lid {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform-origin: 50% 0%;
}

.face.top {
  transform: rotateX(90deg) translateZ(var(--half));
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), transparent 40%),
    linear-gradient(145deg, #9a2c52, var(--wrap) 50%, var(--wrap-deep));
}

.stripe-v,
.stripe-h {
  position: absolute;
  background: linear-gradient(90deg, var(--ribbon-deep), var(--ribbon) 40%, #f4e7a8 50%, var(--ribbon) 60%, var(--ribbon-deep));
  box-shadow: 0 0 12px rgba(224, 193, 90, 0.35);
}

.stripe-v {
  top: 0;
  bottom: 0;
  left: 50%;
  width: 22px;
  translate: -50% 0;
}

.stripe-h {
  left: 0;
  right: 0;
  top: 50%;
  height: 22px;
  translate: 0 -50%;
}

.bow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 86px;
  height: 54px;
  translate: -50% -50%;
  z-index: 2;
}

.loop {
  position: absolute;
  top: 4px;
  width: 44px;
  height: 32px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, #f4e7a8, var(--ribbon) 45%, var(--ribbon-deep));
  box-shadow: inset -6px -4px 10px rgba(80, 50, 0, 0.35);
}

.loop.l { left: 0; transform: rotate(-18deg); }
.loop.r { right: 0; transform: rotate(18deg); }

.knot {
  position: absolute;
  left: 50%;
  top: 12px;
  width: 22px;
  height: 22px;
  translate: -50% 0;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff1b8, var(--ribbon) 50%, var(--ribbon-deep));
  box-shadow: 0 4px 10px rgba(16, 4, 12, 0.35);
}

.tails {
  position: absolute;
  left: 50%;
  top: 28px;
  width: 10px;
  height: 36px;
  translate: -50% 0;
}

.tails::before,
.tails::after {
  content: "";
  position: absolute;
  top: 0;
  width: 12px;
  height: 38px;
  background: linear-gradient(180deg, var(--ribbon), var(--ribbon-deep));
  clip-path: polygon(0 0, 100% 0, 70% 100%, 0 78%);
}

.tails::before { left: -8px; transform: rotate(18deg); }
.tails::after  { right: -8px; transform: rotate(-18deg) scaleX(-1); }

.stage.is-burst .box {
  animation: none;
}

.stage.is-burst .face.front { animation: fling-front 900ms cubic-bezier(0.14, 0.72, 0.2, 1) forwards; }
.stage.is-burst .face.back  { animation: fling-back  920ms cubic-bezier(0.14, 0.72, 0.2, 1) forwards; }
.stage.is-burst .face.left  { animation: fling-left  880ms cubic-bezier(0.14, 0.72, 0.2, 1) forwards; }
.stage.is-burst .face.right { animation: fling-right 940ms cubic-bezier(0.14, 0.72, 0.2, 1) forwards; }
.stage.is-burst .face.bottom{ animation: fling-down  860ms cubic-bezier(0.14, 0.72, 0.2, 1) forwards; }
.stage.is-burst .lid        { animation: fling-lid   980ms cubic-bezier(0.08, 0.78, 0.18, 1) forwards; }
.stage.is-burst .shadow     { animation: fade-shadow 500ms ease forwards; }

@keyframes fling-front {
  to { transform: translateZ(calc(var(--half) + 260px)) rotateX(28deg) rotateZ(-8deg); opacity: 0; }
}
@keyframes fling-back {
  to { transform: rotateY(180deg) translateZ(calc(var(--half) + 240px)) rotateX(-24deg); opacity: 0; }
}
@keyframes fling-left {
  to { transform: rotateY(-90deg) translateZ(calc(var(--half) + 280px)) rotateZ(16deg); opacity: 0; }
}
@keyframes fling-right {
  to { transform: rotateY(90deg) translateZ(calc(var(--half) + 300px)) rotateZ(-20deg); opacity: 0; }
}
@keyframes fling-down {
  to { transform: rotateX(-90deg) translateZ(calc(var(--half) + 80px)) translateY(90px); opacity: 0; }
}
@keyframes fling-lid {
  to { transform: translateY(-210px) rotateX(-48deg) rotateZ(18deg); opacity: 0; }
}
@keyframes fade-shadow {
  to { opacity: 0; }
}

.stage.is-void .box {
  animation: none;
  transform: rotateX(-28deg) rotateY(18deg);
}

.stage.is-void .lid {
  transform: translate(120px, -70px) rotateZ(28deg) rotateX(-20deg);
  opacity: 0.55;
}

.stage.is-void .face.front,
.stage.is-void .face.left,
.stage.is-void .face.right {
  filter: saturate(0.7) brightness(0.7);
}

.stage.is-void .bow {
  opacity: 0;
}

.fallback {
  position: relative;
  z-index: 4;
  margin-top: 0.4rem;
  opacity: 0;
  pointer-events: none;
  font-size: 0.9rem;
}

.fallback a {
  color: var(--ribbon);
}

.stage.is-open .fallback {
  opacity: 1;
  pointer-events: auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .box,
  .parcel.is-live:hover .box,
  .stage.is-burst .face,
  .stage.is-burst .lid,
  .stage.is-burst .flash,
  .stage.is-burst .shock,
  .bit {
    animation: none !important;
  }

  .stage.is-burst .box {
    opacity: 0;
    transition: opacity 200ms linear;
  }
}
