/* =====================================================================
   player.css: video stage shared by the full screen player (.player) and
   the inline live player (.stage--inline). On phones and small windows
   player.js adds .is-touch, which swaps the desktop control bar for a
   centre transport and a "Más" sheet.
   ===================================================================== */

.player { position: fixed; inset: 0; z-index: var(--z-player); background: #000; animation: fade-in .2s var(--ease-calm); }
.player .stage { position: absolute; inset: 0; }

.stage { position: relative; background: #000; overflow: hidden; user-select: none; -webkit-user-select: none; color: #fff; }
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.stage.is-idle { cursor: none; }
.stage.is-preparing::before { content: ""; position: absolute; inset: 0; z-index: var(--z-stage-shade); background: rgba(0, 0, 0, .45); pointer-events: none; }

/* Subtitles. Sizes are written into <style id="xh-cue"> by player.js. */
.stage video::cue {
  font-family: var(--font); font-weight: 500; line-height: 1.3; color: #fff; background: transparent;
  text-shadow: 0 0 4px #000, 0 2px 4px #000, 0 0 12px rgba(0, 0, 0, .6);
}
.stage.cue-box video::cue { background: rgba(0, 0, 0, .72); }
.player .stage:not(.is-idle) video::-webkit-media-text-track-container {
  transform: translateY(calc(-1 * (var(--controls-h) - 24px)));
  transition: transform 200ms var(--ease-std);
}

/* "Mejorar nitidez": the canvas sits exactly over the letterboxed picture; subtitles are drawn above it. */
.stage__sharpen { position: absolute; pointer-events: none; }
.stage__cues { position: absolute; left: 4%; right: 4%; bottom: 9%; z-index: var(--z-stage-shade); display: none; justify-content: center; pointer-events: none; text-align: center; transition: transform 200ms var(--ease-std); }
.stage.is-sharpened .stage__cues { display: flex; }
.player .stage.is-sharpened:not(.is-idle) .stage__cues { transform: translateY(calc(-1 * (var(--controls-h) - 24px))); }
.stage__cues span {
  padding: .08em .4em; border-radius: 4px; color: #fff; font-family: var(--font); font-weight: 500; line-height: 1.3; white-space: pre-line;
  text-shadow: 0 0 4px #000, 0 2px 4px #000, 0 0 12px rgba(0, 0, 0, .6);
}
.stage.cue-box .stage__cues span { background: rgba(0, 0, 0, .72); }

/* Scrims behind the chrome. */
.stage__shade { position: absolute; inset: 0; z-index: var(--z-stage-shade); pointer-events: none; }
.stage__shade::before, .stage__shade::after { content: ""; position: absolute; left: 0; right: 0; transition: opacity var(--dur-3); }
.stage__shade::before { top: 0; height: 160px; background: var(--scrim-stage-top); }
.stage__shade::after { bottom: 0; height: 240px; background: var(--scrim-stage-bottom); }
.stage.is-idle .stage__shade::before, .stage.is-idle .stage__shade::after { opacity: 0; }

/* ---------------------------------------------------------------- chrome */
.stage__top, .stage__bottom { position: absolute; left: 0; right: 0; z-index: var(--z-stage-chrome); transition: opacity var(--dur-3); }
.stage.is-idle .stage__top, .stage.is-idle .stage__bottom, .stage.is-idle .stage__transport { opacity: 0; pointer-events: none; }
.stage__top {
  top: 0; display: flex; align-items: center; gap: 16px;
  padding: max(24px, var(--safe-t)) max(32px, var(--safe-r)) 0 max(32px, var(--safe-l));
}
.stage__titles { min-width: 0; flex: 1; }
.stage__title { font-size: 22px; font-weight: 600; letter-spacing: -.01em; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage__subtitle { color: var(--text-2); font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage__ends { flex: none; color: var(--text-2); font-size: 14px; font-weight: 500; white-space: nowrap; }
.stage__bottom { bottom: 0; padding: 0 max(32px, var(--safe-r)) max(28px, var(--safe-b)) max(32px, var(--safe-l)); }

.seekrow { display: grid; grid-template-columns: 64px 1fr 72px; gap: 16px; height: 32px; align-items: center; }
.seekrow__elapsed { text-align: right; font-size: 14px; font-weight: 500; color: rgba(255, 255, 255, .9); }
.time-remaining { justify-self: start; height: 32px; font-size: 14px; font-weight: 500; color: var(--text-2); white-space: nowrap; }
@media (hover: hover) and (pointer: fine) { .time-remaining:hover { color: var(--text); } }

.controls { display: flex; align-items: center; gap: 4px; height: 52px; margin-top: 8px; }
.controls__group { display: flex; align-items: center; gap: 8px; }
.controls__group--end { gap: 4px; }
.controls__spacer { flex: 1; }

.ctrl {
  width: var(--control); height: var(--control); flex: none; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill); color: #fff; transition: background-color var(--dur-2), transform var(--dur-1) var(--ease-std);
}
.ctrl .icon { width: 24px; height: 24px; }
.ctrl:active { transform: scale(.94); }
.ctrl:disabled { opacity: .4; cursor: default; }
@media (hover: hover) and (pointer: fine) { .ctrl:hover { background: var(--fill-2); } }
.ctrl--primary { width: var(--control-lg); height: var(--control-lg); }
.ctrl--primary .icon { width: 30px; height: 30px; }
.ctrl--label { width: auto; padding: 0 16px 0 12px; gap: 8px; font: 600 15px/1 var(--font); }
.ctrl[aria-expanded="true"] { background: var(--fill-2); }
html.is-tv .ctrl:focus-visible { background: var(--inverse); color: var(--on-inverse); }

.quality-tag {
  display: inline-flex; align-items: center; height: 26px; padding: 0 8px; margin: 0 8px; border-radius: 4px;
  color: var(--text-2); font-size: 13px; font-weight: 600; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28); flex: none;
}
button.quality-tag { cursor: pointer; }
@media (hover: hover) and (pointer: fine) { button.quality-tag:hover { color: var(--text); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5); } }

/* Volume: the slider slides out on hover; it is not built on touch screens. */
.volume { display: inline-flex; align-items: center; }
.volume input {
  width: 96px; height: 4px; margin: 0 8px 0 0; accent-color: #fff; cursor: pointer;
  clip-path: inset(0 100% 0 0); transition: clip-path 200ms var(--ease-std);
}
.volume:focus-within input { clip-path: inset(0); }
@media (hover: hover) and (pointer: fine) { .volume:hover input { clip-path: inset(0); } }

/* --------------------------------------------------------------- seek bar */
.seek { position: relative; height: 32px; display: flex; align-items: center; cursor: pointer; touch-action: none; }
@media (pointer: coarse) { .seek { height: 44px; } }
.seek:focus-visible { outline: none; box-shadow: none; }
.seek__track {
  position: relative; width: 100%; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .24);
  transform: scaleY(.67); transition: transform var(--dur-2) var(--ease-std);
}
.seek.is-dragging .seek__track, .seek:focus-visible .seek__track { transform: scaleY(1); }
@media (hover: hover) and (pointer: fine) { .seek:hover .seek__track { transform: scaleY(1); } }
.seek:focus-visible .seek__track { box-shadow: 0 0 0 2px var(--focus-halo), 0 0 0 4px var(--focus); }
.seek__buffered, .seek__played { position: absolute; inset: 0; border-radius: inherit; transform-origin: left; transform: scaleX(0); }
.seek__buffered { background: var(--progress-buffer); }
.seek__played { background: var(--progress); }
.seek__thumb {
  position: absolute; top: 50%; left: 0; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .5); transform: scale(0); transition: transform var(--dur-2);
}
.seek.is-dragging .seek__thumb, .seek:focus-visible .seek__thumb { transform: scale(1); }
@media (hover: hover) and (pointer: fine) { .seek:hover .seek__thumb { transform: scale(1); } }
@media (pointer: coarse) { .seek__thumb { transform: scale(.85); } }
.seek__tip {
  position: absolute; bottom: 36px; padding: 6px 10px; border-radius: 8px; background: var(--overlay);
  font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap;
  transform: translateX(-50%); opacity: 0; pointer-events: none; transition: opacity 120ms;
}
.seek.is-dragging .seek__tip { opacity: 1; }
@media (hover: hover) and (pointer: fine) { .seek:hover .seek__tip { opacity: 1; } }

