/* ==========================================================================
   Partnership request modal
   Figma: 1440:4576 (form) · 1440:4824 (thank-you)
   ========================================================================== */

/* ---- Overlay ----------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.8);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal.is-open { display: flex; }

/* Locking the body keeps the page behind the overlay from scrolling. */
body.modal-open { overflow: hidden; }

/* ---- Card -------------------------------------------------------------- */
/* Figma draws this at 1128px on a 1440px canvas. At that literal size it eats
   ~75% of a 1512px laptop screen and reads as a takeover, so the whole modal is
   scaled down here. Tune the three values below to resize it as a system —
   type and spacing are derived from them. */
.modal {
  --modal-w: 880px;
  --modal-pad-x: 48px;
  --modal-pad-y: 28px;
}

.modal__card {
  position: relative;
  width: 100%;
  max-width: var(--modal-w);
  margin: auto;
  padding: var(--modal-pad-y) var(--modal-pad-x);
  background: var(--bg-1);
  border: 4px solid var(--primary);
  border-radius: var(--radius-btn);
  /* Never taller than the viewport: scroll inside the card, so the Send button
     stays reachable instead of the whole overlay scrolling away. */
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--white-soft);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.modal__close:hover { color: var(--primary); background: rgba(255, 255, 255, 0.08); }

.modal__panel { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.modal__panel[hidden] { display: none; }

.modal__logo { width: 200px; max-width: 100%; height: auto; align-self: flex-start; }

/* ---- Headings ---------------------------------------------------------- */
.modal__head { display: flex; flex-direction: column; gap: 10px; width: 100%; }

.modal__title {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  line-height: 34px;
  letter-spacing: -0.02em;
  color: var(--primary-light-active);
}

.modal__lead {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--white-soft);
}

/* The waitlist modal is short, so it uses the full Figma 1440-4587 heading scale
   rather than the partnership form's scaled-down sizes. ID-scoped so it never
   touches the partnership modal (its long title must stay small). */
#waitlist-modal .modal__title {
  font-size: 48px;
  font-weight: 700;
  line-height: 48px;          /* 100% */
  letter-spacing: -0.96px;
  color: var(--primary-light-active);   /* #E6FF59 */
}
#waitlist-modal .modal__lead {
  font-size: 24px;
  font-weight: 700;
  line-height: normal;
  color: var(--white-soft);   /* #FBFBFB */
}

/* ---- Form ---------------------------------------------------------------- */
/* Explicit column so the gaps between the fields card, the consent line and the
   CTA are predictable rather than relying on incidental margins. */
.modal__form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

/* ---- Fields card ------------------------------------------------------- */
.modal__fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  padding: 20px;
  background: rgba(219, 219, 219, 0.2);
  border: 2px solid var(--white-soft);
  border-radius: var(--radius-btn);
}

/* Waitlist form has a single email field. Stay single-column and override the
   mobile 2-col grid below (whose :nth-child rule would otherwise halve it). The
   doubled class (0,2,0) is deliberate: it must outrank the equal-specificity
   `.modal__fields { display: grid }` in the max-width:900px block, which wins on
   source order otherwise and shrinks the field to one half-width column. */
.modal__fields.modal__fields--single { display: flex; }

/* Single-line rows centre their label against the field; the interests row has a
   tall stack, so its label top-aligns with the first checkbox instead. */
.modal__row { display: flex; gap: 24px; align-items: center; width: 100%; }
.modal__row--start { align-items: flex-start; }
.modal__row--start .modal__label { padding-top: 8px; }

.modal__label {
  flex: 0 0 140px;
  width: 140px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.09em;    /* 1.17px @ 13px */
  text-transform: uppercase;
  color: var(--white-soft);
}
.modal__label-hint {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 300;
  line-height: 18px;
  letter-spacing: 0.02em;
  text-transform: none;
}

.modal__control { flex: 1 1 auto; min-width: 0; }

