/* ==========================================================================
   Qualifying pop-up
   ==========================================================================
   Timed lead-qualifying pop-up, roughly ten seconds in, once per visitor per
   thirty days. Ported from qualifying-popup.tsx.

   Three states live in the same card: the qualifying question, the form, and
   the confirmation. Frame styling is in components/popup-frame.css, which the
   estimate dialog shares.

   The pop-up will not open on top of an open <dialog>. Interrupting someone
   who is already filling in the estimate form would be the worst possible
   moment to ask them a question.
   ========================================================================== */

.popup { position: fixed; inset: 0; z-index: 100; display: flex;
         align-items: center; justify-content: center; padding: 1rem; }

.popup[hidden] { display: none; }

/* A real button, so the backdrop is dismissable by pointer without inventing
   a click handler on a div. Kept out of the tab order because Escape and the
   close button are the keyboard paths. */
.popup__backdrop {
  position: absolute;
  inset: 0;
  background-color: color-mix(in oklab, var(--color-neutral-1000) 60%, transparent);
}

.popup__card { position: relative; width: 100%; max-width: 42rem; }
.popup__card .popup-frame { box-shadow: var(--shadow-2xl); }

.popup__state[hidden] { display: none; }

/* -------------------------------------------------------------------------- */
.popup__availability {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--text-label-sm-size);
  line-height: var(--text-label-sm-line);
  font-weight: var(--text-label-sm-weight);
  color: color-mix(in oklab, #ffffff 70%, transparent);
}

.popup__dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--radius-full);
  background-color: var(--success);
  box-shadow: 0 0 0 3px rgb(18 183 106 / 0.2);
}

.popup__title {
  margin-top: 0.75rem;
  font-size: var(--text-h4-size);
  line-height: var(--text-h4-line);
  letter-spacing: -0.025em;
  font-weight: 500;
  color: #ffffff;
}

/* The accent on ink is blue-300, not the brand blue: #0052F8 on neutral-900
   does not carry enough contrast to read as an accent. */
.popup__title-accent { color: var(--color-blue-300); }

