/*
 * Оформление экранов WP‑2: карта дома, комната, задание, итог (ТЗ 17, 15.5).
 *
 * Прямых углов нет, тени короткие и мягкие — фетр, а не глубина (17.3).
 * Цвет нигде не единственный носитель смысла: верный ответ помечается
 * цветом И масштабом И звуком.
 */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  /* Планшет: выделение, контекстное меню, зум по двойному тапу и
     pull-to-refresh выключены (15.5). */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}

#app { height: 100%; display: flex; flex-direction: column; }

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: var(--gap);
  min-height: 0;
}

/* Ягодная нить — вязаная нить вдоль верхнего края (17.1, 11.2). */
.thread {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 var(--gap);
  border-bottom: 3px dashed var(--thread);
}
.thread b { font-family: var(--font-display); color: var(--berry); font-size: 24px; }
.berry {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--berry); box-shadow: 0 2px 0 var(--thread);
}

h1, h2 { font-family: var(--font-display); font-weight: 700; margin: 0; }
h1 { font-size: 32px; }
h2 { font-size: 24px; color: var(--ink-soft); }

button, .tap {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  border: none;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: 0 2px 0 var(--thread);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 20px;
  padding: 12px 20px;
  cursor: pointer;
}
button.accent { background: var(--berry); color: var(--surface); }
button:active { transform: translateY(2px); box-shadow: none; }

/* Кнопка «домой» в одной и той же позиции на каждом экране (9.2). */
.corner { position: fixed; left: var(--gap); bottom: var(--gap); z-index: 2; }
.corner-right { position: fixed; right: var(--gap); bottom: var(--gap); z-index: 2; }

.rooms { display: flex; flex-wrap: wrap; gap: var(--gap); }
.room {
  width: 240px; height: 160px;
  border-radius: var(--r-lg);
  background: var(--surface) center/cover no-repeat;
  box-shadow: 0 2px 0 var(--thread);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 12px;
  font-family: var(--font-display); font-size: 22px;
}
.room.locked { opacity: 0.45; filter: grayscale(1); }

/* Сетка вариантов рассчитана на 3, 4 и 6 без перевёрстки (21.6). */
.options {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--gap);
  align-content: center;
}
.option {
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: 0 2px 0 var(--thread);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
  padding: 12px;
  transition: transform 180ms ease;
}
.option img { max-width: 100%; max-height: 220px; border-radius: var(--r-md); pointer-events: none; }
.option .en { font-size: 28px; visibility: hidden; }
/* Написание появляется только после ответа (10.2). */
.option.revealed .en { visibility: visible; }
.option.correct { outline: 6px solid var(--grass); transform: scale(1.08); }
.option.wrong { animation: nudge 420ms ease; }

@keyframes nudge {
  0%   { transform: translateX(0); }
  30%  { transform: translateX(-18px); }
  60%  { transform: translateX(6px); }
  100% { transform: translateX(0); }
}

.task-bar { display: flex; gap: var(--gap); align-items: center; justify-content: center; }

.cards { display: flex; flex-wrap: wrap; gap: var(--gap); }
.card {
  border-radius: var(--r-md); background: var(--surface);
  box-shadow: 0 2px 0 var(--thread); padding: 12px; text-align: center;
}
.card img { width: 120px; height: 120px; object-fit: contain; }
.card .en { font-size: 22px; display: block; margin-top: 8px; }

.say { font-family: var(--font-display); font-size: 26px; max-width: 40ch; }
.muted { color: var(--ink-soft); }

/* T2 «найди на сцене»: объекты — тап-зоны поверх фона, позиционированные в
   процентах от базовой сетки сцены (10.2, 21.6). */
.scene-screen { position: relative; }
.scene-objects { position: relative; flex: 1; }
.scene-object {
  position: absolute;
  background: rgba(251, 247, 240, 0.35) center/cover no-repeat;
  border: 3px dashed var(--thread);
  border-radius: var(--r-md);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 4px;
}
.scene-object .en { font-size: 22px; visibility: hidden; }
.scene-object.revealed .en { visibility: visible; }
.scene-object.correct { outline: 6px solid var(--grass); border-style: solid; }
.scene-object.wrong { animation: nudge 420ms ease; }

/* T3 «пары»: сетка 3×4, картинка и написание на отдельных плитках (10.2). */
.pairs-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(var(--tap-min), 1fr));
  grid-auto-rows: minmax(var(--tap-min), 1fr);
  gap: var(--gap);
  align-content: center;
}
.tile {
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: 0 2px 0 var(--thread);
  display: flex; align-items: center; justify-content: center;
}
.tile img { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }
.tile.matched { outline: 4px solid var(--grass); }
.tile .en { font-size: 22px; }

/* Уважается prefers-reduced-motion; мигание интерфейса отсутствует (17.5). */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* При повороте в портрет макет не перестраивается — экран-заглушка (Риск 5). */
.rotate { display: none; }
@media (orientation: portrait) {
  .screen, .thread { display: none; }
  .rotate {
    display: flex; align-items: center; justify-content: center;
    height: 100%; padding: var(--gap); text-align: center;
    font-family: var(--font-display); font-size: 28px;
  }
}
