/* ==========================================================================
   George Guillén — sitio personal
   Un solo archivo de estilos. Sin frameworks, sin build.
   ========================================================================== */

/* Tipografías autoalojadas (carpeta /fonts/), subconjunto latino de Google Fonts.
   Newsreader: fuente variable con eje óptico (opsz 6–72), regular e itálica.
   Source Sans 3: regular. Licencia SIL Open Font License. */

@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/newsreader-regular.woff2") format("woff2");
}

@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/newsreader-italic.woff2") format("woff2");
}

@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/source-sans-3-regular.woff2") format("woff2");
}

:root {
  --bg: #f7f5ef;        /* hueso */
  --ink: #1f1e1a;       /* texto principal */
  --ink-2: #5f5c53;     /* texto secundario, pies de foto */
  --rule: #d8d3c5;      /* filetes */
  --accent: #3e4a29;    /* oliva oscuro: enlaces y detalles */
  --accent-2: #2b3419;  /* oliva más oscuro: hover */
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Source Sans 3", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --measure: 66ch;      /* ancho de columna de lectura (~65–75 caracteres) */
  --gutter: 1.25rem;
}

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

html {
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 1.5rem;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}

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

figure {
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--accent-2);
}

@media (prefers-reduced-motion: no-preference) {
  a {
    transition: color 0.15s ease;
  }
}

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

::selection {
  background: #e3e6d6;
  color: var(--ink);
}

/* Enlace para saltar al contenido (solo visible con teclado) */
.skip {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--accent);
  transform: translateY(-200%);
}

.skip:focus {
  transform: none;
}

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

/* --------------------------------------------------------------------------
   Cabecera y navegación
   -------------------------------------------------------------------------- */

.site-header {
  border-bottom: 1px solid var(--rule);
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding-block: 1.1rem;
}

.brand {
  font-family: var(--serif);
  font-size: 1.25rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.brand:hover {
  color: var(--accent);
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 1.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a {
  font-size: 0.9375rem;
  color: var(--ink-2);
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current="true"] {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.site-nav a[aria-current="true"] {
  color: var(--ink);
}

/* En pantallas medianas y grandes la cabecera se queda fija al desplazarse.
   En móvil ocupa dos líneas, así que ahí no se fija. */
@media (min-width: 48em) {
  html {
    scroll-padding-top: 4.5rem;
  }

  .site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
  }
}

/* --------------------------------------------------------------------------
   Portada
   -------------------------------------------------------------------------- */

.hero .wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2.25rem;
  padding-block: 3rem 2.5rem;
}

/* min-width: 0 evita que una foto grande ensanche la rejilla más que la pantalla */
.hero .wrap > * {
  min-width: 0;
}

.hero h1 {
  margin: 0 0 1.1rem;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.6rem, 7vw, 4.6rem);
  line-height: 1.02;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.hero .lede {
  max-width: 22em;
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.25rem, 2.4vw, 1.5rem);
  line-height: 1.4;
  color: var(--ink-2);
}

.hero figure {
  max-width: 22rem;
}

@media (min-width: 48em) {
  .hero .wrap {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    align-items: end;
    padding-block: 4.5rem 3.5rem;
  }

  .hero figure {
    justify-self: end;
    width: 100%;
    max-width: 26rem;
  }
}

/* --------------------------------------------------------------------------
   Biografía: rejilla editorial (título al margen, texto en columna estrecha)
   -------------------------------------------------------------------------- */

.bio {
  padding-block: 1rem 4rem;
}

.bio section {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem 3rem;
  padding-block: 2.5rem;
}

.bio section > *,
.bio figure {
  min-width: 0;
}

.bio h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.625rem;
  line-height: 1.2;
  letter-spacing: -0.005em;
}

.prose {
  max-width: var(--measure);
}

.prose p {
  margin: 0 0 1.25em;
}

.prose p:last-child {
  margin-bottom: 0;
}

.bio figure {
  margin-top: 2.25rem;
}

figcaption {
  margin-top: 0.65rem;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--ink-2);
}

/* Foto vertical suelta: se limita el ancho para que no ocupe toda la pantalla */
.bio figure.narrow {
  max-width: 26rem;
}

/* Dos fotos verticales lado a lado (apiladas en móvil). Se recortan a 4:5
   para que ambas tengan la misma altura. */
.pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  margin-top: 2.25rem;
}

.pair figure {
  margin-top: 0;
}

.pair img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}

@media (min-width: 40em) {
  .pair {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }
}

@media (min-width: 60em) {
  .bio section {
    grid-template-columns: 13rem minmax(0, 1fr);
    padding-block: 3rem;
  }

  .bio h2 {
    grid-column: 1;
    padding-top: 0.15rem;
  }

  .prose {
    grid-column: 2;
  }

  .bio figure,
  .pair {
    grid-column: 1 / -1;
    max-width: 54rem;
  }

  .bio figure.narrow {
    grid-column: 2;
    max-width: 26rem;
  }

  .pair figure {
    grid-column: auto;
  }
}

/* --------------------------------------------------------------------------
   Pie de página
   -------------------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--rule);
  padding-block: 2rem 3rem;
  font-size: 0.9375rem;
  color: var(--ink-2);
}

.site-footer p {
  margin: 0 0 0.4rem;
}

.site-footer .name {
  font-family: var(--serif);
  font-style: normal;
  font-size: 1.125rem;
  color: var(--ink);
}

/* --------------------------------------------------------------------------
   Fotos ampliables (script.js envuelve cada foto en un botón y abre el <dialog>)
   -------------------------------------------------------------------------- */

.zoom {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.lightbox {
  max-width: min(92vw, 70rem);
  padding: 0;
  border: 0;
  background: var(--bg);
  color: var(--ink);
}

.lightbox::backdrop {
  background: rgba(31, 30, 26, 0.85);
}

.lightbox img {
  max-width: 100%;
  max-height: 80vh;
  width: auto;
  height: auto;
  aspect-ratio: auto;
  object-fit: contain;
  margin-inline: auto;
}

.lightbox-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem 0.9rem;
}

.lightbox-bar p {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--ink-2);
}

.lightbox-close {
  flex-shrink: 0;
  padding: 0.3rem 0.8rem;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--ink);
  background: none;
  border: 1px solid var(--rule);
  cursor: pointer;
}

.lightbox-close:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   Movimiento. Todo dentro de prefers-reduced-motion: quien lo desactive en su
   sistema ve la página estática.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  @keyframes rise-in {
    from {
      opacity: 0;
      transform: translateY(14px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  @keyframes rise {
    from {
      transform: translateY(10px);
    }
    to {
      transform: none;
    }
  }

  @keyframes fade-in {
    from {
      opacity: 0;
    }
  }

  /* Entrada de la portada al cargar: nombre, línea y retrato, en ese orden.
     El retrato no cambia de opacidad para no retrasar el LCP. */
  .hero h1 {
    animation: rise-in 0.7s cubic-bezier(0.2, 0.6, 0.2, 1) both;
  }

  .hero .lede {
    animation: rise-in 0.7s cubic-bezier(0.2, 0.6, 0.2, 1) 0.15s both;
  }

  .hero figure {
    animation: rise 0.9s cubic-bezier(0.2, 0.6, 0.2, 1) both;
  }

  /* Fotos que aparecen al entrar en pantalla, ligadas al scroll y sin JS. */
  @supports (animation-timeline: view()) {
    .bio figure {
      animation: rise-in linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 40%;
    }
  }

  /* Respaldo para navegadores sin animation-timeline: script.js añade la
     clase js-reveal al <html> y marca cada foto al entrar en pantalla. */
  .js-reveal .bio figure {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.6, 0.2, 1);
  }

  .js-reveal .bio figure.in-view {
    opacity: 1;
    transform: none;
  }

  .lightbox[open] {
    animation: fade-in 0.2s ease both;
  }
}

/* --------------------------------------------------------------------------
   Página 404
   -------------------------------------------------------------------------- */

.notfound {
  min-height: 60vh;
  padding-block: 4rem;
}

.notfound h1 {
  margin: 0 0 1rem;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2rem, 6vw, 3rem);
  line-height: 1.1;
}

.notfound p {
  max-width: var(--measure);
  margin: 0 0 1em;
}

/* --------------------------------------------------------------------------
   Impresión
   -------------------------------------------------------------------------- */

@media print {
  .site-nav,
  .skip {
    display: none;
  }

  a {
    color: inherit;
    text-decoration: none;
  }
}
