/* ═══════════════════════════════════════════════════════
   TaalFlash — Карточки, flip-анимация, кнопки оценки
   Redesign 2026
═══════════════════════════════════════════════════════ */

/* ── Прогресс сессии ──────────────────────────────── */
.study-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.study-deck-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-s);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
.study-progress-text {
  font-size: 13px;
  color: var(--text-s);
  font-weight: 700;
  white-space: nowrap;
}

/* ── Flip-сцена ────────────────────────────────────── */
.flip-scene {
  perspective: 1200px;
  width: 100%;
  max-width: 640px;
  margin: 0 auto 20px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.flip-card {
  display: grid;
  width: 100%;
  min-height: 200px;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.35, 0, 0.25, 1);
}
.flip-card.flipped { transform: rotateY(180deg); }

/* ── Общие стили обеих сторон ──────────────────────── */
.flip-face {
  grid-area: 1 / 1;
  position: relative;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 24px;
  border: 1.5px solid var(--border);
  background: var(--white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 32px 28px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.06);
}

/* ── Лицевая сторона ───────────────────────────────── */
.flip-face-front {
  background: var(--white);
  gap: 6px;
}

.flip-word {
  font-size: clamp(34px, 7vw, 54px);
  font-weight: 900;
  color: var(--text);
  line-height: 1.15;
  letter-spacing: -0.5px;
  word-break: break-word;
}

.flip-pronunciation {
  font-size: 17px;
  color: var(--text-s);
  font-style: italic;
  margin-top: 2px;
  letter-spacing: 0.3px;
}

/* Подсказка "Tap to flip" */
.flip-hint-front {
  position: absolute;
  bottom: 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-s);
  opacity: 0.35;
}
.flip-card.flipped .flip-hint-front { display: none; }

/* ── Кнопка аудио (обе стороны) ─────────────────────── */
.flip-audio-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--orange-bg);
  border: 2px solid var(--orange);
  color: var(--orange);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(255,107,43,0.15);
}
.flip-audio-btn:hover,
.flip-audio-btn:active {
  background: var(--orange);
  color: white;
  transform: scale(1.08);
  box-shadow: 0 4px 14px rgba(255,107,43,0.3);
}

/* ── Оборотная сторона ─────────────────────────────── */
.flip-face-back {
  transform: rotateY(180deg);
  background: linear-gradient(145deg, #1a237e 0%, #283593 100%);
  border-color: transparent;
  color: white;
  gap: 0;
  justify-content: flex-start;
  padding-top: 30px;
}

/* Слово на обороте (источник — меньше, мuted) */
.flip-back-source {
  font-size: clamp(16px, 3vw, 22px);
  font-weight: 600;
  color: rgba(255,255,255,0.55);
  margin-bottom: 6px;
  letter-spacing: 0.2px;
}

/* Перевод — главный акцент */
.flip-translation {
  font-size: clamp(28px, 6vw, 44px);
  font-weight: 900;
  color: white;
  line-height: 1.2;
  letter-spacing: -0.3px;
  margin-bottom: 8px;
  word-break: break-word;
}

/* Транскрипция на обороте */
.flip-face-back .flip-pronunciation {
  color: rgba(255,255,255,0.6);
  margin-bottom: 12px;
}

/* Пример предложения */
.flip-example {
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  font-style: italic;
  line-height: 1.55;
  max-width: 100%;
  text-align: left;
  margin-top: 4px;
  width: 100%;
}
.flip-example em {
  color: rgba(255,255,255,0.65);
  font-style: normal;
}
/* Sprint 3: swipe-to-rate visual hint (mobile-only animation) */
.swipe-hint {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #10b981;
  color: #fff;
  padding: 14px 28px;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.3px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.35);
  pointer-events: none;
  z-index: 1500;
  opacity: 0;
  transition: opacity 0.18s ease-out;
}

/* Inline 🔊 кнопка для примера */
.flip-example-audio {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.22);
  color: #fff;
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 13px;
  cursor: pointer;
  margin-right: 6px;
  vertical-align: middle;
  transition: background 0.15s;
}
.flip-example-audio:hover {
  background: rgba(255,255,255,0.32);
}

