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

:root {
  --bg: #0e0e0f;
  --text: #ecebe8;
  --muted: #8a8985;
  --line: #2a2a2c;
}

html,
body {
  height: 100%;
}

html:has(body.portada) {
  background: #000;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "League Spartan", "Futura", "Century Gothic", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  -webkit-font-smoothing: antialiased;
}

main {
  text-align: center;
  animation: fade 1.2s ease-out both;
}

h1 {
  font-weight: 300;
  font-size: clamp(2.2rem, 7vw, 4.5rem);
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.divider {
  width: 48px;
  height: 1px;
  background: var(--line);
  margin: 2rem auto;
}

nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem 2.5rem;
}

nav a {
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding-bottom: 4px;
  border-bottom: 1px solid transparent;
  transition: color 0.3s ease, border-color 0.3s ease;
}

nav a:hover,
nav a:focus-visible {
  color: var(--text);
  border-color: var(--text);
  outline: none;
}

.back {
  display: inline-block;
  margin-top: 2rem;
}

/* ---------- Portada con capas ---------- */

.portada {
  --pie: 112px;
  --negro: #000;
  --muted: #b5b4b0; /* enlaces más claros para que se lean bien sobre negro */
  background: var(--negro);
  overflow: hidden;
  padding: 0;
  display: block;
}

.escena {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.escena .fondo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Las capas ocupan todo el espacio sobre el pie, centradas y sin deformarse */
.arte {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: calc(var(--pie) + env(safe-area-inset-bottom));
}

/* Cada capa se muestra u oculta de golpe (sin transiciones); portada.js decide cuál */
.capa {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  visibility: hidden;
}

.capa.on {
  visibility: visible;
}

/* Sin JavaScript: imagen fija */
html:not(.js) .capa[data-capa="2"] {
  visibility: visible;
}

/* Nombre y enlaces, siempre por encima y sobre negro */
.pie {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  /* la franja de abajo del iPhone se suma a la altura en vez de comerse el espacio */
  height: calc(var(--pie) + env(safe-area-inset-bottom));
  padding: 0 16px env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  text-align: center;
  background: var(--negro);
}

.pie h1 {
  font-size: 1.15rem;
  font-weight: 300;
  letter-spacing: 0.08em;
  line-height: 1;
}

/* Celular: menos espacio entre letras y entre enlaces para que
   "I WORSHIP THE WORMS" quepa en una línea con los otros dos (desde 360 px de ancho) */
@media (max-width: 480px) {
  .pie nav ul,
  .cv-cabecera nav ul {
    gap: 0.7rem 1.4rem;
  }
  .pie nav a,
  .cv-cabecera nav a {
    letter-spacing: 0.16em;
  }
}

/* Pantallas muy estrechas (p. ej. 320 px): los enlaces pasan a dos líneas;
   el pie crece un poco para que no queden pegados al borde */
@media (max-width: 359px) {
  .portada {
    --pie: 128px;
  }
}

/* ---------- C.V. ---------- */

.cv {
  --negro: #000;
  --muted: #b5b4b0;
  --tenue: #6f6e6a;
  background: var(--negro);
  display: block;
  height: auto;
  min-height: 100%;
  padding: 0 16px;
}

.cv-cabecera,
.cv-cuerpo {
  max-width: 720px;
  margin: 0 auto;
}

.cv-cabecera {
  padding: 2rem 0 3rem;
  text-align: center;
}

.cv-cabecera nav ul {
  justify-content: center;
}

.cv-volver {
  display: inline-block;
  margin-bottom: 3rem;
}

.cv-cabecera h1 {
  font-size: clamp(1.8rem, 6vw, 2.8rem);
  font-weight: 300;
  letter-spacing: 0.02em;
  margin-bottom: 1.5rem;
}

/* Enlaces de la cabecera con el mismo aspecto que en la portada */
.cv-volver {
  font-size: 0.8rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding-bottom: 4px;
  border-bottom: 1px solid transparent;
  transition: color 0.3s ease, border-color 0.3s ease;
}

.cv-volver:hover,
.cv-volver:focus-visible {
  color: var(--text);
  border-color: var(--text);
  outline: none;
}

.cv-cuerpo {
  padding-bottom: 5rem;
  text-align: left;
}

.cv-cuerpo section {
  border-top: 1px solid var(--line);
  padding-top: 1.5rem;
  margin-bottom: 3rem;
}

.cv-cuerpo h2 {
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

/* Una fila por entrada: año a la izquierda, detalle a la derecha */
.cv-lista {
  list-style: none;
}

.cv-lista li {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  column-gap: 1rem;
  margin-bottom: 0.9rem;
  line-height: 1.45;
}

.cv-anio {
  color: var(--tenue);
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  padding-top: 0.05em;
}

.cv-detalle {
  font-size: 1rem;
  font-weight: 300;
  overflow-wrap: anywhere;
}

@media (max-width: 480px) {
  .cv-lista li {
    grid-template-columns: 3.25rem 1fr;
    column-gap: 0.75rem;
  }
  .cv-detalle {
    font-size: 0.95rem;
  }
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  main {
    animation: none;
  }
}
