/* ==========================================================================
   javierprieto.me
   Paleta: papel frío + tinta pizarra + un único acento verde azulado.
   Tipografía: IBM Plex Sans (estructura) + Source Serif 4 (prosa).
   ========================================================================== */

:root {
  --paper: #f3f6f7;
  --surface: #ffffff;
  --ink: #131c24;
  --ink-soft: #33434f;
  --muted: #5c6b76;
  --line: #dbe3e7;
  --line-strong: #c2ced5;
  --accent: #17595f;
  --accent-2: #3f8f83;
  --accent-3: #7fb5a2;
  --accent-4: #b9cfbf;
  --accent-ink: #0d3b40;
  --accent-wash: #e6eeee;
  --warn: #8a5a12;

  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;

  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: clamp(1.45rem, 2.4vw, 1.75rem);
  --step-3: clamp(1.8rem, 3.4vw, 2.4rem);
  --step-4: clamp(2.4rem, 6.2vw, 3.9rem);

  --gap: clamp(1.5rem, 4vw, 3rem);
  --pad: clamp(1.15rem, 4vw, 2.25rem);
  --measure: 66ch;
  --radius: 3px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #10171c;
    --surface: #161f25;
    --ink: #e8eef1;
    --ink-soft: #c3ced5;
    --muted: #93a2ac;
    --line: #26333b;
    --line-strong: #3a4a54;
    --accent: #6fc0c2;
    --accent-2: #4f9e9b;
    --accent-3: #8fd0c0;
    --accent-4: #c3e0d4;
    --accent-ink: #9fd8d8;
    --accent-wash: #1a2a2d;
    --warn: #d8a350;
  }
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--step-0);
  line-height: 1.65;
  font-optical-sizing: auto;
}

h1, h2, h3, h4, nav, button, label, input, select, textarea, .sans, .num {
  font-family: var(--sans);
}

h1, h2, h3 { line-height: 1.12; letter-spacing: -0.02em; font-weight: 600; margin: 0; }
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); letter-spacing: -0.01em; }
p { margin: 0 0 1em; max-width: var(--measure); }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
img { max-width: 100%; display: block; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--gap) 0; }
.skip {
  position: absolute; left: -9999px; top: 0; background: var(--surface);
  padding: .6rem 1rem; z-index: 10;
}
.skip:focus { left: 1rem; top: 1rem; }

/* ---------- Cabecera ---------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 8;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar__in {
  max-width: 1120px; margin: 0 auto; padding: .7rem var(--pad);
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand {
  font-family: var(--sans); font-weight: 600; font-size: .98rem;
  letter-spacing: -0.01em; color: var(--ink); text-decoration: none;
  margin-right: auto;
}
.brand span { color: var(--muted); font-weight: 400; }
.nav { display: flex; gap: clamp(.6rem, 2vw, 1.4rem); align-items: center; flex-wrap: wrap; }
.nav a {
  font-family: var(--sans); font-size: .92rem; color: var(--ink-soft);
  text-decoration: none; padding: .2rem 0; border-bottom: 1px solid transparent;
}
.nav a:hover { color: var(--ink); border-bottom-color: var(--line-strong); }
.nav a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

.lang {
  display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px;
  overflow: hidden; background: var(--surface);
}
.lang button {
  font-size: .78rem; font-weight: 500; letter-spacing: .02em;
  padding: .28rem .62rem; border: 0; background: transparent; color: var(--muted);
  cursor: pointer;
}
.lang button[aria-pressed="true"] { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .lang button[aria-pressed="true"] { color: #08171a; } }

/* ---------- Estructura -------------------------------------------------- */

