/* ============================================================
   AnimeStream Player — reproductor de video propio (estilo JW Player)
   Vanilla JS + <video> nativo, sin dependencias externas.
   ============================================================ */

.asp-player {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	background: #000;
	overflow: hidden;
	border-radius: inherit;
	-webkit-user-select: none;
	user-select: none;
	touch-action: manipulation;
	font-family: var(--font-sans);
}

.asp-video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: contain;
	background: #000;
	display: block;
}

/* ---------- Overlay: botón grande de play/pausa central ---------- */
.asp-overlay-center {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
	z-index: 3;
}
.asp-big-play {
	pointer-events: auto;
	width: 4.5rem;
	height: 4.5rem;
	border-radius: 999px;
	border: none;
	display: grid;
	place-items: center;
	background: rgba(10, 10, 15, .55);
	color: #fff;
	backdrop-filter: blur(6px);
	cursor: pointer;
	transition: transform .18s cubic-bezier(.22,1,.36,1), background .18s;
}
.asp-big-play:hover { background: linear-gradient(135deg, var(--accent-1), var(--accent-2)); transform: scale(1.06); }
.asp-big-play svg { width: 2rem; height: 2rem; }
.asp-big-play .asp-icon-pause { display: none; }
.asp-player[data-playing="1"] .asp-big-play .asp-icon-play { display: none; }
.asp-player[data-playing="1"] .asp-big-play .asp-icon-pause { display: block; }
.asp-player[data-playing="1"][data-idle="1"] .asp-overlay-center { opacity: 0; pointer-events: none; }
.asp-player[data-playing="1"]:not([data-idle="1"]) .asp-overlay-center { opacity: 1; }

/* Cuando ya está reproduciendo y no está inactivo, igual mostramos un
   botón más discreto solo al pasar el mouse por el centro */
.asp-player[data-playing="1"] .asp-big-play {
	width: 3.5rem; height: 3.5rem; opacity: 0;
}
.asp-player[data-playing="1"]:hover .asp-big-play,
.asp-player[data-playing="1"]:not([data-idle="1"]) .asp-big-play { opacity: 1; }

/* ---------- Spinner de carga/buffering ---------- */
.asp-spinner {
	position: absolute;
	inset: 0;
	display: none;
	align-items: center;
	justify-content: center;
	z-index: 4;
	pointer-events: none;
}
.asp-player[data-buffering="1"] .asp-spinner { display: flex; }
.asp-spinner::after {
	content: "";
	width: 2.75rem;
	height: 2.75rem;
	border-radius: 999px;
	border: 3px solid rgba(255,255,255,.25);
	border-top-color: var(--accent-2, #38bdf8);
	animation: asp-spin .8s linear infinite;
}
@keyframes asp-spin { to { transform: rotate(360deg); } }

/* ---------- Doble-tap para adelantar/retroceder (móvil) ---------- */
.asp-seek-flash {
	position: absolute;
	top: 0; bottom: 0;
	width: 40%;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: .35rem;
	font-weight: 700;
	font-size: 1.05rem;
	color: #fff;
	opacity: 0;
	pointer-events: none;
	z-index: 3;
	background: radial-gradient(circle, rgba(255,255,255,.12), transparent 70%);
}
.asp-seek-flash.left { left: 0; }
.asp-seek-flash.right { right: 0; }
.asp-seek-flash.show { animation: asp-flash .55s ease-out; }
@keyframes asp-flash { 0% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- Barra de controles inferior ---------- */
.asp-controls {
	position: absolute;
	left: 0; right: 0; bottom: 0;
	z-index: 5;
	padding: 1.75rem .75rem .6rem;
	background: linear-gradient(to top, rgba(0,0,0,.85) 0%, rgba(0,0,0,.55) 45%, transparent 100%);
	transition: opacity .22s ease, transform .22s ease;
}
.asp-player[data-idle="1"][data-playing="1"] .asp-controls {
	opacity: 0;
	transform: translateY(6px);
	pointer-events: none;
}
.asp-player:not([data-playing="1"]) .asp-controls,
.asp-player[data-idle="0"] .asp-controls { opacity: 1; transform: none; pointer-events: auto; }

/* Barra de progreso */
.asp-progress {
	position: relative;
	height: 14px;
	margin-bottom: .35rem;
	cursor: pointer;
	display: flex;
	align-items: center;
}
.asp-progress-track { position: relative; width: 100%; height: 4px; border-radius: 999px; background: rgba(255,255,255,.25); overflow: visible; transition: height .12s; }
.asp-progress:hover .asp-progress-track,
.asp-progress.dragging .asp-progress-track { height: 6px; }
.asp-progress-buffered { position: absolute; left: 0; top: 0; bottom: 0; width: 0%; background: rgba(255,255,255,.35); border-radius: 999px; }
.asp-progress-played { position: absolute; left: 0; top: 0; bottom: 0; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--accent-1), var(--accent-2)); }
.asp-progress-handle {
	position: absolute; top: 50%; width: 13px; height: 13px; left: 0%;
	transform: translate(-50%, -50%) scale(0);
	border-radius: 999px; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5);
	transition: transform .12s;
}
.asp-progress:hover .asp-progress-handle,
.asp-progress.dragging .asp-progress-handle { transform: translate(-50%, -50%) scale(1); }
.asp-progress-tooltip {
	position: absolute;
	bottom: 18px;
	transform: translateX(-50%);
	background: rgba(10,10,15,.92);
	color: #fff;
	font-size: .7rem;
	font-variant-numeric: tabular-nums;
	padding: .2rem .45rem;
	border-radius: 6px;
	white-space: nowrap;
	opacity: 0;
	pointer-events: none;
	transition: opacity .12s;
	border: 1px solid rgba(255,255,255,.1);
}
.asp-progress:hover .asp-progress-tooltip,
.asp-progress.dragging .asp-progress-tooltip { opacity: 1; }

