/**
 * The lead form (design/sections/leadform.section.json).
 *
 * Sizing here is not taste — it is lifted from what the two market leaders get
 * wrong. Convini's inputs are 14px, so iOS Safari zooms the viewport on every
 * focus and never zooms back; its radio targets are 20×20 against a 44px
 * minimum, seven of them in a row. Both are fixed below and must stay fixed.
 *
 * The three questions are radios styled as chips: one tap each, no keyboard, no
 * dropdown. They are the cheapest possible first commitment, which is the whole
 * conversion argument — both competitors open with eight typed questions instead.
 */

.dw-band--lead {
  padding-block: var(--dw-section-y);
}

.jm-lead {
  margin-top: 1.5rem;
  display: grid;
  gap: 1.5rem;
  max-width: 44rem;
}

/* ── the three tap questions ──────────────────────────────────────── */

.jm-lead__step {
  margin: 0;
  padding: 0;
  border: 0;
}

.jm-lead__legend {
  padding: 0;
  margin-bottom: 0.6rem;
  font-family: var(--dw-display);
  font-weight: 600;
  color: var(--dw-ink);
}

.jm-lead__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* The radio stays in the accessibility tree and keeps keyboard behaviour; only
   its rendering is replaced. clip-path rather than display:none, which would
   remove it from tab order entirely. */
.jm-lead__radio {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.jm-lead__chip {
  display: inline-flex;
  align-items: center;
  /* 44px minimum touch target. */
  min-height: 44px;
  padding: 0 1.05rem;
  border: 1px solid var(--dw-line);
  border-radius: 999px;
  background: var(--wp--preset--color--surface);
  color: var(--dw-ink);
  font-size: 1rem;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color 160ms var(--dw-ease), background-color 160ms var(--dw-ease);
}

@media (hover: hover) {
  .jm-lead__chip:hover {
    border-color: var(--wp--preset--color--primary);
  }
}

.jm-lead__radio:checked + .jm-lead__chip {
  background: var(--wp--preset--color--primary);
  border-color: var(--wp--preset--color--primary);
  color: var(--wp--preset--color--surface);
  font-weight: 600;
}

/* Focus must be visible on the chip, since the input itself is not rendered. */
.jm-lead__radio:focus-visible + .jm-lead__chip {
  outline: 2px solid var(--wp--preset--color--accent);
  outline-offset: 2px;
}

/* ── contact fields ───────────────────────────────────────────────── */

.jm-lead__fields {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 40rem) {
  .jm-lead__fields {
    grid-template-columns: 1fr 1fr;
  }

  .jm-lead__field--wide {
    grid-column: 1 / -1;
  }
}

.jm-lead__field {
  display: grid;
  gap: 0.35rem;
}

.jm-lead__label {
  font-size: 0.875rem;
  color: var(--dw-dis);
}

.jm-lead__req {
  color: var(--wp--preset--color--accent);
  text-decoration: none;
  border: 0;
}

.jm-lead__field input,
.jm-lead__field textarea {
  width: 100%;
  /* Without this, width:100% adds 27px of padding and 2px of border on top of the
     container width and pushes the page sideways by exactly that much on a 390px
     screen. The theme does not set a global border-box. */
  box-sizing: border-box;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--dw-line);
  border-radius: var(--dw-r-sm);
  background: var(--wp--preset--color--surface);
  color: var(--dw-ink);
  font-family: var(--dw-body);
  /* 16px exactly. Anything smaller triggers the iOS focus-zoom trap. */
  font-size: 1rem;
  min-height: 44px;
}

.jm-lead__field textarea {
  resize: vertical;
  line-height: 1.5;
}

.jm-lead__field input:focus-visible,
.jm-lead__field textarea:focus-visible {
  outline: 2px solid var(--wp--preset--color--primary);
  outline-offset: 1px;
  border-color: var(--wp--preset--color--primary);
}

/* The honeypot. Off-canvas rather than display:none, because some bots skip
   fields that are not rendered. Never give a real input this name. */
/* Clipped rather than pushed to left:-9999px. Off-canvas positioning can widen
   the scrollable area in some layouts; clip cannot. Still rendered, so bots that
   skip display:none fields still fill it. */
.jm-lead__hp {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ── submit ───────────────────────────────────────────────────────── */

.jm-lead__foot {
  display: grid;
  gap: 0.75rem;
  align-items: center;
}

@media (min-width: 40rem) {
  .jm-lead__foot {
    grid-template-columns: auto 1fr;
  }
}

.jm-lead__submit {
  min-height: 52px;
  padding: 0 1.75rem;
  border: 0;
  border-radius: 999px;
  background: var(--wp--preset--color--accent);
  color: var(--wp--preset--color--surface);
  font-family: var(--dw-display);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  /* Full width on phones — Convini leaves its submit 128px wide and
     left-aligned at the bottom of a 14,000px page. */
  width: 100%;
}

@media (min-width: 40rem) {
  .jm-lead__submit {
    width: auto;
  }
}

.jm-lead__submit:focus-visible {
  outline: 2px solid var(--dw-ink);
  outline-offset: 2px;
}

.jm-lead__submit[disabled] {
  opacity: 0.6;
  cursor: progress;
}

.jm-lead__status {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--dw-dis);
}

/* A completed form states its outcome in the trust colour, not in the accent —
   the accent means "act", and there is nothing left to act on. */
.jm-lead[data-done="1"] .jm-lead__status {
  color: var(--wp--preset--color--primary);
  font-weight: 600;
}

/* ── disclosure ───────────────────────────────────────────────────── */

/* Sits below the button but is never small print: the brand rules require the
   commercial model to be legible before someone commits, and saying what happens
   next ("leverantören hör av sig inom 24–48 timmar") also lifts completion. */
.jm-lead__disclosure {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--dw-dis);
  padding-top: 1rem;
  border-top: 1px solid var(--dw-line);
}

/* A leadform used for something other than a quote request has no qualifying
   questions — see /integritetspolicy/, where the three option lists are empty.
   The section template still emits each fieldset and its legend, so without
   this the page would show three empty, labelled lead-qualification steps.
   Hiding the fieldset when it contains no chip keeps that decision in the
   content file rather than forking the template. */
.jm-lead__step:not(:has(.jm-lead__chip)) {
  display: none !important;
}
