@import url("https://fonts.googleapis.com/css2?family=Dancing+Script:wght@600;700&family=Poppins:ital,wght@0,400;0,500;0,600;0,700;0,800;1,600&display=swap");
@import url("https://use.typekit.net/jxm1zfd.css");

.recipient-experience {
  --recipient-accent: #ef3c82;
  --recipient-ink: #121a34;
  --recipient-ease: cubic-bezier(.16, 1, .3, 1);
  position: fixed;
  inset: 0;
  z-index: 100;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background: radial-gradient(ellipse at center, rgba(255,255,255,.98) 0%, rgba(255,248,248,.9) 42%, rgba(251,229,235,.94) 100%);
  color: var(--recipient-ink);
  font-family: "Poppins", Arial, sans-serif;
  perspective: 1400px;
}

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

.recipient-preview-toolbar {
  position: fixed;
  inset: 12px 12px auto auto;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px 8px 14px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 4px 8px rgba(54, 38, 74, .12);
  color: #484054;
  font-size: .78rem;
  font-weight: 700;
}

.recipient-preview-toolbar button {
  min-height: 38px;
  padding: 7px 13px;
  border: 0;
  border-radius: 999px;
  background: #242033;
  color: #fff;
  font: inherit;
}

.recipient-ecard,
.recipient-stage {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.recipient-ecard {
  display: grid;
  place-items: center;
  padding: clamp(14px, 3vh, 32px) clamp(12px, 3vw, 36px);
  outline: 0;
}

.recipient-stage {
  display: grid;
  place-items: center;
}

.recipient-stage[hidden] {
  display: none !important;
}

.recipient-envelope-heading {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.recipient-envelope {
  appearance: none;
  width: min(92vw, 980px);
  max-width: 100%;
  margin: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: transform .75s var(--recipient-ease), opacity .55s ease, filter .55s ease;
  -webkit-tap-highlight-color: transparent;
}

.recipient-envelope:hover {
  transform: translateY(-3px);
}

.recipient-envelope:focus-visible {
  outline: 3px solid rgba(238, 92, 136, .6);
  outline-offset: 10px;
  border-radius: 16px;
}

.recipient-envelope-svg {
  display: block;
  width: 100%;
  overflow: visible;
  filter: drop-shadow(0 24px 24px rgba(184,108,127,.12));
}

.recipient-open-flap,
.recipient-closed-flap,
.recipient-seal,
.recipient-seal-note,
.recipient-envelope-card,
.recipient-celebration,
.recipient-burst {
  transform-box: fill-box;
  transform-origin: center;
}

.recipient-open-flap {
  opacity: 0;
  transform: scaleY(-.78);
  transform-origin: 50% 0;
}

.recipient-closed-flap {
  transform-origin: 50% 0;
}

.recipient-front-left,
.recipient-front-right {
  opacity: .8;
}

.recipient-envelope-card {
  opacity: 0;
  transform: translateY(-80px) rotate(-.6deg);
}

.recipient-celebration,
.recipient-burst {
  opacity: 0;
  transform: translateY(30px) scale(.72);
}

.recipient-envelope.is-opening .recipient-seal,
.recipient-envelope.is-opening .recipient-seal-note {
  animation: recipient-seal-release .22s cubic-bezier(.2,.8,.2,1) forwards;
}

.recipient-envelope.is-opening .recipient-closed-flap {
  animation: recipient-flap-flip .58s var(--recipient-ease) 50ms forwards;
}

.recipient-envelope.is-opening .recipient-flap-seam {
  animation: recipient-seam-release .12s ease 90ms forwards;
}

.recipient-envelope.is-opening .recipient-open-flap {
  animation: recipient-back-flap .2s ease .48s forwards;
}

.recipient-envelope.is-opening .recipient-celebration,
.recipient-envelope.is-opening .recipient-burst {
  animation: recipient-celebration .48s var(--recipient-ease) .62s forwards;
}

.recipient-envelope.is-opening .recipient-envelope-card {
  animation: recipient-card-rise .62s var(--recipient-ease) .64s forwards;
}

.recipient-envelope.is-opening .recipient-front-left,
.recipient-envelope.is-opening .recipient-front-right {
  animation: recipient-pocket-settle .18s ease .62s forwards;
}

.recipient-tap {
  position: absolute;
  right: auto;
  bottom: clamp(20px, 5vh, 48px);
  left: 50%;
  width: max-content;
  margin: 0;
  color: rgba(58,37,72,.68);
  font-size: clamp(.78rem, 1.8vh, .92rem);
  font-weight: 800;
  letter-spacing: .08em;
  text-align: center;
  text-transform: uppercase;
  transform: translateX(-50%);
  transition: opacity .2s ease, transform .2s ease;
}

.recipient-envelope.is-opening + .recipient-tap {
  opacity: 0;
  transform: translate(-50%, -6px);
}

.recipient-screen-confetti {
  position: fixed;
  inset: 0;
  z-index: 112;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  pointer-events: none;
}

.recipient-confetti-piece {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w, 8px);
  height: var(--h, 16px);
  border-radius: var(--r, 2px);
  background: var(--c, #ef4f86);
  opacity: 0;
  animation: recipient-confetti var(--dur, 2.7s) cubic-bezier(.16,.72,.28,1) var(--delay, 0s) forwards;
}

.recipient-confetti-piece.is-circle {
  --r: 50%;
}

.recipient-stage--card {
  position: fixed;
  inset: 0;
  z-index: 110;
  padding: clamp(10px, 2vh, 24px);
}

.recipient-feature-card {
  position: relative;
  width: min(94vw, 560px);
  max-height: min(96vh, 920px);
  max-height: min(96dvh, 920px);
  padding: clamp(40px, 5.2vh, 54px) clamp(24px, 4vw, 36px) clamp(8px, 1vh, 12px);
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, .78);
  border-radius: clamp(32px, 4.5vw, 42px);
  background: linear-gradient(180deg, #fff, #fffdfd 58%, #fff8fb);
  box-shadow: 0 28px 72px rgba(54,38,74,.13), 0 1px 0 rgba(255,255,255,.9) inset;
  color: var(--recipient-ink);
  opacity: 0;
  transform: translateY(130px) scale(.38) rotate(-8deg) rotateY(-94deg);
  transform-origin: 50% 72%;
  transform-style: preserve-3d;
  backface-visibility: hidden;
}

.recipient-feature-card.is-visible {
  animation: recipient-card-pop 1.08s var(--recipient-ease) forwards;
}

/* Backend polling can rebuild an already-open recipient view. Restore that
   card directly in its final state so the entrance animation does not replay. */
.recipient-feature-card.is-open-static {
  opacity: 1;
  filter: blur(0);
  transform: translateY(0) scale(1);
}

.recipient-feature-brand {
  position: relative;
  z-index: 1;
  display: block;
  width: min(34%, 144px);
  margin: 0 auto;
}

.recipient-feature-logo {
  display: block;
  width: 100%;
  max-height: 78px;
  height: auto;
  object-fit: contain;
}

.recipient-kicker {
  width: max-content;
  max-width: 100%;
  margin: 0 auto;
  padding: 8px 18px 7px;
  border: 1px solid rgba(255,63,143,.12);
  border-radius: 999px;
  background: rgba(255,246,250,.74);
  box-shadow: 0 8px 22px rgba(55,35,70,.04);
  color: #e72670;
  font-size: clamp(11px, 1.45vh, 13px);
  font-weight: 800;
  letter-spacing: .11em;
  text-align: center;
  text-transform: uppercase;
}

.recipient-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(7px, .95vh, 12px);
  margin: clamp(4px, .65vh, 8px) 0 clamp(5px, .75vh, 9px);
  color: var(--recipient-ink);
  font: 800 clamp(32px, 4.9vh, 45px)/1 "Poppins", Arial, sans-serif;
  letter-spacing: 0;
  text-align: center;
}

.recipient-card-heading {
  display: grid;
  gap: 6px;
  text-align: center;
}

.recipient-card-note {
  max-width: 34rem;
  margin: 0 auto 3px;
  color: #7b2850;
  font-size: .92rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
  text-wrap: pretty;
  white-space: pre-wrap;
}

.recipient-title-line,
.recipient-title-name {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.recipient-title-line {
  display: inline-block;
}

.recipient-title-name {
  position: relative;
  z-index: 3;
  display: inline-block;
  color: var(--recipient-accent);
  font-family: "brushberry-script", "Dancing Script", cursive;
  font-size: 1.72em;
  font-weight: 700;
  line-height: .82;
  margin-top: clamp(4px, .7vh, 8px);
  letter-spacing: 0;
  text-shadow: 0 8px 20px rgba(239,50,124,.12);
}

.recipient-media {
  margin-top: clamp(11px, 1.5vh, 16px);
}

.recipient-art {
  position: relative;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  overflow: hidden;
  border-radius: clamp(25px, 3vw, 32px);
  background: #ffeaf2;
  box-shadow: 0 18px 42px rgba(62,42,76,.09), inset 0 1px 0 rgba(255,255,255,.82);
}

.recipient-art-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.recipient-art-placeholder {
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 25% 25%, #ffd8e5, transparent 38%), linear-gradient(145deg, #fff2f7, #f3dff1);
  color: #8d315c;
  font-weight: 800;
  text-align: center;
}

.recipient-play {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(78px, 10.2vh, 90px);
  height: clamp(78px, 10.2vh, 90px);
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255,255,255,.94);
  border-radius: 50%;
  background: linear-gradient(145deg, #ff468e, #e82670);
  box-shadow: 0 8px 14px rgba(196,45,105,.3), 0 0 0 10px rgba(255,255,255,.55), 0 0 0 17px rgba(255,63,143,.1);
  cursor: pointer;
  transition: transform .2s ease;
}

.recipient-play:hover {
  transform: translate(-50%, -50%) scale(1.025);
}

.recipient-play::after {
  content: "";
  position: absolute;
  left: 42%;
  top: 32%;
  border-top: 14px solid transparent;
  border-bottom: 14px solid transparent;
  border-left: 21px solid #fff;
}

.recipient-play.is-playing::after {
  left: 50%;
  top: 50%;
  width: 20px;
  height: 26px;
  transform: translate(-50%, -50%);
  border: 0;
  background: linear-gradient(90deg, #fff 0 36%, transparent 36% 64%, #fff 64% 100%);
}

.recipient-player-panel {
  position: relative;
  z-index: 2;
  width: 84%;
  margin: -18px auto 0;
  padding: clamp(11px, 1.45vh, 16px) clamp(10px, 2.3vw, 14px) clamp(11px, 1.5vh, 16px);
  border-radius: clamp(24px, 3vw, 34px);
  background: rgba(255,255,255,.92);
  box-shadow: 0 14px 32px rgba(62,42,76,.08), 0 -1px 0 rgba(255,255,255,.68), inset 0 1px 0 rgba(255,255,255,.86);
}

.recipient-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 100%;
  height: clamp(18px, 2.6vh, 28px);
  padding: 0 3px;
  cursor: pointer;
}

.recipient-wave-bar {
  flex: 1;
  min-width: 1px;
  border-radius: 999px;
  background: rgba(235,194,209,.72);
  transition: background .16s ease, transform .16s ease;
}

.recipient-wave-bar.is-active {
  background: linear-gradient(180deg, #ef3c82, #ff82b0);
}

.recipient-feature-card.is-playing .recipient-wave-bar.is-active {
  animation: recipient-wave-pulse .76s ease-in-out infinite alternate;
  animation-delay: calc(var(--i) * -28ms);
}

.recipient-time-row {
  display: flex;
  justify-content: space-between;
  width: calc(100% - 24px);
  margin: 5px auto 0;
  color: #27233e;
  font: 800 clamp(12px, 1.55vh, 14px) "Poppins", Arial, sans-serif;
}

.recipient-audio {
  display: none;
}

.recipient-audio.is-fallback {
  display: block;
  width: 100%;
  height: 38px;
  margin-top: 8px;
}

.recipient-message,
.recipient-song-notice {
  margin-top: 9px;
  padding: 9px 15px;
  border: 1px solid rgba(255,63,143,.12);
  border-radius: 16px;
  background: #fff6fa;
  color: #7b2850;
  text-align: center;
}

.recipient-message p,
.recipient-song-notice {
  margin: 0;
  font-size: clamp(.82rem, 1.65vh, .96rem);
  line-height: 1.4;
}

.recipient-message p {
  margin: 0;
}

.recipient-song-notice {
  display: grid;
  gap: 3px;
}

.recipient-footer {
  margin: 7px 0 0;
  color: #6d6978;
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
}

.recipient-footer-heart {
  color: #e10b63;
  font-size: 1.08em;
}

.recipient-download {
  display: flex;
  justify-content: center;
  width: max-content;
  max-width: 100%;
  margin: 9px auto 0;
  padding: 9px 15px;
  border-radius: 999px;
  background: linear-gradient(135deg, #e01061, #ff4f91);
  color: #fff;
  font-size: .78rem;
  font-weight: 800;
  text-decoration: none;
}

@keyframes recipient-seal-release {
  0% { opacity: 1; transform: scale(1); }
  38% { opacity: 1; transform: scale(1.12); }
  100% { opacity: 0; transform: scale(.58); }
}

@keyframes recipient-flap-flip {
  0%, 18% { opacity: 1; transform: scaleY(1); }
  72%, 88% { opacity: 1; transform: scaleY(-.78); }
  100% { opacity: 0; transform: scaleY(-.78); }
}

@keyframes recipient-seam-release { to { opacity: 0; } }

@keyframes recipient-back-flap {
  from { opacity: 0; transform: scaleY(-.2); }
  to { opacity: 1; transform: scaleY(-.78); }
}

@keyframes recipient-pocket-settle { to { opacity: .98; } }

@keyframes recipient-celebration {
  0% { opacity: 0; transform: translateY(30px) scale(.72); }
  70% { opacity: 1; transform: translateY(-6px) scale(1.04); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes recipient-card-rise {
  0% { opacity: 0; transform: translateY(-80px) rotate(-.6deg); }
  14% { opacity: 1; transform: translateY(-145px) rotate(-.3deg); }
  100% { opacity: 1; transform: translateY(-260px); }
}

@keyframes recipient-card-pop {
  0% { opacity: 0; filter: blur(4px); transform: translateY(130px) scale(.38) rotate(-8deg) rotateY(-94deg); }
  46% { opacity: 1; filter: blur(0); transform: translateY(-22px) scale(1.05) rotate(2deg) rotateY(12deg); }
  72% { opacity: 1; transform: translateY(8px) scale(.98) rotate(-1deg) rotateY(-4deg); }
  100% { opacity: 1; filter: blur(0); transform: translateY(0) scale(1); }
}

@keyframes recipient-confetti {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(0) scale(.72); }
  7%, 58% { opacity: 1; }
  58% { transform: translate(-50%, -50%) translate(var(--peak-x), var(--peak-y)) rotate(var(--rot)) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -50%) translate(var(--end-x), var(--end-y)) rotate(var(--rot)) scale(.9); }
}

@keyframes recipient-wave-pulse {
  from { transform: scaleY(.78); }
  to { transform: scaleY(1.14); }
}

@media (max-width: 560px) {
  .recipient-preview-toolbar {
    inset: 8px 8px auto;
    justify-content: space-between;
  }

  .recipient-envelope {
    width: min(96vw, 460px);
  }

  .recipient-feature-card {
    width: min(92vw, 390px);
    max-height: 94dvh;
    padding: 34px 22px 12px;
    border-radius: 26px;
  }

  .recipient-kicker {
    font-size: .62rem;
    letter-spacing: .06em;
  }

  .recipient-title {
    font-size: clamp(1.65rem, 7.5vw, 2.35rem);
  }

  .recipient-art {
    height: clamp(150px, 24dvh, 200px);
  }

  .recipient-play {
    width: 72px;
    height: 72px;
  }
}

@media (max-height: 800px) and (min-width: 561px) {
  .recipient-envelope { width: min(92vw, 780px); }
  .recipient-feature-card { width: min(82vw, 560px); padding-block: 22px 12px; }
  .recipient-art { height: 185px; }
}

@media (prefers-reduced-motion: reduce) {
  .recipient-experience *,
  .recipient-experience *::before,
  .recipient-experience *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }

  .recipient-confetti-piece {
    display: none !important;
  }
}
