/* =========================================================
   Elogio de la línea · Pau Jordà
   Estructura:
   1. Fuentes y variables
   2. Base y utilidades de accesibilidad
   3. Cabecera
   4. Inicio (rotulado y mosaico de iconos)
   5. Proyecto: modo vertical (por defecto, móvil, zoom, sin JS)
   6. Proyecto: modo horizontal (pantallas amplias, con JS)
   7. Movimiento: transiciones entre páginas y apariciones
   ========================================================= */

/* 1. Fuentes y variables ---------------------------------- */
@font-face {
  font-family: "Inter";
  src: url("/fuentes/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("/fuentes/inter-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter";
  src: url("/fuentes/inter-latin-wght-italic.woff2") format("woff2");
  font-weight: 100 900; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Open Sans";
  src: url("/fuentes/open-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 300 800; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Open Sans";
  src: url("/fuentes/open-sans-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 300 800; font-style: normal; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --tinta: #000;            /* texto: negro como el original */
  --tinta-marca: #24120d;   /* iconos y logo: el marrón de los dibujos de Pau */
  --sanguina: #5b1a22;      /* iconos: el sanguina de Johnny (contraste 13:1 sobre blanco) */
  --tinta-suave: #4a4a4a;   /* etiquetas secundarias (contraste 8.9:1 sobre blanco) */
  --papel: #fff;
  --foco: #0a4fd6;          /* anillo de foco: visible sobre blanco y sobre fotos (doble anillo) */

  --fuente-texto: "Inter", Helvetica, Arial, sans-serif;
  --fuente-titulo: "Open Sans", Helvetica, Arial, sans-serif;
  /* El original usa Inter ExtraLight (200). Subimos a 300 en cuerpo: casi igual a la vista y mucho más legible. */
  --peso-texto: 300;
  --peso-titulo: 300;

  --alto-cabecera: 73px;
  --margen: 1rem;
  --curva: cubic-bezier(.22, .61, .36, 1);
  --suave: cubic-bezier(.16, 1, .3, 1);   /* frena muy despacio al final: la curva "orgánica" de toda la web */
  color-scheme: light;
}

/* 2. Base ---------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--papel);
  color: var(--tinta);
  font-family: var(--fuente-texto);
  font-weight: var(--peso-texto);
  font-size: 1rem;
  line-height: 1.5;
  font-optical-sizing: auto;
}
img, svg { display: block; max-width: 100%; height: auto; }
picture { display: contents; }
figure { margin: 0; }
h1, h2, p, ul, ol { margin: 0; }
a { color: inherit; }
strong, b { font-weight: 500; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--foco);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px var(--papel);
  border-radius: 2px;
}
main:focus { outline: none; }

.visualmente-oculto {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}
.saltar {
  position: fixed; z-index: 100; left: 1rem; top: 1rem;
  padding: .75rem 1rem; background: var(--tinta); color: var(--papel);
  font-weight: 500; text-decoration: none;
  transform: translateY(-200%);
  transition: transform .2s var(--curva);
}
.saltar:focus-visible { transform: none; box-shadow: none; outline-color: var(--papel); outline-offset: -4px; }

/* 3. Cabecera -------------------------------------------- */
.cabecera {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: var(--alto-cabecera);
  padding: .5rem var(--margen);
  background: var(--papel);
  view-transition-name: cabecera;
}
.logo { display: block; padding: .25rem; margin-left: -.25rem; }
.logo img { width: 120px; height: auto; }
.redes ul { display: flex; gap: 0; list-style: none; padding: 0; }
.redes a {
  display: grid; place-items: center;
  width: 44px; height: 44px;  /* objetivo táctil cómodo, icono de 36 */
  color: var(--sanguina);
  border-radius: 8px;
  transition: transform .8s var(--suave);
}
.redes a:hover { transform: translateY(-2px); }
.redes svg { width: 32px; height: 32px; }
@media (min-width: 48em) {
  .cabecera { padding-inline: 36px; }
  .redes svg { width: 36px; height: 36px; }
}

/* 4. Inicio --------------------------------------------- */
.rotulo { margin: 1rem auto 2.5rem; width: min(80vw, 30rem); }
.rotulo img { width: 100%; }

.mosaico { list-style: none; padding: 0 var(--margen) 4rem; display: grid; gap: 1.5rem; justify-items: center; }
.mosaico a {
  display: grid; justify-items: center; gap: .5rem;
  text-decoration: none; padding: .5rem;
  border-radius: 4px;
}
.mosaico .icono { display: block; width: min(50vw, 13rem); }
.mosaico .icono img { width: 100%; mix-blend-mode: multiply; } /* los JPG tienen fondo casi blanco: así desaparece la caja */
.etiqueta {
  font-size: .875rem; letter-spacing: .02em; color: var(--tinta-suave);
}

@media (min-width: 60em) {
  /* Mosaico disperso del original: posiciones en un lienzo de 1440 px que escala con la ventana */
  .inicio { position: relative; height: calc(1000 / 1440 * 100vw); }
  .inicio .pelicula {
    position: absolute; margin: 0; max-width: none;
    left: calc(var(--x) / 1440 * 100vw);
    top: calc((var(--y) - 73) / 1440 * 100vw);
    width: calc(var(--w) / 1440 * 100vw);
  }
  .inicio .controles { position: absolute; right: -8px; bottom: -6px; margin: 0; }
  .rotulo {
    position: absolute; margin: 0;
    left: calc(var(--x) / 1440 * 100vw);
    top: calc((var(--y) - 73) / 1440 * 100vw);
    width: calc(var(--w) / 1440 * 100vw);
  }
  .mosaico { display: block; padding: 0; }
  .mosaico li {
    position: absolute;
    left: calc(var(--x) / 1440 * 100vw);
    top: calc((var(--y) - 73) / 1440 * 100vw);
    width: calc(var(--w) / 1440 * 100vw);
  }
  .mosaico a { display: block; padding: 0; position: relative; }
  .mosaico .icono { width: 100%; transition: transform 1.2s var(--suave), filter 1.2s var(--suave); }
  .etiqueta {
    position: absolute; left: 50%; top: 100%;
    translate: -50% 0;
    white-space: nowrap;
    opacity: 0; transform: translateY(-6px);
    transition: opacity .9s var(--suave), transform 1.2s var(--suave);
  }
  .mosaico a:hover .icono, .mosaico a:focus-visible .icono { transform: scale(1.04) rotate(-.6deg); }
  /* al pasar por un dibujo, los demás se retiran un poco */
  .mosaico:has(a:hover) a:not(:hover) .icono { opacity: .45; filter: blur(.4px); }
  .mosaico .icono { opacity: 1; transition: transform 1.2s var(--suave), opacity .9s var(--suave), filter .9s var(--suave); }
  .mosaico a:hover .etiqueta, .mosaico a:focus-visible .etiqueta { opacity: 1; transform: none; }
}
/* En móvil y tableta no se ve el nombre bajo cada dibujo, como en el original;
   sigue ahí para lectores de pantalla (es el nombre del enlace). */
@media (max-width: 59.99em) {
  .etiqueta {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  .mosaico a { gap: 0; position: relative; }
}

/* Pie de la home: firma de Accesibilidad Primero, pequeña y centrada */
.pie { display: flex; justify-content: center; padding: 2rem var(--margen) 2.5rem; }
.pie-ap {
  display: block; width: 180px; padding: .5rem;
  color: var(--tinta-marca); opacity: .7;
  transition: opacity .8s var(--suave), transform .9s var(--suave);
}
.pie-ap svg { width: 100%; height: auto; display: block; }
.pie-ap:hover, .pie-ap:focus-visible { opacity: 1; transform: translateY(-2px); }

/* 5. Proyecto: modo vertical ----------------------------- */
.ventana { padding: 0 var(--margen) 3rem; }
.tira { display: flex; flex-direction: column; gap: 2.5rem; max-width: 46rem; margin: 0 auto; }

.pieza { margin: 0; }
.portada { order: 0; }
.portada img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.titulo {
  font-family: var(--fuente-titulo); font-weight: var(--peso-titulo);
  font-size: clamp(2rem, 7vw, 2.625rem); line-height: 1.2;
  letter-spacing: -.005em;
}
.titulo br { display: none; }       /* en móvil el título va en una línea, como en el original */
.texto { max-width: 38rem; }
.texto > * + * { margin-top: 1em; }
.texto h2 {
  font-family: var(--fuente-texto); font-size: 1rem; font-weight: 500;
  letter-spacing: .04em; margin-top: 1.5em;
}
.texto h2:first-child { margin-top: 0; }
.texto ol, .texto ul { padding-left: 1.25em; }
.texto li + li { margin-top: .5em; }
.imagen img { width: 100%; }

/* Animaciones (antes GIF): fotogramas superpuestos con fundido */
.animacion { position: relative; }
.fotogramas { display: grid; }
.fotograma { grid-area: 1 / 1; opacity: 0; transition: opacity .8s var(--curva); }
.fotograma.activo { opacity: 1; }
/* Botones dibujados a mano (iconos generados con scripts/iconos-a-mano.py) */
.boton-dibujado {
  display: grid; place-items: center;
  width: 44px; height: 44px; padding: 0;
  border: 0; background: none; color: var(--sanguina); cursor: pointer;
  border-radius: 50%;
  transition: transform .9s var(--suave), opacity .6s var(--suave);
}
.boton-dibujado svg { width: 36px; height: 36px; }
.boton-dibujado:hover { transform: rotate(-4deg) scale(1.06); }
.boton-dibujado:active { transform: scale(.94); transition-duration: .15s; }
.boton-dibujado .i-off { display: none; }
.boton-dibujado.apagado .i-on { display: none; }
.boton-dibujado.apagado .i-off { display: block; }
.boton-dibujado > span { display: block; }

.pausa {
  position: absolute; right: .25rem; bottom: .25rem;
  background: rgb(255 255 255 / .85);
  opacity: .5;
}
.pausa:hover, .pausa:focus-visible, .animacion:hover .pausa { opacity: 1; }

/* Película de la home */
.pelicula { margin: 0 auto 2rem; max-width: 40rem; }
.pelicula-video { display: block; width: 100%; height: auto; mix-blend-mode: multiply; background: var(--papel); }
.controles { display: flex; justify-content: center; gap: .25rem; margin-top: -.5rem; }
.controles .boton-dibujado { opacity: .8; }  /* .8 mantiene más de 3:1 de contraste */
.controles .boton-dibujado:hover, .controles .boton-dibujado:focus-visible { opacity: 1; }

/* Navegación final */
.final ul { list-style: none; padding: 0; display: grid; gap: .75rem; justify-items: end; font-size: .9375rem; }
.final a { text-decoration: none; display: inline-flex; align-items: center; gap: .5rem; min-height: 44px; }
.final a:hover { text-decoration: underline; text-underline-offset: .2em; text-decoration-thickness: 1px; }
.final .flecha { display: inline-block; color: var(--tinta-marca); transition: transform .9s var(--suave); }
.final .flecha svg { width: 26px; height: 20px; }
.final a[rel="next"]:hover .flecha { transform: translateX(4px); }
.final a[rel="prev"]:hover .flecha { transform: translateX(-4px); }
.volver img { width: 35px; height: auto; }
.volver span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.linea-progreso { display: none; }

/* 6. Proyecto: modo horizontal --------------------------
   Lo activa main.js solo si hay espacio de sobra (ancho ≥ 1024 px CSS y alto ≥ 600).
   Con zoom al 200 % o en ventanas pequeñas se vuelve al modo vertical (WCAG 1.4.10). */
.horizontal .proyecto {
  /* Escalas del lienzo original (1440 × alto): en horizontal como el ancho de la ventana, en vertical como el alto disponible.
     Igual que en el original, las piezas se ensanchan con la ventana y las alturas se ajustan a la pantalla. */
  --uy: calc((100vh - var(--alto-cabecera) - 24px) / var(--alto));
  --ux: min(calc(100vw / 1440), calc(var(--uy) * 1.5));
  position: relative;
  height: var(--recorrido, 100vh);   /* lo calcula main.js: ancho de la tira − ventana + alto */
}
.horizontal .ventana {
  position: sticky; top: var(--alto-cabecera);
  height: calc(100vh - var(--alto-cabecera));
  overflow: hidden; padding: 0;
}
.horizontal .tira {
  display: block; position: relative; max-width: none; margin: 0;
  width: calc(var(--ancho) * var(--ux));
  height: calc(var(--alto) * var(--uy));
  transform: translate3d(calc(var(--avance, 0) * -1px), 0, 0);
  will-change: transform;
}
.horizontal .pieza {
  position: absolute;
  left: calc(var(--x) * var(--ux));
  top: calc(var(--y) * var(--uy));
  width: calc(var(--w) * var(--ux));
}
.horizontal .portada, .horizontal .imagen { height: calc(var(--h) * var(--uy)); }
.horizontal .portada img, .horizontal .imagen img { width: 100%; height: 100%; aspect-ratio: auto; }
.horizontal .encaje-cover img { object-fit: cover; }
.horizontal .encaje-contain img { object-fit: contain; }
.horizontal .animacion .fotogramas, .horizontal .animacion .fotograma { height: 100%; }
.horizontal .titulo { font-size: max(1.5rem, calc(var(--tam-titulo) * min(var(--ux), var(--uy)))); line-height: 1.3; }
.horizontal .titulo br { display: inline; }
.horizontal .texto { max-width: none; font-size: clamp(.9375rem, calc(16 * var(--uy)), 1rem); }
/* Los textos que en el original están pegados abajo crecen hacia arriba: así nunca se cortan por el borde inferior */
.horizontal .texto.ancla-abajo { top: auto; bottom: calc(var(--b) * var(--uy)); }
.horizontal .final { top: auto; bottom: 0; }

.horizontal .linea-progreso {
  display: block; position: fixed; left: 0; right: 0; bottom: 0; height: 1px; z-index: 5;
  pointer-events: none;
}
.horizontal .linea-progreso span {
  display: block; height: 100%; background: var(--tinta);
  transform-origin: 0 50%; transform: scaleX(var(--progreso, 0));
}

/* 7. Movimiento ----------------------------------------- */
@view-transition { navigation: auto; }

/* Cambio de página: la de salida se desvanece y se desenfoca, la nueva aparece enfocándose */
::view-transition-old(root) { animation: .6s var(--suave) both salir; }
::view-transition-new(root) { animation: .9s var(--suave) .1s both llegar; }
@keyframes salir { to { opacity: 0; filter: blur(4px); } }
@keyframes llegar { from { opacity: 0; filter: blur(4px); } }
::view-transition-group(heroe) { animation-duration: 1.1s; animation-timing-function: var(--suave); }
::view-transition-old(heroe), ::view-transition-new(heroe) { height: 100%; object-fit: cover; }
::view-transition-group(cabecera) { animation: none; }

/* Aparición suave de las piezas al entrar en pantalla */
.js .revelar { opacity: 0; transform: translateY(14px); transition: opacity .9s var(--curva), transform .9s var(--curva); }
/* En la tira horizontal las piezas entran desde la derecha, como si la web se fuera dibujando al avanzar.
   Entrada orgánica: poco recorrido, curva muy suave al final y un leve desenfoque que se aclara.
   La opacidad va más rápida que el movimiento, así la pieza ya se lee mientras termina de asentarse.
   (.js y .horizontal están las dos en <html>, por eso van juntas sin espacio) */
.js.horizontal .revelar {
  transform: translateX(32px);
  filter: blur(3px);
  transition:
    opacity 1.4s var(--suave),
    transform 2s var(--suave),
    filter 1.2s var(--suave);
}
/* En los textos, cada párrafo llega un instante después del anterior */
.js.horizontal .texto.revelar { transform: none; filter: none; opacity: 1; }
.js.horizontal .texto.revelar > * {
  opacity: 0; transform: translateX(24px); filter: blur(2px);
  transition:
    opacity 1.4s var(--suave),
    transform 2s var(--suave),
    filter 1.2s var(--suave);
  transition-delay: calc(var(--orden, 0) * 110ms + 150ms);
}
.js.horizontal .texto.revelar.visible > * { opacity: 1; transform: none; filter: none; }
.js.horizontal .revelar.visible { filter: none; }
.js .revelar.visible { opacity: 1; transform: none; }

/* Inicio: los iconos aparecen uno tras otro */
.js .mosaico li { animation: entrar 1.6s var(--suave) both; animation-delay: calc(var(--i) * 90ms + 300ms); }
.js .pelicula { animation: entrar 2s var(--suave) both; }
@keyframes entrar { from { opacity: 0; transform: translateY(8px); filter: blur(3px); } }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .revelar, .js.horizontal .revelar, .js.horizontal .texto.revelar > * { opacity: 1; transform: none; filter: none; }
}

/* Página 404 */
.no-encontrada { max-width: 36rem; margin: 18vh auto 4rem; padding-inline: 16px; text-align: center; }
.no-encontrada h1 { font-weight: 300; font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 1rem; }
.no-encontrada a { color: var(--sanguina); text-underline-offset: .2em; }