.modal__input {
  display: block;
  width: 100%;
  height: 36px;
  padding: 0 16px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 300;
  line-height: 36px;
  color: var(--white-soft);
  background: var(--transparent-2);
  border: 0;
  border-radius: 8px;
  outline: none;
}
.modal__input::placeholder { color: var(--grey-darker); }
.modal__input:focus-visible { box-shadow: 0 0 0 2px var(--primary); }

/* ---- Interest checkboxes ----------------------------------------------- */
.modal__checks { display: flex; flex-direction: column; gap: 6px; }

.modal__check {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 34px;
  padding: 0 16px;
  background: var(--transparent-2);
  border-radius: 8px;
  cursor: pointer;
}
.modal__check input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.modal__box {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: var(--black);
  border: 2px solid var(--white-soft);
  border-radius: 4px;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.modal__box svg { opacity: 0; transition: opacity 0.12s ease; }

.modal__check input:checked + .modal__box {
  background: var(--primary);
  border-color: var(--primary);
}
.modal__check input:checked + .modal__box svg { opacity: 1; }
.modal__check input:focus-visible + .modal__box { box-shadow: 0 0 0 2px var(--primary); }

.modal__check-text {
  font-size: 15px;
  font-weight: 300;
  line-height: 20px;
  color: var(--white-soft);
}

/* ---- Consent + submit --------------------------------------------------- */
.modal__consent {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  /* On top of the form's 10px gap — clear separation from the checkbox list. */
  margin-top: 8px;
  font-size: 14px;
  font-weight: 300;
  line-height: 20px;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--primary-light-active);
  cursor: pointer;
}
.modal__consent input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.modal__box--consent {
  width: 18px;
  height: 18px;
  border-color: var(--primary-light-active);
}
.modal__consent input:checked + .modal__box {
  background: var(--primary);
  border-color: var(--primary);
}
.modal__consent input:checked + .modal__box svg { opacity: 1; }
.modal__consent input:focus-visible + .modal__box { box-shadow: 0 0 0 2px var(--primary); }

/* Waitlist agreement line — the Figma frame shows this as plain text (no checkbox);
   submitting the form is the consent, verified by the double opt-in email. */
.modal__fineprint {
  width: 100%;
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 300;
  line-height: 20px;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--primary-light-active);
}

.modal__error {
  width: 100%;
  margin: 0;
  font-size: 16px;
  font-weight: 300;
  text-align: center;
  color: #ff6b6b;
}
.modal__error[hidden] { display: none; }

.modal__actions { display: flex; justify-content: center; padding-top: 4px; }

/* The Figma default state is the disabled/grey CTA — the button only lights up
   once the required fields, an interest and the consent box are all satisfied. */
.modal__submit:disabled {
  background: var(--grey);
  color: var(--grey-darker);
  border-color: transparent;
  cursor: not-allowed;
}
.modal__submit:disabled:hover { background: var(--grey); }

/* Honeypot — hidden from humans, irresistible to bots. Not type="hidden",
   which bots skip; visually removed but still focusable-by-script only. */
.modal__hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---- Thank-you panel ---------------------------------------------------- */
.modal__panel--thanks { gap: 40px; padding: 24px 0; }
.modal__panel--thanks .modal__logo { align-self: center; }

.modal__thanks-titles {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  width: 100%;
}
.modal__thanks-copy { display: flex; flex-direction: column; gap: 8px; text-align: center; }

.modal__thanks-title {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  line-height: 42px;
  color: #E6FF59;
}
.modal__thanks-body {
  margin: 0;
  font-size: 16px;
  font-weight: 300;
  line-height: 24px;
  color: var(--white-soft);
}
.modal__thanks-art { width: 280px; max-width: 100%; height: auto; }

/* ---- Responsive --------------------------------------------------------- */

/* The form must fit without an internal scrollbar. Its natural height is ~780px,
   so as vertical space shrinks the whole modal compacts in tiers rather than
   clipping the Send button behind a scroll. */
