/* ==========================================================================
   Страница теста — фирменная карточка с золотыми уголками
   ========================================================================== */
.test-page { background: var(--bg); }
/* Первый экран равен окну: карточка растягивается, прогресс прижат к низу. */
.test-shell { min-height: calc(100vh - var(--header-h)); min-height: calc(100dvh - var(--header-h)); display: flex; flex-direction: column; padding-top: clamp(16px, 3.4vh, 40px); }

/* ---------- Карточка ---------- */
.test-card {
    position: relative;
    flex: 1 0 auto;
    width: min(1100px, 100% - 2 * clamp(10px, 2.5vw, 40px));
    min-height: min(640px, 70vh);
    margin: 0 auto clamp(16px, 3.4vh, 40px);
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .10);
    display: flex;
    flex-direction: column;
}
.test-card::before, .test-card::after { content: ""; position: absolute; width: clamp(60px, 8vw, 96px); height: clamp(60px, 8vw, 96px); z-index: 1; pointer-events: none; }
.test-card::before { top: 0; left: 0; border-left: 3px solid var(--gold-pale); border-top: 3px solid var(--gold-pale); }
.test-card::after { right: 0; bottom: 0; border-right: 3px solid var(--gold-pale); border-bottom: 3px solid var(--gold-pale); }
.screen { position: relative; z-index: 2; flex: 1; display: flex; flex-direction: column; padding: clamp(30px, 5vh, 48px) clamp(22px, 5vw, 60px) clamp(22px, 3vh, 28px); transition: opacity .4s ease; }
.screen.is-leaving, .screen.is-entering { opacity: 0; }

