/* RSVP page in the ASWC look. Tokens, fonts, sparkles, card and button are
   taken from glitterstarz/Bookings/widget/app/css/style.css (the ASWC booking
   page) so the two read as one family. Fonts are self-hosted (OFL) because
   the CSP allows no third-party resource.
   States are body[data-state]: closed → open → rsvpd (set by /page.js). */

@font-face {
  font-family: 'Bebas Neue';
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url('/fonts/bebas-neue-400.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Sans';
  font-weight: 100 1000;   /* one variable file covers every weight */
  font-style: normal;
  font-display: swap;
  src: url('/fonts/dm-sans-variable.woff2') format('woff2');
}

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ASWC tokens (widget/app/css/style.css :root) */
  --pink:        #E22382;
  --pink-bright: #FF2D9B;
  --pink-glow:   rgba(226, 35, 130, 0.45);
  --gold:        #F0C060;
  --bg:          #070711;
  --border-h:    rgba(226, 35, 130, 0.65);
  --text:        #FFFFFF;
  /* Body copy at 0.72 (bid-duck-26-27 raised ASWC's 0.5 for legibility). */
  --text-body:   rgba(255, 255, 255, 0.72);

  --display: 'Bebas Neue', Impact, "Arial Narrow", sans-serif;
  --body:    'DM Sans', system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  --env-w:   min(340px, calc(100vw - 32px));
  --env-h:   calc(var(--env-w) * 0.75);
  --open-ms: 450ms;
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--body);
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 90% 55% at 50% -10%, rgba(226, 35, 130, 0.14) 0%, transparent 65%),
    radial-gradient(ellipse 50% 35% at 85% 90%,  rgba(240, 192, 96, 0.06) 0%, transparent 55%);
  min-height: 100vh;
}

main {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 16px 56px;
  /* Pops fly wider than a phone; no sideways scroll. hidden is the fallback
     for browsers without clip (Safari < 16). */
  overflow-x: hidden;
  overflow-x: clip;
}

/* ========
   SPARKLES — the ASWC page's twinkle, fixed behind everything
   ======== */
.sparkles {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.sparkles span {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--pink);
  box-shadow: 0 0 4px 1px var(--pink);
  opacity: 0;
  animation: twinkle var(--d, 3s) var(--delay, 0s) infinite ease-in-out;
}

.sparkles span:nth-child(4n) {
  background: var(--gold);
  box-shadow: 0 0 4px 1px var(--gold);
}

.sparkles span:nth-child(1)  { top:  6%; left: 12%; --d: 3.1s; --delay: 0.2s; }
.sparkles span:nth-child(2)  { top: 14%; left: 82%; --d: 2.6s; --delay: 1.1s; }
.sparkles span:nth-child(3)  { top: 22%; left: 34%; --d: 3.6s; --delay: 0.6s; }
.sparkles span:nth-child(4)  { top: 30%; left: 92%; --d: 2.9s; --delay: 1.8s; width: 4px; height: 4px; }
.sparkles span:nth-child(5)  { top: 38%; left:  5%; --d: 3.3s; --delay: 0.9s; }
.sparkles span:nth-child(6)  { top: 46%; left: 70%; --d: 2.4s; --delay: 2.2s; }
.sparkles span:nth-child(7)  { top: 54%; left: 22%; --d: 3.8s; --delay: 0.4s; }
.sparkles span:nth-child(8)  { top: 61%; left: 88%; --d: 3.0s; --delay: 1.5s; width: 4px; height: 4px; }
.sparkles span:nth-child(9)  { top: 68%; left: 46%; --d: 2.7s; --delay: 2.6s; }
.sparkles span:nth-child(10) { top: 74%; left:  9%; --d: 3.4s; --delay: 1.2s; }
.sparkles span:nth-child(11) { top: 80%; left: 63%; --d: 2.8s; --delay: 0.1s; }
.sparkles span:nth-child(12) { top: 86%; left: 28%; --d: 3.5s; --delay: 2.0s; width: 4px; height: 4px; }
.sparkles span:nth-child(13) { top: 91%; left: 79%; --d: 2.5s; --delay: 0.7s; }
.sparkles span:nth-child(14) { top: 10%; left: 55%; --d: 3.2s; --delay: 2.9s; }
.sparkles span:nth-child(15) { top: 50%; left: 96%; --d: 3.7s; --delay: 1.6s; }
.sparkles span:nth-child(16) { top: 96%; left: 40%; --d: 2.9s; --delay: 2.4s; width: 4px; height: 4px; }

