/* === СТИЛИ КОМПОНЕНТА ПЛЕЕРА === */
/* Контейнер плеера и оверлей */
.player-container {
    position: relative;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    background-color: #000;
    outline: none;
    display: block;
    min-height: 200px;

    /* НОВОЕ: базовый масштаб для панели управления */
    --controls-scale: 1;
}
.player-container:fullscreen { aspect-ratio: auto; border-radius: 0; }

/* Оверлей управления */
.controls-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 25%),
                linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 25%);
    pointer-events: none;
}
.player-container.controls-visible .controls-overlay { opacity: 1; }
.top-panel, .bottom-panel { pointer-events: auto; }

/* Панель управления внизу */
.bottom-stack { left: 0; right: 0; bottom: 0; position: absolute; display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; pointer-events: none; z-index: 6; }
.bottom-stack .bottom-panel { pointer-events: auto; }

video {
    /* ИСПРАВЛЕНИЕ: Видео должно занимать все доступное пространство контейнера, сохраняя пропорции */
    width: 100%;
    height: 100%;
    object-fit: contain; /* Это важно, чтобы видео не искажалось */
    display: block;
}


/* --- Оверлей и панели управления --- */
.controls-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 25%),
                linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 25%);
    pointer-events: none;
}
.top-panel, .bottom-panel {
    pointer-events: auto;
}
.player-container.controls-visible .controls-overlay {
    opacity: 1;
}

.top-panel {
    padding: 20px 25px;
    text-shadow: 0 0 8px rgba(0,0,0,0.8);
}

/* НОВОЕ: чуть адаптивнее общий отступ снизу */
.bottom-panel {
    padding: clamp(6px, 1.5vw, 10px) clamp(10px, 2vw, 25px) clamp(10px, 2.2vw, 15px);
}

.controls-panel {
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto; /* клики по внутренним элементам */

    /* НОВОЕ: пропорциональное масштабирование панели */
    transform: scale(var(--controls-scale));
    transform-origin: bottom center;
    will-change: transform;
    gap: clamp(6px, 1.7vw, 10px);
}

.controls-left, .controls-right, .controls-center {
    display: flex;
    align-items: center;
    gap: 10px;
}
.controls-left, .controls-right { flex: 1; }
.controls-right { justify-content: flex-end; }
.controls-center { flex: 2; justify-content: center; }

/* --- Кнопки и индикаторы --- */
.control-btn {
    background: transparent;
    border: none;
    color: white;
    padding: clamp(4px, 1.2vw, 8px);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, transform 0.1s ease;
}
.control-btn:hover { background-color: rgba(255, 255, 255, 0.2); transform: scale(1.1); }
.control-btn:focus-visible {
    outline: 2px solid var(--focus-outline-color);
    outline-offset: 2px;
    background-color: rgba(255, 255, 255, 0.2);
}

/* Центровой индикатор */
#center-indicator {
    position: absolute;
    inset: 0;
    /* было: display: block; */
    display: grid;           /* центрируем содержимое */
    place-items: center;     /* по центру по обеим осям */
    pointer-events: none;
    text-align: center;
}
.center-indicator svg { width: 80px; height: 80px; color: rgba(255,255,255,0.8); opacity: 0; transform: scale(0.5); transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28); }
.center-indicator svg.visible { opacity: 1; transform: scale(1); }

/* Прогресс-бар */
.progress-bar-container { margin-bottom: clamp(4px, 1.2vw, 10px); padding: 5px 0; }
.progress-bar { width: 100%; }

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    height: clamp(14px, 2.4vw, 18px);
}

/* --- Бегунок (Thumb) --- */
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    margin-top: -6px;
    width: 20px; height: 20px;
    background: var(--primary-color);
    border: 3px solid white;
    border-radius: 50%;
    transition: transform 0.2s ease;
}
input[type="range"]::-moz-range-thumb {
    width: 14px; height: 14px;
    background: var(--primary-color);
    border: 3px solid white;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

/* --- Бегунок при наведении --- */
input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.15); }
input[type="range"]:hover::-moz-range-thumb { transform: scale(1.15); }
input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 3px solid var(--focus-outline-color); outline-offset: 2px; }

