/* =============================================================================
   GALERÍA 3D (gallery.sweetspot.art y /galeria)
   -----------------------------------------------------------------------------
   Pantalla completa como un videojuego: el lienzo 3D detrás y encima, barra
   de arriba, plano chico, ficha de la obra, palanca del celular y portada de
   carga. Blanco, negro y azul #0f4fb3, Poppins. Nada se mueve de lado.
   ============================================================================= */

:root {
  --azul: #0f4fb3;
  --azul-claro: #3d7be0;
  --tinta: #f2f2f2;
  --tinta-suave: #a6a6ab;
  --vidrio: rgba(10, 10, 12, 0.72);
  --linea: rgba(255, 255, 255, 0.14);
  --seguro-arriba: env(safe-area-inset-top, 0px);
  --seguro-abajo: env(safe-area-inset-bottom, 0px);
  --seguro-izq: env(safe-area-inset-left, 0px);
  --seguro-der: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overflow-x: clip;
  background: #050505;
  color: var(--tinta);
  font-family: 'Poppins', 'Helvetica Neue', Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

.oculto { display: none !important; }

.g-lienzo {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
  cursor: grab;
}
.g-lienzo.g-lienzo--obra { cursor: pointer; }
.g-lienzo.g-lienzo--arrastrando { cursor: grabbing; }

/* --- Barra de arriba --- */
.g-barra {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: calc(0.75rem + var(--seguro-arriba)) calc(1rem + var(--seguro-der)) 0.75rem calc(1rem + var(--seguro-izq));
  background: linear-gradient(rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
  pointer-events: none;
  z-index: 3;
}
.g-barra > * { pointer-events: auto; }
.g-marca { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--tinta); text-decoration: none; flex: none; }
.g-marca img { display: block; height: 24px; width: auto; }
.g-marca__galeria { font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--tinta-suave); }
.g-titulo {
  margin: 0;
  min-width: 0;
  flex: 1;
  font-size: 0.95rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.g-botones { display: flex; gap: 0.4rem; flex: none; }

.g-boton {
  min-height: 2.4rem;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--linea);
  border-radius: 999px;
  background: var(--vidrio);
  color: var(--tinta);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.g-boton:hover { background: rgba(30, 30, 34, 0.85); }
.g-boton[aria-pressed='true'] { border-color: var(--azul-claro); }
.g-boton:focus-visible { outline: 2px solid var(--azul-claro); outline-offset: 2px; }

.g-borrador {
  position: fixed;
  top: calc(3.6rem + var(--seguro-arriba));
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 2rem);
  margin: 0;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  background: #2a2010;
  border: 1px solid #5c4320;
  color: #f2c07a;
  font-size: 0.78rem;
  text-align: center;
  z-index: 3;
}

/* --- Plano chico --- */
.g-minimapa {
  position: fixed;
  right: calc(1rem + var(--seguro-der));
  top: calc(4.2rem + var(--seguro-arriba));
  width: 180px;
  height: 180px;
  border: 1px solid var(--linea);
  border-radius: 14px;
  background: var(--vidrio);
  z-index: 2;
  pointer-events: none;
}

/* --- Ficha de la obra --- */
.g-ficha {
  position: fixed;
  left: calc(1rem + var(--seguro-izq));
  bottom: calc(1rem + var(--seguro-abajo));
  width: min(380px, calc(100vw - 2rem));
  max-height: min(55dvh, 460px);
  overflow-y: auto;
  padding: 1.1rem 1.2rem 1rem;
  border: 1px solid var(--linea);
  border-radius: 16px;
  background: rgba(10, 10, 12, 0.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 4;
}
.g-ficha[hidden] { display: none; }
.g-ficha__cerrar {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 2.2rem;
  height: 2.2rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--tinta-suave);
  font-size: 1rem;
  cursor: pointer;
}
.g-ficha__cerrar:hover { color: var(--tinta); background: rgba(255, 255, 255, 0.08); }
.g-ficha__titulo { margin: 0 2rem 0.2rem 0; font-size: 1.15rem; line-height: 1.3; }
.g-ficha__artista { margin: 0 0 0.35rem; color: var(--tinta); font-size: 0.92rem; }
.g-ficha__datos { margin: 0 0 0.6rem; color: var(--tinta-suave); font-size: 0.82rem; }
.g-ficha__datos:empty,
.g-ficha__artista:empty,
.g-ficha__descripcion:empty { display: none; }
.g-ficha__descripcion { margin: 0 0 0.8rem; font-size: 0.88rem; line-height: 1.55; white-space: pre-line; }
.g-ficha__acciones { display: flex; justify-content: space-between; gap: 0.5rem; }

