/* Тема сайту pdr-test.com.ua для сторінки тестів: скло, Geologica, кольори як на старому test.php.
   Підключається після style.css і test.css, логіку й розмітку тестів не змінює. */

body.test-page {
  --bg: #e8edf6; --ink: #111827; --muted: #64748b; --blue: #2563eb; --blue-dark: #1d4ed8;
  --green: #059669; --red: #dc2626;
  --accent: var(--blue); --accent-dark: var(--blue-dark); --line: rgba(37, 99, 235, .15);
  --ok: var(--green); --bad: var(--red);
  font-family: 'Geologica', system-ui, sans-serif; color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(at 15% 10%, rgba(96, 165, 250, .28) 0, transparent 50%),
    radial-gradient(at 85% 5%, rgba(139, 92, 246, .22) 0, transparent 45%);
  background-attachment: fixed;
  min-height: 100dvh; display: flex; flex-direction: column;
}
body.test-page button, body.test-page input { font-family: inherit; }

/* ---------- Шапка сайту: спільна для всіх сторінок, /assets/app.css ---------- */
body.test-page .site-nav.t-top { display: block; padding: 10px 0; padding-top: max(10px, calc(env(safe-area-inset-top) + var(--pdr-tg-top, 0px))); }
body.test-page .card::before { display: none; } /* «ручка» потрібна лише шторці 3D-тренажера */

/* ---------- Картки-скло ---------- */
body.test-page .t-main { max-width: 860px; width: 100%; padding: 16px 16px 24px; flex: 1; }
body.test-page .card {
  background: rgba(255, 255, 255, .55);
  backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, .6); border-radius: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .06), 0 16px 48px rgba(0, 0, 0, .08), inset 0 1px 0 rgba(255, 255, 255, .7);
  padding: 20px;
}
body.test-page .ornament { display: none; }
body.test-page .t-hero h1 { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
body.test-page .t-lead { color: var(--muted); }

.t-mode {
  background: rgba(255, 255, 255, .6); border: 1px solid rgba(255, 255, 255, .7); border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7);
}
.t-mode-exam { background: rgba(37, 99, 235, .06); border-color: rgba(37, 99, 235, .25); }
.t-mode h2, .t-topics-head h2 { font-weight: 800; }

/* ---------- Кнопки ---------- */
body.test-page .cta {
  background: var(--blue); color: #fff; border: 0; border-radius: 12px; font-weight: 700;
  box-shadow: 0 6px 18px rgba(37, 99, 235, .3); transition: .15s;
}
@media (hover: hover) { body.test-page .cta:hover { background: var(--blue-dark); transform: translateY(-1px); } }
body.test-page .ghost {
  background: rgba(255, 255, 255, .6); border: 1px solid rgba(37, 99, 235, .15); border-radius: 12px;
  color: var(--muted); font-weight: 600;
}
@media (hover: hover) { body.test-page .ghost:hover:not(:disabled) { border-color: rgba(37, 99, 235, .35); color: var(--blue); } }

/* ---------- Теми ---------- */
.t-search { background: rgba(255, 255, 255, .75); border: 1px solid rgba(37, 99, 235, .15); border-radius: 12px; }
.t-search:focus { border-color: var(--blue); }
.t-list button {
  background: rgba(255, 255, 255, .7); border: 2px solid rgba(37, 99, 235, .12); border-radius: 12px; transition: .2s;
}
@media (hover: hover) { .t-list button:hover:not(:disabled) { background: rgba(37, 99, 235, .06); border-color: rgba(37, 99, 235, .35); transform: translateY(-1px); } }
.t-code { color: var(--blue); }
.t-count { background: rgba(37, 99, 235, .08); color: var(--blue); }

