/* ------------------------------------------------------------------
   Entry modal — fitting the first screen.

   The modal opens by itself and is the first thing most visitors see, so
   it should be readable in one go rather than something to scroll. As
   delivered it was 874px tall on a 390px phone: the eight options ran
   one per row, and the intro, the progress bar, the question, the
   consent line and the skip link had to fit underneath.

   Three things bring it down, in this order of preference:

     1. Two options per row on phones. The delivered stylesheet already
        does this from 600px up; the tiles are short enough to take it
        further down.
     2. Tighter type and spacing, scaled by how much room there actually
        is — driven by viewport HEIGHT, not width, because a 1280x720
        laptop is every bit as short as a phone.
     3. On genuinely short screens, the intro paragraph steps aside. It
        explains what the quiz is; the title and the first question say
        the same thing in fewer pixels.

   Result: every step of the quiz fits without scrolling from 360x640
   upward, which covers current phones, tablets and laptops. Below that
   — a 320x568 iPhone SE — the longest question and the contact step
   still need a scroll, and the overlay scrolls for them as before.

   Nothing here touches the inline quiz card on the page itself. That
   one sits in a scrolling page and has no reason to compress.
   ------------------------------------------------------------------ */

/* ---- Phones ---------------------------------------------------- */
@media (max-width: 520px) {
  #cmvaModal .cmva-choices {
    gap: 8px;
  }

  /* Two up, but only when the step is plain option tiles. The engine
     reuses this same grid for the final contact step — the banner and
     the whole form are its children — so an unconditional two-column
     rule put the form in a side column with its fields off the edge.
     The `:has()` keeps it to the steps it was meant for.

     !important is needed because the engine writes grid-template-columns
     inline on every step, and an inline style outranks a stylesheet. */
  #cmvaModal .cmva-choices:has(> .cmva-choice:not(.has-sub)) {
    grid-template-columns: 1fr 1fr !important;
  }

  #cmvaModal .cmva-choice {
    padding: 10px;
    font-size: 12.5px;
    gap: 8px;
    border-radius: 10px;
  }

  #cmvaModal .cmva-choice__ic {
    font-size: 16px;
  }

  /* Options carrying a description line are too wordy for two columns on
     a narrow screen — they wrap into towers taller than the row they
     save. Those steps stay one per row. */
  #cmvaModal .cmva-choices:has(> .cmva-choice.has-sub) {
    grid-template-columns: 1fr !important;
  }

  #cmvaModal .cmva-choice.has-sub {
    padding: 9px 11px;
  }

  #cmvaModal .cmva-choice__sb {
    font-size: 11.5px;
  }

  #cmvaModal {
    padding: 12px 10px;
  }

  #cmvaModal .cmva-modal__box {
    padding: 16px 14px 12px;
  }

  #cmvaModal .cmva-modal__title {
    font-size: 19px;
    margin-bottom: 6px;
  }

  #cmvaModal .cmva-modal__sub {
    font-size: 13px;
  }

  #cmvaModal .cmva-entry {
    padding-top: 12px;
  }

  #cmvaModal .cmva-progress {
    margin-bottom: 10px;
  }

  #cmvaModal .cmva-entry__step {
    margin-bottom: 10px;
  }

  #cmvaModal .cmva-entry__q {
    margin-bottom: 12px;
  }

  #cmvaModal .cmva-entry__secure {
    margin-top: 12px;
    font-size: 11px;
  }

  /* The last step. Field padding shrinks but the 16px text does not —
     anything smaller and iOS zooms the page in on focus. */
  #cmvaModal .cmva-form {
    gap: 9px 10px;
  }

  #cmvaModal .cmva-form label {
    font-size: 12px;
    gap: 5px;
  }

  #cmvaModal .cmva-form input,
  #cmvaModal .cmva-form select {
    padding: 9px 12px;
  }

  #cmvaModal .cmva-banner {
    padding: 10px 12px;
    margin-bottom: 2px;
  }

  #cmvaModal .cmva-banner p {
    font-size: 12.5px;
  }

  #cmvaModal .cmva-form .cmva-btn {
    padding: 12px 16px;
    font-size: 14px;
  }
}

