/* task_record.css — стили task-режима (SPA 1.8.0, T4 + баги живого теста):
 * экраны записи 9/16, дизайн 1-в-1 Instagram (стеклянные кнопки, шеврон).
 * Было: SPA 1.7.0.
 *
 * Тёмная тема ленты — те же токены :root из style.css (--bg/--fg/--muted/
 * --accent/--glass/--radius/--safe-*). Только префикс классов tr-* (+ #tr-*),
 * review-стили style.css не изменяются; часть классов переиспользуется как
 * есть (.btn/.chip/.sheet/.sound-btn/.done-*/buffer-rotate). */

/* task-режим перекрывает review-UI (страховка поверх инертности app.js) */
body.tr-on #feed,
body.tr-on #topbar,
body.tr-on #controls,
body.tr-on #stories,
body.tr-on #sheet,
body.tr-on #reject-sheet,
body.tr-on #done,
body.tr-on #notg,
body.tr-on #fallback {
  display: none !important;
}

/* ---- Корень task-режима ---- */
.tr-root {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
  /* Instagram: системный шрифт iOS/Android */
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.tr-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.tr-center {
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* ---- Видео-зона (эталон / предпросмотр / рилс) ---- */
.tr-video-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #000;
  overflow: hidden;
}
.tr-ref,
.tr-take {
  width: 100%;
  height: 100%;
  background: #000;
}
.tr-ref {
  object-fit: cover; /* фулскрин-кроп как в Reels */
}
.tr-take {
  object-fit: contain; /* предпросмотр/рилс — без кадрирования */
}
.tr-reel-wrap {
  flex: 0 0 auto;
  height: 46vh;
  border-radius: 12px;
  overflow: hidden;
}
.tr-video-error {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 15px;
  text-align: center;
  padding: 24px;
  background: rgba(13, 13, 18, 0.72);
}

/* ---- LENTA: чипы сверху, действия снизу ---- */
.tr-lenta-top {
  position: absolute;
  top: calc(14px + var(--safe-top));
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  z-index: 21;
  pointer-events: none;
}
.tr-lenta-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  padding: 14px 16px 4px;
  flex: 0 0 auto;
}
.tr-lenta-actions .btn {
  flex: 1 1 0;
  text-align: center;
  text-decoration: none;
}
.tr-lenta-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
  padding: 8px 22px 0;
  flex: 0 0 auto;
}
.tr-hint {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 8px 16px calc(12px + var(--safe-bottom));
  flex: 0 0 auto;
}
.tr-lenta {
  position: absolute;
  inset: 0;
}
.tr-script {
  white-space: pre-wrap;
}
.tr-tips {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

/* ---- КАМЕРА (видоискатель + кольцо-таймер Stories) ---- */
.tr-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.tr-cam-top {
  position: absolute;
  top: calc(10px + var(--safe-top));
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 14px;
  z-index: 21;
}
.tr-cam-btn {
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 50%;
  font-size: 19px;
}
.tr-cam-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(18px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 21;
}
.tr-rec-time {
  font-size: 21px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.65);
}
.tr-rec-label {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
/* Круглая кнопка RECORD: кольцо-таймер вокруг ядра (как в Stories) */
.tr-recbtn {
  position: relative;
  width: 88px;
  height: 88px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  padding: 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.tr-recbtn:active .tr-recbtn-core {
  transform: scale(0.92);
}
.tr-ring {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  transform: rotate(-90deg); /* старт кольца сверху */
  pointer-events: none;
}
.tr-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.28);
  stroke-width: 5;
}
.tr-ring-fill {
  fill: none;
  stroke: rgba(255, 255, 255, 0.95);
  stroke-width: 5;
  stroke-linecap: round;
}
/* предупреждение за 5 сек: кольцо краснеет */
.tr-recbtn.warn .tr-ring-fill {
  stroke: var(--accent);
}
.tr-recbtn.warn .tr-rec-label {
  color: var(--accent);
  animation: tr-blink 1s step-end infinite;
}
@keyframes tr-blink {
  50% { opacity: 0.25; }
}
.tr-recbtn-core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  border-radius: 50%;
  background: #fff;
  transition: all 0.18s ease;
}
/* идёт запись: ядро — красный квадрат со скруглением (стоп) */
.tr-recbtn-core.recording {
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 10px;
  background: var(--accent);
}

