* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: radial-gradient(circle at 50% 0, #1c2c52, #0b1226 70%) fixed #0b1226;
  color: #f4efe3;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 18px;
}

header { text-align: center; padding: 20px 16px 0; }
h1 { font-family: "Great Vibes", cursive; font-weight: 400; font-size: 48px; margin: 0; color: #f1d58a; }
header p { margin: 0; opacity: .8; }

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
  gap: 32px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  align-items: start;
}

/* ---------- card ---------- */
.stage { position: sticky; top: 16px; display: flex; flex-direction: column; align-items: center; gap: 18px; }

.card {
  position: relative;
  width: min(360px, 82vw, 52vh);
  min-width: 260px;
  aspect-ratio: 2 / 3;
  perspective: 1600px;
  transition: transform .9s ease;
}
.inside, .cover, .face { position: absolute; inset: 0; }
.inside, .face { container-type: inline-size; overflow: hidden; border-radius: 4px; }

.inside {
  background:
    radial-gradient(circle at 12% 10%, #fff 0 1.5%, transparent 9%),
    radial-gradient(circle at 90% 92%, #fff 0 2%, transparent 14%),
    linear-gradient(160deg, #e9eef8, #cdd8ec);
  color: #1f2f5c;
  box-shadow: 0 18px 50px #0008;
}
.inside::before, .inside::after, .back::before, .back::after {
  content: "❄"; position: absolute; color: #7f93c4; opacity: .55; font-size: 14cqw; line-height: 1;
}
.inside::before { top: 3cqw; right: 5cqw; }
.inside::after { bottom: 3cqw; left: 5cqw; font-size: 9cqw; }

.verse-box {
  position: absolute; inset: 12% 8%;
  display: flex; flex-direction: column; justify-content: center;
  text-align: center; overflow: hidden;
  font-size: 5.6cqw; line-height: 1.35;
}
.verse-box p { margin: 0 0 .6em; overflow-wrap: anywhere; }
.in-to { font-family: var(--script, "Sacramento"), cursive; font-size: 2em; line-height: 1.15; }
.in-verse { white-space: pre-line; font-style: italic; font-weight: 500; }
.in-from { text-transform: uppercase; letter-spacing: .08em; font-size: .85em; font-weight: 600; }
.in-sign { font-family: var(--script, "Sacramento"), cursive; font-size: 2.1em; line-height: 1.15; }

.in-signature { font-family: "Caveat", cursive; font-size: 1.6em; line-height: 1.15; }
.in-drawn { width: min(11em, 100%); aspect-ratio: 3 / 1; align-self: center; flex: none; }
#pad { display: block; width: 100%; aspect-ratio: 3 / 1; margin-top: 8px; background: #fbf8f0; border-radius: 8px; touch-action: none; cursor: crosshair; }
.pad-buttons { display: flex; gap: 8px; margin-top: 8px; }
.pad-buttons button { padding: 4px 16px; border-radius: 999px; border: 1px solid #f1d58a80; background: transparent; color: inherit; }

.cover {
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 1.2s cubic-bezier(.4, .1, .2, 1), opacity .5s ease;
  cursor: pointer;
}
.face { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.front { box-shadow: 0 18px 50px #0008; }
.back { transform: rotateY(180deg); background: linear-gradient(200deg, #dde5f4, #c3d0e9); }
.back::before { top: 10%; left: 12%; }
.back::after { bottom: 14%; right: 16%; }
#scene { width: 100%; height: 100%; display: block; }

.card.open .cover { transform: rotateY(-180deg); }

/* ---------- front lettering ---------- */
.lettering { position: absolute; top: 0; bottom: 0; left: 6%; right: 6%; padding-top: var(--top, 7.5cqw); text-align: center; pointer-events: none; }
.lettering.split #outBottom { position: absolute; left: 0; right: 0; bottom: 5cqw; }
.lettering p { margin: 0; white-space: nowrap; }
.small {
  font-weight: 600; font-size: 5.8cqw; letter-spacing: .12em; text-transform: uppercase;
  color: #ffe6a6; text-shadow: 0 1px 3px #000, 0 0 12px #000c;
}
.script { font-family: var(--script, "Sacramento"), cursive; font-size: 30cqw; line-height: .86; -webkit-text-stroke: .008em #e9c873; }
.gold {
  display: inline-block;
  padding: .2em .12em .16em;
  margin: -.14em 0 -.1em;
  background: linear-gradient(105deg, #a9782a 0%, #f5da8e 22%, #c99a3f 38%, #fff6cf 50%, #c99a3f 62%, #f5da8e 80%, #a9782a 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  filter: drop-shadow(0 1px 2px #000c) drop-shadow(0 0 9px #000a);
  animation: shimmer 5s linear infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -150% 0; } }

/* ---------- editor ---------- */
fieldset { border: 1px solid #ffffff2e; border-radius: 12px; margin: 0 0 16px; padding: 12px 16px 16px; min-width: 0; }
legend { color: #f1d58a; font-weight: 600; font-size: 20px; padding: 0 6px; }
label { display: block; margin-top: 10px; }
input:not([type=file]), select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 10px;
  font: inherit; color: #14203f; background: #fbf8f0; border: 0; border-radius: 8px;
}
textarea { resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
button { font: inherit; font-weight: 600; cursor: pointer; }
.chips button { padding: 6px 14px; border-radius: 999px; border: 1px solid #f1d58a80; background: transparent; color: inherit; }
.chips button[aria-pressed=true] { background: #f1d58a; color: #14203f; }
.designs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.designs button { padding: 4px 4px 6px; border: 2px solid transparent; border-radius: 10px; background: #ffffff12; color: inherit; font-size: 14px; line-height: 1.2; }
.designs button[aria-pressed=true] { border-color: #f1d58a; background: #f1d58a2e; }
.designs img { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 6px; margin-bottom: 4px; }
.print { margin-top: 20px; }
.secondary { padding: 10px 18px; margin-top: 14px; border-radius: 999px; border: 2px solid #f1d58a; background: transparent; color: inherit; }
.secondary:disabled { opacity: .5; cursor: wait; }
details { margin-top: 10px; font-size: 16px; }
summary { cursor: pointer; color: #f1d58a; }
.stamp { display: none; position: absolute; left: 50%; top: 58%; z-index: 2; transform: translate(-50%, -50%) rotate(-32deg); font: 600 19cqw "Cormorant Garamond", serif; letter-spacing: .1em; color: #fff; opacity: .38; text-shadow: 0 0 6px #0009; pointer-events: none; }
.inside .stamp { color: #1f2f5c; opacity: .16; text-shadow: none; }
.card.preview .stamp { display: block; }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { width: 22px; height: 22px; flex: none; margin: 2px 0 0; padding: 0; }
a { color: #f1d58a; }
.send { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.send .secondary { margin: 0; text-decoration: none; color: #f4efe3; }
.bought h2 { color: #f1d58a; margin-top: 0; }
.message { padding: 12px 16px; border: 1px solid #f1d58a; border-radius: 12px; }
footer { text-align: center; padding: 16px; font-size: 15px; opacity: .8; }
body.viewing footer { display: none; }
.primary { padding: 12px 28px; border: 0; border-radius: 999px; background: #b3202e; color: #fff; }
.file input { display: block; margin-top: 6px; max-width: 100%; }
.hint { font-size: 15px; opacity: .75; margin: 8px 0 0; }
:focus-visible { outline: 3px solid #f1d58a; outline-offset: 2px; }

/* ---------- recipient view ---------- */
body.viewing main { grid-template-columns: 1fr; justify-items: center; }
body.viewing header { display: none; }
body.viewing .stage { position: static; padding-top: 4vh; }
.make-own { color: #f1d58a; }

@media (min-width: 821px) {
  body.viewing .card { width: min(420px, 44vw, 56vh); }
  body.viewing .card.open { transform: translateX(50%); }
}

@media (max-width: 820px) {
  main { grid-template-columns: 1fr; padding: 16px; }
  .stage { position: static; }
  .card.open .cover { opacity: 0; pointer-events: none; }
  h1 { font-size: 36px; }
}

/* On the editing screen the open card shows the inside page on its own */
body:not(.viewing) .card.open .cover { opacity: 0; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .gold { animation: none; }
  .cover, .card { transition: none; }
}