/* --- Дорожка (Track) --- */
input[type="range"]::-webkit-slider-runnable-track {
    height: 8px;
    border-radius: 5px;
    background: linear-gradient(
      to right,
      var(--primary-color) 0%,
      var(--primary-color) var(--fill-percent, 0%),
      rgba(255, 255, 255, 0.3) var(--fill-percent, 0%),
      rgba(255, 255, 255, 0.3) 100%
    );
    transition: height 0.2s ease;
}
input[type="range"]::-moz-range-track {
    height: 8px;
    border-radius: 5px;
    background: linear-gradient(
      to right,
      var(--primary-color) 0%,
      var(--primary-color) var(--fill-percent, 0%),
      rgba(255, 255, 255, 0.3) var(--fill-percent, 0%),
      rgba(255, 255, 255, 0.3) 100%
    );
    transition: height 0.2s ease;
}

/* --- Дорожка при наведении --- */
input[type="range"]:hover::-webkit-slider-runnable-track { height: 10px; }
input[type="range"]:hover::-moz-range-track { height: 10px; }


.time-display { font-size: clamp(12px, 2.2vw, 16px); min-width: clamp(80px, 14vw, 110px); }

/* === СТИЛИ SVG ИКОНОК ПЛЕЕРА === */
.control-btn svg { width: clamp(20px, 2.6vw, 28px); height: clamp(20px, 2.6vw, 28px); }
.play-pause-btn svg { width: clamp(28px, 3.2vw, 36px); height: clamp(28px, 3.2vw, 36px); }

/* Переключение иконок Play/Pause по классам */
.play-pause-btn .icon-play,
.play-pause-btn .icon-pause { display: none !important; }
.play-pause-btn.is-paused .icon-play { display: block !important; }
.play-pause-btn.is-playing .icon-pause { display: block !important; }

/* Переключение иконок Fullscreen по состоянию контейнера */
.fullscreen-btn .icon-fullscreen-enter { display: inline-block !important; }
.fullscreen-btn .icon-fullscreen-exit  { display: none !important; }

/* Стандартный fullscreen */
.player-container:fullscreen .fullscreen-btn .icon-fullscreen-enter { display: none !important; }
.player-container:fullscreen .fullscreen-btn .icon-fullscreen-exit  { display: inline-block !important; }

/* Safari/iOS */
.player-container:-webkit-full-screen .fullscreen-btn .icon-fullscreen-enter { display: none !important; }
.player-container:-webkit-full-screen .fullscreen-btn .icon-fullscreen-exit  { display: inline-block !important; }

/* Рендеринг контуров иконки чуть четче на малых размерах */
.fullscreen-btn svg {
    width: 15px !important;
    height: 15px !important;
    shape-rendering: crispEdges;
    -webkit-font-smoothing: antialiased;
    text-rendering: geometricPrecision;
}

/* === УЛУЧШЕННЫЕ ПОЛЗУНКИ (громкость и прогресс) === */
.volume-container { display: flex; align-items: center; }
.volume-slider { width: 0; opacity: 0; transition: width 0.3s ease, opacity 0.3s ease; }
.volume-container:hover .volume-slider, .volume-slider:focus-visible {
    width: clamp(60px, 12vw, 80px);
    opacity: 1;
}

