/*
 * The six full-screen sections ("scenes", #s0 to #s5): two big titles, one card
 * with the text, the waitlist form, the typewriter effect and the responsive
 * rules. Only one scene is visible at a time; js/scene-controller.js toggles
 * the classes used here:
 *   .on   the scene is visible
 *   .in   the scene is entering (its titles start typing)
 *   .done typing finished: the card slides in
 */

.scene {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;           /* the card re-enables it for the active scene */
  visibility: hidden;
}
.scene.on {
  visibility: visible;
}

/* ---------- big titles ---------- */

.disp {
  position: absolute;
  margin: 0;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.01em;
  color: var(--fg);
  font-size: clamp(2.2rem, 6vw, 4.5rem);
  max-width: 48vw;
  text-shadow: 0 0 18px var(--halo), 0 0 4px var(--halo);
  overflow-wrap: anywhere;
}
.disp.sm {                        /* smaller variant for long titles */
  font-size: clamp(1.7rem, 4vw, 3.4rem);
}
.disp.tl {                        /* top-left title */
  top: calc(56px + 5vh);
  left: clamp(16px, 4vw, 64px);
}
.disp.br {                        /* bottom-right title */
  bottom: 6vh;
  right: clamp(16px, 4vw, 64px);
  text-align: right;
}

/* ---------- card ---------- */

.card {
  position: absolute;
  right: clamp(16px, 6vw, 96px);
  top: 50%;
  width: min(440px, 36vw);
  max-height: calc(100svh - 160px);
  overflow: auto;
  box-sizing: border-box;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--fg);
  pointer-events: none;
  scrollbar-width: none;
  transform: translateY(-50%);
}
.card::-webkit-scrollbar {
  display: none;
}
.card.form {
  width: min(480px, 40vw);
}
.card.more {                      /* more content below: fade the bottom edge (set by scene-controller.js) */
  -webkit-mask-image: linear-gradient(#000 calc(100% - 34px), transparent);
  mask-image: linear-gradient(#000 calc(100% - 34px), transparent);
}

.card p {
  margin: 0 0 .7rem;
}
.card a {
  color: inherit;
}
.card a.btn {
  color: var(--btn-fg);
}
.card a.btn.ghost {
  color: var(--fg);
}
.card h3 {
  margin: 0 0 .2rem;
  font: 600 1.05rem/1.3 var(--font);
}
.card .item {                     /* one titled block inside a card, separated by a thin line */
  border-top: 1px solid var(--line);
  padding: .65rem 0;
}
.card .item:first-child {
  border-top: 0;
  padding-top: 0;
}
.card .item p {
  margin: 0;
  font-size: .95rem;
}
.card .list {
  margin: 0 0 .8rem;
  padding-left: 1.2rem;
}
.card .small {
  font-size: .85rem;
  color: var(--muted);
  margin: 0;
}
.card .chips {                    /* run-in list separated by middle dots */
  font-size: .95rem;
  line-height: 1.6;
  margin: 0 0 .35rem;
}
.card .row {                      /* a row of buttons */
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
}
.card .row.row-top {              /* extra space above a button row that closes a card */
  margin: .9rem 0 0;
}

/* ---------- waitlist form ---------- */

.card form .next {
  display: none;   /* only the phone layout fills the form step by step */
}

.card form {
  display: grid;
  gap: .4rem;
}
.card label {
  display: block;
  font-size: .85rem;
  margin-bottom: .15rem;
}
.card .check {                    /* checkbox rows (privacy, blog) */
  display: flex;
  gap: .5rem;
  align-items: flex-start;
}
.card input[type=text],
.card input[type=email] {
  width: 100%;
  box-sizing: border-box;
  padding: .55rem .65rem;
  font: inherit;
  color: var(--fg);
  background: var(--field);
  border: 1px solid var(--field-line);
  border-radius: 12px;
}
.card input::placeholder {
  color: var(--muted);
}
.card input[type=text]:focus,
.card input[type=email]:focus {
  outline: 0;
  border-color: var(--fg);
  box-shadow: 0 0 0 3px var(--ring);
}
.card input.bad {
  border-color: var(--err);
}
.card .msg {                      /* per-field error text; empty ones take no space */
  font-size: .8rem;
  margin: .25rem 0 0;
  color: var(--err);
}
.card .msg:empty {
  display: none;
}
.card .msg.ok {                   /* success message under the submit button */
  color: var(--ok);
  font-size: .9rem;
  margin: .5rem 0 0;
}

/* Note about the illustration. Hidden on desktop, shown under the form on phones and in the static page. */
.credit-note {
  display: none;
  font-size: .75rem;
  color: var(--muted);
  margin: .9rem 0 0;
}

/* ---------- typewriter (js/typewriter.js) ----------
 * The whole title is in the DOM from the start (stable layout, readable by
 * screen readers); each letter is a span.c that is revealed one by one. */

.c {
  position: relative;
}
.c.r {                            /* red letter: every full stop */
  color: var(--logo-red);
}
.c.b {                            /* azure letter ("o" in "boost") */
  color: var(--logo-blue);
}
.c.i {                            /* every lowercase "i": red dot over an azure stem, like the logo */
  text-shadow: none;
  color: transparent;
  background: linear-gradient(var(--logo-red) 0 var(--tdot, 40%), var(--logo-blue) var(--tdot, 40%) 100%);
  -webkit-background-clip: text;
  background-clip: text;
}
body.tw .c {
  opacity: 0;
}
body.tw .c.on {
  opacity: 1;
}
.c.cur::after {                   /* blinking caret after the last typed letter */
  content: "";
  position: absolute;
  right: -2px;
  top: .08em;
  bottom: .08em;
  width: 2px;
  background: currentColor;
  animation: caret-blink .8s steps(1) infinite;
}
.c.i.cur::after {
  background: var(--fg);
}
@keyframes caret-blink {
  50% { opacity: 0; }
}

/* The card slides in from the right once the titles have finished typing. */
.card {
  opacity: 0;
  transform: translateY(-50%) translateX(48px);
  transition: opacity .6s ease, transform .7s cubic-bezier(.22, .8, .24, 1);
}
.scene.done .card {
  opacity: 1;
  transform: translateY(-50%);
}
body.tw .scene .credit-note {
  opacity: 0;
}
body.tw .scene.done .credit-note {
  opacity: 1;
}

/* ---------- short desktop screens: tighter card, drop the intro line of section 5 ---------- */

@media (min-width: 701px) and (max-height: 820px) {
  body:not(.static) #s4 .lead {
    display: none;
  }
  body:not(.static) #s4 .lead + .item {
    border-top: 0;
    padding-top: 0;
  }
  .card {
    top: calc(50% - 14px);
    padding: 16px 20px;
    max-height: calc(100svh - 268px);
  }
  .card.form {
    padding: 14px 20px;
  }
  .card.form form {
    gap: .2rem;
  }
  .card label {
    font-size: .78rem;
    margin-bottom: .05rem;
  }
  .card input[type=text],
  .card input[type=email] {
    padding: .32rem .6rem;
  }
  .card p {
    margin-bottom: .45rem;
  }
}

