/* =============== IMMERSIVE WORKOUT SCREEN =============== */
/* Модульный CSS для полноэкранного режима тренировки */

/* Экран — контейнер для fullscreen видео */
#active-workout {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100dvh !important;
    height: var(--tg-viewport-stable-height, 100dvh) !important;
    overflow: hidden;
    background: #1E1B14 !important;
    z-index: 9999;
}

#active-workout .header {
    display: none;
}

#active-workout .main-content {
    padding: 0;
    max-height: none;
    overflow: visible;
}

/* ---- Скрыть нативные контролы видео (MAX WebView показывает их принудительно) ---- */
.immersive-video::-webkit-media-controls,
.immersive-video-bg::-webkit-media-controls {
    display: none !important;
    -webkit-appearance: none;
}
.immersive-video::-webkit-media-controls-enclosure,
.immersive-video-bg::-webkit-media-controls-enclosure {
    display: none !important;
}

/* ---- Fullscreen видео ---- */
.immersive-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    transition: object-fit 0.3s;
}

/* Фоновое размытое видео (для горизонтальных) */
.immersive-video-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    filter: blur(30px) brightness(0.4);
    transform: scale(1.1);
    display: none;
}

/* Горизонтальное видео на вертикальном экране */
.immersive-video--landscape {
    object-fit: contain;
    z-index: 1;
}

/* Landscape режим — убираем градиенты, приоритет высоты */
#active-workout.landscape-mode .workout-overlay-top {
    background: none !important;
    padding-bottom: 8px;
}
#active-workout.landscape-mode .workout-overlay-bottom {
    background: none !important;
    padding-top: 12px;
}
#active-workout.landscape-mode .immersive-video {
    object-fit: none;
    width: auto;
    height: 100%;
    left: 50%;
    transform: translateX(-50%);
}

/* Подсказка "Поверни телефон" */
.rotate-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 24px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 16px;
    animation: fadeIn 0.3s ease-out;
    pointer-events: auto;
}
.rotate-hint-icon {
    animation: rotatePhone 2.5s ease-in-out infinite;
}
.rotate-hint-text {
    color: white;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
}
@keyframes rotatePhone {
    0%, 15% { transform: rotate(0deg); }
    35%, 65% { transform: rotate(-90deg); }
    85%, 100% { transform: rotate(0deg); }
}
@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ===== Единый стиль кнопок-действий тренировки (как .btn-primary приложения) ===== */
/* Квадратная (radius 14px = --border-radius-small) + акцентный цвет темы (--gradient-primary). */
.imm-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 24px;
    background: var(--gradient-primary, #C0643E);
    color: #fff;
    border: none;
    border-radius: var(--border-radius-small, 14px);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb, 192,100,62), 0.3);
    transition: transform 0.15s ease, filter 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
.imm-action-btn:active { transform: scale(0.97); filter: brightness(0.95); }
/* Растянуть на всю ширину (нижняя кнопка) */
.imm-action-btn--block { width: 100%; }

/* W5: фаза техники — бейдж + кнопка пропуска */
.technique-badge {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 101;
    padding: 6px 16px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 20px;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
    animation: fadeIn 0.3s ease-out;
    pointer-events: none;
}
/* 14.10.2026 (Тимур: подсказки перекрывают название): бейдж — в нижней панели над кнопкой пропуска */
.workout-overlay-bottom .technique-badge {
    position: static;
    transform: none;
    display: block;
    width: max-content;
    margin: 0 auto 10px;
}
/* Кнопка пропуска техники теперь в нижней панели (.workout-overlay-bottom),
   вид из .imm-action-btn--block, позиционирование не нужно. */
#techniqueSkipBtn { margin-top: 4px; animation: fadeIn 0.3s ease-out; }

/* Лоадер видео */
.immersive-video-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: linear-gradient(145deg, #2C2417 0%, #1E1B14 100%);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}
.immersive-video-loader.active {
    display: flex;
}
.immersive-video-loader-ring {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.15);
    border-top-color: rgba(255,255,255,0.7);
    border-radius: 50%;
    animation: loaderSpin 0.8s linear infinite;
}
.immersive-video-loader-text {
    color: rgba(255,255,255,0.5);
    font-size: 13px;
    font-weight: 500;
}
@keyframes loaderSpin {
    to { transform: rotate(360deg); }
}

.immersive-fallback {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: linear-gradient(145deg, #2C2417 0%, #1E1B14 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.immersive-fallback-icon {
    font-size: 64px;
    opacity: 0.25;
}

.immersive-fallback-text {
    font-size: 16px;
    font-weight: 500;
    color: rgba(255,255,255,0.35);
}

/* ---- Top overlay (название, таймер, прогресс) ---- */
.workout-overlay-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    background: linear-gradient(to bottom, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.4) 70%, transparent 100%);
    padding: 12px 16px 24px;
    padding-top: max(12px, env(safe-area-inset-top));
}

