/* Оформление сайта «Читаем вместе».
 *
 * Правила, из которых выведено всё остальное:
 *   — палец, а не мышь: цели крупные, отступы щедрые, ничего мельче 44 px;
 *   — спокойный фон и высокий контраст букв: букву должно быть видно с
 *     расстояния вытянутой руки, когда ребёнок сидит рядом;
 *   — отклик на действие обязателен, но одинаков: нажатие, переворот,
 *     «прилипание» слога читаются как один язык, а не как набор эффектов;
 *   — уважение к prefers-reduced-motion: движение — украшение, а не несущая
 *     конструкция.
 */

:root {
  --paper: #fdf6e8;
  --paper-deep: #f6ead2;
  --card: #fffdf7;
  --ink: #2f2a24;
  --ink-soft: #6d6355;
  --line: #e6d8bd;

  --berry: #e2604f;
  --sun: #f0a83c;
  --leaf: #58a05e;
  --sky: #3f86c9;
  --plum: #8f5fb5;

  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 6px 0 rgba(47, 42, 36, 0.08), 0 12px 28px rgba(47, 42, 36, 0.08);
  --shadow-press: 0 2px 0 rgba(47, 42, 36, 0.12);

  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: radial-gradient(circle at 12% 8%, #fff8ea 0%, var(--paper) 45%, var(--paper-deep) 100%);
  color: var(--ink);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.5;
  min-height: 100vh;
  overscroll-behavior-y: none;
}

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: 12px;
  top: 12px;
  z-index: 50;
  background: var(--card);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
}

/* ── Верхняя панель ─────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px clamp(12px, 4vw, 32px);
  border-bottom: 2px solid var(--line);
  background: rgba(253, 246, 232, 0.92);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(6px);
}

.topbar__home {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.topbar__mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--berry);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  transform: rotate(-4deg);
}

.topbar__title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.topbar__nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-left: auto;
}

.topbar__nav a {
  padding: 10px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: 600;
}

.topbar__nav a:hover,
.topbar__nav a:focus-visible {
  background: var(--paper-deep);
  color: var(--ink);
}

.topbar__nav a[aria-current="page"] {
  background: var(--ink);
  color: var(--paper);
}

.sound-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink-soft);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.sound-toggle__icon {
  font-size: 20px;
  line-height: 1;
}

.sound-toggle[aria-pressed="false"] {
  opacity: 0.6;
  text-decoration: line-through;
}

/* ── Переключатель детей ────────────────────────────────────────────────── */

/* Детей обычно один, поэтому переключатель выглядит скромно: имя и маленькая
   кнопка «＋». Заметной она становится только для того, кому нужна. */
.child-switcher {
  position: relative;
}

.child-switcher__inner {
  display: flex;
  align-items: center;
  gap: 6px;
}

.child-switcher__button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.child-switcher__name {
  max-width: 12ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.child-switcher__caret {
  color: var(--ink-soft);
  font-size: 12px;
}

.child-switcher__plus {
  width: 44px;
  height: 44px;
  border: 2px dashed var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 20px;
  cursor: pointer;
}

.child-switcher__plus:hover,
.child-switcher__plus:focus-visible {
  border-color: var(--ink-soft);
  color: var(--ink);
}

.popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  width: min(340px, calc(100vw - 24px));
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 12px 30px rgba(47, 42, 36, 0.16);
}

.popover__title {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.child-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.child-row__pick {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 10px;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
}

.child-row__pick:hover,
.child-row__pick:focus-visible {
  background: var(--paper-deep);
}

.child-row__pick.is-active {
  border-color: var(--leaf);
  background: #eef6ec;
}

.child-row__emoji {
  font-size: 22px;
}

.child-row__name {
  font-weight: 700;
}

.child-row__stats {
  margin-left: auto;
  font-size: 13px;
  color: var(--ink-soft);
}

.child-row__check {
  color: var(--leaf);
  font-weight: 700;
}

.child-row__remove {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 20px;
  cursor: pointer;
}

.child-row__remove:hover,
.child-row__remove:focus-visible {
  color: var(--berry);
  background: var(--paper-deep);
}

.child-switcher__add {
  display: block;
  width: 100%;
  min-height: 46px;
  margin-top: 8px;
  padding: 8px 12px;
  border: 2px dashed var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  cursor: pointer;
}

.child-switcher__add:hover,
.child-switcher__add:focus-visible {
  border-color: var(--ink-soft);
}

.child-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.field {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  font: inherit;
  color: var(--ink);
}

.field:focus {
  outline: none;
  border-color: var(--sky);
}

/* Напоминание о том, где живёт прогресс. Стоит и в меню, и на странице родителю:
   человек, заводящий второго ребёнка, — ровно тот, кто завтра откроет сайт с
   телефона и удивится пустым отметкам. */
.notice {
  margin-top: 12px;
  padding: 12px 14px;
  border: 2px solid #e8b3a6;
  border-radius: var(--radius-sm);
  background: #fff5f1;
}

.notice__title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  color: #a8452f;
}

