/* Scroll-driven WebGL presentation */

html,
body {
  margin: 0;
}

/* Lenis smooth scroll (estilos recomendados) */
html.lenis,
html.lenis body {
  height: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}

.lenis.lenis-stopped {
  overflow: hidden;
}

body[data-mode='portfolio'] {
  overflow-x: hidden;
  background: var(--bg);
  min-height: 100vh;
}

.presentation-root {
  position: fixed;
  inset: 0;
  z-index: 10;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  opacity: 1;
  transition: opacity 500ms ease;
}

/* Una vez recorrido el timeline 3D completo, se desvanece y deja ver el
   resto del portafolio (CV) que sigue debajo en el flujo normal. */
.presentation-root.is-past {
  opacity: 0;
  pointer-events: none;
}

/* prefers-reduced-motion: hero estatico de 100vh, sin pin ni scroll-jacking. */
.presentation-root.presentation-root--static {
  position: relative;
  height: 100vh;
}

.presentation-root.presentation-root--static .presentation-hud {
  display: none;
}

.presentation-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.presentation-loading {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity 400ms ease, visibility 400ms ease;
}

.presentation-loading--done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.presentation-loading__grid {
  width: min(70vw, 420px);
  height: min(40vh, 240px);
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  background:
    linear-gradient(transparent 95%, var(--primary-dim) 95%),
    linear-gradient(90deg, transparent 95%, var(--primary-dim) 95%);
  background-size: 24px 24px;
  animation: presentation-grid-pulse 1.4s ease-in-out infinite;
}

.presentation-loading__copy {
  font-family: var(--font-label);
  color: var(--secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.82rem;
}

@keyframes presentation-grid-pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

.presentation-hud {
  position: fixed;
  top: 4.75rem;
  right: 1rem;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.presentation-hud__cluster {
  display: flex;
  gap: 0.45rem;
}

.presentation-hud__progress {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 0.3rem 0.55rem;
  background: rgba(10, 10, 10, 0.82);
  border: 1px solid var(--border);
  font-family: var(--font-label);
  font-size: 0.68rem;
}

.presentation-hud__progress-value {
  color: var(--primary);
  font-family: var(--font-headline);
  font-weight: 700;
}

.presentation-hud__btn {
  padding: 0.35rem 0.55rem;
  background: rgba(10, 10, 10, 0.82);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-family: var(--font-label);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.presentation-hud__btn:hover,
.presentation-hud__btn[aria-pressed='true'] {
  border-color: var(--primary);
  color: var(--primary);
}

.presentation-hud__help {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  width: min(90vw, 280px);
  padding: 0.75rem;
  background: var(--surface-container-high);
  border: 1px solid var(--border-strong);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-soft);
}

.typography-stage {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem 1.25rem;
  pointer-events: none;
}

/* Coreografia: el texto se mueve a la zona libre mientras el objeto 3D ocupa
   la opuesta (ver SCENE_OBJECT_OFFSET en three-scene.ts). Beat "center" no
   necesita regla propia (es el default de arriba). */
.typography-stage[data-layout='left'] {
  align-items: flex-start;
  text-align: left;
  padding-left: clamp(1.25rem, 8vw, 6rem);
}

.typography-stage[data-layout='right'] {
  align-items: flex-end;
  text-align: right;
  padding-right: clamp(1.25rem, 8vw, 6rem);
}

.typography-stage[data-layout='top'] {
  justify-content: flex-start;
  padding-top: clamp(4rem, 14vh, 8rem);
}

.typography-stage[data-layout='bottom-left'] {
  justify-content: flex-end;
  align-items: flex-start;
  text-align: left;
  padding-left: clamp(1.25rem, 8vw, 6rem);
  padding-bottom: clamp(3rem, 12vh, 7rem);
}

.typography-stage[data-layout='left'] .typography-stage__actions,
.typography-stage[data-layout='bottom-left'] .typography-stage__actions {
  justify-content: flex-start;
}

.typography-stage[data-layout='right'] .typography-stage__actions {
  justify-content: flex-end;
}

.typography-stage[data-layout='left'] .typography-stage__secondary,
.typography-stage[data-layout='bottom-left'] .typography-stage__secondary {
  max-width: 26ch;
}

.typography-stage[data-layout='right'] .typography-stage__secondary {
  max-width: 26ch;
  margin-left: auto;
}

.typography-stage__label {
  font-family: var(--font-label);
  color: var(--secondary);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.typography-stage__primary {
  font-family: var(--font-headline);
  font-size: clamp(3rem, 14vw, 8rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: var(--on-surface);
  margin-bottom: 0.35rem;
}

.typography-stage__secondary {
  font-family: var(--font-body);
  font-size: clamp(1rem, 3vw, 1.5rem);
  color: var(--text-soft);
  font-weight: 500;
  max-width: 22ch;
}

.typography-stage__actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 1.25rem;
}

.typography-stage__cta {
  pointer-events: auto;
}

/* ── Burbujas de logros (overlay flotante por beat) ── */
.achievement-bubbles {
  position: absolute;
  inset: 0;
  z-index: 22;
  pointer-events: none;
}

.achievement-bubble {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 240px;
  padding: 0.5rem 0.8rem;
  background: rgba(22, 23, 27, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-family: var(--font-label);
  will-change: transform, opacity;
}

.achievement-bubble__tag {
  flex-shrink: 0;
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  padding: 0.12rem 0.4rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
}

.achievement-bubble__text {
  font-size: 0.78rem;
  line-height: 1.25;
  color: var(--text-soft);
  text-align: left;
}

.presentation-zones {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
}

.presentation-zone {
  flex: 1;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: ns-resize;
}

.presentation-zone--prev {
  cursor: n-resize;
}

.presentation-zone--next {
  cursor: s-resize;
}

.presentation-fallback {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: grid;
  place-content: center;
  gap: 1rem;
  text-align: center;
  background: rgba(11, 11, 12, 0.92);
}

.presentation-fallback[hidden] {
  display: none !important;
}

.scroll-driver {
  position: relative;
  z-index: 1;
  width: 100%;
}

@media (max-width: 720px) {
  /* La coreografia de layout (texto a la izq/der/arriba segun el beat) asume
     pantallas anchas; en movil no hay espacio de sobra, asi que el texto se
     queda centrado siempre y solo el objeto 3D de fondo se sigue moviendo. */
  .typography-stage[data-layout] {
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 2rem 1.25rem;
  }

  .typography-stage[data-layout] .typography-stage__actions {
    justify-content: center;
  }

  .presentation-hud {
    top: 0.65rem;
    right: 0.65rem;
    left: 0.65rem;
  }

  .presentation-hud__progress {
    display: none;
  }

  .typography-stage__primary {
    font-size: clamp(2.4rem, 18vw, 4rem);
  }

  /* En movil las burbujas tapan el titulo: mostramos solo 2, abajo */
  .achievement-bubble:nth-child(n + 3) {
    display: none;
  }

  .achievement-bubble__text {
    font-size: 0.7rem;
  }
}
