/* MP360 · Ayres de Cardales — video programado
 *
 * Diálogo modal. Tarea principal: ver el video (o cerrarlo) sin perder el
 * recorrido. El reproductor es el embebido oficial de YouTube (16:9).
 *
 * Contrato responsive
 *   Imprescindible: reproductor 16:9 completo · cerrar visible desde el inicio.
 *   Progresivo:     error/lento → "Ver en YouTube".
 *   Encaje:         el reproductor toma el mayor 16:9 que entra en el área útil
 *                   (--mp360-vv-h, safe areas, gutter), máx. 1280 px de ancho.
 *   Vertical, tablet y desktop: franja propia arriba del reproductor, con el
 *                   cierre compartido a la derecha (sin título visible: tanda 5).
 *   Altura reducida (≤ 520 px, horizontal): cerrar al costado derecho del
 *                   reproductor, espacio simétrico.
 *   Nunca se superpone al reproductor: no tapa controles de YouTube.
 *   Estados: cerrado · abierto · cerrando; carga: vacio · cargando · listo · lento · error.
 *   Motion: MP360Motion (velo + marco); acá no hay transiciones de opacidad.
 *   Compatibilidad: BLOCK. Solo se abre con el tour libre; si el usuario abre
 *   otra superficie, el video se cierra. Capa 50 en #mp360-root (fullscreen).
 */

.mp360-root .mp360-video {
  --video-gutter: clamp(12px, 3vw, 40px);
  --video-control: 44px;
  --video-gap: 12px;
  --video-alto-util: calc(var(--mp360-vv-h, 100vh) - 2 * var(--video-gutter) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));

  position: absolute;
  left: 0;
  right: 0;
  top: var(--mp360-vv-top, 0px);
  height: var(--mp360-vv-h, 100%);
  z-index: 50;
  font-family: var(--mp360-font-ui);
  color: var(--white);
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.mp360-video[hidden] { display: none !important; }
/* Durante la salida el recorrido vuelve a recibir el puntero. */
.mp360-root .mp360-video[data-estado="cerrando"],
.mp360-video[data-estado="cerrando"] .mp360-video__marco { pointer-events: none; }

.mp360-video__velo {
  position: fixed;
  inset: 0;
  background: rgba(10, 28, 33, 0.9);
  touch-action: none;
}

.mp360-video__dialogo {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding:
    calc(var(--video-gutter) + env(safe-area-inset-top, 0px))
    calc(var(--video-gutter) + env(safe-area-inset-right, 0px))
    calc(var(--video-gutter) + env(safe-area-inset-bottom, 0px))
    calc(var(--video-gutter) + env(safe-area-inset-left, 0px));
  outline: none;
  pointer-events: none;           /* el velo recibe el toque fuera del marco */
}

.mp360-video__marco {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--video-gap);
  width: min(100%, 1280px, calc((var(--video-alto-util) - var(--video-control) - var(--video-gap)) * 16 / 9));
  pointer-events: auto;
}

/* Franja del cierre: reserva su alto, sin contenido visible propio. */
.mp360-video__barra {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: var(--video-control);
}

.mp360-video__enlace:focus-visible {
  outline: 2px solid var(--secondary-400);
  outline-offset: 2px;
}
@media (hover: hover) and (pointer: fine) {
  .mp360-video__enlace:hover { background: var(--primary-50); }
}

/* ---------------- reproductor ---------------- */

.mp360-video__pantalla {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius-compact);
  background: #000;
  box-shadow: 0 24px 64px -16px rgba(0, 0, 0, 0.55);
}

.mp360-video__iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.mp360-video__iframe:focus-visible {
  outline: 2px solid var(--secondary-400);
  outline-offset: -2px;
}

.mp360-video[data-carga="error"] .mp360-video__iframe,
.mp360-video[data-carga="lento"] .mp360-video__iframe { visibility: hidden; }

.mp360-video__estado {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  box-sizing: border-box;
  text-align: center;
  pointer-events: none;
}

/* Cargando: el negro del reproductor alcanza (YouTube muestra su propia carga). */
.mp360-video[data-carga="vacio"] .mp360-video__estado,
.mp360-video[data-carga="cargando"] .mp360-video__estado,
.mp360-video[data-carga="listo"] .mp360-video__estado { display: none; }

/* Carga sin respuesta de la API: el enlace queda debajo, sin cubrir el reproductor. */
.mp360-video[data-carga="listo"][data-api="sin-respuesta"] .mp360-video__estado,
.mp360-video[data-carga="cargando"][data-api="sin-respuesta"] .mp360-video__estado {
  display: flex;
  inset: auto 0 0 auto;
  padding: 8px;
}
.mp360-video[data-api="sin-respuesta"] .mp360-video__mensaje { display: none; }

.mp360-video__mensaje {
  margin: 0;
  max-width: 22rem;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: var(--mp360-ui-tracking);
  color: var(--neutral-50);
  text-wrap: balance;
}
.mp360-video__mensaje:empty { display: none; }

.mp360-video__enlace {
  display: inline-flex;
  align-items: center;
  min-height: var(--video-control);
  padding: 0 16px;
  box-sizing: border-box;
  border-radius: var(--radius-button);
  background: var(--white);
  color: var(--primary-700);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: var(--mp360-ui-tracking);
  text-decoration: none;
  white-space: nowrap;
  pointer-events: auto;
  transition: background-color 0.15s linear;
}
.mp360-video__enlace[hidden] { display: none; }

/* ---------------- altura reducida: cerrar al costado ---------------- */

@media (max-height: 520px) and (orientation: landscape) {
  .mp360-root .mp360-video { --video-gutter: 8px; }
  .mp360-video__marco {
    width: min(
      calc(100% - 2 * (var(--video-control) + var(--video-gap))),
      1280px,
      calc(var(--video-alto-util) * 16 / 9)
    );
  }
  .mp360-video__barra {
    position: absolute;
    top: 0;
    left: 100%;
    margin-left: var(--video-gap);
    min-height: 0;
  }
}
