/* Kidletix — квиз. Токены и вёрстка сняты с макетов Quiz_1…Quiz_12 и Mockups/quiz-mobile-*.
   Файл самостоятельный — styles/base.css сюда не подключается, его правила
   продублированы: K-01 сдана раньше появления общего слоя. */

:root {
  --blue: #105BF5;
  --blue-light: #42A2F8;
  --purple: #9B59B6;
  --yellow: #FFE9B3;
  --text: #4E342E;
  --muted: #D0D0D0;
  --white: #FFFFFF;

  --line: #E6E1DA;
  --tint: #F2F7FF;
  --shell: 1200px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: 'Poppins', system-ui, sans-serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--white);
}

img { display: block; max-width: 100%; }

button { font: inherit; color: inherit; }

a { color: inherit; }

.shell {
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 24px;
}

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

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

.site-header {
  background: var(--yellow);
  padding: 28px 0 8px;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  margin: 0; /* в подвале это <p> — браузерный отступ уводил логотип вниз */
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 40px;
}

.site-nav a {
  font-size: 16px;
  font-weight: 300;
  text-decoration: none;
}

.site-nav a:hover { color: var(--blue); }

.burger {
  display: none;
  width: 44px; height: 44px;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  cursor: pointer;
}

/* ---------- Каркас квиза ---------- */

.quiz {
  background: var(--yellow);
  padding: 24px 0 64px;
}

.quiz__progress {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 36px;
  min-height: 44px;
}

.q-back {
  flex: none;
  width: 64px; height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  border: 1px solid var(--blue);
  border-radius: 12px;
  color: var(--blue);
  cursor: pointer;
}

.q-back:hover { background: var(--tint); }

.q-bar {
  flex: 1 1 auto;
  height: 8px;
  background: var(--white);
  border-radius: 500px;
  overflow: hidden;
}

.q-bar__fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--blue);
  border-radius: 500px;
  transition: width 260ms ease;
}

.q-count {
  flex: none;
  font-size: 18px;
  color: var(--muted);
}

.q-count b {
  font-weight: 500;
  color: var(--blue);
}

.quiz__title {
  margin: 0 0 32px;
  font-size: 40px;
  font-weight: 400;
  line-height: 1.28;
  text-align: center;
  max-width: 780px;
  margin-inline: auto;
}

.quiz__title em {
  font-style: normal;
  color: var(--purple);
}

/* Смена экранов: фейд + лёгкий сдвиг */
.quiz__stage { animation: q-in 200ms ease both; }

.quiz__stage.is-leaving { animation: q-out 140ms ease both; }

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

@keyframes q-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .quiz__stage, .quiz__stage.is-leaving { animation: none; }
  .q-bar__fill { transition: none; }
}

/* ---------- Карточка вопроса ---------- */

/* Контент стоит по центру карточки, персонаж лежит поверх слева и вне потока —
   иначе колонка под иллюстрацию сдвигает поле ввода вправо, чего в макете нет. */
.q-card {
  position: relative;
  background: var(--white);
  border-radius: 40px;
  box-shadow: 0 14px 34px rgba(78, 52, 46, 0.05);
  padding: 40px;
  min-height: 260px;
}

/* Ширина считается от свободного поля слева от контента (плюс вылет за карточку),
   поэтому персонаж не наезжает на текст ни на 1920, ни на промежуточных ширинах. */
.q-card__figure {
  position: absolute;
  left: -40px;
  bottom: -40px;
  width: calc((100% - 620px) / 2 + 40px);
  max-width: 340px;
  pointer-events: none;
}

.q-card__figure img { width: 100%; }

.q-card__body {
  max-width: 620px;
  margin: 0 auto;
}

.q-card__actions {
  max-width: 620px;
  margin: 0 auto;
  display: flex;
  justify-content: flex-end;
  padding-top: 28px;
}

.q-card--noimg .q-card__figure { display: none; }

.q-legend {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 400;
}

.q-hint {
  margin: 16px 0 0;
  font-size: 14px;
  font-weight: 300;
  color: var(--purple);
}

/* ---------- Варианты ответа ---------- */

.q-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
  border: 0;
}

.q-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 10px 24px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 500px;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.q-option:hover { border-color: var(--blue-light); }

.q-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.q-option__mark {
  flex: none;
  width: 18px; height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #9A9A9A;
  border-radius: 50%;
  color: var(--white);
}

.q-option--check .q-option__mark { border-radius: 4px; }