.popup__lede {
  margin-top: 0.75rem;
  font-size: var(--text-body-sm-size);
  line-height: var(--text-body-sm-line);
  font-weight: var(--text-body-sm-weight);
  color: color-mix(in oklab, #ffffff 70%, transparent);
}

.popup__proof { margin-top: 1rem; color: #ffffff; }

.popup__proof-value {
  font-size: var(--text-h5-size);
  line-height: var(--text-h5-line);
  letter-spacing: var(--text-h5-tracking);
  font-weight: 500;
}

.popup__proof-label {
  font-size: var(--text-body-sm-size);
  line-height: var(--text-body-sm-line);
  font-weight: var(--text-body-sm-weight);
  color: color-mix(in oklab, #ffffff 60%, transparent);
}

.popup__question {
  margin-top: 1.25rem;
  font-size: var(--text-label-lg-size);
  line-height: var(--text-label-lg-line);
  font-weight: var(--text-label-lg-weight);
  color: #ffffff;
}

.popup__answers { margin-top: 0.75rem; display: flex; gap: 0.5rem; }

.popup__answer {
  height: 2.75rem;
  flex: 1;
  border-radius: var(--radius-full);
  padding-inline: 1.25rem;
  font-size: var(--text-label-lg-size);
  line-height: var(--text-label-lg-line);
  font-weight: 500;
  color: #ffffff;
  transition: background-color 150ms ease;
}

.popup__answer--yes { background-color: var(--brand); }
.popup__answer--yes:hover { background-color: var(--brand-hover); }
.popup__answer--yes:focus-visible { outline: 2px solid var(--color-blue-300); outline-offset: 2px; }

.popup__answer--no {
  border: 1px solid color-mix(in oklab, #ffffff 15%, transparent);
  background-color: color-mix(in oklab, #ffffff 10%, transparent);
}
.popup__answer--no:hover { background-color: color-mix(in oklab, #ffffff 20%, transparent); }
.popup__answer--no:focus-visible {
  outline: 2px solid color-mix(in oklab, #ffffff 40%, transparent);
  outline-offset: 2px;
}

/* -------------------------------------------------------------------------- */
.popup__form { margin-top: 1.25rem; display: flex; flex-direction: column; gap: 0.625rem; }

.popup__form-row { display: flex; flex-direction: column; gap: 0.625rem; }

@media (min-width: 640px) { .popup__form-row { flex-direction: row; } }

.popup__input {
  height: 2.75rem;
  width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in oklab, #ffffff 15%, transparent);
  background-color: color-mix(in oklab, #ffffff 5%, transparent);
  padding-inline: 0.875rem;
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
  color: #ffffff;
}

.popup__input::placeholder { color: color-mix(in oklab, #ffffff 50%, transparent); }

.popup__input:focus-visible {
  border-color: var(--color-blue-300);
  outline: 2px solid color-mix(in oklab, var(--color-blue-300) 30%, transparent);
  outline-offset: 0;
}

.popup__submit {
  margin-top: 0.25rem;
  display: inline-flex;
  height: 3rem;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: var(--radius-full);
  background-color: var(--brand);
  padding-inline: 1.5rem;
  font-size: var(--text-label-lg-size);
  line-height: var(--text-label-lg-line);
  font-weight: 500;
  color: #ffffff;
  transition: background-color 150ms ease;
}

.popup__submit:hover { background-color: var(--brand-hover); }
.popup__submit:focus-visible { outline: 2px solid var(--color-blue-300); outline-offset: 2px; }
.popup__submit svg { width: 1rem; height: 1rem; }

/* -------------------------------------------------------------------------- */
.popup__done {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-block: 1.5rem;
  text-align: center;
}

.popup__done-mark {
  display: flex;
  width: 3.5rem;
  height: 3.5rem;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background-color: color-mix(in oklab, var(--success) 15%, transparent);
  color: var(--success);
}

.popup__done-mark svg { width: 1.75rem; height: 1.75rem; }
.popup__done .popup__title { margin-top: 1.25rem; }
.popup__done .popup__lede { max-width: 24rem; }

/* The service ladder. Present in every state, so the promise never leaves the
   card whichever step the visitor is on. */
.popup__ladder {
  margin-top: 1.5rem;
  font-size: var(--text-label-sm-size);
  line-height: var(--text-label-sm-line);
  font-weight: var(--text-label-sm-weight);
  color: color-mix(in oklab, #ffffff 50%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  .popup__answer, .popup__submit { transition: none; }
}

/* --------------------------------------------------------------------------
   21 Oct 2026 (Hulusi: "the responsive is a bit broken"). A real dimmed
   backdrop (the neutral-1000 token it used does not exist, so the page showed
   through untouched), readable sizes, a card that never runs off the screen,
   and a bottom sheet without the photo on phones.
   -------------------------------------------------------------------------- */
.popup__backdrop { background: rgb(15 17 19 / .62); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.popup__card { max-width: 48rem; }
.popup__card .popup-frame { max-height: calc(100svh - 2rem); overflow-y: auto; overscroll-behavior: contain; }
.popup-frame__body { padding: clamp(1.5rem, 3vw, 2.5rem); }
/* Only the first line of each step clears the close button. */
.popup__state > :first-child:not(.popup__done-mark) { padding-right: 3rem; }
.popup__title { margin-top: 0; font-size: clamp(1.625rem, 2.4vw, 2rem); line-height: 1.1; letter-spacing: -.035em; text-wrap: balance; }
.popup__lede { font-size: 1rem; line-height: 1.5; max-width: 30rem; }
.popup__question { margin-top: 1.5rem; font-size: 1rem; font-weight: 500; }
.popup__answers { flex-wrap: wrap; }
.popup__answer { flex: 1 1 11rem; height: auto; min-height: 3rem; padding: .625rem 1.25rem; font-size: 1rem; white-space: nowrap; }
.popup__ladder { margin-top: 1.25rem; font-size: .875rem; }
.popup__back { display: inline-flex; align-items: center; gap: .375rem; margin: -.25rem 0 1rem; padding: .25rem 0; font: inherit; font-size: .875rem; color: var(--ed-muted, #50565f); background: none; border: 0; cursor: pointer; }
.popup__back svg { width: 1rem; height: 1rem; }
.popup__back:hover { color: var(--ed-ink, #121417); }
.popup__back:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.popup__form { margin-top: 1.25rem; gap: .875rem; }
.popup__form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .875rem; }
.popup__field { display: grid; gap: .375rem; font-size: .875rem; font-weight: 500; color: var(--ed-ink, #121417); }
.popup__field b { color: #c42b1c; font-weight: 500; }
.popup__field i { font-style: normal; font-weight: 400; color: var(--ed-muted, #50565f); }
.popup__submit { margin-top: .375rem; min-height: 3rem; font-size: 1rem; }
.popup__done { padding-block: 2rem; }
@media (min-width: 768px) {
  .popup-frame:not(.popup-frame--compact) { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); }
}
/* Phones: a sheet from the bottom, no photo, scrolls inside if needed. */
@media (max-width: 767px) {
  .popup { align-items: flex-end; padding: 0; }
  .popup__card { max-width: none; }
  .popup__card .popup-frame { max-height: 92svh; border-width: 0 !important; border-top: 1px solid var(--ed-line, #d8dce1) !important; }
  /* The photo stays on phones (23 Oct, Hulusi: "we need the photo here"), as
     a small portrait at the top of the sheet: a full-width strip blew the
     face up. The close button sits across from it. */
  .popup-frame__photo { display: block; position: absolute; top: 1.25rem; left: 1.25rem; width: 3.5rem; height: 3.5rem; overflow: hidden; z-index: 1; }
  .popup-frame__photo img { object-position: 50% 18%; }
  .popup-frame .popup-frame__body { padding-top: 5.75rem; }
  .popup-frame__body { padding: 1.5rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom, 0px)); }
  .popup-frame__close { top: .875rem; right: .875rem; }
}
@media (max-width: 420px) {
  .popup__form-row { grid-template-columns: minmax(0, 1fr); }
  .popup__answer { flex-basis: 100%; }
}
.popup .popup__done-mark svg { width: 1.75rem; height: 1.75rem; }
/* Phones: the portrait introduces the first step only, not the form or the
   confirmation (23 Oct, Hulusi). */
@media (max-width: 767px) {
  .popup-frame:has([data-popup-state="question"][hidden]) .popup-frame__photo { display: none; }
  .popup-frame:has([data-popup-state="question"][hidden]) .popup-frame__body { padding-top: 1.5rem; }
}
.popup__error { display: block; margin-top: -.125rem; font-size: .875rem; font-weight: 400; color: #c42b1c; }
.popup__error[hidden] { display: none; }
.popup__input[aria-invalid="true"] { border-color: #c42b1c; }
/* Placeholders read as examples, not as filled-in values; the error border
   beats the page's input border. */
.home-editorial .popup .popup__input::placeholder { color: #8b919a; }
.home-editorial .popup .popup__input[aria-invalid="true"] { border-color: #c42b1c; }
/* Keyboard open (qualifying-popup.js sets --kb and --vvh from visualViewport):
   the sheet rides on top of the keyboard and fits the space left. */
@media (max-width: 767px) {
  .popup { padding-bottom: var(--kb, 0px); }
  .popup__card .popup-frame { max-height: min(92svh, calc(var(--vvh, 100svh) - .75rem)); }
}
