/* PartyPost postcard + envelope. Every theme shares this layout; colours come from CSS variables set per theme
   (--bg --bg2 --env --env2 --liner --paper --ink --accent --accent2 --seal). Sizes follow the card width (cqw). */
.pc { position: relative; width: 100%; aspect-ratio: 3 / 2; perspective: 2000px; container-type: inline-size; color: var(--ink); }
.pc-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .9s cubic-bezier(.2, .75, .25, 1); }
.pc.flipped .pc-inner { transform: rotateY(180deg); }
.pc-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: clamp(10px, 2.4cqw, 22px); overflow: hidden; background: var(--paper);
  box-shadow: 0 2.5cqw 6cqw -2cqw rgba(0, 0, 0, .5), 0 0 0 1px rgba(0, 0, 0, .06); }
.pc-art { position: absolute; inset: 0; }
.pc-art svg { width: 100%; height: 100%; display: block; }
.pc-band { position: absolute; left: 4%; right: 4%; bottom: 5%; text-align: center; padding: 1.6cqw 3cqw 1.9cqw; border-radius: 1.8cqw;
  background: color-mix(in srgb, var(--paper) 92%, transparent); box-shadow: 0 1cqw 3cqw -1cqw rgba(0, 0, 0, .35); }
.pc-headline { font: 700 2.1cqw/1.2 var(--font-fun); letter-spacing: .28em; text-transform: uppercase; color: var(--accent); }
.pc-title { margin: .4cqw 0 0; font: 800 5.4cqw/1.08 var(--font-title); color: var(--ink); text-wrap: balance; }
.pc-date { display: inline-flex; gap: 1.2cqw; margin-top: 1.1cqw; font: 700 2.2cqw/1 var(--font-fun); }
.pc-date span { background: var(--accent); color: #fff; padding: .8cqw 1.8cqw; border-radius: 99px; }
.pc-date span + span { background: var(--accent2); color: var(--ink); }

.pc-back { transform: rotateY(180deg); display: grid; grid-template-columns: 1.2fr 1fr; grid-template-rows: minmax(0, 1fr); padding: 4.2cqw 3.6cqw 3.6cqw 4.2cqw; gap: 3cqw;
  background: var(--paper) repeating-linear-gradient(0deg, transparent 0 calc(3.3cqw - 1px), color-mix(in srgb, var(--accent) 9%, transparent) calc(3.3cqw - 1px) 3.3cqw); }
.pc-letter { font: 400 2.25cqw/1.47 var(--font-hand); overflow: auto; min-height: 0; overflow-wrap: anywhere; scrollbar-width: thin; }
.pc-letter p { margin: 0 0 .62em; }
.pc-dear { font-weight: 700; margin-bottom: .5em; font-size: 1.15em; color: var(--accent); }
.pc-sign { margin-top: .62em; font-weight: 700; }
.pc-side { border-left: 2px dashed color-mix(in srgb, var(--ink) 22%, transparent); padding-left: 3cqw; display: flex; flex-direction: column; gap: 1.8cqw; min-height: 0; }
.pc-stamps { display: flex; justify-content: flex-end; align-items: center; gap: 1.6cqw; }
.pc-postmark { width: 11cqw; aspect-ratio: 1; border-radius: 50%; border: .35cqw double color-mix(in srgb, var(--ink) 45%, transparent); display: grid; place-content: center; text-align: center;
  font: 800 1.35cqw/1.35 var(--font-fun); letter-spacing: .08em; color: color-mix(in srgb, var(--ink) 60%, transparent); transform: rotate(-12deg); }
.pc-stamp { width: 12cqw; aspect-ratio: 4 / 5; padding: .7cqw; background: #fff; transform: rotate(3deg); border: .3cqw dashed color-mix(in srgb, var(--ink) 18%, #fff); box-shadow: 0 .4cqw 1cqw rgba(0, 0, 0, .2); }
.pc-stamp svg { width: 100%; height: 100%; display: block; }
.pc-details { margin: 0; display: grid; gap: .75em; overflow: auto; font: 400 1.95cqw/1.4 var(--font-ui); }
.pc-details dt { font: 800 .7em/1 var(--font-ui); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-bottom: .45cqw; }
.pc-details dd { margin: 0; }
.pc-details a { color: var(--accent); font-weight: 700; }
.pc-details small { opacity: .65; }
.pc-missing { opacity: .5; font-style: italic; }

@media (max-width: 640px) {
  .pc { aspect-ratio: 3 / 4.3; }
  .pc-art { bottom: auto; height: 66.6cqw; }
  .pc-band { left: 0; right: 0; bottom: 0; top: 64cqw; border-radius: 0; padding: 4cqw 5cqw; box-shadow: none; display: flex; flex-direction: column; justify-content: center; }
  .pc-headline { font-size: 3.6cqw; } .pc-title { font-size: 8.6cqw; margin-top: 1cqw; } .pc-date { font-size: 3.8cqw; margin-top: 2.6cqw; gap: 2cqw; justify-content: center; } .pc-date span { padding: 1.4cqw 3cqw; }
  .pc-back { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); padding: 5cqw; gap: 3cqw; }
  .pc-side { order: -1; border-left: 0; padding-left: 0; border-bottom: 2px dashed color-mix(in srgb, var(--ink) 22%, transparent); padding-bottom: 3cqw; }
  .pc-stamps { position: absolute; right: 4cqw; top: 4cqw; }
  .pc-postmark { width: 17cqw; font-size: 2.1cqw; } .pc-stamp { width: 17cqw; }
  .pc-details { font-size: 3.6cqw; padding-right: 37cqw; gap: 2.4cqw; }
  .pc-letter { font-size: 4.1cqw; }
}

/* ---- the envelope ---- */
.env { position: relative; width: min(560px, 88vw); aspect-ratio: 1.6; perspective: 1400px; container-type: inline-size; margin: 0 auto; }
.env-back { position: absolute; inset: 0; background: var(--env2); border-radius: 2.6cqw; box-shadow: 0 5cqw 9cqw -3cqw rgba(0, 0, 0, .55); }
.env-letter { position: absolute; left: 5.5%; right: 5.5%; top: 5%; height: 90%; z-index: 2; background: var(--paper); border-radius: 1.6cqw; overflow: hidden;
  transition: transform 1.05s cubic-bezier(.3, .8, .25, 1); box-shadow: 0 0 0 1px rgba(0, 0, 0, .06); }
.env-letter .env-mini { position: absolute; left: 3%; right: 3%; top: 17%; aspect-ratio: 3 / 2; border-radius: 1cqw; overflow: hidden; }
.env-letter .env-mini svg { width: 100%; height: 100%; display: block; }
.env-letter .env-hi { position: absolute; left: 0; right: 0; top: 4.5%; text-align: center; font: 800 5cqw/1 var(--font-title); color: var(--ink); }
.env-tri { position: absolute; inset: 0; z-index: 3; border-radius: 2.6cqw; }
.env-l { background: color-mix(in srgb, var(--env) 88%, #000); clip-path: polygon(0 0, 51% 56%, 0 100%); }
.env-r { background: color-mix(in srgb, var(--env) 88%, #000); clip-path: polygon(100% 0, 49% 56%, 100% 100%); }
.env-b { background: var(--env); clip-path: polygon(0 100%, 50% 45%, 100% 100%); }
.env-flap { position: absolute; left: 0; right: 0; top: 0; height: 60%; z-index: 5; transform-origin: 50% 0; clip-path: polygon(0 0, 100% 0, 50% 100%);
  background: color-mix(in srgb, var(--env) 92%, #fff); border-radius: 2.6cqw 2.6cqw 0 0; transition: transform .75s cubic-bezier(.45, .1, .3, 1), background 0s .3s; }
.env-flap::after { content: ''; position: absolute; inset: 8% 9% 0; clip-path: polygon(0 0, 100% 0, 50% 100%); background: repeating-linear-gradient(45deg, var(--liner) 0 2cqw, color-mix(in srgb, var(--liner) 75%, #fff) 2cqw 4cqw); opacity: 0; transition: opacity 0s .3s; }
.env-to { position: absolute; right: 9%; bottom: 13%; z-index: 4; font: 700 3.6cqw/1.3 var(--font-hand); color: color-mix(in srgb, var(--paper) 92%, transparent); text-align: right; max-width: 55%; }
.env-to small { display: block; font: 700 2.2cqw/1 var(--font-ui); letter-spacing: .2em; text-transform: uppercase; opacity: .75; margin-bottom: 1cqw; }
.env-stampmini { position: absolute; left: 7%; bottom: 12%; z-index: 4; width: 11cqw; aspect-ratio: 4 / 5; background: #fff; padding: .6cqw; transform: rotate(-6deg); box-shadow: 0 .5cqw 1cqw rgba(0, 0, 0, .25); }
.env-stampmini svg { width: 100%; height: 100%; display: block; }
.env-seal { position: absolute; left: 50%; top: 60%; z-index: 6; width: 16cqw; aspect-ratio: 1; margin: -8cqw 0 0 -8cqw; border: 0; border-radius: 50%; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--seal) 70%, #fff), var(--seal) 55%, color-mix(in srgb, var(--seal) 75%, #000));
  box-shadow: 0 .8cqw 1.6cqw rgba(0, 0, 0, .35), inset 0 0 0 1.2cqw color-mix(in srgb, var(--seal) 85%, #000); color: color-mix(in srgb, var(--seal) 45%, #000);
  font: 900 6.5cqw/1 var(--font-title); transition: transform .35s, opacity .35s; animation: seal-pulse 2.2s ease-in-out infinite; }
.env-seal:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
@keyframes seal-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
.env.idle { animation: env-wiggle 4s ease-in-out 1.2s infinite; cursor: pointer; }
@keyframes env-wiggle { 0%, 86%, 100% { transform: rotate(0); } 89% { transform: rotate(-2.4deg); } 92% { transform: rotate(2.2deg); } 95% { transform: rotate(-1.4deg); } 98% { transform: rotate(.8deg); } }
.env.opening .env-seal { transform: scale(0); opacity: 0; animation: none; }
.env.opening .env-flap { transform: rotateX(180deg); }
.env.opening .env-flap::after { opacity: 1; }
.env.flap-behind .env-flap { z-index: 1; }
.env.rise .env-letter { transform: translateY(-66%); }
.env.out { transition: transform .8s cubic-bezier(.5, 0, .7, .4), opacity .7s .1s; transform: translateY(40%) scale(.85); opacity: 0; }
.env-hint { margin-top: 26px; text-align: center; font: 700 17px/1.3 var(--font-fun); color: var(--hint, #fff); letter-spacing: .02em; animation: hint 1.6s ease-in-out infinite; }
@keyframes hint { 0%, 100% { transform: translateY(0); opacity: .85; } 50% { transform: translateY(-5px); opacity: 1; } }

/* theme fonts */
:root { --font-ui: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-fun: ui-rounded, 'SF Pro Rounded', 'Arial Rounded MT Bold', 'Nunito', 'Trebuchet MS', system-ui, sans-serif;
  --font-title: ui-rounded, 'SF Pro Rounded', 'Arial Rounded MT Bold', 'Nunito', 'Trebuchet MS', system-ui, sans-serif;
  --font-hand: 'Segoe Print', 'Bradley Hand', 'Chalkboard SE', 'Marker Felt', 'Comic Sans MS', ui-rounded, cursive; }
[data-theme='golden'] { --font-title: 'Didot', 'Bodoni 72', 'Playfair Display', Georgia, 'Times New Roman', serif; --font-hand: 'Snell Roundhand', 'Apple Chancery', 'Segoe Script', Georgia, serif; --font-fun: Georgia, serif; }
[data-theme='speedway'] { --font-title: 'Arial Black', 'Helvetica Neue', Impact, system-ui, sans-serif; }
[data-theme='speedway'] .pc-title { font-style: italic; letter-spacing: -.01em; }
@media (prefers-reduced-motion: reduce) { .env.idle, .env-seal, .env-hint { animation: none; } .pc-inner, .env-letter, .env-flap { transition-duration: .01s; } }
