/* Временная страница «разговор с Квакишем» в духе диалога из игры:
   всё квадратное, синий фон, ячейки разделены белыми линиями,
   Квакиш — в белой области слева, рядом окно его реплики. Шрифт — Arial. */

:root {
  --blue: #5360e6;
  --blue-deep: #4350d6;
  --white: #ffffff;
  --soft: rgba(255, 255, 255, .72);
  --line: 2px solid var(--white);
  --portrait: clamp(260px, 42vw, 620px);
}

* { box-sizing: border-box; border-radius: 0; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--blue);
  color: var(--white);
  font: 400 16px/1.5 Arial, Helvetica, sans-serif;
}
button, textarea { font: inherit; color: inherit; }

.chat {
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--portrait) minmax(0, 1fr);
  border: var(--line);
}

/* ── слева: цели дня сверху, под ними белая область с Квакишем ── */
.chat__side {
  grid-row: 1 / -1;
  min-height: 0;
  display: flex; flex-direction: column;
  border-right: var(--line);
}
/* голос — синий квадрат в правом нижнем углу белой области */
.chat__sound {
  position: absolute; right: 12px; bottom: 12px;
  width: 44px; height: 44px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--blue); color: var(--white); border: 0; cursor: pointer;
}
.chat__sound:hover, .chat__sound:focus-visible { background: var(--blue-deep); outline: none; }
/* флаг изучаемого языка — в левом нижнем углу, той же высоты и с тем же
   отступом, что иконка голоса; целиком, без обрезки (4:3) */
.chat__flag { position: absolute; left: 12px; bottom: 12px; height: 44px; aspect-ratio: 4 / 3; display: block; }
.chat__flag img { display: block; width: 100%; height: 100%; }
.chat__flag:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.chat__sound svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; stroke-linejoin: miter; }
.chat__sound svg path:first-child { fill: currentColor; }
.chat__sound .off { display: none; }
.chat__sound[aria-pressed="false"] .on { display: none; }
.chat__sound[aria-pressed="false"] .off { display: inline; }

.chat__portrait {
  position: relative;
  flex: 1; min-height: 0;
  background: var(--white);
  display: flex; align-items: flex-end; justify-content: center;
  overflow: hidden;
}
/* размер задаёт chat.js: целое число экранных пикселей на пиксель спрайта */
.chat__mascot {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
}

/* ── справа: реплика маскота или ввод на всю панель ───────── */
.chat__main { position: relative; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }
.chat__speech, .chat__type { grid-row: 2; grid-column: 1; min-height: 0; }
.chat__speech { overflow-y: auto; padding: 24px 28px; }
.chat__bubble { margin: 0; font-size: clamp(1.05rem, 1.7vw, 1.45rem); line-height: 1.6; }
.chat__bubble.is-wait #say { color: var(--soft); }
.chat__bubble.is-error #say { color: #ffd6d6; }

/* что делать дальше — всегда с новой строки под репликой; кнопки инверсные:
   белый квадрат, синий символ или текст; при наведении — наоборот */
.chat__end { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chat__end:empty { display: none; }
.chat__icon {
  width: 1.7em; height: 1.7em; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--white); color: var(--blue); border: var(--line); cursor: pointer;
  font-size: inherit;
}
.chat__icon:hover, .chat__icon:focus-visible { background: var(--blue); color: var(--white); outline: none; }
.chat__icon svg { width: 62%; height: 62%; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: square; stroke-linejoin: miter; }
.chat__icon--next svg { animation: chat-nudge 1.2s steps(2, end) infinite; }
@keyframes chat-nudge { 50% { transform: translateX(14%); } }
.chat__word {
  height: 1.7em; padding: 0 .7em; font-size: inherit;
  background: var(--white); color: var(--blue); border: var(--line); cursor: pointer;
}
.chat__word:hover, .chat__word:focus-visible { background: var(--blue); color: var(--white); outline: none; }
/* под репликой кнопки вдвое больше (в строке ввода — обычные): по ним жмут постоянно */
.chat__end { gap: 12px; margin-top: 20px; }
.chat__end .chat__icon { width: 3.4em; height: 3.4em; }
.chat__end .chat__word { height: 3.4em; padding: 0 1.4em; }

