/* ==========================================================================
   Estilos de componentes. Usa solo las variables de tokens.css.
   Orden: base → navegación → bloques comunes → un bloque por tipo de sección.
   ========================================================================== */

/* --- Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html {
  color-scheme: dark;                 /* barra de scroll oscura: no se ve una franja blanca sobre las secciones negras */
  scrollbar-color: #6f6f6f #000;
  /* Reserva siempre el espacio de la barra de scroll: el ancho de la ventana
     no cambia cuando aparece/desaparece (p. ej. al abrir el visor), así que
     los textos fluidos no se re-escalan. */
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
html:has(.lb[open]) { overflow: hidden; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--mist);
  font-family: var(--font-mono);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, video { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3, p, figure, ul { margin: 0; padding: 0; }
ul { list-style: none; }
button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.skip {
  position: fixed; left: 1rem; top: -4rem; z-index: 100;
  background: var(--paper); color: var(--ink); padding: .6rem 1rem;
}
.skip:focus { top: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* --- Navegación (píldora flotante, como la plantilla de referencia) -------- */
.nav {
  position: fixed; z-index: 50;
  top: max(.9rem, env(safe-area-inset-top));
  left: 50%; transform: translateX(-50%);
  max-width: calc(100% - 1.5rem);
}
.nav__bar {
  display: flex; align-items: center; gap: .25rem;
  padding: .35rem .4rem .35rem 1.1rem;
  border-radius: 999px;
  background: rgba(16, 16, 16, .72);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,.12);
  color: #eee; font-size: var(--fs-small);
}
.nav__brand { margin-right: .75rem; white-space: nowrap; text-decoration: none; }
.nav__list { display: flex; gap: .1rem; }
.nav__link {
  display: block; padding: .5rem .95rem; border-radius: 999px;
  text-decoration: none; white-space: nowrap;
}
.nav__link:hover { background: rgba(255,255,255,.14); }
.nav__link[aria-current="true"] { background: #fff; color: #000; }
.nav__toggle {
  display: none; margin-left: auto; padding: .5rem 1rem; cursor: pointer;
  border: 0; border-radius: 999px; background: rgba(255,255,255,.14);
}

@media (max-width: 760px) {
  .nav { width: calc(100% - 1.5rem); }
  .nav__bar { justify-content: space-between; }
  .nav__toggle { display: block; }
  .nav__list {
    display: none; position: absolute; left: 0; right: 0; top: calc(100% + .5rem);
    flex-direction: column; padding: .5rem; border-radius: 1.2rem;
    background: rgba(16,16,16,.94);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,.12);
  }
  .nav.is-open .nav__list { display: flex; }
  .nav__link { padding: .8rem 1rem; }
}

/* --- Bloques comunes ------------------------------------------------------ */
.sec {
  position: relative;
  background: var(--bg);
  color: var(--fg);
  padding-block: var(--section-pad);
}
.theme-dark  { --bg: var(--ink);   --fg: var(--mist); }
.theme-light { --bg: var(--paper); --fg: var(--ink); }

.wrap {
  width: 100%; max-width: var(--max); margin-inline: auto;
  padding-inline: var(--gutter);
}

.display {
  font-family: var(--font-display);
  font-weight: 300;
  text-transform: var(--caps-display);
  font-variant-numeric: lining-nums;  /* que el 3 de "3D" no baje de la línea */
  letter-spacing: var(--tracking-display);
  line-height: var(--lh-display);
}
.sec__title { font-size: var(--fs-title); text-align: center; text-wrap: balance; }
.mono { font-family: var(--font-mono); text-transform: var(--caps-mono); }
.small { font-size: var(--fs-small); }
.prose { max-width: 62ch; text-wrap: pretty; }
.prose strong { font-weight: 400; background: var(--fg); color: var(--bg); padding: 0 .3em; }  /* resaltado tipo marcador */
.prose a { text-underline-offset: .2em; }

/* Ola entre secciones: se dibuja con el color de la sección anterior */
.is-joined { padding-top: 0; }   /* dos secciones seguidas del mismo color comparten un solo espacio */
.has-wave { padding-top: calc(var(--section-pad) + var(--wave-h) * .5); }
.wave {
  position: absolute; left: 0; top: 0; width: 100%; height: var(--wave-h);
  display: block; pointer-events: none;
}
.wave__fill { fill: var(--prev-bg); }
.wave__line { fill: none; stroke: var(--wave-line); stroke-width: 2; vector-effect: non-scaling-stroke; }

/* --- Tile: imagen o video (se amplía al hacer clic) ------------------------- */
.tile { position: relative; }
.tile__btn {
  display: block; width: 100%; padding: 0; border: 0; background: none;
  cursor: zoom-in; text-align: inherit;
}
.tile__frame {
  position: relative; display: block; overflow: hidden;
  aspect-ratio: var(--ratio, 4 / 5);
  background: #151515; border-radius: var(--radius-tile);
}
.tile__media { width: 100%; height: 100%; object-fit: cover; }
.tile--video .tile__frame::after {   /* icono play, solo si el video no se reproduce solo */
  content: ""; position: absolute; right: .6rem; bottom: .6rem; width: 1.6rem; height: 1.6rem;
  border-radius: 50%; background: rgba(0,0,0,.55) center / 40% no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2 1l7 4-7 4z' fill='white'/%3E%3C/svg%3E");
  opacity: 0; transition: opacity .2s;
}
.tile--video .tile__btn:hover .tile__frame::after,
.tile--video.is-still .tile__frame::after { opacity: 1; }
.tile__cap { margin-top: .75rem; font-size: var(--fs-small); text-align: center; text-transform: var(--caps-mono); }

/* --- HERO ------------------------------------------------------------------- */
.hero { padding: 0; overflow: hidden; min-height: clamp(34rem, 56vw, 64rem); }
.hero__kicker {
  position: absolute; left: var(--gutter); top: clamp(5rem, 6vw, 6.5rem);
  font-size: clamp(1.1rem, 1.5vw, 1.6rem);
}
.hero__title { font-weight: inherit; }
.hero__name {
  position: absolute; z-index: 1;
  left: var(--gutter); top: clamp(7.5rem, 11.5vw, 8rem);
  font-size: var(--fs-hero-name); white-space: nowrap;
}
.hero__word {
  position: absolute; z-index: 3; right: -1.2vw; bottom: 0;
  font-size: var(--fs-hero-word); white-space: nowrap; line-height: .8;
  padding-bottom: .04em;
}
.hero__imgs { position: absolute; inset: 0; z-index: 2; }
.hero__img {
  position: absolute;
  left: calc(var(--x) * 1%); top: calc(var(--y) * 1%); width: calc(var(--w) * 1%);
}
.hero__lead {
  position: absolute; z-index: 2; left: var(--gutter); bottom: clamp(1.5rem, 4vw, 4rem);
  width: min(22rem, 30%); font-size: var(--fs-small); text-wrap: pretty;
}

@media (max-width: 760px) {
  .hero { display: flex; flex-direction: column; min-height: 0; padding: 5.5rem var(--gutter) 0; }
  .hero__title { display: contents; }   /* nombre y palabra se reordenan como hijos directos */
  .hero__kicker, .hero__name, .hero__word, .hero__lead, .hero__imgs { position: static; }
  .hero__kicker { order: 0; } .hero__name { order: 1; } .hero__imgs { order: 2; }
  .hero__lead { order: 3; } .hero__word { order: 4; }
  .hero__kicker { margin-bottom: 1.5rem; }
  .hero__name { white-space: normal; text-wrap: balance; }
  .hero__imgs { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin: 2rem 0 1.5rem; align-items: start; }
  .hero__img { position: static; width: auto; }
  .hero__lead { width: auto; max-width: 30ch; }
  .hero__word { align-self: flex-end; margin: 1.5rem -3vw 0 0; line-height: .85; font-size: clamp(3rem, 15.2vw, 7rem); }
}

/* --- REEL: fila de piezas verticales (p. ej. "Mis habilidades") ------------- */
.reel__row {
  display: grid; grid-template-columns: repeat(var(--cols, 3), 1fr);
  gap: clamp(.75rem, 5vw, 6rem);
  max-width: 64rem; margin: clamp(2rem, 5vw, 4.5rem) auto 0;
}
.reel__item { justify-self: center; width: min(100%, var(--tile-max, 15rem)); }
.reel__caption { margin: clamp(1.75rem, 4vw, 3.5rem) auto 0; text-align: center; font-size: var(--fs-small); }
.reel__caption.prose { max-width: 56ch; }
@media (max-width: 560px) {
  .reel__row { --cols: 2; }
}

/* --- BANNER: fondo en movimiento + título + piezas flotantes ---------------- */
.banner { padding: 0; min-height: clamp(34rem, 95vh, 62rem); overflow: hidden; display: grid; place-items: center; }
.banner__bg { position: absolute; inset: 0; background: #111; }
.banner__bg video, .banner__bg img { width: 100%; height: 100%; object-fit: cover; }
.banner__shade { position: absolute; inset: 0; background: rgba(0,0,0,.25); pointer-events: none; }
.banner__title { position: relative; z-index: 3; font-size: var(--fs-title); text-align: center; color: #fff; mix-blend-mode: normal; }
.banner__float {
  position: absolute; z-index: 2;
  left: calc(var(--x) * 1%); top: calc(var(--y) * 1%); width: calc(var(--w) * 1%);
}
@media (max-width: 760px) {
  .banner { min-height: 0; padding: 4rem var(--gutter); display: block; }
  .banner__bg { position: absolute; }
  .banner__title { margin: 0 0 2rem; }
  .banner__floats { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; position: relative; z-index: 2; }
  .banner__float { position: static; width: auto; }
}

/* --- MARQUEE: texto que corre en bucle -------------------------------------- */
.marquee { padding-block: clamp(.9rem, 2vw, 1.6rem); overflow: hidden; }
.marquee__track { display: flex; width: max-content; animation: marquee var(--speed, 40s) linear infinite; }
.marquee__group { display: flex; flex: none; }
.marquee__item {
  flex: none; padding-right: 1.6em; white-space: nowrap;
  font-size: clamp(1.1rem, 2.2vw, 2.1rem);
}
@keyframes marquee { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .marquee__track { animation: none; } }

/* --- SPLIT: texto + medios (1 o más, con leyendas) --------------------------- */
.split__grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1.5rem, 6vw, 7rem); align-items: center;
}
.split--media-right .split__media { order: 2; }
.split__media { display: flex; gap: clamp(.75rem, 3vw, 3rem); justify-content: center; align-items: flex-start; }
.split__media .tile { flex: 0 1 var(--tw, 100%); min-width: 0; }
.split__text { display: grid; gap: 1.25rem; align-content: center; }
.split__kicker { font-size: var(--fs-small); }
.split__title { font-size: var(--fs-subtitle); text-wrap: balance; }
@media (max-width: 860px) {
  .split__grid { grid-template-columns: 1fr; }
  .split--media-right .split__media { order: 0; }
}

/* --- CHAPTER: título grande con datos al costado ----------------------------- */
.chapter__grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem; align-items: start;
}
.chapter__title { font-size: var(--fs-title); text-wrap: balance; }
.chapter__meta { justify-self: end; text-align: left; font-size: var(--fs-small); padding-top: .75em; display: grid; gap: .6rem; }
@media (max-width: 760px) {
  .chapter__grid { grid-template-columns: 1fr; }
  .chapter__meta { justify-self: start; }
}