.overlay-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.overlay-exercise-row {
    color: #fff;
}

.immersive-back-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.immersive-back-btn:active {
    background: rgba(255,255,255,0.3);
}

.immersive-top-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.immersive-timer {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 8px 14px;
    border-radius: 20px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
}

.immersive-sound-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.immersive-sound-btn:active {
    background: rgba(255,255,255,0.3);
}

/* Ручной масштаб видео — растянуть на весь экран */
.immersive-video.scale-fill {
    object-fit: cover !important;
}

.immersive-exercise-info {
    text-align: left;
    color: #fff;
    flex: 1;
    min-width: 0;
}

.immersive-exercise-counter {
    font-size: 11px;
    font-weight: 500;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.immersive-exercise-name {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.immersive-exercise-reps {
    font-size: 18px;
    font-weight: 600;
    opacity: 0.85;
    margin-top: 4px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

/* Progress bar */
.immersive-progress {
    height: 3px;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
    margin-bottom: 12px;
    overflow: hidden;
}

.immersive-progress-fill {
    height: 100%;
    background: var(--primary, #C06A3E);
    border-radius: 2px;
    transition: width 0.4s ease;
    width: 0%;
}

/* ---- Bottom overlay (подходы, навигация) ---- */
.workout-overlay-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.5) 50%, transparent 100%);
    padding: 40px 20px 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}

/* ---- Пояснение к упражнению (утяжелители): строкой под дозой, без подложки ---- */
.immersive-exercise-note {
    margin-top: 6px;
    font-size: 15px;
    line-height: 1.35;
    color: rgba(255,255,255,0.88);
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

/* ---- Экран подготовки перед упражнением (Тимур 14.10.2026) ---- */
/* Подготовка перед упражнением — окно как наши обычные всплывающие (showCustomAlert в js/utils.js):
   затемнение, белая карточка по центру, значок, заголовок, текст, кнопка. Тимур 15.10.2026. */
.imm-prep {
    position: absolute;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(env(safe-area-inset-top, 0px) + 20px) 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    overflow-y: auto;
}
.imm-prep-card {
    margin: auto;
    width: 100%;
    max-width: 400px;
    background: #FFFFFF;
    border: 1px solid #E4DDD0;
    border-radius: 16px;
    padding: 32px 24px;
    box-shadow: 0 4px 20px rgba(var(--primary-rgb), 0.15);
    text-align: center;
}
.imm-prep-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px auto;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}
.imm-prep-title { margin: 0 0 12px 0; color: #2A2A2A; font-size: 20px; font-weight: 600; line-height: 1.3; }
.imm-prep-text { margin: 0 0 24px 0; color: #8B8680; font-size: 16px; line-height: 1.5; text-align: left; white-space: pre-line; }
.imm-prep-btn {
    width: 100%;
    padding: 16px 20px;
    border: none;
    border-radius: 12px;
    background: var(--gradient-primary);
    color: #fff;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
}

/* ---- Описание техники (сворачиваемое) ---- */
.immersive-description {
    margin-bottom: 16px;
}

.immersive-description-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.85);
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
    transition: color 0.2s;
}

.immersive-description-toggle:active {
    color: #fff;
}

.immersive-description-toggle svg {
    transition: transform 0.2s;
}

.immersive-description-toggle.expanded svg {
    transform: rotate(180deg);
}

.immersive-description-text {
    display: none;
    font-size: 15px;
    font-weight: 500;
    color: rgba(255,255,255,0.75);
    line-height: 1.5;
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 12px;
    border-radius: 10px;
    margin-top: 8px;
}

.immersive-description-text.visible {
    display: block;
    animation: fadeSlideUp 0.2s ease-out;
}

/* ---- Таймер отдыха ---- */
.rest-timer-card {
    text-align: center;
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid rgba(255,255,255,0.1);
    animation: fadeSlideUp 0.3s ease-out;
}

.rest-timer-label {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,0.6);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
}

.rest-timer-value {
    font-size: 48px;
    font-weight: 700;
    color: #fff;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    margin-bottom: 12px;
}

/* Кнопка «Пропустить» отдых — единый стиль .imm-action-btn */
.rest-timer-skip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--gradient-primary, #C0643E);
    color: #fff;
    padding: 11px 24px;
    border-radius: var(--border-radius-small, 14px);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb, 192,100,62), 0.3);
    transition: transform 0.15s ease, filter 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.rest-timer-skip:active {
    transform: scale(0.96);
    filter: brightness(0.95);
}

/* ---- Кнопки подходов ---- */
.immersive-sets-label {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
    width: 100%;
    text-align: center;
}