/* ------------------------------------------------------------------ centre */
.stage__center { position: absolute; inset: 0; z-index: var(--z-stage-center); display: flex; align-items: center; justify-content: center; pointer-events: none; }
.stage__center > * { pointer-events: auto; }
.stage__center > .spinner { width: 40px; height: 40px; pointer-events: none; }
.stage__status {
  position: absolute; left: 50%; top: calc(50% + 48px); z-index: var(--z-stage-center); transform: translateX(-50%);
  color: var(--text-2); font-size: 15px; white-space: nowrap; pointer-events: none; text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}
.stage__bigplay {
  position: absolute; left: 50%; top: 50%; z-index: var(--z-stage-center); width: 80px; height: 80px; margin: -40px 0 0 -40px;
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
  background: rgba(255, 255, 255, .92); color: #0b0b0d; box-shadow: var(--shadow-2);
  opacity: 0; pointer-events: none; transition: opacity 200ms, transform var(--dur-1);
}
.stage__bigplay .icon { width: 34px; height: 34px; margin-left: 4px; }
.stage.is-paused:not(.is-loading):not(.has-error):not(.is-touch) .stage__bigplay { opacity: 1; pointer-events: auto; }
.stage__bigplay:active { transform: scale(.94); }

/* Touch transport: −10 · play · +10 in the middle of the picture. */
.stage__transport {
  position: absolute; inset: 0; z-index: var(--z-stage-center); display: none; align-items: center; justify-content: center; gap: 40px;
  pointer-events: none; transition: opacity var(--dur-3);
}
.stage__transport > * { pointer-events: auto; }
.stage.is-touch .stage__transport { display: flex; }
.stage.is-touch.is-narrow .stage__transport { gap: 28px; }
.stage__transport .ctrl { width: 56px; height: 56px; }
.stage__transport .ctrl .icon { width: 30px; height: 30px; }
.stage__transport .transport__play {
  width: 72px; height: 72px; background: rgba(0, 0, 0, .36); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22);
}
.stage__transport .transport__play .icon { width: 34px; height: 34px; }
.transport__play .spinner { display: none; width: 34px; height: 34px; }
.stage.is-loading .transport__play .icon { display: none; }
.stage.is-loading .transport__play .spinner { display: block; }
.stage.is-loading .stage__transport .ctrl:not(.transport__play) { opacity: .4; pointer-events: none; }
.stage.is-touch .stage__center > .spinner, .stage.has-error .stage__transport { display: none; }

