:root {
  --bg-dark: #060606;
  --gold-accent: #d8c39e;
  --glass-bg: rgba(14, 14, 14, 0.72);
  --glass-border: rgba(255, 255, 255, 0.18);
  --text-light: #f4f1ea;
}

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

html,
body {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-light);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: #000;
}

/* =========================================================
   VÍDEOS BASE 4:3 CENTRADOS A PANTALLA COMPLETA (100dvh)
   ========================================================= */
.stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  z-index: 1;
  background: #000;
}

.stage-video {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100dvh;
  object-fit: cover;
  object-position: center center;
  /* Ligera adaptación de encuadre centrado en móvil y escritorio */
  transform: translate(-50%, -50%) scaleX(0.96);
  transition: opacity 0.25s ease;
}

@media (min-width: 768px) {
  .stage-video {
    transform: translate(-50%, -50%) scaleX(1.04);
  }
}

.is-hidden {
  display: none !important;
}

/* =========================================================
   CAPA DE ESCENA INTERACTIVA
   ========================================================= */
.scene-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.scene-overlay {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
}

.scene-overlay.is-active {
  display: flex;
  pointer-events: auto;
}

/* Botones gráficos exportados de Affinity + respaldo limpio mientras subes PNGs */
.graphic-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.16s ease, filter 0.16s ease;
}

.graphic-btn:active {
  transform: scale(0.95);
}

.graphic-btn img {
  display: block;
  max-width: 100%;
  height: auto;
  pointer-events: none;
}

.fallback-btn {
  display: none;
  padding: 12px 24px;
  border-radius: 999px;
  background: rgba(15, 14, 12, 0.85);
  border: 1px solid var(--gold-accent);
  color: var(--text-light);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
}

.fallback-sign {
  display: none;
  padding: 7px 14px;
  border-radius: 6px;
  background: linear-gradient(180deg, #d7ccb8 0%, #b5a78e 100%);
  border: 1px solid #5d5343;
  color: #1c1915;
  font-size: 0.78rem;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.55);
}

/* Pantalla Inicio */
#ui-inicio {
  align-items: center;
  justify-content: center;
}

.btn-center {
  width: min(46vw, 200px);
}

/* Escena 1: Abrir puerta */
#ui-puerta {
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 16dvh;
}

.btn-door {
  width: min(54vw, 230px);
}

/* Escena 2: 4 botones cardinales tras caída */
.hub-grid {
  position: relative;
  width: 100%;
  height: 100dvh;
}

.hub-top {
  position: absolute;
  top: 12dvh;
  left: 50%;
  transform: translateX(-50%);
  width: min(44vw, 190px);
}

.hub-bottom {
  position: absolute;
  bottom: 11dvh;
  left: 50%;
  transform: translateX(-50%);
  width: min(44vw, 190px);
}

.hub-left {
  position: absolute;
  top: 50%;
  left: 5vw;
  transform: translateY(-50%);
  width: min(38vw, 175px);
}

.hub-right {
  position: absolute;
  top: 50%;
  right: 5vw;
  transform: translateY(-50%);
  width: min(38vw, 175px);
}

/* =========================================================
   ESCENA DEL CUADRO ILUMINADO (SOLO ENFOQUE EN PROYECTO)
   ========================================================= */
.gallery-scene {
  align-items: center;
  justify-content: center;
  padding: 96px 14px 82px;
}

/* Viñeteado circular que mantiene la interfaz externa fuera de la escena */
.spotlight-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(255, 244, 222, 0.04) 0%,
    rgba(0, 0, 0, 0.25) 42%,
    rgba(0, 0, 0, 0.88) 72%,
    rgba(0, 0, 0, 0.98) 100%
  );
}

.gallery-illuminated-group {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 560px;
}

