/* ═══════════════════════════════════════════════════
   РадиоЭкзамен — стили
   Vanilla CSS, без внешних зависимостей
   ═══════════════════════════════════════════════════ */

:root {
  --bg:         #f0f4f8;
  --card:       #ffffff;
  --text:       #1e293b;
  --text-muted: #64748b;
  --border:     #e2e8f0;
  --primary:    #2563eb;
  --primary-lt: #eff6ff;
  --primary-dk: #1d4ed8;
  --success:    #16a34a;
  --success-lt: #f0fdf4;
  --error:      #dc2626;
  --error-lt:   #fef2f2;
  --warn:       #d97706;
  --warn-lt:    #fffbeb;

  /* Категории */
  --c4: #16a34a;  /* зелёный  — Entry  */
  --c3: #2563eb;  /* синий    — Novice */
  --c2: #d97706;  /* оранжевый — HAREC Base */
  --c1: #7c3aed;  /* фиолетовый — HAREC Full */

  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 20px;
  --shadow:   0 1px 3px rgba(0,0,0,.07), 0 6px 20px rgba(0,0,0,.06);
  --shadow-lg:0 4px 6px rgba(0,0,0,.07), 0 12px 40px rgba(0,0,0,.1);

  --duration: .18s;
}

/* ── Сброс и базовые стили ───────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Утилиты ─────────────────────────────────────── */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px;
}

.card {
  background: var(--card);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow);
  padding: 28px;
}

/* #app-root занимает всё пространство между header и footer */
#app-root {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Обёртка главной страницы — центрирует контент по вертикали */
.home-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  width: 100%;
  padding: 24px 0;
}

.text-muted { color: var(--text-muted); font-size: .9rem; }
.text-sm    { font-size: .875rem; }
.text-lg    { font-size: 1.15rem; }
.fw-600     { font-weight: 600; }
.mt-8  { margin-top:  8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom:  8px; }
.mb-16 { margin-bottom: 16px; }

/* ── Шапка ───────────────────────────────────────── */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo span { color: var(--primary); }

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--text-muted);
  font-size: .875rem;
  cursor: pointer;
  transition: color var(--duration), border-color var(--duration), background var(--duration);
  margin-left: auto;
}
.back-btn:hover {
  color: var(--text);
  border-color: var(--text);
  background: var(--bg);
}

/* ── Кнопки ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 22px;
  border-radius: var(--radius-m);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--duration);
  text-align: center;
  white-space: nowrap;
  line-height: 1.3;
  user-select: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-dk);
  border-color: var(--primary-dk);
  box-shadow: 0 4px 12px rgba(37,99,235,.35);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover {
  background: var(--primary-lt);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--bg);
  color: var(--text);
}

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover {
  background: #15803d;
  border-color: #15803d;
  transform: translateY(-1px);
}

.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 8px 16px; font-size: .875rem; border-radius: var(--radius-s); }

/* ── Главная страница ────────────────────────────── */
.hero {
  text-align: center;
  padding: 0 0 24px;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.2;
}

.hero h1 em {
  font-style: normal;
  color: var(--primary);
}

.hero p {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-top: 10px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.hero-badge {
  display: inline-block;
  background: var(--primary-lt);
  color: var(--primary);
  font-size: .8rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 100px;
  margin-bottom: 16px;
  letter-spacing: .02em;
}

/* Сетка категорий */
.cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 0;
}

@media (max-width: 480px) {
  .cat-grid { grid-template-columns: 1fr; }
}

/* Карточка категории */
.cat-card {
  background: var(--card);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--duration), box-shadow var(--duration), border-color var(--duration);
  text-align: left;
  width: 100%;
  display: block;
}

.cat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.cat-card-header {
  height: 6px;
}

.cat-card-body {
  padding: 20px;
}

.cat-card-num {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1;
}

.cat-card-label {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-top: 2px;
}

.cat-card-name {
  font-weight: 600;
  font-size: 1rem;
  margin-top: 10px;
  color: var(--text);
}

.cat-card-meta {
  font-size: .82rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.cat-card-progress {
  margin-top: 14px;
}

/* Маленький прогресс-бар на карточке */
.mini-bar {
  height: 5px;
  background: var(--border);
  border-radius: 100px;
  overflow: hidden;
  margin-top: 6px;
}
.mini-bar-fill {
  height: 100%;
  border-radius: 100px;
  transition: width .6s ease;
}

.cat-progress-text {
  font-size: .78rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

/* Цвета по категориям */
.cat-4 { color: var(--c4); }
.cat-3 { color: var(--c3); }
.cat-2 { color: var(--c2); }
.cat-1 { color: var(--c1); }
.bg-c4 { background: var(--c4); }
.bg-c3 { background: var(--c3); }
.bg-c2 { background: var(--c2); }
.bg-c1 { background: var(--c1); }

.cat-card.cat-4:hover { border-color: var(--c4); }
.cat-card.cat-3:hover { border-color: var(--c3); }
.cat-card.cat-2:hover { border-color: var(--c2); }
.cat-card.cat-1:hover { border-color: var(--c1); }

/* ── Страница категории ───────────────────────────── */
.page { padding: 32px 0 48px; }

.cat-page-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.cat-badge {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-m);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.cat-page-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; }
.cat-page-sub   { color: var(--text-muted); font-size: .9rem; margin-top: 3px; }

.info-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 20px 0;
}

.info-box {
  background: var(--bg);
  border-radius: var(--radius-m);
  padding: 16px;
  text-align: center;
}

.info-box-val {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.03em;
}

.info-box-lbl {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}

@media (max-width: 400px) {
  .action-row { grid-template-columns: 1fr; }
  .info-row   { grid-template-columns: 1fr 1fr; }
}

