/* lead-modal.css — overlay + form styles for the per-vehicle inquiry modal,
   plus the iMessage-blue / golden-yellow CTA buttons that open it.
   Loaded on inventory and VDP pages (and any page with [data-lead-modal]).
*/

/* =========================================================
   CTA buttons that trigger the modal
   ========================================================= */

/* iMessage blue — "Have Austin text me about STK# X"  */
:root {
  --imsg-blue:        #0B93F6;
  --imsg-blue-deep:   #0879D1;
  --aotl-gold:        #F2BF42;
  --aotl-gold-deep:   #D8A322;
}

/* VDP: full-width primary buttons in the right-column pricebar */
.btn--text-cta,
.btn--email-cta {
  width: 100%;
  justify-content: center;
  font-weight: 600;
  letter-spacing: -.005em;
  transition: background .15s var(--ease), transform .12s var(--ease), box-shadow .15s var(--ease);
}
.btn--text-cta {
  background: var(--imsg-blue);
  color: #fff;
  border-color: var(--imsg-blue);
}
.btn--text-cta:hover {
  background: var(--imsg-blue-deep);
  border-color: var(--imsg-blue-deep);
  transform: translateY(-1px);
  box-shadow: 0 6px 14px oklch(from #0B93F6 l c h / .25);
}
.btn--email-cta {
  background: var(--aotl-gold);
  color: #1A1A1A;
  border-color: var(--aotl-gold);
}
.btn--email-cta:hover {
  background: var(--aotl-gold-deep);
  border-color: var(--aotl-gold-deep);
  transform: translateY(-1px);
  box-shadow: 0 6px 14px oklch(from #F2BF42 l c h / .25);
}
/* INFINITI override. vehicle.css has `.page-new .vdp__cta .btn--primary`
   (specificity 0,3,0) which would otherwise repaint these buttons in
   INFINITI midnight blue on the new/CPO VDPs. Matching that specificity
   with .vdp__cta scoping — and loading lead-modal.css AFTER vehicle.css
   in the HTML — means our iMessage-blue and gold win on order tiebreak. */
.page-new .vdp__cta .btn--text-cta,
.page-cpo .vdp__cta .btn--text-cta {
  background: var(--imsg-blue);
  color: #fff;
  border-color: var(--imsg-blue);
}
.page-new .vdp__cta .btn--text-cta:hover,
.page-cpo .vdp__cta .btn--text-cta:hover {
  background: var(--imsg-blue-deep);
  border-color: var(--imsg-blue-deep);
}
.page-new .vdp__cta .btn--email-cta,
.page-cpo .vdp__cta .btn--email-cta {
  background: var(--aotl-gold);
  color: #1A1A1A;
  border-color: var(--aotl-gold);
}
.page-new .vdp__cta .btn--email-cta:hover,
.page-cpo .vdp__cta .btn--email-cta:hover {
  background: var(--aotl-gold-deep);
  border-color: var(--aotl-gold-deep);
}

/* Card variants — proper buttons, not text links. Two CTAs side-by-side
   inside the card, with the optional "View at RBM" link spanning beneath. */
.veh__cta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
  align-items: stretch;
}
.veh__cta-text,
.veh__cta-email {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 999px;
  font: 600 13px/1 var(--sans);
  letter-spacing: -.005em;
  text-decoration: none;
  border: 1.5px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  transition: background .15s var(--ease), transform .12s var(--ease), box-shadow .15s var(--ease);
}
.veh__cta-text {
  background: var(--imsg-blue);
  color: #fff;
  border-color: var(--imsg-blue);
}
.veh__cta-text:hover {
  background: var(--imsg-blue-deep);
  border-color: var(--imsg-blue-deep);
  transform: translateY(-1px);
}
.veh__cta-email {
  background: var(--aotl-gold);
  color: #1A1A1A;
  border-color: var(--aotl-gold);
}
.veh__cta-email:hover {
  background: var(--aotl-gold-deep);
  border-color: var(--aotl-gold-deep);
  transform: translateY(-1px);
}
.veh__cta-text svg,
.veh__cta-email svg { flex-shrink: 0; }
.veh__cta-sec[href] {
  grid-column: 1 / -1;
  justify-self: center;
  font-size: 12px;
  margin-top: 4px;
}

/* =========================================================
   Conditional form fields (text vs email modes)
   ========================================================= */
.lead-modal__field[hidden] { display: none; }

/* =========================================================
   Modal overlay + panel
   ========================================================= */
.lead-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: end center;
  padding: 0;
}
/* The author-level `display: grid` above outranks the UA `[hidden] { display: none }`,
   so without this line the modal stays visually present after close handlers fire.
   Higher-specificity selector (class + attribute) wins the cascade. */
