/* Wizard overlay — Typeform-style one-question-per-screen view.
   Activated by adding `wizard-mode` to the <body>. */

body.wizard-mode {
  --wiz-bg: #FEFEFE;
  --wiz-ink: #121212;
  --wiz-soft: #404040;
  --wiz-mute: #6B6B6B;
  --wiz-green: #9EC43D;
  --wiz-green-hover: #8AB031;
  --wiz-line: rgba(18,18,18,0.08);
  overflow-x: hidden;
}

/* Hide the standard step header & three-step progress bar */
body.wizard-mode .progress { display: none !important; }
body.wizard-mode .step-intro { display: none !important; }
body.wizard-mode section.step .step-footer { display: none !important; }
body.wizard-mode section.step { display: contents !important; }
body.wizard-mode section.step.active,
body.wizard-mode section.step:not(.active) { all: unset; }
body.wizard-mode section.step { all: unset; display: contents !important; }
body.wizard-mode .flow[hidden] { display: none !important; }
body.wizard-mode .flow:not([hidden]) { display: contents !important; }
/* .reveal keeps its native max-height/opacity transition — show/hide is driven
   by the existing form's handleConditionalReveals(). */
body.wizard-mode .savings-panel { display: none !important; }
body.wizard-mode .note { display: none !important; }
body.wizard-mode .trust-line { display: none !important; }

/* Wizard chrome — sticky thin progress bar at the top */
.wiz-bar {
  position: sticky;
  top: 0; left: 0; right: 0;
  z-index: 90;
  height: 6px;
  background: rgba(18,18,18,0.06);
  overflow: hidden;
}
.wiz-bar-fill {
  height: 100%;
  background: var(--wiz-green);
  width: 0%;
  transition: width 0.35s cubic-bezier(0.16,1,0.3,1);
}
.wiz-progress-label {
  position: absolute;
  top: 10px; right: 16px;
  font-size: 11.5px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--wiz-mute);
}

/* Question card — fills available column height, one at a time. The active .q
   is a flex column whose children may shrink. This is critical for the roof
   preview, which gets a max-height so the Yes/No tiles below it stay above the fold. */
body.wizard-mode .q { display: none; }
body.wizard-mode .q.is-active {
  display: flex; flex-direction: column;
  position: relative;
  max-width: 640px;
  margin: 0 auto;
  padding: 4px 0 12px;
  flex: 1 1 auto;
  min-height: 0;
  justify-content: center;
  gap: 10px;
  animation: wiz-slide-in 0.4s cubic-bezier(0.16,1,0.3,1);
}

/* Roof preview — let it shrink within the available column height. Cap so the
   tiles + footer always stay visible without scrolling. */
body.wizard-mode .roof-preview {
  flex: 1 1 auto;
  min-height: 180px;
  max-height: 42vh;
  aspect-ratio: auto;
  margin-top: 4px;
}

/* Tighter stacked-tile groups so 5-option questions fit one viewport */
body.wizard-mode .q.is-active .tile-group.stacked .tile { min-height: 48px; padding: 12px 18px; font-size: 15.5px; }
body.wizard-mode .q.is-active .tile { min-height: 56px; padding: 14px 18px; font-size: 16px; }
body.wizard-mode .q.is-active .tile-icon { transform: scale(1); }
@keyframes wiz-slide-in {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
body.wizard-mode .q.is-leaving {
  display: flex; flex-direction: column;
  position: absolute; inset: 0;
  animation: wiz-slide-out 0.25s cubic-bezier(0.16,1,0.3,1) forwards;
  pointer-events: none;
}
@keyframes wiz-slide-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-20px); }
}

/* Companion .q — rendered inline below the main question (e.g. T&Cs under phone) */
body.wizard-mode .q.is-companion {
  flex: 0 0 auto;
  justify-content: flex-start;
  padding-top: 4px;
  animation: none;
}
body.wizard-mode .q.is-active.is-companion .q-label,
body.wizard-mode .q.is-active.is-companion .field-label {
  font-size: 14px !important;
  font-weight: 600;
  color: var(--wiz-mute);
  text-transform: none;
  letter-spacing: 0;
}

/* Question label / field label become the BIG headline of the card */
body.wizard-mode .q.is-active .q-label,
body.wizard-mode .q.is-active .field-label:not(.tc-text) {
  font-family: 'Avenir Next','Avenir',system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
  font-weight: 500;
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.12;
  letter-spacing: -0.012em;
  color: var(--wiz-ink);
  margin-bottom: 4px;
  text-transform: none;
  flex-shrink: 0;
}
body.wizard-mode .q.is-active .q-label .req,
body.wizard-mode .q.is-active .field-label .req {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--wiz-mute);
  margin-top: 6px;
  letter-spacing: 0;
}
body.wizard-mode .q.is-active .field-help {
  font-size: 14px;
  color: var(--wiz-mute);
  margin-top: -4px;
}

