/* ============================================================
   modal.css
   Post-signup enrichment modal. Opened by scripts/modal.js after
   a successful submit on either the hero waitlist form or the
   closing cta form. The email is already captured; this modal
   asks 5 optional fields and can be dismissed at any point
   (X, Esc, "Skip for now", or backdrop click).

   Design rules (intentional, do not change):
     - ZERO border-radius anywhere
     - One sage-green accent for selected pills only
     - Generous padding, no cramped grids
   ============================================================ */

/* ---------- Container + overlay ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vh 4vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 10, 8, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal__panel {
  position: relative;
  background: var(--bg);
  border: 1px solid rgba(243, 237, 230, 0.16);
  border-radius: 0;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 5vh 3.4vw;
  transform: translateY(20px);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal.is-open .modal__panel {
  transform: none;
}

/* Custom scrollbar on the panel so it doesn't break the dark palette */
.modal__panel::-webkit-scrollbar { width: 6px; }
.modal__panel::-webkit-scrollbar-track { background: transparent; }
.modal__panel::-webkit-scrollbar-thumb {
  background: rgba(243, 237, 230, 0.15);
  border-radius: 0;
}

.modal__close {
  position: absolute;
  top: 1.6vh;
  right: 1.4vw;
  width: 2.2em;
  height: 2.2em;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--muted);
  font-family: "Neue Montreal", sans-serif;
  font-size: 1.4vw;
  line-height: 1;
  cursor: pointer;
  transition: color 200ms ease;
}

.modal__close:hover { color: var(--ink); }

/* ---------- Header ---------- */

.modal__head {
  margin-bottom: 4vh;
}

.modal__title {
  margin: 0;
  font-family: "Gordita", sans-serif;
  font-weight: 300;
  font-size: 2.2vw;
  line-height: 1.1;
  letter-spacing: 0.004em;
  color: var(--ink);
}

.modal__subtitle {
  margin: 1.6vh 0 0;
  max-width: 28em;
  font-family: "Neue Montreal", sans-serif;
  font-size: 1vw;
  line-height: 1.5;
  color: var(--muted);
}

/* ---------- Field block ---------- */

.field {
  margin-bottom: 3.4vh;
}

.field__label {
  display: block;
  margin-bottom: 1.4vh;
  font-family: "Neue Montreal", sans-serif;
  font-size: 0.78vw;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.field__optional {
  margin-left: 0.4em;
  text-transform: none;
  letter-spacing: 0.01em;
  color: rgba(161, 148, 138, 0.55);
}

.field__input {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(243, 237, 230, 0.32);
  border-radius: 0;
  color: var(--ink);
  font-family: "Neue Montreal", sans-serif;
  font-size: 1vw;
  padding: 1em 1.2em;
}

.field__input::placeholder { color: var(--muted); }

.field__input:focus {
  outline: none;
  border-color: rgba(243, 237, 230, 0.6);
}

/* ---------- Pills (single-select, click to toggle) ---------- */

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6vw;
}

.pill {
  padding: 0.85em 1.25em;
  background: transparent;
  border: 1px solid rgba(243, 237, 230, 0.32);
  border-radius: 0;
  color: var(--ink);
  font-family: "Neue Montreal", sans-serif;
  font-size: 0.92vw;
  line-height: 1.2;
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
}

.pill:hover {
  border-color: rgba(243, 237, 230, 0.6);
}

.pill.is-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.pill:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 2px;
}

/* ---------- Choice cards (single-select, like pills but with a bold
   heading + an always-visible muted description). Used for the stage
   field where each option needs a short tooltip-style explanation
   without an actual tooltip. */

.choices {
  display: flex;
  gap: 0.6vw;
  align-items: stretch;       /* all 3 cards match the tallest */
}

.choice {
  flex: 1 1 0;                /* equal width */
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 1.8vh 1vw;
  background: transparent;
  border: 1px solid rgba(243, 237, 230, 0.32);
  border-radius: 0;
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
}

.choice:hover {
  border-color: rgba(243, 237, 230, 0.6);
}

.choice:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 2px;
}

.choice__title {
  display: block;
  font-family: "Gordita", sans-serif;
  font-weight: 400;
  font-size: 1.1vw;
  line-height: 1.2;
  letter-spacing: 0.008em;
  color: var(--ink);
  margin-bottom: 0.8vh;
}

.choice__desc {
  display: block;
  font-family: "Neue Montreal", sans-serif;
  font-size: 0.85vw;
  line-height: 1.45;
  color: var(--muted);
}

/* Selected state — same filled green as .pill.is-selected. Text colors
   shift to the bg palette so they remain legible on green; the desc
   stays slightly faded to preserve hierarchy. */
.choice.is-selected {
  background: var(--accent);
  border-color: var(--accent);
}

.choice.is-selected .choice__title {
  color: var(--bg);
}

.choice.is-selected .choice__desc {
  /* 0.85 alpha lands at 5.5:1 against the sage selected bg — passes
     WCAG AA (4.5:1) with a comfortable margin while keeping the desc
     visually subordinate to the .choice__title above. Earlier 0.72
     measured 4.20:1 (failed AA). */
  color: rgba(34, 23, 18, 0.85);
}

