/*
 * ECAR repair-request form — sitewide (not front-page-gated), since this
 * same partial is meant to be reused inside a future modal on any page.
 * Namespaced under .ecar-form. Carries its own bordered-surface panel
 * look so it reads as complete wherever it's dropped in.
 */

/* The form is the page's single conversion point, so it should read as the
   most substantial object in its section. It used to do so with two layered
   navy glows — an ambient light source with no cause, which is exactly the
   look the brief rules out. Emphasis now comes from material instead: a real
   surface, a stronger edge, a depth shadow that reads as elevation rather
   than emission, and a 2px accent rule along the top edge. */
.ecar-form {
  position: relative;
  background-color: var(--ecar-surface);
  border: 1px solid var(--ecar-border-strong);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  padding: 34px 36px 36px;
}

.ecar-form::before {
  content: '';
  position: absolute;
  inset: -1px -1px auto;
  height: 2px;
  background-color: var(--ecar-accent);
}

.ecar-form__eyebrow {
  display: block;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ecar-text-primary);
  margin-bottom: 20px;
}

.ecar-form__field {
  margin-bottom: 20px;
}

.ecar-form__label {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ecar-text-secondary);
  letter-spacing: 0.01em;
  margin-bottom: 8px;
}

.ecar-form__input {
  display: block;
  width: 100%;
  background-color: var(--ecar-bg-secondary);
  border: 1px solid var(--ecar-border);
  border-radius: 3px;
  color: var(--ecar-text-primary);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  padding: 13px 14px;
  transition: border-color 200ms ease;
}

.ecar-form__input::placeholder {
  color: var(--ecar-text-secondary);
  opacity: 0.7;
}

/* One focus treatment for the whole form: the field's own border goes accent
   and a soft ring sits outside it. No `outline`, because an outline drawn
   around an already-bordered input is what reads as a second box. */
.ecar-form__input:focus-visible {
  outline: none;
  border-color: var(--ecar-accent);
  box-shadow: 0 0 0 3px var(--ecar-accent-quiet);
}

.ecar-form__select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A5A5A5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 38px;
}

/* --- Phone field: flag slot is intentionally empty --- */
.ecar-form__phone-group {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--ecar-bg-secondary);
  border: 1px solid var(--ecar-border);
  border-radius: 3px;
  padding: 0 14px;
  transition: border-color 200ms ease;
}

/* `:focus-within`, not `:has(… :focus-visible)`: a text field should show
   focus whether it was reached by mouse or by keyboard, and this is the one
   element that has to look focused when its child input is. */
.ecar-form__phone-group:focus-within {
  border-color: var(--ecar-accent);
  box-shadow: 0 0 0 3px var(--ecar-accent-quiet);
}

/* Optional flag icon. The slot has an explicit height now: without one the
   element collapsed and the empty state rendered as a 2px dashed sliver
   inside the phone field. When no icon is set the slot is not printed at all. */
.ecar-form__flag-slot {
  display: inline-flex;
  align-items: center;
  width: 22px;

  flex-shrink: 0;
  overflow: hidden;
}

.ecar-form__flag-slot img {
  width: 100%;
  height: 100%;

}

.ecar-form__phone-code {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ecar-text-secondary);
  flex-shrink: 0;
}

.ecar-form__phone-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 13px 0;
}

/* THE "second field" BUG.
   This input has no border and no background of its own — the group around it
   draws both — so an outline plus a ring here painted a second rounded box
   inside the first one, which is exactly what a focused phone field looked
   like. The group above owns the focus state; the input draws nothing.
   Declared after the shared .ecar-form__input rule on purpose: equal
   specificity, so source order is what makes this win. */
.ecar-form__phone-input:focus,
.ecar-form__phone-input:focus-visible {
  outline: none;
  border: 0;
  box-shadow: none;
}

/* --- Field error state --- */
.ecar-form__error {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--ecar-danger);
  margin: 6px 0 0;
}

.ecar-form__field.has-error .ecar-form__input,
.ecar-form__field.has-error .ecar-form__phone-group {
  border-color: var(--ecar-danger);
}

/* --- Honeypot: invisible to sighted users and screen readers alike --- */
.ecar-form__honeypot {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  left: -9999px;
}

/* --- Submit + loader --- */
.ecar-form__submit {
  width: 100%;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}

/* THE INVISIBLE SPINNER BUG.
   It was hardcoded white-on-transparent, which is invisible on the primary
   button — that button is filled with the bone accent and carries near-black
   text. Built from `currentColor` instead, so it inherits whatever the button
   it sits in is using for its label and stays visible on any variant. */