.notice__text {
  margin: 0;
  font-size: 14px;
  color: var(--ink-soft);
}

.notice__text + .notice__text {
  margin-top: 6px;
}

/* Кто занимается — строкой на главной. Значок крупнее текста: ребёнок узнаёт
   своего зверя быстрее, чем читает имя. */
.child-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 16px;
}

.child-line__emoji {
  font-size: 24px;
  line-height: 1.2;
}

/* Список детей на странице родителю. */
.child-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.child-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
}

.child-card.is-active {
  border-color: var(--leaf);
  background: #eef6ec;
}

.child-card__emoji {
  font-size: 30px;
  line-height: 1;
}

.child-card__body {
  display: grid;
  gap: 2px;
  flex: 1;
  min-width: 12ch;
}

.child-card__name {
  font-size: 18px;
}

.child-card__stats {
  font-size: 14px;
  color: var(--ink-soft);
}

.child-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

/* ── Общий каркас экрана ────────────────────────────────────────────────── */

.screen {
  padding: clamp(18px, 4vw, 40px) clamp(12px, 4vw, 32px) 60px;
  max-width: 1080px;
  margin: 0 auto;
  outline: none;
}

.screen__title {
  font-size: clamp(26px, 5vw, 40px);
  margin: 0 0 6px;
}

.screen__lead {
  color: var(--ink-soft);
  margin: 0 0 26px;
  max-width: 62ch;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin-bottom: 8px;
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 600;
}

.back-link:hover {
  color: var(--ink);
}

/* ── Двери на главной ───────────────────────────────────────────────────── */

.doors {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.door {
  display: block;
  padding: 28px 26px 30px;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.door:hover,
.door:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 10px 0 rgba(47, 42, 36, 0.08), 0 18px 34px rgba(47, 42, 36, 0.12);
}

.door__emoji {
  font-size: 52px;
  line-height: 1;
  display: block;
  margin-bottom: 14px;
}

.door__title {
  font-size: 24px;
  margin: 0 0 6px;
}

.door__text {
  margin: 0;
  color: var(--ink-soft);
  font-size: 16px;
}

.door--child {
  border-color: #f3c98a;
}

.door--parent {
  border-color: #a9cbe8;
}

.door--speech {
  border-color: #cbb4e3;
}

/* ── Сетка букв ─────────────────────────────────────────────────────────── */

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
}

.chip {
  min-height: 44px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--card);
  font: inherit;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.letter-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
}

.letter-tile {
  position: relative;
  display: block;
  width: 100%;
  min-height: 116px;
  padding: 12px 8px;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  text-align: center;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.letter-tile:hover,
.letter-tile:focus-visible {
  transform: translateY(-2px) rotate(-1deg);
  box-shadow: var(--shadow-press);
}

.letter-tile__pair {
  display: block;
  font-size: 40px;
  font-weight: 700;
  line-height: 1.1;
}

.letter-tile__pair small {
  font-size: 26px;
  color: var(--ink-soft);
}

.letter-tile__word {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  color: var(--ink-soft);
}

.letter-tile__done {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 16px;
  color: var(--leaf);
}

/* ── Карточка буквы ─────────────────────────────────────────────────────── */

.letter-card {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  padding: clamp(20px, 4vw, 34px);
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
}

.letter-card__pair {
  text-align: center;
  font-weight: 700;
  line-height: 0.95;
  font-size: clamp(96px, 22vw, 190px);
}

.letter-card__pair small {
  display: block;
  font-size: 0.55em;
  color: var(--ink-soft);
}

.letter-card__right {
  text-align: center;
}

.letter-card__emoji {
  font-size: clamp(72px, 16vw, 130px);
  line-height: 1;
}

.letter-card__word {
  font-size: clamp(28px, 6vw, 44px);
  font-weight: 700;
  margin: 10px 0 2px;
}

.letter-card__note {
  color: var(--ink-soft);
  font-size: 16px;
  margin: 8px 0 0;
}

.letter-card__actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 12px 26px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
  box-shadow: var(--shadow);
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(1px);
  box-shadow: var(--shadow-press);
}

.btn--ghost {
  background: var(--card);
  color: var(--ink);
  border-color: var(--line);
}

.btn--accent {
  background: var(--berry);
  border-color: var(--berry);
  color: #fff;
}

.btn--leaf {
  background: var(--leaf);
  border-color: var(--leaf);
  color: #fff;
}

/* ── Конструктор слогов ─────────────────────────────────────────────────── */

