/* =====================================================================
   Ferrum Voluntatis — стиль за презентацією книги «Хід Ферзя»:
   фіолетово-графітова готика, бежеве золото написів, кров'яний акцент.
   ===================================================================== */

/* ===== Токени ===== */
:root {
    --bg: #141217;
    --bg-violet: #2e2a36;        /* холодний фіолетово-сірий фону презентації */
    --surface: rgba(24, 22, 28, .88);
    --surface-2: #211e26;
    --surface-3: #2a2630;
    --border: #3b3542;
    --text: #e9dfca;             /* пергамент */
    --muted: #a39a8b;
    --accent: #cdb68a;           /* бежеве золото «МАГІЯ ВСЕСВІТУ» */
    --accent-strong: #e5d1a5;
    --accent-ink: #1a1510;
    --accent-line: rgba(205, 182, 138, .28);
    --blood: #8f1d20;            /* кров з обкладинки */
    --blood-strong: #b4282c;
    --blood-soft: rgba(143, 29, 32, .16);

    --font-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
    --font-caps: "Oswald", "Arial Narrow", Impact, sans-serif;
    --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;

    --radius: 6px;
    --radius-sm: 4px;
    --ease: cubic-bezier(.23, 1, .32, 1);

    /* орнаменти (SVG) */
    --ornament-divider: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='18' viewBox='0 0 140 18' fill='none' stroke='rgb(205,182,138)' stroke-width='1'%3E%3Cpath d='M0 9H52M88 9H140'/%3E%3Ccircle cx='56' cy='9' r='1.5' fill='rgb(205,182,138)'/%3E%3Ccircle cx='84' cy='9' r='1.5' fill='rgb(205,182,138)'/%3E%3Cpath d='M70 1L78 9L70 17L62 9Z'/%3E%3Cpath d='M70 5V13M66 9H74' stroke='rgb(180,40,44)'/%3E%3C/svg%3E");
    --arch: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 1400' fill='none' stroke='rgb(205,182,138)' stroke-opacity='.07' stroke-width='2'%3E%3Cpath d='M150 1400V700A560 560 0 0 1 600 60A560 560 0 0 1 1050 700V1400'/%3E%3Cpath d='M210 1400V710A500 500 0 0 1 600 130A500 500 0 0 1 990 710V1400'/%3E%3Cpath d='M380 1400V820A300 300 0 0 1 600 420A300 300 0 0 1 820 820V1400'/%3E%3Ccircle cx='600' cy='330' r='60'/%3E%3Ccircle cx='600' cy='330' r='38'/%3E%3Cpath d='M600 270V390M540 330H660'/%3E%3C/svg%3E");
}

/* ===== База ===== */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background:
        var(--arch) center top / min(1200px, 160vw) auto no-repeat,
        radial-gradient(900px 700px at 50% 0%, rgba(70, 62, 84, .55), transparent 70%),
        radial-gradient(ellipse at 50% 120%, rgba(0, 0, 0, .7), transparent 60%),
        linear-gradient(180deg, var(--bg-violet) 0%, var(--bg) 55%);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ===== Шапка / підвал ===== */
.header {
    padding: 48px 16px 40px;
    text-align: center;
}
.header__kicker {
    display: block;
    font-family: var(--font-caps);
    font-weight: 600;
    font-size: clamp(15px, 2.6vw, 20px);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 4px;
}
.header__title {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(42px, 9vw, 72px);
    line-height: 1.05;
    letter-spacing: .02em;
    color: var(--accent-strong);
    text-shadow: 0 2px 24px rgba(0, 0, 0, .6);
}

.main {
    flex: 1;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 0 16px;
}

.footer {
    padding: 28px 16px 36px;
    text-align: center;
    font-family: var(--font-caps);
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    font-size: 12px;
}

/* ===== Картка: подвійна рамка, як на обкладинці ===== */
.card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 44px;
    min-height: 480px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(255, 255, 255, .03);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}
.card::before {             /* внутрішня рамка */
    content: "";
    position: absolute;
    inset: 8px;
    border: 1px solid var(--accent-line);
    border-radius: 2px;
    pointer-events: none;
}
@media (max-width: 639px) {
    .card { padding: 32px 20px 24px; min-height: 420px; }
    .card::before { inset: 6px; }
    .answer { padding: 12px 14px; gap: 12px; }
}

.card__body {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ===== Прогрес ===== */
.progress { position: relative; margin-bottom: 28px; }
.progress[hidden] { display: none; }
.progress__meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-family: var(--font-caps);
    font-size: 13px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--muted);
}
.progress__text { font-variant-numeric: tabular-nums; }
.progress__track {
    height: 3px;
    background: var(--surface-3);
    overflow: hidden;
}
.progress__bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--blood), var(--blood-strong));
    box-shadow: 0 0 10px rgba(180, 40, 44, .6);
    transition: width .45s var(--ease);
}

/* ===== Екрани ===== */
.step {
    flex: 1;
    display: flex;
    flex-direction: column;
    animation: stepIn .45s var(--ease);
}
.step--intro {
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 24px;
}
@keyframes stepIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

