/* Диагностический тест со свободным вводом ответа.
   Вся визуальная система берётся из site.css + topic-test.css + moodle-question.css,
   как на /tasks/ege-basic-real/. Здесь только то, чего у того теста нет:
   блок «имя + согласие», подсказка к формату ответа, предупреждение о пропусках
   и состояние ожидания серверного результата. */

/* Атрибут hidden скрывает через UA-стиль, а любое авторское display его
   перебивает (.button{display:inline-flex}, .result-numbers{display:grid}).
   Правило ограничено этой страницей и возвращает hidden его смысл. */
.diag-free-page [hidden] { display: none !important; }

/* --- Имя ученика и согласие --- */
.diag-identity {
  margin-bottom: 26px;
  padding: clamp(22px, 3.5vw, 30px);
  border: 1px solid var(--line);
  border-left: 5px solid var(--primary);
  border-radius: 22px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.diag-identity > h2 {
  margin: 0 0 16px;
  font-size: clamp(1.2rem, 2.4vw, 1.5rem);
  letter-spacing: -.02em;
}

.diag-field { display: grid; gap: 7px; max-width: 420px; }
.diag-field label { font-weight: 800; color: var(--secondary); }
.diag-field input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid #abc7da;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}
.diag-field input:focus { border-color: var(--primary); outline: 3px solid rgba(21, 126, 192, .14); }
.diag-field input[aria-invalid="true"] { border-color: #cc6d6d; }
.diag-field-error { margin: 8px 0 0; color: #b4453f; font-size: .85rem; font-weight: 700; }

.diag-consent {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  margin-top: 18px;
  padding: 14px 15px;
  border: 1px solid #c8dbe8;
  border-radius: 14px;
  background: #fbfdff;
  cursor: pointer;
  line-height: 1.5;
}
.diag-consent input { flex: 0 0 auto; width: 20px; height: 20px; margin-top: 2px; accent-color: var(--primary); }
.diag-consent span { font-size: .92rem; color: #304f68; }
.diag-privacy-link { margin: 8px 0 0 46px; font-size: .82rem; }

/* --- Длинные выключные формулы --- */
/* На узком экране формула задания 7 не помещается в карточку. SVG от MathJax
   ужимается по ширине (viewBox сохраняет пропорции), чтобы условие читалось
   целиком; скролл внутри контейнера остаётся страховкой. */
.diag-free-page .moodle-question-body mjx-container[display="true"] { max-width: 100%; overflow-x: auto; overflow-y: hidden; }
.diag-free-page .moodle-question-body mjx-container[display="true"] > svg { max-width: 100%; height: auto; }

/* --- Подсказка к формату ответа --- */
.topic-hint { margin: 9px 0 0; color: var(--muted); font-size: .85rem; line-height: 1.5; }

/* --- Источник заданий: мелко и ненавязчиво --- */
.diag-source { margin: 16px 0 0; max-width: 820px; color: var(--muted); font-size: .84rem; line-height: 1.6; }

/* --- Кнопка завершения --- */
.topic-submit .button[disabled] { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.diag-submit-note { margin: 10px 0 0; color: var(--muted); font-size: .85rem; text-align: center; }

/* --- Предупреждение о незаполненных заданиях --- */
.diag-warning {
  max-width: 760px;
  margin: 0 auto 18px;
  padding: 16px 18px;
  border: 1px solid #e6c98c;
  border-radius: 16px;
  background: #fffaf0;
  color: #6b4c14;
}
.diag-warning p { margin: 0 0 12px; }
.diag-warning__actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* --- Состояние отправки и итог --- */
.diag-status { margin: 0; color: var(--muted); }
.diag-status.is-error { color: #b4453f; font-weight: 700; }
.diag-errors { margin: 0 0 6px; color: var(--muted); }
.topic-result .result-numbers p { margin: 0; font-size: clamp(1rem, 2vw, 1.15rem); }
.topic-result .result-numbers strong { white-space: nowrap; font-size: clamp(1.35rem, 3vw, 1.8rem); }

/* --- Разбор: какие задания решены верно --- */
/* Правильные ответы не раскрываются, показывается только вердикт по каждому
   заданию; сами карточки подкрашиваются штатными .is-correct/.is-incorrect
   из topic-test.css. */
.topic-verdict {
  display: inline-flex;
  align-items: center;
  margin: 12px 0 0;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 800;
}
.topic-verdict.is-ok { background: #e6f7ee; color: #1d6b46; }
.topic-verdict.is-bad { background: #fdeceb; color: #b4453f; }
html[data-theme="dark"] .topic-verdict.is-ok { background: #102d20; color: #8fd9b2; }
html[data-theme="dark"] .topic-verdict.is-bad { background: #301c1c; color: #e9a8a4; }

/* --- Тёмная тема --- */
html[data-theme="dark"] .diag-identity { border-color: var(--line); background: var(--surface); }
html[data-theme="dark"] .diag-field input,
html[data-theme="dark"] .diag-consent { border-color: var(--line); background: #122838; color: var(--ink); }
html[data-theme="dark"] .diag-consent span { color: var(--muted); }
html[data-theme="dark"] .diag-warning { border-color: #7a6330; background: #2c2413; color: #edd8a6; }

/* --- Узкие экраны --- */
@media (max-width: 560px) {
  .diag-identity { border-radius: 17px; }
  .diag-warning__actions .button { width: 100%; }
}
@media (max-width: 380px) {
  .diag-identity { padding: 20px 16px; }
  .diag-consent { padding: 12px; }
}

/* --- Варианты ответа для задания с множественным выбором ---
   База — существующий компонент .lead-choice из site.css: та же рамка,
   та же подсветка отмеченного варианта, тот же фокус. Здесь только то,
   что нужно формулам: вариант занимает всю ширину строки и не сжимается
   в «таблетку», потому что MathJax отрисовывает дроби в две строки. */
.diag-choice-grid { display: grid; gap: 8px; margin: 4px 0 10px; }

.diag-choice.lead-choice {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: .95rem;
  font-weight: 600;
}

.diag-choice.lead-choice > span { display: inline-flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.diag-choice.lead-choice > span b { font-weight: 800; color: var(--primary-dark); }

html[data-theme="dark"] .diag-choice.lead-choice { border-color: var(--line); background: #122838; color: var(--ink); }
html[data-theme="dark"] .diag-choice.lead-choice:has(input:checked) { border-color: var(--primary); background: #1c4a68; }

@media (max-width: 560px) {
  .diag-choice.lead-choice { padding: 10px 12px; font-size: .9rem; }
}
