/* The paper is its own layer, so its painted edges follow any message length. */
#receive #gift-card {
  --card-paper: url('./assets/ui/painted-message-card.webp?v=20261118-worldcard1');
  --card-ink: #49372c;
  --card-meta: #705a3e;
  --card-rule: #aa875b85;
  isolation: isolate;
  padding: 42px 28px 38px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--card-ink);
}

body[data-theme="arctic"] #receive #gift-card {
  --card-paper: url('./assets/ui/painted-message-arctic.webp?v=20261118-worldcard1');
  --card-ink: #273e56;
  --card-meta: #4d6379;
  --card-code: var(--card-ink);
  --card-rule: #7fabc28c;
}
body[data-theme="candy"] #receive #gift-card {
  --card-paper: url('./assets/ui/painted-message-candy.webp?v=20261118-worldcard1');
  --card-ink: #573344;
  --card-meta: #80506a;
  --card-code: var(--card-ink);
  --card-rule: #b47e9780;
}
body[data-theme="midnight"] #receive #gift-card {
  --card-paper: url('./assets/ui/painted-message-midnight.webp?v=20261118-worldcard1');
  --card-ink: #3b3149;
  --card-meta: #6c5b79;
  --card-code: var(--card-ink);
  --card-rule: #ac8c4a8c;
}
body[data-theme="workshop"] #receive #gift-card {
  --card-paper: url('./assets/ui/painted-message-workshop.webp?v=20261118-worldcard1');
  --card-ink: #344735;
  --card-meta: #556248;
  --card-code: var(--card-ink);
  --card-rule: #8f9c6c8c;
}
body[data-theme="gingerbread"] #receive #gift-card {
  --card-paper: url('./assets/ui/painted-message-gingerbread.webp?v=20261118-worldcard1');
  --card-ink: #563929;
  --card-meta: #82583d;
  --card-code: var(--card-ink);
  --card-rule: #b68a608c;
}
body[data-theme="neon"] #receive #gift-card {
  --card-paper: url('./assets/ui/painted-message-neon.webp?v=20261118-worldcard1');
  --card-ink: #3f345a;
  --card-meta: #685980;
  --card-code: var(--card-ink);
  --card-rule: #a68bb68c;
}
body[data-theme="newyear"] #receive #gift-card {
  --card-paper: url('./assets/ui/painted-message-newyear.webp?v=20261118-worldcard1');
  --card-ink: #473950;
  --card-meta: #705976;
  --card-code: var(--card-ink);
  --card-rule: #b59a6a8c;
}

#receive #gift-card::before,
#receive #gift-card::after {
  display: none;
  content: none;
}

#receive #gift-card .card-paper {
  position: absolute;
  z-index: -1;
  inset: -4px;
  box-sizing: border-box;
  border: solid transparent;
  border-width: 52px 64px 56px;
  border-image-source: var(--card-paper);
  border-image-slice: 230 280 250 280 fill;
  border-image-width: 52px 64px 56px 64px;
  border-image-repeat: stretch;
  filter: drop-shadow(0 2px 1px #7453344d) drop-shadow(0 12px 16px #07101c66);
  pointer-events: none;
}

#receive #gift-card .card-to {
  margin: 0 0 22px;
  padding: 0 32px;
  font: 400 14px/1.5 var(--ui-display);
  letter-spacing: 0;
  text-transform: none;
  text-align: center;
  color: var(--card-meta, #7b6547);
  overflow-wrap: anywhere;
}

#receive #gift-card .card-msg {
  margin: 0 0 24px;
  line-height: 1.4;
  color: var(--card-ink);
}

#receive #gift-card .card-from {
  margin: 0 40px 0 0;
  padding-top: 6px;
  font: italic 400 14px/1.5 var(--ui-display);
  color: var(--card-meta, #71543b);
}

/* A gift code reads like a small enclosure on the same sheet. */
#receive #gift-card .ticket {
  margin-top: 25px;
  padding: 19px 0 0;
  border: 0;
  border-top: 1px dashed var(--card-rule);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
#receive #gift-card .ticket > small { color: var(--card-meta, #806b4c); }
#receive #gift-card .ticket strong {
  margin: 10px 0 14px;
  color: var(--card-ink);
}
#receive #gift-card .ticket-code { gap: 10px; }
#receive #gift-card .ticket code {
  min-width: 0;
  color: var(--card-code, #614b32);
  overflow-wrap: anywhere;
}
#receive #gift-card .ticket button {
  position: relative;
  isolation: isolate;
  flex: 0 0 auto;
  min-width: 56px;
  min-height: 44px;
  padding: 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #fff0ce;
  font: 700 10px/1.4 Arial, sans-serif;
}
#receive #gift-card .ticket button::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: -1px -2px;
  border: 7px solid transparent;
  border-image-source: var(--painted-evergreen);
  border-image-slice: 30% 14% fill;
  border-image-width: 7px 12px;
  pointer-events: none;
}
#receive #gift-card .ticket .btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 44px;
  margin-top: 15px;
  padding: 14px 24px;
  font: 400 16px/1.2 var(--ui-display);
  text-align: center;
  color: #49372c;
  text-shadow: none;
}
#receive #gift-card .ticket .btn small {
  max-width: 100%;
  font: 700 9px/1.4 Arial, sans-serif;
  letter-spacing: .04em;
  color: #705a3e;
  overflow-wrap: anywhere;
}

/* Preserve the established arrival, with shadows only on the irregular paper. */
#recipient.message-arriving #gift-card {
  box-shadow: none;
  animation: illustratedCardArrival 1.12s cubic-bezier(.18, .72, .24, 1) both;
}
#receive #gift-card.physical-reveal {
  animation: illustratedCardArrival 1.12s cubic-bezier(.18, .72, .24, 1) both;
}
#recipient.message-arriving #gift-card .card-paper {
  animation: illustratedPaperGlow 2.6s ease-out both;
}

@keyframes illustratedCardArrival {
  0% {
    opacity: 0;
    transform: perspective(800px) translateY(var(--card-lift, 50px)) scale(.91) rotateX(9deg) rotate(2.4deg);
  }
  28% { opacity: 1; }
  72% { transform: perspective(800px) translateY(-3px) scale(1.008) rotateX(0) rotate(-.7deg); }
  100% {
    opacity: 1;
    transform: perspective(800px) translateY(0) scale(1) rotateX(0) rotate(-.45deg);
  }
}
@keyframes illustratedPaperGlow {
  0%, 100% {
    filter: drop-shadow(0 2px 1px #7453344d) drop-shadow(0 12px 16px #07101c66);
  }
  22% {
    filter: drop-shadow(0 2px 1px #7453344d) drop-shadow(0 12px 16px #07101c66) drop-shadow(0 0 16px var(--message-glow-soft));
  }
}

@media (max-width: 360px) {
  #receive #gift-card { padding: 40px 21px 37px; }
  #receive #gift-card .card-to { margin-bottom: 19px; padding-inline: 32px; font-size: 13px; }
  #receive #gift-card .card-msg { margin-bottom: 21px; }
  #receive #gift-card .card-from { margin-right: 39px; font-size: 13px; }
  #receive #gift-card .ticket { margin-top: 23px; }
}

@media (prefers-reduced-motion: reduce) {
  #recipient.message-arriving #gift-card,
  #receive #gift-card.physical-reveal {
    animation: none !important;
    transform: none;
    opacity: 1;
    box-shadow: none;
  }
  #recipient.message-arriving #gift-card .card-paper { animation: none; }
}

@media print {
  #receive #gift-card { color: #49372c; transform: none; }
  #receive #gift-card .card-paper { filter: none; animation: none; }
}
