/* Ruta — оформление по системе «Organic Neo-Brutalism».
   Фисташковый фон, чёрные обводки в два пикселя, жёсткие смещённые тени
   вместо размытых, сильно скруглённые углы. Тени здесь не свет, а
   «наклейка»: элемент выглядит вырезанным и положенным сверху. */

@font-face {
  font-family: 'Quicksand';
  src: url('fonts/Quicksand.ttf') format('truetype-variations');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --pistachio:      #e6f5d0;  /* главный фон */
  --paper:          #fbf9f5;  /* поверхность карточек */
  --white:          #ffffff;
  --lime:           #b7dc65;  /* активное, успех */
  --lime-bright:    #d7fe82;
  --olive:          #556346;  /* кольцо прогресса, «пройдено» */
  --olive-deep:     #4c6700;
  --orange:         #ff5c33;  /* серия дней и горячие кнопки */
  --ink:            #000000;
  --ink-soft:       #45483f;
  --grey:           #e2e2e2;
  --grey-line:      #c5c8bc;
  --error:          #ba1a1a;

  --border: 2px solid var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 2px 2px 0 var(--ink);
  --shadow-lg: 6px 6px 0 var(--ink);

  --r-sm: 12px;
  --r: 24px;
  --r-md: 32px;
  --r-pill: 999px;

  --wrap: 32rem;
  --font: 'Quicksand', ui-rounded, 'SF Pro Rounded', system-ui, sans-serif;
}

/* Система построена на чёрном по светлому. Тёмная тема ломает её смысл:
   чёрная обводка на чёрном фоне исчезает. Поэтому светлая всегда. */
:root { color-scheme: light; }

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--pistachio);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* ─────────── экраны ─────────── */

.view {
  display: none;
  min-height: 100dvh;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.view.is-active { display: flex; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 20px 20px 40px;
  flex: 1;
}
.wrap--card { display: flex; flex-direction: column; justify-content: center; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  max-width: var(--wrap);
  width: 100%;
  margin: 0 auto;
  min-height: 60px;
}

/* ─────────── типографика ─────────── */

.brand {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin: 0;
}
.brand--small { font-size: 12px; }

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 6px;
}

