/* Rexvalentia — hoja de estilos del sitio público.
   Columna de lectura (~42rem) bajo una cabecera fina. La sierra del logo es el
   único elemento expresivo; el resto se apoya en tipografía, espacio y líneas. */

:root {
  --bg: #F5F6F3;          /* piedra clara, sesgo verde frío */
  --surface: #EBEDE8;
  --fg: #1B201D;
  --muted: #5B655F;
  --faint: #7D8780;
  --line: #D6DAD3;
  --accent: #3B6650;      /* encina */
  --accent-soft: rgba(59, 102, 80, .10);
  --f-ui: "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  --f-read: "Newsreader", Georgia, "Times New Roman", serif;
  --f-code: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --measure: 42rem;
  --wide: 64rem;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #121614;
  --surface: #1A1F1C;
  --fg: #E3E7E2;
  --muted: #98A39C;
  --faint: #6F7973;
  --line: #29302C;
  --accent: #8DB79A;
  --accent-soft: rgba(141, 183, 154, .12);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font: 400 1rem/1.6 var(--f-ui);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.015em; text-wrap: balance; }
p { margin: 0; }
.wrap { width: 100%; max-width: var(--wide); margin-inline: auto; padding-inline: 20px; }
.read { max-width: var(--measure); }
.center { margin-inline: auto; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- cabecera ---------- */
.site-head {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-head .wrap { display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand svg { width: 34px; height: 20px; flex: none; }
.brand span { font-size: .8125rem; font-weight: 500; letter-spacing: .32em; text-transform: uppercase; }
.nav { display: flex; gap: 22px; margin-left: auto; align-items: center; }
.nav a { font-size: .9375rem; color: var(--muted); padding-block: 4px; border-bottom: 1px solid transparent; transition: color .15s; }
.nav a:hover { color: var(--fg); }
.nav a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--fg); }
.tools { display: flex; gap: 6px; }
.icon-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px;
  background: none; border: 1px solid var(--line); border-radius: 7px;
  color: var(--muted); font: 400 .8125rem var(--f-ui); cursor: pointer;
  transition: color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--fg); border-color: var(--faint); }
.icon-btn svg { width: 15px; height: 15px; }
kbd { font: 400 .6875rem var(--f-code); color: var(--faint); }
[data-theme="dark"] .icon-moon, :root:not([data-theme="dark"]) .icon-sun { display: none; }
@media (max-width: 560px) {
  .site-head .wrap { gap: 14px; }
  .brand span { display: none; }
  .nav { gap: 16px; }
  .icon-btn kbd, .icon-btn .lbl { display: none; }
}

/* ---------- sierra (firma visual) ---------- */
.ridge { display: block; width: 100%; height: auto; overflow: visible; }
.ridge path { fill: none; stroke: currentColor; stroke-width: 1.25; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.ridge .tower { stroke: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .ridge.draw path { stroke-dasharray: 1; animation: draw 1.6s cubic-bezier(.6, 0, .2, 1) both; }
  .ridge.draw .tower { animation-delay: 1.1s; animation-duration: .8s; }
}
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }

/* ---------- estructura ---------- */
main.wrap { flex: 1 0 auto; padding-block: 56px 96px; }
.section-title {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  font-size: 1rem; font-weight: 600;
  padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.section-title a { font-size: .875rem; font-weight: 400; color: var(--muted); }
.section-title a:hover { color: var(--accent); }
.block { margin-top: 72px; }
.page-head h1 { font-size: clamp(2rem, 4.5vw, 2.75rem); letter-spacing: -0.03em; line-height: 1.1; }
.page-head .intro { margin-top: 10px; color: var(--muted); font: 400 1.125rem/1.55 var(--f-read); max-width: 36rem; }
.page-head .intro p + p { margin-top: .6em; }
.crumbs { font-size: .875rem; color: var(--faint); display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.crumbs a:hover { color: var(--accent); }
.empty-state { padding: 40px 0; color: var(--muted); }

/* ---------- inicio ---------- */
.hero { display: grid; gap: 28px; }
.hero h1 { font-size: clamp(2.5rem, 6vw, 4rem); line-height: 1.02; letter-spacing: -0.035em; }
.hero .lede { font: 400 clamp(1.15rem, 2vw, 1.35rem)/1.5 var(--f-read); color: var(--muted); max-width: 34rem; }
.hero .lede p + p { margin-top: .6em; }
.hero .lede b, .hero .lede strong { color: var(--fg); font-weight: 500; }
.hero .lede a { color: var(--fg); border-bottom: 1px solid var(--line); }
.hero-ridge { margin-top: 24px; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 18rem; gap: 64px; margin-top: 72px; }
.home-grid > :only-child { grid-column: 1 / -1; }
@media (max-width: 820px) { .home-grid { grid-template-columns: 1fr; gap: 48px; } }
.now dl { margin: 0; display: grid; gap: 18px; padding-top: 16px; }
.now dt { font-size: .8125rem; color: var(--faint); }
.now dd { margin: 2px 0 0; font-size: .9375rem; }
.now dd a { border-bottom: 1px solid var(--line); transition: color .15s, border-color .15s; }
.now dd a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- listas de entradas ---------- */
.posts { list-style: none; margin: 0; padding: 0; }
.posts a { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 4px 20px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.posts time { font-size: .875rem; color: var(--faint); font-variant-numeric: tabular-nums; padding-top: 2px; }
.posts h3 { font-size: 1.0625rem; font-weight: 500; line-height: 1.4; transition: color .15s; }
.posts a:hover h3 { color: var(--accent); }
.posts .cat { grid-column: 2; font-size: .8125rem; color: var(--muted); }
@media (max-width: 480px) {
  .posts a { grid-template-columns: 1fr; }
  .posts .cat { grid-column: 1; }
}
.year { font-size: .875rem; font-weight: 600; color: var(--faint); margin-top: 40px; padding-bottom: 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.year:first-child { margin-top: 0; }

/* ---------- blog: árbol de categorías ---------- */
.blog-layout { display: grid; grid-template-columns: 12rem minmax(0, 1fr); gap: 32px 56px; }
.blog-layout > .page-head { grid-column: 1 / -1; }
.tree { position: sticky; top: 84px; align-self: start; font-size: .9375rem; }
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul ul { margin: 2px 0 6px 10px; padding-left: 10px; border-left: 1px solid var(--line); }
.tree a { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; color: var(--muted); transition: color .15s; }
.tree a:hover { color: var(--fg); }
.tree a[aria-current="page"] { color: var(--accent); font-weight: 500; }
.tree .n { color: var(--faint); font-variant-numeric: tabular-nums; font-size: .8125rem; font-weight: 400; }
@media (max-width: 760px) {
  .blog-layout { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .tree { position: static; overflow-x: auto; margin-inline: -20px; padding-inline: 20px; scrollbar-width: none; }
  .tree > ul { display: flex; gap: 6px; }
  .tree ul ul, .tree li { display: contents; }
  .tree a { white-space: nowrap; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; }
  .tree a[aria-current="page"] { border-color: var(--accent); }
  .tree .n { display: none; }
}

.filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 28px; font-size: .875rem; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 6px 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.chip a { display: inline-flex; padding: 2px; border-radius: 99px; }
.chip svg { width: 12px; height: 12px; }
.subcats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 32px; }

/* ---------- artículo ---------- */
.article h1 { font-size: clamp(2.25rem, 5vw, 3.25rem); line-height: 1.08; letter-spacing: -0.03em; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 20px; font-size: .875rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.meta > * + *::before {
  content: ""; display: inline-block; width: 3px; height: 3px; border-radius: 50%;
  background: var(--faint); vertical-align: middle; margin-right: 20px; position: relative; top: -1px;
}
.article .prose { margin-top: 40px; }
.article-cover { margin: 36px 0 0; }
.article-cover img { display: block; width: 100%; border-radius: 6px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); }
.tag { font-size: .8125rem; color: var(--muted); padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; transition: color .15s, border-color .15s; }
.tag:hover, .tag[aria-current="page"] { color: var(--accent); border-color: var(--accent); }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 40px; }
.pager > * { display: grid; align-content: start; gap: 4px; padding: 16px 0; border-top: 1px solid var(--fg); }
.pager > :last-child { text-align: right; }
.pager small { font-size: .8125rem; color: var(--faint); }
.pager span { font-weight: 500; transition: color .15s; }
.pager a:hover span { color: var(--accent); }
.pager .is-empty { border-top-color: var(--line); }
.pager .is-empty span { color: var(--faint); font-weight: 400; }

/* ---------- texto largo (rich text y markdown) ---------- */
.prose { font: 400 1.1875rem/1.72 var(--f-read); }
/* El markdown llega envuelto en un <div>: el ritmo se aplica a cualquier profundidad. */
.prose :is(p, ul, ol, blockquote, pre, table, figure, hr, .codehilite) { margin-block: 0; }
.prose * + :is(p, ul, ol, blockquote, pre, table, figure, .codehilite) { margin-top: 1.1em; }
.prose :is(h2, h3, h4):first-child { margin-top: 0; }
.prose h2 {
  font: 600 1rem/1.4 var(--f-ui); letter-spacing: -0.01em;
  margin-top: 72px; padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.prose h3 { font: 600 1.0625rem/1.4 var(--f-ui); margin-top: 2em; }
.prose h4 { font: 600 1rem/1.4 var(--f-ui); margin-top: 1.6em; }
.prose :is(h2, h3, h4) + * { margin-top: .8em; }
.prose b, .prose strong { font-weight: 600; }
.prose a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.prose a:hover { text-decoration-color: currentColor; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: .4em; }
.prose li::marker { color: var(--faint); }
.prose blockquote { margin-inline: 0; padding-left: 1.1em; border-left: 2px solid var(--accent); color: var(--muted); font-style: italic; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin-block: 2.5em; }
.prose code { font: .82em var(--f-code); background: var(--surface); padding: .12em .35em; border-radius: 4px; }
.prose pre, .prose .codehilite {
  font: .8125rem/1.65 var(--f-code); background: var(--surface);
  padding: 16px 18px; border-radius: 6px; overflow-x: auto;
}
.prose .codehilite pre { padding: 0; margin: 0; background: none; }
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose img { border-radius: 6px; }
.prose table { width: 100%; border-collapse: collapse; font: .9375rem/1.5 var(--f-ui); display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); }
.prose th { font-weight: 600; }
.figure { margin: 2em 0; }
.figure img { display: block; width: 100%; border-radius: 6px; }
.figure figcaption { margin-top: 8px; font: 400 .875rem/1.5 var(--f-ui); color: var(--faint); }

/* ---------- sobre mí: experiencia ---------- */
.tl { list-style: none; margin: 24px 0 0; padding: 0; }
.tl li { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 24px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.tl li:last-child { border-bottom: 0; }
.tl .when { font-size: .875rem; color: var(--faint); font-variant-numeric: tabular-nums; padding-top: 3px; }
.tl .current { display: block; color: var(--accent); font-weight: 500; }
.tl h3 { font-size: 1.0625rem; font-weight: 600; }
.tl .role { font-size: .9375rem; color: var(--muted); }
.tl .desc { font: 400 1.0625rem/1.65 var(--f-read); margin-top: 10px; }
.tl .desc p + p { margin-top: .8em; }
.tl .stack { font-size: .8125rem; color: var(--faint); margin-top: 10px; }
@media (max-width: 560px) { .tl li { grid-template-columns: 1fr; gap: 6px; } }

/* ---------- sobre mí: apps ---------- */
.apps-intro { margin-top: 16px; color: var(--muted); font: 400 1.0625rem/1.65 var(--f-read); }
.apps-banner { margin-top: 20px; }
.apps-banner img { display: block; width: 100%; border-radius: 6px; }
.apps { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
.apps a { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--line); height: 100%; }
.apps img, .apps .mono { width: 44px; height: 44px; border-radius: 10px; }
.apps .mono { display: grid; place-items: center; background: var(--surface); font-weight: 600; }
.apps h3 { font-size: 1rem; font-weight: 600; transition: color .15s; }
.apps a:hover h3 { color: var(--accent); }
.apps .platform { margin-left: 6px; font: 400 .6875rem var(--f-code); letter-spacing: .02em; text-transform: uppercase; color: var(--faint); vertical-align: 1px; }
.apps p { font-size: .9375rem; color: var(--muted); line-height: 1.5; margin-top: 2px; }
@media (max-width: 640px) { .apps { grid-template-columns: 1fr; } }

/* ---------- paginación ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 40px; font-size: .9375rem; }
.pagination a { color: var(--muted); transition: color .15s; }
.pagination a:hover { color: var(--accent); }
.pagination .off { color: var(--line); }
.pagination .pos { font-size: .875rem; color: var(--faint); font-variant-numeric: tabular-nums; }

/* ---------- búsqueda ---------- */
.search-field { display: flex; align-items: center; gap: 10px; max-width: 32rem; padding: 0 14px; height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); transition: border-color .15s; }
.search-field:focus-within { border-color: var(--accent); }
.search-field svg { width: 16px; height: 16px; color: var(--faint); flex: none; }
.search-field input { flex: 1; min-width: 0; font: 400 1rem var(--f-ui); background: none; border: 0; outline: 0; color: var(--fg); }
.search-field input::-webkit-search-cancel-button { filter: grayscale(1); }
.result-count { margin: 20px 0 32px; font-size: .9375rem; color: var(--muted); }
.result-count strong { color: var(--fg); font-weight: 500; }

.search-dlg {
  border: 1px solid var(--line); border-radius: 12px; padding: 0;
  width: min(36rem, calc(100vw - 32px)); margin-top: 12vh;
  background: var(--bg); color: var(--fg);
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .35);
}
.search-dlg::backdrop { background: rgba(10, 14, 12, .45); }
.search-dlg form { display: flex; align-items: center; gap: 10px; padding: 14px 16px; }
.search-dlg svg { width: 16px; height: 16px; color: var(--faint); flex: none; }
.search-dlg input { flex: 1; min-width: 0; font: 400 1rem var(--f-ui); background: none; border: 0; outline: 0; color: var(--fg); }
.search-dlg p { padding: 10px 16px; border-top: 1px solid var(--line); font-size: .8125rem; color: var(--faint); }
@media (prefers-reduced-motion: no-preference) {
  .search-dlg[open] { animation: pop .16s cubic-bezier(.2, .8, .2, 1); }
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.985); } }

/* ---------- pie ---------- */
.site-foot { border-top: 1px solid var(--line); }
.site-foot .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 24px; padding-block: 28px; font-size: .875rem; color: var(--faint); }
.site-foot nav { display: flex; gap: 20px; }
.site-foot .foot-meta { display: flex; flex-direction: column; gap: 4px; }
.site-foot .privacy-note { margin: 0; font-size: .8125rem; }
.site-foot a { transition: color .15s; }
.site-foot a:hover { color: var(--fg); }

/* ---------- botones (páginas de error) ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line); font: 500 .9375rem var(--f-ui); color: var(--fg); background: none; cursor: pointer; transition: border-color .15s, background-color .15s; }
.btn:hover { border-color: var(--faint); }
.btn-primary { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.btn-primary:hover { background: color-mix(in srgb, var(--fg) 85%, var(--bg)); }

/* ---------- ajustes de ritmo entre piezas ---------- */
.prose.lead { margin-top: 28px; }
.search-page-form { margin-top: 24px; }
.section-title + .subcats { margin-top: 16px; }
.subcats + .section-title { margin-top: 24px; }
