/* ==========================================================================
   "Book a free scan" popup with the multi-step form
   ========================================================================== */

/* ---------- Dialog shell ---------- */
html:has(.scan-dialog[open]) { overflow: hidden; }

.scan-dialog {
  width: min(680px, calc(100% - 32px));
  max-height: calc(100dvh - 48px);
  margin: auto;
  padding: 40px;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(20, 20, 19, 0.25);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.scan-dialog[open] { display: flex; flex-direction: column; gap: 28px; animation: dialog-in .35s cubic-bezier(.2,.8,.2,1); }
.scan-dialog::backdrop { background: rgba(20, 20, 19, 0.55); backdrop-filter: blur(3px); animation: backdrop-in .25s ease; }
.scan-dialog.is-closing { animation: dialog-out .2s ease forwards; }
.scan-dialog.is-closing::backdrop { animation: backdrop-out .2s ease forwards; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(24px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes dialog-out { to { opacity: 0; transform: translateY(16px) scale(.98); } }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes backdrop-out { to { opacity: 0; } }

.scan-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 44px; height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background-color .15s ease;
}
.scan-close:hover { background: var(--paper); }

.scan-intro { display: flex; flex-direction: column; gap: 10px; padding-right: 48px; }
.scan-heading { font-size: clamp(28px, 4vw, 36px); line-height: 1.08; font-weight: 700; letter-spacing: -0.025em; }
.scan-intro p { color: var(--ink-muted); font-size: 16px; }

/* ---------- Stepper ---------- */
.stepper { display: flex; flex-direction: column; gap: 24px; }

.stepper-head { display: flex; flex-direction: column; gap: 10px; }
.stepper-count { font-family: var(--font-mono); font-size: 12px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted); }
.stepper-progress { height: 6px; border-radius: var(--radius-pill); background: var(--block); overflow: hidden; }
.stepper-bar { display: block; height: 100%; width: 25%; background: var(--ink); border-radius: inherit; transition: width .45s cubic-bezier(.2,.8,.2,1); }

.step { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.step[hidden] { display: none; }
.step:not([hidden]) { animation: step-in .4s cubic-bezier(.2,.8,.2,1); }
.step.is-back:not([hidden]) { animation-name: step-in-back; }
@keyframes step-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes step-in-back { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }

.step-title { padding: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.step-title:focus { outline: none; }
legend.step-title { margin-bottom: 16px; } /* a legend sits outside the fieldset's flex gap */
.step-hint { margin-top: -10px; color: var(--ink-muted); font-size: 15px; }
.step-subtitle { margin-top: 8px; font-size: 17px; font-weight: 700; }
.step-error { font-size: 14px; font-weight: 600; color: var(--danger); }
.step-error:empty { display: none; }

/* Real inputs, visually hidden; the label is the visible control */
.choice input, .pill input, .date-card input, .slot input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.choice {
  position: relative;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}
.choice:hover { border-color: var(--ink-muted); }
.choice:active { transform: scale(.98); }
.choice-icon {
  flex: none;
  width: 34px; height: 34px;
  border-radius: var(--radius-pill);
  background: var(--paper);
  display: flex; align-items: center; justify-content: center;
  transition: background-color .15s ease;
}
.choice:has(input:checked) { border-color: var(--ink); background: var(--choice-bg); }
.choice:has(input:checked) .choice-icon { background: var(--accent-tint); }
.choice:has(input:checked)::after {
  content: "";
  position: absolute;
  top: 8px; right: 8px;
  width: 16px; height: 16px;
  border-radius: var(--radius-pill);
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23F2B807' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 10px no-repeat;
}

.pill-group { display: flex; flex-wrap: wrap; gap: 10px; }
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}
.pill:hover { border-color: var(--ink-muted); }
.pill:has(input:checked) { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ---------- Availability (step 3) ---------- */
.step-subtitle + .date-grid, .step-subtitle + .slot-grid { margin-top: -6px; }
.date-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.date-card {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  user-select: none;
  transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}
.date-card:hover { border-color: var(--ink-muted); }
.date-dow, .date-month { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted); }
.date-day { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.date-card:has(input:checked) { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.date-card:has(input:checked) .date-dow, .date-card:has(input:checked) .date-month { color: var(--accent-light); }

.slot-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.slot {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  user-select: none;
  transition: border-color .15s ease, background-color .15s ease;
}
.slot:hover { border-color: var(--ink-muted); }
.slot-name { font-size: 15px; font-weight: 700; }
.slot-time { font-size: 13px; color: var(--ink-muted); }
.slot:has(input:checked) { border-color: var(--ink); background: var(--accent-tint); }
.slot:has(input:checked) .slot-time { color: var(--ink); }

.flexible { display: inline-flex; align-items: center; gap: 10px; align-self: flex-start; min-height: 44px; font-size: 15px; font-weight: 600; cursor: pointer; }
.flexible input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); cursor: pointer; }

/* "I'm flexible" greys out the specific choices */
.step.is-flexible .date-grid, .step.is-flexible .slot-grid { opacity: .4; pointer-events: none; }
.step.is-flexible .step-subtitle { opacity: .4; }

.choice:has(input:focus-visible), .pill:has(input:focus-visible),
.date-card:has(input:focus-visible), .slot:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 3px; }

.estimate {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--accent-tint);
  font-size: 15px;
  line-height: 1.45;
  animation: step-in .35s cubic-bezier(.2,.8,.2,1);
}

