/* Sign-up: the working state and the moment of joining. Behaviour and the
   markup of the done layer live in home.js; the form is waitlistForm() in
   src/home/shared.ts.

   Layout never moves. On success the form only fades (it keeps its space),
   the note keeps its height, and .ps-done, an aria-hidden layer over the
   whole sign-up block, shows the confirmation. .is-done is the resting state; .is-joining (the form that
   was used, about 1.1s) plays the way in, and every animation ends exactly
   on the resting state. */

/* ---------- Working: the button stays pressed while the request runs ---------- */
.ps-signup .ps-btn svg { transition: opacity .18s var(--ps-ease), translate .18s var(--ps-ease); }
.ps .ps-signup.is-busy .ps-btn { transform: translate(-4px, 5px); box-shadow: 0 0 0 var(--plurel-ink); cursor: progress; }
.ps-signup.is-busy .ps-btn svg { opacity: 0; translate: 6px 0; }

/* ---------- Done: resting state ---------- */
.ps-signup { position: relative; }
.ps-signup.is-done .ps-form { opacity: 0; }
/* The note keeps its height (home.js) while its text is visually hidden. */
.ps-signup.is-done .ps-note:focus { outline: none; }

.ps-done {
  position: absolute; inset: 0; z-index: 2; justify-self: stretch; align-self: stretch;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  text-align: center; pointer-events: none;
}
/* The pill: paper, ink outline, the buttons' hard offset shadow. */
.ps-done__pill {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 0 24px 0 8px;
  border: 1px solid var(--plurel-ink); border-radius: 999px;
  background: var(--plurel-paper); color: var(--plurel-ink); box-shadow: var(--plurel-shadow-action);
  font: 700 .8125rem/1 var(--plurel-body); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
}
/* The check sits in a disc the colour of the button it came from. */
.ps-done__check {
  display: grid; place-items: center; flex: none; width: 34px; height: 34px;
  border: 1px solid var(--plurel-ink); border-radius: 50%; background: var(--ps-done-disc, var(--ps-orange));
}
.ps-close { --ps-done-disc: var(--ps-yellow); }
.ps .ps-done__check svg { width: 20px; height: 20px; overflow: visible; }
.ps-done__check path {
  fill: none; stroke: var(--plurel-ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1 2; stroke-dashoffset: 0;
}
/* Also a .ps-note, so it shares the note's type; the layer's gap spaces it. */
.ps .ps-done .ps-done__next { max-width: 100%; margin: 0; text-wrap: balance; }

/* ---------- Joining: the way in ---------- */
/* 0 to .22s: the email row fades. */
.ps-signup.is-joining .ps-form { animation: ps-signup-out .22s ease-out both; }
/* .06 to .56s: the pill rises out of the button to the centre of the block. */
.ps-signup.is-joining .ps-done__pill {
  animation: ps-signup-rise-from .5s cubic-bezier(.16, 1, .3, 1) .06s both, ps-signup-fade-in .18s ease-out .06s both;
}
/* .38 to .72s: the check draws itself. */
.ps-signup.is-joining .ps-done__check path { animation: ps-signup-draw .34s cubic-bezier(.65, 0, .35, 1) .38s both; }
/* .6 to .96s: the follow-up line. */
.ps-signup.is-joining .ps-done__next {
  animation: ps-signup-lift .36s cubic-bezier(.16, 1, .3, 1) .6s both, ps-signup-fade-in .3s ease-out .6s both;
}

/* About .17 to 1.18s: brand doodles thrown out from behind the pill as it
   lands, to a ring around it (home.js sets --x/--y). A little overshoot on
   the throw, then they fade where they land. */
.ps-burst { position: absolute; z-index: 0; width: 0; height: 0; pointer-events: none; }
.ps .ps-burst img {
  position: absolute; left: 0; top: 0; width: var(--s); height: var(--s); max-width: none;
  margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2); opacity: 0;
  animation: ps-burst-throw .62s cubic-bezier(.2, 1.35, .45, 1) var(--d) both, ps-burst-fade .95s linear var(--d) both;
}
/* Orange doodles vanish on the orange band, so they go ink there. */
.ps-close .ps-burst img { filter: brightness(0); }

/* Both ends are spelled out: an implied "from" would be the done state's
   opacity 0, and the row would vanish instead of fading. */
