/* Original Somos Codex visual system, preserved for the independent institutional theme. */

/* base.css */
:where([data-theme="somos-codex"] .sc-home) *,
:where([data-theme="somos-codex"] .sc-home) *::before,
:where([data-theme="somos-codex"] .sc-home) *::after {
  box-sizing: border-box;
}

:where([data-theme="somos-codex"] .sc-home) {
  background: var(--c-abyss);
  color-scheme: dark;
  scroll-padding-top: var(--header-h);
  -webkit-text-size-adjust: 100%;
}

:where([data-theme="somos-codex"] .sc-home) {
  margin: 0;
  min-width: 320px;
  overflow-x: clip;
  background: var(--c-abyss);
  color: var(--c-text);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-stretch: calc(var(--wdth-body) * 1%);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

:where([data-theme="somos-codex"] .sc-home) h1,
:where([data-theme="somos-codex"] .sc-home) h2,
:where([data-theme="somos-codex"] .sc-home) h3,
:where([data-theme="somos-codex"] .sc-home) p,
:where([data-theme="somos-codex"] .sc-home) ol,
:where([data-theme="somos-codex"] .sc-home) ul,
:where([data-theme="somos-codex"] .sc-home) dl,
:where([data-theme="somos-codex"] .sc-home) dd,
:where([data-theme="somos-codex"] .sc-home) figure,
:where([data-theme="somos-codex"] .sc-home) fieldset {
  margin: 0;
  padding: 0;
}

:where([data-theme="somos-codex"] .sc-home) ol,
:where([data-theme="somos-codex"] .sc-home) ul {
  list-style: none;
}

:where([data-theme="somos-codex"] .sc-home) fieldset {
  border: 0;
  min-width: 0;
}

:where([data-theme="somos-codex"] .sc-home) img {
  display: block;
  max-width: 100%;
  height: auto;
}

:where([data-theme="somos-codex"] .sc-home) a {
  color: inherit;
  text-decoration: none;
}

:where([data-theme="somos-codex"] .sc-home) button,
:where([data-theme="somos-codex"] .sc-home) input,
:where([data-theme="somos-codex"] .sc-home) select,
:where([data-theme="somos-codex"] .sc-home) textarea {
  font: inherit;
  color: inherit;
}

:where([data-theme="somos-codex"] .sc-home) :focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 3px;
  border-radius: 4px;
}

:where([data-theme="somos-codex"] .sc-home) ::selection {
  background: var(--c-accent);
  color: var(--c-abyss);
}

:where([data-theme="somos-codex"] .sc-home) .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Entradas únicas al llegar a cada sección. Sin JavaScript, o con movimiento
   reducido, todo se muestra desde el principio (site.js añade .sc-motion). */
:where([data-theme="somos-codex"] .sc-home.sc-motion) [data-reveal] {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 0.9s var(--ease),
    transform 0.9s var(--ease),
    clip-path 1.1s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 85ms);
}

/* Encabezado: cada pieza entra por separado, el título se descubre de abajo arriba. */
:where([data-theme="somos-codex"] .sc-home.sc-motion) [data-reveal="heading"] {
  opacity: 1;
  transform: none;
}

:where([data-theme="somos-codex"] .sc-home.sc-motion) [data-reveal="heading"] > * {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.8s var(--ease), transform 0.9s var(--ease), clip-path 1s var(--ease-out);
}

:where([data-theme="somos-codex"] .sc-home.sc-motion) [data-reveal="heading"] > :is(h2, h3) {
  clip-path: inset(-0.2em -0.2em 100% -0.2em);
  transform: translateY(0.35em);
}

:where([data-theme="somos-codex"] .sc-home.sc-motion) [data-reveal="heading"] > :nth-child(2) { transition-delay: 80ms; }
:where([data-theme="somos-codex"] .sc-home.sc-motion) [data-reveal="heading"] > :nth-child(3) { transition-delay: 170ms; }
:where([data-theme="somos-codex"] .sc-home.sc-motion) [data-reveal="heading"] > :nth-child(n + 4) { transition-delay: 250ms; }

/* Imagen: se abre como un obturador y se asienta desde un leve acercamiento.
   El recorte va en el primer hijo: el elemento observado debe seguir visible
   para que IntersectionObserver lo detecte. */
:where([data-theme="somos-codex"] .sc-home.sc-motion) [data-reveal="image"] {
  opacity: 1;
  transform: none;
}