/* === СТИЛИ МЕНЮ НАСТРОЕК ПЛЕЕРА === */
.settings-container { position: relative; display: flex; align-items: center; }
.settings-menu {
    position: absolute; bottom: 100%; right: 0; margin-bottom: 15px;
    background-color: #272B30; border: 1px solid #495057; border-radius: 5px;
    padding: 8px; width: 220px; box-shadow: 0 0 15px rgba(0,0,0,0.5);
    opacity: 0; visibility: hidden; transform: translateY(10px);
    transition: all 0.2s ease-out; z-index: 50; pointer-events: auto; /* поверх skip */
}
.settings-menu.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.settings-menu-section { display: flex; flex-direction: column; }
.settings-menu-item { background: none; border: none; color: #e0e0e0; text-align: left; padding: 8px 12px; border-radius: 4px; cursor: pointer; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.settings-menu-item:hover { background-color: rgba(255, 255, 255, 0.1); }
.settings-menu-item.active { background-color: var(--primary-color); color: white; font-weight: bold; }
.settings-menu-title { font-size: 12px; color: #adb5bd; text-transform: uppercase; letter-spacing: .08em; margin: 6px 0 4px; padding-top: 6px; border-top: 1px solid #3a3f44; }
.settings-root, .settings-submenu { display: none; }
.settings-root.active, .settings-submenu.active { display: flex; flex-direction: column; }
.settings-menu-header { display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin-bottom: 4px; border-bottom: 1px solid #3a3f44; color: #e0e0e0; font-size: 13px; }
.settings-back-btn { background: none; border: none; color: #e0e0e0; cursor: pointer; padding: 4px 8px; border-radius: 4px; }
.settings-back-btn:hover { background-color: rgba(255,255,255,0.1); }

/* Кнопка пропуска — инлайн в центре управления (перед Prev) */
#skip-button-container {
    position: static !important;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    margin-right: 10px;  /* перед «Предыдущая серия» */
    flex: 0 0 auto;
}
.skip-button {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: rgba(30,30,30,0.85);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.35);
    display: grid; place-items: center;
    font-weight: 700; font-size: 14px;
    cursor: pointer;
    transition: transform .12s ease, background-color .15s ease, opacity .2s ease;
    opacity: 0; transform: scale(0.9);
    position: relative; z-index: 9; pointer-events: auto;
}
.skip-button.visible { opacity: 1; transform: scale(1); }
.skip-button:hover { background: rgba(50,50,50,0.9); }
.skip-button .countdown { font-variant-numeric: tabular-nums; line-height: 1; }
.skip-button span {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Удаляем возможные старые позиционирования */
#skip-button-container.old, #skip-button-container.bottom {
    position: static !important; bottom: auto !important; right: auto !important; left: auto !important;
}

/* Оверлей загрузки */
.player-loading {
    position: absolute; inset: 0;
    display: none;
    align-items: center; justify-content: center;
    background: rgba(0,0,0,0.35); z-index: 8;
}
.player-container.is-loading .player-loading { display: flex; }

/* Полоса серий под плеером */
.player-episode-strip { width: 100%; margin-top: 0.75rem; grid-column: 1 / 2; }
.episode-strip-wrapper {
    position: relative; width: 100%;
    display: grid; grid-template-columns: 34px 1fr 34px; gap: 8px;
    align-items: center; pointer-events: auto;
}
.episode-strip-wrapper .episode-nav.prev { grid-column: 1; }
.episode-strip-wrapper .episode-strip { grid-column: 2; }
.episode-strip-wrapper .episode-nav.next { grid-column: 3; }

/* Мобильные корректировки */
@media (max-width: 767.98px) {
    .skip-button { width: 38px; height: 38px; font-size: 13px; }
}

/* Кнопка пропуска — уменьшение на очень узких экранах */
@media (max-width: 575.98px) {
    .skip-button { width: 34px; height: 34px; font-size: 12px; }
}

/* Метаданные: по умолчанию показываем до 2 строк, дальше — кнопка "развернуть" */
.meta-list .meta-value { display: flex; align-items: center; gap: .25rem; }
.meta-list .meta-content {
  min-width: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}
.meta-list .meta-item.expanded .meta-content {
  -webkit-line-clamp: unset;
  line-clamp: unset;
  -webkit-box-orient: initial;
  display: block;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}
.meta-list .meta-toggle i { transition: transform .2s ease; }
.meta-list .meta-item.expanded .meta-toggle i { transform: rotate(180deg); }

