/* mfernandezm.com. Dirección: tipografía sola. Tokens primero, todo lo demás los usa. */
:root {
  --font-display: "Libre Franklin", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-text: "Source Serif 4", Georgia, "Times New Roman", serif;

  --pad: 24px;
  --gap-section: clamp(88px, 12vw, 200px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --step-small: clamp(0.875rem, 0.85rem + 0.1vw, 0.9375rem);
  --step-body: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
  --step-lead: clamp(1.25rem, 1.1rem + 0.7vw, 1.75rem);
  --step-head: clamp(1.875rem, 1.2rem + 3.4vw, 5rem);
  --step-title: clamp(1.625rem, 1rem + 2.6vw, 3.5rem);
  --step-hero: clamp(3.2rem, 14.5vw, 15rem);
}

:root, [data-theme="dark"] {
  --bg: #0a0f1a;
  --surface: #121a2b;
  --ink: #eaf0fa;
  --muted: #a1b0c8;
  --accent: #2f73ff;
  --accent-ink: #04101f;
  --hl-a: #7aa7ff;
  --hl-b: #c9dcff;
  --hl-c: #ff9b85;
  --hl-ink: #04101f;
  --inv-bg: #eaf0fa;
  --inv-ink: #0a0f1a;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #eef2f9;
  --surface: #e0e7f3;
  --ink: #0a0f1a;
  --muted: #44526a;
  --accent: #1d4ff5;
  --accent-ink: #ffffff;
  --hl-a: #9dbcff;
  --hl-b: #cfe0ff;
  --hl-c: #ffb4a3;
  --hl-ink: #04101f;
  --inv-bg: #0a0f1a;
  --inv-ink: #eaf0fa;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--step-body);
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent); color: var(--accent-ink); }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-underline-offset: 0.2em; }
h1, h2, h3, p, ul, ol { margin: 0; }
ul { padding: 0; list-style: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }

.skip { position: absolute; left: var(--pad); top: -80px; background: var(--accent); color: var(--accent-ink);
  padding: 10px 14px; font-family: var(--font-display); z-index: 100; }
.skip:focus { top: 12px; }

h1, h2, h3, .btn, .chip, nav, .wordmark, .r-date, .r-min, .p-name, .contact-mail, label {
  font-family: var(--font-display);
}
h1, h2 { font-weight: 700; letter-spacing: -0.035em; line-height: 0.98; text-wrap: balance; }
h2 { font-size: var(--step-head); }

/* ------------------------------------------------------------ cabecera */
.top {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 18px var(--pad); font-size: 15px; font-weight: 500;
}
.top a { text-decoration: none; }
.wordmark { font-weight: 700; letter-spacing: -0.02em; }
.top nav { display: flex; align-items: center; gap: clamp(14px, 3vw, 32px); }
.top nav a { transition: color 0.2s; }
.top nav a:hover, .top nav a[aria-current="page"] { color: var(--accent); }
.theme-toggle {
  font: inherit; font-weight: 500; color: inherit; background: var(--surface); border: 0;
  padding: 6px 12px; cursor: pointer; transition: background 0.2s, color 0.2s, transform 0.15s;
}
.theme-toggle:hover { background: var(--accent); color: var(--accent-ink); }
.theme-toggle:active { transform: scale(0.96); }

.progress { position: fixed; inset: 0 0 auto 0; height: 3px; background: var(--accent);
  transform: scaleX(0); transform-origin: 0 50%; z-index: 90; will-change: transform; }

