/* =============================================================================
   LEAD FORMS — home hero + contact page (en / es), driven by js/lead-form.js.
   Floating labels, one look for the inputs and the showroom select, inline
   errors, a sending state and a form-level status message.
   ============================================================================= */

/* ---------- Inputs ---------- */
.lead-form .field-input {
  height: 56px;
  padding: 24px 16px 8px;
  /* 16px keeps iOS from zooming in on focus (custom.css forces 13px on every input) */
  font-size: 16px !important;
  line-height: 1.25;
  background-color: var(--color-bg-alt);
  border: 1.5px solid transparent;
  border-radius: 10px;
  transition: border-color var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
}

.lead-form .field-input:hover {
  border-color: var(--color-line);
}

.lead-form .field-input:focus {
  outline: none;
  background-color: var(--color-white);
  border-color: var(--color-ink);
  box-shadow: 0 0 0 4px rgba(10, 10, 10, 0.06);
}

.lead-form textarea.field-input {
  height: auto;
  min-height: 120px;
  padding-top: 28px;
  resize: vertical;
}

/* Browser autofill: keep our colours instead of the yellow / blue fill */
.lead-form .field-input:-webkit-autofill {
  -webkit-text-fill-color: var(--color-ink);
  box-shadow: inset 0 0 0 100px var(--color-bg-alt);
}

.lead-form .field-input:-webkit-autofill:focus {
  box-shadow: inset 0 0 0 100px var(--color-white), 0 0 0 4px rgba(10, 10, 10, 0.06);
}

/* ---------- Floating labels (input needs placeholder=" ") ---------- */
.lead-form .field-label {
  position: absolute;
  top: 18px;
  left: 17.5px;
  max-width: calc(100% - 52px);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 15px;
  line-height: 20px;
  color: var(--color-ink-muted);
  pointer-events: none;
  transform-origin: left top;
  transition: transform var(--transition-fast), color var(--transition-fast);
}

.lead-form .field-input:focus + .field-label,
.lead-form .field-input:not(:placeholder-shown) + .field-label,
.lead-form .field-input:-webkit-autofill + .field-label {
  transform: translateY(-10px) scale(0.75);
  color: var(--color-ink-soft);
}

.lead-form .field-optional {
  color: var(--color-ink-muted);
}

/* Home form: phone next to ZIP — give the phone the room, a ZIP is only 5 digits */
.lead-form .field-row {
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
}

/* Small phones: a full "(555) 123-4567" no longer fits next to the ZIP */
@media (max-width: 380px) {
  .lead-form .field-row {
    grid-template-columns: 1fr;
  }
}

/* ---------- Valid / invalid ---------- */
.lead-form .field-input.is-valid:not(:focus) {
  border-color: transparent !important;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231a8a3c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  background-size: 14px;
}

.lead-form .field-input.is-valid:focus {
  border-color: var(--color-ink) !important;
}

/* Red border plus an alert badge inside the field, mirroring the green check */
.lead-form .field-input.is-invalid {
  padding-right: 42px;
  background-color: #FFF7F8;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='11' fill='%23E8122E'/%3E%3Cpath d='M12 6.8v6.4' stroke='white' stroke-width='2.6' stroke-linecap='round'/%3E%3Ccircle cx='12' cy='17.2' r='1.45' fill='white'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
  box-shadow: none;
}

.lead-form .field-input.is-invalid:focus {
  background-color: var(--color-white);
  box-shadow: 0 0 0 4px rgba(232, 18, 46, 0.12);
}

.lead-form .field-input.is-invalid + .field-label {
  color: var(--color-red);
}

/* ---------- Inline field errors ----------
   Always laid out so they can slide open and closed: the single grid row
   grows from 0fr to 1fr and the fields below move smoothly instead of jumping. */
.lead-form .field-error {
  display: grid;
  grid-template-rows: 0fr;
  margin-top: 0;
  padding: 0 4px 0 17.5px; /* text lines up with the label */
  opacity: 0;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.005em;
  color: var(--color-red-dark);
  animation: none;
  transition:
    grid-template-rows 240ms var(--ease-smooth),
    margin-top 240ms var(--ease-smooth),
    opacity 180ms var(--ease-smooth);
}