/* ---------- Combobox (custom dropdown) ----------
   Native <select> popups can't be styled — light bg, rounded corners,
   system fonts. We replace them with an ARIA-listbox pattern that uses
   the same dark/cream/square palette as the rest of the modal.

   Markup pattern (see index.html):
     .combobox > [trigger] + [hidden input] + [ul role=listbox]
   Behavior lives in scripts/modal.js (setupCombobox). */

.combobox {
  position: relative;
}

.combobox__trigger {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid rgba(243, 237, 230, 0.32);
  border-radius: 0;
  color: var(--ink);
  font-family: "Neue Montreal", sans-serif;
  font-size: 1vw;
  padding: 1em 3em 1em 1.2em;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
}

.combobox__trigger:focus {
  outline: none;
  border-color: rgba(243, 237, 230, 0.6);
}

.combobox__value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.combobox__value.is-placeholder {
  color: var(--muted);
}

/* Chevron — same shape/position as the old .select::after, but inside
   the button so we can rotate it when the listbox opens. */
.combobox__chevron {
  position: absolute;
  right: 1.3em;
  top: 50%;
  width: 0.55em;
  height: 0.55em;
  border-right: 1px solid var(--muted);
  border-bottom: 1px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.combobox__trigger[aria-expanded="true"] .combobox__chevron {
  /* flip the same square 180° so the diagonal points up */
  transform: translateY(-30%) rotate(225deg);
}

/* ---------- Listbox panel ---------- */

.combobox__list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--bg);
  border: 1px solid rgba(243, 237, 230, 0.32);
  border-radius: 0;
  max-height: 260px;
  overflow-y: auto;
  font-family: "Neue Montreal", sans-serif;
  font-size: 1vw;
}

.combobox__list::-webkit-scrollbar { width: 6px; }
.combobox__list::-webkit-scrollbar-track { background: transparent; }
.combobox__list::-webkit-scrollbar-thumb {
  background: rgba(243, 237, 230, 0.2);
  border-radius: 0;
}

.combobox__option {
  padding: 0.85em 1.2em;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  /* don't transition background — flicker-free keyboard nav */
}

.combobox__option:hover,
.combobox__option.is-highlighted {
  background: rgba(243, 237, 230, 0.08);
}

.combobox__option[aria-selected="true"] {
  color: var(--accent);
}

/* Separator under UAE in the country list — non-interactive divider */
.combobox__option--separator {
  cursor: default;
  pointer-events: none;
  color: rgba(243, 237, 230, 0.18);
  font-size: 0.7em;
  letter-spacing: 0.2em;
  padding: 0.4em 1.2em;
  border-top: 1px solid rgba(243, 237, 230, 0.08);
  border-bottom: 1px solid rgba(243, 237, 230, 0.08);
}

/* ---------- Actions ---------- */

.modal__actions {
  margin-top: 4.6vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.8vh;
}

.modal__submit {
  width: 100%;
  background: var(--ink);
  color: var(--bg);
  border: 1px solid var(--ink);
  border-radius: 0;
  font-family: "Gordita", sans-serif;
  font-size: 1vw;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 1.15em 2vw;
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
}

.modal__submit:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.modal__skip {
  background: none;
  border: 0;
  padding: 0.4em 0.6em;
  font-family: "Neue Montreal", sans-serif;
  font-size: 0.88vw;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 200ms ease;
}

.modal__skip:hover { color: var(--ink); }

/* ---------- Success state ----------
   Shown for 3.5s after Done is clicked, then the modal closes.
   Skip path closes immediately (no success view); X closes immediately
   from any state. Markup lives next to the form, toggled via `hidden`. */

/* Important: do NOT set `display` on the bare .modal__success selector.
   The element uses the [hidden] attribute to toggle visibility, and an
   unconditional `display: flex` here would override the user-agent's
   `[hidden] { display: none }` (equal specificity, author rule wins by
   cascade order) — leaving the success view visible underneath the form
   when the modal first opens. Gate all layout on :not([hidden]). */
.modal__success:not([hidden]) {
  padding: 4vh 0 2vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* Hand-drawn checkmark — same SVG idiom as the .check in who.css, but
   bigger and drawn-on-reveal. Animation triggers the moment the parent
   loses `hidden` (CSS sees the attribute presence). */
.modal__success-check {
  width: 3.8vw;
  height: 3.8vw;
  margin-bottom: 2.6vh;
  overflow: visible;
}

.modal__success-check path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.modal__success:not([hidden]) .modal__success-check path {
  animation: draw 0.7s cubic-bezier(0.65, 0, 0.35, 1) 0.18s forwards;
}

.modal__success-title {
  margin: 0;
  font-family: "Gordita", sans-serif;
  font-weight: 300;
  font-size: 2vw;
  line-height: 1.1;
  letter-spacing: 0.004em;
  color: var(--ink);
}

.modal__success-sub {
  margin: 1.6vh 0 0;
  max-width: 22em;
  font-family: "Neue Montreal", sans-serif;
  font-size: 1vw;
  line-height: 1.5;
  color: var(--muted);
}