/* Кнопка произношения на обороте */
.flip-pronounce-btn {
  margin-top: 14px;
  padding: 8px 20px;
  border-radius: 100px;
  border: 1.5px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.90);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.flip-pronounce-btn:hover,
.flip-pronounce-btn:active {
  background: rgba(255,255,255,0.20);
  border-color: rgba(255,255,255,0.6);
}

/* Аудио на обороте */
.flip-face-back .flip-audio-btn {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.3);
  color: white;
  box-shadow: none;
}
.flip-face-back .flip-audio-btn:hover {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.6);
  box-shadow: none;
}

/* ── Кнопка «Показать ответ» ────────────────────────── */
.show-answer-wrap {
  max-width: 640px;
  margin: 0 auto 18px;
  padding: 0 4px;
}
.show-answer-btn {
  width: 100%;
  padding: 16px 24px;
  border-radius: 16px;
  border: none;
  background: var(--orange);
  color: white;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 0.2px;
  transition: all 0.18s;
  box-shadow: 0 4px 18px rgba(255,107,43,0.30);
}
.show-answer-btn:hover,
.show-answer-btn:active {
  background: var(--orange-d, #c2440e);
  box-shadow: 0 6px 24px rgba(255,107,43,0.40);
  transform: translateY(-1px);
}

/* ── Область оценки ─────────────────────────────────── */
.rating-area-wrap {
  max-width: 640px;
  margin: 0 auto;
}
.rating-howwell {
  text-align: center;
  color: var(--text-s);
  font-size: 13px;
  font-weight: 600;
  margin: 4px 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* ── 4 кнопки оценки ────────────────────────────────── */
.rating-btns {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.rating-btn {
  padding: 12px 6px 10px;
  position: relative;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: all 0.16s;
  border: none;
  cursor: pointer;
  min-width: 0;
}
.rating-btn:active { transform: scale(0.95); }
.rating-btn:disabled { opacity: 0.45; pointer-events: none; }

.rating-btn .r-label {
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  color: white;
}
.rating-btn .r-interval {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.80);
  line-height: 1;
}
.rating-btn .r-kbd {
  position: absolute;
  top: 5px; right: 7px;
  font-size: 9px;
  opacity: 0.45;
  font-family: monospace;
  background: rgba(0,0,0,0.15);
  border-radius: 3px;
  padding: 1px 4px;
  color: white;
}
.rating-btn .r-hint {
  font-size: 10px;
  font-weight: 500;
  color: #fff;
  line-height: 1;
  font-style: italic;
}

/* Again — красная */
.btn-again {
  background: linear-gradient(145deg, #ef4444, #dc2626);
  box-shadow: 0 3px 12px rgba(239,68,68,0.30);
}
.btn-again:hover { box-shadow: 0 5px 18px rgba(239,68,68,0.45); transform: translateY(-1px); }

/* Hard — оранжевая */
.btn-hard {
  background: linear-gradient(145deg, #f97316, #ea580c);
  box-shadow: 0 3px 12px rgba(249,115,22,0.30);
}
.btn-hard:hover { box-shadow: 0 5px 18px rgba(249,115,22,0.45); transform: translateY(-1px); }

/* Good — зелёная */
.btn-good {
  background: linear-gradient(145deg, #22c55e, #16a34a);
  box-shadow: 0 3px 12px rgba(34,197,94,0.30);
}
.btn-good:hover { box-shadow: 0 5px 18px rgba(34,197,94,0.45); transform: translateY(-1px); }

/* Easy — синяя */
.btn-easy {
  background: linear-gradient(145deg, #6366f1, #4f46e5);
  box-shadow: 0 3px 12px rgba(99,102,241,0.30);
}
.btn-easy:hover { box-shadow: 0 5px 18px rgba(99,102,241,0.45); transform: translateY(-1px); }

/* Backward compat */
.btn-dont-know { background: linear-gradient(145deg, #ef4444, #dc2626); }

/* ── Произношение ───────────────────────────────────── */
.pron-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

/* ── Кнопка Undo ────────────────────────────────────── */
.undo-wrap {
  display: flex;
  justify-content: center;
  margin-top: 4px;
  min-height: 32px;
}
.btn-undo {
  font-size: 13px;
  padding: 5px 16px;
  border-radius: 100px;
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--text-s);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-undo:hover { border-color: var(--orange); color: var(--orange); }
.btn-undo .undo-timer {
  font-size: 11px;
  background: var(--bg);
  border-radius: 10px;
  padding: 1px 7px;
  font-weight: 700;
}

/* ── Режим ввода ─────────────────────────────────────── */
.input-mode-card {
  position: relative;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 36px 32px;
  max-width: 640px;
  margin: 0 auto 20px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.06);
}
.input-question {
  font-size: clamp(30px, 6.5vw, 48px);
  font-weight: 900;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}
.input-field-wrap { position: relative; margin: 18px 0; }
.input-answer {
  width: 100%;
  padding: 14px 48px 14px 18px;
  border: 2px solid var(--border);
  border-radius: 14px;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  background: var(--bg);
  color: var(--text);
}
.input-answer:focus { outline: none; border-color: var(--orange); background: var(--white); }
.input-answer.correct   { border-color: #22c55e; background: #f0fdf4; color: #16a34a; }
.input-answer.almost    { border-color: #eab308; background: #fefce8; color: #854d0e; }
.input-answer.incorrect { border-color: #ef4444; background: #fef2f2; color: #dc2626; }

.input-mic-btn {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--orange-bg);
  color: var(--orange);
  border: none;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  cursor: pointer;
}
.input-mic-btn:hover { background: var(--orange); color: white; }
.input-mic-btn.recording { background: #ef4444; color: white; animation: pulse 1s infinite; }
@keyframes pulse {
  0%,100% { transform: translateY(-50%) scale(1); }
  50%      { transform: translateY(-50%) scale(1.12); }
}

.answer-result {
  padding: 12px 16px;
  border-radius: 12px;
  margin: 10px 0;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.answer-result.correct   { background: #f0fdf4; color: #16a34a; border: 1px solid #86efac; }
.answer-result.incorrect { background: #fef2f2; color: #dc2626; border: 1px solid #fca5a5; }

.answer-example {
  font-size: 13px;
  color: var(--text-s);
  font-style: italic;
  background: var(--bg);
  border-radius: 12px;
  padding: 10px 16px;
  margin-top: 8px;
  line-height: 1.6;
  text-align: left;
  border: 1px solid var(--border);
}

/* ── Бейдж статуса карточки (NEW / LEARNING / REVIEW) ── */
.card-badge {
  position: absolute;
  top: 14px;
  left: 16px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 100px;
  pointer-events: none;
  opacity: 0.85;
}
.badge-new    { background: #dbeafe; color: #1d4ed8; }
.badge-learn  { background: #fef3c7; color: #b45309; }
.badge-review { background: #dcfce7; color: #15803d; }
.badge-leech  { background: #fee2e2; color: #b91c1c; }
[data-theme="dark"] .badge-new    { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .badge-learn  { background: #4a3500; color: #fcd34d; }
[data-theme="dark"] .badge-review { background: #14532d; color: #86efac; }
[data-theme="dark"] .badge-leech  { background: #4d1a0a; color: #fca5a5; }

/* ── Undo: полоска прогресса ────────────────────────── */
.btn-undo { position: relative; overflow: hidden; }
.undo-progress {
  position: absolute;
  bottom: 0; left: 0;
  height: 2px;
  background: var(--orange);
  transition: width 1s linear;
  border-radius: 0 0 100px 100px;
}

/* ── Анимация flash при оценке карточки ─────────────── */
@keyframes rate-flash-ok {
  0%   { box-shadow: inset 0 0 0 3px transparent; }
  25%  { box-shadow: inset 0 0 0 3px var(--green, #22c55e); }
  100% { box-shadow: inset 0 0 0 3px transparent; }
}
@keyframes rate-flash-err {
  0%   { box-shadow: inset 0 0 0 3px transparent; }
  25%  { box-shadow: inset 0 0 0 3px var(--red, #ef4444); }
  100% { box-shadow: inset 0 0 0 3px transparent; }
}
.rate-flash-ok  { animation: rate-flash-ok  0.45s ease-out; }
.rate-flash-err { animation: rate-flash-err 0.45s ease-out; }

/* ── Проекция следующего интервала после оценки ────── */
@keyframes next-iv-pop {
  0%   { opacity: 0; transform: translate(-50%, -8px) scale(0.85); }
  18%  { opacity: 1; transform: translate(-50%, 0) scale(1); }
  82%  { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -10px) scale(0.95); }
}
.next-iv-toast {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 5;
  pointer-events: none;
  background: rgba(34,197,94,0.95);
  color: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  animation: next-iv-pop 1300ms ease-out forwards;
}
.next-iv-toast.miss { background: rgba(239,68,68,0.95); }
[data-theme="dark"] .next-iv-toast { box-shadow: 0 4px 14px rgba(0,0,0,0.4); }

/* ── Завершение сессии ───────────────────────────────── */
.session-complete {
  text-align: center;
  padding: 60px 20px;
}
.session-complete .big-emoji { font-size: 72px; margin-bottom: 16px; }
.session-complete h2 { font-size: 28px; font-weight: 800; color: var(--text); margin-bottom: 8px; }
.session-complete p  { color: var(--text-s); margin-bottom: 28px; font-size: 16px; }
.session-stats {
  display: flex;
  gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 32px;
}
.session-stat { text-align: center; }
.session-stat .num { font-size: 40px; font-weight: 900; color: var(--orange); }
.session-stat .lbl { font-size: 12px; color: var(--text-s); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }

/* ── iPad (641px – 1024px) ───────────────────────────── */
@media (min-width: 641px) and (max-width: 1024px) {
  /* Увеличить touch-цели для пальцев */
  .rating-btn {
    min-height: 56px;
    padding: 12px 8px;
    border-radius: 16px;
  }
  .show-answer-btn {
    min-height: 56px;
    padding: 18px 24px;
  }
  .flip-audio-btn {
    width: 52px;
    height: 52px;
    font-size: 22px;
  }
  .rating-btns { gap: 10px; }
}

/* ── Мобильные стили (≤640px) ────────────────────────── */
@media (max-width: 640px) {
  .flip-scene { max-width: 100%; }
  .flip-face  { padding: 28px 20px 24px; border-radius: 20px; }
  .flip-card  { min-height: 160px; }

  .show-answer-wrap { padding: 0; }
  .show-answer-btn  { border-radius: 14px; padding: 15px; font-size: 16px; }

  .rating-btns { gap: 6px; }
  .rating-btn  { padding: 10px 4px 8px; border-radius: 12px; min-height: 52px; }
  .rating-btn .r-label    { font-size: 13px; }
  .rating-btn .r-interval { font-size: 10px; }
  .rating-btn .r-hint     { font-size: 9px; }
  .rating-btn .r-kbd      { display: none; }

  .input-mode-card { padding: 24px 16px; border-radius: 20px; }

  /* study-header: меньше gap на телефоне */
  .study-header { gap: 8px; }
  .study-deck-name { max-width: 200px; font-size: 14px; }
}

/* Компактные AI кнопки на узких экранах */
@media (max-width: 480px) {
  .flip-ai-btns {
    gap: 6px;
    margin: 8px auto 12px;
  }
  .flip-ai-btns .ai-explain-btn {
    padding: 7px 12px;
    font-size: 12px;
  }
}

/* ── Тёмная тема ─────────────────────────────────────── */
[data-theme="dark"] .flip-face-front {
  background: var(--card-bg, #1e1e3a);
  border-color: var(--border);
}
[data-theme="dark"] .flip-face-back {
  background: linear-gradient(145deg, #0d1340 0%, #1a237e 100%);
}
[data-theme="dark"] .show-answer-btn {
  box-shadow: 0 4px 18px rgba(255,107,43,0.20);
}
