/* Аттестация менторов AiPlus — мобильный первым делом, светлая и тёмная темы */

:root {
  --bg: #f4f6fb;
  --bg-elevated: #ffffff;
  --surface-muted: #eef1f8;
  --border: #e2e6f0;
  --border-strong: #cdd4e4;

  --text: #131a2b;
  --text-muted: #5b6479;
  --text-faint: #8b93a7;

  --accent: #3b5bdb;
  --accent-hover: #2f4bc4;
  --accent-soft: #e8ecfd;
  --accent-contrast: #ffffff;

  --success: #12805c;
  --success-soft: #dff5ec;
  --danger: #c0392f;
  --danger-soft: #fdeceb;
  --warning: #9a6700;
  --warning-soft: #fff4d6;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 2px rgba(19, 26, 43, 0.06), 0 1px 3px rgba(19, 26, 43, 0.04);
  --shadow: 0 4px 16px rgba(19, 26, 43, 0.08);
  --shadow-lg: 0 12px 40px rgba(19, 26, 43, 0.12);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    'Noto Sans', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1220;
    --bg-elevated: #171d31;
    --surface-muted: #1e2540;
    --border: #262e4a;
    --border-strong: #37415f;

    --text: #eef1f8;
    --text-muted: #a3abc2;
    --text-faint: #7b849d;

    --accent: #7f97ff;
    --accent-hover: #94a8ff;
    --accent-soft: #232c4d;
    --accent-contrast: #0e1220;

    --success: #4ad4a4;
    --success-soft: #14342c;
    --danger: #ff8b80;
    --danger-soft: #3a1f1e;
    --warning: #ffc95c;
    --warning-soft: #33290f;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.55);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

p {
  margin: 0;
}

/* ---------- Шапка ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.brand-mark {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #7048e8);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-size: 15px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.lang-switch {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-muted);
  border-radius: 999px;
  border: 1px solid var(--border);
}

.lang-switch button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
  min-height: 34px;
}

.lang-switch button[aria-pressed='true'] {
  background: var(--bg-elevated);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.icon-button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  min-height: 38px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease;
}

.icon-button:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

/* ---------- Каркас ---------- */

main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px 56px;
}

.screen {
  display: none;
  animation: fade-in 0.28s ease;
}

.screen.is-active {
  display: block;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .screen,
  .option {
    animation: none !important;
    transition: none !important;
  }
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: var(--shadow-sm);
}

.card + .card {
  margin-top: 16px;
}

.card-title {
  font-size: 22px;
  font-weight: 680;
}