@keyframes twinkle {
  0%, 100% { opacity: 0;   transform: scale(0.4); }
  50%      { opacity: 0.7; transform: scale(1.6); }
}

/* ========
   MASTHEAD — the ASWC header's logo glow and muted uppercase subtitle
   ======== */
.masthead {
  text-align: center;
}

.gs-logo {
  display: block;
  width: auto;
  height: 72px;
  margin: 0 auto 10px;
  filter: drop-shadow(0 0 14px rgba(226, 35, 130, 0.35));
}

.subtitle {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-body);
}

/* Room for the card's resting place (~0.5 envelope heights up). At its peak
   the card passes in front of the masthead for a moment. */
.stage {
  position: relative;
  z-index: 1;
  padding-top: calc(var(--env-h) * 0.62);
}

/* ========
   ENVELOPE — brand pink, glowing on the dark ground
   ======== */
.envelope {
  position: relative;
  width: var(--env-w);
  height: var(--env-h);
  perspective: 900px;
}

.envelope-back,
.envelope-front,
.envelope-flap {
  position: absolute;
  inset: 0;
  border-radius: 2px;
}

/* Pink under a dark veil: the inside of the envelope. */
.envelope-back {
  z-index: 1;
  background: linear-gradient(rgba(7, 7, 17, 0.45), rgba(7, 7, 17, 0.45)), var(--pink);
  box-shadow: 0 0 40px var(--pink-glow);
}

/* The pocket. The bottom darkens so the white name and hint read clearly. */
.envelope-front {
  z-index: 3;
  background:
    linear-gradient(to bottom, transparent 35%, rgba(7, 7, 17, 0.4) 100%),
    linear-gradient(160deg, var(--pink-bright) 0%, var(--pink) 60%);
  clip-path: polygon(0 0, 50% 40%, 100% 0, 100% 100%, 0 100%);
}

.envelope-flap {
  z-index: 4;
  background:
    linear-gradient(rgba(7, 7, 17, 0.18), rgba(7, 7, 17, 0.18)),
    linear-gradient(180deg, var(--pink-bright) 0%, var(--pink) 100%);
  /* Tip at 45% (pocket V at 40%): high enough that the seal clears a
     two-line guest name below it. */
  clip-path: polygon(0 0, 100% 0, 50% 45%);
  transform-origin: top center;
  transform: rotateX(0deg);
  transition: transform var(--open-ms) ease-in-out,
              z-index 0s linear calc(var(--open-ms) / 2);
}

[data-state="open"] .envelope-flap,
[data-state="rsvpd"] .envelope-flap {
  transform: rotateX(180deg);
  z-index: 0;
}

/* The seal: a gold diamond at the flap's tip, glowing like the gold sparkles. */
.seal {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 45%;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  background: var(--gold);
  transform: rotate(45deg);
  box-shadow: 0 0 14px 2px rgba(240, 192, 96, 0.55);
  transition: opacity 200ms ease, transform 200ms ease;
}

[data-state="open"] .seal,
[data-state="rsvpd"] .seal {
  opacity: 0;
  transform: rotate(45deg) scale(0.5);
}

/* The closed envelope is one button carrying the guest's name. */
.envelope-open {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 0 20px 20px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.envelope-open:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
}

