/* =====================================================================
   REFRAME GROUP — розділ «Житло для людей»

   Перевірка житлових можливостей (єОселя, сертифікат, ваучер,
   єВідновлення), результат перевірки та підбір будинків під бюджет.
   ===================================================================== */

/* --- 1. Пояснення механізмів ---------------------------------------- */
.h-kb {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

.h-kb__card {
    display: grid;
    gap: 10px;
    align-content: start;
    padding: clamp(20px, 2.6vw, 28px);
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--surface);
    transition: transform var(--t-base) var(--ease-out),
                box-shadow var(--t-base) var(--ease-out),
                border-color var(--t-base) var(--ease-out);
}

.h-kb__card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-sm);
    border-color: var(--border-strong);
}

.h-kb__name {
    font-family: var(--font-display);
    font-size: var(--fs-h4);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.h-kb__text { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.6; }

/* --- 2. Перевірка можливостей: один екран, одне питання ------------- */
.quiz {
    position: relative;
    display: grid;
    gap: clamp(20px, 3vw, 28px);
    padding: clamp(24px, 3.4vw, 40px);
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    min-height: 430px;
    align-content: start;
}

.quiz__top { display: grid; gap: 12px; }

.quiz__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-subtle);
}

.quiz__meta strong { color: var(--accent-text); font-variant-numeric: tabular-nums; }

.quiz__bar {
    height: 4px;
    border-radius: 2px;
    background: var(--bg-sunken);
    overflow: hidden;
}

.quiz__bar-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--amber-500), var(--amber-300));
    border-radius: 2px;
    transition: width 0.5s var(--ease-out);
}

.quiz__q {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 3.4vw, 2rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.15;
    text-wrap: balance;
    max-width: 24ch;
}

.quiz__hint {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    max-width: 56ch;
    margin-top: -10px;
}

.quiz__opts { display: grid; gap: 10px; }

@media (min-width: 720px) {
    .quiz__opts--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.quiz__step {
    display: grid;
    gap: clamp(18px, 2.4vw, 24px);
    animation: quizIn 0.42s var(--ease-out) both;
}

@keyframes quizIn {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}

.opt {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    width: 100%;
    min-height: 62px;
    padding: 14px 20px;
    border-radius: var(--r-md);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    text-align: left;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.35;
    color: var(--text);
    animation: quizIn 0.4s var(--ease-out) backwards;
    animation-delay: calc(var(--i, 0) * 45ms + 60ms);
    transition: border-color var(--t-fast) var(--ease-out),
                background var(--t-fast) var(--ease-out),
                transform var(--t-fast) var(--ease-out);
}

.opt:hover {
    border-color: var(--amber-500);
    background: rgba(245, 165, 75, 0.07);
    transform: translateX(3px);
}

.opt.is-selected { border-color: var(--amber-500); background: rgba(245, 165, 75, 0.14); }

.opt__mark {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border-strong);
    flex: none;
    display: grid;
    place-items: center;
    transition: border-color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}

.opt:hover .opt__mark { border-color: var(--amber-500); }

.opt.is-selected .opt__mark { border-color: var(--amber-500); background: var(--amber-500); }

.opt.is-selected .opt__mark::after {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ink-900);
}

.quiz__input { max-width: 420px; }

.quiz__input .field__control {
    min-height: 62px;
    font-size: 1.1rem;
    font-variant-numeric: tabular-nums;
}

.quiz__nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    padding-top: var(--space-2);
}

.quiz__back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-subtle);
    padding: 12px 4px;
}

.quiz__back:hover { color: var(--text); }

.quiz__skip { margin-left: auto; font-size: var(--fs-sm); color: var(--text-subtle); padding: 12px; }
.quiz__skip:hover { color: var(--text); }

@media (max-width: 560px) {
    .quiz__nav .btn--accent { width: 100%; }
    .quiz__skip { margin-left: 0; }
}

/* --- 3. Результат перевірки ----------------------------------------- */
.result { display: grid; gap: clamp(26px, 4vw, 40px); animation: quizIn 0.5s var(--ease-out) both; }

.result__lead {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 3.4vw, 2rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.18;
    text-wrap: balance;
    max-width: 26ch;
}

.paths { display: grid; gap: var(--space-4); }