/* --------------------------------------------------------------- botones */
.btn {
  display: inline-block; background: var(--accent); color: var(--accent-ink); font-weight: 700;
  font-size: 17px; letter-spacing: -0.01em; padding: 16px 28px; border: 0; border-radius: 0;
  text-decoration: none; cursor: pointer; transition: transform 0.2s var(--ease), opacity 0.2s;
}
.btn:hover { transform: translateY(-3px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn-inverse { background: var(--accent-ink); color: var(--accent); }
.chip {
  display: inline-block; background: var(--surface); color: var(--ink); font-size: 15px; font-weight: 500;
  padding: 8px 14px; border: 0; text-decoration: none; cursor: pointer; transition: background 0.2s, color 0.2s, transform 0.15s;
}
.chip span { color: var(--muted); margin-left: 4px; }
.chip:hover, .chip[aria-current="true"] { background: var(--accent); color: var(--accent-ink); }
.chip:hover span, .chip[aria-current="true"] span { color: inherit; }
.chip:active { transform: scale(0.97); }
.more { font-family: var(--font-display); font-weight: 500; }

/* ------------------------------------------------------------------ hero */
.hero {
  min-height: calc(100svh - 62px); padding: 0 var(--pad) 28px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.hero-title { display: flex; flex-direction: column; margin-top: 4vh; text-transform: uppercase;
  font-size: var(--step-hero); letter-spacing: -0.05em; line-height: 0.86; }
.mask { display: block; overflow: hidden; padding: 0.04em 0; }
.mask-in { display: block; }
.l2 { text-align: right; }
.hero-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-top: 18vh; }
.hero-foot p { font-size: var(--step-lead); line-height: 1.3; max-width: 30ch; }

/* ---------------------------------------------------------------- bandas */
.band { padding: var(--gap-section) var(--pad) 0; }
.sec-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: clamp(32px, 5vw, 64px); }
.sec-head p { max-width: 36ch; font-size: var(--step-body); color: var(--muted); }

/* sobre mí: dos columnas con resaltados */
.about-text {
  columns: 2; column-gap: 40px; text-align: justify; hyphens: auto;
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(1.375rem, 1.2rem + 0.9vw, 2rem); line-height: 1.2; letter-spacing: -0.015em;
}
.about-text strong { font-weight: 700; }
.hl { color: var(--hl-ink); padding: 0 0.12em; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.hl.a { background: var(--hl-a); } .hl.b { background: var(--hl-b); } .hl.c { background: var(--hl-c); }
.hl-link { text-decoration: none; }
.hl-link:hover .hl { filter: brightness(1.12); }

/* proyectos: nombres a gran escala */
.project-list li a {
  display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 0.7fr) minmax(0, 1.5fr);
  align-items: baseline; gap: 24px; padding: 14px 0; text-decoration: none;
}
.p-name { font-size: var(--step-head); font-weight: 700; letter-spacing: -0.04em; line-height: 1;
  transition: transform 0.4s var(--ease), color 0.2s; }
.p-kind { font-family: var(--font-display); font-weight: 500; font-size: var(--step-small); color: var(--muted); }
.p-text { font-size: var(--step-body); color: var(--muted); }
.project-list li a:hover .p-name, .project-list li a:focus-visible .p-name { transform: translateX(14px); color: var(--accent); }
.project-list li a:hover .p-text { color: var(--ink); }

/* listas de artículos: una sola medida */
.post-rows li a {
  display: grid; grid-template-columns: 9ch minmax(0, 1fr) minmax(0, 0.45fr) 6ch; gap: 24px;
  align-items: baseline; padding: 14px 0; text-decoration: none; font-size: var(--step-lead);
  transition: padding 0.3s var(--ease), color 0.2s;
}
.r-date, .r-min { font-size: var(--step-small); font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.r-min { text-align: right; }
.r-title { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; line-height: 1.12; }
.r-title small { display: block; font-family: var(--font-text); font-weight: 400; letter-spacing: 0;
  font-size: var(--step-body); color: var(--muted); margin-top: 6px; line-height: 1.4; }
.r-tags { font-size: var(--step-small); color: var(--muted); }
.post-rows li a:hover { padding-left: 14px; color: var(--accent); }
.post-rows li a:hover .r-title small, .post-rows li a:hover .r-date, .post-rows li a:hover .r-tags, .post-rows li a:hover .r-min { color: var(--ink); }

/* campo de acento */
.field-accent { background: var(--accent); color: var(--accent-ink); margin-top: var(--gap-section); padding-bottom: var(--gap-section); }
.field-accent .sec-head p { color: inherit; }
.radar-teaser { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 40px 64px; align-items: start; }
.radar-teaser h2 { grid-row: span 2; }
.radar-teaser ul { display: grid; gap: 18px; }
.radar-teaser li a { font-family: var(--font-display); font-weight: 700; font-size: var(--step-lead); letter-spacing: -0.02em; line-height: 1.15; }
.radar-teaser li span { display: block; font-size: var(--step-small); margin-top: 4px; }
.radar-teaser .btn { justify-self: start; }

/* suscripción */
.news-inner { max-width: 640px; margin-left: auto; display: grid; gap: 14px; }
.news-inner h2 { font-size: var(--step-lead); letter-spacing: -0.02em; line-height: 1.1; }
.news-inner p { color: var(--muted); }
.subscribe label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.subscribe-row { display: flex; gap: 12px; flex-wrap: wrap; }
.subscribe input[type="email"] {
  flex: 1 1 240px; min-width: 0; font: inherit; font-size: 17px; color: var(--ink); background: var(--surface);
  border: 2px solid transparent; padding: 14px 16px; border-radius: 0; transition: border-color 0.2s;
}
.subscribe input[type="email"]:focus { outline: none; border-color: var(--accent); }
.subscribe input::placeholder { color: var(--muted); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.subscribe-status { min-height: 1.5em; margin-top: 10px; font-size: var(--step-small); color: var(--ink); }

/* contacto */
.contact {
  margin-top: var(--gap-section); background: var(--inv-bg); color: var(--inv-ink);
  min-height: min(100svh, 900px); padding: 32px var(--pad); display: flex; flex-direction: column; justify-content: space-between;
}
.contact-ask { font-size: var(--step-lead); max-width: 20ch; line-height: 1.2; }
.contact-mail { font-size: min(4.6vw, 6.5rem); font-weight: 500; letter-spacing: -0.04em; line-height: 1;
  text-decoration: none; white-space: nowrap; transition: color 0.25s; margin-bottom: 12vh; }
.contact-mail:hover { color: var(--accent); }
[data-theme="dark"] .contact-mail:hover { color: #1d4ff5; }
.contact-foot { display: flex; justify-content: space-between; gap: 24px; font-size: var(--step-small); font-family: var(--font-display); font-weight: 500; }
.contact-links { display: flex; gap: 20px; }

/* ------------------------------------------------------ páginas interiores */
.page-head { padding: clamp(40px, 8vw, 120px) var(--pad) 0; }
.page-head h1 { font-size: clamp(3rem, 12vw, 11rem); letter-spacing: -0.05em; line-height: 0.9; }
.page-sub { margin-top: 24px; max-width: 34ch; font-size: var(--step-lead); line-height: 1.3; }
.blog-tools { padding: 48px var(--pad) 0; display: grid; gap: 20px; }
.search input {
  width: 100%; max-width: 520px; font: inherit; font-size: 17px; color: var(--ink); background: var(--surface);
  border: 2px solid transparent; padding: 14px 16px; border-radius: 0; transition: border-color 0.2s;
}
.search input:focus { outline: none; border-color: var(--accent); }
.search label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.blog-list { padding: 32px var(--pad) 0; }
.empty { color: var(--muted); padding: 24px 0; }

/* artículo */
.post-head { padding: clamp(32px, 6vw, 88px) var(--pad) 0; max-width: 1200px; }
.post-meta { font-family: var(--font-display); font-weight: 500; font-size: var(--step-small); color: var(--muted); margin-bottom: 20px; }
.post-head h1 { font-size: var(--step-title); letter-spacing: -0.04em; line-height: 1; }
.post-summary { margin-top: 24px; max-width: 46ch; font-size: var(--step-lead); line-height: 1.3; }
.post-tags { margin-top: 24px; display: flex; flex-wrap: wrap; gap: 10px; }
.post-grid { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 70ch); gap: 48px; padding: clamp(48px, 7vw, 96px) var(--pad) 0; }
.post-grid:not(:has(.toc)) { grid-template-columns: minmax(0, 70ch); margin-left: 0; }
.post-grid:has(.toc) .prose { grid-column: 2; }
.toc { grid-column: 1; grid-row: 1; align-self: start; position: sticky; top: 24px; font-size: var(--step-small); }
.toc p { font-family: var(--font-display); font-weight: 700; margin-bottom: 10px; }
.toc li { margin-bottom: 8px; line-height: 1.35; }
.toc a { color: var(--muted); text-decoration: none; transition: color 0.2s; }
.toc a:hover { color: var(--accent); }

.prose { font-size: var(--step-body); line-height: 1.65; }
.prose > * + * { margin-top: 1.25em; }
.prose h2 { font-size: var(--step-lead); letter-spacing: -0.025em; line-height: 1.1; margin-top: 2.2em; scroll-margin-top: 24px; }
.prose h3 { font-size: 1.15em; margin-top: 1.8em; }
.prose a { color: var(--accent); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose ul { list-style: disc; } .prose ol { list-style: decimal; }
.prose li + li { margin-top: 0.4em; }
.prose code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.88em; background: var(--surface); padding: 0.12em 0.4em; }
.prose pre, .prose .highlight { margin-left: 0; }
.prose .highlight { background: var(--surface); overflow-x: auto; padding: 20px 22px; }
.prose .highlight pre { margin: 0; line-height: 1.55; font-size: 0.86em; }
.prose .highlight code { background: none; padding: 0; font-size: inherit; }
.prose blockquote { margin-left: 0; background: var(--surface); padding: 18px 22px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 0.95em; }
.prose th, .prose td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--surface); }
.prose th { font-family: var(--font-display); }

.share { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 56px var(--pad) 0; }
.share span { font-family: var(--font-display); font-weight: 700; margin-right: 8px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: var(--gap-section) var(--pad) 0; }
.pager a { font-family: var(--font-display); font-weight: 700; font-size: var(--step-lead); letter-spacing: -0.02em; line-height: 1.15; text-decoration: none; transition: color 0.2s; }
.pager a:hover { color: var(--accent); }
.pager a span { display: block; font-size: var(--step-small); font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.pager .right { text-align: right; grid-column: 2; }

/* radar */
.feed { display: grid; gap: clamp(32px, 4vw, 56px); max-width: 900px; }
.feed-meta { font-family: var(--font-display); font-weight: 500; font-size: var(--step-small); color: var(--muted); margin-bottom: 8px; }
.feed-text { font-size: var(--step-lead); line-height: 1.3; margin-bottom: 10px; }
.radar-block + .radar-block { margin-top: 0; }
.reads { display: grid; gap: clamp(24px, 3vw, 40px); }
.reads li { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.5fr) minmax(0, 1.2fr); gap: 24px; align-items: baseline; }
.read-title { font-family: var(--font-display); font-weight: 700; font-size: var(--step-lead); letter-spacing: -0.02em; line-height: 1.15; }
.read-src { font-family: var(--font-display); font-weight: 500; font-size: var(--step-small); }

/* vídeos */
.videos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(32px, 4vw, 56px) clamp(24px, 3vw, 48px); }
.video-thumb { display: block; aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface); position: relative; }
.video-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s var(--ease); }
.video-thumb:hover img, .video-thumb:focus-visible img { transform: scale(1.04); }
.video-thumb iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.videos h3 { font-size: var(--step-lead); letter-spacing: -0.02em; line-height: 1.15; margin-top: 16px; }
.video-meta { font-family: var(--font-display); font-weight: 500; font-size: var(--step-small); color: var(--muted); margin-top: 6px; }
.video-note { margin-top: 10px; }
.news-rows li a { grid-template-columns: 9ch minmax(0, 1fr) minmax(0, 0.4fr) 3ch; }

