/* Alfred: the waitlist page.
   One ground (ink), one metal (champagne gold, used as light and foil only),
   one voice for words (ivory). */

:root {
  --ink: #07080a;
  --ink-card: #0d0e11;
  --gold: #d9bf8c;
  --gold-bright: #f0dfb8;
  --rule: rgba(217, 191, 140, 0.34);
  --rule-faint: rgba(217, 191, 140, 0.14);
  --ivory: #ece5d6;
  --muted: #a39b88;
  --garnet: #e79a8c;

  --display: 'Aboreto', 'Didot', 'Bodoni 72', serif;
  --text: 'Jost', 'Futura', 'Century Gothic', 'Avenir Next', sans-serif;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --tap: 3.5rem;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--ink);
  color: var(--ivory);
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--ink);
  font-family: var(--text);
  font-weight: 400;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

::selection { background: var(--gold); color: var(--ink); }

button, input { font: inherit; color: inherit; }

/* ---------- The room ---------- */

.stage {
  position: fixed;
  inset: 0 0 auto 0;
  width: 100%;
  height: 100lvh;
  display: block;
  touch-action: manipulation;
  opacity: 0;
  transition: opacity 0.9s ease;
}
.stage.is-live { opacity: 1; }

/* The sparks the light throws off as the fall lands, which gather into the name.
   Over the room, under the words. */
.sparks {
  position: fixed;
  inset: 0 0 auto 0;
  width: 100%;
  height: 100lvh;
  display: block;
  pointer-events: none;
}

/* No 3D available: a quiet pool of light stands in for the scene. */
.no-webgl .stage,
.no-webgl .sparks { display: none; }
.no-webgl body {
  background:
    radial-gradient(38% 26% at 50% 54%, rgba(217, 191, 140, 0.13), transparent 72%),
    radial-gradient(90% 60% at 50% 100%, rgba(217, 191, 140, 0.05), transparent 70%),
    var(--ink);
}

.page {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  padding:
    calc(env(safe-area-inset-top) + clamp(4.5rem, 13svh, 9rem))
    max(16px, env(safe-area-inset-right))
    calc(env(safe-area-inset-bottom) + clamp(1.75rem, 7svh, 5rem))
    max(16px, env(safe-area-inset-left));
  overflow-x: clip;
  pointer-events: none;
}

.page > * { pointer-events: auto; }

/* ---------- The name ---------- */

.wordmark {
  grid-row: 1;
  margin: 0;
  /* the trailing letter-space would pull the word off centre; nudge it back */
  transform: translateX(0.1em);
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.6rem, 12.5vw, 6rem);
  line-height: 1;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  white-space: nowrap;
  user-select: none;
  transition:
    opacity 1.8s var(--ease),
    letter-spacing 2.6s var(--ease),
    transform 2.6s var(--ease),
    filter 1.8s var(--ease);
}

.wordmark.is-replayable { cursor: pointer; }

.intro .wordmark {
  opacity: 0;
  letter-spacing: 0.55em;
  transform: translateX(0.275em);
  filter: blur(14px);
}

/* While the sparks are gathering they hold the name: it waits, unseen, in exactly
   the shape it will be handed. `measuring` is the same shape for a single frame,
   so the sparks can read where each letter lands. Both must come after `intro`. */
.sparking .wordmark { opacity: 0; }

.sparking .wordmark,
.measuring .wordmark {
  letter-spacing: 0.2em;
  transform: translateX(0.1em);
  filter: none;
  transition: none;
}

/* the sparks go out over the same second the name comes up */
.handoff .wordmark { transition: opacity 1.1s var(--ease); }

/* ---------- The invitation ---------- */

.invite {
  grid-row: 3;
  position: relative;
  width: min(100%, 23rem);
  transition: opacity 1.2s var(--ease) 0.5s, transform 1.4s var(--ease) 0.5s;
}

.intro .invite {
  opacity: 0;
  transform: translateY(0.75rem);
  pointer-events: none;
}

.cta {
  display: block;
  width: 100%;
  height: var(--tap);
  padding: 0 1.5rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: rgba(7, 8, 10, 0.55);
  color: var(--gold-bright);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    background-color 0.5s var(--ease),
    color 0.5s var(--ease),
    border-color 0.5s var(--ease),
    opacity 0.35s var(--ease);
}

@media (hover: hover) {
  .cta:hover { background: var(--gold); border-color: var(--gold); color: var(--ink); }
}
.cta:active { background: var(--gold); border-color: var(--gold); color: var(--ink); }

:focus-visible { outline: 1px solid var(--gold-bright); outline-offset: 4px; }

/* ---------- The reply card ---------- */

.card {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 2.25rem 1.5rem 1.5rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--ink-card);
  /* folded down to the size of the button it grows out of */
  clip-path: inset(calc(100% - var(--tap)) 0 0 0);
  opacity: 0;
  visibility: hidden;
  transition:
    clip-path 0.8s var(--ease),
    opacity 0.3s var(--ease),
    visibility 0s linear 0.8s;
}

/* the second engraved rule */
.card::before {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1px solid var(--rule-faint);
  pointer-events: none;
}

.invite:not([data-state='closed']) .card {
  clip-path: inset(0 0 0 0);
  opacity: 1;
  visibility: visible;
  transition:
    clip-path 0.8s var(--ease),
    opacity 0.2s var(--ease),
    visibility 0s;
}

.invite:not([data-state='closed']) .cta {
  opacity: 0;
  pointer-events: none;
}