@media (min-width: 760px) {
    .paths { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
}

.path {
    display: grid;
    gap: 10px;
    align-content: start;
    padding: clamp(20px, 2.6vw, 28px);
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    border-top: 3px solid var(--amber-500);
    background: var(--surface);
    animation: quizIn 0.5s var(--ease-out) backwards;
    animation-delay: calc(var(--i, 0) * 80ms + 100ms);
}

.path__num {
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent-text);
}

.path__name {
    font-family: var(--font-display);
    font-size: var(--fs-h4);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.path__text { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.6; }

.budget {
    display: grid;
    gap: var(--space-5);
    padding: clamp(22px, 3vw, 34px);
    border-radius: var(--r-lg);
    background: var(--ink-900);
    color: var(--dark-text);
}

.budget__rows { display: grid; }

.budget__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-4);
    padding: 12px 0;
    border-bottom: 1px solid var(--dark-border);
    font-size: var(--fs-sm);
}

.budget__row span:first-child { color: var(--dark-muted); }

.budget__row span:last-child {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.budget__row--total { border-bottom: 0; padding-top: 18px; }

.budget__row--total span:first-child {
    color: var(--amber-400);
    font-weight: 700;
    font-size: var(--fs-xs);
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.budget__row--total span:last-child {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 4vw, 2rem);
    letter-spacing: -0.03em;
}

.budget__note { font-size: var(--fs-xs); color: rgba(243, 237, 226, 0.6); line-height: 1.55; }

/* --- 4. Підібрані будинки та заявка ---------------------------------- */
.matches { display: grid; gap: var(--space-4); }

@media (min-width: 760px) {
    .matches { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.match {
    display: flex;
    flex-direction: column;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--surface);
    overflow: hidden;
    text-align: left;
    animation: quizIn 0.5s var(--ease-out) backwards;
    animation-delay: calc(var(--i, 0) * 90ms + 160ms);
    transition: transform var(--t-base) var(--ease-out), box-shadow var(--t-base) var(--ease-out);
}

.match:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }

.match__media { aspect-ratio: 4 / 3; background: var(--bg-sunken); overflow: hidden; }

.match__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--t-slow) var(--ease-out);
}

.match:hover .match__media img { transform: scale(1.05); }

.match__body { display: grid; gap: 8px; padding: var(--space-5); align-content: start; flex: 1; }

.match__name {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.match__meta { font-size: var(--fs-xs); color: var(--text-muted); }

.match__price {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    margin-top: auto;
    padding-top: 8px;
    color: var(--accent-text);
}

.h-lead {
    display: grid;
    gap: var(--space-5);
    align-items: center;
    padding: clamp(24px, 3.4vw, 38px);
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    background: var(--bg-alt);
}

@media (min-width: 900px) {
    .h-lead { grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-7); }
}

.h-lead__title {
    font-family: var(--font-display);
    font-size: var(--fs-h3);
    font-weight: 600;
    letter-spacing: -0.025em;
}

/* ---------------------------------------------------------------------
   5. Модальне вікно перевірки

   Світлий діалог: усередині живуть картки quiz і результату,
   розраховані на світлий фон.
   --------------------------------------------------------------------- */
.modal--check .modal__dialog {
    width: min(900px, 100%);
    background: var(--bg);
    color: var(--text);
}

.modal--check .modal__close {
    right: max(clamp(12px, 2.4vw, 28px), calc(50vw - 450px + 14px));
}

.check-modal {
    display: grid;
    gap: clamp(20px, 2.6vw, 30px);
    padding: clamp(24px, 3.4vw, 44px);
}

.check-modal__head { display: grid; gap: 10px; }

.check-modal__title {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 3.4vw, 2.2rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.15;
    text-wrap: balance;
}

.check-modal__text {
    font-size: var(--fs-sm);
    line-height: 1.6;
    color: var(--text-muted);
    max-width: 62ch;
}

/* У модалці картка quiz уже всередині діалогу — рамка зайва */
.check-modal .quiz {
    border: 0;
    box-shadow: none;
    background: transparent;
    padding: 0;
    min-height: 380px;
}

.check-modal .h-lead { background: var(--surface); }

@media (max-width: 700px) {
    .check-modal .quiz { min-height: 340px; }
}
