/* The sealed envelope on a dark table. */

.stage {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: safe center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  overflow: auto;
  background:
    radial-gradient(90% 55% at 50% 108%, var(--night-lift) 0%, transparent 62%),
    radial-gradient(120% 80% at 50% 38%, var(--night-lift) 0%, var(--night) 68%);
  transition: opacity var(--dur-slow) var(--ease-out);
}
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.stage.gone { opacity: 0; pointer-events: none; }

.stage-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(14px, 3vh, 28px);
  width: 100%;
}

.addressee {
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: var(--track);
  text-transform: uppercase;
  color: var(--metal-hi);
  text-align: center;
}
.addressee b {
  display: block;
  margin-top: 8px;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 26px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--paper);
}

.hint {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: var(--track);
  text-transform: uppercase;
  color: var(--paper);
  opacity: 0.82;
  animation: breathe 2.8s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: 0.45; } }

.skip {
  margin-top: -12px;
  padding: 12px 18px;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: var(--track-tight);
  text-transform: uppercase;
  text-decoration: underline;
  text-underline-offset: 4px;
  color: color-mix(in srgb, var(--paper) 88%, transparent);
}

.env-space {
  width: min(var(--env-width), 58svh);
  perspective: 1600px;
}
.env {
  position: relative;
  width: 100%;
  aspect-ratio: var(--env-ratio);
  transform-style: preserve-3d;
}
@media (prefers-reduced-motion: no-preference) {
  .env { animation: arrive 0.7s var(--ease-out) both; }
}
.env svg { max-width: none; }
@keyframes arrive { from { opacity: 0; } }

.env-shadow {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -22px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgb(0 0 0 / 0.55), transparent);
  filter: blur(6px);
  z-index: 0;
}
.env-back {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: var(--env-radius);
  background: linear-gradient(165deg, var(--envelope-deep), color-mix(in srgb, var(--envelope-deep) 80%, black));
  box-shadow: var(--shadow-stage);
}
.env-back::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: calc(var(--env-radius) - 2px);
  background:
    repeating-linear-gradient(45deg, var(--liner) 0 2px, transparent 2px 9px),
    var(--liner-deep);
  opacity: 0.55;
}

.card {
  position: absolute;
  left: 5%;
  right: 5%;
  top: 7%;
  height: 86%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  overflow: hidden;
  text-align: center;
  color: var(--ink);
  background: var(--paper);
  border-radius: var(--radius-xs);
  box-shadow:
    0 0 0 var(--ring) color-mix(in srgb, var(--metal) 35%, transparent),
    0 12px 28px -16px rgb(0 0 0 / 0.45);
}
.card.fly {
  position: fixed;
  right: auto;
  margin: 0;
  z-index: 20;
}
.card small {
  font-family: var(--font-ui);
  font-size: 9px;
  letter-spacing: var(--track);
  text-transform: uppercase;
  color: var(--metal-deep);
}
.card .nm {
  font-family: var(--font-script);
  font-size: clamp(32px, 8vw, 46px);
  line-height: 1.05;
}
.card .dt {
  font-size: 15px;
  font-style: italic;
  color: var(--ink-soft);
}
.card-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--night) 55%, transparent), transparent 58%);
}

.env-front {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.flap {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 62%;
  z-index: 4;
  transform-origin: 50% 0;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
}
.flap .face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.flap .face.in { transform: rotateX(180deg); }
.flap .face svg {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.seal {
  position: absolute;
  left: 50%;
  top: 58%;
  z-index: 5;
  width: var(--seal-size);
  height: var(--seal-size);
  margin: calc(var(--seal-size) / -2) 0 0 calc(var(--seal-size) / -2);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.seal::after {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: var(--ring) solid var(--metal-hi);
  opacity: 0;
  animation: ping 2.8s ease-out infinite;
}
@keyframes ping {
  0% { transform: scale(0.84); opacity: 0.7; }
  80%, 100% { transform: scale(1.4); opacity: 0; }
}
.seal.broken::after { display: none; }
.seal .half {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 47% 53% 50% 50% / 52% 46% 54% 48%;
  background: radial-gradient(circle at 34% 30%, var(--seal-hi), var(--seal) 46%, var(--seal-deep) 100%);
  box-shadow: var(--shadow-seal);
}
.seal .l { clip-path: polygon(0 0, 52% 0, 46% 22%, 56% 40%, 45% 60%, 54% 80%, 48% 100%, 0 100%); }
.seal .r { clip-path: polygon(52% 0, 100% 0, 100% 100%, 48% 100%, 54% 80%, 45% 60%, 56% 40%, 46% 22%); }
.seal span {
  font-family: var(--font-script);
  font-size: 28px;
  line-height: 1;
  margin-top: 4px;
  color: var(--seal-ink);
  text-shadow: 0 1px 0 rgb(90 40 46 / 0.35);
}
.seal:hover .half { filter: brightness(1.06); }
.seal:focus-visible { outline-offset: 6px; }