:where([data-theme="somos-codex"] .sc-home.sc-motion) [data-reveal="image"] > :first-child {
  clip-path: inset(0 0 100% 0);
  transition: clip-path 1.15s var(--ease-out);
}

:where([data-theme="somos-codex"] .sc-home.sc-motion) [data-reveal="image"] > figcaption {
  opacity: 0;
  transition: opacity 0.6s var(--ease) 0.5s;
}

:where([data-theme="somos-codex"] .sc-home.sc-motion) [data-reveal="image"] img {
  scale: 1.14;
  transition: scale 1.6s var(--ease-out);
}

:where([data-theme="somos-codex"] .sc-home.sc-motion) [data-reveal].is-visible,
:where([data-theme="somos-codex"] .sc-home.sc-motion) [data-reveal="heading"].is-visible > *,
:where([data-theme="somos-codex"] .sc-home.sc-motion) [data-reveal="image"].is-visible > figcaption {
  opacity: 1;
  transform: none;
}

:where([data-theme="somos-codex"] .sc-home.sc-motion) [data-reveal="heading"].is-visible > :is(h2, h3) {
  clip-path: inset(-0.2em);
}

:where([data-theme="somos-codex"] .sc-home.sc-motion) [data-reveal="image"].is-visible > :first-child {
  clip-path: inset(0);
}

:where([data-theme="somos-codex"] .sc-home.sc-motion) [data-reveal="image"].is-visible img {
  scale: 1;
}

:where([data-theme="somos-codex"] .sc-home.sc-motion) [data-reveal]:focus-within,
:where([data-theme="somos-codex"] .sc-home.sc-motion) [data-reveal]:focus-within > * {
  opacity: 1;
  transform: none;
  clip-path: none;
  transition: none;
}

@media (max-width: 899px) {
  :where([data-theme="somos-codex"] .sc-home.sc-motion > *) [data-reveal] {
    --dur: 0.55s;
  }
}

@media (prefers-reduced-motion: no-preference) {
  :where([data-theme="somos-codex"] .sc-home) {
    scroll-behavior: smooth;
  }
}

@media (prefers-reduced-motion: reduce) {
  :where([data-theme="somos-codex"] .sc-home) *,
  :where([data-theme="somos-codex"] .sc-home) *::before,
  :where([data-theme="somos-codex"] .sc-home) *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}

/* components.css */
/* ---------- Botones ---------- */
/* Planos y casi rectos, como el logotipo. El principal siempre lleva el acento. */
:where([data-theme="somos-codex"] .sc-home) .btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 3.5rem;
  padding: 0.9rem 1.75rem;
  border: 0;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition:
    background-color 0.25s var(--ease),
    color 0.25s var(--ease),
    transform 0.2s var(--ease);
}

:where([data-theme="somos-codex"] .sc-home) .btn svg {
  transition: transform 0.3s var(--ease);
}

:where([data-theme="somos-codex"] .sc-home) .btn:hover svg {
  transform: translate(3px, -3px);
}

:where([data-theme="somos-codex"] .sc-home) .btn:active {
  transform: scale(0.97);
}

:where([data-theme="somos-codex"] .sc-home) .btn--primary {
  background: var(--c-accent);
  color: var(--c-abyss);
}

:where([data-theme="somos-codex"] .sc-home) .btn--primary:hover {
  background: var(--c-accent-strong);
}

:where([data-theme="somos-codex"] .sc-home) .btn--ghost {
  background: rgb(238 242 247 / 0.09);
  color: var(--c-text);
}

:where([data-theme="somos-codex"] .sc-home) .btn--ghost:hover {
  background: rgb(238 242 247 / 0.16);
}

/* ---------- Rótulos ---------- */
/* OSD: texto sobreimpreso de la cámara. Solo vive sobre superficies de cámara
   (escena principal, despiece y visor de instalación). */
:where([data-theme="somos-codex"] .sc-home) .osd {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--c-muted);
}

/* Piloto de grabación: parpadea como el de una cámara encendida. */
:where([data-theme="somos-codex"] .sc-home) .osd__dot {
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #ff5a4f;
}

@media (prefers-reduced-motion: no-preference) {
  :where([data-theme="somos-codex"] .sc-home) .osd__dot {
    animation: sc-rec 1.6s steps(2, jump-none) infinite;
  }
}