.ecar-form__spinner {
  display: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  /* The transparent quadrant is what makes a ring read as spinning. */
  border-top-color: transparent;
  opacity: 0.9;
  animation: ecar-form-spin 700ms linear infinite;
}

.ecar-form.is-submitting .ecar-form__spinner {
  display: inline-block;
}

/* The label is swapped rather than dimmed: "Sending…" states what is
   happening, a 75%-opacity "Send a repair request" just looks broken. */
.ecar-form__submit-sending {
  display: none;
}

.ecar-form.is-submitting .ecar-form__submit-label {
  display: none;
}

.ecar-form.is-submitting .ecar-form__submit-sending {
  display: inline;
}

.ecar-form.is-submitting .ecar-form__submit {
  cursor: default;
  pointer-events: none;
}

@keyframes ecar-form-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ecar-form__spinner {
    animation: none;
    opacity: 0.6;
  }
}

/* --- Status message --- */
.ecar-form__status {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  min-height: 1.3em;
  margin: 16px 0 0;
  color: var(--ecar-text-secondary);
}

.ecar-form.is-success .ecar-form__status {
  color: var(--ecar-success);
}

.ecar-form.is-error .ecar-form__status {
  color: var(--ecar-danger);
}

@media (max-width: 767px) {
  .ecar-form {
    padding: 28px 24px;
  }
}

/* --- Textarea + hints (added with the message field) --- */
.ecar-form__textarea {
  min-height: 104px;
  resize: vertical;
  line-height: 1.5;
  font-family: var(--font-sans);
}

/* "optional" beside a label rather than an asterisk on everything else: two
   required fields marked * and one marked optional is less visual noise than
   four asterisks and a legend. */
.ecar-form__optional {
  margin-left: 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ecar-text-muted);
}

.ecar-form__hint {
  margin: 7px 0 0;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--ecar-text-muted);
}

.ecar-form__consent {
  margin: 12px 0 0;
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  line-height: 1.5;
  color: var(--ecar-text-muted);
}

/* The status line only reserves height once it has something to say — an
   empty 1.3em gap under every form was dead space. */
.ecar-form__status:empty {
  display: none;
}

/* =========================================================================
   Lead modal
   Opened by every booking CTA, and on a timer (assets/js/lead-form.js).
   Two columns on a desktop — offer and reassurance on the left, fields on
   the right — collapsing to one on a phone with the copy above the fields.
   ========================================================================= */
/* An author-level `display` beats the UA stylesheet's [hidden] rule, so the
   closed state has to be restated here or the dialog would render on every
   page load. */
.ecar-modal[hidden] {
  display: none;
}

.ecar-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 4vw, 40px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ecar-modal__backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(4, 4, 4, 0.78);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}

.ecar-modal.is-open .ecar-modal__backdrop {
  opacity: 1;
}

/* Progressive nicety: without support the flat scrim already does the job. */
@supports (backdrop-filter: blur(4px)) {
  .ecar-modal__backdrop {
    backdrop-filter: blur(3px);
  }
}

.ecar-modal__dialog {
  position: relative;
  width: 100%;
  max-width: 880px;
  margin: auto;
  background-color: var(--ecar-surface);
  border: 1px solid var(--ecar-border-strong);
  border-radius: 14px;
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: translateY(14px) scale(0.985);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.ecar-modal__dialog:focus-visible {
  outline: none;
}

.ecar-modal.is-open .ecar-modal__dialog {
  opacity: 1;
  transform: none;
}

/* Drawn on the dialog, not on the form inside it, so the large radius is not
   cut by a square accent rule. */
.ecar-modal__dialog::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  border-radius: 14px 14px 0 0;
  background: linear-gradient(90deg, var(--ecar-gold) 0%, var(--ecar-accent) 100%);
}

.ecar-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 9px;
  background-color: rgba(10, 10, 10, 0.6);
  border: 1px solid var(--ecar-border);
  border-radius: var(--r-pill);
  color: var(--ecar-text-secondary);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background-color var(--transition);
}

.ecar-modal__close:hover,
.ecar-modal__close:focus-visible {
  color: var(--ecar-text-primary);
  border-color: var(--ecar-border-strong);
  background-color: var(--ecar-surface-2);
}

.ecar-modal__close svg {
  width: 100%;
  height: 100%;
}

.ecar-modal__body {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1fr);
  gap: 0;
}

.ecar-modal__aside {
  display: flex;
  flex-direction: column;
  padding: clamp(26px, 3vw, 38px);
  border-right: 1px solid var(--ecar-hairline);
}