/* Tile groups inside an active wizard question — full width, big touch targets */
body.wizard-mode .q.is-active .tile-group,
body.wizard-mode .q.is-active .tile-plus-row {
  width: 100%;
}
body.wizard-mode .q.is-active .tile {
  min-height: 64px;
  font-size: 17px;
  padding: 18px 22px;
}
body.wizard-mode .q.is-active .tile-icon { transform: scale(1.1); }

/* Inputs/selects inside active question — large */
body.wizard-mode .q.is-active .field-input,
body.wizard-mode .q.is-active .field-select {
  font-size: 22px;
  padding: 18px 18px;
  border-radius: 14px;
  border: 1.5px solid rgba(18,18,18,0.12);
  background: var(--wiz-bg);
}
body.wizard-mode .q.is-active .field-input:focus,
body.wizard-mode .q.is-active .field-select:focus {
  outline: none;
  border-color: var(--wiz-green);
  box-shadow: 0 0 0 4px rgba(158,196,61,0.18);
}
body.wizard-mode .q.is-active .field-grid {
  display: grid; gap: 12px;
}
body.wizard-mode .q.is-active .field-grid.three {
  grid-template-columns: 1.4fr 0.8fr 1fr;
}
@media (max-width: 600px) {
  body.wizard-mode .q.is-active .field-grid.three { grid-template-columns: 1fr; }
}

/* T&Cs */
body.wizard-mode .q.is-active .tc-row { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; padding: 14px; border: 1.5px solid var(--wiz-line); border-radius: 14px; }
body.wizard-mode .q.is-active .tc-row .tc-text { font-size: 15px; line-height: 1.5; color: var(--wiz-soft); font-weight: 500; }
body.wizard-mode .q.is-active .tc-checkbox { width: 22px; height: 22px; }

/* Bill upload */
body.wizard-mode .q.is-active .bill-upload {
  min-height: 180px;
}

/* Wizard footer — pinned to the bottom of the card, inside the left column */
.wiz-footer {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px clamp(28px, 5vw, 72px);
  background: var(--wiz-bg);
  border-top: 1px solid rgba(18,18,18,0.06);
  z-index: 80;
}
body.wizard-mode .form-split > .card { position: relative; padding-bottom: 76px; }
.wiz-back, .wiz-skip {
  background: transparent;
  border: 0;
  color: var(--wiz-mute);
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  padding: 10px 14px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s, background 0.15s;
}
.wiz-back:hover, .wiz-skip:hover { color: var(--wiz-ink); background: rgba(18,18,18,0.05); }
.wiz-back svg { width: 14px; height: 14px; }
.wiz-back[hidden] { visibility: hidden; }

.wiz-next {
  background: var(--wiz-green);
  color: var(--wiz-ink);
  border: 0;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
  padding: 14px 28px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 0 rgba(18,18,18,0.12);
  transition: background 0.2s, transform 0.2s;
}
.wiz-next:hover { background: var(--wiz-green-hover); transform: translateY(-1px); box-shadow: 0 4px 0 rgba(18,18,18,0.12); }
.wiz-next:disabled { background: rgba(158,196,61,0.45); cursor: not-allowed; box-shadow: none; transform: none; }
.wiz-next svg { width: 14px; height: 14px; }
.wiz-next-hint {
  font-size: 11.5px;
  color: var(--wiz-mute);
  letter-spacing: 0.06em;
  margin-left: 10px;
}

@media (max-width: 880px) {
  /* On mobile/tablet the split collapses to one column. Let the page scroll
     normally on small screens so the user always has access to the keyboard
     + form footer. The "no scroll" constraint is desktop-first. */
  body.wizard-mode .form-split { height: auto; max-height: none; overflow: visible; }
  body.wizard-mode .form-split > .card { height: auto; max-height: none; overflow: visible; padding-bottom: 100px; }
  body.wizard-mode .q.is-active { padding: 16px 0 24px; flex: none; min-height: 50vh; justify-content: flex-start; }
  .wiz-footer { padding: 14px 18px; }
  .wiz-next { padding: 13px 22px; font-size: 15px; }
  .wiz-next-hint { display: none; }
}

/* Hide everything below the wizard chrome */
body.wizard-mode .form-card-foot,
body.wizard-mode .savings-panel { display: none !important; }