.step__question.intro__title {
    margin: 0;
    max-width: 18ch;
    font-size: clamp(30px, 5.4vw, 40px);
    line-height: 1.15;
}
.intro__title[hidden] { display: none; }

/* орнамент-розділювач замість символу */
.sigil {
    width: 140px;
    height: 18px;
    background: var(--ornament-divider) center / contain no-repeat;
    font-size: 0;
}

.step__lead {
    margin: 0;
    max-width: 50ch;
    font-family: var(--font-display);
    font-size: clamp(20px, 3.2vw, 23px);
    font-weight: 500;
    line-height: 1.45;
    color: var(--text);
}

.step__question {
    margin: 0 0 22px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(25px, 4.4vw, 32px);
    line-height: 1.2;
    color: var(--accent-strong);
    outline: none;
}

/* ===== Відповіді ===== */
.answers {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.answer {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    width: 100%;
    padding: 13px 16px;
    text-align: left;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color .2s var(--ease), background-color .2s var(--ease), transform .2s var(--ease);
}
.answer:active { transform: scale(.99); }
.answer:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.answer[disabled] { cursor: default; }

.answer__letter {                   /* буква рівно по центру, ромб — окремим шаром */
    position: relative;
    flex: none;
    width: 30px; height: 30px;
    margin-top: -2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-caps);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    color: var(--accent);
}
.answer__letter::before {
    content: "";
    position: absolute;
    inset: 5px;
    border: 1px solid var(--accent-line);
    transform: rotate(45deg);
    transition: background-color .2s var(--ease), border-color .2s var(--ease);
    z-index: -1;
}
.answer__letter { isolation: isolate; }
.answer__text { padding-top: 1px; }

.answer.is-selected {
    border-color: var(--blood-strong);
    background: var(--blood-soft);
}
.answer.is-selected .answer__letter { color: var(--accent-strong); }
.answer.is-selected .answer__letter::before {
    background: var(--blood);
    border-color: var(--blood-strong);
}

/* ===== Кнопки ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 54px;
    padding: 14px 36px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font-caps);
    font-weight: 500;
    font-size: 17px;
    letter-spacing: .14em;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform .25s var(--ease), box-shadow .25s var(--ease), background-color .2s, border-color .2s, color .2s;
}
.btn--primary {
    background: var(--accent);
    color: var(--accent-ink);
    min-width: min(280px, 100%);
    box-shadow: inset 0 0 0 3px var(--accent), inset 0 0 0 4px var(--accent-ink);
}
.btn--primary:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 3px; }

.btn--ghost {
    margin-top: 12px;
    background: transparent;
    border-color: var(--accent-line);
    color: var(--accent);
}
.btn--ghost:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.link-btn {
    background: none;
    border: 0;
    padding: 4px 0;
    color: var(--muted);
    cursor: pointer;
    font-family: var(--font-caps);
    letter-spacing: .1em;
    text-transform: uppercase;
    font-size: 13px;
}
.link-btn[hidden] { display: none; }
.link-btn:disabled { visibility: hidden; }

/* ===== Результат ===== */
.step--result {
    align-items: center;
    text-align: center;
    gap: 14px;
    padding: 8px 0;
}
.result__media {
    margin: 0 0 8px;
    width: 100%;
    max-width: 360px;
    aspect-ratio: 1;
    overflow: hidden;
    border: 1px solid var(--accent-line);
    outline: 1px solid var(--accent-line);
    outline-offset: 5px;
    background: var(--surface-2);
}
.result__media[hidden], .step--result .sigil { display: none; }
.result__image { width: 100%; height: 100%; object-fit: cover; display: block; }
.result__label {
    margin: 0;
    font-family: var(--font-caps);
    font-weight: 600;
    font-size: 15px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--accent);
}
.result__title {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(42px, 8vw, 64px);
    line-height: 1.05;
    color: var(--accent-strong);
    text-shadow: 0 2px 24px rgba(0, 0, 0, .6);
    outline: none;
}
.result__title::after {
    content: "";
    display: block;
    width: 140px;
    height: 18px;
    margin: 18px auto 6px;
    background: var(--ornament-divider) center / contain no-repeat;
}
.result__text {
    max-width: 56ch;
    text-align: left;
    font-size: 17px;
}
.result__text p { margin: 0 0 1em; }
.result__text p:last-child { margin-bottom: 0; }

/* Hover лише для пристроїв з курсором — на тач-екранах :hover "залипає" після тапу */
@media (hover: hover) and (pointer: fine) {
    .answer:hover { border-color: var(--accent); background: var(--surface-3); }
    .btn--primary:hover { background: var(--accent-strong); box-shadow: inset 0 0 0 3px var(--accent-strong), inset 0 0 0 4px var(--accent-ink), 0 10px 28px -10px rgba(205, 182, 138, .5); transform: translateY(-1px); }
    .btn--ghost:hover { border-color: var(--accent); color: var(--accent-strong); }
    .link-btn:hover { color: var(--accent); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