.gallery-signs-top {
  width: 100%;
  max-width: 440px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sign-btn {
  max-width: 145px;
}

/* Marco del cuadro: protagonista visual */
.painting-frame {
  position: relative;
  background: #0d0c0a;
  border: 6px solid #2b2318;
  border-radius: 4px;
  box-shadow:
    0 0 0 2px #6b583c,
    0 18px 40px rgba(0, 0, 0, 0.85),
    inset 0 0 18px rgba(0, 0, 0, 0.75);
  overflow: hidden;
  transition: width 0.25s ease, height 0.25s ease;
}

/* Variante Horizontal 16:9 */
.painting-frame.is-horizontal {
  width: min(88vw, 520px);
  aspect-ratio: 16 / 9;
}

/* Variante Vertical 9:16 (prioriza altura cómoda en móvil sin invadir UI) */
.painting-frame.is-vertical {
  height: min(46dvh, 410px);
  aspect-ratio: 9 / 16;
}

.project-reel {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.canvas-texture {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.45);
}

.gallery-signs-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.title-plaque {
  padding: 5px 14px;
  border-radius: 4px;
  background: rgba(24, 21, 17, 0.88);
  border: 1px solid rgba(216, 195, 158, 0.45);
  color: #f2e8d5;
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-align: center;
}

/* =========================================================
   SECCIONES PDF (INGENIERÍA Y CONTACT & ME)
   ========================================================= */
.pdf-section-view {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 84px 12px 24px;
  background: rgba(8, 8, 8, 0.94);
}

.pdf-container {
  width: 100%;
  max-width: 760px;
  flex: 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  background: #141414;
}

.pdf-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.contact-pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--gold-accent);
  color: var(--text-light);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
}

/* =========================================================
   UI EXTERNA (BOTONES MACRO + RAYITAS IG + COMENTARIOS)
   ========================================================= */
.external-top-ui {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  padding: max(10px, env(safe-area-inset-top)) 10px 8px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0) 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.macro-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}

.macro-btn {
  flex: 1;
  padding: 6px 4px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(18, 18, 18, 0.78);
  color: rgba(255, 255, 255, 0.78);
  font-size: clamp(0.64rem, 2.5vw, 0.8rem);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.2s ease;
}

.macro-btn.is-active {
  border-color: var(--gold-accent);
  color: #fff;
  background: rgba(216, 195, 158, 0.18);
  font-weight: 600;
}

.story-bars {
  display: flex;
  gap: 6px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  height: 3px;
}

.story-bar-segment {
  flex: 1;
  height: 3px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.24);
  transition: background-color 0.25s ease;
}

.story-bar-segment.is-active {
  background: #ffffff;
}

/* Barra inferior de comentarios estilo Instagram */
.external-bottom-ui {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  padding: 10px 14px max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.94) 0%, rgba(0, 0, 0, 0) 100%);
}

.comment-form {
  max-width: 540px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(15, 15, 15, 0.75);
  backdrop-filter: blur(8px);
}

.comment-form input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 0.9rem;
}

.comment-form input::placeholder {
  color: rgba(255, 255, 255, 0.55);
}

.send-comment-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

/* Aviso sutil tipo respuesta de historia de Instagram */
.ig-toast {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  z-index: 50;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(28, 28, 30, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f5f5f7;
  font-size: 0.82rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.ig-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =========================================================
   OPCIÓN A: VISTA DEDICADA "SABER MÁS" (PDF + YOUTUBE)
   ========================================================= */
.detail-view {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #0a0a0a;
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--glass-border);
  background: #111;
}

.detail-back-btn {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--gold-accent);
  background: transparent;
  color: var(--text-light);
  font-size: 0.85rem;
  cursor: pointer;
}

.detail-title {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--gold-accent);
}

.detail-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

.youtube-wrapper {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}

.youtube-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.detail-pdf-wrapper {
  width: 100%;
  min-height: 68dvh;
  flex: 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
}

.detail-pdf-wrapper iframe {
  width: 100%;
  height: 100%;
  min-height: 68dvh;
  border: none;
}
/* =========================================================
   CONTROLES SUTILES ARRIBA A LA DERECHA (AUDIO + OMITIR ESCENAS)
   ========================================================= */
.global-utility-controls {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: 12px;
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Si la cabecera macro está visible, bajamos un poco para no pisarla */
.app-shell.has-macro-header .global-utility-controls {
  top: calc(max(10px, env(safe-area-inset-top)) + 44px);
}

.utility-btn {
  background: rgba(14, 14, 14, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(6px);
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(244, 241, 234, 0.85);
  transition: opacity 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
}

.utility-btn:active {
  transform: scale(0.95);
}

.utility-btn img {
  display: block;
  height: 18px;
  width: auto;
  pointer-events: none;
}

.utility-icon-btn {
  padding: 6px;
}

.utility-fallback {
  display: none;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1;
}

.utility-btn.is-skip-active {
  border-color: var(--gold-accent);
  color: var(--gold-accent);
}