/* Fila de botones */
.asp-controls-row {
	display: flex;
	align-items: center;
	gap: .35rem;
	color: #fff;
}
.asp-btn {
	background: transparent;
	border: none;
	color: #fff;
	width: 2.1rem;
	height: 2.1rem;
	border-radius: 8px;
	display: grid;
	place-items: center;
	cursor: pointer;
	flex-shrink: 0;
	transition: background .15s, color .15s;
}
.asp-btn:hover { background: rgba(255,255,255,.14); }
.asp-btn svg { width: 1.15rem; height: 1.15rem; }
.asp-btn .asp-icon-pause,
.asp-player[data-playing="1"] .asp-btn-play .asp-icon-play { display: none; }
.asp-player[data-playing="1"] .asp-btn-play .asp-icon-pause { display: block; }
.asp-btn-mute .asp-icon-vol-mute,
.asp-btn-mute .asp-icon-vol-low { display: none; }
.asp-player[data-muted="1"] .asp-btn-mute .asp-icon-vol-mute { display: block; }
.asp-player[data-muted="1"] .asp-btn-mute .asp-icon-vol-full,
.asp-player[data-muted="1"] .asp-btn-mute .asp-icon-vol-low { display: none; }
.asp-player[data-vol-level="low"]:not([data-muted="1"]) .asp-btn-mute .asp-icon-vol-full { display: none; }
.asp-player[data-vol-level="low"]:not([data-muted="1"]) .asp-btn-mute .asp-icon-vol-low { display: block; }

.asp-btn-fullscreen .asp-icon-compress { display: none; }
.asp-player[data-fullscreen="1"] .asp-btn-fullscreen .asp-icon-expand { display: none; }
.asp-player[data-fullscreen="1"] .asp-btn-fullscreen .asp-icon-compress { display: block; }

