/* =========================================================
   ANDRÉS Y EL LINCE — Estilos de la experiencia cinematográfica
   ========================================================= */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: 'Helvetica Neue', Arial, sans-serif;
}

#cine {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#reproductor {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* ---------------------------------------------------------
   Capas superpuestas (portada, decisión, fin)
   --------------------------------------------------------- */

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 5vh 5vw;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.85) 0%,
    rgba(0, 0, 0, 0.35) 35%,
    rgba(0, 0, 0, 0.0) 60%
  );
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
  z-index: 10;
}

.overlay:not(.oculto) {
  opacity: 1;
  pointer-events: auto;
}

.oculto {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ---------------------------------------------------------
   Portada
   --------------------------------------------------------- */

.titulo {
  color: #f2f2f2;
  font-size: clamp(3rem, 8vw, 6rem);
  letter-spacing: 0.14em;
  font-weight: 300;
  text-transform: uppercase;
  margin-bottom: 1.4rem;
  text-shadow: 0 2px 12px rgba(0,0,0,0.8);
}

.subtitulo {
  color: #b8b8b8;
  font-size: clamp(1.3rem, 2.8vw, 1.9rem);
  letter-spacing: 0.08em;
  margin-bottom: 1rem;
  font-style: italic;
}

.creditos {
  color: #a0a0a0;
  font-size: clamp(1rem, 1.8vw, 1.25rem);
  letter-spacing: 0.05em;
  margin-bottom: 3.5rem;
  max-width: 85%;
}

/* ---------------------------------------------------------
   Decisión narrativa
   --------------------------------------------------------- */

.pregunta-decision {
  color: #f2f2f2;
  font-size: clamp(1.6rem, 3.6vw, 2.6rem);
  letter-spacing: 0.03em;
  margin-bottom: 3rem;
  max-width: 80%;
  text-shadow: 0 2px 10px rgba(0,0,0,0.9);
}

.opciones-decision {
  display: flex;
  flex-wrap: wrap;
  gap: 1.6rem;
  justify-content: center;
}

/* ---------------------------------------------------------
   Botones
   --------------------------------------------------------- */

.boton-decision {
  background: rgba(20, 20, 20, 0.55);
  color: #f2f2f2;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 2px;
  padding: 1.3rem 3.2rem;
  font-size: clamp(1.1rem, 2.2vw, 1.4rem);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 400;
  cursor: pointer;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: background 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
}

.boton-decision:hover,
.boton-decision:focus-visible {
  background: rgba(255, 255, 255, 0.15);
  border-color: #ffffff;
  transform: translateY(-2px);
  outline: none;
}

.boton-decision:active {
  transform: translateY(0);
}

/* ---------------------------------------------------------
   Barra de control del clip actual (aparece con hover)
   --------------------------------------------------------- */

.controles {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.6rem 2.2rem 1.4rem;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.75) 0%,
    rgba(0, 0, 0, 0.0) 100%
  );
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  z-index: 5;
}

.controles.visible {
  opacity: 1;
  pointer-events: auto;
}

.btn-play-pausa {
  background: none;
  border: none;
  color: #f2f2f2;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem;
  opacity: 0.9;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
}

.btn-play-pausa:hover {
  opacity: 1;
}

.tiempo {
  color: #e0e0e0;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 2.6em;
  text-align: center;
}

.barra-progreso {
  position: relative;
  flex: 1;
  height: 18px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.progreso-fondo {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  transition: height 0.15s ease;
}

.progreso-relleno {
  position: absolute;
  left: 0;
  height: 3px;
  width: 0%;
  background: #f2f2f2;
  border-radius: 2px;
  pointer-events: none;
  transition: height 0.15s ease;
}

.progreso-manija {
  position: absolute;
  left: 0%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f2f2f2;
  transform: translateX(-50%) scale(0);
  transition: transform 0.15s ease;
  pointer-events: none;
  box-shadow: 0 0 6px rgba(0,0,0,0.6);
}

.barra-progreso:hover .progreso-fondo,
.barra-progreso:hover .progreso-relleno {
  height: 5px;
}

.barra-progreso:hover .progreso-manija {
  transform: translateX(-50%) scale(1);
}

/* --- Volumen (mismo estilo fino que la barra de progreso) --- */

.volumen {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.control-volumen {
  --nivel: 100%;
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 18px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}

.control-volumen:focus {
  outline: none;
}

.control-volumen::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    #f2f2f2 var(--nivel),
    rgba(255, 255, 255, 0.25) var(--nivel)
  );
}

.control-volumen::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: #f2f2f2;
  box-shadow: 0 0 6px rgba(0,0,0,0.6);
}

.control-volumen::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.25);
}