/* ---- UPLOAD: прогресс ---- */
.tr-progress {
  width: 100%;
  max-width: 320px;
  height: 6px;
  margin: 18px auto 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
}
.tr-progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.2s ease;
}

/* ---- STITCHING: спиннер (реюз buffer-rotate из style.css) ---- */
.tr-spin {
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.22);
  border-top-color: rgba(255, 255, 255, 0.88);
  animation: buffer-rotate 0.9s linear infinite;
}

/* ---- Тост task-режима ---- */
#tr-toast {
  position: fixed;
  left: 50%;
  bottom: calc(104px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 80;
  max-width: 86vw;
  text-align: center;
}

/* ---- Вертикаль: CSS-поворот landscape-кадра (живой поток/превью
   фолбэк-записи; размеры бокса ставит TaskCamera.orientVideo) ---- */
.tr-preview.tr-rot-90,
.tr-preview.tr-rot-270,
.tr-take.tr-rot-90,
.tr-take.tr-rot-270 {
  position: absolute;
  right: auto;
  bottom: auto;
  max-width: none;
  transform-origin: center center;
}
.tr-preview.tr-rot-90,
.tr-take.tr-rot-90 {
  transform: rotate(90deg);
}
.tr-preview.tr-rot-270,
.tr-take.tr-rot-270 {
  transform: rotate(270deg);
}

/* ---- Instagram: стеклянные кнопки (glassmorphism) ---- */
.btn-glass,
.tr-cam-btn {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  transition: transform 0.12s ease, background 0.12s ease;
}
.btn-glass:active,
.tr-cam-btn:active {
  transform: scale(0.97);
  background: rgba(255, 255, 255, 0.22);
}

/* «✅ Отправить» — акцентная (IG primary CTA) */
.btn-glass-accent {
  background: linear-gradient(135deg, #1b74e4, #0095f6);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  font-weight: 700;
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(0, 149, 246, 0.38);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn-glass-accent:active {
  transform: scale(0.97);
  filter: brightness(1.06);
}

/* «Подробнее» — яркая иконка-шеврон без текста (IG, стеклянный кружок) */
.tr-details-btn {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff; /* яркая иконка */
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}
.tr-details-btn:active {
  transform: scale(0.94);
  background: rgba(255, 255, 255, 0.22);
}
.tr-details-chevron {
  display: block;
}

/* IG-геометрия: пилюли действий, скругления, тени, отступы */
.tr-lenta-actions .btn {
  border-radius: 999px;
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.1px;
}
.tr-cam-btn {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  font-size: 18px;
}
.tr-hint,
.tr-lenta-note {
  letter-spacing: 0.1px;
}

/* ---- Кнопки-действия в ошибках/финале ---- */
.tr-lenta-actions .btn-dark {
  margin-top: 0;
}
.tr-center .tr-lenta-actions {
  width: 100%;
  max-width: 420px;
  flex-wrap: wrap;
}

/* ---- ▶ Старт по тапу: постер эталона и оверлей превью ----
 * play() БЕЗ жеста отклоняется политикой WebView (Telegram Android):
 * баги «чёрный экран эталона при первой загрузке» и «камера стартует
 * со второго раза» — гарантированный старт ПО ТАПУ (жест). */
.tr-ref-play,
.tr-preview-tap {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  background: rgba(13, 13, 18, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.tr-ref-play-icon,
.tr-preview-tap-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  font-size: 26px;
  padding-left: 4px; /* оптическая центровка ▶ */
  color: #0d0d12;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
.tr-ref-play:active .tr-ref-play-icon,
.tr-preview-tap:active .tr-preview-tap-icon {
  transform: scale(0.94);
}