.q-option__mark svg { opacity: 0; }

.q-option__text { font-size: 16px; }

.q-option__text small {
  display: block;
  font-size: 14px;
  font-weight: 300;
  color: #7A6A63;
}

.q-option__text i { font-weight: 300; }

.q-option.is-checked {
  border-color: var(--blue);
  background: var(--tint);
}

.q-option.is-checked .q-option__mark {
  border-color: var(--blue);
  background: var(--blue);
}

.q-option.is-checked .q-option__mark svg { opacity: 1; }

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

.q-btn {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  min-width: 280px;
  min-height: 64px;
  padding: 8px 8px 8px 32px;
  justify-content: space-between;
  background: var(--blue);
  color: var(--white);
  border: 0;
  border-radius: 500px;
  font-size: 18px;
  cursor: pointer;
  transition: background-color 140ms ease;
}

.q-btn span { flex: 1 1 auto; text-align: center; }

.q-btn__ico {
  flex: none !important;
  width: 44px; height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  border-radius: 50%;
  color: var(--blue);
}

.q-btn:hover:not(:disabled) { background: #0B48C6; }

.q-btn:disabled {
  background: var(--muted);
  color: var(--white);
  cursor: not-allowed;
}

.q-btn:disabled .q-btn__ico { color: var(--muted); }

/* ---------- Рост и вес ---------- */

.q-units {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
}

.q-units__label {
  font-size: 16px;
  color: var(--blue);
}

.q-units__group { display: flex; gap: 8px; }

.q-unit {
  min-width: 56px;
  padding: 8px 16px;
  background: var(--yellow);
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
}

.q-unit.is-active {
  background: var(--white);
  border-color: var(--blue);
  color: var(--blue);
}

.q-field { margin-top: 4px; }

.q-field__label {
  display: block;
  margin-bottom: 12px;
  font-size: 18px;
}

.q-inputs { display: flex; gap: 12px; }

.q-input {
  width: 100%;
  min-height: 56px;
  padding: 10px 24px;
  font: inherit;
  color: var(--text);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 500px;
}

.q-input::placeholder { color: var(--muted); }

/* стрелки-спиннеры у type="number" в макете не нарисованы */
.q-input[type='number'] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.q-input::-webkit-outer-spin-button,
.q-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.q-input:focus {
  outline: none;
  border-color: var(--blue);
}

.q-input--short { width: 140px; }

.q-error {
  margin: 10px 0 0;
  font-size: 14px;
  color: #C0392B;
}

/* ---------- Слайдер частоты ---------- */

.q-slider { padding: 44px 0 8px; }

.q-slider__track { position: relative; }

.q-slider__badge {
  position: absolute;
  bottom: calc(50% + 18px); /* от центра линии, а не от верха блока */
  transform: translateX(-50%);
  padding: 2px 10px;
  background: var(--blue);
  color: var(--white);
  border-radius: 8px;
  font-size: 14px;
}

.q-slider__badge::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -7px;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--blue);
}

.q-slider__ticks {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.q-slider__ticks i {
  width: 2px;
  height: 18px;
  background: var(--purple);
  border-radius: 2px;
}

/* Высота = зона попадания курсором. Линия остаётся 2px, но кликать
   можно на 20px выше и ниже неё, а не строго по волоску. */
.q-range {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 40px;
  margin: 0;
  background: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.q-range:focus { outline: none; }

.q-range::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(var(--purple), var(--purple)) no-repeat;
  background-size: var(--fill, 0%) 100%;
  background-color: #E3D4EA;
}

.q-range::-moz-range-track {
  height: 2px;
  border-radius: 2px;
  background: #E3D4EA;
}

.q-range::-moz-range-thumb { box-sizing: border-box; }

.q-range::-moz-range-progress {
  height: 2px;
  border-radius: 2px;
  background: var(--purple);
}

.q-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  margin-top: -8px;
  background: var(--white);
  border: 3px solid var(--purple);
  border-radius: 50%;
}

.q-range::-moz-range-thumb {
  width: 18px; height: 18px;
  background: var(--white);
  border: 3px solid var(--purple);
  border-radius: 50%;
}

.q-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(16, 91, 245, 0.25); }

.q-slider__ends {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 14px;
}

/* ---------- Условные блоки ---------- */

.q-notice {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  padding: 14px 18px;
  background: var(--purple);
  color: var(--white);
  border-radius: 16px;
  font-size: 14px;
  font-weight: 300;
  line-height: 1.45;
}

