/* ============================================================
   sandeval.dev — sistema de diseño
   Estructura y proporciones inspiradas en portafolios editoriales
   de columna única. Identidad propia: magenta + 35mm.
   ============================================================ */

:root {
  --bg:            #fbfaf9;
  --fg:            #0c0a09;
  --muted:         #7c6d67;
  --faint:         #786c67;
  --border:        #e8e4e3;
  --accent:        #e8e4e3;
  --border-strong: #d8d2d0;
  --highlight:     #a600b5;   /* ← único token de identidad. Cámbialo aquí y cambia todo el sitio. */
  --surface:       #f3f1f1;
  --strip:         #1d1816;
  --ok:            #4a7c59;

  --max:     840px;   /* contenedor (max-w-210) */
  --gutter:  16px;
  --measure: 66ch;    /* medida de lectura */
  --nav-h:   68px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg:            #0c0a09;
  --fg:            #fbfaf9;
  --muted:         #aba09c;
  --faint:         #a49790;
  --border:        #ffffff1a;
  --accent:        #2b2422;
  --border-strong: #ffffff2e;
  --highlight:     #e12afb;
  --surface:       #1d1816;
  --strip:         #f3f1f1;
  --ok:            #7fa98b;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif;
  font-size: 17px;          /* 1.0625rem */
  line-height: 1.7;
  letter-spacing: -.005em;
  padding-top: 88px;       /* pt-22 */
  padding-bottom: 16px;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  transition: background .2s ease, color .2s ease;
}

::selection { background: var(--highlight); color: #fff; }

.mono {
  font-family: 'Geist Mono', ui-monospace, 'JetBrains Mono', monospace;
  font-feature-settings: 'tnum' 1;
}

/* ───────────────────────── nav ───────────────────────── */

.nav {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, var(--max));
  z-index: 60;
  background: color-mix(in oklab, var(--bg) 80%, transparent);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.nav-in {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.brand { display: block; flex-shrink: 0; margin-top: 2px; }
.brand-dot {
  display: block;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: radial-gradient(circle at 28% 24%, rgb(232 121 249) 0%, rgb(192 38 211) 38%, rgb(124 58 237) 72%, rgb(49 46 129) 100%);
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--accent);
}
.nav-links a {
  font-size: 14px;
  line-height: 20px;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 8px;
  min-width: 44px;
  text-align: center;
  border-radius: 999px;
  transition: color .15s, background .15s;
}
.nav-links a:hover { color: var(--fg); }
.nav-links a[aria-current="page"] { color: var(--fg); background: var(--bg); }

.icon-btn {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border: 0; background: transparent; cursor: pointer;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  transition: color .15s, background .15s;
}
.icon-btn:hover { color: var(--fg); background: var(--surface); }
.icon-btn svg {
  width: 20px; height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible { outline: 2px solid var(--highlight); outline-offset: 4px; }
.skip-link {
  position: fixed;
  top: 8px;
  left: 16px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--bg);
  color: var(--fg);
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto 64px;
  padding: 0 var(--gutter);
  font-size: 17px;
  line-height: 1.7;
  font-weight: 500;
  display: flex;
  flex-direction: column;
}
.site-header a { color: var(--fg); text-decoration: none; }
.site-header p { color: var(--muted); margin: 0; max-width: none; }

/* ───────────────────────── layout ───────────────────────── */

main {
  flex: 1;
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--gutter);
  min-width: 0;
  scroll-margin-top: 88px;
  animation: page-in .3s cubic-bezier(.65, .05, .36, 1) both;
}
@keyframes page-in {
  from { transform: translateY(7px); filter: blur(2px); }
  to   { transform: translateY(0);   filter: blur(0); }
}

.measure { max-width: var(--measure); }

/* ───────────────────────── retrato ───────────────────────── */

