/* The VIP card, at vip.<your address>. The card itself is drawn into a canvas by js/vip.js, so the screen and the PDF match.
   On top lie a burgundy cover over most of the card, a satin ribbon round both and a bow. Opening unties the bow, slips the
   ribbon off and swings the cover back on its left edge, like a card in its wrap.
   Ribbon, wax and embossing are the same neutral grey images as the main site, blended with hard-light over a colour. */
:root {
  --ribbon: #6d1a2d;
  --wax: #f1e4cf;
  --invite: #64101f;
  --gold: #b8923f;
  --pink: #e7a9b4;
  --paper: #faf3e9;
  --ink: #2f1219;
  --pen: #6d1a2d;
  --accent: #7b5a2e;
  --foil-light: color-mix(in srgb, var(--gold) 52%, #fff3d4);
  --foil-dark: color-mix(in srgb, var(--gold) 80%, #3a2410);
  --foil: linear-gradient(105deg, var(--foil-dark) 0%, var(--foil-light) 24%, var(--gold) 44%, var(--foil-light) 64%, var(--foil-dark) 84%, var(--foil-light) 100%);
  --night-gold: color-mix(in srgb, var(--gold) 38%, #fff3d4);
  --display: 'Cormorant', 'Times New Roman', serif;
  --body: 'EB Garamond', Georgia, serif;
  --caps: 'Cinzel', 'Cormorant', serif;
  --deco: 'Cinzel Decorative', 'Cinzel', serif;
  --hand: 'WindSong', cursive;
  --ease: cubic-bezier(.16, 1, .3, 1);
  /* The card is A5, 148 by 210. Its width leaves room under it for the buttons, and above it for a guest's name. */
  --room: 190px;
  --w: min(calc(100vw - 40px), 540px, calc((100vh - var(--room)) * 148 / 210));
  --w: min(calc(100vw - 40px), 540px, calc((100dvh - var(--room)) * 148 / 210));
}
.has-guest { --room: 240px; }
@media (max-width: 520px) { :root { --room: 250px; } .has-guest { --room: 300px; } }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--paper); }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; color: var(--ink); font: 400 18px/1.5 var(--body); -webkit-font-smoothing: antialiased; overflow-x: hidden;
  background: radial-gradient(120% 80% at 50% 38%, color-mix(in srgb, var(--pink) 16%, var(--paper)) 0, var(--paper) 62%), var(--paper);
}
body::before { content: ""; position: fixed; inset: 0; background: url(../assets/grain.webp); opacity: .7; pointer-events: none; }
p { margin: 0; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--pen); outline-offset: 3px; }
.ico { width: 1.2em; height: 1.2em; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.stage { position: relative; min-height: 100vh; min-height: 100dvh; overflow-x: clip; display: grid; justify-items: center; align-content: center; gap: 18px; padding: 28px 20px 36px; }
.for { font: 500 clamp(30px, 7vw, 42px)/1.15 var(--hand); color: var(--pen); text-align: center; margin-bottom: -4px; }

/* ------------------------------------------------------------ the card and its wrap */
.pack { --bw: calc(var(--w) * .5); position: relative; width: var(--w); aspect-ratio: 148 / 210; perspective: 1700px; perspective-origin: 30% 50%; cursor: pointer; }
.opened .pack { cursor: auto; }
.card {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: color-mix(in srgb, var(--paper) 45%, #fff);
  box-shadow: 0 1px 2px rgba(60, 20, 26, .12), 0 26px 50px -24px rgba(80, 30, 36, .55);
  transition: transform 1.2s var(--ease), box-shadow 1.2s var(--ease);
}
.cover {
  position: absolute; left: 0; top: 0; bottom: 0; width: 62%; padding: 0; border: 0; font: inherit; color: inherit; cursor: pointer; background: none;
  transform-origin: 0 50%; transform-style: preserve-3d; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.cover:focus-visible { outline-offset: 4px; }
.cover-face, .cover-back { position: absolute; inset: 0; display: block; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.cover-face {
  display: grid; grid-template-columns: 100%; justify-items: center; align-content: start; padding-top: 15%;
  background: url(../assets/emboss.webp) center / cover no-repeat, var(--invite); background-blend-mode: hard-light;
  box-shadow: 6px 0 14px -6px rgba(40, 8, 14, .55), inset -1px 0 0 color-mix(in srgb, var(--gold) 55%, transparent);
}
/* the inside of the cover, seen as it swings */
.cover-back { transform: rotateY(180deg); background: color-mix(in srgb, var(--invite) 88%, #000); box-shadow: inset 0 0 0 calc(var(--w) * .022) color-mix(in srgb, var(--invite) 70%, #000); }
.cover-vip {
  font: 700 calc(var(--w) * .135)/1 var(--deco); letter-spacing: .08em; text-indent: .08em;
  background: var(--foil); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 1px 1px rgba(20, 2, 6, .55));
}
.cover-rule {
  display: block; width: 70%; aspect-ratio: 1000 / 110; margin: calc(var(--w) * .02) 0 calc(var(--w) * .012);
  background: var(--foil); -webkit-mask: url(../assets/rule.webp) center / 100% 100% no-repeat; mask: url(../assets/rule.webp) center / 100% 100% no-repeat;
}
.cover-names { display: grid; justify-items: center; font: 500 calc(var(--w) * .068)/1.08 var(--hand); color: var(--night-gold); white-space: nowrap; text-shadow: 0 1px 2px rgba(20, 2, 6, .5); }
.cover-names i { font: italic 500 .62em/1 var(--display); margin: -.05em 0 -.02em; }
.cover-date { margin-top: calc(var(--w) * .012); font: 500 calc(var(--w) * .026)/1 var(--caps); letter-spacing: .3em; text-indent: .3em; color: var(--night-gold); }
/* the wax seal over the knot, with the logo pressed into it, as on the doors of the main invitation */
.seal { position: absolute; left: 50%; top: 30%; width: 30%; aspect-ratio: 1; transform: translate(-50%, -50%); filter: drop-shadow(0 calc(var(--w) * .006) calc(var(--w) * .01) rgba(20, 2, 6, .5)); }
.seal i {
  position: absolute; inset: 0; display: block;
  background: url(../assets/seal.webp) center / 100% 100% no-repeat, var(--wax); background-blend-mode: hard-light;
  -webkit-mask: url(../assets/seal.webp) center / 100% 100% no-repeat; mask: url(../assets/seal.webp) center / 100% 100% no-repeat;
}
.seal i::after { content: ""; position: absolute; inset: 25%; background: var(--foil); -webkit-mask: url(../assets/logo-mark.svg) center / contain no-repeat; mask: url(../assets/logo-mark.svg) center / contain no-repeat; }

/* the satin ribbon round the card and its cover, in two halves that part at the bow */
.band {
  --y: 57%;
  position: absolute; top: var(--y); height: calc(var(--w) * .052); margin-top: calc(var(--w) * -.026); pointer-events: none;
  background: repeating-linear-gradient(118deg, rgba(255, 255, 255, .06) 0 1px, rgba(0, 0, 0, .04) 1px 2.5px), linear-gradient(180deg, #4a4a4a 0, #767676 3%, #8c8c8c 22%, #828282 62%, #7a7a7a 96%, #484848 100%), var(--wax);
  background-blend-mode: normal, hard-light; box-shadow: 0 2px 5px rgba(60, 20, 20, .3);
}
.band-l { left: -1.5%; width: 32.5%; }
.band-r { left: 31%; right: -1.5%; }
.bow { position: absolute; left: 31%; top: 57%; width: var(--bw); height: calc(var(--bw) * 1.1667); margin-left: calc(var(--bw) / -2); margin-top: calc(var(--bw) * -.35); pointer-events: none; }
.part {
  position: absolute; inset: 0; display: block;
  background: var(--img) center / 100% 100% no-repeat, var(--wax); background-blend-mode: hard-light;
  -webkit-mask: var(--img) center / 100% 100% no-repeat; mask: var(--img) center / 100% 100% no-repeat;
  filter: drop-shadow(0 2px 3px rgba(40, 10, 14, .35));
}
.tail-l { --img: url(../assets/bow-tail-l.webp); }
.tail-r { --img: url(../assets/bow-tail-r.webp); }
.loop-l { --img: url(../assets/bow-loop-l.webp); }
.loop-r { --img: url(../assets/bow-loop-r.webp); }
.knot { --img: url(../assets/bow-knot.webp); }

.prompt { font: 500 13px/1 var(--caps); letter-spacing: .26em; text-indent: .26em; text-transform: uppercase; color: var(--pen); transition: opacity .3s; }
@media (prefers-reduced-motion: no-preference) {
  .prompt { animation: breathe 2.6s ease-in-out infinite; }
  .cover:not(:disabled):hover .cover-face { filter: brightness(1.05); }
}
@keyframes breathe { 50% { opacity: .55; } }

/* ------------------------------------------------------------ opening */
.opening .prompt { opacity: 0; animation: none; }
.opening .cover { pointer-events: none; }
.opening .knot { opacity: 0; transition: opacity .25s; }
.opening .seal { opacity: 0; transform: translate(-50%, -64%) scale(1.12); transition: transform .5s var(--ease), opacity .4s .1s; }
.opening .loop, .opening .tail { opacity: 0; transition: transform .8s cubic-bezier(.5, 0, .2, 1), opacity .6s .2s; }
.opening .loop-l { transform: translate(-16%, -10%) rotate(-24deg) scale(.7); }
.opening .loop-r { transform: translate(16%, -10%) rotate(24deg) scale(.7); }
.opening .tail-l { transform: translate(-10%, 22%) rotate(12deg); }
.opening .tail-r { transform: translate(10%, 22%) rotate(-12deg); }
.opening .band { opacity: 0; transition: transform .9s cubic-bezier(.5, 0, .2, 1) .15s, opacity .5s .5s; }
.opening .band-l { transform: translateX(-30%); }
.opening .band-r { transform: translateX(30%); }
.opening .cover { transform: rotateY(-172deg); opacity: 0; transition: transform 1.6s cubic-bezier(.62, .03, .25, 1) .55s, opacity .45s 1.75s; }
.opened .card { transform: scale(1.012); box-shadow: 0 1px 2px rgba(60, 20, 26, .12), 0 34px 60px -26px rgba(80, 30, 36, .6); }
.opened .cover, .opened .band, .opened .bow { display: none; }
/* larger, on a computer, after a click on the open card */
@media (min-width: 700px) {
  .opened .pack { cursor: zoom-in; }
  .big { --w: min(calc(100vw - 40px), 820px); }
  .big .pack { cursor: zoom-out; }
}

/* ------------------------------------------------------------ after opening */
.below { display: grid; justify-items: center; align-items: start; }
.below > * { grid-area: 1 / 1; }
.opened .prompt { visibility: hidden; }
.actions { display: grid; justify-items: center; gap: 12px; visibility: hidden; }
.opened .actions { visibility: visible; animation: rise .9s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.actions-note { font: italic 400 17px/1.35 var(--display); color: color-mix(in srgb, var(--ink) 72%, var(--paper)); text-align: center; text-wrap: balance; }
.actions-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em; min-height: 46px; padding: .55em 1.5em; border-radius: 999px;
  font: 500 17px/1.1 var(--body); letter-spacing: .02em; text-decoration: none; white-space: nowrap; cursor: pointer; border: 1px solid transparent;
  transition: transform .25s var(--ease), background-color .25s, color .25s;
}
.btn:active { transform: scale(.98) translateY(1px); }
.btn-ink { background: var(--pen); color: var(--paper); min-width: 200px; }
.btn-ink:hover { background: var(--ink); }
.btn-ink[aria-busy="true"] { opacity: .75; cursor: progress; }
.btn-line { border-color: color-mix(in srgb, var(--gold) 80%, transparent); color: var(--pen); background: none; font-size: 15px; letter-spacing: .08em; }
.btn-line:hover { background: var(--pen); color: var(--paper); border-color: var(--pen); }
.more { color: var(--pen); text-decoration-color: color-mix(in srgb, var(--gold) 80%, transparent); text-underline-offset: .22em; }

@media (prefers-reduced-motion: reduce) {
  .opening .cover, .opening .band, .opening .bow, .opening .loop, .opening .tail { transform: none; transition: opacity .3s; }
  .opening .seal { transform: translate(-50%, -50%); transition: opacity .3s; }
  .opened .actions { animation: none; }
}