/* ---------- Питання ---------- */
.t-quiz-title { font-weight: 700; }
.t-timer, .t-progress { background: rgba(37, 99, 235, .1); color: var(--blue); }
.t-timer.t-warn { background: rgba(220, 38, 38, .1); color: var(--red); }
.t-grid button { background: rgba(255, 255, 255, .7); border: 2px solid rgba(37, 99, 235, .15); color: var(--muted); }
.t-grid button.done { background: rgba(37, 99, 235, .12); border-color: rgba(37, 99, 235, .4); color: var(--blue); }
.t-grid button.ok { background: rgba(5, 150, 105, .14); border-color: rgba(5, 150, 105, .5); color: #065f46; }
.t-grid button.bad { background: rgba(220, 38, 38, .1); border-color: rgba(220, 38, 38, .45); color: #991b1b; }
.t-grid button.cur { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--blue); }
.t-meta { color: var(--blue); font-weight: 700; }
.t-figure img { background: rgba(255, 255, 255, .4); border-radius: 14px; }
.t-question { font-size: 18px; font-weight: 700; line-height: 1.3; }

/* варіанти: кружок-перемикач ліворуч, як на сайті */
.t-options button {
  background: rgba(255, 255, 255, .7); border: 2px solid rgba(37, 99, 235, .15); border-radius: 12px;
  font-size: 14px; line-height: 1.3; color: var(--ink); transition: .2s;
}
@media (hover: hover) { .t-options button:hover:not(:disabled) { background: rgba(37, 99, 235, .06); border-color: rgba(37, 99, 235, .35); transform: translateY(-1px); } }
.t-options .num {
  width: 16px; height: 16px; font-size: 0; background: rgba(255, 255, 255, .8);
  border: 2px solid rgba(37, 99, 235, .25); transition: .2s;
}
@media (hover: hover) { .t-options button:hover:not(:disabled) .num { border-color: var(--blue); } }
.t-options button.picked { background: rgba(37, 99, 235, .08); border-color: rgba(37, 99, 235, .5); }
.t-options button.picked .num { border-color: var(--blue); background: var(--blue); box-shadow: inset 0 0 0 3px #fff; }
.t-options button.ok { background: rgba(5, 150, 105, .14); border-color: rgba(5, 150, 105, .5); color: #065f46; }
.t-options button.ok .num { border-color: var(--green); background: var(--green); box-shadow: inset 0 0 0 3px #fff; }
.t-options button.bad { background: rgba(239, 68, 68, .1); border-color: rgba(239, 68, 68, .45); color: #991b1b; }
.t-options button.bad .num { border-color: #ef4444; background: #ef4444; box-shadow: inset 0 0 0 3px #fff; }

/* ---------- Результат ---------- */
.t-result { text-align: left; }
.t-result::before { content: "📚"; display: block; font-size: 56px; margin-bottom: 8px; }
.t-result.t-pass::before { content: "🏆"; }
.t-result.t-fail::before { content: "💪"; }
.t-verdict { font-size: 24px; font-weight: 800; }
.t-pass .t-verdict { color: var(--green); }
.t-fail .t-verdict { color: var(--red); }
.t-result .t-lead { font-size: 16px; }
.t-actions { justify-content: flex-start; }
.t-result .t-lead, .t-result .t-rule { max-width: 42em; }
.t-sub { font-weight: 800; }

.t-review > li { border: 1px solid rgba(0, 0, 0, .07); border-radius: 12px; background: rgba(255, 255, 255, .6); }
.t-review > li.is-ok { border: 1px solid rgba(5, 150, 105, .3); background: rgba(5, 150, 105, .04); }
.t-review > li.is-bad { border: 1px solid rgba(220, 38, 38, .3); background: rgba(220, 38, 38, .04); }
.t-review img { width: 120px; border-radius: 8px; }
.t-review-q { font-weight: 700; font-size: 14px; }
.t-given { font-size: 13px; color: #991b1b; font-weight: 600; background: rgba(220, 38, 38, .08); padding: 6px 10px; border-radius: 8px; }
.t-right { font-size: 13px; color: #166534; font-weight: 600; background: rgba(22, 163, 74, .1); padding: 6px 10px; border-radius: 8px; }
.t-review .t-expl { font-size: 13px; color: #1e3a5f; line-height: 1.6; background: rgba(59, 130, 246, .07); padding: 10px 12px; border-radius: 8px; }
.t-review .refs { color: var(--blue); font-weight: 600; }

.t-source { color: var(--muted); }
.t-source a { color: var(--blue); }

.site-foot { padding: 16px; text-align: center; color: var(--muted); font-size: 12px; }
.site-foot a { color: var(--blue); text-decoration: none; }
body.in-quiz .site-foot { display: none; }

/* ---------- Екран питання: рівно на висоту пристрою, сторінка не прокручується ----------
   Ілюстрація забирає вільне місце і стискається; питання, відповіді й кнопки завжди на екрані. */
body.test-page.in-quiz { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
body.test-page.in-quiz .t-main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding-top: 12px; padding-bottom: 12px; }
body.test-page.in-quiz .t-quiz {
  flex: 1 1 auto; min-height: 0; height: auto;
  display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto; overscroll-behavior: contain; /* запас на дуже низькі екрани */
}
body.test-page.in-quiz .t-quiz > * { flex: none; }
/* ілюстрація в натуральну висоту на всю ширину; якщо місця бракує — стискається (але не менше 96 px) */
body.test-page.in-quiz .t-quiz > .t-figure {
  flex: 0 1 auto; min-height: 96px; max-height: 62vh; max-height: 62dvh;
  margin: 0; display: flex; flex-direction: row; justify-content: center; align-items: flex-start; gap: 6px;
}
body.test-page.in-quiz .t-figure img {
  flex: 1 1 0; min-width: 0; width: 100%; height: auto; max-width: 100%; max-height: 100%;
  aspect-ratio: auto; object-fit: contain; background: transparent;
}
body.test-page.in-quiz .t-figure figcaption { display: none; }
/* вільне місце — між відповідями й кнопками */
body.test-page.in-quiz .t-quiz > .t-spacer { flex: 1 1 0; }
body.test-page.in-quiz .t-question { margin: 2px 0 0; }
body.test-page.in-quiz .t-grid { padding-top: 4px; padding-bottom: 2px; }
body.test-page.in-quiz .t-nav { margin-top: 0; }
/* варіанти відповіді — не нижчі за 50 px, щоб зручно влучати пальцем */
body.test-page .t-options button { min-height: 50px; align-items: center; }
/* «Завершити» іспит — маленька кнопка в шапці поруч із таймером */
body.test-page .t-quiz-head .t-finish {
  flex: none; margin: 0; padding: 6px 12px; font-size: 13px; font-weight: 700;
  color: var(--blue); border-color: rgba(37, 99, 235, .35);
}
@media (max-width: 700px) {
  body.test-page .t-quiz-head .t-finish { padding: 4px 10px; font-size: 12px; }
  /* номери питань — одна стрічка, яку гортають пальцем */
  body.test-page .t-quiz .t-grid,
  body.test-page .t-quiz .t-grid.fit,
  body.test-page .t-quiz .t-grid.fit-m {
    display: flex; gap: 6px; padding: 4px 2px 6px; margin: 0 -12px; padding-left: 12px; padding-right: 12px;
    overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity; scroll-padding: 0 12px; scrollbar-width: none; touch-action: pan-x;
  }
  body.test-page .t-quiz .t-grid::-webkit-scrollbar { display: none; }
  /* м'яко розмиті краї стрічки — лише з того боку, куди ще можна гортати (класи ставить test.js) */
  body.test-page .t-quiz .t-grid {
    --fade-l: 0px; --fade-r: 0px;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
    mask-image: linear-gradient(90deg, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
  }
  body.test-page .t-quiz .t-grid.fade-l { --fade-l: 44px; }
  body.test-page .t-quiz .t-grid.fade-r { --fade-r: 44px; }
  body.test-page .t-quiz .t-grid button {
    flex: none; width: 40px; height: 40px; min-width: 40px; padding: 0;
    border-radius: 11px; font-size: 14px; scroll-snap-align: center;
  }
}

/* невисокі вікна комп'ютера й планшета: без шапки на час тесту і компактніше */
@media (min-width: 701px) and (max-height: 820px) {
  body.test-page.in-quiz .site-nav { display: none; }
  body.test-page.in-quiz .t-main { padding-top: 8px; padding-bottom: 8px; }
  body.test-page.in-quiz .t-quiz { padding: 12px 18px; gap: 6px; }
  body.test-page.in-quiz .t-grid button { height: 28px; font-size: 12px; }
  body.test-page.in-quiz .t-question { font-size: 16px; line-height: 1.3; }
  body.test-page.in-quiz .t-options { gap: 5px; }
  body.test-page.in-quiz .t-options button { padding: 8px 12px; font-size: 14px; line-height: 1.25; }
  body.test-page.in-quiz .t-nav .cta { padding: 10px; }
  body.test-page.in-quiz .t-quiz > .t-figure { min-height: 80px; }
}

@media (max-width: 700px) {
  body.test-page.in-quiz .site-nav { display: none; }
  body.test-page.in-quiz .t-main { padding: 0; }
  body.test-page.in-quiz .t-quiz {
    gap: 6px; border: 0; border-radius: 0; box-shadow: none;
    padding: max(8px, calc(env(safe-area-inset-top) + var(--pdr-tg-top, 0px))) 12px max(8px, env(safe-area-inset-bottom));
  }
  body.test-page.in-quiz .t-quiz > .t-figure { max-height: none; }
}

@media (max-width: 600px) {
  .t-question { font-size: 16px; }
  .t-options button { font-size: 13px; }
  .t-review img { width: 100%; }
}