.portrait-wrap { width: 100%; max-width: 752px; margin: 0 auto 40px; }
.portrait {
  position: relative;
  isolation: isolate;
  width: 160px;
  aspect-ratio: 1;
}
.portrait-glow {
  position: absolute;
  inset: 0;
  transform: scale(1.05);
  border-radius: 6px;
  filter: blur(16px) saturate(1.5);
  opacity: .65;
  pointer-events: none;
}
.portrait-img {
  position: relative;
  z-index: 1;
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}
/* marcador mientras no hay foto real */
.portrait-empty {
  position: relative;
  z-index: 1;
  width: 100%; height: 100%;
  border-radius: 6px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}

/* ───────────────────────── tipografía ───────────────────────── */

/* Medidas tomadas del CSS de referencia:
   h1-h3 20/28 medium, tracking -.025em, max 56ch, centrados
   p 66ch, margin-block 12, line-height 1.65 · sección 65ch */
h1 {
  font-size: 20px;
  line-height: 1.4;
  font-weight: 500;
  letter-spacing: -.025em;
  text-wrap: balance;
  width: 100%;
  max-width: 56ch;
  margin: 12px auto;
}

.prose p, main > p {
  color: var(--muted);
  text-wrap: pretty;
  width: 100%;
  max-width: 66ch;
  margin: 12px auto;
  line-height: 1.65;
}

a.link {
  color: var(--highlight);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 1px;
}
a.link:hover { text-decoration: underline; text-underline-offset: 2px; }
a.link svg { width: 1em; height: 1em; fill: currentColor; }