/* Double-tap seek feedback. */
.seek-ripple {
  position: absolute; top: 50%; z-index: var(--z-stage-center); width: 88px; height: 88px; margin: -44px 0 0 -44px;
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
  background: rgba(255, 255, 255, .14); font-size: 15px; font-weight: 700; pointer-events: none;
  animation: ripple-out 600ms var(--ease-std) forwards;
}
@keyframes ripple-out { 0% { opacity: 0; transform: scale(.8); } 20% { opacity: 1; transform: scale(1); } 70% { opacity: 1; } 100% { opacity: 0; } }

/* "Activar sonido": its own slot, never cleared by the loading status. */
.stage__notice { position: absolute; top: calc(max(24px, var(--safe-t)) + 64px); left: 50%; transform: translateX(-50%); z-index: var(--z-stage-notice); }
.stage--inline .stage__notice { top: 56px; }

/* -------------------------------------------------------------- touch mode */
.stage.is-touch .stage__top { gap: 8px; padding: max(12px, var(--safe-t)) max(12px, var(--safe-r)) 0 max(12px, var(--safe-l)); }
.stage.is-touch .stage__title { font-size: 17px; }
.stage.is-touch .stage__subtitle { font-size: 13px; }
.stage.is-touch .stage__bottom { padding: 0 max(12px, var(--safe-r)) max(12px, var(--safe-b)) max(12px, var(--safe-l)); }
.stage.is-touch .seekrow { grid-template-columns: 52px 1fr 60px; gap: 12px; height: 44px; }
.stage.is-touch .seekrow__elapsed, .stage.is-touch .time-remaining { font-size: 13px; }
.stage.is-touch .controls { height: 44px; margin-top: 0; }
.stage.is-touch .stage__notice { top: calc(max(12px, var(--safe-t)) + 52px); }
.stage.is-touch .ctrl--desk, .stage:not(.is-touch) .ctrl--touch { display: none; }
/* Touch bar: Episodios · Siguiente on the left, full screen on the right. */
.stage.is-touch .controls__spacer { display: none; }
.stage.is-touch .controls__group--end { flex: 1; }
.stage.is-touch .ctrl--episodes { order: -1; }
.stage.is-touch .ctrl--fullscreen { margin-left: auto; }
.controls__quality { display: flex; align-items: center; }
.stage__ends[hidden] { display: none; }

