/* Режим «Смотреть» — витрина видеоуроков (/teach/video).
 * Только светлая тема: тёмной на платформе нет и не планируется.
 * Токены берём из /static/common.css (--accent, --surface, --text, ...).
 */

/* Атрибут hidden должен побеждать наши display:flex/grid — иначе скрытые блоки
 * (плеер, «продолжить», список предметов) видны всегда: UA-правило [hidden]
 * слабее любого авторского селектора с классом. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── Шапка ─────────────────────────────────────────────────────── */
.vd-top {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.vd-top-inner {
  max-width: 940px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.vd-back {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  white-space: nowrap;
}
.vd-back:hover { color: var(--accent); }
.vd-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.vd-search-wrap { margin-left: auto; flex: 1 1 220px; max-width: 340px; }
.vd-search {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--bg-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.vd-search:focus { border-color: var(--accent); background: var(--surface); }

/* ── Каркас ────────────────────────────────────────────────────── */
.vd-main { max-width: 940px; margin: 0 auto; padding: 24px 20px 80px; }
.vd-state { padding: 60px 0; text-align: center; color: var(--text-secondary); }
.vd-state--error { color: var(--danger); }

.vd-empty {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 40px 28px;
  text-align: center;
}
.vd-empty h2 { margin: 0 0 10px; font-size: 1.125rem; }
.vd-empty p { margin: 0 0 20px; color: var(--text-secondary); font-size: 0.9375rem; line-height: 1.6; }

/* ── Продолжить смотреть ───────────────────────────────────────── */
.vd-resume {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 16px 18px;
  margin-bottom: 20px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.15s var(--ease);
}
.vd-resume:hover { border-color: var(--accent); }
.vd-resume-icon {
  flex: none;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
  font-size: 1rem;
}
.vd-resume-label { font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; }
.vd-resume-title { font-weight: 600; font-size: 0.9375rem; margin-top: 2px; }

/* ── Предметы ──────────────────────────────────────────────────── */
.vd-subjects { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 18px; }
.vd-subjects::-webkit-scrollbar { height: 0; }
.vd-subject-pill {
  flex: none;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s var(--ease);
}
.vd-subject-pill:hover { color: var(--text); }
.vd-subject-pill.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.vd-subject-head { margin-bottom: 18px; }
.vd-subject-stats { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 8px; }
.vd-subject-stats b { color: var(--text); }
.vd-bar { height: 6px; background: var(--bg-secondary); border-radius: 3px; overflow: hidden; }
.vd-bar-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.4s var(--ease); }

/* ── Разделы ───────────────────────────────────────────────────── */
.vd-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}
.vd-section-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: none;
  border: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}