/* ---------- phones: first title on top, the brain, the second title, the card at the bottom ---------- */

@media (max-width: 700px) {
  :root {
    --brain-room: clamp(100px, 17svh, 150px);   /* least height kept free for the brain between the titles */
    --card-bottom: 56px;                        /* gap between the card and the bottom of the window: room for the legal line (#legal, three lines) */
  }

  body:not(.static) .lead {
    display: none;
  }
  body:not(.static) .lead + .item {
    border-top: 0;
    padding-top: 0;
  }

  /*
   * The first title sits at the top, the second one just above the card (js/mobile-layout.js
   * publishes the card height as --card-h, so the title follows the card when it grows) and
   * the brain takes the room between them. The second title is smaller.
   */
  .disp {
    font-size: clamp(1.9rem, 10vw, 3rem);
    max-width: calc(100vw - 32px);
  }
  .disp.sm {
    font-size: clamp(1.5rem, 7.5vw, 2.2rem);
  }
  .disp.tl {
    top: 76px;
    left: 16px;
  }
  .disp.br,
  .disp.sm.br {
    top: auto;
    bottom: calc(var(--card-h, 180px) + var(--card-bottom) + 12px);
    right: 16px;
    font-size: clamp(1.35rem, 6.4vw, 1.9rem);
    transition: bottom .3s ease;
  }

  .card,
  .card.form {
    top: auto;
    bottom: var(--card-bottom);
    left: 12px;
    right: 12px;
    width: auto;
    padding: 14px 18px;
    /* js/mobile-layout.js sets --titles-bottom and --title2-h per section: the card never grows into the room kept for the brain */
    max-height: max(140px, min(46svh, calc(100svh - var(--titles-bottom, 200px) - var(--title2-h, 80px) - var(--brain-room) - var(--card-bottom) - 24px)));
    transform: translateY(40px);
  }
  .scene.done .card {
    transform: none;
  }

  /* section 5 has the longest card: compact it */
  #s4 .card {
    max-height: max(140px, min(52svh, calc(100svh - var(--titles-bottom, 200px) - var(--title2-h, 80px) - var(--brain-room) - var(--card-bottom) - 24px)));
  }
  #s4 .item {
    padding: .4rem 0;
  }
  #s4 .item h3 {
    font-size: 1rem;
  }
  #s4 .chips {
    font-size: .88rem;
    line-height: 1.5;
  }
  #s4 .list li {
    font-size: .92rem;
    line-height: 1.35;
  }
  #s4 .row {
    margin-top: .5rem !important;
  }
  .card .item .list {
    margin-bottom: .2rem;
  }

  /*
   * Accordion: only the bold titles of a card show; a tap opens that block and closes the
   * previous one (js/mobile-layout.js adds body.acc and toggles .open). The text stays in the
   * page; without JavaScript or in the static layout every block is open.
   */
  body.acc .card .item {
    padding: .5rem 0;
  }
  body.acc .card .item > h3 {
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
  }
  body.acc .card .item > h3::after {
    content: "+";
    font-weight: 400;
    color: var(--muted);
  }
  body.acc .card .item.open > h3 {
    margin-bottom: .3rem;
  }
  body.acc .card .item.open > h3::after {
    content: "\2212";
  }
  body.acc .card .item:not(.open) > :not(h3) {
    display: none;
  }

  /* Section 4 has no blocks to fold: its list only repeats the sentence above it, so it is not shown on phones (the text stays in the page). */
  body.acc #s3 .list {
    display: none;
  }

  /* The form is filled one step at a time on phones (js/waitlist-form.js marks the current step with .cur), so the card stays small and the brain keeps its room. */
  body.acc #wf > [data-step]:not(.cur) {
    display: none;
  }
  body.acc #wf .next {
    display: inline-block;
  }
  body.acc #wf.last .next {
    display: none;
  }

  #dots {
    right: 8px;
    top: 46%;
  }
  #cue {
    display: none;
  }
  .credit-note {
    display: block;
  }
}

/* The legal line (#legal) takes four lines on the narrowest phones, so the card sits higher. */
@media (max-width: 340px) {
  :root {
    --card-bottom: 70px;
  }
}

/* Honeypot of the waitlist form: off-screen rather than hidden, so bots still fill it in. */
.trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
