/* Línea 1: índice cronológico. */

:root {
  --bg: #f3f2ee;
  --ink: #141414;
  --muted: #7a7873;
  --rule: #d9d7d0;
  --hover: #e8e6df;

  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --gutter: clamp(1rem, 3vw, 2.5rem);
  --text: 42rem;
  --wide: 68rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121211;
    --ink: #ecebe6;
    --muted: #8c8a84;
    --rule: #2c2b29;
    --hover: #1d1c1a;
  }
}

* { box-sizing: border-box; }

html { background: var(--bg); color: var(--ink); }

body {
  margin: 0;
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

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

/* ---------- cabecera ---------- */

.site {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .25rem 1.5rem;
  padding: var(--gutter);
  padding-bottom: 0;
}

.site-name { font-weight: 500; text-decoration: none; }
.site-tagline { color: var(--muted); }

.site nav { margin-left: auto; display: flex; gap: 1.25rem; }
.site nav a { text-decoration: none; color: var(--muted); }
.site nav a[aria-current] { color: var(--ink); }
.site nav a:hover { color: var(--ink); }

/* En móvil: nombre y menú en una línea, el lema debajo */
@media (max-width: 40rem) {
  .site-tagline { order: 3; flex-basis: 100%; }
}

main { padding: var(--gutter); padding-bottom: 6rem; }

/* ---------- índice ---------- */

.index-head {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: .875rem;
  margin: clamp(3rem, 12vh, 8rem) 0 .75rem;
}

.index { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ink); }

.index a {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr) 14rem 16rem;
  gap: 1rem;
  align-items: baseline;
  padding: .7rem 0;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
}

.index .year { font-variant-numeric: tabular-nums; }
.index .same-year .year { visibility: hidden; }
.index .title { font-size: clamp(1.125rem, 1.6vw, 1.5rem); line-height: 1.25; }
.index .cats, .index .tags { color: var(--muted); font-size: .875rem; }
.index .thumb { display: none; }

@media (hover: hover) {
  .index a { transition: padding-left .25s ease, background-color .25s; }
  .index a:hover, .index a:focus-visible { padding-left: .75rem; background: var(--hover); }
  .index:hover a:not(:hover) { color: var(--muted); }
}

/* El recuadro que sigue al cursor. Solo con ratón. */
.peek {
  position: fixed;
  top: 0;
  left: 0;
  width: min(26rem, 34vw);
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
  z-index: 10;
}
.peek.on { opacity: 1; }
@media not (hover: hover) { .peek { display: none; } }

@media (max-width: 60rem) {
  .index a { grid-template-columns: 3.5rem minmax(0, 1fr) 11rem; }
  .index .tags { display: none; }
}

@media (max-width: 40rem) {
  .index a {
    grid-template-columns: minmax(0, 1fr) 5.5rem;
    grid-template-areas: "year thumb" "title thumb" "cats thumb";
    gap: .15rem 1rem;
    align-items: start;
  }
  .index .year { grid-area: year; color: var(--muted); font-size: .875rem; }
  .index .same-year .year { visibility: visible; }
  .index .title { grid-area: title; }
  .index .cats { grid-area: cats; }
  .index .thumb {
    grid-area: thumb;
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
  }
}

/* ---------- proyecto ---------- */

.project { max-width: var(--wide); margin-top: clamp(2.5rem, 8vh, 5rem); }

.back { color: var(--muted); text-decoration: none; font-size: .875rem; }
.back:hover { color: var(--ink); }

.project-head { margin: 2rem 0 3rem; }
.project-head .meta { color: var(--muted); font-size: .875rem; margin: 0 0 .75rem; }
.project-head h1 {
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.05;
  font-weight: 500;
  letter-spacing: -.02em;
  margin: 0;
  max-width: 20ch;
}

.body > * { max-width: var(--text); }
.body > figure, .body > video, .body > .embed { max-width: var(--wide); }

.body p { margin: 0 0 1.1em; }
.body h2, .body h3, .body h4 { font-weight: 500; margin: 2.5rem 0 .75rem; }

.body figure { margin: 2.5rem 0; }
.body figcaption { color: var(--muted); font-size: .875rem; margin-top: .5rem; }
.body video { width: 100%; margin: 2.5rem 0; }

.body .embed iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; }

.body blockquote {
  margin: 2.5rem 0;
  padding: 0;
  font-size: clamp(1.25rem, 2vw, 1.6rem);
  line-height: 1.3;
}
.body blockquote p { margin: 0; }
.body blockquote cite {
  display: block;
  margin-top: .75rem;
  font-size: .875rem;
  font-style: normal;
  color: var(--muted);
}

/* Tuits: tarjeta propia, sin el widget de X */
.body .tweet {
  max-width: 34rem;
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border: 1px solid var(--rule);
  font-size: .95rem;
}
.tweet p { white-space: pre-line; margin: 0 0 .75rem; }
.tweet-media { display: grid; grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); gap: .25rem; margin-bottom: .75rem; }
.tweet-media img { width: 100%; height: 100%; object-fit: cover; }
.tweet a.src { color: var(--muted); font-size: .875rem; text-decoration: none; }
.tweet a.src:hover { color: var(--ink); }

.project-foot {
  max-width: var(--text);
  margin-top: 4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: .875rem;
}
.project-foot dl { display: grid; grid-template-columns: 8rem 1fr; gap: .35rem 1rem; margin: 0 0 1.5rem; }
.project-foot dt { color: var(--muted); }
.project-foot dd { margin: 0; }
.project-foot .tags { color: var(--muted); }

.pager {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  margin-top: 5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--ink);
}
.pager a { text-decoration: none; max-width: 45%; }
.pager a:last-child { text-align: right; margin-left: auto; }
.pager small { display: block; color: var(--muted); }

/* ---------- about ---------- */

.about { margin-top: clamp(3rem, 12vh, 8rem); }

.bio { max-width: var(--text); font-size: clamp(1.125rem, 1.6vw, 1.35rem); line-height: 1.4; }
.bio p { margin: 0 0 1em; }

.cv h2 {
  font-size: .875rem;
  font-weight: 400;
  color: var(--muted);
  margin: 4rem 0 .75rem;
}
.cv ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ink); max-width: var(--wide); }
.cv li {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr);
  gap: 1rem;
  padding: .6rem 0;
  border-bottom: 1px solid var(--rule);
}
.cv li .year { font-variant-numeric: tabular-nums; }
.cv li.same-year .year { visibility: hidden; }
.cv .empty { color: var(--muted); }

@media (max-width: 40rem) {
  .cv li { grid-template-columns: 3.5rem minmax(0, 1fr); }
  .project-foot dl { grid-template-columns: 1fr; }
  .project-foot dd { margin-bottom: .5rem; }
}

.error { color: #c33; }
