/* NutriLoPets — reproductor de video propio (js/player.js).
   Tokens de diseno/design.md vía tokens.css. Los controles viven en una
   franja propia debajo del cuadro: nunca se superponen a la imagen, porque el
   video de bienvenida lleva los subtítulos incrustados abajo. */

.nlp-player {
  --np-bar: var(--green-900, #0A3326);
  --np-lima: var(--lima, #CFE654);
  --np-lima-soft: var(--lima-soft, #E6F1A6);
  --np-ink: var(--green-900, #0A3326);
  --np-r: var(--r-lg, 20px);
  position: relative;
  display: block;
  width: 100%;
  border-radius: var(--np-r);
  overflow: hidden;
  background: var(--np-bar);
  color: #fff;
  font-family: var(--font, "Outfit", system-ui, sans-serif);
  container-type: inline-size;
  isolation: isolate;
}
.nlp-player:focus { outline: none; }
.nlp-player[hidden], .nlp-player [hidden] { display: none !important; }

/* ---------- Cuadro ---------- */
.nlp-player .np-stage {
  position: relative;
  width: 100%;
  aspect-ratio: var(--np-ar, 16 / 9);
  background: #000;
  overflow: hidden;
}
.nlp-player .np-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%; max-width: none;
  margin: 0; border-radius: 0; aspect-ratio: auto;
  object-fit: contain;            /* nunca recorta: los subtítulos van en la imagen */
  background: #000;
}
.nlp-player.np-compact .np-video { object-fit: cover; }
.nlp-player[data-ui="hide"][data-state="playing"] .np-stage { cursor: none; }

/* ---------- Botones sobre el cuadro ---------- */
.nlp-player .np-big,
.nlp-player .np-again,
.nlp-player .np-retry {
  appearance: none; border: 0; cursor: pointer; font: inherit;
  background: var(--np-lima); color: var(--np-ink);
}
.nlp-player .np-big:hover,
.nlp-player .np-again:hover,
.nlp-player .np-retry:hover { background: var(--np-lima-soft); }

/* Botón grande de reproducir: centrado, solo en pausa o antes de empezar */
.nlp-player .np-big {
  position: absolute; left: 50%; top: 50%;
  width: 5.5rem; height: 5.5rem;
  margin: -2.75rem 0 0 -2.75rem;
  display: grid; place-items: center;
  border-radius: 50%;
  box-shadow: var(--sh-float, 0 26px 50px -22px rgba(10, 51, 38, .4)), 0 0 0 6px rgba(207, 230, 84, .28);
  opacity: 0; visibility: hidden; pointer-events: none;
}
.nlp-player .np-big .np-i { width: 2.5rem; height: 2.5rem; margin-left: .2rem; stroke: currentColor; stroke-width: 6; stroke-linejoin: round; }
/* Cuadro pequeño (celular): el botón no tapa media imagen */
@container (max-width: 519px) {
  .nlp-player:not(.np-compact) .np-big { width: 4rem; height: 4rem; margin: -2rem 0 0 -2rem; }
  .nlp-player:not(.np-compact) .np-big .np-i { width: 1.9rem; height: 1.9rem; }
}
.nlp-player.np-compact .np-big { width: 3.5rem; height: 3.5rem; margin: -1.75rem 0 0 -1.75rem; box-shadow: var(--sh-2, 0 14px 34px -16px rgba(10, 51, 38, .28)), 0 0 0 4px rgba(207, 230, 84, .28); }
.nlp-player.np-compact .np-big .np-i { width: 1.6rem; height: 1.6rem; }
.nlp-player[data-state="idle"] .np-big,
.nlp-player[data-state="paused"] .np-big { opacity: 1; visibility: visible; pointer-events: auto; }
.nlp-player[data-loading="true"] .np-big { opacity: 0; visibility: hidden; pointer-events: none; }

/* Fin del video */
.nlp-player .np-again {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: inline-flex; align-items: center; gap: .6rem;
  height: 3rem; padding: 0 1.4rem 0 1.1rem;
  border-radius: var(--r-pill, 999px);
  font-weight: 700; font-size: 1rem; white-space: nowrap;
  box-shadow: var(--sh-float, 0 26px 50px -22px rgba(10, 51, 38, .4));
}
.nlp-player .np-again .np-i { width: 1.4rem; height: 1.4rem; }
.nlp-player.np-compact .np-again { width: 3.5rem; height: 3.5rem; padding: 0; justify-content: center; border-radius: 50%; }
.nlp-player.np-compact .np-again span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Cargando: anillo discreto */
.nlp-player .np-spin {
  position: absolute; left: 50%; top: 50%;
  width: 3rem; height: 3rem; margin: -1.5rem 0 0 -1.5rem;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .35);
  border-top-color: var(--np-lima);
  opacity: 0; visibility: hidden; pointer-events: none;
}
.nlp-player[data-loading="true"] .np-spin { opacity: 1; visibility: visible; }
.nlp-player.np-compact .np-spin { width: 2.25rem; height: 2.25rem; margin: -1.125rem 0 0 -1.125rem; }

/* Error: cubre el cuadro con un panel sólido (no hay imagen que proteger) */
.nlp-player .np-error {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .85rem;
  padding: 1.25rem; text-align: center;
  background: var(--np-bar);
}
.nlp-player .np-error p { max-width: 24ch; font-size: 1.0625rem; line-height: 1.4; font-weight: 500; color: #fff; }
.nlp-player .np-error .np-warn { width: 2rem; height: 2rem; color: var(--np-lima); }
.nlp-player .np-retry {
  height: 3rem; min-width: 3rem; padding: 0 1.5rem;
  border-radius: var(--r-pill, 999px); font-weight: 700; font-size: 1rem;
}
.nlp-player.np-compact .np-error p { font-size: .9375rem; }

/* ---------- Franja de controles (debajo del cuadro) ---------- */
.nlp-player .np-bar {
  display: grid;
  align-items: center;
  column-gap: .25rem;
  padding: .25rem .5rem .5rem;
  background: var(--np-bar);
}
.nlp-player .np-bar > .np-play { grid-area: play; }
.nlp-player .np-bar > .np-time { grid-area: time; }
.nlp-player .np-bar > .np-track { grid-area: track; }
.nlp-player .np-bar > .np-mute { grid-area: mute; }
.nlp-player .np-bar > .np-fs { grid-area: fs; }
/* En estrecho: barra arriba; abajo reproducir, tiempo, silencio y pantalla completa */
.nlp-player .np-bar { grid-template-columns: auto 1fr auto auto; grid-template-areas: "track track track track" "play time mute fs"; }

@container (min-width: 520px) {
  .nlp-player .np-bar {
    grid-template-columns: auto auto 1fr auto auto;
    grid-template-areas: "play time track mute fs";
    column-gap: .5rem;
    padding: .375rem .75rem;
  }
}

.nlp-player .np-btn {
  appearance: none; border: 0; background: transparent; color: #fff; cursor: pointer;
  display: grid; place-items: center;
  width: 2.75rem; height: 2.75rem;      /* 44 px de área táctil */
  border-radius: 50%;
  padding: 0;
}
.nlp-player .np-btn:hover { background: rgba(255, 255, 255, .14); }
.nlp-player .np-play { background: var(--np-lima); color: var(--np-ink); }
.nlp-player .np-play:hover { background: var(--np-lima-soft); }
.nlp-player .np-btn .np-i { width: 1.5rem; height: 1.5rem; }
.nlp-player .np-play .np-i { width: 1.35rem; height: 1.35rem; stroke: currentColor; stroke-width: 6; stroke-linejoin: round; }

/* Íconos propios (trazo) y del sprite (relleno) */
.nlp-player .np-i { flex: none; fill: currentColor; }
.nlp-player .np-i.np-s { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.nlp-player .np-time {
  padding: 0 .5rem;
  font-size: .875rem; font-weight: 600; line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: #fff;
}
.nlp-player .np-sep, .nlp-player .np-dur { color: rgba(255, 255, 255, .72); }

/* Barra de progreso: 44 px de zona de toque, riel de 6 px */
.nlp-player .np-track {
  position: relative; display: block; height: 2.75rem; margin: 0 .75rem;
  cursor: pointer; touch-action: pan-y; user-select: none; -webkit-user-select: none;
  border-radius: 8px;
}
.nlp-player .np-rail {
  position: absolute; left: 0; right: 0; top: 50%; height: 6px; margin-top: -3px;
  border-radius: 999px; background: rgba(255, 255, 255, .22); overflow: hidden;
}
.nlp-player .np-buf, .nlp-player .np-fill {
  position: absolute; inset: 0; border-radius: 999px; transform-origin: left center; transform: scaleX(0);
}
.nlp-player .np-buf { background: rgba(255, 255, 255, .42); }
.nlp-player .np-fill { background: var(--np-lima); }
.nlp-player .np-knob {
  position: absolute; top: 50%; left: 0; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border-radius: 50%; background: var(--np-lima); box-shadow: 0 0 0 3px var(--np-bar);
  pointer-events: none;
}
.nlp-player .np-track:hover .np-knob,
.nlp-player .np-track.is-drag .np-knob { transform: scale(1.3); }
.nlp-player .np-track.is-drag .np-rail { height: 8px; margin-top: -4px; }

/* Compacto: play, barra, tiempo y pantalla completa en una sola fila */
.nlp-player.np-compact .np-bar {
  grid-template-columns: auto 1fr auto auto;
  grid-template-areas: "play track time fs";
  column-gap: .25rem;
  padding: .25rem .5rem;
}
.nlp-player.np-compact .np-track { margin: 0 .5rem; }
.nlp-player.np-compact .np-sep, .nlp-player.np-compact .np-dur { display: none; }
.nlp-player.np-compact .np-time { padding: 0 .25rem; min-width: 2.4rem; text-align: right; }
.nlp-player.np-compact .np-mute { display: none; }
.nlp-player.np-compact .np-play { width: 2.75rem; height: 2.75rem; }
/* Reproductor compacto angosto (menos de 16 rem, p. ej. el testimonio en 320 o 360 px): la barra de progreso toma una fila entera
   y el tiempo baja junto a los botones; en una sola fila el seek quedaba de 38 px (R-RSP-005). */
@container (max-width: 16rem) {
  .nlp-player.np-compact .np-bar { grid-template-columns: auto 1fr auto; grid-template-areas: "track track track" "play time fs"; }
  .nlp-player.np-compact .np-track { margin: 0 .5rem; }
  .nlp-player.np-compact .np-time { text-align: left; padding: 0 .5rem; }
}

/* Foco visible: anillo del sistema, lima sobre verde */
.nlp-player .np-btn:focus-visible,
.nlp-player .np-again:focus-visible,
.nlp-player .np-retry:focus-visible,
.nlp-player .np-track:focus-visible {
  outline: 3px solid var(--np-lima); outline-offset: 2px;
}
.nlp-player .np-play:focus-visible { outline-offset: 3px; }
/* Sobre el cuadro (imagen de fondo desconocida): doble anillo, legible en cualquier fondo */
.nlp-player .np-big:focus-visible,
.nlp-player .np-again:focus-visible,
.nlp-player .np-retry:focus-visible {
  outline: 3px solid #fff; outline-offset: 3px;
  box-shadow: 0 0 0 3px var(--np-bar);
}
.nlp-player .np-big:focus-visible { box-shadow: 0 0 0 3px var(--np-bar), 0 0 0 6px rgba(207, 230, 84, .28); }

/* Controles ocultos tras 2,5 s sin interacción (solo mientras suena).
   La franja conserva su sitio; queda un hilo de progreso. */
.nlp-player[data-ui="hide"][data-state="playing"] .np-btn,
.nlp-player[data-ui="hide"][data-state="playing"] .np-time { opacity: 0; pointer-events: none; }
.nlp-player[data-ui="hide"][data-state="playing"] .np-track { pointer-events: none; }
.nlp-player[data-ui="hide"][data-state="playing"] .np-knob { opacity: 0; }
.nlp-player[data-ui="hide"][data-state="playing"] .np-rail { height: 3px; margin-top: -1.5px; }

/* Texto solo para lectores de pantalla */
.nlp-player .np-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Pantalla completa ---------- */
.nlp-player.is-fs {
  display: flex; flex-direction: column;
  width: 100vw; height: 100vh; height: 100dvh;
  border-radius: 0; background: #000;
}
.nlp-player.is-fs .np-stage { flex: 1 1 auto; min-height: 0; aspect-ratio: auto; }
.nlp-player.is-fs .np-video { object-fit: contain; }
.nlp-player.is-fs .np-bar {
  background: var(--np-bar);
  padding-bottom: max(.5rem, env(safe-area-inset-bottom));
  padding-left: max(.75rem, env(safe-area-inset-left));
  padding-right: max(.75rem, env(safe-area-inset-right));
}

/* ---------- Movimiento: solo con preferencia normal ---------- */
@media (prefers-reduced-motion: no-preference) {
  .nlp-player .np-big,
  .nlp-player .np-again,
  .nlp-player .np-retry { transition: transform .45s var(--ease, cubic-bezier(.22, .61, .36, 1)), background-color .2s, opacity .2s, visibility .2s; }
  .nlp-player .np-big:hover { transform: translateY(-2px); }
  .nlp-player .np-again { transition: background-color .2s; }
  .nlp-player .np-btn { transition: background-color .2s, opacity .25s; }
  .nlp-player .np-time { transition: opacity .25s; }
  .nlp-player .np-rail { transition: height .15s, margin .15s; }
  .nlp-player .np-knob { transition: transform .15s, opacity .25s; }
  .nlp-player .np-spin { animation: np-giro .8s linear infinite; }
}
@keyframes np-giro { to { transform: rotate(360deg); } }

/* Sin movimiento: anillo quieto, sin transiciones decorativas */
@media (prefers-reduced-motion: reduce) {
  .nlp-player *, .nlp-player *::before, .nlp-player *::after { transition: none !important; animation: none !important; }
}

/* Celular horizontal: el cuadro cabe en la pantalla (el video queda centrado, con franjas a los lados) */
@media (max-height: 520px) and (orientation: landscape) {
  .nlp-player:not(.is-fs) .np-stage { max-height: calc(100vh - 8.5rem); max-height: calc(100svh - 8.5rem); min-height: 12rem; }
}

/* Alto contraste del sistema */
@media (forced-colors: active) {
  .nlp-player .np-big, .nlp-player .np-again, .nlp-player .np-retry, .nlp-player .np-play { border: 2px solid ButtonText; }
  .nlp-player .np-fill, .nlp-player .np-knob { background: Highlight; }
}