.lead-modal[hidden] { display: none; }
@media (min-width: 700px) {
  .lead-modal {
    place-items: center;
    padding: 24px;
  }
}

body.lead-modal-open { overflow: hidden; }

.lead-modal__overlay {
  position: absolute;
  inset: 0;
  background: oklch(0% 0 0 / .55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: lm-fade .18s var(--ease) both;
}

.lead-modal__panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 540px;
  /* iOS Safari computes static `vh` against the *large* viewport (browser
     UI hidden), so 92vh ends up larger than the visible area when the
     address bar is showing — the panel extends above the screen and you
     can't reach the cut-off top. `dvh` is the dynamic viewport and tracks
     the actual visible height. Keep `vh` as fallback for older engines. */
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  /* Contain scroll so reaching the panel's top/bottom doesn't bleed into
     the page (which is locked, but iOS still tries to rubber-band). */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* Body has `touch-action: pan-y`; setting it explicitly here makes
     vertical scroll inside the panel reliable on iOS Safari regardless
     of how touch propagates from the overlay. */
  touch-action: pan-y;
  background: var(--bg, #FBF6EC);
  border: 1px solid var(--line, #E5DCC4);
  border-top: 1.5px solid var(--line, #E5DCC4);
  border-radius: 18px 18px 0 0;
  /* Bottom padding accommodates the iOS home-indicator safe area so the
     submit button isn't tucked under it. */
  padding: clamp(18px, 4vw, 28px)
           clamp(18px, 4vw, 28px)
           max(clamp(20px, 4vw, 28px), env(safe-area-inset-bottom, 20px));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .18);
  animation: lm-rise .22s var(--ease) both;
}
@media (min-width: 700px) {
  .lead-modal__panel {
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .22);
    max-height: 88vh;
    max-height: 88dvh;
  }
}

/* Tight mobile spacing — the form has ~7 sections and easily exceeds the
   visible area on a phone. These trims keep more content in view without
   relying on internal scroll. */
@media (max-width: 480px) {
  .lead-modal__panel {
    padding-top: 16px;
  }
  .lead-modal__close { top: 8px; right: 8px; width: 32px; height: 32px; }
  .lead-modal__head { margin: 0 36px 12px 0; }
  .lead-modal__title { font-size: 18px; line-height: 1.2; }
  .lead-modal__eyebrow { font-size: 10.5px; margin-bottom: 2px; }
  .lead-modal__form { gap: 10px; }
  .lead-modal__field > input,
  .lead-modal__field > textarea {
    padding: 10px 12px;
    font-size: 16px; /* iOS won't auto-zoom on focus when input >= 16px */
  }
  .lead-modal__field > textarea { min-height: 72px; line-height: 1.35; }
  .lead-modal__consent { font-size: 12px; padding: 8px 10px; }
  .lead-modal__submit-row { margin-top: 2px; }
}

@keyframes lm-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes lm-rise {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.lead-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: transparent;
  border: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--ink, #1A1A1A);
  transition: background .12s var(--ease);
}
.lead-modal__close:hover { background: var(--paper-2, #F2EAD2); }
.lead-modal__close:focus-visible { outline: 2px solid var(--ink, #1A1A1A); outline-offset: 2px; }

/* Header */
.lead-modal__head {
  margin: 0 36px 18px 0;
}
.lead-modal__eyebrow {
  margin: 0 0 4px;
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted, #7a6f55);
}
.lead-modal__via {
  font-weight: 600;
}
[data-via="text"] ~ * .lead-modal__via,
.lead-modal__form input[name="via"][value="text"] ~ .lead-modal__via { /* hook for via state */ }
.lead-modal__title {
  margin: 0;
  font-family: var(--display, var(--sans));
  font-weight: 700;
  font-size: clamp(20px, 2.6vw, 26px);
  letter-spacing: -.015em;
  line-height: 1.15;
  color: var(--ink, #1A1A1A);
  font-variation-settings: "wdth" 96;
}

/* Form layout */
.lead-modal__form { display: grid; gap: 14px; }
.lead-modal__row { display: grid; gap: 12px; }
.lead-modal__row--2 {
  grid-template-columns: 1fr;
}
@media (min-width: 480px) {
  .lead-modal__row--2 { grid-template-columns: 1fr 1fr; }
}

.lead-modal__field { display: grid; gap: 4px; min-width: 0; }
.lead-modal__field > span {
  font: 500 11.5px/1 var(--mono, ui-monospace, Menlo, monospace);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted, #7a6f55);
}
.lead-modal__field > input,
.lead-modal__field > textarea {
  font: 500 16px/1.35 var(--sans, system-ui);
  padding: 12px 14px;
  background: var(--paper-2, #F5EDDA);
  color: var(--ink, #1A1A1A);
  border: 1.5px solid var(--line, #E5DCC4);
  border-radius: 10px;
  outline: none;
  transition: border-color .12s var(--ease), background .12s var(--ease);
  width: 100%;
  resize: vertical;
  font-family: inherit;
}
.lead-modal__field > textarea {
  min-height: 96px;
  line-height: 1.4;
}
.lead-modal__field > input:focus,
.lead-modal__field > textarea:focus {
  border-color: var(--ink, #1A1A1A);
  background: #fff;
}
.lead-modal__field > input[readonly] {
  color: var(--ink-soft, #4a4a4a);
  background: oklch(from #F5EDDA l c h / .6);
  border-style: dashed;
}
.lead-modal__field.is-error > input,
.lead-modal__field.is-error > textarea {
  border-color: #C8362F;
  background: #FCEFEC;
}
.lead-modal__opt {
  font-style: normal;
  font-weight: 400;
  color: var(--ink-soft, #6a5f48);
  text-transform: none;
  letter-spacing: 0;
  margin-left: 4px;
}
.lead-modal__field.is-error > span { color: #C8362F; }

.lead-modal__err {
  font: 500 11px/1.3 var(--mono, monospace);
  color: #C8362F;
  margin-top: 2px;
  display: block;
  font-style: normal;
}
.lead-modal__err:empty { display: none; }

/* Consent */
.lead-modal__consent {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  background: var(--paper-2, #F5EDDA);
  border: 1px solid var(--line, #E5DCC4);
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-soft, #4a4a4a);
  cursor: pointer;
}
.lead-modal__consent input {
  margin-top: 2px;
  accent-color: var(--imsg-blue);
  cursor: pointer;
}
.lead-modal__consent.is-error {
  border-color: #C8362F;
  background: #FCEFEC;
}

/* Submit row */
.lead-modal__submit-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  margin-top: 4px;
}
.lead-modal__cancel {
  font: 500 13.5px/1 var(--sans, system-ui);
  background: transparent;
  border: 0;
  padding: 12px 8px;
  color: var(--ink-soft, #4a4a4a);
  cursor: pointer;
  border-radius: 8px;
  transition: background .12s var(--ease);
}
.lead-modal__cancel:hover { background: var(--paper-2, #F5EDDA); }

.lead-modal__submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  background: var(--imsg-blue);
  color: #fff;
  font: 600 14px/1 var(--sans, system-ui);
  letter-spacing: -.005em;
  border: 1.5px solid var(--imsg-blue);
  border-radius: 999px;
  cursor: pointer;
  transition: background .12s var(--ease), transform .12s var(--ease);
}
.lead-modal__submit:hover {
  background: var(--imsg-blue-deep);
  border-color: var(--imsg-blue-deep);
}
/* Email variant — when the modal is opened via email CTA we color the submit
   button gold to mirror the source action. Switched via data-via on the panel. */
.lead-modal:has(input[name="via"][value="email"]) .lead-modal__submit {
  background: var(--aotl-gold);
  color: #1A1A1A;
  border-color: var(--aotl-gold);
}
.lead-modal:has(input[name="via"][value="email"]) .lead-modal__submit:hover {
  background: var(--aotl-gold-deep);
  border-color: var(--aotl-gold-deep);
}
.lead-modal__submit.is-loading { opacity: .7; cursor: progress; }
.lead-modal__submit[disabled] { cursor: progress; }

/* Thanks state — uses the shared `.confirm` component from styles.css for
   the animated checkmark, headline, recap list. Modal-specific tweaks
   below keep it tight inside the panel.
   Entry animation is now driven by `.swap-pane.is-entering` (see styles.css)
   so it stays in sync with the form's exit. The opaque cream background
   covers the form pane underneath during the rise. */
.lead-modal__thanks {
  padding: 4px 0 8px;
  background: var(--bg, #FBF6EC);
}
.lead-modal__thanks .confirm { max-width: 100%; }
.lead-modal__thanks .confirm__head {
  font-size: clamp(22px, 2.5vw, 28px);
  outline: none;
}
.lead-modal__thanks .confirm__lede { font-size: 15px; }
.lead-modal__thanks .confirm__recap { font-size: 12.5px; }
.lead-modal__thanks .lead-modal__cancel {
  justify-self: start;
  background: var(--paper-2, #F5EDDA);
  padding: 10px 16px;
  margin-top: 4px;
}