@keyframes ps-signup-out { from { opacity: 1; scale: 1; } to { opacity: 0; scale: .97; } }
@keyframes ps-signup-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes ps-signup-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes ps-signup-rise-from { from { translate: var(--ps-from-x, 0) var(--ps-from-y, 0); scale: .55; } }
/* Starts a little past the path's start so the round cap leaves no dot. */
@keyframes ps-signup-draw { from { stroke-dashoffset: 1.15; } }
@keyframes ps-signup-lift { from { translate: 0 6px; } }
@keyframes ps-burst-throw {
  from { translate: 0 0; rotate: 0deg; scale: .3; }
  to { translate: var(--x) var(--y); rotate: var(--r); scale: 1; }
}
@keyframes ps-burst-fade { 0% { opacity: 0; } 10% { opacity: 1; } 62% { opacity: 1; } 100% { opacity: 0; } }

/* Reduced motion: no travel, no burst (home.js skips it), the check is
   already drawn; one short cross-fade. These beat base.css's blanket rule. */
@media (prefers-reduced-motion: reduce) {
  .ps .ps-signup .ps-btn svg { transition: none; }
  .ps .ps-signup.is-busy .ps-btn svg { translate: none; }
  .ps .ps-signup.is-joining .ps-form { animation: ps-signup-fade-out .2s ease-out both !important; }
  .ps .ps-signup.is-joining .ps-done__pill,
  .ps .ps-signup.is-joining .ps-done__next { animation: ps-signup-fade-in .24s ease-out .08s both !important; }
  .ps .ps-signup.is-joining .ps-done__check path { animation: none !important; }
  .ps .ps-burst { display: none; }
}

/* ---------- The confirmation is a taped receipt (it replaces the pill) ---------- */
.ps .ps-done__pill.ps-ticket {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; flex: none; box-sizing: border-box; width: min(340px, 100% - 16px); min-height: 0; padding: 20px 20px 14px;
  border: 1.5px solid var(--plurel-ink); border-radius: 6px; box-shadow: -6px 8px 0 var(--plurel-ink);
  font: 400 .875rem/1.5 var(--plurel-body); letter-spacing: 0; text-transform: none; text-align: left; white-space: normal;
  rotate: -1.5deg;
}
.ps-ticket::before { content: ""; position: absolute; left: 50%; top: -12px; width: 92px; height: 23px; translate: -50% 0; rotate: -3deg; background: #ece6cd; }
.ps-ticket__head { padding-bottom: 9px; margin-bottom: 6px; border-bottom: 1.5px dashed var(--plurel-ink); font: 400 .6875rem/1 var(--plurel-label); letter-spacing: .1em; text-transform: uppercase; }
.ps-ticket__row { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; }
.ps-ticket__row b { flex: none; display: inline-flex; align-items: center; gap: 5px; }
.ps-ticket__email { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps .ps-ticket .ps-done__check { width: 16px; height: 16px; border: 0; background: none; }
.ps .ps-ticket .ps-done__check svg { width: 16px; height: 16px; }
.ps .ps-ticket__sticker { position: absolute; right: -16px; top: -36px; width: 88px; height: auto; max-width: none; rotate: 12deg; }
/* .5s: the sticker is slapped on once the receipt has landed. */
.ps-signup.is-joining .ps-ticket__sticker { animation: ps-ticket-stick .34s cubic-bezier(.2, 1.4, .45, 1) .5s both; }
@keyframes ps-ticket-stick { from { opacity: 0; scale: 1.7; rotate: 30deg; } }
@media (max-width: 480px) { .ps .ps-ticket__sticker { right: -8px; top: -38px; width: 76px; } }
@media (prefers-reduced-motion: reduce) {
  .ps .ps-signup.is-joining .ps-ticket__sticker { animation: ps-signup-fade-in .24s ease-out .08s both !important; }
}

/* ---------- Human check: shown only if Cloudflare asks the visitor to tick a box ---------- */
.ps-check {
  position: relative; z-index: 3; width: min(100%, 360px); margin: 18px auto 0; padding: 18px 18px 16px; text-align: left;
  border: 1.5px solid var(--plurel-ink); border-radius: 16px; background: var(--plurel-paper); color: var(--plurel-ink);
  box-shadow: -6px 8px 0 var(--plurel-ink);
  animation: ps-check-in .28s cubic-bezier(.16, 1, .3, 1) both;
}
.ps-check[hidden] { display: none; }
.ps-check::before { content: ""; position: absolute; left: 50%; top: -11px; width: 84px; height: 22px; translate: -50% 0; rotate: -3deg; background: #ece6cd; }
.ps .ps-check__title { font: 400 .75rem/1.2 var(--plurel-label); letter-spacing: .1em; text-transform: uppercase; }
.ps .ps-check__text { margin: 6px 0 12px; font: 400 .9375rem/1.4 var(--plurel-body); }
.ps-check__widget { min-height: 65px; border-radius: 8px; overflow: hidden; }
@keyframes ps-check-in { from { opacity: 0; translate: 0 8px; } }
@media (prefers-reduced-motion: reduce) { .ps .ps-check { animation: none; } }