/* Botón CC (subtítulos) resaltado cuando hay una pista activa */
.asp-player[data-cc-on="1"] .asp-btn-cc { color: var(--accent-text, #c3b8ff); }

/* Apariencia del texto de los subtítulos (WebVTT) a juego con el tema */
.asp-video::cue {
	background: rgba(0, 0, 0, .7);
	color: #fff;
	font-size: 1.05em;
	font-family: var(--font-sans);
	padding: .1em .3em;
	border-radius: 3px;
}

.asp-volume-wrap {
	display: flex;
	align-items: center;
	width: 0;
	overflow: hidden;
	transition: width .18s ease;
}
.asp-volume-group:hover .asp-volume-wrap,
.asp-volume-group.active .asp-volume-wrap { width: 5.5rem; }
.asp-volume-group { display: flex; align-items: center; }
.asp-volume {
	-webkit-appearance: none;
	appearance: none;
	width: 5rem;
	height: 3px;
	margin-left: .35rem;
	border-radius: 999px;
	background: rgba(255,255,255,.3);
	cursor: pointer;
}
.asp-volume::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 11px; height: 11px; border-radius: 999px;
	background: #fff; cursor: pointer;
	box-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.asp-volume::-moz-range-thumb {
	width: 11px; height: 11px; border-radius: 999px; border: none;
	background: #fff; cursor: pointer;
}

.asp-time {
	font-size: .78rem;
	font-variant-numeric: tabular-nums;
	color: rgba(255,255,255,.9);
	white-space: nowrap;
	margin-left: .15rem;
}
.asp-spacer { flex: 1; }

.asp-title-tag {
	font-size: .78rem;
	color: rgba(255,255,255,.8);
	max-width: 40%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	margin-right: .35rem;
	display: none;
}
@media (min-width: 640px) { .asp-title-tag { display: block; } }

/* ---------- Menús flotantes (velocidad / calidad) ---------- */
.asp-menu-wrap { position: relative; }
.asp-menu-btn {
	font-size: .75rem;
	font-weight: 600;
	padding: 0 .5rem;
	width: auto;
	min-width: 2.4rem;
}
.asp-menu {
	position: absolute;
	bottom: calc(100% + .5rem);
	right: 0;
	min-width: 8.5rem;
	background: rgba(17,17,22,.97);
	border: 1px solid rgba(255,255,255,.1);
	border-radius: 10px;
	padding: .35rem;
	box-shadow: 0 10px 30px rgba(0,0,0,.5);
	display: none;
	max-height: 14rem;
	overflow-y: auto;
}
.asp-menu.open { display: block; }
.asp-menu-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: .5rem;
	width: 100%;
	background: transparent;
	border: none;
	color: #e5e5ea;
	font-size: .8rem;
	text-align: left;
	padding: .4rem .55rem;
	border-radius: 6px;
	cursor: pointer;
}
.asp-menu-item:hover { background: rgba(255,255,255,.08); }
.asp-menu-item[data-active="1"] { color: var(--accent-text, #c3b8ff); font-weight: 600; }
.asp-menu-item[data-active="1"]::after { content: "✓"; }

/* ---------- Fullscreen ---------- */
.asp-player[data-fullscreen="1"] {
	border-radius: 0;
}
.asp-player:fullscreen,
.asp-player:-webkit-full-screen {
	width: 100vw;
	height: 100vh;
}
.asp-player:fullscreen .asp-video,
.asp-player:-webkit-full-screen .asp-video { object-fit: contain; }

/* Cursor oculto sobre el video cuando los controles están inactivos */
.asp-player[data-idle="1"][data-playing="1"] { cursor: none; }

/* Estado de error */
.asp-error {
	position: absolute;
	inset: 0;
	display: none;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: .5rem;
	color: var(--muted, #9a9aa8);
	font-size: .85rem;
	text-align: center;
	padding: 1rem;
	z-index: 6;
	background: #000;
}
.asp-player[data-error="1"] .asp-error { display: flex; }
.asp-player[data-error="1"] .asp-controls,
.asp-player[data-error="1"] .asp-overlay-center { display: none; }

/* Responsive: controles más compactos en pantallas chicas */
@media (max-width: 480px) {
	.asp-controls { padding: 1.25rem .4rem .45rem; }
	.asp-btn { width: 1.9rem; height: 1.9rem; }
	.asp-time { font-size: .7rem; }
	.asp-volume-group { display: none; } /* en móvil el volumen se controla con el hardware */
	.asp-big-play { width: 3.75rem; height: 3.75rem; }
}
