/* =========================================================
   Lead form (inline on home + contact, in the consultation modal, and the callback popup).
   Loaded sitewide from header.php; uses the design tokens from base.css.
   ========================================================= */

.lead-form { max-width: 820px; }
.lead-form__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}
.lead-form__field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; margin: 0; padding: 0; border: 0; }
.lead-form__field--wide { grid-column: 1 / -1; }
.lead-form__field label,
.lead-form__field legend {
  padding: 0;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--brand-ink);
}
.lead-form__field legend { margin-bottom: 0.35rem; }
.lead-form__optional { font-weight: 400; color: var(--text-secondary); }
.lead-form input[type="text"],
.lead-form input[type="tel"],
.lead-form select,
.lead-form textarea {
  width: 100%;
  min-height: 48px;
  padding: 0.6rem 0.85rem;
  font: inherit;
  font-size: var(--fs-base);
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.lead-form textarea { min-height: 88px; resize: vertical; line-height: 1.7; }
.lead-form ::placeholder { color: #9AA2AA; }
.lead-form input[dir="ltr"] { text-align: left; }
.lead-form input:focus,
.lead-form select:focus,
.lead-form textarea:focus { outline: none; border-color: var(--brand-gold-dark); box-shadow: 0 0 0 3px rgba(210, 171, 94, 0.25); }
.lead-form [aria-invalid="true"] { border-color: #B3261E; }
.lead-form__error { font-size: 0.8125rem; color: #B3261E; }

/* Project type: one-tap chips (native radios underneath). */
.lead-form__chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.lead-chip { position: relative; display: block; flex: 1 1 auto; cursor: pointer; }
.lead-chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.lead-chip span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-1);
  white-space: nowrap;
  color: var(--brand-ink);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-align: center;
  line-height: 1.5;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.lead-chip:hover span { border-color: var(--brand-gold-dark); }
.lead-chip input:checked + span { border-color: var(--brand-gold-dark); background: rgba(210, 171, 94, 0.16); box-shadow: inset 0 0 0 1px var(--brand-gold-dark); }
.lead-chip input:focus-visible + span { box-shadow: 0 0 0 3px rgba(210, 171, 94, 0.35); }
.lead-form__choices[aria-invalid="true"] .lead-chip span { border-color: #B3261E; }

.lead-form__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin-top: var(--space-3); }
.lead-form__submit { min-height: 50px; min-width: 220px; justify-content: center; cursor: pointer; border: 0; border-radius: 10px; font: inherit; font-weight: 700; }
.lead-form__submit:disabled { opacity: 0.7; cursor: wait; }
.lead-form .lead-form__privacy { margin: 0; color: var(--text-secondary); font-size: 0.8125rem; }
.lead-form__status { margin: var(--space-2) 0 0; font-weight: 600; min-height: 1.5em; }
.lead-form__status:empty { display: none; }
.lead-form__status.is-success { color: #1E6B3A; }
.lead-form__status.is-error { color: #B3261E; }

/* Honeypot — hidden from people, visible to naive bots. */
.lead-form__hp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Inline form on wide screens: name / phone / city share the first row. */
@media (min-width: 1000px) {
  .lead-form--full .lead-form__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.lead-form-section .lead-form,
.cta-band--form .lead-form {
  padding: clamp(1.25rem, 3vw, 2rem);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 14px 40px rgba(7, 20, 26, 0.08);
}

/* Home page: dark band with intro on one side, white form card on the other. */
.cta-band--form { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: clamp(1.5rem, 4vw, 3rem); align-items: center; }
.cta-band--form .lead-form { max-width: none; color: var(--text-primary); }
.cta-band__points { display: grid; gap: 0.6rem; margin: 1.25rem 0 0; }
.cta-band__points li { position: relative; padding-inline-start: 1.6rem; color: var(--text-on-dark); }
.cta-band__points li::before {
  content: "";
  position: absolute;
  top: 0.45em;
  inset-inline-start: 0;
  width: 0.95rem;
  height: 0.55rem;
  border-inline-start: 2px solid var(--brand-gold);
  border-bottom: 2px solid var(--brand-gold);
  transform: rotate(-45deg) scaleX(-1);
}

/* =========================================================
   Dialogs: consultation modal + callback popup (native <dialog>)
   ========================================================= */
html.dialog-open { overflow: hidden; }
.lead-dialog {
  width: min(560px, calc(100vw - 2rem));
  max-width: none;
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--text-primary);
  overflow: visible;
}
.lead-dialog--popup { width: min(440px, calc(100vw - 2rem)); }
.lead-dialog::backdrop { background: rgba(7, 20, 26, 0.45); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.lead-dialog__panel {
  position: relative;
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(1.5rem, 4vw, 2.25rem);
  border-radius: 18px;
  background: var(--surface-1);
  box-shadow: 0 30px 80px rgba(7, 20, 26, 0.28);
}
.lead-dialog[open] .lead-dialog__panel { animation: lead-dialog-in 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
.lead-dialog[open]::backdrop { animation: lead-fade-in 0.28s ease; }
@keyframes lead-dialog-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes lead-fade-in { from { opacity: 0; } to { opacity: 1; } }

.lead-dialog__close {
  position: absolute;
  top: 0.75rem;
  inset-inline-end: 0.75rem;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--brand-ink);
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.lead-dialog__close:hover { background: var(--border); }
.lead-dialog__close:focus-visible { outline: 2px solid var(--brand-gold-dark); outline-offset: 2px; }
.lead-dialog__head { padding-inline-end: 3rem; margin-bottom: 1.25rem; }
.lead-dialog__head h2 { margin: 0.25rem 0 0.5rem; font-size: var(--fs-lg); line-height: 1.5; }
.lead-dialog__head p { margin: 0; color: var(--text-secondary); font-size: var(--fs-sm); line-height: 1.9; }
.lead-dialog__icon {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 0.5rem;
  border-radius: 16px;
  background: rgba(210, 171, 94, 0.16);
  color: var(--brand-gold-dark);
}
.lead-dialog .lead-form { max-width: none; }
.lead-dialog .lead-form__actions { margin-top: 1.25rem; }
.lead-dialog .lead-form__submit { flex: 1 1 100%; width: 100%; }
.lead-dialog .lead-form__privacy { flex-basis: 100%; text-align: center; }
.lead-dialog--popup .lead-form__grid { grid-template-columns: 1fr; gap: 0.85rem; }
.lead-form--modal .lead-form__field--city { grid-column: 1 / -1; }
.lead-dialog__dismiss {
  display: block;
  margin: 0.75rem auto 0;
  padding: 0.6rem 1rem;
  border: 0;
  background: none;
  color: var(--text-secondary);
  font: inherit;
  font-size: var(--fs-sm);
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}
.lead-dialog__dismiss:hover { color: var(--brand-ink); }

/* Success state replaces the form inside a dialog. */
.lead-dialog.is-done .lead-dialog__head,
.lead-dialog.is-done .lead-form,
.lead-dialog.is-done .lead-dialog__dismiss { display: none; }
.lead-dialog__success { padding: 1rem 0 0.25rem; text-align: center; }
.lead-dialog__success .lead-dialog__success-text { margin: 0.9rem auto 1.4rem; max-width: 30ch; color: var(--petrol-800); font-size: var(--fs-md); font-weight: 700; line-height: 1.9; }
.lead-dialog__check {
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(30, 107, 58, 0.1);
  color: #1E6B3A;
}

@media (max-width: 900px) {
  .cta-band--form { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .lead-form__grid { grid-template-columns: 1fr; }
  .lead-form__chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cta-band--form { padding: 1.5rem 1rem 1rem; }
  .cta-band--form .lead-form, .lead-form-section .lead-form { padding: 1.25rem 1rem; }
  .lead-chip span { white-space: normal; }
  .lead-form__submit { width: 100%; }
  .lead-form__privacy { flex-basis: 100%; text-align: center; }
  /* Modal becomes a bottom sheet on phones: easy to reach, easy to dismiss. */
  .lead-dialog:not(.lead-dialog--popup) {
    width: 100vw;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: 20px 20px 0 0;
  }
  .lead-dialog:not(.lead-dialog--popup) .lead-dialog__panel { max-height: 92dvh; border-radius: 20px 20px 0 0; padding-bottom: calc(1.5rem + env(safe-area-inset-bottom)); }
  .lead-dialog:not(.lead-dialog--popup)[open] .lead-dialog__panel { animation-name: lead-sheet-in; }
  /* Consultation modal on phones: the eyebrow / heading / intro are taken out of the layout
     (visually hidden, still announced by screen readers via aria-labelledby) so the whole form,
     from the close button to the privacy line, fits one screen without scrolling. */
  #lead-modal .lead-dialog__head {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
  /* Compact spacing so the remaining form fits a 375×667 screen: same fields, tighter rhythm. */
  #lead-modal,
  #lead-modal .lead-dialog__panel { max-height: calc(100dvh - 12px); }
  #lead-modal .lead-dialog__panel { padding: 1.6rem 1rem calc(0.85rem + env(safe-area-inset-bottom)); }
  #lead-modal .lead-dialog__close { width: 40px; height: 40px; }   /* same spot, clears the first field */
  #lead-modal .lead-form__grid { gap: 0.5rem; }
  #lead-modal .lead-form__field { gap: 0.25rem; }
  #lead-modal .lead-form input[type="text"],
  #lead-modal .lead-form input[type="tel"] { min-height: 44px; padding-block: 0.45rem; }
  #lead-modal .lead-form textarea { min-height: 56px; }
  #lead-modal .lead-form__field legend { margin-bottom: 0.25rem; }
  #lead-modal .lead-chip span { min-height: 40px; }
  #lead-modal .lead-form__actions { margin-top: 0.85rem; gap: 0.35rem; }
  #lead-modal .lead-form__submit { min-height: 48px; }
  @keyframes lead-sheet-in { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
}

@media (prefers-reduced-motion: reduce) {
  .lead-dialog[open] .lead-dialog__panel, .lead-dialog[open]::backdrop { animation: none; }
}
