/* Анкета. Образ — школьная тетрадь: клетка на фоне, красная линия полей,
   синий цвет шариковой ручки как единственный акцент.
   Все размеры текста — не меньше 17 px (база 18 px). */

@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("/static/fonts/golos-text-cyrillic-wght.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("/static/fonts/golos-text-latin-wght.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --paper: #f6f8fb;      /* лист */
  --grid: #e4eaf2;       /* клетка */
  --sheet: #ffffff;      /* карточки и поля ввода */
  --ink: #172133;        /* текст */
  --ink-2: #4b5567;      /* второстепенный текст */
  --control: #6f7b8f;    /* рамки полей и отметок, ≥ 3:1 к фону */
  --line: #d3dbe6;       /* рамки карточек */
  --pen: #1f4fbf;        /* синяя ручка — акцент */
  --pen-ink: #ffffff;    /* текст на акценте */
  --pen-soft: #e8eefb;   /* выбранная карточка */
  --margin: #e3a6a1;     /* линия полей */
  --error: #b3261e;
  --radius: 12px;
  --gutter: 20px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #121722;
    --grid: #1a2230;
    --sheet: #1a2130;
    --ink: #e9edf4;
    --ink-2: #aeb7c6;
    --control: #8592a7;
    --line: #2d3748;
    --pen: #8fb0ff;
    --pen-ink: #0d1524;
    --pen-soft: #22304e;
    --margin: #7a4442;
    --error: #ff9b91;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  font-size: 112.5%; /* 18 px */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  -webkit-tap-highlight-color: transparent;
}

/* Лист тетради: колонка с линией полей справа */
.sheet {
  position: relative;
  max-width: 40rem;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 calc(var(--gutter) + 12px) 0 var(--gutter);
}
.sheet::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: 10px;
  border-right: 2px solid var(--margin);
  pointer-events: none;
}

h1, h2, p { margin: 0; }

:focus-visible { outline: 3px solid var(--pen); outline-offset: 2px; border-radius: 4px; }
[tabindex="-1"]:focus { outline: none; }

.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;
}

/* ---------- Титульный экран и экраны-сообщения ---------- */

.step-intro, .screen {
  padding: clamp(48px, 16vh, 140px) 0 48px;
}
.intro-title, .screen-title {
  font-size: clamp(2rem, 1.55rem + 2.2vw, 2.75rem);
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.intro-text {
  margin-top: 20px;
  font-size: 1.0556rem; /* 19 px */
  line-height: 1.55;
  max-width: 34em;
  text-wrap: pretty;
}
.btn-start { margin-top: 32px; min-width: 12rem; }
.screen .lead { margin-top: 16px; font-size: 1.0556rem; color: var(--ink-2); }
.error-list { margin: 16px 0 28px; padding-left: 1.2em; color: var(--error); }
.error-list li + li { margin-top: 6px; }

/* ---------- Прогресс ---------- */

.progress {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 14px 0 10px;
  background: var(--paper);
}
.progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--pen);
  transition: width 220ms ease-out;
}
.progress-text { margin-top: 8px; font-size: 0.9444rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- Шаги ---------- */

.step { border: 0; margin: 0; padding: 0; min-width: 0; }
.no-js .step + .step { margin-top: 56px; }
.js .step { display: none; }
.js .step.is-current { display: block; }
.js .step:not(.step-intro) { padding: 20px 0 32px; }

.q { padding: 0; margin: 0 0 18px; float: none; width: 100%; }
.q-title {
  font-size: clamp(1.3rem, 1.05rem + 1.1vw, 1.75rem); /* 23–31 px */
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -0.005em;
  text-wrap: balance;
}
.q-hint { margin: -6px 0 16px; font-size: 0.9444rem; color: var(--ink-2); }
.q-note { margin-top: 10px; font-size: 0.9444rem; color: var(--ink-2); }
.q-error {
  margin: 0 0 14px;
  padding: 2px 0 2px 12px;
  border-left: 3px solid var(--error);
  color: var(--error);
  font-weight: 550;
}
.q-error:empty { display: none; }

/* ---------- Карточки вариантов ---------- */

.opts { display: grid; gap: 10px; }
@media (min-width: 480px) { .opts-row { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.nw { white-space: nowrap; }

.opt {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-height: 56px;
  padding: 15px 16px;
  background: var(--sheet);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: border-color 120ms ease-out, background-color 120ms ease-out;
}
.opt input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}
.opt-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-top: 1px;
  border: 2px solid var(--control);
  border-radius: 6px;
  background: var(--sheet);
}
.opt-radio .opt-mark { border-radius: 50%; }
.opt-text { font-size: 1rem; line-height: 1.4; }

.opt:has(input:checked) { border-color: var(--pen); background: var(--pen-soft); }
.opt input:checked + .opt-mark { background: var(--pen); border-color: var(--pen); }
.opt-check input:checked + .opt-mark::after {
  content: "";
  width: 7px;
  height: 13px;
  margin-top: -3px;
  border: solid var(--pen-ink);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}
.opt-radio input:checked + .opt-mark::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pen-ink);
}
.opt:has(input:focus-visible) { outline: 3px solid var(--pen); outline-offset: 2px; }
@media (hover: hover) {
  .opt:hover { border-color: var(--control); }
  .opt:has(input:checked):hover { border-color: var(--pen); }
}

