/* Mando del Museo Virtual URJC.
   Portado del controller antiguo (nowArLab/urjc_controller): mismos colores,
   misma estructura, tipografia Inter. Vanilla, sin framework. */

@font-face {
  font-family: "Inter";
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/Inter-Regular.ttf") format("truetype");
}
@font-face {
  font-family: "Inter";
  font-weight: 600 700;
  font-display: swap;
  src: url("/fonts/Inter-Bold.ttf") format("truetype");
}

:root {
  --rojo: #ed1b2f;
  --rojo-oscuro: #c40024;
  --tinta: #1a1a1a;
  --gris: #666;
  --borde: #e0e0e0;
  --cab-alto: 136px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overscroll-behavior: none;
  font-family: "Inter", system-ui, sans-serif;
  color: var(--tinta);
  background: #0e0e0e;
  user-select: none;
}
body { height: 100dvh; overflow: hidden; position: relative; }

[hidden] { display: none !important; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ═══════════ Escena 3D ═══════════ */

#escena {
  position: fixed;
  inset: 0;
  touch-action: none;
  background: radial-gradient(ellipse at 50% 42%, #2a2a2a 0%, #0e0e0e 72%);
}
#escena canvas { display: block; }

#cargando {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: .8rem;
  pointer-events: none;
  z-index: 5;
}
.ruleta {
  width: 2.6rem; height: 2.6rem;
  border: 3px solid rgba(255,255,255,.15);
  border-top-color: var(--rojo);
  border-radius: 50%;
  animation: girar .9s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }
#progreso { color: #888; font-size: .85rem; font-variant-numeric: tabular-nums; }

/* ═══════════ Cabecera ═══════════ */

#cabecera {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: rgba(232, 232, 232, .92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.cab-arriba {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(.5rem + env(safe-area-inset-top)) 14px .5rem;
}
.cab-logo { height: 34px; width: auto; }

.cab-acciones { display: flex; gap: 10px; }
.cab-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--rojo);
  display: grid;
  place-items: center;
  transition: transform .12s, background .12s;
}
.cab-btn:active { transform: scale(.92); background: var(--rojo-oscuro); }
.cab-btn svg { width: 26px; height: 26px; }

