/* Antonio López Sánchez · la mesa del escritor · mundo: manuscrito y máquina de escribir */

@font-face {
  font-family: "IM Fell DW Pica";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/fell-400.woff2") format("woff2");
}
@font-face {
  font-family: "IM Fell DW Pica";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/fell-italic.woff2") format("woff2");
}
@font-face {
  font-family: "EB Garamond";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("fonts/garamond-var.woff2") format("woff2");
}
@font-face {
  font-family: "EB Garamond";
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url("fonts/garamond-italic-var.woff2") format("woff2");
}
@font-face {
  font-family: "Courier Prime";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/courier-400.woff2") format("woff2");
}
@font-face {
  font-family: "Courier Prime";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/courier-700.woff2") format("woff2");
}
@font-face {
  font-family: "Courier Prime";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/courier-italic.woff2") format("woff2");
}

:root {
  /* grano de papel: ruido tibio de baja opacidad, tile de 220px */
  --grano: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.42 0 0 0 0 0.35 0 0 0 0 0.24 0 0 0 0.17 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23g)'/%3E%3C/svg%3E");
  /* mascara de entintado para sellos: alfa alto con calvas de tinta */
  --entintado: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='140'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.11 0.13' numOctaves='3' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.55 0.62'/%3E%3C/filter%3E%3Crect width='260' height='140' filter='url(%23m)'/%3E%3C/svg%3E");
  --mesa: #eadcc4;
  --mesa-sombra: #d9c8ab;
  --papel: #faf5e9;
  --papel-viejo: #f5edda;
  --tinta: #262019;
  --tinta-suave: #4d4335;
  --rojo: #b3372b;
  --rojo-tenue: #c86a5f;
  --paso: cubic-bezier(0.16, 1, 0.3, 1);
  --sombra-hoja: 0 2px 4px rgba(84, 62, 34, 0.1), 0 6px 18px rgba(84, 62, 34, 0.13);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scrollbar-color: var(--tinta-suave) var(--mesa);
}

body {
  font-family: "EB Garamond", "Georgia", serif;
  font-size: 1.15rem;
  line-height: 1.65;
  background: var(--mesa);
  color: var(--tinta);
  caret-color: var(--rojo);
  padding: clamp(1.2rem, 4vw, 3.5rem) 1rem 4rem;
}

::selection { background: var(--rojo); color: var(--papel); }

a { color: inherit; text-underline-offset: 0.24em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

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

.salto {
  position: absolute;
  left: 1rem; top: -4rem;
  z-index: 10;
  background: var(--tinta); color: var(--papel);
  padding: 0.6rem 1rem;
  font-family: "Courier Prime", monospace;
  font-size: 0.9rem;
  transition: top 0.2s var(--paso);
}
.salto:focus-visible { top: 1rem; }

/* ---------- lo mecanografiado ---------- */

.maquina, .maquina-roja {
  font-family: "Courier Prime", "Courier New", monospace;
}
.maquina-roja { color: var(--rojo); }

/* ---------- cuartillas ---------- */

.cuartilla {
  position: relative;
  width: min(100%, 46rem);
  margin: 0 auto;
  background: var(--grano), var(--papel);
  padding: 1.4rem clamp(1.4rem, 5vw, 4rem) 3.2rem;
  box-shadow: var(--sombra-hoja);
}
.cuartilla + .cuartilla { margin-top: 3rem; }

/* la hoja de abajo del montón */
.cuartilla::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--papel-viejo);
  transform: rotate(0.9deg) translate(5px, 3px);
  z-index: -1;
  box-shadow: 0 2px 8px rgba(84, 62, 34, 0.08);
}

/* la rotacion vive en la seccion contenedora: un transform en la propia
   cuartilla crearia stacking context y la hoja de abajo (::after, z -1)
   taparia el grano y los renglones del fondo propio */
section:nth-of-type(odd), main > .cuartilla:nth-of-type(odd) { transform: rotate(0.35deg); }
section:nth-of-type(even), main > .cuartilla:nth-of-type(even) { transform: rotate(-0.3deg); }
section:nth-of-type(even) .cuartilla::after,
main > .cuartilla:nth-of-type(even)::after { transform: rotate(-1deg) translate(-5px, 3px); }

.cabezal {
  font-family: "Courier Prime", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--tinta-suave);
  margin-bottom: 2.6rem;
}

/* ---------- hoja 1: portada ---------- */

.portada {
  padding-bottom: 2.6rem;
}
.portada::after { transform: rotate(-1.1deg) translate(-6px, 4px); }
/* el monton: mas hojas debajo de la primera cuartilla */
.portada::before {
  content: "";
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--papel-viejo) 88%, var(--mesa-sombra));
  transform: rotate(1.7deg) translate(10px, 8px);
  z-index: -2;
  box-shadow: 0 3px 10px rgba(84, 62, 34, 0.1), 0 14px 2px -12px rgba(84, 62, 34, 0.18);
}