/* ------------------------------------------------------- menus and panels */
.menu {
  position: absolute; right: max(32px, var(--safe-r)); bottom: calc(var(--controls-h) + 12px); z-index: var(--z-stage-menu);
  max-height: min(62vh, 520px); max-height: min(62svh, 520px); overflow-y: auto; overscroll-behavior: contain; padding: 12px;
  background: var(--overlay); border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: var(--shadow-3);
  transform-origin: bottom right; animation: menu-in 200ms var(--ease-calm);
}
@keyframes menu-in { from { opacity: 0; transform: scale(.96); } }
.menu__cols { display: grid; grid-template-columns: repeat(var(--cols, 1), 240px); gap: 12px; }
.menu__cols--quality { grid-template-columns: 280px; }
.menu__head { display: block; padding: 8px 12px 6px; color: var(--text-3); }
.menu__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin-top: 8px; padding: 12px 4px 0; border-top: 1px solid var(--line); }
.menu__foot-label { color: var(--text-2); font-size: 14px; font-weight: 500; margin-right: 12px; }
.menu__note { padding: 4px 12px 8px; color: var(--text-3); font-size: 13px; line-height: 1.45; max-width: 30ch; }
.menu__option {
  display: grid; grid-template-columns: 24px 1fr; align-items: center; gap: 4px; width: 100%; height: 44px; padding: 0 12px;
  border-radius: 10px; font: 500 15px/1.2 var(--font); color: var(--text-2); text-align: left;
}
.menu__option .icon { width: 18px; height: 18px; color: #fff; }
.menu__option[aria-checked="true"] { color: var(--text); font-weight: 600; }
@media (hover: hover) and (pointer: fine) { .menu__option:hover { background: rgba(255, 255, 255, .08); color: var(--text); } }
.menu__option:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; box-shadow: none; background: rgba(255, 255, 255, .08); }
.menu__option > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Touch: bottom sheet inside the stage, so it also works in full screen. */
.sheet-scrim { position: absolute; inset: 0; z-index: calc(var(--z-stage-sheet) - 1); background: rgba(0, 0, 0, .45); animation: fade-in 200ms; }
.sheet--player {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: var(--z-stage-sheet); max-height: 72%;
  display: flex; flex-direction: column; background: var(--overlay); border-radius: 20px 20px 0 0;
  padding: 8px max(16px, var(--safe-r)) max(16px, var(--safe-b)) max(16px, var(--safe-l));
  animation: sheet-in 320ms var(--ease-calm);
}
.sheet--player.sheet--tall { max-height: 80%; }
@keyframes sheet-in { from { transform: translateY(100%); } }
.sheet__grabber { width: 36px; height: 4px; margin: 0 auto 4px; border-radius: 2px; background: rgba(255, 255, 255, .3); flex: none; }
.sheet__head { display: flex; align-items: center; gap: 8px; min-height: 52px; flex: none; }
.sheet__title { flex: 1; font-size: 17px; font-weight: 600; }
.sheet__body { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.sheet__body .menu__option { height: 52px; }
.sheet__body .segmented { margin: 4px 0 12px; }
.sheet__line { display: flex; align-items: center; min-height: 52px; padding: 0 12px; color: var(--text-2); font-size: 15px; }
.sheet__body .toggle { width: 100%; justify-content: space-between; min-height: 52px; padding: 0 12px; color: var(--text); }
.sheet__body .menu__head { padding-top: 12px; }

/* Episodes panel: stops above the controls so subtitles and the bar stay visible. */
.panel {
  position: absolute; right: max(24px, var(--safe-r)); top: calc(max(24px, var(--safe-t)) + 64px); bottom: calc(var(--controls-h) + 12px);
  width: 400px; max-width: calc(100% - 48px); z-index: var(--z-stage-panel); display: flex; flex-direction: column;
  background: var(--overlay); border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: var(--shadow-3);
  animation: panel-in 280ms var(--ease-calm);
}
html.is-tv .panel { width: calc(520px * var(--tvu)); }
@keyframes panel-in { from { transform: translateX(24px); opacity: 0; } }
.panel__head { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 0 8px 0 16px; flex: none; }
.panel__head h3 { font-size: var(--fs-title-3); font-weight: 600; }
.panel__count { color: var(--text-2); font-size: 14px; white-space: nowrap; }
.panel__spacer { flex: 1; }
.panel__body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 8px 12px; }
.panel__body .ranges { padding: 0 4px; margin-bottom: 8px; }
.panel__loading { display: flex; justify-content: center; padding: 32px 0; }

/* The season picker in the episodes panel is the shared .picker chip (components.css). */