.desc-card {
  background: var(--bg);
  border-radius: var(--radius-m);
  padding: 16px 20px;
  border-left: 3px solid var(--primary);
  font-size: .9rem;
}

/* История сессий */
.sessions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.session-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--radius-s);
  font-size: .875rem;
}

.session-score {
  font-weight: 700;
  font-size: 1rem;
}

.session-date { color: var(--text-muted); font-size: .8rem; margin-left: auto; }

/* ── Тест ─────────────────────────────────────────── */
.test-progress-bar {
  height: 5px;
  background: var(--border);
  width: 100%;
}

.test-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  transition: width .4s cubic-bezier(.4,0,.2,1);
}

.test-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
}

.test-counter {
  font-size: .875rem;
  color: var(--text-muted);
}

.test-topic-badge {
  font-size: .75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
  background: var(--primary-lt);
  color: var(--primary);
}

.question-card {
  margin: 0 0 16px;
}

.question-text {
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1.55;
  margin-bottom: 20px;
}

/* Иллюстрация к вопросу */
.question-img {
  margin: 0 0 20px;
  text-align: center;
}
.question-img img {
  max-width: 100%;
  max-height: 260px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* Кнопки вариантов ответа */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--card);
  text-align: left;
  cursor: pointer;
  font-size: .95rem;
  line-height: 1.5;
  color: var(--text);
  transition: border-color var(--duration), background var(--duration), box-shadow var(--duration), transform .1s;
  font-family: inherit;
}

.option-btn:not(:disabled):hover {
  border-color: var(--primary);
  background: var(--primary-lt);
  box-shadow: 0 2px 8px rgba(37,99,235,.12);
}

.option-btn:not(:disabled):active {
  transform: scale(.99);
}

.option-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 50%;
  background: var(--bg);
  font-weight: 700;
  font-size: .8rem;
  color: var(--text-muted);
  transition: background var(--duration), color var(--duration);
}

.option-btn:not(:disabled):hover .option-letter {
  background: var(--primary);
  color: #fff;
}

/* После ответа */
.option-btn.correct {
  border-color: var(--success);
  background: var(--success-lt);
  color: #14532d;
}
.option-btn.correct .option-letter {
  background: var(--success);
  color: #fff;
}

.option-btn.wrong {
  border-color: var(--error);
  background: var(--error-lt);
  color: #7f1d1d;
}
.option-btn.wrong .option-letter {
  background: var(--error);
  color: #fff;
}

.option-btn.dim {
  opacity: .45;
}

.option-btn:disabled { cursor: default; }

/* Объяснение после ответа */
.answer-feedback {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--radius-s);
  font-size: .9rem;
  font-weight: 500;
  margin-top: 12px;
  animation: fadeIn .2s ease;
}

.answer-feedback.ok  { background: var(--success-lt); color: #15803d; border-left: 3px solid var(--success); }
.answer-feedback.err { background: var(--error-lt);   color: #b91c1c; border-left: 3px solid var(--error);  }

/* Нижняя панель теста */
.test-footer {
  padding: 16px 0 40px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Результаты ───────────────────────────────────── */
.score-block {
  text-align: center;
  padding: 32px 0 20px;
}

.score-ring {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -.04em;
  margin-bottom: 16px;
  position: relative;
}

.score-ring.pass {
  background: var(--success-lt);
  color: var(--success);
  box-shadow: 0 0 0 5px rgba(22,163,74,.15);
}

.score-ring.fail {
  background: var(--error-lt);
  color: var(--error);
  box-shadow: 0 0 0 5px rgba(220,38,38,.12);
}

.score-verdict {
  font-size: 1.2rem;
  font-weight: 700;
}

.score-sub {
  color: var(--text-muted);
  font-size: .9rem;
  margin-top: 4px;
}

/* Секция аналитики */
.section-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.topic-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topic-row {
  display: grid;
  grid-template-columns: 110px 1fr 48px;
  align-items: center;
  gap: 10px;
  font-size: .875rem;
}

.topic-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topic-bar-wrap {
  background: var(--border);
  border-radius: 100px;
  height: 10px;
  overflow: hidden;
}

.topic-bar-fill {
  height: 100%;
  border-radius: 100px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}

.topic-pct {
  font-weight: 600;
  font-size: .82rem;
  text-align: right;
  color: var(--text-muted);
}

/* Список вопросов для повторения */
.wrong-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.wrong-item {
  background: var(--bg);
  border-radius: var(--radius-s);
  padding: 10px 14px;
  font-size: .875rem;
}

.wrong-item-id {
  font-size: .75rem;
  font-weight: 700;
  color: var(--error);
  margin-bottom: 2px;
}

/* Кнопки результатов */
.results-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 48px;
}

/* ── Загрузка ─────────────────────────────────────── */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 40vh;
  gap: 16px;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── Анимации ─────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-6px); }
  40%     { transform: translateX(6px); }
  60%     { transform: translateX(-4px); }
  80%     { transform: translateX(4px); }
}

@keyframes pulse {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.04); }
}

.anim-fadein    { animation: fadeInUp .25s ease both; }
.anim-shake     { animation: shake .4s ease; }
.anim-pulse     { animation: pulse .3s ease; }

/* Задержки для cascade-эффекта */
.anim-d1 { animation-delay: .05s; }
.anim-d2 { animation-delay: .10s; }
.anim-d3 { animation-delay: .15s; }
.anim-d4 { animation-delay: .20s; }

/* ── Разделитель ────────────────────────────────── */
hr.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* ── Подвал ───────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 20px;
  font-size: .78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--card);
}