/* ---------- Общие элементы ---------- */
.question-label { color: var(--gold-deep); font-family: var(--f-ui); font-size: 10px; font-weight: 600; letter-spacing: 1.8px; text-transform: uppercase; margin-bottom: 16px; }
.question-title { font-family: var(--f-display); font-weight: 400; font-size: clamp(22px, 1.3rem + .5vw, 27px); line-height: 1.35; color: #2a2a2a; max-width: 820px; margin: 0; outline: none; text-wrap: pretty; }

/* ---------- Знакомство ---------- */
.intro { display: grid; grid-template-columns: 1.05fr .95fr; gap: clamp(28px, 5vw, 72px); align-items: start; }
.intro__title { font-size: clamp(30px, 1.6rem + 1.6vw, 44px); margin-bottom: 20px; }
.intro__text { font-size: 18.5px; color: var(--ink-2); line-height: 1.6; }
.intro__facts { display: grid; grid-template-columns: repeat(3, 1fr); margin: 30px 0; border-top: 1px solid var(--line-warm); border-bottom: 1px solid var(--line-warm); }
.intro__facts div { padding: 20px 10px 18px 0; }
.intro__facts div + div { padding-left: 18px; border-left: 1px solid var(--line-warm); }
.intro__facts dt { font-family: var(--f-display); font-size: clamp(30px, 3.4vw, 40px); line-height: 1; color: var(--gold); margin-bottom: 8px; }
.intro__facts dd { margin: 0; font-family: var(--f-ui); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); line-height: 1.4; }
.intro__note { font-family: var(--f-ui); font-size: 13px; line-height: 1.6; color: var(--muted); margin: 0; }
.intro__invite { margin: 0 0 26px; padding: 18px 20px; border: 1px solid var(--gold-line); background: #FFFDF6; font-family: var(--f-ui); font-size: 14px; line-height: 1.55; color: var(--ink-2); }
.intro__invite .question-label { display: block; margin-bottom: 6px; }
.intro__form { display: grid; gap: 22px; padding: clamp(22px, 3vw, 32px); border: 1px solid #F0E6D2; background: #FFFEFB; }
.birth-row { display: grid; grid-template-columns: minmax(84px, .85fr) 1.5fr minmax(96px, 1fr); gap: 8px; }
.birth-row .select { padding-left: 12px; padding-right: 30px; background-position: right 10px center; }
@media (max-width: 900px) { .intro { grid-template-columns: 1fr; } }
@media (max-width: 520px) {
    .intro__facts div + div { padding-left: 10px; }
    .intro__facts dd { font-size: 9.5px; letter-spacing: .04em; }
    .birth-row { grid-template-columns: 1fr 1.5fr; }
    .birth-row select[name="year"] { grid-column: 1 / -1; }
    .intro__form { padding: 18px; }
}

/* ---------- Заставка главы ---------- */
.screen--chapter { justify-content: center; }
.chapter { max-width: 640px; margin: 0 auto; text-align: center; padding: clamp(20px, 6vh, 60px) 0; }
.chapter__numeral { font-family: var(--f-display); font-size: clamp(64px, 9vw, 104px); line-height: 1; color: var(--gold); margin-bottom: 18px; animation: numeralIn 1.1s var(--ease) both; }
@keyframes numeralIn { from { opacity: 0; letter-spacing: .3em; } to { opacity: 1; letter-spacing: 0; } }
.chapter .question-label { margin-bottom: 14px; }
.chapter__title { font-size: clamp(30px, 2rem + 1.4vw, 44px); margin: 0 0 18px; }
.chapter__text { font-size: 19px; color: var(--ink-2); margin: 0 auto 26px; }
.chapter__fact { position: relative; margin: 0 auto 36px; max-width: 520px; padding: 18px 0 0; border-top: 1px solid var(--line-warm); font-style: italic; font-size: 18px; color: var(--muted); }
.chapter__fact::before { content: "Любопытный факт"; display: block; margin-bottom: 8px; font-family: var(--f-ui); font-style: normal; font-size: 10px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--gold-deep); }
.chapter__fact:empty { display: none; }

/* ---------- Вопрос ---------- */
.question-number { position: absolute; top: clamp(15px, 3vh, 25px); right: clamp(15px, 3vw, 25px); width: clamp(45px, 7vw, 55px); height: clamp(45px, 7vw, 55px); border: 1.5px solid #f0e6d2; background: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--f-display); font-size: clamp(18px, 3.4vw, 23px); color: var(--gold); z-index: 3; font-variant-numeric: lining-nums; }
.question-header { margin: clamp(4px, 1vh, 10px) 0 clamp(25px, 4vh, 38px); padding-right: clamp(54px, 9vw, 80px); }
.answers-grid { display: grid; grid-template-columns: 1fr; gap: clamp(10px, 1.5vw, 16px); margin-bottom: clamp(22px, 4vh, 32px); }
@media (min-width: 768px) { .answers-grid--grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.answer-card {
    appearance: none; width: 100%; min-height: clamp(70px, 10vh, 89px);
    display: flex; align-items: center; gap: clamp(14px, 2vw, 20px);
    padding: 12px clamp(15px, 3vw, 22px); text-align: left; cursor: pointer; position: relative;
    background: #fff; border: 1px solid #e5e5e5; border-radius: 4px;
    transition: border-color .3s, box-shadow .3s, background .3s;
    animation: answerIn .45s ease backwards; animation-delay: calc(var(--i, 0) * 50ms);
    -webkit-tap-highlight-color: transparent;
}
@keyframes answerIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.answer-letter { width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%; background: #fff; border: 1px solid var(--gold); color: var(--gold); display: flex; align-items: center; justify-content: center; font-family: var(--f-display); font-size: 12px; font-weight: 600; transition: transform .3s, background .3s, border-width .3s; }
.answer-text { flex: 1; font-family: var(--f-text); font-size: clamp(16.5px, 1.05rem, 18px); line-height: 1.42; color: #5E5E5E; transition: color .2s; }
.answer-level { display: inline-flex; gap: 3px; flex: none; margin-left: 6px; }
.answer-level i { width: 5px; height: 14px; background: #EFE7D3; }
.answer-level i.on { background: var(--gold); }
.checkmark { position: absolute; top: 50%; right: 16px; width: 22px; height: 22px; margin-top: -11px; border-radius: 50%; background: #fff; color: var(--gold); display: none; align-items: center; justify-content: center; }
.checkmark svg { width: 11px; height: 11px; }
@media (hover: hover) {
    .answer-card:hover { border-color: var(--gold); box-shadow: 0 10px 30px rgba(226, 173, 40, .45); z-index: 5; }
    .answer-card:hover .answer-letter { background: #fffbf0; transform: scale(1.1); border-width: 2px; }
    .answer-card:hover .answer-text { color: #222; }
}
.answer-card:focus-visible { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(226, 173, 40, .35); }
.answer-card.selected { background: linear-gradient(90deg, var(--gold) 0%, #D4AF37 100%); border-color: var(--gold); padding-right: 48px; }
.answer-card.selected .answer-letter { background: #fff; color: var(--gold); border-color: #fff; transform: none; }
.answer-card.selected .answer-text { color: #fff; }
.answer-card.selected .answer-level i { background: rgba(255, 255, 255, .45); }
.answer-card.selected .answer-level i.on { background: #fff; }
.answer-card.selected .checkmark { display: flex; }
.instruction { margin-top: auto; padding-bottom: 14px; text-align: center; font-family: var(--f-ui); font-size: 12.5px; color: var(--muted-2); }
.instruction kbd { display: inline-block; min-width: 20px; padding: 1px 5px; border: 1px solid #E2DED5; border-radius: 3px; font-family: var(--f-ui); font-size: 11px; color: var(--muted); background: #FBFAF7; }
.test-navigation { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 16px; border-top: 1px solid #F3EEE3; }
.nav-btn { display: inline-flex; align-items: center; gap: 9px; min-height: 42px; padding: 0 18px; background: transparent; border: 1px solid #e0e0e0; border-radius: 4px; font-family: var(--f-ui); font-size: 12.5px; color: #888; cursor: pointer; transition: border-color .3s, color .3s; }
.nav-btn svg { width: 9px; height: 13px; fill: currentColor; }
.nav-btn:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-deep); }
.nav-btn:disabled { opacity: .45; cursor: default; }
.answered-counter { font-family: var(--f-ui); font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
    .nav-btn--pause span { display: none; }
    .nav-btn--pause { padding: 0 15px; }
    .answer-card { gap: 13px; }
    .answer-level { display: none; }
    .instruction { display: none; }
}

/* ---------- Прогресс по главам ---------- */
.progress-strip { width: 100%; margin-top: auto; padding: 18px 0 calc(18px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid rgba(223, 172, 42, .15); }
.progress-bar-section { display: flex; width: min(1100px, 100% - 2 * clamp(14px, 2.5vw, 40px)); margin: 0 auto 14px; gap: 4px; }
.progress-segment-wrap { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.progress-segment { height: 6px; background: #f0f0f0; border-radius: 3px; overflow: hidden; position: relative; }
.progress-segment i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--gold); transition: width .5s ease; }
.progress-segment.filled i { width: 100% !important; background: linear-gradient(90deg, var(--gold) 0%, #ffe082 50%, var(--gold) 100%); background-size: 200% 100%; animation: segShimmer 2s infinite linear; }
@keyframes segShimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.progress-segment-label { display: none; font-family: var(--f-ui); font-size: 10px; color: #bdbdbd; text-align: center; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color .3s; }
@media (min-width: 768px) { .progress-segment-label { display: block; } }
.progress-segment-wrap.active .progress-segment-label { color: var(--gold-deep); font-weight: 600; }
.progress-segment-wrap.done .progress-segment-label { color: #9E9E9E; }
.progress-info { width: min(1100px, 100% - 2 * clamp(14px, 2.5vw, 40px)); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-family: var(--f-ui); font-size: 13px; color: var(--muted); }
.progress-percent { color: var(--gold-deep); font-weight: 600; }
.remaining-text strong { color: var(--gold-deep); font-weight: 600; }

/* ---------- Пауза ---------- */
.pause-progress { margin: 18px 0 24px; padding: 16px 18px; background: #f9f9f9; font-family: var(--f-ui); }
.pause-progress__head { display: flex; justify-content: space-between; font-size: 13px; color: #555; margin-bottom: 8px; }
.pause-progress__head b { color: var(--gold-deep); }
.pause-progress__bar { height: 6px; background: #eee; border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.pause-progress__bar i { display: block; height: 100%; width: 0; background: var(--gold); }
.pause-progress p { margin: 0; font-size: 12px; color: #9a9a9a; }

/* ---------- Формирование отчёта ---------- */
.cinematic { position: fixed; inset: 0; z-index: 5000; display: flex; align-items: center; justify-content: center; padding: 20px; overflow: hidden;
    background: radial-gradient(circle at 22% 18%, rgba(223, 172, 42, .18) 0%, transparent 46%), radial-gradient(circle at 78% 76%, rgba(223, 172, 42, .12) 0%, transparent 55%), linear-gradient(180deg, #fff 0%, #fbfbf8 100%); }
.cinematic[hidden] { display: none !important; }
.cinematic::before { content: ""; position: absolute; inset: -40%; background: conic-gradient(from 180deg, transparent, rgba(223, 172, 42, .16), transparent, rgba(223, 172, 42, .10), transparent); animation: clRotate 10s linear infinite; filter: blur(18px); opacity: .85; pointer-events: none; }
@keyframes clRotate { to { transform: rotate(360deg); } }
.cinematic__box { position: relative; width: min(560px, 100%); padding: 26px 26px 20px; background: rgba(255, 255, 255, .9); border: 1px solid rgba(223, 172, 42, .25); box-shadow: 0 24px 70px rgba(0, 0, 0, .10); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.cinematic__box::before { content: ""; position: absolute; top: 0; left: 0; width: 70px; height: 70px; border-top: 3px solid var(--gold-pale); border-left: 3px solid var(--gold-pale); }
.cinematic__top { display: flex; gap: 16px; align-items: center; }
.cinematic__symbol { position: relative; flex: none; width: 66px; height: 66px; display: grid; place-items: center; overflow: hidden; border: 1px solid rgba(223, 172, 42, .3); background: #fff; }
.cinematic__symbol::before { content: ""; position: absolute; inset: -55%; background: conic-gradient(from 0deg, rgba(223, 172, 42, .08), rgba(223, 172, 42, .55), rgba(223, 172, 42, .10), rgba(223, 172, 42, .4), rgba(223, 172, 42, .08)); animation: clRotate 2.6s linear infinite; }
.cinematic__symbol::after { content: ""; position: absolute; inset: 5px; background: #fff; border: 1px solid rgba(26, 26, 26, .05); }
.cinematic__symbol span { position: relative; z-index: 2; font-family: var(--f-display); font-size: 26px; font-weight: 600; color: var(--gold); }
.cinematic h3 { margin: 0 0 6px; font-size: clamp(19px, 2.6vw, 23px); }
.cinematic__top p { margin: 0; font-family: var(--f-ui); font-size: 13.5px; line-height: 1.55; color: rgba(26, 26, 26, .7); }
.cinematic__progress { margin-top: 20px; height: 8px; background: rgba(26, 26, 26, .07); border-radius: 999px; overflow: hidden; }
.cinematic__progress i { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, rgba(223, 172, 42, .92), rgba(255, 240, 187, .95), rgba(223, 172, 42, .92)); background-size: 200% 100%; animation: barShimmer 1.8s linear infinite; transition: width .35s var(--ease); }
@keyframes barShimmer { to { background-position: 200% 0; } }
.cinematic__status { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; font-family: var(--f-ui); font-size: 12px; color: rgba(26, 26, 26, .6); }
.cinematic__tip { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid rgba(26, 26, 26, .08); font-family: var(--f-ui); font-size: 12px; line-height: 1.55; color: rgba(26, 26, 26, .6); }
.cinematic__error { margin-top: 16px; padding: 14px 16px; border-left: 2px solid var(--danger); background: #FBF4F3; font-family: var(--f-ui); font-size: 13px; color: var(--danger); }
.cinematic__error p { margin: 0 0 10px; }

/* ---------- Телефон и планшет ---------- */
@media (max-width: 767px) {
    .test-shell { padding-top: 14px; }
    .test-card { min-height: 0; margin-bottom: 18px; }
    .screen { padding: 26px 18px 18px; }
    .question-title { font-size: 21px; line-height: 1.38; }
    .question-header { padding-right: 52px; margin-bottom: 22px; }
    .answer-card { min-height: 64px; }
    .progress-info { font-size: 12px; }
}
@media (min-width: 768px) and (max-width: 1024px) {
    .test-card { width: min(900px, 100% - 48px); }
    .answer-card { min-height: 84px; }
    .question-title { font-size: 25px; }
}