main { max-width: 1120px; margin: 0 auto; padding: 0 var(--pad) 5rem; }
section { margin-top: clamp(2.6rem, 6vw, 4.4rem); }
.section-head {
  display: flex; align-items: baseline; gap: 1rem; position: relative;
  border-bottom: 1px solid var(--line); padding-bottom: .5rem; margin-bottom: 1.4rem;
}
.section-head::after {
  content: ""; position: absolute; left: 0; bottom: -1px; width: 2.6rem; height: 2px;
  background: var(--accent);
}
.section-head h2 { font-size: var(--step-2); }
.section-head .count { font-family: var(--sans); font-size: .85rem; color: var(--muted); margin-left: auto; }
.lede { font-size: var(--step-1); color: var(--ink-soft); max-width: 60ch; }

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

.hero {
  position: relative;
  padding: clamp(2.6rem, 8vw, 5.5rem) 0 clamp(1.5rem, 4vw, 2.5rem);
  display: grid; gap: var(--gap);
  grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr);
  align-items: start;
}
.hero::before {
  content: ""; position: absolute; inset: -1rem -2rem auto -2rem; height: 105%;
  background-image: radial-gradient(circle at center, var(--line-strong) 1px, transparent 1.2px);
  background-size: 15px 15px;
  -webkit-mask-image: radial-gradient(120% 90% at 78% 12%, #000 0%, transparent 62%);
  mask-image: radial-gradient(120% 90% at 78% 12%, #000 0%, transparent 62%);
  opacity: .55; pointer-events: none; z-index: -1;
}
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; }
  .hero__photo { order: -1; max-width: 190px; }
}
.hero h1 { margin-bottom: .55rem; }
.hero__role { font-size: var(--step-1); color: var(--ink); margin-bottom: .1rem; }
.hero__aff { color: var(--muted); max-width: 46ch; }
.hero__photo {
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); padding: 5px; width: 100%;
}
.hero__photo img { aspect-ratio: 4 / 5; object-fit: cover; width: 100%; border-radius: 1px; }
.hero__photo--empty {
  aspect-ratio: 4 / 5; display: grid; place-items: center; color: var(--muted);
  font-family: var(--sans); font-size: .85rem; text-align: center; padding: 1rem;
}

.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.5rem; }
.chip {
  display: inline-flex; align-items: center; gap: .45rem;
  font-family: var(--sans); font-size: .88rem; text-decoration: none;
  color: var(--ink-soft); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 999px;
  padding: .3rem .8rem .3rem .38rem;
  transition: border-color .18s ease, color .18s ease, background .18s ease;
}
.chip .ico {
  width: 1.45rem; height: 1.45rem; flex: none; color: var(--accent);
  background: var(--accent-wash); border-radius: 50%; padding: .18rem;
  transition: background .18s ease, color .18s ease;
}
.chip:hover { color: var(--accent-ink); border-color: var(--accent); }
.chip:hover .ico { background: var(--accent); color: var(--surface); }
@media (prefers-color-scheme: dark) { .chip:hover .ico { color: #0d1b1e; } }

.strip {
  display: grid; gap: 1px; background: var(--line);
  grid-template-columns: repeat(auto-fit, minmax(min(50%, 150px), 1fr));
  border-block: 1px solid var(--line); margin-top: clamp(1.4rem, 4vw, 2.2rem);
}
.strip__i {
  background: var(--paper); padding: 1rem .4rem 1.05rem; text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: .15rem; transition: background .18s ease;
}
.strip__i:hover { background: var(--surface); }
.strip__n {
  font-family: var(--sans); font-weight: 600; font-size: clamp(1.5rem, 3.6vw, 2.1rem);
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--accent); line-height: 1;
}
.strip__l { font-family: var(--sans); font-size: .84rem; color: var(--muted); }

.tags { display: flex; flex-wrap: wrap; gap: .45rem; margin: 0; padding: 0; list-style: none; }
.tags li {
  font-family: var(--sans); font-size: .85rem; color: var(--accent-ink);
  background: var(--accent-wash); border-radius: var(--radius); padding: .3rem .7rem;
}

.prose { max-width: var(--measure); }
.prose p:last-child { margin-bottom: 0; }

/* ---------- Listas en dos columnas ------------------------------------- */

.cols { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr)); }

