/* The waitlist form's states, on top of .join in site.css. The script (waitlist.js) sets
   form[data-state], the status line's data-tone, aria-invalid on the field, aria-busy on the
   button and data-open on the Turnstile holder. Kit and Lado tokens only, both themes, logical
   properties so it reads the same in Arabic.

   .join is a grid with a gap, and an empty grid row still takes its gap. So a part that has
   nothing to show is taken out of the flow (position: absolute, no size), never display: none:
   the status line has to stay in the page for screen readers, and Turnstile has to stay alive. */

/* the kit gives --error to form.form only; the waitlist form is a .join, so it takes the same one */
.join { --error: color-mix(in oklab, #d92d20 72%, var(--ink)); position: relative; }

/* the trap field: out of sight, out of the tab order and out of the layout */
.join__trap {
  position: absolute; inset-block-start: 0; inset-inline-start: 0;
  inline-size: 1px; block-size: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; pointer-events: none;
}

/* the Turnstile holder: no room at all until the check has to show itself to the visitor */
.join__check:not([data-open]) {
  position: absolute; inset-block-end: 0; inset-inline-start: 0;
  inline-size: 0; block-size: 0; overflow: hidden;
}
.join__check[data-open] { min-block-size: 65px; }

/* the status line */
.join__status { margin: 0; font-size: var(--t-small); line-height: 1.5; color: var(--muted); }
.join__status:empty { position: absolute; inline-size: 0; block-size: 0; overflow: hidden; }

/* while the status line speaks it takes the note's place, so the form keeps its height and the
   hero under it does not move (a browser without :has shows both, one line taller) */
.join:not([data-state="done"]):has(.join__status:not(:empty)) .join__note { display: none; }

/* wrong address, or the send failed: the reason in words in the error colour (the field itself
   gets the kit's 2px border from aria-invalid) */
.join__status:is([data-tone="invalid"], [data-tone="error"]) { color: var(--error); font-weight: 500; }

/* the bot check or the service asks for another try: Lado's "needs you" lemon dot before the words */
.join__status:is([data-tone="bot"], [data-tone="busy"]) { color: var(--ink); font-weight: 500; }
.join__status:is([data-tone="bot"], [data-tone="busy"])::before {
  content: ""; display: inline-block; inline-size: 8px; block-size: 8px; margin-inline-end: var(--s-2);
  border-radius: 50%; background: var(--needs-solid); vertical-align: 1px;
}

/* sending: the button stays in place and reads as busy */
.join .btn[aria-busy="true"] { opacity: .6; cursor: progress; }

/* done: the row gives its place to the confirmation, at the height the row had */
.join[data-state="done"] .join__row { display: none; }
.join[data-state="done"] .join__status {
  display: flex; align-items: center; box-sizing: border-box;
  min-block-size: var(--join-row-h, 48px); padding: var(--s-3) var(--s-4); border-radius: var(--r-sm);
  background: var(--done-bg); color: var(--done-ink);
  font-size: var(--t-body); font-weight: 500; line-height: 1.5;
}

@media (prefers-reduced-motion: no-preference) {
  .join__status:not(:empty) { animation: join-status-in var(--dur) var(--ease); }
}
@keyframes join-status-in { from { opacity: 0; } }