.immersive-sets-row {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin-bottom: 16px;
}
.immersive-sets {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.immersive-set-btn {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    border: 1.5px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.immersive-set-btn:active {
    transform: scale(0.97);
}

.immersive-set-btn.completed {
    background: var(--success, #7B8F6B);
    border-color: var(--success, #7B8F6B);
    animation: immSetComplete 0.4s ease-out;
}

.immersive-set-btn.completed::after {
    content: '✓';
    position: absolute;
    font-size: 18px;
    font-weight: 700;
}

.immersive-set-btn.completed .set-num {
    opacity: 0;
}

@keyframes immSetComplete {
    0% { transform: scale(1); }
    40% { transform: scale(1.06); }
    100% { transform: scale(1); }
}

/* ---- Строка подходов с навигацией ---- */
.immersive-sets-row {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}
.immersive-sets-nav {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
.immersive-sets-nav:active {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0.95);
}

/* ---- Кнопка завершить (единый стиль .imm-action-btn, на всю ширину) ---- */
.immersive-finish-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: var(--border-radius-small, 14px);
    background: var(--gradient-primary, #C0643E);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb, 192,100,62), 0.3);
    transition: transform 0.15s ease, filter 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
.immersive-finish-btn:active {
    filter: brightness(0.95);
    transform: scale(0.98);
}

/* ---- Кнопка назад (выход из тренировки) ---- */
.immersive-back-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
    outline: none;
    flex-shrink: 0;
    margin-right: 8px;
}
.immersive-back-btn:active {
    background: rgba(255, 255, 255, 0.3);
}

/* ---- Кнопка паузы ---- */
.immersive-pause-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
.immersive-pause-btn:active {
    background: rgba(255, 255, 255, 0.3);
}
.immersive-timer.paused {
    animation: timerBlink 1s ease-in-out infinite;
}
@keyframes timerBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Убираем синие outline на всех кнопках тренировки */
#active-workout button,
#active-workout .immersive-side-btn {
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

/* ---- Анимации ---- */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes immExerciseChange {
    0% {
        opacity: 0;
        transform: translateX(30px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.immersive-animate-in .immersive-exercise-info,
.immersive-animate-in .immersive-sets,
.immersive-animate-in .immersive-description {
    animation: immExerciseChange 0.35s ease-out;
}

/* ---- Медиа-запросы ---- */
@media (max-height: 600px) {
    .immersive-exercise-name {
        font-size: 20px;
    }
    .rest-timer-value {
        font-size: 36px;
    }
    .immersive-set-btn {
        width: 44px;
        height: 44px;
        border-radius: 12px;
    }
}

/* Кругляш цвета резинки на экране упражнения (Тимур 15.08.2026) */
.imm-band-dot {
    display: inline-block;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.85);
    vertical-align: -1px;
}

/* ── Интервальное движение (эллипсоид, EL-01) ─────────────────────────────
   Одна карточка на всё движение: непрерывный таймер, текущий темп, время до
   смены и сопротивление. Панель поверх видео, подсказки — крупно и по центру,
   чтобы читались во время движения. ТЗ Тимура 26.08.2026. */
.el-panel {
    position: absolute;
    left: 0; right: 0; bottom: 170px;   /* выше полосы и кнопки — Тимур 03.09.2026 */
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 0 20px;
    pointer-events: none;            /* панель не перехватывает жесты по видео */
    z-index: 6;
    text-shadow: 0 2px 12px rgba(0, 0, 0, .65);
}
.el-line { color: #fff; font-size: 16px; font-weight: 500; }
.el-line--main { font-size: 30px; font-weight: 700; letter-spacing: .2px; }
.el-line--dim { opacity: .85; font-size: 15px; }

.el-cue {
    margin-top: 10px;
    max-width: 340px;
    padding: 10px 16px;
    border-radius: 14px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-size: 17px; line-height: 1.35; text-align: center;
    opacity: 0; transform: translateY(6px);
    transition: opacity .25s ease, transform .25s ease;
}
.el-cue.visible { opacity: 1; transform: translateY(0); }
/* Предупреждение за пять секунд и команда остановки различаются на вид: человек
   смотрит на экран краем глаза и должен понять разницу без чтения. */
.el-cue--warn { background: rgba(200, 120, 30, .88); }
.el-cue--stop { background: rgba(180, 50, 40, .92); font-weight: 600; }

.el-tech-btn {
    pointer-events: auto;
    margin-top: 12px;
    padding: 9px 20px;
    border: 1px solid rgba(255, 255, 255, .5);
    border-radius: 20px;
    background: rgba(0, 0, 0, .4);
    color: #fff; font-size: 15px; cursor: pointer;
}
.el-tech-btn:active { background: rgba(0, 0, 0, .6); }

@media (prefers-reduced-motion: reduce) {
    .el-cue { transition: none; }
}

/* Кнопка «Техника» интервального движения в верхней панели: внизу она
   перекрывалась подходами и не нажималась (скрины Тимура 02.09.2026). */
.el-tech-btn--top {
    margin-top: 8px;
    padding: 6px 14px;
    font-size: 13px;
    align-self: flex-start;
}