.drums {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.drum {
  padding: 18px;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
}

.drum__label {
  margin: 0 0 12px;
  font-size: 15px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.drum__row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.drum__key {
  min-width: 58px;
  min-height: 58px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  background: var(--paper);
  font: inherit;
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: transform 100ms ease, background 100ms ease;
}

.drum__key:hover,
.drum__key:focus-visible {
  transform: translateY(-2px);
}

.drum__key[aria-pressed="true"] {
  background: var(--sun);
  border-color: var(--sun);
  color: #3a2a10;
}

.syllable-stage {
  margin: 26px 0;
  padding: clamp(20px, 5vw, 40px);
  border-radius: var(--radius);
  border: 2px dashed var(--line);
  background: var(--card);
  text-align: center;
}

.syllable-stage__value {
  font-size: clamp(72px, 18vw, 150px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  transition: transform 160ms ease;
}

.syllable-stage__value.is-new {
  animation: pop-in 320ms ease;
}

.syllable-stage__hint {
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 16px;
}

.syllable-stage__actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
}

.trail {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding: 0;
  list-style: none;
}

.trail__item {
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--paper-deep);
  font-size: 22px;
  font-weight: 700;
}

@keyframes pop-in {
  0% { transform: scale(0.75); opacity: 0.4; }
  60% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); }
}

/* ── Сборка слова ───────────────────────────────────────────────────────── */

.word-stage {
  padding: clamp(18px, 4vw, 30px);
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: center;
}

.word-stage__slots {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  min-height: 92px;
  align-items: center;
}

.word-stage__slot {
  min-width: 92px;
  min-height: 82px;
  display: grid;
  place-items: center;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: 2px dashed var(--line);
  background: var(--paper);
  font-size: 34px;
  font-weight: 700;
}

.word-stage__slot.is-filled {
  border-style: solid;
  border-color: var(--leaf);
  background: #eef6ec;
  animation: pop-in 240ms ease;
}

.word-stage__picture {
  font-size: clamp(56px, 14vw, 110px);
  line-height: 1;
  margin-top: 16px;
  min-height: 1.1em;
}

.word-stage__answer {
  margin: 10px 0 0;
  font-size: 22px;
  font-weight: 700;
}

.word-stage__hint {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 16px;
}

.word-pool {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.word-pool__tile {
  min-width: 92px;
  min-height: 82px;
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  font: inherit;
  font-size: 34px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: transform 120ms ease;
}

.word-pool__tile:hover,
.word-pool__tile:focus-visible {
  transform: translateY(-3px);
}

.word-pool__tile:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
}

/* ── Страница родителю ──────────────────────────────────────────────────── */

.route {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 16px;
}

.route__step {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 16px;
  padding: 20px 22px;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
}

.route__num {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--sky);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
}

.route__title {
  margin: 0 0 4px;
  font-size: 21px;
}

.route__text {
  margin: 0;
  color: var(--ink-soft);
  font-size: 16px;
}

.route__letters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.route__letter {
  min-width: 40px;
  padding: 4px 10px;
  border-radius: 10px;
  background: var(--paper-deep);
  text-align: center;
  font-weight: 700;
}

.route__letter.is-done {
  background: #e2f0dd;
  color: #3d6b34;
}

.tips {
  margin: 30px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.tips li {
  padding-left: 34px;
  position: relative;
  color: var(--ink-soft);
}

.tips li::before {
  content: "•";
  position: absolute;
  left: 10px;
  color: var(--berry);
  font-size: 26px;
  line-height: 1.1;
}

.panel {
  margin-top: 28px;
  padding: 20px 22px;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--card);
}

.panel__title {
  margin: 0 0 10px;
  font-size: 20px;
}

/* Панель предупреждения. Нужна там, где текст важнее соседних: «чего дома
   делать нельзя» в разборе нарушений — это не ещё один абзац, а то, ради чего
   блок и стоит. Отличается цветом, а не размером: пугать вёрсткой не нужно. */
.panel--warn {
  border-color: #e8b3a6;
  background: #fff5f1;
}

.panel--warn .panel__title {
  color: #a8452f;
}

/* ── Подвал и всплывающие частицы ───────────────────────────────────────── */

.footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 clamp(12px, 4vw, 32px) 48px;
  color: var(--ink-soft);
  font-size: 15px;
}

.footer__quiet {
  opacity: 0.8;
}

.burst-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 40;
}

.burst {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  animation: burst-fly 620ms ease-out forwards;
}

@keyframes burst-fly {
  0% { transform: translate(0, 0) scale(0.4); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1); opacity: 0; }
}

/* ── Уважение к настройке «меньше движения» ─────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .burst { display: none; }
}

/* ── Узкий экран и планшет ──────────────────────────────────────────────── */

@media (max-width: 640px) {
  body { font-size: 17px; }
  .letter-card { grid-template-columns: 1fr; }
  .topbar__nav { order: 3; width: 100%; margin-left: 0; }
  .screen { padding-bottom: 40px; }
}

/* ── Печать: карточка буквы на A4 ───────────────────────────────────────── */

@media print {
  .topbar,
  .footer,
  .letter-card__actions,
  .burst-layer { display: none; }
  body { background: #fff; }
  .letter-card { box-shadow: none; border-color: #999; break-inside: avoid; }
}