.stack { list-style: none; margin: 0; padding: 0; }
.stack > li { padding: .8rem 0; border-top: 1px solid var(--line); }
.stack > li:first-child { border-top: 0; padding-top: 0; }
.stack strong { font-family: var(--sans); font-weight: 600; font-size: .98rem; }
.stack .meta { display: block; color: var(--muted); font-family: var(--sans); font-size: .86rem; }

/* ---------- Indicadores ------------------------------------------------- */

.kpis { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); overflow: hidden; }
.kpi { background: var(--surface); padding: 1.1rem 1.15rem 1.2rem; transition: background .18s ease; }
.kpi:hover { background: var(--accent-wash); }
.kpi__n {
  font-family: var(--sans); font-weight: 600; font-size: clamp(1.9rem, 4.4vw, 2.7rem);
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1;
  display: block; margin-bottom: .45rem;
}
.kpi__n small { font-size: .5em; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.kpi__l { font-family: var(--sans); font-size: .87rem; color: var(--muted); }
.kpi--accent .kpi__n { color: var(--accent); }

.panels {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
}
.panel {
  margin: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .95rem 1rem 1.1rem;
}
.panel--wide { grid-column: span 2; }
.panel--full { grid-column: 1 / -1; }
.panel__box--s { height: 250px; }
@media (max-width: 760px) { .panel--wide { grid-column: auto; } }
.panel figcaption {
  font-family: var(--sans); font-size: .9rem; font-weight: 500; color: var(--ink-soft);
  display: flex; align-items: baseline; gap: .5rem; margin-bottom: .7rem;
  padding-bottom: .55rem; border-bottom: 1px solid var(--line);
}
.panel figcaption .note { font-size: .78rem; }
.panel__box { position: relative; height: 240px; }
.panel--wide .panel__box { height: 260px; }
.note { font-family: var(--sans); font-size: .85rem; color: var(--muted); max-width: 70ch; }
label.inline { font-family: var(--sans); font-size: .88rem; color: var(--muted); }

/* ---------- Publicaciones ---------------------------------------------- */

.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.6rem; }
.field {
  font-family: var(--sans); font-size: .92rem; padding: .48rem .7rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); min-width: 0;
}
input.field { flex: 1 1 240px; }
.field--s { flex: 0 0 auto; }
.btn {
  font-family: var(--sans); font-size: .9rem; font-weight: 500; cursor: pointer;
  padding: .48rem .9rem; border-radius: var(--radius);
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
}
@media (prefers-color-scheme: dark) { .btn { color: #08171a; } }
.btn:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn--ghost { background: var(--surface); color: var(--ink-soft); border-color: var(--line-strong); }
.btn--ghost:hover { background: var(--surface); color: var(--accent); border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: progress; }

.pubyear {
  display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); gap: 1rem;
  padding: 1.1rem 0; border-top: 1px solid var(--line);
}
.pubyear:first-of-type { border-top: 0; }
.pubyear__y {
  font-family: var(--sans); font-weight: 600; font-size: 1rem; color: var(--muted);
  font-variant-numeric: tabular-nums; position: sticky; top: 4.2rem; align-self: start;
}
.pub { padding: .55rem 0; }
.pub + .pub { border-top: 1px dotted var(--line); }
.pub__t { display: block; font-size: 1.02rem; }
.pub__m { font-family: var(--sans); font-size: .85rem; color: var(--muted); margin-top: .18rem; }
.pub__m em { font-style: normal; color: var(--ink-soft); }
.pub__m a { text-decoration: none; }
.pub__m a:hover { text-decoration: underline; }
@media (max-width: 560px) {
  .pubyear { grid-template-columns: 1fr; gap: .2rem; }
  .pubyear__y { position: static; }
}

.badge {
  font-family: var(--sans); font-size: .72rem; border: 1px solid var(--line-strong);
  border-radius: 2px; padding: .05rem .34rem; color: var(--muted); white-space: nowrap;
}

.msg {
  font-family: var(--sans); font-size: .9rem; padding: .8rem 1rem; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft);
}
.msg--warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); color: var(--warn); }
.msg--ok { border-color: var(--accent); color: var(--accent); }

