/*
  ClipReady: the waitlist sheet. The email, then three questions, then the done screen:
  a check, "You're on the list." and one line under it.

  This is the final design, put together from the ten drafts in this folder:
      from q2   the bottom sheet, the three-segment progress, the chips that wrap (steps 1 and 3),
                and steps that slide sideways
      from q1   step 2: the four reels two by two, each tapped to choose it
  plus an email step in front, for pages where "Join the waitlist" is a button (the landing page),
  and a done screen of its own: a filled circle springs in, a check draws inside it and eight
  dots burst from it (chosen from the six in check/). There is no invite link.
  The drafts and their shared stylesheet (questionnaire.css) are untouched; this file holds only
  what the final design uses.

  Loaded after tokens.css and styles.css, without holding up the page: the sheet is hidden until
  someone asks for it. Every colour, font, size, space, radius and shadow is a token. The parts
  are the design system's own: a choice is the waitlist pages' "Choice" (several can be chosen
  here, so tapping one again clears it), the box under them is the "Other" field, Next and Done
  are the primary button, Back and Skip are plain words so only one filled button is in view,
  and the card is a white card with the tile's corners over the scrim, with no shadow.
  The plain numbers left are sizes of drawn things (the close cross, the tick, the progress
  line, the done screen's check), lengths of time, and the breakpoint (760px).
*/

/* ---------- The sheet ---------- */
.qz {
  --qz-pad: var(--cr-space-6);   /* inside the card, left and right */
  --qz-move: .32s;               /* a step leaving and the next arriving; the sheet arriving */
  --qz-ease: cubic-bezier(.2, .7, .2, 1);
  --qz-h: 640px;                 /* the card's height: the same on every step, so the buttons never move */
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: var(--cr-space-3); text-align: left; color: var(--cr-ink);
}
.qz[hidden] { display: none; }
.qz__scrim { position: absolute; inset: 0; background: var(--cr-scrim); }
.qz__card { position: relative; display: flex; flex-direction: column; width: min(100%, 560px); height: min(100%, var(--qz-h)); max-height: 100%; overflow: hidden; border-radius: var(--cr-radius-lg); background: var(--cr-white); }
.qz__card:focus { outline: none; }
/* While it is open the page behind does not scroll */
.qz-open, .qz-open body { overflow: hidden; }

/* ---------- Top: progress and the close button ---------- */
.qz__top { flex: none; display: flex; align-items: center; gap: var(--cr-space-4); padding: var(--cr-space-4) var(--cr-space-4) 0 var(--qz-pad); }
.qz__progress { flex: 1 1 0; min-width: 0; }
.qz__count { font-weight: var(--cr-weight-semibold); font-size: var(--cr-text-sm); line-height: var(--cr-leading-snug); color: var(--cr-grey); font-variant-numeric: tabular-nums; }
/* Three segments, one for each question. A segment is "on" once its question has been reached. */
.qz__bar { display: flex; gap: var(--cr-space-1); height: 4px; margin-top: var(--cr-space-2); }
.qz__bar i { flex: 1 1 0; border-radius: var(--cr-radius-pill); background: var(--cr-line); }
.qz__bar i.is-on { background: var(--cr-ink); }
.qz__x { position: relative; flex: none; width: var(--cr-button-height-sm); height: var(--cr-button-height-sm); margin: 0; padding: 0; border: 0; border-radius: 50%; background: var(--cr-tile); cursor: pointer; -webkit-appearance: none; appearance: none; }
.qz__x::before, .qz__x::after { content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 2px; margin: -1px 0 0 -7px; border-radius: 1px; background: var(--cr-ink); transform: rotate(45deg); }
.qz__x::after { transform: rotate(-45deg); }

/* ---------- The steps: one shows at a time ---------- */
.qz__steps { position: relative; flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: var(--cr-space-5) var(--qz-pad) var(--cr-space-2); }
.qz__step { display: none; min-width: 0; }
.qz__step.is-now, .qz__step.is-leaving { display: block; }
.qz__step.is-leaving { position: absolute; left: var(--qz-pad); right: var(--qz-pad); top: var(--cr-space-5); pointer-events: none; }
.qz__q { margin-bottom: var(--cr-space-4); font-weight: var(--cr-weight-semibold); font-size: var(--cr-text-lg); line-height: var(--cr-leading-snug); letter-spacing: var(--cr-tracking-tight); text-wrap: balance; }
.qz__q:focus { outline: none; }
/* The done screen sits in the middle of the room the questions took */
.qz__steps:has(> .qz__done.is-now) { display: flex; flex-direction: column; justify-content: center; }
.qz__done.is-now { padding-bottom: var(--cr-space-8); }