/* sobre mí */
.about-body .prose { max-width: 60ch; font-size: var(--step-lead); line-height: 1.4; }
.project-detail { display: grid; gap: clamp(40px, 5vw, 72px); }
.project-detail li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 8px 48px; scroll-margin-top: 24px; }
.project-detail h3 { font-size: var(--step-head); letter-spacing: -0.04em; line-height: 1; grid-row: span 3; }
.pd-kind, .pd-stack { font-family: var(--font-display); font-weight: 500; font-size: var(--step-small); color: var(--muted); }
.pd-text { font-size: var(--step-lead); line-height: 1.3; }

/* pie */
.foot { margin-top: var(--gap-section); background: var(--surface); padding: 40px var(--pad) 20px; min-height: min(80svh, 760px);
  display: grid; grid-template-rows: auto 1fr auto auto; gap: 24px; }
.foot-cols { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 32px; font-size: var(--step-small); line-height: 1.6; }
.foot-cols .strong { font-weight: 600; }
.foot-cols li:not(.strong) { color: var(--muted); }
.foot-cols a { text-decoration: none; transition: color 0.2s; overflow-wrap: anywhere; }
.foot-cols a:hover { color: var(--accent); }
.foot-mark { width: 100%; height: auto; align-self: end; fill: var(--ink); font-family: var(--font-display); font-weight: 700; font-size: 110px; }
.legal { font-size: var(--step-small); color: var(--muted); }