.to {
  max-width: 100%;
  font-family: var(--display);
  font-size: clamp(1.6rem, 8vw, 2.1rem);
  line-height: 1;
  letter-spacing: 0.06em;
  overflow-wrap: anywhere;
  text-shadow: 0 0 18px rgba(7, 7, 17, 0.35);
  /* At most two lines, so the name never climbs into the seal. */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.hint {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

[data-state="open"] .envelope-open,
[data-state="rsvpd"] .envelope-open {
  display: none;
}

/* ========
   CARD — the ASWC service card: dark, thin pink border, pink glow, square
   ======== */
.card {
  position: absolute;
  z-index: 2;
  left: 6%;
  right: 6%;
  top: 6%;
  height: 92%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 18px 16px;
  background:
    linear-gradient(135deg, rgba(226, 35, 130, 0.1) 0%, transparent 55%),
    var(--bg);
  border: 1px solid var(--border-h);
  box-shadow: 0 0 28px var(--pink-glow);
  text-align: center;
  overflow: hidden;   /* closed: content taller than the envelope stays inside */
}

/* Once out, the card grows to fit its content (narrow phones, long names).
   Its resting place is in envelope heights, not its own height, so a taller
   card does not jump up into the masthead. */
[data-state="open"] .card,
[data-state="rsvpd"] .card {
  height: auto;
  min-height: 92%;
  transform: translateY(calc(var(--env-h) * -0.57));
  z-index: 7;
  animation: card-out calc(var(--open-ms) * 2) ease-in-out var(--open-ms) both;
}

/* Rise until the card's bottom clears the pocket, come forward, settle. */
@keyframes card-out {
  0%   { transform: translateY(0); z-index: 2; }
  55%  { transform: translateY(calc(-100% - var(--env-h) * 0.08)); z-index: 2; }
  56%  { transform: translateY(calc(-100% - var(--env-h) * 0.08)); z-index: 7; }
  100% { transform: translateY(calc(var(--env-h) * -0.57)); z-index: 7; }
}

/* The ASWC gold label (.service-duration). */
.eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

.card h1 {
  margin: 6px 0 8px;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.75rem, 8.5vw, 2.15rem);
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--text);
  overflow-wrap: anywhere;
}

.details {
  font-size: 0.95rem;
  color: var(--text-body);
}

/* The ASWC .btn-primary. At 24px the Bebas label is WCAG large text, so white
   on --pink (4.38:1) passes AA (3:1). */
.rsvp {
  align-self: center;
  min-width: 160px;
  min-height: 48px;
  margin-top: 16px;
  padding: 10px 40px;
  border: 0;
  border-radius: 0;
  background: var(--pink);
  color: var(--text);
  font-family: var(--display);
  font-size: 1.5rem;
  line-height: 1;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: background 0.18s, box-shadow 0.18s;
}

.rsvp:hover {
  background: var(--pink-bright);
  box-shadow: 0 0 28px var(--pink-glow);
}

.rsvp:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

/* ========
   RSVP'D — sparkles pop out from behind the card and fade
   ======== */
.pops {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: -5%;
  width: 0;
  height: 0;
  pointer-events: none;
}

.pops span {
  position: absolute;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: var(--pink-bright);
  box-shadow: 0 0 8px 2px var(--pink);
  opacity: 0;
}

.pops span:nth-child(even) {
  background: var(--gold);
  box-shadow: 0 0 8px 2px var(--gold);
}

.pops span:nth-child(1)  { --x: -150px; --y: -110px; }
.pops span:nth-child(2)  { --x:  150px; --y: -120px; }
.pops span:nth-child(3)  { --x: -165px; --y:   10px; }
.pops span:nth-child(4)  { --x:  165px; --y:    0px; }
.pops span:nth-child(5)  { --x: -120px; --y:  120px; }
.pops span:nth-child(6)  { --x:  125px; --y:  125px; }
.pops span:nth-child(7)  { --x:  -60px; --y: -150px; }
.pops span:nth-child(8)  { --x:   70px; --y: -145px; }
.pops span:nth-child(9)  { --x: -158px; --y:  -55px; }
.pops span:nth-child(10) { --x:  160px; --y:   60px; }

[data-state="rsvpd"] .pops span {
  animation: pop 1100ms cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

[data-state="rsvpd"] .pops span:nth-child(odd) { animation-delay: 60ms; }

@keyframes pop {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.3); }
  25%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--x), var(--y)) scale(1.2); }
}

.noscript {
  margin-top: 24px;
  text-align: center;
  color: var(--text-body);
}

/* Reduced motion: the same three states, with no movement between them. */
@media (prefers-reduced-motion: reduce) {
  .sparkles span {
    animation: none;
    opacity: 0.45;
  }
  .envelope-flap,
  .seal,
  [data-state="open"] .card,
  [data-state="rsvpd"] .card {
    transition: none;
    animation: none;
  }
  [data-state="rsvpd"] .pops span {
    animation: none;
  }
}