/* ---- Short screens, any width ----------------------------------- */
@media (max-height: 700px) {
  #cmvaModal .cmva-modal__sub {
    display: none;
  }

  #cmvaModal .cmva-modal__head {
    margin-bottom: 10px;
  }

  #cmvaModal .cmva-modal__title {
    font-size: 18px;
  }

  #cmvaModal .cmva-choice {
    padding: 9px;
    font-size: 12.5px;
  }

  #cmvaModal .cmva-entry__note {
    margin-top: 10px;
    font-size: 11.5px;
  }

  #cmvaModal .cmva-entry__secure {
    margin-top: 10px;
  }

  #cmvaModal .cmva-modal__skip {
    margin-top: 2px;
  }
}

@media (max-height: 600px) {
  #cmvaModal .cmva-modal__eyebrow {
    display: none;
  }

  #cmvaModal .cmva-modal__title {
    font-size: 17px;
    margin-bottom: 4px;
  }

  #cmvaModal .cmva-entry {
    padding-top: 8px;
  }

  #cmvaModal .cmva-entry__step {
    margin-bottom: 8px;
  }

  #cmvaModal .cmva-entry__q {
    margin-bottom: 9px;
  }
}

/* ---- Laptops: wide but short ------------------------------------ */
@media (min-width: 521px) and (max-height: 780px) {
  #cmvaModal {
    padding: 16px 12px;
  }

  #cmvaModal .cmva-modal__box {
    padding: 18px 20px 14px;
  }

  #cmvaModal .cmva-modal__title {
    font-size: 21px;
  }

  #cmvaModal .cmva-modal__sub {
    font-size: 13.5px;
  }

  #cmvaModal .cmva-modal__head {
    margin-bottom: 10px;
  }

  #cmvaModal .cmva-entry {
    padding-top: 12px;
  }

  #cmvaModal .cmva-choice {
    padding: 11px 12px;
  }

  #cmvaModal .cmva-entry__step {
    margin-bottom: 10px;
  }

  #cmvaModal .cmva-entry__q {
    margin-bottom: 12px;
  }

  #cmvaModal .cmva-entry__note {
    margin-top: 10px;
  }

  #cmvaModal .cmva-entry__secure {
    margin-top: 12px;
  }
}

/* A block the script empties between steps kept its margin, so the modal
   carried gaps where nothing was drawn. */
#cmvaModal .cmva-entry__intro:empty {
  margin: 0;
}

#cmvaModal [hidden] {
  display: none !important;
  margin: 0 !important;
}

/* ---- The contact step ------------------------------------------- */

/* By the last step the visitor has answered five questions, so the intro
   paragraph explaining what the quiz is has done its job. Dropping it
   buys the form the room it needs. */
@media (max-width: 640px) {
  #cmvaModal:has(.cmva-form) .cmva-modal__sub {
    display: none;
  }
}

/* Four labelled fields, a banner, a button and the consent line is the
   tallest thing the modal ever shows. On a short screen everything
   except the text size of the inputs gives a little. */
@media (max-height: 700px) {
  #cmvaModal .cmva-banner {
    padding: 8px 10px;
  }

  #cmvaModal .cmva-banner p {
    font-size: 11.5px;
    line-height: 1.45;
  }

  #cmvaModal .cmva-form {
    gap: 7px 10px;
  }

  #cmvaModal .cmva-form label {
    font-size: 11.5px;
    gap: 4px;
  }

  #cmvaModal .cmva-form input,
  #cmvaModal .cmva-form select {
    padding: 8px 11px;
  }

  #cmvaModal .cmva-form .cmva-btn {
    padding: 11px 16px;
    font-size: 13.5px;
  }
}

@media (max-height: 660px) {
  #cmvaModal .cmva-entry__secure {
    margin-top: 8px;
    font-size: 10.5px;
    line-height: 1.5;
  }

  #cmvaModal .cmva-modal__skip {
    margin-top: 0;
  }

  #cmvaModal .cmva-modal__box {
    padding-bottom: 10px;
  }
}

/* ---- Captcha ----------------------------------------------------
   Turnstile runs in interaction-only mode, so for most visitors it
   draws nothing at all and this container stays empty. When
   Cloudflare does decide someone has to be challenged, the widget is
   rendered into a div appended to the end of <body> — which, left
   unstyled, lands below the fold and behind the modal (z-index 200),
   where nobody would ever see it. The submission would then sit there
   until the 8-second timeout gave up on a token that was waiting for
   a click the visitor could not see.

   Centring it above the modal is what makes that case work. The
   :not(:empty) test means none of this applies until the widget
   actually has something in it.
   ------------------------------------------------------------------ */
.cmva-captcha:empty {
  display: none;
}

.cmva-captcha:not(:empty) {
  position: fixed;
  z-index: 210;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 16px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(16, 22, 38, .28);
}
