/* Alena TV-lite — TV / weak-browser stylesheet.
   Rules:
   - no :hover (TVs have no pointer)
   - focus state must be high-contrast and obvious from across a room
   - px units only (no rem/vw/clamp — they break on old WebKit)
   - flex only (no grid, no gap-on-flex — older Tizen/WebOS lack support)
   - one accent color: #FF7043 (Material Deep Orange 400) */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  background: #FFF8F0;
  color: #2A2520;
  font-family: -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 18px; line-height: 1.4;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; -webkit-user-drag: none; user-select: none; }
button { font: inherit; color: inherit; background: transparent; border: 0; padding: 0; cursor: default; }
input { font: inherit; color: inherit; }
ul { list-style: none; margin: 0; padding: 0; }
a { color: inherit; text-decoration: none; }

/* ---- Boot splash ---- */
.boot { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.boot-logo { color: #FF7043; font-size: 56px; font-weight: 700; letter-spacing: 2px; }

/* ---- Focus ---- */
/* The ONLY way an element looks "active": keyboard / D-pad focus.
   Mouse hover does nothing, mouse click does not show a focus ring.
   :focus applies the highlight; :focus:not(:focus-visible) undoes it
   on mouse-click. Old TV browsers ignore the :not(:focus-visible)
   rule as invalid syntax, so the highlight stays applied there — the
   only kind of focus they ever see is D-pad anyway. */
button:focus, input:focus, .focusable:focus { outline: 0; }

.focusable {
  position: relative;
  border: 3px solid transparent;
  border-radius: 10px;
  transition: border-color 120ms linear, background-color 120ms linear, transform 120ms linear, box-shadow 120ms linear;
}
.focusable:focus {
  border-color: #FF7043;
  background-color: rgba(255, 112, 67, 0.10);
  box-shadow: 0 0 0 1px rgba(255, 112, 67, 0.35);
  z-index: 2;
}

/* ---- App shell ---- */
#app { width: 100%; height: 100%; display: flex; flex-direction: column; }

.top-bar {
  flex: 0 0 auto;
  height: 72px;
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #FFFFFF;
  border-bottom: 1px solid #EADFCF;
}
.brand { color: #FF7043; font-weight: 700; font-size: 24px; letter-spacing: 1px; }
.top-nav { display: flex; }
.top-nav .focusable {
  padding: 10px 18px;
  margin-left: 8px;
  border-radius: 8px;
  color: #7A6E5F;
  font-size: 16px;
}
.top-nav .focusable.active { color: #FF7043; }

.view {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
}

/* ---- Generic elements ---- */
.btn {
  display: inline-block;
  padding: 14px 28px;
  background: #F2EBE0;
  border-radius: 10px;
  font-size: 18px;
  color: #2A2520;
}
.btn-primary { background: #FF7043; color: #fff; font-weight: 600; }
.btn-primary.focusable:focus { background: #FF8A65; border-color: #fff; box-shadow: 0 0 0 3px rgba(255, 112, 67, 0.35); }

.input {
  display: block;
  width: 100%;
  padding: 16px 18px;
  background: #FFFFFF;
  border: 2px solid #E0D5C3;
  border-radius: 10px;
  color: #2A2520;
  font-size: 22px;
}
.input:focus { border-color: #FF7043; background: #FFFAF2; }

.hint  { color: #8B7E70; font-size: 14px; margin-top: 8px; }
.err   { color: #C0392B; font-size: 15px; margin-top: 10px; min-height: 22px; }
.title { font-size: 30px; font-weight: 700; margin: 0 0 8px; }
.lead  { color: #6A5F52; font-size: 16px; margin-bottom: 24px; }

/* ---- Login / Verify ---- */
.center-page {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.auth-card {
  width: 480px;
  max-width: 100%;
  background: #FFFFFF;
  border: 1px solid #EADFCF;
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: 0 6px 24px rgba(120, 90, 60, 0.08);
}
.auth-card .title { color: #FF7043; }
.auth-actions { display: flex; justify-content: space-between; margin-top: 20px; }
.auth-actions .focusable { padding: 12px 22px; }

/* ---- Choose login (TG / Max) ---- */
.auth-card.choose-card { width: 560px; }
.auth-card.choose-card .title,
.auth-card.choose-card .lead { text-align: center; }
.choose-grid {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}
.choose-tile {
  flex: 1 1 0;
  margin: 0 8px;
  padding: 22px 16px 18px;
  background: #FFFFFF;
  border: 1px solid #EADFCF;
  border-radius: 14px;
  text-align: center;
  cursor: default;
}
.choose-tile:first-child { margin-left: 0; }
.choose-tile:last-child  { margin-right: 0; }
.choose-logo {
  width: 64px; height: 64px;
  margin: 0 auto 10px;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 1px;
}
.choose-logo.tg-logo  { background: #2AABEE; }
.choose-logo.max-logo { background: linear-gradient(135deg, #FF6E3A 0%, #C2452B 100%); }
.choose-name { font-size: 20px; font-weight: 700; color: #2A2520; margin-bottom: 4px; }
.choose-sub  { font-size: 12px; color: #8B7E70; line-height: 1.35; }
.choose-tile.focusable:focus { transform: translateY(-2px); }

/* ---- Max-login row: QR + код вместе ---- */
.max-row {
  display: flex;
  align-items: stretch;
  justify-content: center;
  margin: 6px 0 14px;
}
.max-qr {
  flex: 0 0 auto;
  padding: 10px;
  background: #FFFAF2;
  border: 1px solid #EADFCF;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.max-qr img {
  display: block;
  width: 240px;
  height: 240px;
}
.max-code-box {
  flex: 0 0 auto;
  margin-left: 14px;
  padding: 18px 22px;
  background: #FFF8F0;
  border: 1px solid #EADFCF;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.max-code-label {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #FF7043;
  font-weight: 700;
  margin-bottom: 6px;
}
.max-code {
  font-size: 38px;
  font-weight: 700;
  color: #2A2520;
  letter-spacing: 4px;
  font-variant-numeric: tabular-nums;
  margin-bottom: 8px;
}
.max-code-box .tg-bot-url {
  font-size: 11px;
  max-width: 180px;
  margin: 0;
}

/* ---- Telegram QR-login card ---- */
/* Шире обычной auth-card — QR живёт лучше при ~300px. На мелких экранах
   max-width: 100% ужмёт обратно. */
.auth-card.tg-auth { width: 540px; }
.auth-card.tg-auth .lead { margin-bottom: 16px; text-align: center; }
.auth-card.tg-auth .title { text-align: center; }
.tg-qr-box {
  display: flex; align-items: center; justify-content: center;
  width: 100%;
  min-height: 320px;
  background: #FFFAF2;
  border: 1px solid #EADFCF;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
}
.tg-qr { width: 300px; height: 300px; display: block; }
.tg-bot-url {
  text-align: center;
  color: #FF7043;
  font-size: 12px;
  word-break: break-all;
  margin-bottom: 10px;
}
.tg-status {
  text-align: center;
  color: #6A5F52;
  font-size: 15px;
  min-height: 22px;
  margin-bottom: 6px;
}
.tg-status.err { color: #C0392B; }

/* 4-digit code input — single box, large monospace */
.code-input {
  text-align: center;
  letter-spacing: 18px;
  font-size: 40px;
  font-weight: 700;
  padding-left: 18px; /* compensate letter-spacing on the last char */
}

/* ---- Home ---- */
.home {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.home-header {
  flex: 0 0 auto;
  padding: 28px 40px 18px;
  background: #FFFFFF;
  border-bottom: 1px solid #EADFCF;
}
.home-title { font-size: 28px; font-weight: 700; margin: 0 0 6px; }
.home-desc  { color: #6A5F52; font-size: 14px; max-width: 880px; margin: 0;
              display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.rows { flex: 1 1 auto; overflow-y: auto; padding: 24px 0 40px; }
.row-block { margin-bottom: 28px; }
.row-h {
  padding: 0 40px 12px;
  font-size: 13px;
  color: #FF7043;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 700;
}
.row-scroll {
  display: flex;
  overflow-x: auto;
  padding: 4px 40px 16px;
  -webkit-overflow-scrolling: touch;
}
.row-scroll::-webkit-scrollbar { display: none; }

.card {
  flex: 0 0 auto;
  width: 230px;
  margin-right: 14px;
  background: #FFFFFF;
  border: 1px solid #EADFCF;
  border-radius: 10px;
  overflow: hidden;
}
.card-img {
  width: 100%; height: 130px;
  background: #F2EBE0 center/cover no-repeat;
  position: relative;
}
.card-img.empty::after {
  content: ""; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background-image: linear-gradient(135deg, #FF7043 0%, #C2452B 100%);
  opacity: 0.55;
}
.card-img.empty::before {
  content: ""; position: absolute; left: 50%; top: 50%;
  margin: -22px 0 0 -16px; width: 32px; height: 44px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'><path d='M8 5v14l11-7z'/></svg>") center/contain no-repeat;
  opacity: 0.8;
}
.card-body { padding: 10px 12px 12px; }
.card-title {
  font-size: 14px; font-weight: 600;
  color: #2A2520;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 38px;
  line-height: 1.3;
}
.card-meta { color: #8B7E70; font-size: 12px; margin-top: 4px; }

.card.focusable:focus { transform: translateY(-4px); }

/* ---- Course page ---- */
.course {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  padding: 24px 40px 32px;
  overflow: hidden;
}
.course-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.course-title { font-size: 28px; font-weight: 700; margin: 0; color: #2A2520; }
.course-sub { color: #8B7E70; font-size: 14px; margin-top: 4px; }

.course-body {
  flex: 1 1 auto;
  display: flex;
  overflow: hidden;
  margin-top: 16px;
}
.video-list-wrap {
  flex: 1 1 60%;
  display: flex; flex-direction: column;
  padding-right: 20px;
  min-height: 0;
}
.video-list {
  flex: 1 1 auto;
  overflow-y: auto;
}
.vlist-arrow {
  flex: 0 0 auto;
  align-self: center;
  width: 80px; height: 36px;
  border-radius: 8px;
  background: #FFFFFF;
  border: 1px solid #EADFCF;
  color: #FF7043;
  font-size: 18px;
  margin: 4px 0;
  display: flex; align-items: center; justify-content: center;
}
.video-item {
  display: flex; align-items: center;
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: #FFFFFF;
  border: 1px solid #EADFCF;
  border-radius: 12px;
  text-align: left;
}
.video-num {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  border-radius: 18px;
  background: #FFE6DA;
  color: #FF7043;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-right: 16px;
}
.video-info { flex: 1 1 auto; min-width: 0; }
.video-name { font-size: 17px; font-weight: 600; color: #2A2520;
              white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.video-sub  { color: #8B7E70; font-size: 13px; margin-top: 2px;
              white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.video-play { color: #FF7043; font-size: 13px; margin-left: 16px; font-weight: 600; }

/* Обёртка для панели описания — column flex, чтобы можно было воткнуть
   ▲ сверху и ▼ снизу для прокрутки текста по клику. */
.video-detail-wrap {
  flex: 1 1 40%;
  display: flex; flex-direction: column;
  margin-left: 16px;
  min-height: 0;
}
.video-detail {
  flex: 1 1 auto;
  background: #FFFFFF;
  border: 1px solid #EADFCF;
  border-radius: 12px;
  padding: 20px 22px;
  overflow-y: auto;
  min-height: 0;
}
.video-detail-h {
  font-size: 12px; letter-spacing: 2px; color: #FF7043; text-transform: uppercase; font-weight: 700;
  margin-bottom: 8px;
}
.video-detail-title { font-size: 20px; font-weight: 600; margin-bottom: 10px; color: #2A2520; }
.video-detail-text  { color: #3F362E; font-size: 15px; line-height: 1.5; }
.video-detail-text p  { margin: 0 0 10px 0; }
.video-detail-text p:last-child { margin-bottom: 0; }
.video-detail-text ul { margin: 0 0 12px 0; padding-left: 22px; }
.video-detail-text li { margin: 4px 0; }
.video-detail-text li::marker { color: #FF7043; }
.video-detail-empty { color: #A89C8E; font-size: 14px; font-style: italic; }

/* ---- Player ---- */
.player {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #000;
}
.player-frame {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%; height: 100%;
  border: 0;
  background: #000;
  outline: 0;
}
/* Маска поверх кнопки «На весь экран» внутри Kinescope-iframe'а: SDK
   её скрыть не даёт. Чёрный прямоугольник в правом нижнем углу плеера —
   когда контролы видны, сливается с их тёмной градиентной подложкой;
   когда контролы скрыты во время воспроизведения, остаётся небольшой
   незаметный угол. pointer-events: auto — клик/тап в этой зоне не
   доходит до FS-кнопки. */
.fs-mask {
  position: absolute;
  right: 0; bottom: 0;
  width: 64px; height: 52px;
  background: #000;
  z-index: 6;
  pointer-events: auto;
}
.player-msg {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: flex; align-items: center;
  color: #fff; font-size: 18px;
  z-index: 4;
}
/* Экран загрузки на уровне родителя — показывается сразу как только
   пользователь нажал на видео, исчезает когда iframe пришлёт сообщение
   canplay или playing. Нужен потому что iframe сам грузится сетью
   несколько сот мс и до этого момента у юзера чёрный экран. */
.player-loading {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: #FFF8F0;
  color: #2A2520;
  z-index: 4;
}
.player-loading .spinner {
  width: 56px; height: 56px;
  border: 5px solid rgba(255, 112, 67, 0.18);
  border-top-color: #FF7043;
  border-radius: 50%;
  -webkit-animation: spin 900ms linear infinite;
          animation: spin 900ms linear infinite;
  margin: 0 0 20px 0;
}
.player-loading-text {
  font-size: 18px;
  color: #5A5048;
  max-width: 480px;
  text-align: center;
  padding: 0 24px;
}
.player-loading.error .spinner { display: none; }
.player-loading.error .player-loading-text { color: #C0392B; }
.spinner {
  display: inline-block;
  width: 28px; height: 28px;
  border: 3px solid rgba(255,255,255,0.18);
  border-top-color: #FF7043;
  border-radius: 50%;
  -webkit-animation: spin 900ms linear infinite;
          animation: spin 900ms linear infinite;
  margin-right: 14px;
}
@-webkit-keyframes spin { to { -webkit-transform: rotate(360deg); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* Top bar: back + title. Над iframe'ом, с лёгким градиентом, чтобы
   читалось поверх любой картинки видео. Авто-скрытие синхронно с
   нижними контролами. */
.player-top {
  position: absolute; left: 0; right: 0; top: 0;
  padding: 18px 24px 28px;
  background-image: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0) 100%);
  z-index: 5;
  display: flex; align-items: center;
  transition: opacity 200ms linear;
}
.player-top.hidden { opacity: 0; pointer-events: none; }
.player-back {
  width: 44px; height: 44px;
  border-radius: 22px;
  background: rgba(0, 0, 0, 0.7);
  margin-right: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 22px;
  flex: 0 0 auto;
}
.player-title { color: #fff; font-size: 16px; font-weight: 600; flex: 1; min-width: 0;
                overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Bottom controls: play/pause + progress + time. Single row, минимально. */
.player-controls {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 28px 24px 18px;
  background-image: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
  z-index: 5;
  display: flex; align-items: center;
  transition: opacity 200ms linear;
}
.player-controls.hidden { opacity: 0; pointer-events: none; }
.player-play {
  width: 44px; height: 44px;
  border-radius: 22px;
  background: #FF7043;
  color: #fff;
  font-size: 18px;
  margin-right: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.player-progress {
  flex: 1 1 auto;
  height: 5px;
  background: rgba(255,255,255,0.20);
  border-radius: 3px;
  position: relative;
  margin-right: 16px;
  cursor: pointer;
  /* Расширяем интерактивную область вверх/вниз чтобы было легче
     попасть мышью, не увеличивая видимую высоту полосы. */
  padding: 10px 0; background-clip: content-box;
}
.player-progress-fill {
  position: absolute;
  left: 0; top: 10px; bottom: 10px;
  background: #FF7043;
  border-radius: 3px;
  width: 0;
}
.player-time {
  color: #DDD;
  font-size: 14px;
  min-width: 96px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

/* ---- Profile / settings / about ---- */
.page {
  width: 100%; height: 100%;
  overflow-y: auto;
  padding: 32px 40px 40px;
}
.page-title { font-size: 28px; font-weight: 700; margin: 0 0 20px; color: #2A2520; }
.profile-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 20px; }
.card-block {
  background: #FFFFFF;
  border: 1px solid #EADFCF;
  border-radius: 14px;
  padding: 20px 24px;
  margin-bottom: 16px;
}
.row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid #F0E7D8;
}
.row:last-child { border-bottom: 0; }
.row-key { color: #8B7E70; font-size: 14px; }
.row-val { font-size: 16px; color: #2A2520; }
.list-item {
  display: flex; align-items: center;
  padding: 14px 16px;
  border-radius: 10px;
  margin-bottom: 8px;
  background: #FFFFFF;
  border: 1px solid #EADFCF;
}
.list-item .label { flex: 1; }
.list-item .icon-pos { color: #FF7043; margin-left: 12px; }

.toggle {
  display: inline-flex; align-items: center;
  padding: 10px 18px;
  border-radius: 22px;
  background: #F2EBE0;
  font-size: 14px; color: #7A6E5F;
}
.toggle.on { background: #FF7043; color: #fff; }

/* ---- Modal / toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 40px;
  transform: translateX(-50%);
  background: #2A2520;
  color: #FFFAF2;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 15px;
  z-index: 50;
  box-shadow: 0 6px 20px rgba(120, 90, 60, 0.25);
}

/* ---- Empty state ---- */
.empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  width: 100%; height: 100%;
  color: #6A5F52;
  font-size: 16px;
  text-align: center;
  padding: 24px;
}
.empty .empty-title { font-size: 22px; color: #2A2520; margin-bottom: 10px; }
.empty .qr-img {
  width: 160px; height: 160px;
  margin: 16px 0 12px;
  padding: 10px;
  background: #fff;
  border: 1px solid #EADFCF;
  border-radius: 10px;
  display: block;
}
.empty .qr-hint {
  color: #2A2520;
  font-size: 14px;
  max-width: 360px;
  margin: 0 0 8px;
  font-weight: 600;
}
.empty .qr-link {
  color: #FF7043;
  font-size: 12px;
  word-break: break-all;
  max-width: 360px;
}
.empty .qr-wait {
  color: #8B7E70;
  font-size: 13px;
  margin-top: 12px;
}