.vd-section-head:hover { background: var(--surface-hover); }
.vd-section-name { font-weight: 600; font-size: 1rem; flex: 1; }
.vd-section-count {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
.vd-section-count.is-done { color: var(--success); font-weight: 600; }
.vd-caret { flex: none; color: var(--text-secondary); transition: transform 0.2s var(--ease); font-size: 0.75rem; }
.vd-section.is-open .vd-caret { transform: rotate(90deg); }
.vd-section-body { display: none; border-top: 1px solid var(--border); }
.vd-section.is-open .vd-section-body { display: block; }

/* ── Урок ──────────────────────────────────────────────────────── */
.vd-lesson {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 18px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}
.vd-lesson:last-child { border-bottom: none; }
.vd-lesson:hover { background: var(--surface-hover); }
.vd-play {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
  font-size: 0.6875rem;
  transition: background 0.15s var(--ease);
}
.vd-lesson:hover .vd-play { background: var(--accent); color: #fff; }
.vd-lesson.is-watched .vd-play { background: var(--success-soft); color: var(--success); }
.vd-lesson-text { flex: 1; min-width: 0; }
.vd-lesson-name { display: block; font-size: 0.9375rem; line-height: 1.4; }
.vd-lesson.is-watched .vd-lesson-name { color: var(--text-secondary); }
.vd-lesson-meta { font-size: 0.75rem; color: var(--text-secondary); margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.vd-lesson-where { display: block; font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 3px; }

/* ── Плеер ─────────────────────────────────────────────────────── */
.vd-player { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.vd-player-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.72); }
.vd-player-box {
  position: relative;
  width: 100%;
  max-width: 860px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.vd-player-close {
  position: absolute; top: 8px; right: 12px;
  z-index: 2;
  width: 34px; height: 34px;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,0.9);
  color: #1e293b;
  font-size: 1.5rem; line-height: 1;
  cursor: pointer;
}
.vd-player-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #0f172a; }
.vd-player-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.vd-player-fallback { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; color: #e2e8f0; font-size: 0.9375rem; }
.vd-player-fallback a { color: #fff; }
/* ── Геймификация: тот же контракт, что в ридере методички ──────
 * Просмотр видео здесь весит столько же, сколько в конспекте: +10 в трек,
 * очко лиги, день стрика, подкачка дерева навыков. Поэтому и выглядеть должен
 * так же — зелёная кнопка старта, «+10 XP» и тост про уровень/стрик.
 */
.vd-player-frame.is-locked iframe { pointer-events: none; }
.vd-start-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  cursor: pointer;
}
.vd-start-btn {
  padding: 13px 30px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(13, 148, 136, 0.4);
  transition: transform 0.15s var(--ease), background 0.15s var(--ease);
}
.vd-start-overlay:hover .vd-start-btn { background: var(--accent-hover); transform: translateY(-1px); }
.vd-start-hint { color: #e2e8f0; font-size: 0.8125rem; font-weight: 500; }

.vd-xp-pulse {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 5;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 1.75rem;
  font-weight: 800;
  text-shadow: 0 2px 12px rgba(13, 148, 136, 0.9);
  pointer-events: none;
  animation: vd-xp-rise 1.1s var(--ease) forwards;
}
@keyframes vd-xp-rise {
  0%   { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
  25%  { opacity: 1; transform: translate(-50%, -55%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -130%) scale(1); }
}

.vd-confetti {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  z-index: 4;
  pointer-events: none;
  animation: vd-confetti-fall 1s ease-out forwards;
}
@keyframes vd-confetti-fall {
  0%   { opacity: 1; transform: translate(0, 0) rotate(0deg); }
  100% { opacity: 0; transform: translate(var(--dx), 120px) rotate(360deg); }
}

.vd-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  z-index: 300;
  max-width: min(92vw, 420px);
  padding: 13px 20px;
  border-radius: var(--radius);
  background: #0f172a;
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.vd-toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }

.vd-player-body { padding: 20px 22px 24px; }
.vd-player-crumb { margin: 0 0 4px; font-size: 0.8125rem; color: var(--text-secondary); }
.vd-player-title { margin: 0 0 14px; font-size: 1.125rem; font-weight: 700; line-height: 1.35; }

.vd-parts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.vd-part {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit; font-size: 0.8125rem; font-weight: 500;
  cursor: pointer;
}
.vd-part.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

.vd-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.vd-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s var(--ease);
}
.vd-chip:hover { background: var(--accent-soft); color: var(--accent); }

.vd-player-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.vd-btn {
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 0.9375rem; font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: all 0.15s var(--ease);
}
.vd-btn:hover { border-color: var(--accent); color: var(--accent); }
.vd-btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.vd-btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.vd-btn--watch.is-on { background: var(--success-soft); border-color: transparent; color: var(--success); }

.vd-search-empty { text-align: center; color: var(--text-secondary); padding: 40px 0; }

/* Пришли по ссылке на раздел, а видео там нет — говорим прямо, а не показываем
 * молча «не тот» раздел. */
.vd-notice {
  margin: 0 0 16px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: rgba(217, 119, 6, 0.1);
  color: #92400e;
  font-size: 0.875rem;
  line-height: 1.5;
}

@media (max-width: 640px) {
  .vd-top-inner { padding: 12px 16px; gap: 10px; }
  .vd-title { font-size: 1.0625rem; }
  .vd-search-wrap { flex-basis: 100%; max-width: none; margin-left: 0; order: 3; }
  .vd-main { padding: 18px 14px 60px; }
  .vd-player { padding: 0; align-items: flex-end; }
  .vd-player-box { max-height: 100vh; border-radius: 0; }
  .vd-player-body { padding: 18px 16px 28px; }
}


/* ── Оценка урока учеником: 1–5 + комментарий ────────────────────
 * Шкала та же, что у запроса оценки через бота, — обе сходятся в средней
 * на витрине /team_ops/lessons/rating. Оценить можно и не досмотрев: это
 * отзыв о ролике, а не о факте просмотра. */
.vd-rate {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.vd-rate-h { font-size: 0.9375rem; font-weight: 600; margin-bottom: 10px; }
.vd-stars { display: flex; align-items: center; gap: 4px; margin-bottom: 12px; }
.vd-star {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1.75rem;
  line-height: 1;
  padding: 2px 3px;
  color: #d8dce4;
  transition: color .12s, transform .12s;
}
.vd-star:hover { transform: scale(1.12); }
.vd-star.is-on { color: #f5a623; }
.vd-rate-val { margin-left: 8px; font-size: 0.8125rem; color: var(--text-secondary); }
.vd-rate-text {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1.5;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.vd-rate-text:focus { outline: none; border-color: var(--accent); }
.vd-rate-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.vd-rate-send { padding: 10px 20px; }
.vd-rate-send:disabled { opacity: .5; cursor: not-allowed; }
.vd-rate-note { font-size: 0.75rem; color: var(--text-secondary); }
.vd-rate-done { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.vd-rate-done-t { font-size: 0.9375rem; font-weight: 600; }
.vd-rate-done-t .vd-rate-stars { color: #f5a623; letter-spacing: 1px; }
.vd-rate-done-c {
  flex-basis: 100%;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.vd-rate-edit {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
}
.vd-rate-edit:hover { color: var(--text); }