.subcab {
  height: 46px;
  background: var(--rojo);
  color: #fff;
}
.subcab-cerrada, .subcab-abierta {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 0 16px;
  gap: 10px;
  color: #fff;
  font-size: 17px;
  font-weight: 500;
}
.subcab-abierta { justify-content: space-between; }
.menu-atras { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 17px; font-weight: 500; }
.menu-cerrar { color: #fff; font-size: 20px; padding: 4px 8px; }
.ico-burger, .ico-atras { width: 24px; height: 24px; display: inline-block; }
.ico-burger svg, .ico-atras svg { width: 24px; height: 24px; }

/* ═══════════ Menú de filtros ═══════════ */

#menu {
  position: fixed;
  top: var(--cab-alto);
  left: 0; right: 0;
  bottom: 0;
  z-index: 19;
  background: #fff;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--borde);
  font-size: 16px;
}
.menu-item:active { background: #f5f5f5; }
.menu-item .flecha { margin-left: auto; color: #bbb; font-size: 18px; }
.menu-item.obra { padding: 12px 20px; }
.menu-thumb {
  width: 46px; height: 46px;
  border-radius: 8px;
  background: #ececec;
  display: grid;
  place-items: center;
  color: #999;
  font-weight: 700;
  flex: none;
  overflow: hidden;
}
.menu-item .sub { color: var(--gris); font-size: 13px; margin-top: 2px; }
.menu-item .col { display: flex; flex-direction: column; min-width: 0; }
.menu-item .col > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-vacio { padding: 32px; text-align: center; color: var(--gris); }
.menu-cargando { display: grid; place-items: center; padding: 60px 0; }

/* ═══════════ Controles de la obra ═══════════ */

#controles-obra {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

/* HUD inferior: columna centrada pegada abajo, como el .ui-overlay del original. */
.hud {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 580px;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }

/* Barra de modo detalle: ancho completo, rojo, siempre visible. */
.btn-detalle {
  width: 100%;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--rojo);
  color: #fff;
  border-radius: 12px;
  font: 500 17px "Inter", sans-serif;
  transition: transform .12s, background .12s;
}
.btn-detalle:active { transform: scale(.98); background: var(--rojo-oscuro); }
.btn-detalle-ico { width: 20px; height: 20px; display: inline-block; }
.btn-detalle-ico svg { width: 20px; height: 20px; display: block; }
body.detalle .btn-detalle { background: #2b2b2b; }
body.detalle .btn-detalle:active { background: #3a3a3a; }

/* Ficha translúcida (título/autor), como .artwork-info del original. */
.ficha-obra {
  width: 100%;
  padding: 10px 12px;
  background: rgba(255, 255, 255, .55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 8px;
  transition: opacity .25s, transform .25s;
}
#obra-titulo { font: 700 21px "Inter", sans-serif; margin: 0; color: #222; line-height: 1.2; }
#obra-autoria { font: 400 16px "Inter", sans-serif; margin: 3px 0 0; color: #555; }

/* Anterior / info / siguiente. */
.nav-obra {
  display: flex;
  justify-content: space-around;
  align-items: center;
  transition: opacity .25s, transform .25s;
}
.nav-btn {
  width: 62px; height: 62px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  transition: transform .12s;
}
.nav-btn:active { transform: scale(.9); }
.nav-btn svg { width: 48px; height: 48px; }
/* El botón de info resalta cuando la ficha está mostrándose en la pantalla. */
#nav-info.activo { background: var(--rojo); }
#nav-info.activo svg path { fill: #fff; }

/* En modo detalle se apartan la ficha y la navegación (para no tapar la obra);
   la barra de detalle sigue visible para poder salir. Se desvanece cada uno por
   separado: la opacidad del contenedor se compondría con la del hijo. */
body.detalle .ficha-obra,
body.detalle .nav-obra {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.pista-detalle {
  position: absolute;
  left: 20px; right: 20px;
  top: calc(var(--cab-alto) + 64px);
  text-align: center;
  color: rgba(255,255,255,.55);
  font-size: .82rem;
  pointer-events: none;
}

/* ═══════════ Estado de conexión ═══════════ */

/* Aviso de conexión: bajo la cabecera, sólo cuando hay problema (no se muestra
   un "Conectado" permanente que sería ruido). */
.estado-conexion {
  position: fixed;
  z-index: 15;
  left: 50%;
  transform: translateX(-50%);
  top: calc(var(--cab-alto) + 12px);
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .9rem;
  background: rgba(20,20,20,.8);
  color: #eee;
  border-radius: 2rem;
  font-size: .82rem;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.punto { width: .5rem; height: .5rem; border-radius: 50%; background: #888; }
.punto.viva { background: #37d67a; }
.punto.rota { background: var(--rojo); }

/* ═══════════ Splash ═══════════ */

.splash {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #fff;
  display: grid;
  place-items: center;
  padding: 2rem;
  transition: opacity .5s;
}
.splash.saliendo { opacity: 0; }
.splash-contenido {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.5rem;
  max-width: 22rem;
}
.splash-logo { width: 220px; max-width: 70vw; height: auto; }
.splash-titulo { font-size: 1.5rem; font-weight: 700; }
.splash-sub { color: var(--gris); line-height: 1.5; }

.btn-primario {
  padding: .8rem 1.8rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--rojo);
  border-radius: 9999px;
  transition: transform .12s, opacity .12s;
}
.btn-primario:active { transform: scale(.96); opacity: .9; }

.btn-secundario {
  padding: .8rem 1.6rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--tinta);
  background: #ececec;
  border-radius: 9999px;
}

/* ═══════════ Tutorial ═══════════ */

.tutorial {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(12,12,12,.96);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem 1.5rem calc(2rem + env(safe-area-inset-bottom));
}
.tut-progreso {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: rgba(255,255,255,.1);
}
.tut-barra { height: 100%; width: 0; background: var(--rojo); transition: width .3s ease; }

.tut-lottie {
  width: min(80vw, 420px);
  height: min(80vw, 420px);
  max-height: 46vh;
  border-radius: 24px;
  overflow: hidden;
  background: rgba(255,255,255,.02);
  transition: opacity .4s;
}
.tut-lottie svg { border-radius: 24px; }

.tut-pie {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}
.tut-instruccion {
  color: #fff;
  font-size: 1.05rem;
  text-align: center;
  white-space: pre-line;
  min-height: 3em;
  max-width: 20rem;
}
.tut-botones { display: flex; gap: .8rem; }
.tut-saltar { color: #777; font-size: .85rem; text-decoration: underline; }

/* ═══════════ Sesión cerrada ═══════════ */

.cerrada {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #f4f4f4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  padding: 2rem;
  text-align: center;
}
.cerrada-logo { width: 200px; max-width: 65vw; height: auto; }
.cerrada-texto { font-size: 1.4rem; font-weight: 700; color: #333; }
.cerrada-sub { color: var(--gris); max-width: 20rem; }
