/* =====================================================================
   Опитування для дверних компаній (/quiz/doors)

   Анкета на 76 питань має читатися як розмова, а не як бланк: один блок
   на екран, спокійні відступи, помітний прогрес. Кольори — з tokens.css,
   тож сторінка виглядає частиною ELISOR і працює в обох темах.
   ===================================================================== */

/* Кнопки й лічильники мають власний display, тож атрибут hidden без
   цього правила їх не ховає — «Надіслати» світилася б з першого кроку. */
.quiz [hidden] { display: none !important; }

.quiz {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* clip, а не hidden: інакше зламається липкий прогрес угорі сторінки */
    overflow-x: clip;
}
.quiz__bg {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100vw;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}
.quiz__glow {
    position: absolute;
    width: 620px;
    height: 620px;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.5;
}
.quiz__glow--1 { top: -240px; right: -160px; background: var(--accent-soft); }
.quiz__glow--2 { bottom: -300px; left: -200px; background: var(--tint-soft); }

.quiz__main {
    position: relative;
    z-index: 1;
    flex: 1 0 auto;
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 40px 20px 80px;
}

/* --- Знайомство -------------------------------------------------------- */
.quiz-tag {
    display: inline-flex;
    padding: 5px 12px;
    border: 1px solid var(--accent-line);
    border-radius: var(--r-full);
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: var(--t-xs);
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 18px;
}
.quiz-intro__title {
    font-size: clamp(var(--t-2xl), 5vw, var(--t-4xl));
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin-bottom: 16px;
}
.quiz-intro__lead {
    font-size: var(--t-md);
    color: var(--text-muted);
    line-height: 1.7;
    max-width: 62ch;
    margin-bottom: 28px;
}

.quiz-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
    gap: 10px;
    margin-bottom: 24px;
}
.quiz-fact {
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--bg-raised);
}
.quiz-fact__value {
    display: block;
    font-size: var(--t-2xl);
    font-weight: 600;
    color: var(--accent-text);
    line-height: 1.1;
    margin-bottom: 6px;
}
.quiz-fact__value svg { width: 22px; height: 22px; }
.quiz-fact__label { font-size: var(--t-sm); color: var(--text-muted); }

.quiz-notes { list-style: none; display: grid; gap: 9px; margin-bottom: 28px; }
.quiz-notes li {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    font-size: var(--t-base);
    color: var(--text-soft);
}
.quiz-notes svg { flex-shrink: 0; margin-top: 3px; color: var(--accent-text); }

.quiz-intro__resume {
    margin-top: 20px;
    padding: 14px 16px;
    border: 1px solid var(--accent-line);
    border-radius: var(--r-lg);
    background: var(--accent-soft);
    font-size: var(--t-base);
    color: var(--text-soft);
}
.quiz-link {
    border: none;
    background: none;
    padding: 0;
    font: inherit;
    color: var(--accent-text);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
.quiz-link--quiet { color: var(--text-muted); }

/* --- Прогрес ----------------------------------------------------------- */
.quiz-progress { position: sticky; top: 0; z-index: 2; padding: 14px 0 16px; background: var(--bg-deep); }
.quiz-progress__bar {
    height: 4px;
    border-radius: var(--r-full);
    background: var(--tint-hover);
    overflow: hidden;
}
.quiz-progress__fill {
    height: 100%;
    border-radius: var(--r-full);
    background: linear-gradient(90deg, var(--accent-line), var(--accent));
    transition: width var(--normal) var(--ease);
}
.quiz-progress__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 9px;
    font-size: var(--t-sm);
    color: var(--text-muted);
}
.quiz-progress__saved { display: inline-flex; align-items: center; gap: 5px; color: var(--positive); }