/* ввод: вся панель — поле */
.chat__type { display: grid; grid-template-rows: minmax(0, 1fr) auto; background: var(--blue-deep); }
.chat__type[hidden] { display: none; }
.chat__type textarea {
  width: 100%; height: 100%; resize: none; border: 0; outline: 0; background: none;
  padding: 24px 28px; font-size: clamp(1.05rem, 1.7vw, 1.45rem); line-height: 1.6; caret-color: var(--white);
}
.chat__type textarea::placeholder { color: var(--soft); }
.chat__type-bar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 16px; border-top: var(--line); font-size: 1.1rem; }
.chat__type-hint { margin-right: auto; color: var(--soft); font-size: .8rem; }

/* цели дня: три отсека над Квакишем — на белом, без заливки, синим текстом,
   разделены тонкими синими линиями */
.chat__goals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--white); color: var(--blue); border-bottom: 1px solid var(--blue); }
.chat__goals[hidden] { display: none; }
.chat__goal { min-height: 52px; display: flex; align-items: center; padding: 6px 10px; border-right: 1px solid var(--blue); }
.chat__goal:last-child { border-right: 0; }
.chat__goal-label { font-size: .78rem; line-height: 1.25; }
.chat__goal-count { display: block; font-size: 1rem; font-weight: 700; }

/* место над репликой (сейчас занятие идёт только репликами) */
.chat__card[hidden] { display: none; }

/* особые буквы изучаемого языка — в строке под полем */
.chat__keys { display: flex; flex-wrap: wrap; gap: 6px; margin-right: auto; }
.chat__keys:empty { display: none; }
.chat__keys:not(:empty) + .chat__type-hint { display: none; }
.chat__key { min-width: 36px; height: 36px; padding: 0 8px; background: none; color: var(--white); border: var(--line); cursor: pointer; font-size: 1rem; }
.chat__key:hover { background: var(--white); color: var(--blue); }

/* жаба прежнего сайта: спрятана ниже края синей панели, выглядывает по рот
   (~62% роста) с подпрыгиванием и уезжает вниз. Рисуется на canvas (chat.js)
   один к одному в пикселях экрана: картинки с pixelated мигали на iPhone.
   Нажатия проходят сквозь неё. Спрайт 63×64; --frog-px (экранный размер
   его пикселя) chat.js ставит равным пикселю Квакиша, здесь — запасное значение. */
.chat__frog {
  --frog-px: 4px;
  --frog-w: calc(var(--frog-px) * 63);
  --frog-h: calc(var(--frog-px) * 64);
  --frog-peek: calc(var(--frog-h) * 0.62);
  --frog-headroom: 2.5rem;
  position: absolute; right: 28px; bottom: 0; z-index: 2;
  width: var(--frog-w); height: calc(var(--frog-peek) + var(--frog-headroom));
  overflow: hidden; pointer-events: none;
}
.chat__frog-sprite {
  position: absolute; top: 0; left: 0; width: 100%; height: var(--frog-h);
  transform: translateY(calc(var(--frog-peek) + var(--frog-headroom)));
  transition: transform 320ms cubic-bezier(0.55, 0, 1, 0.45);
  will-change: transform; /* постоянный слой: без пересоздания в начале и конце движения */
}
.chat__frog-sprite canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; will-change: transform; }
.chat__frog.is-out .chat__frog-sprite { transform: translateY(var(--frog-headroom)); transition-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1); }
/* смех (рот и подпрыгивание на каждое «ха») ведёт chat.js */

@media (prefers-reduced-motion: reduce) {
  .chat__icon--next svg { animation: none; }
  .chat__frog-sprite { transition: none; }
}

/* на телефоне: голос и маскот сверху, под ними реплика или ввод */
@media (max-width: 640px) {
  body { font-size: 15px; }
  .chat { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .chat__side { grid-row: auto; border-right: 0; border-bottom: var(--line); }
  /* высоту белой области задаёт chat.js: Квакиш и пустота над головой в четверть роста */
  .chat__portrait { flex: none; }
  .chat__speech, .chat__type textarea { padding: 14px 16px; }
  /* ввод — на всю страницу, поверх целей и Квакиша */
  .chat__type { position: fixed; inset: 0; z-index: 20; height: 100dvh; padding-bottom: env(safe-area-inset-bottom); }
  .chat__type-hint { display: none; }
  .chat__frog { right: 16px; }
  .chat__goal { padding: 6px 8px; }
}