/* ----------------------------------------------------------------- up next */
.upnext {
  position: absolute; right: max(32px, var(--safe-r)); bottom: calc(var(--controls-h) + 12px); z-index: var(--z-stage-upnext);
  width: min(360px, calc(100% - 32px)); padding: 16px; border-radius: 18px;
  background: var(--overlay); border: 1px solid var(--line-strong); box-shadow: var(--shadow-3);
  animation: menu-in 200ms var(--ease-calm);
}
.stage.is-touch .upnext { left: 12px; right: 12px; width: auto; bottom: calc(var(--controls-h) + 8px); }
.upnext__label { color: var(--text-3); }
.upnext__title { margin: 6px 0 14px; font-size: 17px; font-weight: 600; line-height: 1.3; }
.upnext__actions { display: flex; gap: 8px; }
.upnext__play { position: relative; overflow: hidden; isolation: isolate; }
.upnext__play.is-counting::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background: rgba(11, 11, 13, .12);
  transform-origin: left; animation: countdown 8s linear forwards;
}
@keyframes countdown { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ------------------------------------------------------------------- alert */
.alert {
  width: min(440px, calc(100% - 32px)); padding: 28px; border-radius: 20px; text-align: center;
  background: var(--overlay); border: 1px solid var(--line-strong);
}
.alert__icon-wrap { display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; margin: 0 auto 14px; border-radius: 50%; background: var(--surface-3); }
.alert__icon-wrap .icon { width: 22px; height: 22px; color: var(--text-2); }
.alert h3 { font-size: 20px; font-weight: 600; }
.alert p { max-width: 40ch; margin: 8px auto 20px; color: var(--text-2); font-size: 15px; line-height: 1.55; }
.alert__actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.alert .alert__note { margin: -8px auto 16px; color: var(--text-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.stage--inline .alert .alert__note { margin: -4px auto 12px; font-size: 12px; }
.stage--inline .alert { padding: 18px; }
.stage--inline .alert p { margin-bottom: 14px; font-size: 14px; }
.stage--inline .alert__icon-wrap { width: 40px; height: 40px; margin-bottom: 10px; }

/* ------------------------------------------------------------- live player */
.stage--inline { aspect-ratio: 16 / 9; border-radius: var(--radius-lg); box-shadow: var(--shadow-stage), 0 0 0 1px var(--line); }
.stage--inline .stage__top { gap: 10px; padding: 14px 16px 0; }
.stage--inline .stage__title { font-size: 15px; font-weight: 600; }
.stage--inline .stage__bottom { padding: 0 12px 10px; }
.stage--inline .controls { height: 44px; margin-top: 0; }
.stage--inline .ctrl { width: 40px; height: 40px; }
.stage--inline .ctrl .icon { width: 22px; height: 22px; }
@media (pointer: coarse) { .stage--inline .ctrl { width: 44px; height: 44px; } }
.stage:fullscreen, .stage:-webkit-full-screen { border-radius: 0; }
.live-badge {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; flex: none;
  border-radius: var(--radius-pill); background: rgba(0, 0, 0, .55); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
  font: 600 12px/1 var(--font); letter-spacing: .08em; color: #fff;
}
.live-badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--live); animation: pulse-opacity 1.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .live-badge::before { animation: none; } }

/* Channel OSD after a channel change. */
.stage__osd {
  position: absolute; left: max(16px, var(--safe-l)); bottom: 56px; z-index: var(--z-stage-osd);
  display: flex; gap: 14px; align-items: center; padding: 12px 16px; border-radius: 16px; background: var(--overlay);
  opacity: 0; transition: opacity 240ms; pointer-events: none;
}
.stage__osd.is-visible { opacity: 1; transition-duration: 160ms; }
.stage__osd-logo { display: flex; align-items: center; justify-content: center; width: 72px; height: 48px; border-radius: 8px; background: var(--surface-2); overflow: hidden; flex: none; }
.stage__osd-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.stage__osd-num { font-size: 28px; font-weight: 700; }
.stage__osd-name { font-size: 20px; font-weight: 600; }
.stage__osd-cat { color: var(--text-2); font-size: 14px; }
.stage:fullscreen .stage__osd, html.is-tv .stage__osd { left: max(32px, var(--safe-l)); bottom: 96px; transform: scale(1.5); transform-origin: bottom left; }

/* ------------------------------------------------------------------ TV size */
html.is-tv .stage__title { font-size: calc(32px * var(--tvu)); }
html.is-tv .seek__track { height: 8px; }
html.is-tv .seek__thumb { width: 24px; height: 24px; margin: -12px 0 0 -12px; }
html.is-tv .menu__option { height: calc(56px * var(--tvu)); font-size: var(--fs-callout); }