.lead-form .field-error.is-visible {
  grid-template-rows: 1fr;
  margin-top: 7px;
  opacity: 1;
}

.lead-form .field-error-text {
  min-height: 0;
  overflow: hidden;
}

.lead-form .field.is-shaking {
  animation: lead-form-shake 380ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes lead-form-shake {
  20% { transform: translateX(-5px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(1px); }
}

/* ---------- Showroom select: same box as the inputs ---------- */
.lead-form .showroom-select-wrap {
  height: 56px;
  background: var(--color-bg-alt);
  border: 1.5px solid transparent;
}

.lead-form .showroom-select-wrap:hover {
  border-color: var(--color-line);
}

.lead-form .showroom-select-wrap:focus-within {
  background: var(--color-white);
  border-color: var(--color-ink);
  box-shadow: 0 0 0 4px rgba(10, 10, 10, 0.06);
}

.lead-form .showroom-select-wrap:focus-within .field-select-chevron {
  color: var(--color-ink);
}

.lead-form .field-select,
.lead-form .field-select:hover,
.lead-form .field-select:focus {
  height: 100%;
  padding: 0 44px;
  font-size: 16px !important;
  background: transparent;
  border: none;
  box-shadow: none;
}

/* Placeholder option still selected */
.lead-form .field-select:has(option[value=""]:checked) {
  color: var(--color-ink-muted);
}

/* ---------- Submit ---------- */
.lead-form .form-submit {
  width: 100%;
  height: 54px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
}

.lead-form .form-submit:focus-visible {
  outline: 3px solid rgba(232, 18, 46, 0.35);
  outline-offset: 2px;
}

.lead-form .form-submit:disabled {
  cursor: progress;
  opacity: 0.85;
  transform: none;
  box-shadow: none;
}

.lead-form .form-submit-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: var(--color-white);
  border-radius: 50%;
  animation: lead-form-spin 700ms linear infinite;
}

.lead-form.is-sending .form-submit-spinner {
  display: inline-block;
}

.lead-form.is-sending .btn-arrow {
  display: none;
}

@keyframes lead-form-spin {
  to { transform: rotate(360deg); }
}

/* ---------- Form-level status (server / network errors) ---------- */
.lead-form .form-status {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: var(--space-3);
  padding: 14px 44px 14px 14px;
  text-align: left;
  background: linear-gradient(180deg, #FFF8F9 0%, #FFF2F4 100%);
  border: 1px solid rgba(232, 18, 46, 0.16);
  border-radius: 12px;
  box-shadow: 0 12px 28px -18px rgba(197, 14, 38, 0.45);
  animation: lead-form-status-in 280ms var(--ease-smooth) both;
}

.lead-form .form-status[hidden] {
  display: none;
}

.lead-form .form-status-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--color-red);
  color: var(--color-white);
  box-shadow: 0 0 0 4px rgba(232, 18, 46, 0.12);
}

.lead-form .form-status-icon svg {
  width: 16px;
  height: 16px;
}

.lead-form .form-status-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding-top: 1px;
}

.lead-form .form-status-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--color-ink);
}

.lead-form .form-status-text {
  font-size: 13px;
  line-height: 1.45;
  color: var(--color-ink-soft);
}

.lead-form .form-status-close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--color-ink-muted);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.lead-form .form-status-close:hover {
  background: rgba(232, 18, 46, 0.08);
  color: var(--color-red-dark);
}

.lead-form .form-status-close:focus-visible {
  outline: 2px solid rgba(232, 18, 46, 0.45);
  outline-offset: 1px;
}

.lead-form .form-status-close svg {
  width: 16px;
  height: 16px;
}

@keyframes lead-form-status-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* ---------- Fine print ---------- */
.lead-form .form-fine--legal {
  margin-top: 4px;
  font-size: 10.5px;
  color: #A3A39E;
}

.lead-form .form-fine--legal a {
  color: inherit;
  text-decoration-color: currentColor;
}

@media (prefers-reduced-motion: reduce) {
  .lead-form .field-input,
  .lead-form .field-label,
  .lead-form .field-error,
  .lead-form .field.is-shaking,
  .lead-form .form-status {
    transition: none;
    animation: none;
  }
}