.nombre {
  font-family: "IM Fell DW Pica", "Georgia", serif;
  font-weight: 400;
  font-size: clamp(2.7rem, 8.5vw, 5.4rem);
  line-height: 1.02;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin: 1rem 0 1.6rem;
}

.oficio {
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  min-height: 1.6em;
  margin-bottom: 0.6rem;
}
.cursor-maquina {
  display: inline-block;
  width: 0.55em;
  height: 1.05em;
  vertical-align: text-bottom;
  background: var(--tinta);
  margin-left: 1px;
  animation: parpadeo 1s steps(1) infinite;
}
@keyframes parpadeo { 50% { opacity: 0; } }

.premio {
  font-size: 0.95rem;
  margin-bottom: 2.4rem;
}

.accion { margin: 0 0 2.6rem; }

.sello {
  display: inline-block;
  font-family: "Courier Prime", monospace;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--rojo);
  background: transparent;
  border: 2px solid var(--rojo);
  outline: 1px solid var(--rojo);
  outline-offset: 3px;
  padding: 0.85rem 1.9rem;
  transform: rotate(-2deg);
  cursor: pointer;
  -webkit-mask-image: var(--entintado);
  mask-image: var(--entintado);
  -webkit-mask-size: 260px 140px;
  mask-size: 260px 140px;
  transition: transform 0.3s var(--paso), color 0.3s var(--paso), border-color 0.3s var(--paso);
}
.sello:hover { transform: rotate(-2deg) scale(0.97); color: #922c22; border-color: #922c22; }
.sello:active { transform: rotate(-2deg) scale(0.94); }
.sello:focus-visible { outline: 2px solid var(--rojo); outline-offset: 5px; }
.sello:disabled {
  color: var(--rojo-tenue);
  border-color: var(--rojo-tenue);
  outline-color: var(--rojo-tenue);
  cursor: not-allowed;
  transform: rotate(-2deg);
}

.portada-cuerpo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(11rem, 15rem);
  gap: clamp(1.4rem, 4vw, 2.8rem);
  align-items: center;
  margin-bottom: 2.4rem;
}
.foto-retrato { margin-top: 0; }

/* la foto del mar, suelta sobre la mesa */
.foto-mar {
  width: min(26rem, 88%);
  margin: 3.2rem auto 0;
  transform: rotate(0.9deg);
}
.foto-mar img {
  display: block;
  width: 100%;
  height: auto;
  border: 6px solid var(--papel);
  outline: 1px solid var(--mesa-sombra);
  box-shadow: var(--sombra-hoja);
}

/* navegacion mecanografiada al pie de cada hoja */
.indice-pie {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.6rem;
  border-top: 1px solid var(--mesa-sombra);
  margin-top: 3rem;
  padding-top: 1rem;
  font-size: 0.85rem;
}
.indice-pie a { text-decoration: none; }
.indice-pie a:hover { text-decoration: underline; text-underline-offset: 0.24em; }
.indice-pie span[aria-current] {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.24em;
}

.accion-cierre { margin: 1.8rem 0 2.4rem; }

.indice {
  border-top: 1px solid var(--mesa-sombra);
  padding-top: 1.1rem;
  max-width: 30rem;
}
.indice-titulo {
  font-family: "Courier Prime", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tinta-suave);
  margin-bottom: 0.5rem;
}
.indice ol { list-style: none; }
.indice a {
  display: inline-block;
  padding: 0.32rem 0;
  text-decoration: none;
  font-family: "Courier Prime", monospace;
  font-size: 0.95rem;
}
.indice a:hover { text-decoration: underline; text-underline-offset: 0.24em; }

/* ---------- tiras separadoras ---------- */

.tira {
  width: fit-content;
  max-width: 100%;
  margin: 4.5rem auto 2.8rem;
  background: var(--grano), var(--papel-viejo);
  padding: 0.9rem 2.4rem 1rem;
  box-shadow: var(--sombra-hoja);
  transform: rotate(-1.2deg);
  text-align: center;
}
section:nth-of-type(even) .tira { transform: rotate(1deg); }
.tira h1, .tira h2 {
  font-family: "IM Fell DW Pica", "Georgia", serif;
  font-weight: 400;
  font-size: clamp(1.7rem, 4.5vw, 2.4rem);
  line-height: 1.1;
  text-wrap: balance;
}
.tira .maquina {
  font-size: 0.82rem;
  color: var(--tinta-suave);
  margin-top: 0.2rem;
}

/* ---------- obras ---------- */

.obra-cuerpo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(9.5rem, 12.5rem);
  gap: clamp(1.4rem, 4vw, 2.8rem);
  align-items: start;
}

.obra-numero {
  font-size: 1rem;
  color: var(--tinta-suave);
  margin-bottom: 0.3rem;
}

.obra-texto h3 {
  font-family: "IM Fell DW Pica", "Georgia", serif;
  font-weight: 400;
  font-size: clamp(1.9rem, 5vw, 2.9rem);
  line-height: 1.05;
  letter-spacing: -0.005em;
  text-wrap: balance;
  margin-bottom: 0.9rem;
}