@media (max-height: 950px) {
  .modal { --modal-w: 820px; --modal-pad-y: 22px; }
  .modal__logo { width: 180px; }
  .modal__title { font-size: 26px; line-height: 30px; }
  .modal__panel { gap: 12px; }
  .modal__fields { padding: 16px; gap: 8px; }
  .modal__input { height: 34px; line-height: 34px; }
  .modal__check { min-height: 32px; }
  .modal__checks { gap: 5px; }
  .modal__row--start .modal__label { padding-top: 6px; }
}

@media (max-height: 830px) {
  .modal { --modal-pad-y: 16px; --modal-pad-x: 40px; }
  .modal__logo { width: 160px; }
  .modal__title { font-size: 22px; line-height: 26px; }
  .modal__lead { font-size: 14px; }
  .modal__panel { gap: 8px; }
  .modal__form { gap: 8px; }
  .modal__fields { padding: 14px; gap: 6px; }
  .modal__input { height: 32px; line-height: 32px; }
  .modal__check { min-height: 30px; }
  .modal__checks { gap: 4px; }
  .modal__check-text { font-size: 14px; }
  .modal__consent { margin-top: 4px; font-size: 13px; }
  .modal__actions { padding-top: 0; }
  .modal__submit { padding: 0.875rem 1.5rem; }
}

@media (max-width: 900px) {
  /* Phones: the form is taller than the screen (label-above-input + 44px touch
     targets), so it MUST scroll. Two WebKit-specific traps to avoid — and iOS
     Safari AND iOS Chrome are both WebKit, so this hits every iPhone:

     1. A flex scroll-container that centres an overflowing child (align-items /
        justify-content: center) clips the child's TOP outside the scroll range —
        the card's logo jams against the top edge and can't be scrolled to.
     2. A position:fixed overlay extends behind the browser's bottom toolbar, so
        the last element (the Send button) parks behind the bar, untappable.

     Fix: drop flex on phones. Plain block flow scrolls the overlay from the top,
     keeping the whole card reachable (top never clipped). Bottom padding — plus
     the safe-area inset — lifts the Send button clear of the toolbar. The card
     grows to its natural height; the overlay is the single scroll container. */
  .modal.is-open { display: block; }
  .modal {
    padding: 12px 12px calc(48px + env(safe-area-inset-bottom, 0px));
    --modal-pad-x: 20px;
    --modal-pad-y: 24px;
    -webkit-overflow-scrolling: touch;
  }
  .modal__card { margin: 0 auto; max-height: none; overflow: visible; }

  /* Switch to grid to allow side-by-side fields on mobile */
  .modal__fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 8px;
    padding: 12px;
  }

  /* Stack the label above its control — the fixed column is too wide to keep. */
  .modal__row { grid-column: span 2; flex-direction: column; align-items: flex-start; gap: 4px; width: 100%; }

  .modal__control { width: 100%; }

  /* Place First Name and Last Name in a single row */
  .modal__row:nth-child(1),
  .modal__row:nth-child(2) { grid-column: span 1; }

  .modal__label { flex-basis: auto; width: 100%; font-size: 11px; }

  .modal__logo { width: 140px; }
  .modal__title { font-size: 22px; line-height: 26px; }
  .modal__lead { display: none; }
  .modal__thanks-title { font-size: 26px; line-height: 32px; }

  /* Waitlist headings: scale the 48px title down for phones and keep the subtitle
     visible (the rule above hides .modal__lead for the long partnership form). */
  #waitlist-modal .modal__title { font-size: 32px; line-height: 34px; }
  #waitlist-modal .modal__lead { display: block; font-size: 18px; }

  /* Slightly reduced to compact the form while maintaining touchability */
  .modal__input { height: 38px; line-height: 38px; }
  .modal__check { min-height: 38px; padding: 0 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .modal__box,
  .modal__box svg,
  .modal__close { transition: none; }
}
