/* ==========================================================================
   CF CRACKS · base
   Reinicio, el hormigón (fondo y grano), la tipografía, la maqueta general y
   los dos gestos atados al scroll: la foto que se descubre y la raya que se traza.
   ========================================================================== */

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

/* Un componente con display propio no puede pisar el atributo hidden. */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-padding-top: var(--e-5);
  /* En móvil la barra de pestañas es fija: el final de página no puede quedar debajo. */
  scroll-padding-bottom: calc(var(--alto-barra) + var(--seguro-abajo) + var(--e-4));
}
@media (min-width: 56.25em) {
  html {
    scroll-padding-top: calc(var(--alto-cabecera) + var(--e-5));
    scroll-padding-bottom: var(--e-5);
  }
}

body {
  margin: 0;
  min-height: var(--alto-ventana, 100svh);
  background: var(--blanco);
  color: var(--tinta);
  font-family: var(--f);
  font-size: var(--t-cuerpo);
  font-weight: var(--p-texto);
  font-stretch: var(--a-texto);
  line-height: 1.55;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* hueco para la barra fija del móvil */
  padding-bottom: calc(var(--alto-barra) + var(--seguro-abajo));
}
@media (min-width: 56.25em) {
  body {
    padding-bottom: 0;
  }
}

::selection {
  background: var(--azul);
  color: var(--blanco);
}

/* --------------------------------------------------------------------------
   El grano. Una sola capa fija, en multiply, sobre toda la página: el blanco
   deja de ser un rectángulo con color de fondo y coge el poro del hormigón.
   -------------------------------------------------------------------------- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' seed='11' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .04 0 0 0 0 .15 0 0 0 0 .25 0 0 0 -.22 .15'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  background-size: 220px 220px;
}
@media print {
  body::before {
    display: none;
  }
}

/* ------------------------------------------------------------ tipografía */
h1,
h2,
h3,
h4,
p,
ul,
ol,
dl,
dd,
figure,
blockquote,
address {
  margin: 0;
}
ul,
ol {
  padding: 0;
  list-style: none;
}
address {
  font-style: normal;
}

/* El rótulo: la misma familia, más estrecha cuanto más grande. En frase, nunca
   en mayúsculas, y sin nada encima: el titular carga con todo. */
h1,
h2,
h3 {
  font-family: var(--f-rotulo);
  font-weight: var(--p-rotulo);
  letter-spacing: -0.012em;
  text-wrap: balance;
  color: var(--marino);
}
h1 {
  font-size: var(--t-1);
  font-stretch: var(--a-1);
  line-height: 0.98;
}
h2 {
  font-size: var(--t-2);
  font-stretch: var(--a-2);
  line-height: 1.04;
}
h3 {
  font-size: var(--t-3);
  font-stretch: var(--a-3);
  line-height: 1.2;
  letter-spacing: 0;
}
p {
  text-wrap: pretty;
}
strong,
b {
  font-weight: var(--p-fuerte);
}

/* El dato: a máquina, cifras tabulares. */
.dato,
time {
  font-family: var(--f-dato);
  font-size: var(--t-dato);
  font-weight: var(--p-dato);
  font-stretch: 100%;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.suave {
  color: var(--tinta-suave);
}
.entradilla {
  font-size: var(--t-entradilla);
  line-height: 1.45;
  max-width: 38em;
}

img,
svg,
picture {
  display: block;
  max-width: 100%;
}
img {
  height: auto;
}

/* ---------------------------------------------------------------- enlaces */
a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}
a,
button,
[role="button"],
summary {
  touch-action: manipulation;
}
button {
  font: inherit;
  color: inherit;
}

/* Foco: azul sobre el hormigón, blanco sobre la pintura. */
:focus-visible {
  outline: 2px solid var(--foco);
  outline-offset: 3px;
  border-radius: var(--r-placa);
}
:focus:not(:focus-visible) {
  outline: none;
}

.salto {
  position: absolute;
  left: var(--margen);
  top: -6rem;
  z-index: 70;
  padding: var(--e-3) var(--e-5);
  background: var(--marino);
  color: var(--blanco);
  font-weight: var(--p-fuerte);
  border-radius: var(--r-placa);
  text-decoration: none;
}
.salto:focus {
  top: var(--e-3);
}

.solo-lector {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ----------------------------------------------------------------- maqueta */
/* El contenido respeta las zonas seguras (un móvil en horizontal, con su muesca); los
   fondos a sangre, no: llegan al borde. */
.ancho {
  width: min(100% - 2 * var(--margen) - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px), var(--ancho));
  margin-inline: auto;
}
.ancho--lectura {
  width: min(100% - 2 * var(--margen) - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px), 44rem);
}

.tramo {
  padding-block: var(--tramo);
}
.tramo--corto {
  padding-block: calc(var(--tramo) * 0.6);
}

/* Cabecera de sección: la raya (el canto del peldaño), el titular a la
   izquierda y su enlace a la derecha. Más aire encima que debajo. */
.cab-tramo {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--e-3) var(--e-6);
  padding-top: var(--e-5);
  margin-bottom: var(--e-6);
}
.cab-tramo::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--tinta);
  transform-origin: left center;
}
.cab-tramo p {
  max-width: 38em;
  margin-top: var(--e-3);
  color: var(--tinta-suave);
}
.cab-tramo .enlace {
  margin-bottom: 0.3em;
}

/* --------------------------------------------------------- las superficies */
/* La pintura: marino de pared a pared. Radio 0, siempre a sangre. */
.pintura {
  --foco: var(--blanco);
  background: var(--marino-hondo);
  color: var(--blanco);
}
.pintura h1,
.pintura h2,
.pintura h3 {
  color: var(--blanco);
}
.pintura .suave,
.pintura .cab-tramo p {
  color: var(--niebla);
}
.pintura .cab-tramo::before {
  background: var(--blanco);
}
/* El hormigón visto: el mismo plano, un punto más frío. También de pared a pared. */
.hormigon {
  background: var(--hormigon);
}

/* -----------------------------------------------------------------------
   Los dos gestos atados al scroll (DISENO.md, § 5). No tienen duración: los
   marca el dedo. Un navegador sin `animation-timeline` lo enseña todo quieto
   desde el principio; con menos movimiento, también.
   ----------------------------------------------------------------------- */
@keyframes descubrir {
  from {
    clip-path: inset(0 0 24% 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}
@keyframes asentar {
  from {
    transform: scale(1.07);
  }
  to {
    transform: none;
  }
}
@keyframes trazar {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    /* la foto no sube: se descubre, y se asienta en su marco */
    .foto picture {
      animation: descubrir linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 80%;
    }
    .foto img {
      animation: asentar linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 34%;
    }
    /* la raya se traza */
    .cab-tramo::before {
      animation: trazar linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 24%;
    }
  }
}

/* ------------------------------------------------- el paso de página (gesto 4) */
@view-transition {
  navigation: auto;
}
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 180ms;
  animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}