.day__title {
  font-size: clamp(28px, 8vw, 40px);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

.day__place { color: var(--ink-soft); margin: 0 0 24px; }

.note {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.45;
  margin: 20px 0 0;
}
.note--error { color: var(--error); font-weight: 700; }
.note--warn {
  background: var(--lime-bright);
  border: var(--border);
  box-shadow: var(--shadow-sm);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  color: var(--ink);
}

.linkish {
  background: none;
  border: 0;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  padding: 4px 0;
}
.linkish:hover { text-decoration: underline; }

.progress, .scene__role {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  background: var(--white);
  border: var(--border);
  border-radius: var(--r-pill);
  padding: 5px 14px;
  font-variant-numeric: tabular-nums;
}
/* Без текста плашка превращается в пустую белую таблетку. */
.progress:empty, .scene__role:empty { display: none; }

/* Серия дней — единственный «горячий» элемент в интерфейсе. */
.streak {
  font-size: 13px;
  font-weight: 700;
  background: var(--ink);
  color: var(--white);
  border-radius: var(--r-pill);
  padding: 6px 14px;
}
.streak:empty { display: none; }

/* ─────────── вход ─────────── */

.view--login { justify-content: center; }

.login {
  max-width: 22rem;
  margin: 0 auto;
  padding: 32px 20px;
  text-align: center;
  width: 100%;
}

.login__title {
  font-size: 40px;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 16px 0 8px;
}
.login__sub { color: var(--ink-soft); margin: 0 0 28px; }

.pin { display: flex; justify-content: center; gap: 14px; margin-bottom: 32px; }
.pin__dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: var(--border);
  background: var(--white);
  transition: background 0.15s, transform 0.15s;
}
.pin__dot.is-filled { background: var(--lime); transform: scale(1.15); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.keypad button {
  aspect-ratio: 1.5;
  border: var(--border);
  background: var(--white);
  color: var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  font: inherit;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s;
}
.keypad button:active {
  transform: translate(4px, 4px);
  box-shadow: none;
}
.keypad__ghost { background: var(--grey) !important; font-size: 18px !important; }

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

.actions { display: flex; flex-direction: column; gap: 12px; margin-top: 28px; }

.btn {
  appearance: none;
  border: var(--border);
  border-radius: var(--r-md);
  padding: 18px 24px;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s;
}
.btn:active:not(:disabled) { transform: translate(4px, 4px); box-shadow: none; }
.btn:disabled { opacity: 0.45; cursor: default; box-shadow: var(--shadow-sm); }

.btn--primary { background: var(--ink); color: var(--white); }
.btn--primary:hover:not(:disabled) { background: #1b1c19; }

.btn--ghost { background: var(--white); color: var(--ink); }
.btn--ghost:hover:not(:disabled) { background: var(--lime-bright); }

/* Кнопка «продолжить» на экране дня — оранжевая, как в макете:
   единственное место, где интерфейс повышает голос. */
.btn--hot { background: var(--orange); color: var(--ink); }

.btn--small { padding: 10px 16px; font-size: 14px; border-radius: var(--r-pill); box-shadow: var(--shadow-sm); }
.btn--small:active:not(:disabled) { transform: translate(2px, 2px); }

/* ─────────── статистика ─────────── */

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 8px; }
.stat {
  background: var(--paper);
  border: var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 14px 12px;
  text-align: center;
}
.stat:first-child { background: var(--lime-bright); }
.stat__num {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  display: block;
  font-variant-numeric: tabular-nums;
}
.stat__label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─────────── карточка слова ─────────── */

.card {
  background: var(--paper);
  border: var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 40px 24px 32px;
  text-align: center;
  position: relative;
  min-height: 16rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.card__es {
  font-size: clamp(30px, 8vw, 40px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0;
}
.card__tr { color: var(--ink-soft); font-size: 15px; margin: 0; }
.card__ru { font-size: 19px; font-weight: 600; margin: 12px 0 0; }
.card__example {
  font-style: italic;
  color: var(--ink-soft);
  font-size: 15px;
  margin: 16px 0 0;
  min-height: 1.4em;
}

.speaker {
  position: absolute;
  top: 14px; right: 14px;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: var(--border);
  background: var(--lime);
  box-shadow: var(--shadow-sm);
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}
.speaker:active { transform: translate(2px, 2px); box-shadow: none; }
.speaker--inline { position: static; margin: 0 auto 24px; display: block; }

/* ─────────── проверка ─────────── */

.check__word {
  font-size: clamp(32px, 9vw, 44px);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin: 8px 0 16px;
}

.options { display: grid; gap: 12px; }
.option {
  padding: 18px 20px;
  border: var(--border);
  background: var(--white);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s;
}
.option:hover:not([disabled]) { background: var(--lime-bright); }
.option:active:not([disabled]) { transform: translate(4px, 4px); box-shadow: none; }
.option.is-right { background: var(--lime); }
.option.is-wrong { background: #ffdad6; }

/* ─────────── сцена ─────────── */

.view--scene { height: 100dvh; background: var(--paper); }

.dialog {
  flex: 1;
  overflow-y: auto;
  padding: 8px 20px 16px;
  max-width: var(--wrap);
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bubble {
  max-width: 85%;
  padding: 14px 18px;
  border: var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  line-height: 1.4;
  animation: rise 0.2s ease-out;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.bubble--ai { align-self: flex-start; background: var(--white); cursor: pointer; }
.bubble--user { align-self: flex-end; background: var(--lime); }
.bubble--system {
  align-self: center;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  padding: 4px 0;
  max-width: 100%;
}

.bubble__es { font-size: 17px; font-weight: 600; margin: 0; }
.bubble__ru {
  font-size: 14px;
  color: var(--ink-soft);
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 2px dashed var(--grey-line);
}
.bubble__ru[hidden] { display: none; }

.composer {
  max-width: var(--wrap);
  width: 100%;
  margin: 0 auto;
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom));
  border-top: var(--border);
  background: var(--pistachio);
}
.composer__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.composer__text {
  width: 100%;
  margin-top: 12px;
  padding: 14px 16px;
  border: var(--border);
  border-radius: var(--r);
  background: var(--white);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* меньше — и Safari зумит страницу при фокусе */
}
.composer__text:focus { outline: none; border-width: 3px; background: var(--lime-bright); }

.mic {
  width: 76px; height: 76px;
  border-radius: 50%;
  border: var(--border);
  background: var(--orange);
  box-shadow: var(--shadow);
  font-size: 28px;
  cursor: pointer;
  flex: 0 0 auto;
  transition: transform 0.08s, box-shadow 0.08s, background 0.2s;
}
.mic:active:not(:disabled) { transform: translate(4px, 4px); box-shadow: none; }
.mic.is-listening { background: var(--lime); animation: pulse 1.2s ease-in-out infinite; }
.mic:disabled { opacity: 0.4; cursor: default; animation: none; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

.hints { display: grid; gap: 8px; margin: 0 0 12px; }
.hint {
  text-align: left;
  padding: 12px 16px;
  border: 2px dashed var(--ink);
  background: var(--white);
  border-radius: var(--r);
  font: inherit;
  color: var(--ink);
  cursor: pointer;
}
.hint:hover { background: var(--lime-bright); }
.hint b { font-weight: 700; font-size: 16px; }
.hint span { display: block; font-size: 13px; color: var(--ink-soft); margin-top: 2px; }

/* ─────────── разбор ─────────── */

.mistake {
  border: var(--border);
  background: var(--paper);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 12px;
  cursor: pointer;
}
.mistake__said {
  color: var(--ink-soft);
  text-decoration: line-through;
  text-decoration-color: var(--error);
  text-decoration-thickness: 2px;
  margin: 0;
}
.mistake__better { font-size: 19px; font-weight: 700; margin: 6px 0 10px; }
.mistake__why { font-size: 14px; margin: 0; color: var(--ink-soft); }

/* ─────────── Основы ─────────── */

.modules { display: grid; gap: 12px; margin-top: 24px; }

.module-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  width: 100%;
  padding: 18px 20px;
  border: var(--border);
  background: var(--paper);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  font: inherit;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s;
}
.module-row:hover { background: var(--lime-bright); }
.module-row:active { transform: translate(4px, 4px); box-shadow: none; }
.module-row.is-done { background: var(--lime); }
.module-row.is-done .module-row__title::after { content: ' ✓'; }

.module-row__title { font-size: 19px; font-weight: 700; flex: 1; }
.module-row__sub { font-size: 12px; font-weight: 600; color: var(--ink-soft); }

.module__intro {
  background: var(--paper);
  border: var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  line-height: 1.55;
  margin: 0 0 24px;
}

.letters { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 12px; }
.letter {
  border: var(--border);
  background: var(--paper);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 14px 12px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s;
}
.letter:hover { background: var(--lime-bright); }
.letter:active { transform: translate(2px, 2px); box-shadow: none; }
.letter__char { font-size: 26px; font-weight: 700; display: block; }
.letter__name { font-size: 12px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.06em; }
.letter__note { font-size: 12px; margin: 8px 0 0; line-height: 1.35; }
.letter__ex { font-style: italic; font-size: 13px; color: var(--ink-soft); margin: 6px 0 0; }

.rule {
  border: var(--border);
  background: var(--paper);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 14px;
}
.rule__head { font-size: 19px; font-weight: 700; margin: 0 0 8px; line-height: 1.25; }
.rule__why { font-size: 14px; color: var(--ink-soft); margin: 0 0 14px; line-height: 1.5; }
.rule__ex {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  border-top: 2px dashed var(--grey-line);
  cursor: pointer;
  flex-wrap: wrap;
}
.rule__ex:hover { background: var(--lime-bright); }
.rule__es { font-size: 17px; font-weight: 700; }
.rule__tr { font-size: 13px; color: var(--ink-soft); }
.rule__ru { font-size: 13px; margin-left: auto; color: var(--ink-soft); }

.wordlist { display: grid; gap: 10px; }
.wordrow {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 14px 18px;
  border: var(--border);
  background: var(--paper);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  flex-wrap: wrap;
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s;
}
.wordrow:hover { background: var(--lime-bright); }
.wordrow:active { transform: translate(2px, 2px); box-shadow: none; }
.wordrow__es { font-size: 18px; font-weight: 700; }
.wordrow__tr { font-size: 13px; color: var(--ink-soft); }
.wordrow__ru { margin-left: auto; font-size: 15px; font-weight: 600; }

/* ─────────── голос ─────────── */

.speed {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--paper);
  border: var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 14px 18px;
  margin-bottom: 16px;
}
.speed__label { font-size: 13px; font-weight: 700; white-space: nowrap; }
.speed__value { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: right; }

.speed__range {
  flex: 1;
  appearance: none;
  height: 12px;
  border: var(--border);
  border-radius: var(--r-pill);
  background: var(--grey);
  cursor: pointer;
}
.speed__range::-webkit-slider-thumb {
  appearance: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--lime);
  border: var(--border);
  cursor: pointer;
}
.speed__range::-moz-range-thumb {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--lime);
  border: var(--border);
  cursor: pointer;
}

.wordrow.is-chosen { background: var(--lime); }
.wordrow.is-chosen .wordrow__ru { font-weight: 700; }

/* ─────────── тост ─────────── */

.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--white);
  border-radius: var(--r);
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 600;
  max-width: min(30rem, calc(100vw - 32px));
  z-index: 50;
  animation: rise 0.2s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