.opts-row .opt { justify-content: flex-start; }

.other-field { display: none; margin: 8px 0 0; }
.opt-other:has(input[data-other]:checked) .other-field,
.no-js .other-field { display: block; }

/* ---------- Поля ввода ---------- */

.field + .field { margin-top: 18px; }
.field-label { display: block; margin-bottom: 8px; font-weight: 600; }

.input, .select, .textarea {
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 14px 16px;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background-color: var(--sheet);
  border: 1.5px solid var(--control);
  border-radius: var(--radius);
}
.textarea { min-height: 9.5em; line-height: 1.5; resize: vertical; }
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 48px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-2) 50%),
    linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 25px) 50%, calc(100% - 18px) 50%;
  background-size: 7px 7px;
  background-repeat: no-repeat;
}
.input-date { appearance: none; -webkit-appearance: none; text-align: left; }
.input-date::-webkit-date-and-time-value { text-align: left; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible {
  outline: 3px solid var(--pen);
  outline-offset: 1px;
  border-color: var(--pen);
}
.counter {
  margin-top: 6px;
  text-align: right;
  font-size: 0.9444rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.counter:empty { display: none; }

/* В10: дата или месяц */
.js .step[data-mode-current="date"] [data-mode="month"],
.js .step[data-mode-current="month"] [data-mode="date"] { display: none; }

/* ---------- Список школ с поиском ---------- */

.combo-input { padding-right: 16px; }
.combo-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 6px;
  max-height: min(56dvh, 440px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--sheet);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
}
.combo-ul { list-style: none; margin: 0; padding: 0; }
.combo-group {
  padding: 12px 12px 4px;
  font-size: 0.9444rem;
  font-weight: 650;
  color: var(--ink-2);
}
.combo-opt {
  padding: 12px;
  min-height: 48px;
  border-radius: 8px;
  cursor: pointer;
}
.combo-opt[aria-selected="true"] { background: var(--pen-soft); font-weight: 600; }
.combo-opt.is-active { outline: 2px solid var(--pen); outline-offset: -2px; }
@media (hover: hover) { .combo-opt:hover { background: var(--pen-soft); } }
.combo-resident { margin-top: 6px; border-top: 1.5px solid var(--line); border-radius: 0 0 8px 8px; padding-top: 14px; }
.combo-empty { padding: 12px; color: var(--ink-2); }
.combo-chosen { margin-top: 10px; font-size: 0.9444rem; color: var(--ink-2); }
.combo-chosen:empty { display: none; }

/* ---------- Шкала 0–10 ---------- */

.scale {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  gap: 4px;
}
.scale-btn { position: relative; cursor: pointer; }
.scale-btn input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.scale-btn span {
  display: grid;
  place-items: center;
  height: 56px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  background: var(--sheet);
  border: 1.5px solid var(--control);
  border-radius: 10px;
  transition: background-color 120ms ease-out;
}
.scale-btn input:checked + span { background: var(--pen); border-color: var(--pen); color: var(--pen-ink); }
.scale-btn input:focus-visible + span { outline: 3px solid var(--pen); outline-offset: 2px; }
.scale-legend {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 10px;
  font-size: 0.9444rem;
  color: var(--ink-2);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 0 24px;
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  border-radius: var(--radius);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background-color 120ms ease-out, transform 80ms ease-out;
}
.btn-primary { background: var(--pen); color: var(--pen-ink); }
.btn-ghost { background: var(--sheet); color: var(--ink); border-color: var(--control); }
.btn-link {
  min-height: 48px;
  margin-top: 6px;
  padding: 0 2px;
  background: none;
  color: var(--pen);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 550;
}
.btn:disabled { opacity: 0.6; cursor: progress; }
@media (prefers-reduced-motion: no-preference) {
  .btn:active, .opt:active { transform: scale(0.985); }
}

/* Панель «Назад / Далее» у нижнего края — под большой палец */
.actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(7rem, auto) 1fr;
  gap: 12px;
  padding: 14px 0 calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 78%, transparent);
}
.actions.is-first { grid-template-columns: 1fr; }
.actions.is-first [data-action="back"] { display: none; }

.nojs-submit { padding: 40px 0 64px; }
.js .nojs-submit, .no-js .actions, .no-js .progress,
.no-js .btn-start, .no-js .btn-link { display: none; }

/* Ловушка для ботов */
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* Смена шага — короткое проявление, чтобы было видно, что вопрос сменился */
@media (prefers-reduced-motion: no-preference) {
  .js .step.is-current { animation: step-in 180ms ease-out; }
  @keyframes step-in { from { opacity: 0; transform: translateY(6px); } }
}

@media (min-width: 640px) {
  :root { --gutter: 32px; }
  .js .step:not(.step-intro) { padding-top: 40px; }
  .opts { gap: 12px; }
}