.ecar-modal__offer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-self: flex-start;
  margin: 0 0 20px;
  padding: 10px 14px;
  background-color: var(--ecar-gold-quiet);
  border: 1px solid var(--ecar-gold-line);
  border-radius: 8px;
}

.ecar-modal__offer-label {
  font-family: var(--font-sans);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ecar-gold-strong);
}

.ecar-modal__offer-figures {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.ecar-modal__offer-old {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ecar-text-muted);
  text-decoration: line-through;
  text-decoration-color: var(--ecar-promo);
  text-decoration-thickness: 2px;
}

.ecar-modal__offer-new {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--ecar-text-primary);
}

.ecar-modal__title {
  margin: 0 0 10px;
  font-size: clamp(1.5rem, 3vw, 1.875rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.ecar-modal__text {
  margin: 0 0 20px;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--ecar-text-secondary);
}

.ecar-modal__trust {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.ecar-modal__trust li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ecar-text-primary);
}

/* Same plate device as the hero's trust strip, one size down: the dialog is
   repeating those claims, so it should look like it is quoting them. */
.ecar-modal__trust-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 5px;
  color: var(--ecar-gold);
  background-color: var(--ecar-gold-quiet);
  border: 1px solid var(--ecar-gold-line);
  border-radius: 8px;
}

.ecar-modal__trust-icon svg {
  width: 100%;
  height: 100%;
}

/* Pushed to the bottom of the column so both panels end level. */
.ecar-modal__call {
  margin: auto 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--ecar-hairline);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--ecar-text-secondary);
}

.ecar-modal__call a {
  display: block;
  margin-top: 2px;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--ecar-text-primary);
  text-decoration: none;
}

.ecar-modal__call a:hover,
.ecar-modal__call a:focus-visible {
  color: var(--ecar-gold-strong);
}

.ecar-modal__form {
  padding: clamp(26px, 3vw, 38px);
}

/* Inside the dialog the form is not its own panel — the dialog is. */
.ecar-modal__form .ecar-form {
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
}

.ecar-modal__form .ecar-form::before {
  display: none;
}

/* Scroll lock. `position: fixed` on <body> would lose the scroll position;
   overflow keeps the page where the visitor left it. */
.ecar-modal-open,
.ecar-modal-open body {
  overflow: hidden;
}

@media (max-width: 767px) {
  /* Full-screen sheet: a centred card with margins on a 375px screen leaves
     the form scrolling inside a scroll, which is where phone modals go wrong. */
  .ecar-modal {
    padding: 0;
    align-items: stretch;
  }

  .ecar-modal__dialog {
    max-width: none;
    min-height: 100%;
    border: 0;
    border-radius: 0;
  }

  .ecar-modal__dialog::before {
    border-radius: 0;
  }

  .ecar-modal__body {
    grid-template-columns: 1fr;
  }

  /* The whole intro block is compressed here for one reason: on a 375px
     screen the desktop proportions pushed the first input ~630px down, so an
     auto-opened dialog showed a visitor a sales panel and no form. Everything
     below trims that to roughly 260px, which puts the name and phone fields
     on the first screenful — the two fields that are actually required. */
  .ecar-modal__aside {
    padding: 40px 20px 18px;
    border-right: 0;
    border-bottom: 1px solid var(--ecar-hairline);
  }

  /* Label beside the figures instead of above them. */
  .ecar-modal__offer {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding: 7px 12px;
  }

  .ecar-modal__offer-new {
    font-size: 1.25rem;
  }

  .ecar-modal__title {
    margin-bottom: 6px;
    font-size: 1.375rem;
  }

  .ecar-modal__text {
    margin-bottom: 14px;
    font-size: 0.875rem;
  }

  .ecar-modal__trust {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 7px 14px;
    margin-bottom: 14px;
  }

  .ecar-modal__trust li {
    font-size: 0.625rem;
    gap: 7px;
  }

  .ecar-modal__trust-icon {
    width: 24px;
    height: 24px;
    padding: 4px;
    border-radius: 7px;
  }

  /* One line, number inline: two stacked lines here cost 46px of the space
     the fields need. */
  .ecar-modal__call {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 0;
    padding-top: 14px;
    font-size: 0.75rem;
  }

  .ecar-modal__call a {
    margin-top: 0;
    font-size: 1rem;
  }

  .ecar-modal__form {
    padding: 22px 22px 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ecar-modal__backdrop,
  .ecar-modal__dialog {
    transition: none;
  }

  .ecar-modal__dialog {
    transform: none;
  }
}
