@font-face {
  font-family: "Bricolage";
  src: url("../fonts/bricolage-grotesque-latin-opsz-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --papel: #dfe4e7;
  --tinta: #13151b;

  --prusia: #0d2c54;
  --bermellon: #e8501f;
  --ocre: #d6a02f;
  --viridian: #103a31;

  --margen: clamp(1.1rem, 3.2vw, 3rem);
  --orilla: clamp(3.5rem, 13vw, 12rem);
  --salida: cubic-bezier(0.16, 1, 0.3, 1);
  --cabecera: var(--tinta);
  --cabecera-fondo: var(--papel);
  --cabecera-acento: var(--bermellon);
  --cabecera-acento-letra: #160804;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html.lenis,
html.lenis body {
  height: auto;
}

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

body {
  margin: 0;
  background: var(--papel);
  color: var(--tinta);
  font-family: "Bricolage", ui-sans-serif, system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.45;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

img,
svg,
canvas {
  display: block;
}

img {
  max-width: 100%;
  height: auto;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
}

/* ───────── Cabecera ───────── */

.cabecera {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: clamp(0.85rem, 1.5vw, 1.35rem) var(--margen);
  color: var(--cabecera);
  transition: color 0.5s var(--salida), transform 0.8s var(--salida);
  pointer-events: none;
}

/* Sobre los campos la cabecera se retira al bajar, para no tapar las obras */
.cabecera.oculta {
  transform: translateY(-115%);
}

.cabecera a {
  pointer-events: auto;
}

/* la firma y cada palabra del menu toman el color del campo que tienen debajo */
.cabecera .firma,
.indice li {
  color: var(--cabecera);
  transition: color 0.5s var(--salida);
}

.firma {
  display: block;
  width: clamp(6.25rem, 8.6vw, 8.75rem);
}

.firma svg {
  width: 100%;
  height: auto;
}

.indice {
  display: flex;
  align-items: center;
  gap: clamp(0.1rem, 0.6vw, 0.7rem);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Cada palabra del menu se posa sobre una aguada: una mancha de acuarela con la misma orilla que
   separa los campos. Aparece al pasar el puntero y se queda en la seccion donde uno esta. */
.indice a {
  position: relative;
  display: block;
  padding: 0.72em 0.9em 0.8em;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  isolation: isolate;
  transition: color 0.45s var(--salida);
}

.indice a::before,
.indice a::after {
  content: "";
  position: absolute;
  inset: -0.3em -0.15em;
  z-index: -1;
  -webkit-mask: var(--m) center / 100% 100% no-repeat;
  mask: var(--m) center / 100% 100% no-repeat;
  opacity: 0;
  scale: 0.8;
  transition: opacity 0.4s ease, scale 0.7s var(--salida), background-color 0.5s var(--salida);
  pointer-events: none;
}

/* el pigmento, con el mismo lavado de los campos */
.indice a::before {
  background: url("../img/lavado.webp") 40% 30% / 20rem auto, var(--cabecera);
  background-blend-mode: soft-light;
}

/* la linea de pigmento que se junta en la orilla */
.indice a::after {
  background: #000;
  -webkit-mask-image: var(--o);
  mask-image: var(--o);
}

.indice li:nth-child(1) a { --m: url("../img/aguada-nav-1.webp"); --o: url("../img/aguada-nav-1-orla.webp"); }
.indice li:nth-child(2) a { --m: url("../img/aguada-nav-2.webp"); --o: url("../img/aguada-nav-2-orla.webp"); }
.indice li:nth-child(3) a { --m: url("../img/aguada-nav-3.webp"); --o: url("../img/aguada-nav-3-orla.webp"); }
.indice li:nth-child(4) a { --m: url("../img/aguada-nav-4.webp"); --o: url("../img/aguada-nav-4-orla.webp"); }

@media (hover: hover) {
  .indice a:hover {
    color: var(--cabecera-fondo);
  }

  .indice a:hover::before {
    opacity: 1;
    scale: 1;
  }

  .indice a:hover::after {
    opacity: 0.2;
    scale: 1;
  }
}

.indice a:focus-visible,
.indice a[aria-current="true"] {
  color: var(--cabecera-fondo);
}

.indice a:focus-visible::before,
.indice a[aria-current="true"]::before {
  opacity: 1;
  scale: 1;
}

.indice a:focus-visible::after,
.indice a[aria-current="true"]::after {
  opacity: 0.2;
  scale: 1;
}

/* Encargos es la accion: su aguada esta siempre, en el color de acento del campo */
.indice__fijo {
  display: grid;
  justify-items: end;
  align-items: center;
  margin-left: clamp(0.35rem, 0.9vw, 1rem);
}

.indice .indice__fijo a {
  grid-area: 1 / 1;
  padding: 0.72em 1.25em 0.8em;
  color: var(--cabecera-acento-letra);
  font-weight: 800;
  letter-spacing: -0.02em;
  --m: url("../img/aguada-chip.webp");
  --o: url("../img/aguada-chip-orla.webp");
  transition: color 0.5s var(--salida), opacity 0.45s ease, translate 0.6s var(--salida), visibility 0s linear 0s;
}

.indice .indice__fijo a::before,
.indice .indice__fijo a::after {
  inset: -0.34em -0.3em;
  opacity: 1;
  scale: 1;
}

.indice .indice__fijo a::before {
  background: url("../img/lavado.webp") 40% 30% / 20rem auto, var(--cabecera-acento);
  background-blend-mode: soft-light;
}

.indice .indice__fijo a::after {
  opacity: 0.22;
}

@media (hover: hover) {
  .indice .indice__fijo a:hover::before,
  .indice .indice__fijo a:hover::after {
    scale: 1.06 1.12;
  }
}

.indice .indice__fijo a:focus-visible::before,
.indice .indice__fijo a:focus-visible::after {
  scale: 1.06 1.12;
}

/* En el cierre la palabra se releva por una flecha sobre una gota de la misma aguada: volver arriba */
.indice .indice__fijo .indice__volver {
  padding: 0.7em 0.75em 0.78em;
  --m: url("../img/aguada-gota.webp");
  --o: url("../img/aguada-gota-orla.webp");
}

.indice__fijo .indice__volver svg {
  display: block;
  width: 1.3em;
  height: 1.3em;
}

.indice .indice__fijo .indice__volver,
[data-tramo="encargos"] .indice .indice__fijo .indice__ir {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: color 0.5s var(--salida), opacity 0.35s ease, translate 0.6s var(--salida), visibility 0s linear 0.45s;
}

.indice .indice__fijo .indice__volver {
  translate: 0 0.7rem;
}

[data-tramo="encargos"] .indice .indice__fijo .indice__ir {
  translate: 0 -0.7rem;
}

[data-tramo="encargos"] .indice .indice__fijo .indice__volver {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  translate: 0 0;
  transition: color 0.5s var(--salida), opacity 0.45s ease 0.12s, translate 0.6s var(--salida) 0.12s, visibility 0s linear 0s;
}

@media (max-width: 46rem) {
  .indice li:not(.indice__fijo) {
    display: none;
  }
}

/* ───────── Pintura húmeda (portada y cierre) ───────── */

.humeda {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--papel);
}

.humeda img,
.humeda canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.humeda img {
  object-fit: cover;
  object-position: var(--fx, 50%) var(--fy, 50%);
}

.humeda canvas {
  opacity: 0;
  touch-action: pan-y;
  transition: opacity 0.5s linear;
}

.humeda.viva canvas {
  opacity: 1;
}

/* Con WebGL la pintura florece en el lienzo; la imagen queda debajo para lectores y como respaldo */
.js .humeda:not(.plana) img {
  opacity: 0;
}

.humeda.plana img {
  opacity: 1;
  transition: opacity 0.9s linear;
}

/* ───────── Portada ───────── */

.portada {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 100svh;
  min-height: 32rem;
  overflow: hidden;
  --fx: 50%;
  --fy: 30%;
}

@media (max-aspect-ratio: 3/4) {
  .portada {
    --fx: 18%;
    --fy: 50%;
  }
}

.portada__nombre {
  position: absolute;
  z-index: 2;
  left: var(--margen);
  top: clamp(4.6rem, 12svh, 8.5rem);
  margin: 0;
  font-size: clamp(2.9rem, 5.4vw, 5.75rem);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.035em;
  pointer-events: none;
}

.portada__nombre span {
  display: block;
}

@media (min-aspect-ratio: 3/4) {
  .portada__nombre span {
    display: inline;
  }
}

/* Oficio y lugar: abajo a la izquierda, como el credito de un afiche */
.portada__oficio,
.portada__ficha {
  position: absolute;
  z-index: 2;
  bottom: calc(var(--orilla) * 0.74 + 0.9rem);
  margin: 0;
  font-size: clamp(1.0625rem, 1.35vw, 1.375rem);
  font-weight: 500;
  line-height: 1.2;
  pointer-events: none;
}

.portada__oficio {
  left: var(--margen);
  color: #fff;
  mix-blend-mode: difference;
}

.portada__ficha {
  right: var(--margen);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

/* En vertical el oficio descansa sobre el ala oscura de la Loica, donde se lee entero */
@media (max-aspect-ratio: 3/4) {
  .portada__oficio {
    bottom: 19svh;
    color: #eef1f3;
    mix-blend-mode: normal;
  }
}

.portada__gesto {
  font-size: 0.9375rem;
  font-weight: 600;
  transition: opacity 0.8s var(--salida);
}

.portada__gesto.fuera {
  opacity: 0;
}

/* ───────── Campos de pigmento ───────── */

.campo {
  position: relative;
  z-index: 2;
  padding: clamp(4.5rem, 13vh, 10rem) var(--margen) clamp(6rem, 17vh, 13rem);
  background: var(--bg);
  color: var(--fg);
}

.campo::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../img/lavado.webp") 0 0 / 68rem auto;
  mix-blend-mode: soft-light;
  opacity: 0.62;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 22rem);
  mask-image: linear-gradient(to bottom, transparent 0, #000 22rem);
}

.campo > * {
  position: relative;
}

.campo--acuarela {
  --bg: var(--prusia);
  --fg: #eef2f4;
  --fg2: #c3d0de;
}

.campo--koi {
  --bg: var(--bermellon);
  --fg: #160804;
  --fg2: #160804;
}

.campo--nouveau {
  --bg: var(--ocre);
  --fg: #1c1406;
  --fg2: #3d2f0d;
}

.campo--oleo {
  --bg: var(--viridian);
  --fg: #eef3ee;
  --fg2: #b9cdc3;
}

/* Borde de aguada: la orilla del lavado entra sobre lo anterior, con su linea de pigmento acumulado */
.campo > .borde {
  position: absolute;
  inset: auto 0 calc(100% - 1px) 0;
  height: var(--orilla);
  background: var(--bg);
  pointer-events: none;
}

.campo > .borde,
.campo > .borde::after {
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

.campo > .borde::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0.32;
}

.campo--acuarela > .borde { -webkit-mask-image: url("../img/borde-1.webp"); mask-image: url("../img/borde-1.webp"); }
.campo--acuarela > .borde::after { -webkit-mask-image: url("../img/borde-1-orla.webp"); mask-image: url("../img/borde-1-orla.webp"); }
.campo--koi > .borde { -webkit-mask-image: url("../img/borde-2.webp"); mask-image: url("../img/borde-2.webp"); }
.campo--koi > .borde::after { -webkit-mask-image: url("../img/borde-2-orla.webp"); mask-image: url("../img/borde-2-orla.webp"); }
.campo--nouveau > .borde { -webkit-mask-image: url("../img/borde-3.webp"); mask-image: url("../img/borde-3.webp"); }
.campo--nouveau > .borde::after { -webkit-mask-image: url("../img/borde-3-orla.webp"); mask-image: url("../img/borde-3-orla.webp"); }
.campo--oleo > .borde { -webkit-mask-image: url("../img/borde-4.webp"); mask-image: url("../img/borde-4.webp"); }
.campo--oleo > .borde::after { -webkit-mask-image: url("../img/borde-4-orla.webp"); mask-image: url("../img/borde-4-orla.webp"); }

.campo__titulo {
  margin: 0 0 clamp(3rem, 11vh, 8rem) -0.045em;
  font-size: clamp(4.25rem, 20.5vw, 21rem);
  font-weight: var(--peso, 800);
  line-height: 0.8;
  /* al cargarse el peso, las letras se abren lo justo para no fundirse */
  letter-spacing: calc(-0.04em + (var(--peso, 800) - 220) * 0.00006em);
  white-space: nowrap;
}

/* ───────── Pliegos ───────── */

.pliegos {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: clamp(1rem, 2vw, 2rem);
  row-gap: clamp(4rem, 13vh, 9.5rem);
  align-items: start;
}

.obra {
  grid-column: var(--col, 1 / -1);
  margin: var(--baja, 0) 0 0;
  min-width: 0;
}

.obra__abrir {
  position: relative;
  display: block;
  width: 100%;
  background: var(--tono, #cfd4d9);
  box-shadow: 0 1.6rem 2.6rem -1.4rem rgb(0 0 0 / 0.55), 0 0.25rem 0.6rem -0.1rem rgb(0 0 0 / 0.22);
  transform: translate3d(0, calc(var(--v, 0) * var(--k, 16) * 0.5px), 0) rotate(calc(var(--v, 0) * var(--r, 0.7) * 0.45deg));
  transition: box-shadow 0.8s var(--salida), opacity 0.4s linear;
}

.obra__abrir img {
  width: 100%;
  aspect-ratio: var(--ar);
  object-fit: cover;
}

.obra__abrir canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

@media (hover: hover) and (pointer: fine) {
  .obra__abrir {
    cursor: none;
  }

  .obra__abrir:hover {
    box-shadow: 0 2.2rem 3.2rem -1.6rem rgb(0 0 0 / 0.58), 0 0.35rem 0.8rem -0.1rem rgb(0 0 0 / 0.24);
  }

  /* el lavado del campo se desplaza apenas con el scroll, como pigmento bajo los pliegos */
  .campo::before {
    inset: -3rem 0;
    transform: translate3d(0, calc(var(--v, 0) * -1.8rem), 0);
  }
}

/* Antes de levantarse del baño: invisible. Sin JS, siempre visible. */
.js .obra:not(.vista) .obra__abrir {
  background: transparent;
  box-shadow: none;
}

.js .obra:not(.vista) .obra__abrir img {
  opacity: 0;
}

.js .obra:not(.vista) figcaption {
  opacity: 0;
  transform: translateY(0.6rem);
}

.obra figcaption {
  margin-top: 0.95rem;
  transition: opacity 0.9s var(--salida) 0.35s, transform 0.9s var(--salida) 0.35s;
}

.obra__titulo {
  font-size: clamp(1.0625rem, 1.3vw, 1.375rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

/* Ritmo de la grilla de acuarelas: pares desfasados que se repiten cada seis */
@media (min-width: 56rem) {
  .campo--acuarela .obra:nth-child(6n + 1) { --col: 1 / span 5; --k: 22; --r: -0.9; }
  .campo--acuarela .obra:nth-child(6n + 2) { --col: 8 / span 4; --baja: 20vh; --k: 10; --r: 0.6; }
  .campo--acuarela .obra:nth-child(6n + 3) { --col: 3 / span 4; --k: 14; --r: 0.8; }
  .campo--acuarela .obra:nth-child(6n + 4) { --col: 8 / span 5; --baja: 12vh; --k: 24; --r: -0.5; }
  .campo--acuarela .obra:nth-child(6n + 5) { --col: 1 / span 4; --k: 12; --r: 0.5; }
  .campo--acuarela .obra:nth-child(6n + 6) { --col: 6 / span 5; --baja: 16vh; --k: 20; --r: -0.8; }
  .campo--acuarela .obra.obra--ancha { --col: 5 / span 8; --baja: 0; }
  .campo--acuarela .obra.obra--calle { --col: 1 / span 5; }

  .campo--acuarela .pliegos { padding-inline: clamp(0rem, 4.5vw, 5.5rem); }

  .campo--nouveau .obra:nth-child(1) { --col: 2 / span 4; --k: 20; --r: -0.7; }
  .campo--nouveau .obra:nth-child(2) { --col: 7 / span 4; --baja: 18vh; --k: 10; --r: 0.6; }

  .campo--oleo .obra { --k: 14; --r: 0.4; }
  .campo--oleo .obra:nth-child(1) { --col: 1 / span 7; }
  .campo--oleo .obra:nth-child(2) { --col: 4 / span 9; }
  .campo--oleo .obra:nth-child(3) { --col: 1 / span 4; --baja: 10vh; }
  .campo--oleo .obra:nth-child(4) { --col: 6 / span 3; }
  .campo--oleo .obra:nth-child(5) { --col: 9 / span 4; --baja: 16vh; }
  .campo--oleo .obra:nth-child(6) { --col: 2 / span 4; --baja: 8vh; }
  .campo--oleo .obra:nth-child(7) { --col: 6 / span 7; }
  .campo--oleo .obra:nth-child(8) { --col: 1 / span 5; }
  .campo--oleo .obra:nth-child(9) { --col: 1 / -1; }
}

@media (min-width: 36rem) and (max-width: 55.99rem) {
  .pliegos {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 4rem;
  }

  .obra { --col: auto; }
  .obra:nth-child(even) { --baja: 5rem; }
  .obra.obra--ancha,
  .campo--oleo .obra:nth-child(2),
  .campo--oleo .obra:nth-child(7),
  .campo--oleo .obra:nth-child(9) { --col: 1 / -1; --baja: 0; }
}

@media (max-width: 35.99rem) {
  .pliegos {
    row-gap: 3.5rem;
  }

  .pliegos .obra:nth-child(3n + 2) { width: 84%; }
  .pliegos .obra:nth-child(3n + 3) { width: 84%; margin-left: 16%; }
  .campo--acuarela .pliegos .obra:nth-child(3n + 1) { width: 88%; }
  .campo--acuarela .pliegos .obra:nth-child(3n + 2) { width: 72%; margin-left: 28%; }
  .campo--acuarela .pliegos .obra:nth-child(3n + 3) { width: 72%; margin-left: 0; }
  .pliegos .obra.obra--ancha,
  .campo--oleo .obra:nth-child(2),
  .campo--oleo .obra:nth-child(7),
  .campo--oleo .obra:nth-child(9) { width: 100%; margin-left: 0; }
  .campo--acuarela .pliegos .obra.obra--ancha { width: 100%; margin-left: 0; }
}

/* ───────── Koi: cinta sin fin ───────── */

.campo--koi {
  padding-inline: 0;
}

.campo--koi .campo__titulo {
  margin-inline: calc(var(--margen) - 0.045em) var(--margen);
}

/* Sin JS (o con menos movimiento) es una fila que se desliza con el dedo */
.carrusel {
  overflow-x: auto;
  overflow-y: hidden;
  padding-block: 0.5rem 3.5rem;
  scrollbar-width: none;
  touch-action: pan-x pan-y;
}

.carrusel::-webkit-scrollbar {
  display: none;
}

.carrusel__pista {
  display: flex;
  align-items: flex-start;
  gap: clamp(1.25rem, 3.5vw, 3.5rem);
  width: max-content;
  padding-inline: var(--margen);
}

.carrusel .obra {
  flex: none;
  width: clamp(15rem, 62vw, 27rem);
  grid-column: auto;
  --k: 10;
}

.carrusel .obra:nth-child(even) {
  margin-top: clamp(1.5rem, 5vw, 4rem);
  --r: -0.6;
}

/* Con JS: la cinta avanza sola, no tiene fin y se arrastra */
.carrusel--vivo {
  overflow: clip visible;
  touch-action: pan-y;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.carrusel--vivo .carrusel__pista {
  padding-inline: 0;
  will-change: transform;
}

.carrusel--vivo .obra__abrir img {
  -webkit-user-drag: none;
  pointer-events: none;
}

.carrusel--arrastre {
  cursor: grabbing;
}

.carrusel--arrastre .obra__abrir {
  cursor: grabbing;
}

/* ───────── Cierre ───────── */

.cierre {
  position: relative;
  z-index: 2;
  margin-top: calc(var(--orilla) * -1);
  color: var(--tinta);
  --fx: 30%;
  --fy: 55%;
}

.cierre__escena {
  position: relative;
}

/* la Garza Cuca entra sobre el campo con su propia orilla de aguada */
.cierre__lienzo {
  position: relative;
  height: calc(100svh + var(--orilla));
  min-height: 36rem;
  -webkit-mask: url("../img/borde-5.webp") top / 100% var(--orilla) no-repeat,
    linear-gradient(#000, #000) bottom / 100% calc(100% - var(--orilla) + 1px) no-repeat;
  mask: url("../img/borde-5.webp") top / 100% var(--orilla) no-repeat,
    linear-gradient(#000, #000) bottom / 100% calc(100% - var(--orilla) + 1px) no-repeat;
}

.cierre__texto {
  position: absolute;
  z-index: 2;
  right: var(--margen);
  top: calc(46% + var(--orilla) * 0.5);
  width: min(31vw, 27rem);
  transform: translateY(-50%);
}

.cierre__titulo {
  margin: 0 0 1.1rem -0.04em;
  font-size: clamp(3.25rem, 6.4vw, 6rem);
  font-weight: 800;
  line-height: 0.88;
  letter-spacing: -0.03em;
}

.cierre__texto p {
  margin: 0 0 1.6rem;
  max-width: 24ch;
  font-size: clamp(1.0625rem, 1.3vw, 1.3125rem);
  line-height: 1.35;
}

/* La accion va sobre una aguada del bermellon de la Loica: la misma mancha del menu, mas grande */
.enlace {
  position: relative;
  display: inline-block;
  margin: 0.35em 0 0 0.3em;
  padding: 0.8em 1.2em 0.9em;
  color: #160804;
  font-size: clamp(1.2rem, 5.5vw, 1.35rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.025em;
  text-decoration: none;
  white-space: nowrap;
  isolation: isolate;
}

@media (min-width: 56rem) {
  .enlace {
    padding-inline: 1.5em;
    font-size: clamp(1.5rem, 1.9vw, 1.75rem);
  }
}

.enlace::before,
.enlace::after {
  content: "";
  position: absolute;
  inset: -0.34em -0.3em;
  z-index: -1;
  -webkit-mask: url("../img/aguada-accion.webp") center / 100% 100% no-repeat;
  mask: url("../img/aguada-accion.webp") center / 100% 100% no-repeat;
  transition: scale 0.7s var(--salida);
  pointer-events: none;
}

.enlace::before {
  background: url("../img/lavado.webp") 40% 30% / 20rem auto, var(--bermellon);
  background-blend-mode: soft-light;
}

.enlace::after {
  background: #000;
  opacity: 0.22;
  -webkit-mask-image: url("../img/aguada-accion-orla.webp");
  mask-image: url("../img/aguada-accion-orla.webp");
}

@media (hover: hover) {
  .enlace:hover::before,
  .enlace:hover::after {
    scale: 1.05 1.1;
  }
}

.enlace:focus-visible::before,
.enlace:focus-visible::after {
  scale: 1.05 1.1;
}

/* El pie vive sobre la misma pintura: firma y creditos abajo a la derecha, en el papel vacio de la garza */
.pie {
  position: absolute;
  z-index: 2;
  right: var(--margen);
  bottom: clamp(1.25rem, 2.6vw, 2.25rem);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.9rem;
  font-size: 0.875rem;
  text-align: right;
}

.pie .firma {
  width: clamp(8.5rem, 13vw, 12.5rem);
}

.pie p {
  margin: 0;
}

.pie__credito {
  display: inline-block;
  margin-top: 0.35rem;
}

.pie__credito a {
  font-weight: 700;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
}

/* En vertical la pintura va entera arriba y el texto debajo, sobre el mismo papel de la garza:
   su tono y su grano, y la pintura se deshace en el con una orilla de aguada (su firma queda entera) */
@media (max-aspect-ratio: 1/1) {
  .cierre::before {
    content: "";
    position: absolute;
    inset: var(--orilla) 0 0 0;
    z-index: -1;
    /* el mismo tono que trae el papel en el borde inferior de la pintura, columna por columna: sin costura */
    background: url("../img/papel-grano.webp") 0 0 / 30rem auto, var(--papel-pie, linear-gradient(#a9abb5, #a9abb5));
    background-blend-mode: soft-light, normal;
  }

  .cierre__lienzo {
    height: auto;
    min-height: 0;
    aspect-ratio: 3 / 4;
    --fx: 50%;
    --fy: 100%;
    -webkit-mask: url("../img/borde-5.webp") top / 100% var(--orilla) no-repeat,
      url("../img/borde-pie.webp") bottom / 100% var(--orilla) no-repeat,
      linear-gradient(#000, #000) 0 var(--orilla) / 100% calc(100% - var(--orilla) * 2 + 2px) no-repeat;
    mask: url("../img/borde-5.webp") top / 100% var(--orilla) no-repeat,
      url("../img/borde-pie.webp") bottom / 100% var(--orilla) no-repeat,
      linear-gradient(#000, #000) 0 var(--orilla) / 100% calc(100% - var(--orilla) * 2 + 2px) no-repeat;
  }

  .cierre__texto {
    position: relative;
    inset: auto;
    width: auto;
    transform: none;
    padding: 1.75rem var(--margen) 3rem;
  }

  .pie {
    position: static;
    align-items: flex-start;
    padding: 0 var(--margen) 2.25rem;
    text-align: left;
  }
}

/* ───────── Visor ───────── */

.visor {
  position: fixed;
  inset: 0;
  z-index: 100;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--visor-bg, #10131a);
  color: var(--visor-fg, #eef1f3);
  overflow: hidden;
}

/* el visor sigue siendo el mismo campo de pigmento */
.visor::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../img/lavado.webp") 0 0 / 68rem auto;
  mix-blend-mode: soft-light;
  opacity: 0.55;
  pointer-events: none;
}

.visor::backdrop {
  background: transparent;
}

.visor__lienzo {
  position: absolute;
  inset: 4rem var(--margen) 5.25rem;
  touch-action: pan-y pinch-zoom;
}

/* La obra ocupa su proporcion exacta dentro del visor (--arn = ancho / alto) */
.visor__lienzo img {
  position: absolute;
  inset: 0;
  margin: auto;
  width: min(100%, calc((100dvh - 9.25rem) * var(--arn, 0.75)));
  height: auto;
  max-height: 100%;
  aspect-ratio: var(--arn, 0.75);
  box-shadow: 0 2.2rem 4rem -2rem rgb(0 0 0 / 0.55);
}

/* Al abrir: el nombre y los controles suben despues de que llega la obra */
@keyframes sube {
  from { opacity: 0; transform: translateY(0.9rem); }
}

.visor[open] .visor__pie {
  animation: sube 0.8s var(--salida) 0.3s both;
}

.visor[open] .visor__cerrar {
  animation: sube 0.8s var(--salida) 0.4s both;
}

.visor__pie {
  position: absolute;
  inset: auto var(--margen) 1.1rem var(--margen);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
}

.visor__titulo {
  margin: 0;
  font-size: clamp(1.125rem, 1.6vw, 1.5rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.visor__pasos {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: none;
}

.visor__cuenta {
  min-width: 4.5ch;
  margin: 0 0.5rem;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.boton-icono {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  transition: background-color 0.4s var(--salida), color 0.4s var(--salida);
}

.boton-icono svg {
  width: 1.25rem;
  height: 1.25rem;
}

.boton-icono:hover,
.boton-icono:focus-visible {
  background: var(--visor-fg, #eef1f3);
  color: var(--visor-bg, #10131a);
}

.visor__cerrar {
  position: absolute;
  top: 0.6rem;
  right: calc(var(--margen) - 0.6rem);
}

/* ───────── Gota (cursor sobre los pliegos) ───────── */

/* Dos piezas: la exterior solo lleva la posicion del puntero; la interior es la gota que
   florece y se seca en su sitio. Asi nunca viaja desde una esquina ni desde otro cuadro. */
.gota {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 200;
  display: none;
  pointer-events: none;
}

.gota__cuerpo {
  display: grid;
  place-items: center;
  width: 3.75rem;
  height: 3.75rem;
  margin: -1.875rem 0 0 -1.875rem;
  border-radius: 50%;
  background: var(--gota-bg, #eef2f4);
  color: var(--gota-fg, #0d2c54);
  font-size: 0.8125rem;
  font-weight: 600;
  transform: scale(0.82);
  opacity: 0;
  /* al irse: se desvanece pronto y suave, sin encogerse a un punto ni saltar */
  transition: transform 0.3s ease-out, opacity 0.26s ease-out, background-color 0.5s ease, color 0.5s ease;
}

.gota.activa .gota__cuerpo {
  transform: scale(1);
  opacity: 1;
  /* al entrar: florece bajo el puntero */
  transition: transform 0.55s var(--salida), opacity 0.22s ease, background-color 0.5s ease, color 0.5s ease;
}

@media (hover: hover) and (pointer: fine) {
  .gota {
    display: block;
  }
}

/* ───────── Transición entre pliego y visor ───────── */

::view-transition-group(obra) {
  animation-duration: 0.7s;
  animation-timing-function: cubic-bezier(0.2, 0.9, 0.2, 1);
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.5s;
}

/* Ir a una seccion desde el menu: la pagina se disuelve y aparece alla */
.salto::view-transition-old(root) {
  animation: 0.55s cubic-bezier(0.4, 0, 0.6, 1) both sale;
}

.salto::view-transition-new(root) {
  animation: 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both entra;
}

@keyframes sale {
  to { opacity: 0; transform: translateY(-1.5%); }
}

@keyframes entra {
  from { opacity: 0; transform: translateY(1.5%); }
}

/* ───────── Menos movimiento ───────── */

@media (prefers-reduced-motion: reduce) {
  .obra__abrir,
  .campo::before {
    transform: none;
  }

  .visor[open] .visor__pie,
  .visor[open] .visor__cerrar {
    animation: none;
  }

  .humeda.plana img,
  .obra figcaption,
  .cabecera,
  .gota__cuerpo,
  .indice a,
  .indice a::before,
  .indice a::after,
  .enlace::before,
  .enlace::after {
    transition: none;
  }

  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}