/* --- Palanca (solo táctil) --- */
.g-palanca {
  position: fixed;
  left: calc(1.5rem + var(--seguro-izq));
  bottom: calc(1.5rem + var(--seguro-abajo));
  width: 120px;
  height: 120px;
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: rgba(10, 10, 12, 0.35);
  touch-action: none;
  z-index: 3;
  display: none;
}
.tactil .g-palanca { display: block; }
.tactil.ficha-abierta .g-palanca { display: none; }
.g-palanca__bola {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.g-pista {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + var(--seguro-abajo));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 2rem);
  margin: 0;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: var(--vidrio);
  color: var(--tinta-suave);
  font-size: 0.78rem;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.6s;
  z-index: 2;
}
.g-pista:empty { opacity: 0; }

/* --- Portada --- */
.g-portada {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(1.5rem + var(--seguro-arriba)) 1.5rem calc(1.5rem + var(--seguro-abajo));
  background: radial-gradient(circle at 50% 35%, #12161f 0%, #050505 70%);
  z-index: 10;
  transition: opacity 0.5s;
  overflow-y: auto;
}
.g-portada--saliendo { opacity: 0; pointer-events: none; }
.g-portada__caja { width: min(460px, 100%); text-align: center; }
.g-portada__logo { display: block; margin: 0 auto 1.6rem; height: 34px; width: auto; }
.g-portada__titulo { margin: 0 0 0.6rem; font-size: clamp(1.5rem, 5vw, 2.2rem); line-height: 1.2; font-weight: 600; }
.g-portada__texto { margin: 0 0 1.4rem; color: var(--tinta-suave); font-size: 0.95rem; line-height: 1.6; white-space: pre-line; }
.g-carga { height: 4px; margin: 0 auto 1.4rem; width: min(260px, 80%); border-radius: 4px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.g-carga__barra { width: 0; height: 100%; background: var(--azul-claro); transition: width 0.25s; }
.g-entrar {
  min-width: 11rem;
  min-height: 3rem;
  padding: 0.7rem 2rem;
  border: 0;
  border-radius: 999px;
  background: var(--azul);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}
.g-entrar:hover:not(:disabled) { background: #0c4499; }
.g-entrar:disabled { opacity: 0.45; cursor: default; }
.g-entrar:focus-visible { outline: 2px solid var(--azul-claro); outline-offset: 3px; }
.g-controles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem 1rem;
  margin: 1.8rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--tinta-suave);
  font-size: 0.8rem;
  text-align: left;
}
.g-controles b { display: block; color: var(--tinta); font-weight: 600; }
.solo-tactil { display: none; }
.tactil .solo-tactil { display: list-item; }
.tactil .solo-compu { display: none; }

/* --- Celular --- */
@media (max-width: 700px) {
  .g-marca__galeria { display: none; }
  .g-marca img { height: 20px; }
  .g-botones .g-boton { padding: 0.35rem 0.65rem; font-size: 0.75rem; }
  #g-boton-pantalla { display: none; }
  .g-minimapa { width: 120px; height: 120px; top: calc(3.6rem + var(--seguro-arriba)); }
  .g-titulo { display: none; }
  .g-ficha {
    left: calc(0.75rem + var(--seguro-izq));
    right: calc(0.75rem + var(--seguro-der));
    bottom: calc(0.75rem + var(--seguro-abajo));
    width: auto;
  }
  .g-borrador { top: calc(3.3rem + var(--seguro-arriba)); font-size: 0.7rem; }
  /* La pista no tapa la palanca. */
  .tactil .g-pista { left: auto; right: calc(1rem + var(--seguro-der)); transform: none; max-width: calc(100vw - 170px); bottom: calc(2rem + var(--seguro-abajo)); }
}

@media (prefers-reduced-motion: reduce) {
  .g-portada, .g-pista, .g-carga__barra { transition: none; }
}