.quiz-dots { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.quiz-dot {
    width: 22px;
    height: 4px;
    padding: 0;
    border: none;
    border-radius: var(--r-full);
    background: var(--tint-hover);
    cursor: pointer;
    transition: background var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.quiz-dot:hover { transform: scaleY(1.6); }
.quiz-dot.is-done { background: var(--accent-line); }
.quiz-dot.is-current { background: var(--accent); }

/* --- Блок питань ------------------------------------------------------- */
.quiz-step { animation: quiz-in var(--normal) var(--ease) both; }
@keyframes quiz-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.quiz-step__head { display: flex; gap: 12px; align-items: flex-start; margin: 26px 0 22px; }
.quiz-step__icon {
    display: inline-flex;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-md);
    background: var(--accent-soft);
    color: var(--accent-text);
}
.quiz-step__title { font-size: var(--t-xl); font-weight: 600; letter-spacing: -0.02em; }
.quiz-step__lead { font-size: var(--t-base); color: var(--text-muted); margin-top: 4px; line-height: 1.6; }

.quiz-q {
    padding: 20px 0 22px;
    border-top: 1px solid var(--line);
}
.quiz-q:first-of-type { border-top: none; padding-top: 0; }
.quiz-q__title { font-size: var(--t-md); font-weight: 550; line-height: 1.5; }
.quiz-q__star {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: var(--r-full);
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: var(--t-xs);
    font-weight: 500;
    vertical-align: middle;
}
.quiz-q__hint { font-size: var(--t-sm); color: var(--text-faint); margin-top: 6px; line-height: 1.6; }
.quiz-q__head { margin-bottom: 14px; }
.quiz-q__error { margin-top: 10px; font-size: var(--t-sm); color: var(--danger); }
.quiz-q.has-error { scroll-margin-top: 90px; }
.quiz-q.has-error .quiz-q__title { color: var(--danger); }

/* Варіанти */
.quiz-options { display: grid; gap: 8px; }
.quiz-opt {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 13px 15px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--bg-raised);
    cursor: pointer;
    transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.quiz-opt:hover { border-color: var(--line-bright); }
.quiz-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.quiz-opt__mark {
    position: relative;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    border: 1px solid var(--line-bright);
    border-radius: 50%;
    transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.quiz-opt__mark--box { border-radius: var(--r-xs); }
.quiz-opt__text { font-size: var(--t-base); color: var(--text-soft); line-height: 1.5; }
.quiz-opt:has(input:checked) {
    border-color: var(--accent-line);
    background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--bg-raised);
}
.quiz-opt:has(input:checked) .quiz-opt__text { color: var(--text); }
.quiz-opt input:checked + .quiz-opt__mark { border-color: var(--accent); background: var(--accent); }
.quiz-opt input:checked + .quiz-opt__mark::after {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: inherit;
    background: var(--text-invert);
}
.quiz-opt input:focus-visible + .quiz-opt__mark { box-shadow: 0 0 0 3px var(--accent-soft); }
.quiz-opt.is-locked { opacity: 0.45; cursor: not-allowed; }

/* Шкала 1–10 */
.quiz-scale__row { display: flex; gap: 6px; flex-wrap: wrap; }
.quiz-scale__item { flex: 1; min-width: 42px; }
.quiz-scale__item input { position: absolute; opacity: 0; width: 0; height: 0; }
.quiz-scale__item span {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--bg-raised);
    color: var(--text-muted);
    font-size: var(--t-base);
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: all var(--fast) var(--ease);
}
.quiz-scale__item span:hover { border-color: var(--line-bright); color: var(--text); }
.quiz-scale__item input:checked + span {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--text-invert);
    font-weight: 600;
}
.quiz-scale__ends {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 9px;
    font-size: var(--t-xs);
    color: var(--text-faint);
}
.quiz-scale__ends span:last-child { text-align: right; }

/* Сітка оцінок */
.quiz-grid { display: grid; gap: 6px; }
.quiz-grid__row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--bg-raised);
}
.quiz-grid__label { flex: 1; min-width: 150px; font-size: var(--t-base); color: var(--text-soft); }
.quiz-grid__marks { display: flex; gap: 5px; }
.quiz-grid__mark input { position: absolute; opacity: 0; width: 0; height: 0; }
.quiz-grid__mark span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    color: var(--text-faint);
    font-size: var(--t-sm);
    cursor: pointer;
    transition: all var(--fast) var(--ease);
}
.quiz-grid__mark span:hover { border-color: var(--accent-line); color: var(--text); }
.quiz-grid__mark input:checked + span {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--text-invert);
    font-weight: 600;
}

/* Число й текст */
.quiz-number { display: flex; align-items: center; gap: 10px; }
.quiz-number .input { max-width: 180px; }
.quiz-number__unit { font-size: var(--t-base); color: var(--text-muted); }
.quiz-text { width: 100%; }
textarea.quiz-text { resize: vertical; min-height: 96px; line-height: 1.6; }

/* --- Навігація --------------------------------------------------------- */
.quiz-nav {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 30px;
    padding: 14px 0 18px;
    background: linear-gradient(to top, var(--bg-deep) 70%, transparent);
}
.quiz-nav__count { flex: 1; text-align: center; font-size: var(--t-sm); color: var(--text-faint); }
.quiz-flow__error {
    margin-top: 10px;
    padding: 12px 14px;
    border: 1px solid var(--danger);
    border-radius: var(--r-md);
    background: var(--danger-soft);
    color: var(--danger);
    font-size: var(--t-base);
}

/* --- Фінал ------------------------------------------------------------- */
.quiz-done { text-align: center; padding: 60px 0 40px; animation: quiz-in var(--normal) var(--ease) both; }
.quiz-done__icon {
    display: inline-flex;
    width: 64px;
    height: 64px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-text);
    margin-bottom: 20px;
}
.quiz-done__title { font-size: var(--t-2xl); font-weight: 600; letter-spacing: -0.02em; margin-bottom: 12px; }
.quiz-done__text { font-size: var(--t-md); color: var(--text-muted); line-height: 1.7; max-width: 52ch; margin: 0 auto 26px; }
.quiz-done__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

@media (max-width: 640px) {
    .quiz__main { padding: 24px 16px 60px; }
    .quiz-scale__item { min-width: 0; }
    .quiz-scale__item span { height: 40px; font-size: var(--t-sm); }
    .quiz-grid__row { gap: 8px; }
    .quiz-grid__label { min-width: 100%; }
    .quiz-nav .btn { flex: 1; }
    .quiz-nav__count { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .quiz-step, .quiz-done { animation: none; }
    .quiz-progress__fill { transition: none; }
}
