/* X3RED — квиз «Проверка воронки» (Funnel fit check). Токены и базовые компоненты (.btn, .field, .input, .steps) — из styles.css.
   Движение по правилам дизайн-системы: слева направо, без подпрыгиваний; при prefers-reduced-motion анимаций нет. */

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---------- Окно на весь экран ---------- */
.qz { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--page); color: var(--text); overflow: hidden; }
.qz[open] { display: flex; flex-direction: column; }
.qz::backdrop { background: var(--page); }
.qz__top { flex: none; background: var(--page); border-bottom: 1px solid var(--stroke-hairline); }
.qz__bar { max-width: 1040px; height: 64px; margin: 0 auto; padding: 0 12px; display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; }
.qz__back { grid-column: 1; }
.qz__logo { grid-column: 2; justify-self: center; display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-display); font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.qz__close { grid-column: 3; }
.qz__icon { width: 44px; height: 44px; padding: 0; display: inline-flex; align-items: center; justify-content: center; background: transparent; border: 0; border-radius: var(--radius-md); color: var(--text-muted); cursor: pointer; transition: color var(--dur-tint) ease; }
.qz__icon:hover { color: var(--text); }
.qz__back .i { transform: rotate(180deg); }

.qz__prog { max-width: 1040px; margin: 0 auto; padding: 0 20px 14px; list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.qz__prog li { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.qz__track { display: block; height: 3px; border-radius: 2px; background: var(--stroke); overflow: hidden; }
.qz__fill { display: block; width: 100%; height: 100%; background: var(--text); transform: scaleX(var(--p, 0)); transform-origin: left center; transition: transform 400ms var(--ease-ui); }
.qz__ch { font-family: var(--font-mono); font-size: 11px; line-height: 1.4; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-quiet); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qz__prog li.is-on .qz__ch { color: var(--text); }

.qz__main { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.qz__col { max-width: 600px; margin: 0 auto; padding: 40px 20px 56px; }

/* ---------- Шаг ---------- */
.qz__step { display: flex; flex-direction: column; gap: 24px; }
.qz__step:not([hidden]) { animation: qz-in 420ms var(--ease-ui) both; }
.qz__head { display: flex; flex-direction: column; gap: 10px; text-align: center; }
.qz__h { font-family: var(--font-display); font-size: 32px; line-height: 1.14; font-weight: 800; letter-spacing: -0.02em; color: var(--text); outline: none; text-wrap: balance; }
.qz__sub { font-size: 16px; line-height: 1.55; color: var(--text-muted); text-wrap: pretty; }
.qz__sub b { font-weight: 600; color: var(--text); }
.qz__foot { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
.qz .qz-next[disabled] { cursor: not-allowed; }
.qz .qz-next[disabled] > span { color: var(--text-muted); }
.qz-link { min-height: 44px; background: none; border: 0; font: inherit; font-size: 14px; color: var(--text-muted); cursor: pointer; }
.qz-link:hover { color: var(--text); }

/* ---------- Варианты ответа ---------- */
.qz-opts { display: flex; flex-direction: column; gap: 10px; }
.qz-opts--grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.qz-opt { position: relative; width: 100%; min-height: 60px; padding: 12px 16px; display: flex; align-items: center; gap: 14px; background: var(--surface); border: 0; border-radius: var(--radius-lg); box-shadow: inset 0 0 0 1px var(--stroke); font: inherit; color: var(--text); text-align: left; cursor: pointer; transition: box-shadow var(--dur-tint) ease, background-color var(--dur-tint) ease, opacity var(--dur-tint) ease; }
.qz-opt:hover { box-shadow: inset 0 0 0 1px var(--stroke-strong); }
.qz-opt:focus-visible, .qz-band:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.qz-opt[aria-pressed="true"] { background: var(--field); box-shadow: inset 0 0 0 1.5px var(--text); }
.qz-opt.is-dim { opacity: 0.5; }
.qz-opt--wide { grid-column: 1 / -1; }
.qz-opt__k { flex: none; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-md); background: var(--field); box-shadow: inset 0 0 0 1px var(--stroke-strong); color: var(--text-secondary); font-size: 12px; }
.qz-opt__b { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.qz-opt__t { font-size: 15px; line-height: 1.35; font-weight: 700; }
.qz-opt__s { font-size: 13px; line-height: 1.4; color: var(--text-muted); }
.qz-opt__m { position: relative; flex: none; width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--text-disabled); }
.qz-opt__m.is-check { border-radius: 5px; }
.qz-opt[aria-pressed="true"] .qz-opt__m { background: var(--text); box-shadow: none; }
.qz-opt[aria-pressed="true"] .qz-opt__m::after { content: ""; position: absolute; left: 5px; top: 6px; width: 10px; height: 5px; border-left: 2px solid var(--page); border-bottom: 2px solid var(--page); transform: rotate(-45deg); }

/* ---------- Истории и иллюстрации ---------- */
.qz-visual { height: 300px; display: flex; align-items: center; justify-content: center; background: var(--page-alt); border: 1px solid var(--stroke-hairline); border-radius: var(--radius-xl); overflow: hidden; }
/* 3D-рендеры с прозрачными краями: занимают всю высоту карточки и мягко проявляются при входе на шаг. */
.qz-visual img { height: 100%; width: auto; max-width: 100%; object-fit: contain; animation: qz-rise 700ms var(--ease-sweep) 120ms both; }

.qz-card { background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--radius-xl); padding: 20px 22px; }
.qz-report { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.qz-report__top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.qz-report__t { font-weight: 700; }
.qz-bar { display: grid; grid-template-columns: 84px minmax(0, 1fr) 72px; gap: 12px; align-items: center; font-size: 13px; color: var(--text-secondary); }
.qz-bar .data { text-align: right; color: var(--text); }
.qz-bar.is-strong > span:first-child { font-weight: 700; color: var(--text); }
.qz-bar__track { display: block; height: 20px; }
.qz-bar__fill { display: block; width: var(--w, 0); height: 100%; border-radius: 4px; background: var(--stroke-strong); transform-origin: left center; animation: qz-grow 800ms var(--ease-sweep) both; }
.qz-bar:nth-child(3) .qz-bar__fill { animation-delay: 120ms; }
.qz-bar:nth-child(4) .qz-bar__fill { animation-delay: 240ms; }
.qz-bar:nth-child(5) .qz-bar__fill { animation-delay: 360ms; }
.qz-bar__fill.is-mid { background: var(--text-quiet); }
.qz-bar__fill.is-hi { background: var(--text); }

/* ---------- Персональные экраны ---------- */
.qz-strip { list-style: none; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.qz-strip li { padding: 10px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--surface); border-radius: var(--radius-md); box-shadow: inset 0 0 0 1px var(--stroke); font-size: 12px; font-weight: 700; line-height: 1.25; text-align: center; opacity: 0.45; transition: opacity 300ms var(--ease-ui), box-shadow 300ms var(--ease-ui); }
.qz-strip li .data { font-size: 11px; font-weight: 400; color: var(--text-muted); }
.qz-strip li.is-on { opacity: 1; box-shadow: inset 0 0 0 1.5px var(--text); }
.qz-strip.is-all li { opacity: 1; }
.qz-reasons { display: flex; flex-direction: column; gap: 10px; }
.qz-reason { padding: 14px 16px; text-align: left; }
.qz-reason__t { font-size: 15px; font-weight: 700; }
.qz-reason__d { margin-top: 4px; font-size: 14px; line-height: 1.5; color: var(--text-secondary); }
.qz-reasons > :not([hidden]) { animation: qz-in 420ms var(--ease-ui) both; }
.qz-reasons > :nth-child(n+3) { animation-delay: 120ms; }
.qz-reasons > :nth-child(n+5) { animation-delay: 240ms; }

.qz-live { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; background: var(--page-alt); border: 1px solid var(--stroke-hairline); border-radius: var(--radius-lg); }
.qz-live p { font-size: 15px; line-height: 1.5; }

.qz-budget { display: flex; flex-direction: column; gap: 20px; }
.qz-budget__v { min-height: 44px; font-family: var(--font-display); font-size: 40px; line-height: 1.1; font-weight: 800; letter-spacing: -0.03em; text-align: center; }
.qz-budget__opts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.qz-band { min-height: 56px; padding: 8px 4px; display: flex; flex-direction: column; align-items: stretch; gap: 10px; background: none; border: 0; border-radius: var(--radius-md); font: inherit; color: var(--text-muted); cursor: pointer; }
.qz-band__bar { display: block; height: 8px; border-radius: 4px; background: var(--stroke); transition: background-color var(--dur-tint) ease; }
.qz-band.is-fill .qz-band__bar { background: var(--text); }
.qz-band:hover .qz-band__bar { background: var(--stroke-strong); }
.qz-band.is-fill:hover .qz-band__bar { background: var(--text); }
.qz-band__t { font-family: var(--font-mono); font-size: 12px; line-height: 1.4; text-align: center; }
.qz-band[aria-pressed="true"] .qz-band__t { color: var(--text); }
.qz-budget__hint { padding: 14px 16px; background: var(--page-alt); border: 1px solid var(--stroke-hairline); border-radius: var(--radius-lg); font-size: 14px; line-height: 1.55; color: var(--text-secondary); text-align: center; }

.qz-weeks { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.qz-weeks li { padding: 14px 16px; display: flex; align-items: baseline; gap: 16px; background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--radius-lg); font-size: 15px; line-height: 1.5; animation: qz-in 420ms var(--ease-ui) both; }
.qz-weeks li:nth-child(2) { animation-delay: 120ms; }
.qz-weeks li:nth-child(3) { animation-delay: 240ms; }
.qz-weeks li:nth-child(4) { animation-delay: 360ms; }
.qz-weeks .label { flex: none; width: 76px; color: var(--text-muted); }
.qz-note { padding: 12px 14px; background: var(--field); border: 1px solid var(--stroke); border-left: 2px solid var(--text-muted); border-radius: var(--radius-md); font-size: 14px; line-height: 1.55; color: var(--text-secondary); text-align: left; }
.qz-note.is-positive { margin-top: 8px; background: var(--positive-tint); border-color: var(--positive-stroke); border-left-color: var(--positive); color: var(--text); }
.qz-note a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.qz-note a:hover { color: var(--accent-hover-text); }

.qz-load { list-style: none; padding: 6px 20px; }
.qz-load li { padding: 14px 0; display: flex; align-items: center; gap: 14px; opacity: 0.35; transition: opacity 300ms var(--ease-ui); }
.qz-load li + li { border-top: 1px solid var(--stroke); }
.qz-load li.is-active, .qz-load li.is-done { opacity: 1; }
.qz-load__m { position: relative; flex: none; width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--text-disabled); }
.qz-load li.is-active .qz-load__m::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid transparent; border-top-color: var(--text); animation: qz-spin 800ms linear infinite; }
.qz-load li.is-done .qz-load__m { background: var(--text); box-shadow: none; }
.qz-load li.is-done .qz-load__m::after { content: ""; position: absolute; left: 6px; top: 7px; width: 10px; height: 5px; border-left: 2px solid var(--page); border-bottom: 2px solid var(--page); transform: rotate(-45deg); }
.qz-load__k { display: block; font-size: 13px; line-height: 1.4; color: var(--text-muted); }
.qz-load b { display: block; font-size: 15px; line-height: 1.45; }

.qz-rows { padding: 4px 20px; }
.qz-rows > div { padding: 12px 0; display: flex; justify-content: space-between; gap: 16px; }
.qz-rows > div + div { border-top: 1px solid var(--stroke); }
.qz-rows dt { font-size: 14px; color: var(--text-muted); }
.qz-rows dd { margin: 0; font-size: 14px; font-weight: 600; text-align: right; }
.qz-case { padding: 16px 18px; display: flex; justify-content: space-between; align-items: center; gap: 16px; background: var(--page-alt); border: 1px solid var(--stroke-hairline); border-radius: var(--radius-lg); }
.qz-case > span:first-child { display: flex; flex-direction: column; gap: 4px; }
.qz-case b { font-size: 15px; line-height: 1.4; }
.qz-case__n { font-family: var(--font-display); font-size: 26px; font-weight: 800; letter-spacing: -0.03em; white-space: nowrap; }

.qz-form { display: flex; flex-direction: column; gap: 16px; text-align: left; }
.qz .form__legal { flex: none; text-align: center; }
.qz .form__legal a { color: var(--text-muted); text-decoration: underline; text-underline-offset: 3px; }
.qz-steps { margin-top: 8px; }

/* ---------- Первый вопрос прямо на странице ---------- */
.qz-start { padding: 28px; display: flex; flex-direction: column; gap: 20px; background: var(--page); border: 1px solid var(--stroke); border-radius: var(--radius-xl); text-align: left; }
.qz-start__top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.qz-start__track { display: block; height: 3px; border-radius: 2px; background: var(--stroke); overflow: hidden; }
.qz-start__track > span { display: block; width: 11%; height: 100%; background: var(--text); }
.qz-start__head { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Движение ---------- */
@keyframes qz-in { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }
@keyframes qz-rise { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes qz-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes qz-spin { to { transform: rotate(360deg); } }

/* ---------- Телефон ---------- */
@media (max-width: 767px) {
  .qz__bar { height: 56px; padding: 0 8px; }
  /* На телефоне под полосками одна подпись — название текущей главы по центру, без обрезки. */
  .qz__prog { position: relative; padding: 0 16px 32px; gap: 6px; }
  .qz__prog li { gap: 0; }
  .qz__prog .qz__ch { position: absolute; left: 16px; right: 16px; bottom: 10px; text-align: center; }
  .qz__prog li:not(.is-on) .qz__ch { visibility: hidden; }
  .qz__col { padding: 24px 16px 0; }
  .qz__h { font-size: 26px; }
  .qz__sub { font-size: 15px; }
  .qz-visual { height: 220px; }
  .qz__step { padding-bottom: 24px; }
  .qz__step > .qz__foot { position: sticky; bottom: 0; z-index: 2; margin: 0 -16px -24px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--page); border-top: 1px solid var(--stroke-hairline); }
  .qz-opt { min-height: 56px; padding: 10px 14px; gap: 12px; }
  .qz-opt__k { width: 32px; height: 32px; }
  .qz-weeks li { flex-direction: column; gap: 4px; }
  .qz-budget__v { font-size: 34px; }
  .qz-start { padding: 20px; }
}
@media (max-width: 479px) {
  .qz-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .qz-budget__opts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .qz-bar { grid-template-columns: 64px minmax(0, 1fr) 60px; }
}
@media (prefers-reduced-motion: reduce) {
  .qz__step:not([hidden]), .qz-reasons > :not([hidden]), .qz-weeks li, .qz-bar__fill, .qz-visual img { animation: none; }
  .qz-load li.is-active .qz-load__m::after { animation: none; }
  .qz__fill { transition: none; }
}
