:root {
  color-scheme: dark;
  background: #050505;
  --bg-primary: #050505;
  --bg-panel: rgba(8, 20, 12, 0.82);
  --text-main: #e7ffe7;
  --text-soft: rgba(211, 255, 216, 0.72);
  --line: rgba(93, 255, 139, 0.18);
  --accent: #39ff78;
  --accent-strong: #0fcf58;
  --shadow: rgba(17, 255, 106, 0.24);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at top, rgba(16, 72, 30, 0.34), transparent 42%),
    linear-gradient(180deg, #071009 0%, var(--bg-primary) 48%, #020302 100%);
  color: var(--text-main);
  font-family: "Segoe UI", sans-serif;
  overflow: hidden;
}

body.is-ready {
  overflow: auto;
}

.is-scroll-locked {
  overflow: hidden;
}

.story {
  min-height: 100vh;
}

.story__scene {
  position: relative;
  height: 360vh;
  z-index: 1;
}

.portal-transition {
  position: fixed;
  inset: 0;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
}

.portal-transition__image,
.portal-transition__wash {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.portal-transition__image {
  display: block;
  object-fit: cover;
  object-position: center;
  transform: scale(1.08);
  filter: blur(24px) brightness(0.55);
}

.portal-transition__wash {
  background:
    radial-gradient(circle at 68% 45%, rgba(98, 255, 143, 0.24), transparent 18%),
    linear-gradient(180deg, rgba(2, 10, 3, 0.12), rgba(1, 7, 2, 0.44));
}

.loader {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    linear-gradient(180deg, rgba(1, 7, 2, 0.94), rgba(2, 10, 3, 0.97)),
    radial-gradient(circle at center, rgba(25, 77, 34, 0.22), transparent 50%);
  transition:
    opacity 500ms ease,
    visibility 500ms ease;
}

.loader.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.loader__panel {
  width: min(100%, 36rem);
  padding: 2rem;
  border: 1px solid var(--line);
  background: var(--bg-panel);
  box-shadow: 0 0 30px var(--shadow);
  backdrop-filter: blur(18px);
}

.loader__eyebrow {
  margin: 0 0 0.75rem;
  color: var(--text-soft);
  font-size: 0.78rem;
  letter-spacing: 0.28rem;
  text-transform: uppercase;
}

.loader__title {
  margin: 0 0 1.25rem;
  font-size: clamp(2.6rem, 7vw, 4.8rem);
  line-height: 0.95;
  text-transform: uppercase;
}

.loader__bar {
  overflow: hidden;
  height: 0.95rem;
  border: 1px solid rgba(93, 255, 139, 0.28);
  background: rgba(255, 255, 255, 0.05);
}

.loader__progress {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
  box-shadow: 0 0 22px rgba(57, 255, 120, 0.6);
  transition: width 220ms ease;
}

.loader__status {
  margin: 0.85rem 0 0;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.hero {
  position: sticky;
  top: 0;
  min-height: 100vh;
  overflow: hidden;
}

.hero__viewport {
  position: absolute;
  inset: 0;
  transform-origin: center center;
  will-change: transform, filter;
  transition:
    transform 180ms linear,
    filter 180ms linear,
    opacity 240ms ease;
}

.hero__image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100vh;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  transition: opacity 700ms ease;
}

body.is-ready .hero__image--base {
  opacity: 1;
}

body.is-ready .hero__image--mid,
body.is-ready .hero__image--final {
  opacity: 0;
}

.hero__flash {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  background:
    radial-gradient(circle at 50% 24%, rgba(199, 255, 213, 0.18), transparent 28%),
    radial-gradient(circle at 68% 48%, rgba(57, 255, 120, 0.18), transparent 22%),
    linear-gradient(180deg, rgba(150, 255, 181, 0.08), transparent 55%);
}

.hero__hud {
  position: absolute;
  right: clamp(1rem, 3vw, 2.5rem);
  bottom: clamp(1rem, 4vw, 2.5rem);
  z-index: 2;
  max-width: min(28rem, calc(100vw - 2rem));
  padding: 1rem 1.15rem;
  border: 1px solid rgba(93, 255, 139, 0.22);
  background: rgba(3, 10, 5, 0.56);
  box-shadow: 0 0 26px rgba(17, 255, 106, 0.12);
  backdrop-filter: blur(10px);
}

.hero__label,
.hero__hint {
  margin: 0;
}

.hero__label {
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.22rem;
  text-transform: uppercase;
}

.hero__hint {
  margin-top: 0.45rem;
  color: var(--text-main);
  font-size: clamp(0.95rem, 1.7vw, 1.1rem);
}

.printer-world {
  position: relative;
  z-index: 3;
  min-height: 220vh;
}

.printer-world__stage {
  position: sticky;
  top: 0;
  min-height: 100vh;
  overflow: hidden;
}

.printer-world__backdrop {
  position: absolute;
  inset: 0;
  opacity: 1;
  will-change: transform, filter, opacity;
}

.printer-world__image,
.printer-world__veil,
.printer-world__portal-glow {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.printer-world__image {
  display: block;
  object-fit: cover;
  object-position: center;
}

.printer-world__veil {
  background:
    linear-gradient(180deg, rgba(1, 7, 2, 0.2) 0%, rgba(1, 7, 2, 0.5) 100%),
    radial-gradient(circle at 68% 40%, rgba(62, 255, 117, 0.15), transparent 24%);
}

.printer-world__portal-glow {
  opacity: 0.24;
  mix-blend-mode: screen;
  background:
    radial-gradient(circle at 68% 44%, rgba(80, 255, 134, 0.35), transparent 10%),
    radial-gradient(circle at 68% 44%, rgba(80, 255, 134, 0.18), transparent 22%);
}

.printer-world__content {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: center;
  min-height: 100vh;
  max-width: 34rem;
  margin-left: auto;
  padding: clamp(1rem, 3vw, 2.5rem);
  opacity: 0;
  transform: translate3d(0, 60px, 0);
  will-change: transform, opacity;
}

.printer-world__eyebrow,
.printer-world__title,
.printer-world__text {
  margin: 0;
}

.printer-world__eyebrow {
  color: var(--accent);
  font-size: 0.8rem;
  letter-spacing: 0.22rem;
  text-transform: uppercase;
}

.printer-world__title {
  margin-top: 0.7rem;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 0.95;
}

.printer-world__text {
  margin-top: 1rem;
  padding: 1rem 1.15rem;
  border: 1px solid rgba(93, 255, 139, 0.2);
  background: rgba(4, 11, 6, 0.68);
  color: var(--text-soft);
  font-size: clamp(1rem, 1.4vw, 1.08rem);
  line-height: 1.55;
  backdrop-filter: blur(14px);
}

.printer-feature {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: clamp(1rem, 3vw, 2.5rem);
  opacity: 0;
  transform: translate3d(0, -260px, 0);
  pointer-events: none;
  will-change: transform, opacity;
}

.printer-feature__copy {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: 26rem;
  padding: 1rem 1.15rem;
  border: 1px solid rgba(93, 255, 139, 0.2);
  background: rgba(3, 10, 5, 0.52);
  backdrop-filter: blur(10px);
  transform: translate3d(-170%, -50%, 0);
}

.printer-feature__eyebrow,
.printer-feature__title,
.printer-feature__description {
  margin: 0;
}

.printer-feature__eyebrow {
  color: var(--accent);
  font-size: 0.8rem;
  letter-spacing: 0.2rem;
  text-transform: uppercase;
}

.printer-feature__title {
  margin-top: 0.6rem;
  font-size: clamp(1.8rem, 3vw, 2.8rem);
  line-height: 1;
}

.printer-feature__description {
  margin-top: 0.8rem;
  color: var(--text-soft);
  line-height: 1.55;
}

.printer-feature__viewer {
  position: relative;
  width: min(100%, 38rem);
  aspect-ratio: 1 / 1;
  background: transparent;
  transform: translateX(0);
}

.printer-feature__canvas {
  display: block;
  width: 100%;
  height: 100%;
}

body.is-transitioning-printer .hero__viewport {
  transform: translate3d(-148%, -98%, 0) scale(5.2);
  filter: brightness(1.2) blur(16px);
}

body.is-transitioning-printer .hero__hud {
  opacity: 0;
  transform: translate3d(0, 24px, 0);
  transition: opacity 220ms ease, transform 220ms ease;
}

body.is-transitioning-printer .portal-transition {
  opacity: 1;
  transition: opacity 180ms ease;
}

body.is-transitioning-printer .portal-transition__image {
  transform: scale(1);
  filter: blur(6px) brightness(0.82);
  transition:
    transform 700ms cubic-bezier(0.2, 0.8, 0.2, 1),
    filter 700ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

body.is-transitioning-printer.phase-switch .portal-transition__image {
  transform: scale(1);
  filter: blur(0) brightness(0.95);
}

body.is-returning-printer .portal-transition {
  opacity: 1;
  transition: opacity 180ms ease;
}

body.is-returning-printer .portal-transition__image {
  transform: scale(1);
  filter: blur(0) brightness(0.95);
  transition:
    transform 700ms cubic-bezier(0.2, 0.8, 0.2, 1),
    filter 700ms cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 260ms ease;
}

body.is-returning-printer.phase-switch-back .portal-transition__image {
  transform: scale(1.08);
  filter: blur(20px) brightness(0.58);
}

body.is-returning-printer.phase-switch-back .portal-transition {
  opacity: 0;
}

body.is-returning-printer .hero__viewport,
body.is-returning-printer.phase-switch-back .hero__viewport {
  transform: translate3d(-142%, -90%, 0) scale(4.1);
  filter: brightness(1.12);
}

body.is-printer-world .printer-world__backdrop {
  filter: brightness(0.9);
}

body.is-exiting-printer .printer-world__backdrop {
  filter: brightness(0.8) blur(8px);
  transform: scale(1.04);
  transition:
    transform 460ms ease,
    filter 460ms ease;
}

body.is-exiting-printer .printer-world__content {
  opacity: 0;
  transform: translate3d(0, -36px, 0);
  transition: opacity 260ms ease, transform 260ms ease;
}

body.is-exiting-printer .hero__hud {
  opacity: 0;
  transform: translate3d(0, 24px, 0);
  transition: opacity 240ms ease, transform 240ms ease;
}

body.is-exiting-printer .portal-transition {
  opacity: 0;
  transition: none;
}

body.is-exiting-printer .portal-transition__image {
  transform: translate3d(-148%, -98%, 0) scale(5.2);
  filter: blur(16px) brightness(1.2);
  transition: none;
}

body.is-exiting-printer .hero__viewport {
  transform: translate3d(-148%, -98%, 0) scale(5.2);
  filter: blur(16px) brightness(1.2);
  transition: none;
}

body.is-exiting-printer.phase-exit-blur .printer-world__backdrop {
  filter: brightness(0.55) blur(20px);
  transform: scale(1.08);
}

body.is-exiting-printer.phase-exit-blur .portal-transition {
  opacity: 1;
  transition: opacity 280ms ease;
}

body.is-exiting-printer.phase-exit-zoomout .portal-transition__image {
  transform: translate3d(0, 0, 0) scale(1);
  filter: blur(0) brightness(0.95);
  transition:
    transform 980ms cubic-bezier(0.2, 0.8, 0.2, 1),
    filter 980ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

body.is-exiting-printer.phase-exit-zoomout .hero__viewport {
  transform: translate3d(0, 0, 0) scale(1);
  filter: brightness(1) blur(0);
  transition:
    transform 980ms cubic-bezier(0.2, 0.8, 0.2, 1),
    filter 980ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.desk-return {
  position: relative;
  z-index: 2;
  min-height: 240vh;
}

.desk-return__stage {
  position: sticky;
  top: 0;
  min-height: 100vh;
  overflow: hidden;
}

.desk-return__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 1;
}

.desk-return__veil {
  position: absolute;
  inset: 0;
  background: transparent;
}

body.scene-booting .hero__image--base {
  animation: scene-base-flicker 2.8s steps(1, end) forwards;
}

body.scene-booting .hero__image--mid {
  animation: scene-mid-flicker 2.8s steps(1, end) forwards;
}

body.scene-booting .hero__image--final {
  animation: scene-final-flicker 2.8s steps(1, end) forwards;
}

body.scene-booting .hero__flash {
  animation: scene-flash 2.8s ease-out forwards;
}

body.scene-live .hero__image--base {
  opacity: 0;
}

body.scene-live .hero__image--mid {
  opacity: 0;
}

body.scene-live .hero__image--final {
  opacity: 1;
}

@keyframes scene-base-flicker {

  0%,
  10%,
  18%,
  28%,
  100% {
    opacity: 1;
  }

  12%,
  24%,
  36%,
  62%,
  74% {
    opacity: 0.78;
  }

  42%,
  86% {
    opacity: 0.2;
  }
}

@keyframes scene-mid-flicker {

  0%,
  8%,
  100% {
    opacity: 0;
  }

  14%,
  22%,
  32%,
  46%,
  58%,
  72% {
    opacity: 0.55;
  }

  18%,
  28%,
  40%,
  54%,
  66% {
    opacity: 0.9;
  }

  78%,
  88% {
    opacity: 0.22;
  }
}

@keyframes scene-final-flicker {

  0%,
  44% {
    opacity: 0;
  }

  48%,
  56%,
  68% {
    opacity: 0.82;
  }

  52%,
  62%,
  74% {
    opacity: 0.28;
  }

  84%,
  100% {
    opacity: 1;
  }
}

@keyframes scene-flash {

  0%,
  10%,
  100% {
    opacity: 0;
  }

  16%,
  30%,
  48% {
    opacity: 0.2;
  }

  20%,
  34%,
  52%,
  70% {
    opacity: 0.38;
  }

  58%,
  78% {
    opacity: 0.12;
  }
}

/* Lab3 Menu Hotspots (Pizarra) */
.lab3-btn {
  position: absolute;
  left: 63.5%;
  width: 17.5%;
  height: 6.5%;
  z-index: 100;
  padding: 0;
  background: transparent;
  color: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  display: block;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.3s ease,
    background-color 0.2s ease,
    border-color 0.2s ease;
}

/* Posiciones verticales ajustadas (subidos un poco más) */
.lab3-btn--projects {
  top: 26.0%;
}

.lab3-btn--about {
  top: 35%;
}

.lab3-btn--contact {
  top: 44.5%;
}

.lab3-btn--resume {
  top: 54.0%;
}

/* Solo se ve cuando la escena está activa */
body.scene-live .lab3-btn {
  opacity: 1;
  pointer-events: auto;
}

/* Efecto hover sutil */
.lab3-btn:hover {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: rgba(93, 255, 139, 0.2);
  box-shadow: 0 0 15px rgba(57, 255, 120, 0.1);
}

body.is-printer-world .lab3-btn {
  opacity: 0;
  pointer-events: none;
}

/* Iconos sociales pequeños (debajo de Resume) */
.lab3-icon {
  position: absolute;
  width: 2%;
  aspect-ratio: 1 / 1;
  z-index: 100;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.3s ease,
    background-color 0.2s ease,
    border-color 0.2s ease;
}

.lab3-icon--1 {
  left: 65.5%;
  top: 64%;
}

.lab3-icon--2 {
  left: 69.3%;
  top: 64.3%;
}

.lab3-icon--3 {
  left: 73.4%;
  top: 64.9%;
}

.lab3-icon--4 {
  left: 77.3%;
  top: 64.9%;
}

body.scene-live .lab3-icon {
  opacity: 1;
  pointer-events: auto;
}

.lab3-icon:hover {
  background-color: rgba(255, 255, 255, 0.12);
  border-color: rgba(93, 255, 139, 0.3);
  box-shadow: 0 0 10px rgba(57, 255, 120, 0.2);
}

body.is-printer-world .lab3-icon {
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {

  .loader,
  .loader__progress,
  .hero__image,
  .hero__flash,
  .hero__viewport,
  .printer-world__backdrop,
  .printer-world__content {
    transition: none;
    animation: none !important;
  }
}

@media (max-width: 640px) {
  .loader {
    padding: 1rem;
  }

  .loader__panel {
    padding: 1.35rem;
  }

  .loader__eyebrow {
    letter-spacing: 0.18rem;
  }

  .story__scene {
    height: 340vh;
  }

  .printer-world {
    min-height: 180vh;
  }

  .desk-return {
    min-height: 180vh;
  }

  .hero__hud {
    right: 0.8rem;
    bottom: 0.8rem;
    left: 0.8rem;
    max-width: none;
  }

  .printer-world__content {
    max-width: none;
    padding: 1rem;
  }

  .printer-feature {
    place-items: center;
  }

  .printer-feature__viewer {
    width: 100%;
    max-width: 28rem;
    margin: 0 auto;
    transform: translateX(0);
  }

  .printer-feature__copy {
    position: static;
    max-width: none;
    transform: translate3d(0, 0, 0);
    margin-top: 1rem;
  }

}
/* GLOBAL PAGE TRANSITIONS */
.page-transition-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--bg-primary); /* matches styles.css background */
  z-index: 99999;
  opacity: 1;
  pointer-events: none;
  transition: opacity 400ms ease-in-out;
}