a.dashed {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
a.dashed:hover { color: var(--highlight); }

/* ───────────────────────── secciones ───────────────────────── */

.section {
  width: 100%;
  max-width: 65ch;
  margin: 80px auto 0;
  border-top: 1px solid var(--border);
  padding-top: 32px;
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.section-head h2 {
  font-size: 20px;
  line-height: 1.4;
  font-weight: 500;
  letter-spacing: -.025em;
  margin: 0;
  max-width: none;
}
.section-meta {
  font-size: 14px;
  line-height: 1.43;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color .15s;
}
a.section-meta:hover { color: var(--highlight); }

ol.list, ul.list { list-style: none; }

/* ── item de proyecto ── */
.proj {
  display: grid;
  gap: 8px;
  padding: 20px 0;
  text-decoration: none;
  color: inherit;
}
@media (min-width: 640px) {
  .proj { grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 32px; }
}
.proj-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.proj-title h3 {
  font-size: 18px;
  line-height: 1.555;
  font-weight: 500;
  letter-spacing: -.025em;
  margin: 0;
  width: fit-content;
  transition: color .18s;
}
.proj:hover .proj-title h3 { color: var(--highlight); }
.proj-title svg {
  width: 19px; height: 19px;
  fill: currentColor;
  color: var(--faint);
  transition: transform .2s, color .2s;
}
.proj:hover .proj-title svg {
  transform: translate(2px,-2px);
  color: var(--fg);
}
.proj p {
  font-size: 14px;
  line-height: 1.43;
  color: var(--muted);
  margin: 4px 0 0;
  max-width: 100%;
}

/* ── item de nota / post ── */
.note {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.note a {
  display: block;
  padding: 8px 0;
  text-decoration: none;
  flex: 1;
  min-width: 0;
}
.note h3 {
  font-size: 16px;
  line-height: 1.5;
  font-weight: 400;
  letter-spacing: -.025em;
  color: var(--muted);
  margin: 0;
  max-width: none;
  transition: color .15s;
}
.note:hover h3 { color: var(--highlight); text-decoration: underline; text-underline-offset: 3px; }
.note > svg { width: 1em; height: 1em; fill: currentColor; color: var(--faint); flex-shrink: 0; }
.note:hover > svg { color: var(--highlight); }
.note time {
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
  letter-spacing: .04em;
}

/* ── fila de blog (página completa) ── */
.post-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}
@media (min-width: 640px) {
  .post-row { grid-template-columns: 86px minmax(0,1fr); gap: 24px; align-items: baseline; }
}
.post-row:hover h3 { color: var(--highlight); }
.post-row time {
  font-family: 'Geist Mono', monospace;
  font-size: 11.5px;
  color: var(--faint);
  letter-spacing: .04em;
}
.post-row h3 {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -.02em;
  transition: color .18s;
}
.post-row p {
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
  margin-top: 4px;
  max-width: 58ch;
}

/* ───────────────────────── quests ───────────────────────── */

.quest {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}
@media (min-width: 640px) {
  .quest { grid-template-columns: 22px minmax(0,1fr) auto; gap: 16px; align-items: start; }
}
.quest-mark {
  width: 15px; height: 15px;
  border-radius: 4px;
  border: 1.5px solid var(--border-strong);
  margin-top: 4px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.quest-mark svg { width: 10px; height: 10px; fill: #fff; opacity: 0; }
.quest.done .quest-mark { background: var(--ok); border-color: var(--ok); }
.quest.done .quest-mark svg { opacity: 1; }
.quest.active .quest-mark { border-color: var(--highlight); }
.quest.active .quest-mark::after {
  content: '';
  width: 7px; height: 7px;
  border-radius: 2px;
  background: var(--highlight);
}
.quest h3 {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -.02em;
}
.quest.done h3 { color: var(--muted); }
.quest p {
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
  margin-top: 3px;
  max-width: 56ch;
}
.quest-meta {
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  letter-spacing: .05em;
  color: var(--faint);
  white-space: nowrap;
  text-transform: uppercase;
}
.quest-stack {
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  color: var(--faint);
  margin-top: 8px;
  letter-spacing: .04em;
}

/* barra de progreso de grupo */
.quest-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.qp-track {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
}
.qp-fill { height: 100%; background: var(--highlight); border-radius: 2px; }
.qp-label {
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  color: var(--faint);
  letter-spacing: .06em;
}

/* ───────────────────────── artículo ───────────────────────── */

.article-head { margin-bottom: 40px; max-width: var(--measure); }
.draft-notice {
  border-left: 2px solid var(--highlight);
  padding: 8px 16px;
  margin-bottom: 32px;
  color: var(--muted);
  background: var(--surface);
  font-size: 14px;
}
.article-back {
  font-size: 17px;
  color: var(--highlight);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 24px;
}
.article-back:hover { text-decoration: underline; text-underline-offset: 2px; }
.article-back svg { width: 1em; height: 1em; fill: currentColor; }

.article-meta {
  font-size: 14px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}
.article-head h1 { margin-bottom: 14px; }

.article { max-width: var(--measure); }
.article p { color: var(--muted); margin-bottom: 20px; }
.article h2 {
  font-size: 21px;
  font-weight: 500;
  letter-spacing: -.02em;
  color: var(--fg);
  margin: 42px 0 14px;
}
.article ul, .article ol { margin: 0 0 20px 20px; color: var(--muted); }
.article li { margin-bottom: 8px; }
.article strong { color: var(--fg); font-weight: 600; }
.article blockquote {
  border-left: 2px solid var(--highlight);
  padding-left: 18px;
  margin: 26px 0;
  color: var(--fg);
  font-size: 17px;
}
.article code {
  font-family: 'Geist Mono', monospace;
  font-size: .88em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}
.article hr { border: 0; border-top: 1px solid var(--border); margin: 42px 0; }

/* ───────────────────────── footer ───────────────────────── */

footer {
  max-width: var(--max);
  width: 100%;
  margin: 96px auto 0;
  padding: 0 var(--gutter);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  font-size: 14px;
  line-height: 1.43;
  color: var(--muted);
}
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--highlight); }
.footer-info { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; margin-top: 14px; }
.foot-links { display: flex; gap: 0; }
.theme-picker {
  display: flex;
  padding: 4px;
  border-radius: 999px;
  background: var(--accent);
}
.theme-picker .icon-btn { width: 28px; height: 28px; border-radius: 50%; }
.theme-picker .icon-btn svg { width: 16px; height: 16px; }
.theme-picker .icon-btn:hover { background: var(--accent); color: var(--fg); }
.theme-picker [aria-pressed="true"] { background: var(--bg); color: var(--fg); }

@media (max-width: 640px) {
  .section { margin-top: 60px; }
  .quest { grid-template-columns: 20px minmax(0, 1fr); gap: 6px 12px; }
  .quest-meta { grid-column: 2; }
  footer { margin-top: 72px; }
  .foot-links { flex-wrap: wrap; justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