.card__close {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  z-index: 2;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.3s var(--ease);
}
.card__close:hover { color: var(--gold-bright); }
.card__close svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 1.3; fill: none; }

/* form and thank-you share one cell so the card never jumps in size */
.card__stack { display: grid; }
.card__stack > * { grid-area: 1 / 1; }

.card__form,
.card__done {
  transition: opacity 0.6s var(--ease), transform 0.8s var(--ease), visibility 0s;
}

.card__done {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.5rem);
}

.invite[data-state='done'] .card__form {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-0.5rem);
  transition: opacity 0.35s var(--ease), transform 0.5s var(--ease), visibility 0s linear 0.5s;
}

.invite[data-state='done'] .card__done {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0.15s;
}

.card__done:focus { outline: none; }

.card__title {
  margin: 0 0 1.75rem;
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.0625rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-align: center;
  color: var(--gold);
}

.field { display: block; margin: 0 0 1.35rem; }

.field__label {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input {
  display: block;
  width: 100%;
  padding: 0.45rem 0 0.55rem;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  background: transparent;
  color: var(--ivory);
  font-size: 1.125rem;
  line-height: 1.4;
  caret-color: var(--gold);
  outline: none;
  appearance: none;
  transition: border-color 0.35s var(--ease);
}

.field input:focus { border-bottom-color: var(--gold); }
.field input[aria-invalid='true'] { border-bottom-color: var(--garnet); }

/* browsers paint autofilled fields pale blue or yellow; keep them in the card */
.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ivory);
  caret-color: var(--gold);
  box-shadow: 0 0 0 100px var(--ink-card) inset;
  transition: background-color 9999s linear 0s;
}

.field__error {
  display: block;
  min-height: 0;
  margin-top: 0.4rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--garnet);
}
.field__error:empty { display: none; }

.trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.submit {
  position: relative;
  display: block;
  width: 100%;
  height: 3.25rem;
  margin-top: 0.4rem;
  overflow: hidden;
  border: 0;
  border-radius: 2px;
  background: var(--gold);
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.35s var(--ease);
}
@media (hover: hover) {
  .submit:hover { background: var(--gold-bright); }
}
.submit:disabled { cursor: progress; }

/* sending: a hairline fills along the foot of the button */
.submit::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--ink);
  opacity: 0;
  transform: scaleX(0);
  transform-origin: left center;
}
.invite[data-state='sending'] .submit::after {
  opacity: 0.75;
  animation: fill 4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes fill {
  from { transform: scaleX(0); }
  to   { transform: scaleX(0.92); }
}

.card__status {
  margin: 0.85rem 0 0;
  font-size: 0.875rem;
  line-height: 1.45;
  text-align: center;
  color: var(--garnet);
}
.card__status:empty { display: none; }

/* The one note under the form: how few places there are. Quiet, but not fine print. */
.fineprint {
  max-width: 30ch;
  margin: 1.15rem auto 0;
  font-size: 0.8125rem;
  line-height: 1.55;
  text-align: center;
  color: var(--muted);
  text-wrap: balance;
}

/* ---------- Sealed ---------- */

.seal {
  width: 84px;
  height: 84px;
  margin: 0 0 1.4rem;
  color: var(--gold);
  overflow: visible;
}
.seal__ring  { fill: none; stroke: currentColor; stroke-width: 1; }
.seal__inner { fill: none; stroke: currentColor; stroke-width: 0.6; opacity: 0.55; }
/* 96 engraved ticks round the rim */
.seal__ticks { fill: none; stroke: currentColor; stroke-width: 3; stroke-dasharray: 0.55 2.297; opacity: 0.7; }
.seal__letter {
  font-family: var(--display);
  font-size: 38px;
  fill: currentColor;
  text-anchor: middle;
  dominant-baseline: middle;
}

.invite[data-state='done'] .seal { animation: press 1.1s var(--ease) 0.2s both; }
@keyframes press {
  0%   { opacity: 0; transform: scale(1.7) rotate(-18deg); filter: blur(8px); }
  55%  { opacity: 1; transform: scale(0.95) rotate(0deg);  filter: blur(0); }
  100% { opacity: 1; transform: scale(1)    rotate(0deg);  filter: blur(0); }
}

.card__thanks {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.1875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  overflow-wrap: anywhere;
}

.card__message {
  max-width: 29ch;
  margin: 0.9rem auto 0;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ivory);
  text-wrap: balance;
}

.noscript {
  grid-row: 3;
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
}

/* ---------- Larger screens ---------- */

@media (min-width: 48rem) {
  .page {
    padding-top: clamp(4rem, 12vh, 8.5rem);
    padding-bottom: clamp(2.5rem, 9vh, 6.5rem);
  }
  .card { padding: 2.75rem 2.25rem 2rem; }
}

/* Short landscape phones: keep the name and the button apart, and close the card
   up enough that the whole reply, note and all, is there without scrolling. */
@media (max-height: 30rem) and (orientation: landscape) {
  .page { padding-top: 1.5rem; padding-bottom: 1.25rem; }
  .wordmark { font-size: clamp(2rem, 7vw, 3.5rem); }
  .card {
    max-height: calc(100svh - 2rem);
    overflow-y: auto;
    padding: 1.5rem 2.25rem 1.25rem;
  }
  .card__title { margin-bottom: 1rem; }
  .field { margin-bottom: 0.9rem; }
  .fineprint { margin-top: 0.7rem; }
}

/* ---------- No-JavaScript and reduced motion ---------- */

.no-js .cta { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