/* ---------- The email step: the site's own waitlist form ---------- */
.qz__join .signup { max-width: none; margin: 0; }
.qz[data-at="email"] .qz__count, .qz[data-at="email"] .qz__nav > * { visibility: hidden; }
/* Someone already on the list is told so there, and only "Done" is offered */
.qz[data-at="email"].is-already .qz__nav > :not(.qz__finish) { display: none; }
.qz[data-at="email"].is-already .qz__finish { display: inline-flex; margin-left: auto; visibility: visible; }

/* ---------- Choices (steps 1 and 3): chips at their own width, wrapping ---------- */
.qz__chips { display: flex; flex-wrap: wrap; gap: var(--cr-space-2); }
.qz__chip { position: relative; display: flex; flex: 0 1 auto; min-width: 0; }
/* The real tick box lies over the whole choice, unseen: a tap anywhere on it ticks it */
.qz__chip input, .qz__reel input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; -webkit-appearance: none; appearance: none; }
.qz__chip span, .qz__name {
  display: flex; align-items: center; justify-content: center; flex: 1 1 auto;
  min-height: var(--cr-button-height-md); margin: 0; padding: var(--cr-space-2) var(--cr-space-4);
  border: var(--cr-border) solid var(--cr-line); border-radius: var(--cr-button-radius); background: var(--cr-white); color: var(--cr-ink);
  font: var(--cr-button-weight) var(--cr-text-sm)/var(--cr-leading-snug) var(--cr-font); letter-spacing: var(--cr-tracking-body); text-align: center;
  transition: background-color var(--cr-duration-fast) var(--cr-ease), border-color var(--cr-duration-fast) var(--cr-ease), color var(--cr-duration-fast) var(--cr-ease);
}
.qz__chip span { padding-inline: var(--cr-space-5); }
.qz__chip input:checked + span, .qz__reel input:checked ~ .qz__name { border-color: var(--cr-accent); background: var(--cr-accent); color: var(--cr-on-accent); }
.qz__chip input:focus-visible + span, .qz__reel input:focus-visible ~ .qz__name { outline: var(--cr-focus-width) solid var(--cr-accent-ink); outline-offset: var(--cr-focus-width); }
@media (hover: hover) { .qz__chip input:not(:checked):hover + span, .qz__reel input:not(:checked):hover ~ .qz__name { border-color: var(--cr-accent-ink); } }

/* ---------- "Something else? Type it" ---------- */
.qz__other { margin-top: var(--cr-space-2); }
.qz__other input {
  width: 100%; min-width: 0; min-height: var(--cr-button-height-md); margin: 0; padding: 0 var(--cr-space-5);
  border: var(--cr-border) solid var(--cr-line); border-radius: var(--cr-button-radius); background: var(--cr-white); color: var(--cr-ink);
  font: var(--cr-weight-regular) var(--cr-text-base)/var(--cr-leading-snug) var(--cr-font); letter-spacing: var(--cr-tracking-body);
  -webkit-appearance: none; appearance: none;
}
.qz__other input::placeholder { color: var(--cr-grey-2); opacity: 1; }
.qz__other input:focus-visible { outline: none; border-color: var(--cr-accent-ink); box-shadow: var(--cr-shadow-focus); }