/* ---------------------------------------------------------------- movimiento */
.js .mask-in { transform: translateY(108%); }
.js.ready .mask-in { transform: none; transition: transform 0.9s var(--ease); }
.js.ready .l2 .mask-in { transition-delay: 0.11s; }
.js [data-reveal] { opacity: 0; transform: translateY(24px); }
.js [data-reveal].in { opacity: 1; transform: none; transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); transition-delay: calc(var(--i, 0) * 70ms); }
.js .hero-foot[data-reveal].in { transition-delay: 0.5s; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .mask-in, .js [data-reveal] { transform: none; }
  .js.ready .mask-in, .js [data-reveal].in { transition: opacity 0.3s; }
  .btn:hover, .p-name, .post-rows li a { transition: none; }
  .project-list li a:hover .p-name { transform: none; }
  .post-rows li a:hover { padding-left: 0; }
}

/* ------------------------------------------------------------------- móvil */
@media (max-width: 860px) {
  :root { --pad: 16px; }
  .top { gap: 8px; font-size: 14px; }
  .top a, .theme-toggle { white-space: nowrap; }
  .top nav { gap: 12px; }
  .theme-toggle { padding: 6px 10px; }
  .hero { padding-bottom: 20px; }
  .hero-title { font-size: 17vw; margin-top: 6vh; }
  .l2 { text-align: left; }
  .hero-foot { flex-direction: column; align-items: stretch; margin-top: 12vh; gap: 20px; }
  .hero-foot p { font-size: 18px; max-width: 28ch; }
  .hero-foot .btn { text-align: center; }
  .about-text { columns: 1; text-align: left; hyphens: manual; font-size: 20px; line-height: 1.25; }
  .project-list li a { grid-template-columns: 1fr; gap: 4px; padding: 16px 0; }
  .post-rows li a { grid-template-columns: 1fr auto; gap: 4px 16px; font-size: 20px; }
  .r-date { grid-column: 1; grid-row: 2; } .r-title { grid-column: 1 / -1; grid-row: 1; }
  .r-tags { display: none; } .r-min { grid-column: 2; grid-row: 2; }
  .news-rows .r-tags { display: block; grid-column: 1; grid-row: 3; }
  .radar-teaser { grid-template-columns: 1fr; }
  .radar-teaser h2 { grid-row: auto; }
  .news-inner { margin-left: 0; }
  .contact { min-height: 86svh; }
  .contact-mail { font-size: 5.1vw; }
  .contact-foot { flex-direction: column; }
  .post-grid, .post-grid:not(:has(.toc)) { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .post-grid:has(.toc) .prose { grid-column: 1; }
  .toc { position: static; grid-row: auto; }
  .reads li { grid-template-columns: 1fr; gap: 6px; }
  .videos { grid-template-columns: 1fr; }
  .news-rows li a { grid-template-columns: 1fr auto; }
  .project-detail li { grid-template-columns: 1fr; }
  .project-detail h3 { grid-row: auto; }
  .foot-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 16px; }
  .pager { grid-template-columns: 1fr; }
  .pager .right { grid-column: 1; text-align: left; }
}