.q-notice b { font-weight: 500; }

.q-notice__ico { flex: none; margin-top: 2px; }

.q-notice[hidden], [hidden] { display: none !important; }

.q-subfield { margin-top: 16px; }

/* ---------- Интерстишиалы ---------- */

.q-info__lead {
  margin: 0 0 20px;
  font-size: 20px;
}

.q-info__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.q-info__card {
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-radius: 24px;
  padding: 28px;
  min-height: 200px;
}

.q-info__card h3 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 500;
  color: var(--blue);
}

.q-info__card p {
  margin: 0;
  font-size: 16px;
  font-weight: 300;
}

.q-info__card img {
  margin: 16px auto 0;
  max-height: 180px;
  width: auto;
}

.q-info__card--photo { padding: 0; overflow: hidden; }

.q-info__card--photo img {
  margin: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
}

.q-info__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 24px;
}

.q-info__note {
  margin: 0;
  font-size: 14px;
  font-weight: 300;
  color: var(--purple);
}

/* ---------- Экран возраста ---------- */

.q-age__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

/* overflow видимый: тултип про границы 7–17 выходит за карточку */
.q-age__card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0;
  background: var(--white);
  border: 0;
  border-radius: 24px;
  cursor: pointer;
  text-align: left;
}

.q-age__card img {
  width: 100%;
  height: 220px;
  object-fit: contain;
  object-position: bottom;
  padding: 16px 16px 0;
}

.q-age__card figcaption {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--purple);
  color: var(--white);
  border-radius: 0 0 24px 24px;
  font-size: 16px;
  font-weight: 300;
}

.q-age__i {
  flex: none;
  display: inline-flex;
}

.q-age__card.is-checked { outline: 3px solid var(--blue); }

.q-age__card:hover figcaption { background: #8E4EA9; }

/* Координаты на десктопе выставляет скрипт — тултип лежит в body, а не в карточке */
.q-tip {
  position: absolute;
  z-index: 40;
  width: 300px;
  padding: 16px 18px;
  background: var(--blue);
  color: var(--white);
  border-radius: 16px;
  font-size: 14px;
  font-weight: 300;
  line-height: 1.5;
}

.q-tip__text { margin: 0; }

/* хвостик вниз, к плашке с возрастом; --tail ставит скрипт */
.q-tip::after {
  content: '';
  position: absolute;
  left: var(--tail, 50%);
  bottom: -9px;
  margin-left: -8px;
  border: 8px solid transparent;
  border-top-color: var(--blue);
}

.q-tip__close {
  position: absolute;
  top: 6px; right: 8px;
  width: 28px; height: 28px;
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  color: var(--white);
  cursor: pointer;
}

.q-tip__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 20px;
  background: var(--white);
  color: var(--blue);
  border: 0;
  border-radius: 500px;
  font-size: 14px;
  cursor: pointer;
}

.q-tip__backdrop { display: none; }

.q-consent {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-top: 32px;
  cursor: pointer;
}

.q-consent input { position: absolute; opacity: 0; pointer-events: none; }

.q-consent__mark {
  flex: none;
  width: 20px; height: 20px;
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  border: 1px solid #9A9A9A;
  border-radius: 4px;
  color: var(--white);
}

.q-consent__mark svg { opacity: 0; }

.q-consent input:checked + .q-consent__mark {
  background: var(--blue);
  border-color: var(--blue);
}

.q-consent input:checked + .q-consent__mark svg { opacity: 1; }

.q-consent__text { font-size: 16px; font-weight: 300; }

.q-consent__text a { color: inherit; }

.q-disclaimer {
  margin: 16px 0 0;
  font-size: 16px;
  font-weight: 300;
}

.q-consent.is-required .q-consent__mark {
  border-color: #C0392B;
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.14);
}

.q-age__actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 32px;
}

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

.site-footer {
  background: var(--white);
  padding: 56px 0 40px;
}

.site-footer__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.site-footer__cols {
  display: flex;
  gap: 64px;
}

.site-footer__col span {
  display: block;
  font-size: 14px;
  font-weight: 300;
  color: #8B7B74;
}

.site-footer__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-top: 20px;
  font-size: 14px;
  font-weight: 300;
}

.site-footer__links {
  display: flex;
  gap: 64px;
  color: var(--muted);
}

.site-footer__links a { text-decoration: none; }