.control-volumen::-moz-range-progress {
  height: 3px;
  border-radius: 2px;
  background: #f2f2f2;
}

.control-volumen::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: none;
  border-radius: 50%;
  background: #f2f2f2;
  box-shadow: 0 0 6px rgba(0,0,0,0.6);
}

/* En pantallas táctiles (iPhone/Android) el volumen se maneja con
   los botones físicos del teléfono: solo se muestra el botón de silencio. */
@media (hover: none) and (pointer: coarse) {
  .control-volumen {
    display: none;
  }
}

/* ---------------------------------------------------------
   Fin de historia
   --------------------------------------------------------- */

.texto-fin {
  color: #f2f2f2;
  font-size: clamp(2.2rem, 5.5vw, 3.6rem);
  letter-spacing: 0.3em;
  font-weight: 300;
  margin-bottom: 3.5rem;
  text-transform: uppercase;
}

/* ---------------------------------------------------------
   Responsivo
   --------------------------------------------------------- */

@media (max-width: 600px) {
  .opciones-decision {
    flex-direction: column;
    width: 100%;
  }

  .boton-decision {
    width: 100%;
  }

  .controles {
    padding: 1.2rem 1.2rem 1rem;
    gap: 0.7rem;
  }

  .tiempo {
    font-size: 0.7rem;
  }
}

/* ---------------------------------------------------------
   Pantallas táctiles (iPhone / Android)
   Todo lo de abajo solo aplica cuando script.js añade la
   clase "tactil" a <html> (pantalla sin hover y puntero
   grueso). En escritorio no cambia nada.
   --------------------------------------------------------- */

/* Botones de retroceder/adelantar 5 s: ocultos en escritorio */
.btn-salto {
  display: none;
}

.tactil .btn-salto {
  display: flex;
}

/* Altura real visible en Safari de iPhone (sin quedar tapado por la barra del navegador) */
.tactil #cine {
  height: 100vh;
  height: 100dvh;
}

/* Barra de control en dos filas: progreso arriba, botones grandes abajo */
.tactil .controles {
  display: grid;
  grid-template-columns: auto auto auto 1fr auto auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 0.4rem;
  row-gap: 0.2rem;
  padding: 2.2rem 0.9rem calc(0.5rem + env(safe-area-inset-bottom));
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.85) 0%,
    rgba(0, 0, 0, 0.0) 100%
  );
}

.tactil #tiempo-actual         { grid-row: 1; grid-column: 1; }
.tactil #barra-progreso        { grid-row: 1; grid-column: 2 / 6; }
.tactil #tiempo-total          { grid-row: 1; grid-column: 6; }
.tactil #btn-retroceder        { grid-row: 2; grid-column: 1; }
.tactil #btn-play-pausa        { grid-row: 2; grid-column: 2; }
.tactil #btn-adelantar         { grid-row: 2; grid-column: 3; }
.tactil .volumen               { grid-row: 2; grid-column: 5; }
.tactil #btn-pantalla-completa { grid-row: 2; grid-column: 6; }

/* Botones grandes para dedos (mínimo 48 px) */
.tactil .btn-play-pausa {
  width: 48px;
  height: 48px;
  padding: 0;
  justify-self: center;
  -webkit-tap-highlight-color: transparent;
}

.tactil .btn-play-pausa svg {
  width: 28px;
  height: 28px;
}

.tactil #btn-play-pausa {
  width: 56px;
  height: 56px;
}

.tactil #btn-play-pausa svg {
  width: 36px;
  height: 36px;
}

.tactil .tiempo {
  font-size: 0.8rem;
}

/* Barra de progreso: zona de toque alta y manija siempre visible */
.tactil .barra-progreso {
  height: 36px;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.tactil .progreso-fondo,
.tactil .progreso-relleno {
  height: 4px;
}

.tactil .progreso-manija {
  width: 18px;
  height: 18px;
  transform: translateX(-50%) scale(1);
}

/* ---------------------------------------------------------
   Modo cine (iPhone): la película ocupa toda la pantalla
   disponible con el mismo <video> y las decisiones dentro.
   Solo se activa con la clase "modo-cine" (botón ⛶ cuando el
   navegador no permite pantalla completa de elementos).
   --------------------------------------------------------- */

html.modo-cine,
html.modo-cine body {
  background: #000;
  overscroll-behavior: none;
}

html.modo-cine #cine {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  z-index: 1000;
}

/* Sugerencia breve para girar el teléfono (nunca visible en escritorio) */
.aviso-girar {
  position: absolute;
  top: calc(1rem + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  background: rgba(20, 20, 20, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #f2f2f2;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 20;
}

.aviso-girar.visible {
  opacity: 1;
}