/* --- GALLERY: mosaico de piezas gráficas ------------------------------------- */
.gallery__grid { column-count: var(--cols, 3); column-gap: clamp(.75rem, 2vw, 2rem); margin-top: clamp(2rem, 5vw, 4.5rem); }
.gallery__grid .tile { break-inside: avoid; margin-bottom: clamp(.75rem, 2vw, 2rem); }
@media (max-width: 900px) { .gallery__grid { column-count: 2; } }
@media (max-width: 480px) { .gallery__grid { column-count: 1; } }
.gallery__intro { margin: 1.25rem auto 0; text-align: center; max-width: 52ch; }

/* --- CONTACT / FOOTER --------------------------------------------------------- */
.contact { text-align: center; }
.contact__text { margin: 1.5rem auto 0; text-align: center; }
.contact__mail {
  display: inline-block; margin-top: 2rem; font-size: var(--fs-subtitle);
  text-underline-offset: .15em; text-decoration-thickness: 1px;
}
.contact__links { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem 2rem; margin-top: 2rem; }
.foot { background: var(--ink); color: var(--ash); padding: 1.5rem var(--gutter) 2rem; font-size: var(--fs-small); text-align: center; }

/* --- VISOR (lightbox) --------------------------------------------------------- */
.lb {
  width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: rgba(0,0,0,0.3); color: #fff;
}
.lb::backdrop { background: #000000c0; }
.lb[open] { display: grid; grid-template-rows: 1fr auto; place-items: center; }
.lb__stage { width: 70%; height: 70%; min-height: 0; display: grid; place-items: center; padding: 3.5rem 4rem 0; }
.lb__stage img, .lb__stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb__cap { padding: .75rem 1rem 1.25rem; font-size: var(--fs-small); text-align: center; min-height: 2.5rem; }
.lb__btn {
  position: absolute; z-index: 2; width: 3rem; height: 3rem; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.12); font-size: 2rem; line-height: 1; cursor: pointer;
}
.lb__btn:hover { background: rgba(255,255,255,.26); }
.lb__close { top: 1rem; right: 1rem; }
.lb__prev, .lb__next { top: 50%; transform: translateY(-50%); }
.lb__prev { left: .75rem; } .lb__next { right: .75rem; }
.lb.is-single .lb__prev, .lb.is-single .lb__next { display: none; }
@media (max-width: 600px) { .lb__stage { padding: 4rem .5rem 0; } }