.stepper-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stepper-nav .btn { margin-left: auto; }
.btn-back, .btn-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 6px;
  border: none;
  background: none;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
}
.btn-back:hover, .btn-link:hover { color: var(--ink); }
.btn-back[hidden] { display: none; }
.btn-link { text-decoration: underline; text-underline-offset: 4px; }

.reassure {
  list-style: none;
  margin: 0;
  padding: 18px 0 0;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: 14px;
  color: var(--ink-muted);
}
.reassure li { display: flex; align-items: center; gap: 6px; }
.reassure svg { flex: none; }
.stepper .form-note { margin-top: -12px; }
.form-note a { color: var(--link); }

/* ---------- Done ---------- */
.stepper.is-done .stepper-nav,
.stepper.is-done .stepper-head,
.stepper.is-done .reassure,
.stepper.is-done .form-note { display: none; }
.step-done { align-items: flex-start; }
.done-check {
  width: 56px; height: 56px;
  border-radius: var(--radius-pill);
  background: var(--accent-tint);
  display: flex; align-items: center; justify-content: center;
  animation: pop .5s cubic-bezier(.2,1.4,.4,1);
}
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.done-summary { margin: 0; width: 100%; display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.done-summary div { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.done-summary dt { width: 120px; font-size: 14px; color: var(--ink-muted); }
.done-summary dd { margin: 0; flex: 1 1 200px; font-size: 15px; font-weight: 600; }
.done-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }

/* ---------- Phone: full-height sheet ---------- */
@media (max-width: 600px) {
  .scan-dialog {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    padding: 24px 16px 28px;
    border-radius: 0;
  }
  .scan-dialog[open] { gap: 22px; }
  .scan-close { top: 12px; right: 12px; }
  .step-title { font-size: 22px; }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .choice { min-height: 52px; padding: 8px; gap: 7px; font-size: 14px; overflow-wrap: break-word; }
  .choice-icon { width: 26px; height: 26px; }
  .choice-icon svg { width: 16px; height: 16px; }
  .pill { padding: 0 16px; }
  .date-grid { gap: 6px; }
  .date-card { padding: 8px 2px; border-radius: 12px; }
  .date-day { font-size: 19px; }
  .date-dow, .date-month { font-size: 10px; letter-spacing: 0.03em; }
  .slot-grid { grid-template-columns: 1fr; }
  .slot { flex-direction: row; justify-content: space-between; align-items: center; min-height: 48px; padding: 8px 14px; }
  .reassure { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  .scan-dialog[open], .scan-dialog::backdrop, .scan-dialog.is-closing,
  .step:not([hidden]), .estimate, .done-check { animation: none; }
  .stepper-bar { transition: none; }
}