.obra-datos {
  font-size: 0.88rem;
  line-height: 1.55;
  margin-bottom: 1.2rem;
}

.obra-sinopsis, .prosa {
  max-width: 58ch;
  margin-bottom: 0.9rem;
}

.prosa-inicial::first-letter {
  font-family: "IM Fell DW Pica", "Georgia", serif;
  font-size: 3.1em;
  float: left;
  line-height: 0.78;
  padding-right: 0.14em;
}

.nota-demo {
  font-size: 0.78rem;
  color: var(--tinta-suave);
  margin-top: 1.1rem;
}

/* fotos de cubierta apoyadas sobre la hoja */
.foto {
  position: relative;
  margin-top: 1.6rem;
  transform: rotate(2deg);
  transition: transform 0.4s var(--paso);
}
.obra:nth-of-type(even) .foto, section:nth-of-type(even) .foto { transform: rotate(-1.8deg); }
.cuartilla:hover .foto { transform: rotate(0.6deg); }
.foto img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--mesa-sombra);
  box-shadow: 0 1px 3px rgba(84, 62, 34, 0.18);
}

/* ---------- trova ---------- */

.lista-maquina {
  list-style: none;
  margin-top: 1.6rem;
  border-top: 1px solid var(--mesa-sombra);
}
.lista-maquina li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--mesa-sombra);
  font-size: 1.05rem;
}
.lista-maquina .maquina { font-size: 0.85rem; color: var(--tinta-suave); }
.lista-maquina strong { font-weight: 600; }

/* ---------- el poeta: copia al carbon en papel cebolla ---------- */

.carbon {
  /* papel de segunda: mas frio y delgado que la cuartilla;
     la mancha se funde por multiply, como cafe absorbido por la fibra */
  background:
    url("img/mancha.svg") no-repeat top -3.4rem right -3.2rem / 16rem 16rem,
    var(--grano),
    #f2ede0;
  background-blend-mode: multiply, normal, normal;
  overflow: clip;
}
/* el tipeo de copia: tinta de carbon, un punto mas difusa */
.carbon .poema-titulo,
.carbon .poema-texto {
  color: #3b3327;
  text-shadow: 0 0 0.6px rgba(59, 51, 39, 0.55);
}
.carbon .cabezal { margin-bottom: 1.9rem; }

.poema-titulo {
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.28em;
  text-decoration-thickness: 1px;
  margin-bottom: 1.8rem;
}
.poema-texto {
  white-space: pre-wrap;
  font-size: 0.98rem;
  line-height: 1.85;
  max-width: 56ch;
}
.poema-credito {
  margin-top: 1.8rem;
  font-size: 0.85rem;
  color: var(--rojo);
}

/* ---------- el periodista: ficha ---------- */

.ficha-archivo { border-top: 3px solid var(--rojo); }

.ficha div {
  display: grid;
  grid-template-columns: minmax(6.5rem, 9rem) minmax(0, 1fr);
  gap: 1rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--mesa-sombra);
}
.ficha div:first-child { border-top: none; padding-top: 0; }
.ficha dt {
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--tinta-suave);
  padding-top: 0.3rem;
}
.ficha dd { max-width: 58ch; }

/* ---------- directorio ---------- */

.pie { margin-top: 4.5rem; transform: rotate(0.25deg); }

.pie h2 {
  font-family: "IM Fell DW Pica", "Georgia", serif;
  font-weight: 400;
  font-size: clamp(2rem, 5vw, 2.8rem);
  margin-bottom: 0.9rem;
}
.cierre-texto { max-width: 44ch; }
.pie .accion { margin: 1.8rem 0 2.4rem; }

.colofon {
  font-size: 0.76rem;
  line-height: 1.7;
  color: var(--tinta-suave);
  border-top: 1px solid var(--mesa-sombra);
  padding-top: 1rem;
  max-width: 58ch;
}
.fin {
  text-align: center;
  font-size: 0.85rem;
  color: var(--tinta-suave);
  margin-top: 2.4rem;
}

/* ---------- responsive ---------- */

@media (max-width: 40rem) {
  body { padding-top: 1rem; }
  .obra-cuerpo, .portada-cuerpo { grid-template-columns: 1fr; }
  .foto-retrato { max-width: 15rem; margin-inline: auto; }
  .foto-mar { width: min(20rem, 92%); }
  .foto { max-width: 13rem; margin-inline: auto; }
  section, section:nth-of-type(odd), section:nth-of-type(even), .pie { transform: none; }
  .cuartilla::after, section .cuartilla::after { transform: rotate(0.7deg) translate(4px, 3px); }
  .cabezal { margin-bottom: 1.8rem; }
  .poema-texto { font-size: 0.88rem; line-height: 1.8; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .sello, .foto, .salto { transition: none; }
  .cursor-maquina { animation: none; }
}