/* ---------- Pie --------------------------------------------------------- */

.foot {
  border-top: 1px solid var(--line); margin-top: clamp(3rem, 8vw, 5rem);
  padding: 1.5rem var(--pad) 2.5rem;
}
.foot__in {
  max-width: 1120px; margin: 0 auto; display: flex; gap: 1rem; flex-wrap: wrap;
  font-family: var(--sans); font-size: .85rem; color: var(--muted);
}
.foot__in a { color: var(--muted); }

/* ---------- Entrada de página (una sola secuencia) --------------------- */

@media (prefers-reduced-motion: no-preference) {
  .enter > * { animation: rise .55s cubic-bezier(.2,.7,.3,1) backwards; }
  .enter > *:nth-child(1) { animation-delay: .02s; }
  .enter > *:nth-child(2) { animation-delay: .1s; }
  .enter > *:nth-child(3) { animation-delay: .18s; }
  @keyframes rise { from { opacity: 0; transform: translateY(10px); } }
}

/* ---------- Administración --------------------------------------------- */

.admin { max-width: 880px; }
.admin fieldset {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  padding: 1.1rem 1.2rem 1.4rem; margin: 0 0 1.2rem;
}
.admin legend {
  font-family: var(--sans); font-weight: 600; font-size: .95rem; padding: 0 .4rem;
  color: var(--accent);
}
.grid2 { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.f { display: flex; flex-direction: column; gap: .3rem; }
.f label { font-family: var(--sans); font-size: .82rem; color: var(--muted); }
.f input, .f textarea, .f select {
  font-family: var(--sans); font-size: .95rem; padding: .5rem .65rem; color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--paper);
  width: 100%;
}
.f textarea { min-height: 9rem; font-family: var(--serif); line-height: 1.55; resize: vertical; }
.f--wide { grid-column: 1 / -1; }
.rep { border-top: 1px solid var(--line); padding: .9rem 0 .2rem; }
.rep:first-of-type { border-top: 0; }
.rep__bar { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.rep__bar strong { font-family: var(--sans); font-size: .85rem; color: var(--muted); margin-right: auto; }
.bar-actions {
  position: sticky; bottom: 0; background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(6px); border-top: 1px solid var(--line);
  padding: .8rem 0; display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; z-index: 5;
}
.bar-actions .spacer { margin-left: auto; }
code, .mono { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: .88em; }

/* ---------- docencia ----------------------------------------------------- */

.teach-y + .teach-y { margin-top: 1.6rem; }
.teach-y h3 {
  font-size: 1rem; color: var(--muted); font-variant-numeric: tabular-nums;
  padding-bottom: .35rem; border-bottom: 1px solid var(--line); margin-bottom: .5rem;
}
.stack .badge { margin-left: .35rem; vertical-align: 1px; }
.mono-area {
  font-family: "IBM Plex Mono", ui-monospace, monospace !important;
  font-size: .82rem !important; line-height: 1.7; white-space: pre; overflow-x: auto;
}

/* ---------- selector de destacados y estrella --------------------------- */

.star { color: var(--accent); }

.stars { border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--paper); }
.stars .field { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.stars__list { max-height: 22rem; overflow-y: auto; }
.star {
  display: grid; grid-template-columns: 1.4rem minmax(0, 1fr) auto; gap: .5rem; align-items: center;
  padding: .45rem .7rem; border-top: 1px solid var(--line);
  font-family: var(--sans); font-size: .88rem; cursor: pointer;
}
.star:first-child { border-top: 0; }
.star:hover { background: var(--accent-wash); }
.star input { display: none; }
.star__i { color: var(--muted); font-size: 1.05rem; text-align: center; }
.star--on .star__i { color: var(--accent); }
.star__t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.star__m { color: var(--muted); font-size: .8rem; white-space: nowrap; }
@media (max-width: 620px) { .star__m { display: none; } }