.card-hint {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- Формы ---------- */

.field {
  margin-top: 18px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 620;
  color: var(--text-muted);
  margin-bottom: 7px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* < 16px заставляет iOS Safari зумить форму при фокусе */
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  min-height: 50px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 19px) calc(50% + 2px), calc(100% - 14px) calc(50% + 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 40px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field select:disabled {
  background: var(--surface-muted);
  color: var(--text-faint);
  cursor: not-allowed;
}

.field-row {
  display: grid;
  gap: 0;
}

@media (min-width: 560px) {
  .field-row {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  .field-row .field {
    margin-top: 18px;
  }
}

/* ---------- Кнопки ---------- */

.btn {
  appearance: none;
  border: 0;
  font: inherit;
  font-weight: 650;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.18s ease, transform 0.12s ease, opacity 0.18s ease;
  min-height: 50px;
  padding: 14px 22px;
  font-size: 16px;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-ghost {
  background: var(--surface-muted);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-block {
  width: 100%;
  margin-top: 22px;
}

/* Главная кнопка старта — крупная, по центру, видна сразу */
.start-hero {
  text-align: center;
  padding: 36px 20px 40px;
}

.btn-hero {
  width: 100%;
  max-width: 420px;
  min-height: 68px;
  font-size: 19px;
  border-radius: var(--radius);
  box-shadow: 0 8px 28px color-mix(in srgb, var(--accent) 32%, transparent);
  margin-top: 8px;
}

.btn-hero:hover:not(:disabled) {
  box-shadow: 0 10px 32px color-mix(in srgb, var(--accent) 40%, transparent);
}

/* ---------- Карточки аттестаций на главной ---------- */

.test-card {
  margin-top: 16px;
}

.test-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.test-title {
  font-size: 19px;
  font-weight: 680;
}

.test-card .notice.is-info {
  margin: 0 0 14px;
}

.rule-step {
  color: var(--text);
  font-weight: 620;
}

/* Скрытый шаг «сначала видео» не должен оставлять отступ над правилом. */
.rule-box .rule-step[hidden] + p {
  margin-top: 0;
}

.test-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.test-actions .btn-hero {
  margin-top: 0;
}

.test-actions .btn-ghost {
  width: 100%;
  max-width: 420px;
}

.history-title {
  margin-top: 20px;
  font-weight: 650;
}

/* ---------- Видео ---------- */

.video-wrap {
  margin-top: 18px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
  aspect-ratio: 16 / 9;
}

.video-wrap video {
  display: block;
  width: 100%;
  height: 100%;
}

.btn-tight {
  margin-top: 10px;
}

/* Сцены для пересмотра на экране результата */
.result-scenes {
  margin-top: 18px;
}

.scene-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scene-link {
  appearance: none;
  width: 100%;
  font: inherit;
  font-size: 14px;
  text-align: left;
  color: var(--accent);
  background: var(--accent-soft);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  cursor: pointer;
}

.scene-link:hover {
  text-decoration: underline;
}

/* ---------- Открытые вопросы ---------- */

.field textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.5;
}

.open-field label {
  font-size: 15px;
  font-weight: 620;
  color: var(--text);
  line-height: 1.45;
}

.field textarea.is-invalid {
  border-color: var(--danger);
}

.open-counter {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-faint);
  text-align: right;
}

.open-counter.is-ok {
  color: var(--success);
}

/* ---------- Тест ---------- */

.quiz-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.quiz-counter {
  font-size: 14px;
  font-weight: 650;
  color: var(--text-muted);
}

/* У теста без тем плашку не показываем вовсе. */
.quiz-category:empty {
  display: none;
}

.quiz-category {
  font-size: 12px;
  font-weight: 650;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 5px 12px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}

.progress {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
  margin-bottom: 22px;
}

.progress-bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #7048e8);
  transition: width 0.35s ease;
}

.question-text {
  font-size: 20px;
  font-weight: 640;
  line-height: 1.4;
  margin-bottom: 20px;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 15px 16px;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
  min-height: 56px;
}

.option:hover {
  border-color: var(--accent);
}

.option[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option-marker {
  flex: none;
  width: 24px;
  height: 24px;
  margin-top: 1px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  display: grid;
  place-items: center;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.option[aria-pressed='true'] .option-marker {
  border-color: var(--accent);
  background: var(--accent);
}

.option[aria-pressed='true'] .option-marker::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-contrast);
}

/* ---------- Результат ---------- */

.result {
  text-align: center;
  padding: 32px 20px;
}

.result-badge {
  width: 84px;
  height: 84px;
  margin: 0 auto 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 40px;
}

.result-badge.is-pass {
  background: var(--success-soft);
  color: var(--success);
}

.result-badge.is-fail {
  background: var(--danger-soft);
  color: var(--danger);
}

.result-title {
  font-size: 24px;
  font-weight: 700;
}

.result-score {
  font-size: 52px;
  font-weight: 750;
  letter-spacing: -0.03em;
  margin: 18px 0 2px;
  font-variant-numeric: tabular-nums;
}

.result-score.is-pass {
  color: var(--success);
}

.result-score.is-fail {
  color: var(--danger);
}

.result-caption {
  color: var(--text-muted);
  font-size: 15px;
}

.result-meta {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
  gap: 28px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 14px;
}

.result-actions {
  margin-top: 26px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.result-actions .btn {
  width: 100%;
  max-width: 340px;
}

/* ---------- Мелочи ---------- */

.notice {
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-top: 16px;
  display: none;
}

.notice.is-visible {
  display: block;
}

.notice.is-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.notice.is-success {
  background: var(--success-soft);
  color: var(--success);
}

.notice.is-info {
  background: var(--accent-soft);
  color: var(--accent);
}

.rule-box {
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 15px;
  color: var(--text-muted);
  text-align: left;
}

.rule-box strong {
  color: var(--text);
}

.rule-box p + p {
  margin-top: 10px;
}

.history {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.history-date {
  color: var(--text-faint);
  font-size: 13px;
}

.badge {
  font-size: 12px;
  font-weight: 650;
  padding: 4px 11px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge.is-pass {
  background: var(--success-soft);
  color: var(--success);
}

.badge.is-fail {
  background: var(--danger-soft);
  color: var(--danger);
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 40px auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.footer-note {
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  padding: 0 16px 24px;
}

@media (min-width: 640px) {
  main {
    padding: 32px 24px 64px;
  }
  .card {
    padding: 30px 28px;
  }
  .card-title {
    font-size: 24px;
  }
  .question-text {
    font-size: 22px;
  }
}