@keyframes sc-rec {
  50% { opacity: 0.25; }
}

/* ---------- Títulos de sección ---------- */
:where([data-theme="somos-codex"] .sc-home) .section-head {
  display: grid;
  gap: 1.25rem;
  max-width: 46rem;
}

:where([data-theme="somos-codex"] .sc-home) .section-title {
  font-size: var(--fs-title);
  font-weight: 600;
  font-stretch: calc(var(--wdth-display) * 1%);
  line-height: 1.04;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

:where([data-theme="somos-codex"] .sc-home) .section-lead {
  max-width: 36rem;
  font-size: var(--fs-lead);
  line-height: 1.55;
  color: var(--c-soft);
  text-wrap: pretty;
}

/* sections/hero.css */
/* Hero: una escena a sangre con fotografías que se funden despacio (modules/hero.ts).
   El texto vive sobre la zona oscura de la izquierda; la cámara queda a la derecha. */
:where([data-theme="somos-codex"] .sc-home) .hero {
  --hero-fade: 2.4s;

  position: relative;
  display: grid;
  align-content: center;
  min-height: 100svh;
  padding: calc(var(--header-h) + 2rem) var(--pad) clamp(5rem, 11vh, 7rem);
  overflow: clip;
  isolation: isolate;
  background: var(--c-abyss);
}

:where([data-theme="somos-codex"] .sc-home) .hero__scene {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

/* Las imágenes se apilan. La entrante se funde encima de la actual, que no se
   retira hasta quedar tapada: en ningún momento se ve el fondo. */
:where([data-theme="somos-codex"] .sc-home) .hero__slide {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  width: calc(100% + var(--bleed, 0%));
  max-width: none;
  height: 100%;
  object-fit: cover;
  object-position: var(--pos, 50% 50%);
  opacity: 0;
  transform-origin: 75% 50%;
  transition: opacity var(--hero-fade) ease-in-out;
}

:where([data-theme="somos-codex"] .sc-home) .hero__slide.is-active {
  z-index: 1;
  opacity: 1;
}

:where([data-theme="somos-codex"] .sc-home) .hero__slide.is-entering {
  z-index: 2;
  opacity: 1;
}

:where([data-theme="somos-codex"] .sc-home) .hero__slide--first {
  transition-duration: 700ms;
}
@media (prefers-reduced-motion: reduce) {
  :where([data-theme="somos-codex"] .sc-home) .hero__slide { transition: none; }
}

/* Oscurece la zona del texto y funde la escena con la cabecera y la sección siguiente. */
:where([data-theme="somos-codex"] .sc-home) .hero__scene::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  background:
    linear-gradient(to bottom, rgb(4 7 13 / 0.86), rgb(4 7 13 / 0.5) 4.5rem, transparent 9rem),
    linear-gradient(to top, var(--c-abyss), rgb(4 7 13 / 0.5) 16%, transparent 44%),
    linear-gradient(to right, rgb(4 7 13 / 0.94), rgb(4 7 13 / 0.78) 28%, rgb(4 7 13 / 0.2) 52%, transparent 66%);
}

:where([data-theme="somos-codex"] .sc-home) .hero__copy {
  display: grid;
  gap: 1.5rem;
  justify-items: start;
}

/* Dos renglones fijos: cada uno entra por separado al encenderse la escena. */
:where([data-theme="somos-codex"] .sc-home) .hero__title {
  font-size: var(--fs-display);
  font-weight: 600;
  font-stretch: calc(var(--wdth-display) * 1%);
  line-height: 0.96;
  letter-spacing: -0.03em;
}

:where([data-theme="somos-codex"] .sc-home) .hero__line {
  display: block;
  padding-bottom: 0.06em;
  overflow: clip;
  white-space: nowrap;
}

:where([data-theme="somos-codex"] .sc-home) .hero__line > span {
  display: inline-block;
}

:where([data-theme="somos-codex"] .sc-home) .hero__lead {
  max-width: 30rem;
  font-size: var(--fs-lead);
  line-height: 1.55;
  color: rgb(238 242 247 / 0.86);
  text-wrap: pretty;
}

:where([data-theme="somos-codex"] .sc-home) .hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* Rótulo de la escena: canal, indicador de imagen y pausa. */
:where([data-theme="somos-codex"] .sc-home) .hero__osd {
  position: absolute;
  inset: auto var(--pad) clamp(1.25rem, 3vh, 2rem);
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-height: 2.75rem;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgb(255 255 255 / 0.78);
}

:where([data-theme="somos-codex"] .sc-home) .hero__channel {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-right: auto;
}

:where([data-theme="somos-codex"] .sc-home) .hero__rotation {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

:where([data-theme="somos-codex"] .sc-home) .hero__rotation[hidden] {
  display: none;
}

:where([data-theme="somos-codex"] .sc-home) .hero__ticks {
  display: flex;
  gap: 0.35rem;
}

:where([data-theme="somos-codex"] .sc-home) .hero__ticks span {
  width: 1.5rem;
  height: 2px;
  background: rgb(255 255 255 / 0.28);
  transition: background-color 0.6s var(--ease);
}

:where([data-theme="somos-codex"] .sc-home) .hero__ticks .is-active {
  background: var(--c-accent-strong);
}

:where([data-theme="somos-codex"] .sc-home) .hero__toggle {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  transition: background-color 0.25s var(--ease);
}

:where([data-theme="somos-codex"] .sc-home) .hero__toggle:hover {
  background: rgb(255 255 255 / 0.1);
}

:where([data-theme="somos-codex"] .sc-home) .hero__toggle svg {
  fill: currentColor;
}

:where([data-theme="somos-codex"] .sc-home) .hero__toggle-play,
:where([data-theme="somos-codex"] .sc-home) .is-paused .hero__toggle-pause {
  display: none;
}

:where([data-theme="somos-codex"] .sc-home) .is-paused .hero__toggle-play {
  display: block;
}

/* Pantallas verticales o casi cuadradas: la escena ocupa una franja superior
   donde la cámara cabe entera, y el texto sigue debajo. */
@media (max-aspect-ratio: 3/2) {
  :where([data-theme="somos-codex"] .sc-home) .hero {
    --scene-h: min(100vw, 56svh);

    align-content: start;
    padding-top: calc(var(--scene-h) - 5.5rem);
    padding-bottom: 5.5rem;
  }

  :where([data-theme="somos-codex"] .sc-home) .hero__scene {
    inset: 0 0 auto;
    height: var(--scene-h);
  }

  :where([data-theme="somos-codex"] .sc-home) .hero__scene::after {
    background:
      linear-gradient(to bottom, rgb(4 7 13 / 0.72), transparent 7rem),
      linear-gradient(to top, var(--c-abyss), rgb(4 7 13 / 0.6) 14%, transparent 42%);
  }

  :where([data-theme="somos-codex"] .sc-home) .hero__slide {
    width: 100%;
  }

  :where([data-theme="somos-codex"] .sc-home) .hero__title {
    max-width: none;
  }

  :where([data-theme="somos-codex"] .sc-home) .hero__lead {
    max-width: 32rem;
  }
}

/* Móvil en horizontal: poca altura, así que el texto se compacta junto a la cámara. */
@media (orientation: landscape) and (max-height: 560px) {
  :where([data-theme="somos-codex"] .sc-home) .hero {
    padding-top: calc(var(--header-h) + 0.75rem);
    padding-bottom: 4rem;
  }

  :where([data-theme="somos-codex"] .sc-home) .hero__copy {
    gap: 0.9rem;
  }

  :where([data-theme="somos-codex"] .sc-home) .hero__title {
    max-width: 8em;
    font-size: clamp(1.9rem, 4.6vw, 2.6rem);
  }

  :where([data-theme="somos-codex"] .sc-home) .hero__lead {
    max-width: 22rem;
    font-size: var(--fs-small);
  }

  :where([data-theme="somos-codex"] .sc-home) .hero__actions {
    margin-top: 0;
  }
}

@media (max-width: 599px) {
  :where([data-theme="somos-codex"] .sc-home) .hero__actions {
    width: 100%;
  }

  :where([data-theme="somos-codex"] .sc-home) .hero__actions .btn {
    flex: 1 1 12rem;
  }

  :where([data-theme="somos-codex"] .sc-home) .hero__clock {
    display: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  /* La cámara se enciende: la escena sube desde negro con un parpadeo de
     exposición y se asienta desde un acercamiento; después entra el texto. */
  :where([data-theme="somos-codex"] .sc-home) .hero__scene {
    animation: sc-hero-power 1.9s var(--ease-out) both;
  }

  :where([data-theme="somos-codex"] .sc-home) .hero__line > span {
    animation: sc-hero-line 1.1s var(--ease-out) both;
    animation-delay: 0.45s;
  }

  :where([data-theme="somos-codex"] .sc-home) .hero__line + .hero__line > span {
    animation-delay: 0.57s;
  }

  :where([data-theme="somos-codex"] .sc-home) .hero__copy > :not(h1) {
    animation: sc-hero-rise 0.9s var(--ease) both;
    animation-delay: 0.8s;
  }

  :where([data-theme="somos-codex"] .sc-home) .hero__copy > :not(h1) + :not(h1) {
    animation-delay: 0.92s;
  }

  :where([data-theme="somos-codex"] .sc-home) .hero__osd {
    animation: sc-hero-fade 0.8s var(--ease) 1.2s both;
  }

  /* Acercamiento lento mientras la imagen está en pantalla. */
  :where([data-theme="somos-codex"] .sc-home) .hero--live .hero__slide:is(.is-active, .is-entering) {
    animation: sc-hero-drift 14s linear both;
  }
}

/* Al bajar, la escena se aleja de la cámara y el texto se retira antes. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    :where([data-theme="somos-codex"] .sc-home) .hero {
      view-timeline: --sc-hero block;
    }

    :where([data-theme="somos-codex"] .sc-home) .hero__copy {
      animation: sc-hero-exit-copy linear both;
      animation-timeline: --sc-hero;
      animation-range: exit 0% exit 70%;
    }

    :where([data-theme="somos-codex"] .sc-home) .hero__scene {
      animation:
        sc-hero-power 1.9s var(--ease-out) both,
        sc-hero-exit-scene linear both;
      animation-timeline: auto, --sc-hero;
      animation-range: normal, exit 0% exit 100%;
    }
  }
}

@keyframes sc-hero-power {
  0% { opacity: 0; transform: scale(1.09); }
  14% { opacity: 0.55; }
  20% { opacity: 0.2; }
  34% { opacity: 0.85; }
  100% { opacity: 1; transform: none; }
}

@keyframes sc-hero-line {
  from { transform: translateY(105%); }
}

@keyframes sc-hero-rise {
  from { opacity: 0; transform: translateY(22px); }
}

@keyframes sc-hero-fade {
  from { opacity: 0; }
}

@keyframes sc-hero-exit-copy {
  to { opacity: 0; translate: 0 -12vh; }
}

@keyframes sc-hero-exit-scene {
  to { scale: 1.14; }
}

@keyframes sc-hero-drift {
  from { transform: scale(1.06); }
  to { transform: scale(1); }
}

/* sections/stages.css */
/* Secciones con imagen protagonista y textos HTML independientes.
   02 se recorre con scroll (animations/disassembly.ts); 04 sigue estática. */

:where([data-theme="somos-codex"] .sc-home) .stage {
  padding: var(--section-space) var(--pad);
}

:where([data-theme="somos-codex"] .sc-home) .stage__pin {
  display: grid;
  gap: clamp(2rem, 4vw, 3.5rem);
}

:where([data-theme="somos-codex"] .sc-home) .beats {
  display: grid;
  gap: 2rem clamp(1.5rem, 3vw, 3rem);
}

/* ---------- 02 · Ingeniería y diseño ---------- */
/* Versión estática: sin JavaScript, con movimiento reducido o si falla la secuencia. */
:where([data-theme="somos-codex"] .sc-home) .stage--engineering {
  display: grid;
  gap: clamp(2.5rem, 5vw, 4.5rem);
  background: linear-gradient(to bottom, var(--c-abyss), var(--c-deep) 40%, var(--c-abyss));
}

:where([data-theme="somos-codex"] .sc-home) .stage__media {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--c-navy);
}

:where([data-theme="somos-codex"] .sc-home) .stage__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

:where([data-theme="somos-codex"] .sc-home) .stage__overlay {
  display: grid;
  gap: clamp(1.5rem, 3vw, 2.5rem);
}

:where([data-theme="somos-codex"] .sc-home) .stage__progress {
  display: none;
}

:where([data-theme="somos-codex"] .sc-home) .moments {
  display: grid;
  gap: 2rem clamp(1.5rem, 3vw, 3rem);
}

:where([data-theme="somos-codex"] .sc-home) .moment {
  display: grid;
  gap: 0.6rem;
  align-content: start;
  padding-top: 1.25rem;
  border-top: 1px solid var(--c-line-strong);
}

:where([data-theme="somos-codex"] .sc-home) .moment__label {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-accent);
}

:where([data-theme="somos-codex"] .sc-home) .moment__phrase {
  font-size: 1.35rem;
  font-weight: 600;
  font-stretch: calc(var(--wdth-display) * 1%);
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

:where([data-theme="somos-codex"] .sc-home) .stage__note {
  font-size: var(--fs-small);
  color: var(--c-muted);
}

@media (min-width: 600px) {
  :where([data-theme="somos-codex"] .sc-home) .moments {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  :where([data-theme="somos-codex"] .sc-home) .moments {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Versión con scroll: el tramo es más alto que la pantalla y el contenido queda
   fijo con position: sticky mientras se recorre. No se altera el scroll.

   La escena no tiene marco. El fotograma se funde por los bordes con un fondo
   CSS que repite, fila a fila, los tonos del propio video (--sky arriba,
   --floor abajo), y el suelo continúa por debajo hasta apagarse. */
:where([data-theme="somos-codex"] .sc-home) .stage--scrub {
  --travel: 220vh;
  --scene-w: min(100%, calc((100svh - var(--header-h)) * 16 / 9), 97.5rem);
  --sky: #080e17;
  --floor: #1a2639;
  /* Tramo en el que el suelo se apaga al salir de la escena. */
  --floor-run: clamp(8rem, 30vh, 17rem);

  gap: 0;
  padding-bottom: var(--floor-run);
  background: linear-gradient(
    to bottom,
    var(--c-abyss),
    var(--sky) 18rem,
    var(--sky) calc(100% - var(--floor-run)),
    var(--c-abyss)
  );
}

:where([data-theme="somos-codex"] .sc-home) .stage--scrub .section-head {
  padding-bottom: clamp(2rem, 5vw, 3.5rem);
}

:where([data-theme="somos-codex"] .sc-home) .stage--scrub .stage__track {
  height: calc(100svh + var(--travel));
  margin-inline: calc(var(--pad) * -1);
  overflow-x: clip;
}

:where([data-theme="somos-codex"] .sc-home) .stage--scrub .stage__pin {
  position: sticky;
  top: 0;
  display: block;
  height: 100svh;
}

/* Escena y textos comparten la misma caja 16:9, centrada bajo la cabecera. */
:where([data-theme="somos-codex"] .sc-home) .stage--scrub .stage__scene,
:where([data-theme="somos-codex"] .sc-home) .stage--scrub .stage__overlay {
  position: absolute;
  inset: var(--header-h) 0 0;
  width: var(--scene-w);
  aspect-ratio: 16 / 9;
  margin: auto;
}

:where([data-theme="somos-codex"] .sc-home) .stage--scrub .stage__scene {
  isolation: isolate;
}

:where([data-theme="somos-codex"] .sc-home) .stage--scrub .stage__scene::before,
:where([data-theme="somos-codex"] .sc-home) .stage--scrub .stage__scene::after {
  content: '';
  position: absolute;
  z-index: -1;
  pointer-events: none;
}

/* Tonos del borde del fotograma, medidos cada 10 % de su altura. */
:where([data-theme="somos-codex"] .sc-home) .stage--scrub .stage__scene::before {
  inset: 0 -50vw;
  background: linear-gradient(
    to bottom,
    #080e17 0%,
    #080e17 10%,
    #090f1a 20%,
    #09111b 30%,
    #09111d 40%,
    #08121d 50%,
    #09131f 60%,
    #0d1829 70%,
    #152335 80%,
    #192536 90%,
    #1a2639 100%
  );
}

/* El suelo sigue por debajo del fotograma y se apaga. */
:where([data-theme="somos-codex"] .sc-home) .stage--scrub .stage__scene::after {
  inset: 100% -50vw auto;
  height: var(--floor-run);
  background:
    radial-gradient(30% 60% at 58% 0%, rgb(46 57 74 / 0.4), transparent 100%),
    linear-gradient(to bottom, var(--floor), rgb(26 38 57 / 0.55) 35%, rgb(8 14 23 / 0));
}

:where([data-theme="somos-codex"] .sc-home) .stage--scrub .stage__media {
  position: absolute;
  inset: 0;
  aspect-ratio: auto;
  border-radius: 0;
  background: none;
  -webkit-mask-image:
    linear-gradient(to bottom, transparent, #000 7%, #000 97%, transparent),
    linear-gradient(to right, transparent, #000 4%, #000 96%, transparent);
  mask-image:
    linear-gradient(to bottom, transparent, #000 7%, #000 97%, transparent),
    linear-gradient(to right, transparent, #000 4%, #000 96%, transparent);
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}

:where([data-theme="somos-codex"] .sc-home) .stage__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

:where([data-theme="somos-codex"] .sc-home) .stage__canvas.is-ready {
  opacity: 1;
}

:where([data-theme="somos-codex"] .sc-home) .stage--scrub .stage__progress {
  position: absolute;
  inset: auto 0 0;
  z-index: 2;
  display: block;
  height: 2px;
  background: var(--c-accent-strong);
  opacity: 0.7;
  transform: scaleX(0);
  transform-origin: left;
}

/* Los textos flanquean la cámara: cada uno ocupa la zona que el video deja libre
   en su momento del recorrido. Solo uno es visible a la vez. */
:where([data-theme="somos-codex"] .sc-home) .stage--scrub .stage__overlay {
  display: block;
  container-type: inline-size;
  pointer-events: none;
}

:where([data-theme="somos-codex"] .sc-home) .stage--scrub .moments {
  display: block;
}

:where([data-theme="somos-codex"] .sc-home) .stage--scrub .moment {
  position: absolute;
  padding-top: 0;
  border-top: 0;
}

:where([data-theme="somos-codex"] .sc-home) .stage--scrub .moment:not(:first-child) {
  opacity: 0;
}

/* 1 · cámara completa: a la izquierda, a media altura */
:where([data-theme="somos-codex"] .sc-home) .stage--scrub .moment:nth-child(1) {
  inset: 0 auto 0 4%;
  width: 21%;
  align-content: center;
}

/* 2 · frontal y óptica: abajo a la derecha, sobre el suelo */
:where([data-theme="somos-codex"] .sc-home) .stage--scrub .moment:nth-child(2) {
  inset: auto 4% 10% auto;
  width: 36%;
}

/* 3 · componentes: abajo a la izquierda */
:where([data-theme="somos-codex"] .sc-home) .stage--scrub .moment:nth-child(3) {
  inset: auto auto 10% 4%;
  width: 44%;
}

/* 4 · despiece final: arriba a la derecha, la única zona que queda despejada */
:where([data-theme="somos-codex"] .sc-home) .stage--scrub .moment:nth-child(4) {
  inset: 7% 4% auto auto;
  width: 48%;
}

:where([data-theme="somos-codex"] .sc-home) .stage--scrub .moment:nth-child(even) {
  justify-items: end;
  text-align: right;
}

:where([data-theme="somos-codex"] .sc-home) .stage--scrub .moment__phrase {
  font-size: clamp(1.15rem, 0.5rem + 2.2vw, 2.6rem);
  font-size: clamp(1.15rem, 3cqw, 2.6rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

:where([data-theme="somos-codex"] .sc-home) .stage--scrub .stage__note {
  position: absolute;
  inset: auto auto 3.2% 4%;
  max-width: 56%;
  font-size: var(--fs-label);
  line-height: 1.35;
  color: rgb(152 165 186 / 0.85);
}

/* Escena pequeña (móvil en horizontal): rótulos más contenidos y más separación
   entre la frase inferior y la nota. */
@container (max-width: 720px) {
  :where([data-theme="somos-codex"] .sc-home) .stage--scrub .moment {
    gap: 0.35rem;
  }

  :where([data-theme="somos-codex"] .sc-home) .stage--scrub .moment__label {
    font-size: 0.6rem;
  }

  :where([data-theme="somos-codex"] .sc-home) .stage--scrub .moment:nth-child(2),
  :where([data-theme="somos-codex"] .sc-home) .stage--scrub .moment:nth-child(3) {
    bottom: 15%;
  }

  :where([data-theme="somos-codex"] .sc-home) .stage--scrub .stage__note {
    max-width: 92%;
    font-size: 0.6rem;
  }
}

/* Móvil en vertical: la escena ocupa todo el ancho y los textos se suceden
   debajo, sobre el suelo, alternando el lado en el que se apoyan. */
@media (max-width: 899px) and (orientation: portrait) {
  :where([data-theme="somos-codex"] .sc-home) .stage--scrub {
    --travel: 190vh;
    --scene-w: 100%;
    --scene-top: calc(var(--header-h) + (100svh - var(--header-h) - 56.25vw - 12.5rem) * 0.5);
  }

  :where([data-theme="somos-codex"] .sc-home) .stage--scrub .stage__scene {
    inset: var(--scene-top) 0 auto;
    margin: 0;
  }

  :where([data-theme="somos-codex"] .sc-home) .stage--scrub .stage__media {
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 10%, #000 96%, transparent);
    mask-image: linear-gradient(to bottom, transparent, #000 10%, #000 96%, transparent);
  }

  /* Mismo encuadre ampliado con el que el canvas empieza en pantallas estrechas. */
  :where([data-theme="somos-codex"] .sc-home) .stage--scrub .stage__media img {
    transform: scale(1.4);
    transform-origin: 60.5% 50%;
  }

  :where([data-theme="somos-codex"] .sc-home) .stage--scrub .stage__overlay {
    inset: calc(var(--scene-top) + 56.25vw + 1.5rem) var(--pad) auto;
    display: grid;
    gap: 1.25rem;
    width: auto;
    aspect-ratio: auto;
    margin: 0;
  }

  :where([data-theme="somos-codex"] .sc-home) .stage--scrub .moments {
    display: grid;
  }

  :where([data-theme="somos-codex"] .sc-home) .stage--scrub .moment:nth-child(n) {
    position: static;
    grid-area: 1 / 1;
    width: auto;
    align-content: start;
  }

  /* Reserva dos líneas para que el cambio de frase no mueva nada. */
  :where([data-theme="somos-codex"] .sc-home) .stage--scrub .moment__phrase {
    min-height: 2.1em;
    font-size: clamp(1.6rem, 0.9rem + 2.6vw, 2.4rem);
  }

  :where([data-theme="somos-codex"] .sc-home) .stage--scrub .moment {
    gap: 0.6rem;
  }

  :where([data-theme="somos-codex"] .sc-home) .stage--scrub .moment__label {
    font-size: var(--fs-label);
  }

  :where([data-theme="somos-codex"] .sc-home) .stage--scrub .stage__note {
    position: static;
    max-width: 24rem;
    font-size: 0.72rem;
  }
}

/* sections/context.css */
/* En contexto: la fotografía del atardecer empieza como un recuadro y se abre
   hasta ocupar la pantalla mientras se baja. */
:where([data-theme="somos-codex"] .sc-home) .context {
  position: relative;
  display: grid;
  align-items: end;
  min-height: min(100svh, 62rem);
  padding: clamp(4rem, 10vw, 7rem) var(--pad);
  isolation: isolate;
}

:where([data-theme="somos-codex"] .sc-home) .context__media {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

:where([data-theme="somos-codex"] .sc-home) .context__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 76% center;
}

/* Velo neutro para que el texto se lea sobre la foto. */
:where([data-theme="somos-codex"] .sc-home) .context__media::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, rgb(4 7 13 / 0.92), rgb(4 7 13 / 0.55) 34%, transparent 64%),
    linear-gradient(to right, rgb(4 7 13 / 0.55), transparent 55%);
}

:where([data-theme="somos-codex"] .sc-home) .context__copy {
  display: grid;
  gap: 1.5rem;
  max-width: 44rem;
}

:where([data-theme="somos-codex"] .sc-home) .context__copy .section-lead {
  color: rgb(238 242 247 / 0.9);
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    :where([data-theme="somos-codex"] .sc-home) .context {
      view-timeline: --sc-context block;
    }

    :where([data-theme="somos-codex"] .sc-home) .context__media {
      animation: sc-context-open linear both;
      animation-timeline: --sc-context;
      animation-range: entry 0% cover 50%;
    }

    :where([data-theme="somos-codex"] .sc-home) .context__media img {
      animation: sc-context-settle linear both;
      animation-timeline: --sc-context;
      animation-range: entry 0% exit 100%;
    }
  }
}

@keyframes sc-context-open {
  from { clip-path: inset(9% 7% 9% 7% round 6px); }
  to { clip-path: inset(0 round 0); }
}

@keyframes sc-context-settle {
  from { scale: 1.22; }
  to { scale: 1; }
}