.site-footer__links a:hover { color: var(--text); }

/* ---------- Планшет ---------- */

@media (max-width: 960px) {
  .shell { padding: 0 32px; }

  .quiz__title { font-size: 32px; }

  .q-card { padding: 32px; }

  /* Места меньше: персонаж ужимается, а контент отходит вправо, чтобы не наехать на него */
  .q-card__figure { width: 220px; left: -20px; bottom: -28px; }

  .q-card:not(.q-card--noimg) .q-card__body,
  .q-card:not(.q-card--noimg) .q-card__actions {
    max-width: 520px;
    margin-right: 0;
  }

  .q-info__grid { gap: 16px; }

  .q-info__card { padding: 20px; }

  .q-age__grid { grid-template-columns: repeat(3, 1fr); }

  .site-footer__cols { gap: 32px; }

  .site-footer__links { gap: 32px; }
}

/* ---------- Мобильный ---------- */

@media (max-width: 640px) {
  .shell { padding: 0 20px; }

  .site-header { padding: 20px 0 4px; }

  .brand { font-size: 22px; }

  .burger { display: inline-flex; }

  .site-nav {
    display: none;
    position: absolute;
    left: 0; right: 0;
    top: 100%;
    z-index: 20;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    background: var(--white);
    box-shadow: 0 12px 24px rgba(78, 52, 46, 0.12);
  }

  .site-header__inner { position: relative; }

  .site-nav.is-open { display: flex; }

  .quiz { padding: 16px 0 40px; }

  .quiz__progress { gap: 12px; margin-bottom: 24px; }

  .q-back { width: 44px; }

  .q-count { font-size: 16px; }

  .quiz__title {
    font-size: 24px;
    line-height: 1.3;
    margin-bottom: 24px;
  }

  /* На мобиле белый фон уходит с карточки на её тело:
     персонаж и кнопка стоят на жёлтом, как в макете. */
  .q-card {
    display: flex;
    flex-direction: column;
    background: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    min-height: 0;
  }

  .q-card__body {
    order: 1;
    background: var(--white);
    border-radius: 24px;
    padding: 24px 20px;
    max-width: none;
    margin: 0;
  }

  /* перебивает планшетный сдвиг вправо — на мобиле карточка во всю ширину */
  .q-card:not(.q-card--noimg) .q-card__body,
  .q-card:not(.q-card--noimg) .q-card__actions {
    max-width: none;
    margin: 0;
  }

  .q-card__figure {
    order: 2;
    position: static;
    width: 220px;
    margin: -28px 0 0 24px;
    bottom: auto;
    left: auto;
    z-index: 2;
  }

  /* Экраны, где в мобильном макете иллюстрации нет: она только удлиняет прокрутку */
  .q-card--nofig-sm .q-card__figure { display: none; }

  .q-card__actions {
    order: 3;
    max-width: none;
    margin: 0;
    padding-top: 16px;
  }

  .q-card__actions .q-btn { width: 100%; }

  .q-btn { min-width: 0; width: 100%; }

  .q-legend { font-size: 18px; }

  .q-units { flex-wrap: wrap; margin-bottom: 24px; }

  .q-info__grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }

  .q-info__card { min-height: 0; }

  .q-info__card--photo { min-height: 220px; }

  .q-info__lead { font-size: 18px; }

  .q-info__foot { flex-direction: column; align-items: stretch; }

  .q-age__grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }

  .q-age__card img { height: 150px; }

  .q-age__card figcaption { font-size: 14px; padding: 10px 14px; }

  /* Тултип возраста на мобиле — модалка поверх затемнения */
  .q-tip {
    position: fixed;
    z-index: 40;
    top: 50% !important;
    left: 20px !important;
    right: 20px;
    width: auto;
    transform: translateY(-50%);
    padding: 24px 20px;
    border-radius: 24px;
    font-size: 16px;
  }

  .q-tip::after { display: none; }

  .q-tip__close { display: inline-flex; top: -44px; right: 0; }

  .q-tip__backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(0, 0, 0, 0.72);
  }

  .site-footer { padding: 32px 0 24px; }

  .site-footer__top { flex-direction: column; align-items: flex-start; gap: 20px; }

  .site-footer__cols { flex-direction: column; gap: 16px; }

  .site-footer__bottom { flex-direction: column-reverse; align-items: flex-start; gap: 16px; }

  .site-footer__links { flex-direction: column; gap: 12px; }
}