/* ---------- Step 2: a reel for each style, two by two, tapped to choose ---------- */
.qz__reels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--cr-space-4) var(--cr-space-3); width: min(100%, 300px); margin-inline: auto; }
.qz__reel { position: relative; display: flex; flex-direction: column; gap: var(--cr-space-2); min-width: 0; }
.qz__frame { position: relative; display: block; }
.qz__reel .reel { display: block; pointer-events: none; }
.qz .reel__toggle { display: none; }
.qz__name { flex: 1 0 auto; }
/* An empty frame says so */
.qz .ph { display: none; position: absolute; left: 50%; top: 50%; padding: var(--cr-space-1) var(--cr-space-3); border-radius: var(--cr-radius-pill); background: var(--cr-scrim); color: var(--cr-white); font-weight: var(--cr-weight-semibold); font-size: var(--cr-text-sm); line-height: var(--cr-leading-snug); white-space: nowrap; transform: translate(-50%, -50%); }
.qz .reel.is-empty .ph { display: block; }
/* A chosen reel gets a tick in its corner */
.qz__frame::before, .qz__frame::after { content: ""; position: absolute; z-index: 1; opacity: 0; transition: opacity var(--cr-duration-fast) var(--cr-ease); }
.qz__frame::before { right: var(--cr-space-2); top: var(--cr-space-2); width: 26px; height: 26px; border-radius: 50%; background: var(--cr-accent); }
.qz__frame::after { right: calc(var(--cr-space-2) + 9px); top: calc(var(--cr-space-2) + 6px); width: 7px; height: 12px; border: solid var(--cr-on-accent); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.qz__reel input:checked ~ .qz__frame::before, .qz__reel input:checked ~ .qz__frame::after { opacity: 1; }

/* ---------- Done: a check, "You're on the list." and one line, all in the middle ---------- */
.qz__done { text-align: center; }
.qz__done .qz__q { margin: var(--cr-space-5) 0 0; }
/* The line under the heading: a sub-line as elsewhere on the site (grey, one size under its heading) */
.qz__sub { margin: var(--cr-space-2) 0 0; font-size: var(--cr-text-base); line-height: var(--cr-leading-lede); color: var(--cr-grey); text-wrap: balance; }
/* The check is one small drawing in a 96 by 96 box: a filled circle, a white tick, and eight dots
   that are seen only while they fly (see Motion, below). This is how it looks when finished, which
   is also all that "reduce motion" shows. */
.qz__check { display: flex; justify-content: center; }
.qz__check svg { display: block; flex: none; width: 96px; height: 96px; overflow: visible; }
.qz__check svg * { transform-origin: 48px 48px; }   /* anything that grows or turns does so about the middle of the drawing */
.qz__check-disc { fill: var(--cr-accent); }
.qz__check-tick { fill: none; stroke: var(--cr-on-accent); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.qz__check-dots circle { fill: var(--cr-accent); opacity: 0; }

/* ---------- Back, Skip, Next ---------- */
.qz__nav { flex: none; display: flex; align-items: center; gap: var(--cr-space-1); padding: var(--cr-space-3) var(--qz-pad) var(--cr-space-5); border-top: var(--cr-border) solid transparent; }
.qz__card.has-more .qz__nav { border-top-color: var(--cr-line); }   /* there is more to scroll to above */
.qz__quiet { min-height: var(--cr-button-height-sm); margin: 0; padding: 0 var(--cr-space-3); border: 0; border-radius: var(--cr-radius-pill); background: none; color: var(--cr-ink-2); font: var(--cr-weight-semibold) var(--cr-text-sm)/var(--cr-leading-snug) var(--cr-font); cursor: pointer; -webkit-appearance: none; appearance: none; }
@media (hover: hover) { .qz__quiet:hover { color: var(--cr-accent-ink); } }
.qz__back { margin: 0 auto 0 calc(-1 * var(--cr-space-3)); }
.qz__next, .qz__finish { margin-left: var(--cr-space-2); }
.qz__finish { display: none; }
.qz[data-at="1"] .qz__back { visibility: hidden; }
.qz[data-at="done"] :is(.qz__back, .qz__skip, .qz__next) { display: none; }
.qz[data-at="done"] .qz__finish { display: inline-flex; margin-left: auto; }
.qz[data-at="done"] .qz__count { visibility: hidden; }

/* ---------- A phone: the card is a sheet from the bottom edge ---------- */
@media (max-width: 759px) {
  .qz { align-items: flex-end; padding: 0; }
  .qz__card { width: 100%; height: min(calc(100% - var(--cr-space-10)), var(--qz-h)); max-height: calc(100% - var(--cr-space-10)); border-radius: var(--cr-radius-lg) var(--cr-radius-lg) 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
/* ---------- A wide screen: a card in the middle, the four reels in one row ---------- */
@media (min-width: 760px) {
  .qz { --qz-pad: var(--cr-space-8); --qz-h: 600px; padding: var(--cr-space-8); }
  .qz__top { padding-top: var(--cr-space-6); padding-right: var(--cr-space-6); }
  .qz__nav { padding-bottom: var(--cr-space-6); }
  .qz__reels { grid-template-columns: repeat(4, minmax(0, 1fr)); width: auto; }
}

/* ---------- Motion ----------
   final.js adds is-open to the sheet a moment after showing it, marks the step being left
   is-leaving for as long as --qz-move, and says which way things are going with
   data-dir="next" or "back". With "reduce motion" on, none of this runs: steps and the sheet
   simply appear, and the done screen shows its finished check. */
@keyframes qz-in-right { from { opacity: 0; transform: translateX(40px); } }
@keyframes qz-in-left { from { opacity: 0; transform: translateX(-40px); } }
@keyframes qz-out-left { to { opacity: 0; transform: translateX(-40px); } }
@keyframes qz-out-right { to { opacity: 0; transform: translateX(40px); } }
/* The done screen. The tick draws by sliding a dash the length of the line into place (the tick is
   marked pathLength="1", so "1" is its whole length). Each dot flies out along its own direction
   (--turn) from the circle's edge to --far, both set on the dot in the page. */
@keyframes qz-pop { from { opacity: 0; transform: scale(.3); } 25% { opacity: 1; } }
@keyframes qz-draw { from { stroke-dasharray: 1 1; stroke-dashoffset: 1; opacity: 0; } 8% { opacity: 1; } to { stroke-dasharray: 1 1; stroke-dashoffset: 0; opacity: 1; } }
@keyframes qz-burst {
  from { opacity: 0; transform: rotate(var(--turn)) translateY(-43px) scale(.4); }
  25%, 60% { opacity: 1; }
  to { opacity: 0; transform: rotate(var(--turn)) translateY(calc(-1 * var(--far))) scale(1); }
}
@keyframes qz-rise { from { opacity: 0; transform: translateY(6px); } }

@media (prefers-reduced-motion: no-preference) {
  .qz__scrim { transition: opacity var(--qz-move) var(--cr-ease); }
  .qz__card { transition: opacity var(--qz-move) var(--cr-ease), transform var(--qz-move) var(--qz-ease); }
  .qz:not(.is-open) .qz__scrim { opacity: 0; }
  .qz:not(.is-open) .qz__card { opacity: 0; transform: translateY(20px); }
  .qz__bar i { transition: background-color var(--cr-duration) var(--cr-ease); }
  .qz__step.is-now { animation: qz-in-right var(--qz-move) var(--qz-ease) both; }
  .qz__step.is-leaving { animation: qz-out-left calc(var(--qz-move) * .6) var(--cr-ease) both; }
  .qz[data-dir="back"] .qz__step.is-now { animation-name: qz-in-left; }
  .qz[data-dir="back"] .qz__step.is-leaving { animation-name: qz-out-right; }
  .qz[data-dir="none"] .qz__step.is-now { animation: none; }   /* the first thing shown arrives with the sheet, not by itself */

  /* The done screen does not slide in like a question: its parts arrive themselves, and step 3
     leaves quickly. In order, from the press of Next or Skip on step 3:
         the circle springs in, overshooting a little     .06s to .46s
         the tick draws inside it                         .32s to .58s
         the eight dots burst out and fade                .58s to .88s
         the heading and its line rise in                 .34s to .62s
     So it is over in about .88s. To change the pace, change the lengths and delays below together.
     Each part is held at its starting look until its turn ("backwards") and, once it has arrived,
     is simply the finished drawing again. */
  .qz .qz__step.qz__done.is-now { animation: none; }
  .qz[data-at="done"] .qz__step.is-leaving { animation-duration: .12s; }
  .qz__done.is-now .qz__check-disc { animation: qz-pop .4s cubic-bezier(.34, 1.56, .64, 1) .06s backwards; }
  .qz__done.is-now .qz__check-tick { animation: qz-draw .26s ease-out .32s backwards; }
  .qz__done.is-now .qz__check-dots circle { animation: qz-burst .3s var(--qz-ease) .58s backwards; }
  .qz__done.is-now :is(.qz__q, .qz__sub) { animation: qz-rise .28s var(--cr-ease) .34s backwards; }
}
@media (prefers-reduced-motion: no-preference) and (max-width: 759px) {
  /* The sheet comes up from the bottom edge */
  .qz:not(.is-open) .qz__card { opacity: 1; transform: translateY(100%); }
}
