/*
 * Identidad: azul cobalto de plano técnico + amarillo de señalización industrial (un solo uso: la banda de contacto).
 * Tipografía: una sola familia, Archivo, jugando con su eje de anchura: titulares muy condensados, texto a anchura normal.
 * Layout: columna izquierda alineada, filas de lista en vez de tarjetas, páginas de proyecto con demo a ancho completo.
 */
@font-face {
  font-family: "Archivo"; font-style: normal; font-display: swap;
  font-weight: 100 900; font-stretch: 62% 125%;
  src: url("fonts/archivo-latin-wdth-normal.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono"; font-style: normal; font-display: swap;
  font-weight: 100 800;
  src: url("fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
}
:root {
  --bg: #eef0f3;
  --surface: #ffffff;
  --sunken: #e3e6ec;
  --ink: #1a1f2b;
  --muted: #586073;
  --line: #cfd4de;
  --brand: #2337c6;
  --brand-ink: #ffffff;
  --brand-soft: #e1e5fb;
  --signal: #f2c230;
  --signal-ink: #1a1f2b;
  --alert: #c2410c;
  --alert-soft: #fbe6da;
  --ok: #1f7a3a;
  --warn: #9a5b00;
  --font: "Archivo", "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --s-sm: 0.875rem;
  --s-base: 1.0625rem;
  --s-md: 1.375rem;
  --s-lg: clamp(1.9rem, 1.4rem + 2vw, 2.75rem);
  --s-xl: clamp(3.4rem, 2rem + 7vw, 7.5rem);
  --measure: 66ch;
  --radius: 6px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151d; --surface: #1a1e29; --sunken: #0e1118; --ink: #e8eaf0; --muted: #9aa2b3;
    --line: #2b3140; --brand: #8d9bff; --brand-ink: #0d1030; --brand-soft: #232a52;
    --alert: #fb923c; --alert-soft: #3b2216; --ok: #5fc27a; --warn: #e9b44c; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12151d; --surface: #1a1e29; --sunken: #0e1118; --ink: #e8eaf0; --muted: #9aa2b3;
  --line: #2b3140; --brand: #8d9bff; --brand-ink: #0d1030; --brand-soft: #232a52;
  --alert: #fb923c; --alert-soft: #3b2216; --ok: #5fc27a; --warn: #e9b44c; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: var(--s-base); line-height: 1.6;
  font-variation-settings: "wdth" 100;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.05; text-wrap: balance; font-weight: 800; }
p, ul, dl { margin: 0; }
a { color: var(--brand); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 3px; }
img, canvas { max-width: 100%; }
.mono { font-family: var(--font-mono); }
.tabnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.wrap {
  max-width: 1160px; margin: 0 auto;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.condensed { font-stretch: 62%; font-variation-settings: "wdth" 62; letter-spacing: -0.01em; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--brand); color: var(--brand-ink); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }

/* ---------- Cabecera ---------- */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--bg); }
.site-head { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line); }
.site-head .wrap { display: flex; align-items: center; gap: 20px; min-height: 60px; }
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; white-space: nowrap; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 4px; background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; font-size: 0.8rem; font-weight: 800; font-stretch: 75%; font-variation-settings: "wdth" 75;
}
.site-nav { display: flex; gap: 2px; margin-left: auto; }
.site-nav a { text-decoration: none; color: var(--muted); padding: 8px 10px; border-radius: 4px; font-size: 0.95rem; font-weight: 600; }
.site-nav a:hover { color: var(--ink); background: var(--sunken); }
.site-nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--brand); border-radius: 0; }
.theme-toggle {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); display: grid; place-items: center; cursor: pointer; flex: none;
}
.theme-toggle svg { width: 18px; height: 18px; }
@media (max-width: 560px) {
  .site-head .wrap { gap: 8px; }
  .logo .full { display: none; }
  .site-nav a { padding: 8px 7px; font-size: 0.9rem; }
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; cursor: pointer;
  font: inherit; font-weight: 700; font-size: 0.95rem; line-height: 1;
  padding: 12px 18px; border-radius: var(--radius); border: 2px solid var(--ink); background: transparent; color: var(--ink);
}
.btn:hover { background: var(--ink); color: var(--bg); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.sm { padding: 7px 12px; font-size: 0.85rem; border-width: 1px; }
.btn[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--ink); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Estructura de página ---------- */
main { display: block; }
.section { padding-block: 64px; }
.section + .section { border-top: 1px solid var(--line); }
.section-title { font-size: var(--s-lg); margin-bottom: 28px; }
.section-title.condensed { font-size: calc(var(--s-lg) * 1.25); }
.lede { font-size: 1.2rem; max-width: 58ch; color: var(--muted); }
.page-head { padding-block: 56px 36px; }
.page-head h1 { font-size: var(--s-xl); line-height: 0.92; }
.page-head .lede { margin-top: 18px; }
.crumbs { font-size: var(--s-sm); color: var(--muted); margin-bottom: 18px; }
.crumbs a { color: var(--muted); }

/* ---------- Portada ---------- */
.hero { padding-block: 64px 56px; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 48px; align-items: end; }
.hero h1 { font-size: var(--s-xl); line-height: 0.88; text-transform: uppercase; }
.hero .intro { margin-top: 24px; font-size: 1.25rem; max-width: 44ch; }
.hero .actions { margin-top: 28px; }
.facts { border-left: 2px solid var(--brand); padding-left: 20px; display: grid; gap: 14px; }
.facts dt { font-size: var(--s-sm); color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; }
.available { display: inline-flex; align-items: center; gap: 8px; }
.available::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; gap: 32px; padding-block: 40px; } }

/* ---------- Lista de proyectos (filas) ---------- */
.rows { border-top: 2px solid var(--ink); }
.row {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr) auto; gap: 24px; align-items: center;
  padding-block: 22px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit;
}
.row:hover .row-name { color: var(--brand); }
.row-name { font-size: clamp(1.8rem, 1.3rem + 1.8vw, 2.6rem); font-weight: 800; line-height: 1; font-stretch: 70%; font-variation-settings: "wdth" 70; }
.row-desc { color: var(--muted); }
.row-desc strong { display: block; color: var(--ink); font-weight: 600; margin-bottom: 2px; }
.row-meta { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 760px) {
  .row { grid-template-columns: 1fr; gap: 8px; }
  .row-meta { justify-content: flex-start; }
}
.pill {
  display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap; background: var(--surface);
}
.pill.demo { border-color: var(--brand); color: var(--brand); }
.pill.wip { border-color: color-mix(in srgb, var(--alert) 50%, var(--line)); color: var(--alert); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.filter {
  font: inherit; font-size: 0.9rem; font-weight: 600; padding: 7px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.filter[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.empty { padding-block: 32px; color: var(--muted); }

/* ---------- Página de proyecto ---------- */
.project-head { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 48px; align-items: start; }
@media (max-width: 860px) { .project-head { grid-template-columns: 1fr; gap: 28px; } }
.spec { display: grid; gap: 16px; border-left: 2px solid var(--brand); padding-left: 20px; }
.spec dt { font-size: var(--s-sm); color: var(--muted); }
.spec dd { margin: 4px 0 0; }
.stack { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; list-style: none; }
.stack li { font-size: 0.85rem; padding: 3px 9px; border-radius: 4px; background: var(--sunken); }
.demo-wrap { background: var(--surface); border-block: 1px solid var(--line); }
.demo-wrap .section { padding-block: 40px 48px; }
.demo-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.demo-head h2 { font-size: var(--s-md); }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px; }
@media (max-width: 760px) { .two { grid-template-columns: 1fr; gap: 28px; } }
.two h3 { font-size: var(--s-md); margin-bottom: 12px; }
.ticks { padding: 0; list-style: none; display: grid; gap: 10px; max-width: var(--measure); }
.ticks li { padding-left: 22px; position: relative; }
.ticks li::before { content: ""; position: absolute; left: 0; top: 0.62em; width: 10px; height: 2px; background: var(--brand); }
.note { margin-top: 28px; padding: 14px 16px; background: var(--sunken); border-radius: var(--radius); font-size: 0.95rem; max-width: var(--measure); }

.flow { display: flex; align-items: stretch; flex-wrap: wrap; counter-reset: step; }
.flow li { list-style: none; flex: 1 1 160px; position: relative; padding: 16px 28px 16px 18px; background: var(--surface); border: 1px solid var(--line); margin: 0 -1px -1px 0; min-width: 0; }
.flow li b { display: block; font-size: 1.05rem; }
.flow li span { color: var(--muted); font-size: 0.9rem; }
.flow li:not(:last-child)::after {
  content: ""; position: absolute; right: -9px; top: 50%; width: 16px; height: 16px; z-index: 1;
  background: var(--bg); border-top: 2px solid var(--brand); border-right: 2px solid var(--brand); transform: translateY(-50%) rotate(45deg);
}
.flow { padding: 0; margin: 0; }
@media (max-width: 640px) {
  .flow { flex-direction: column; }
  .flow li:not(:last-child)::after { right: auto; left: 24px; top: auto; bottom: -9px; transform: rotate(135deg); }
}

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; border-top: 2px solid var(--ink); padding-top: 20px; }
.pager a { text-decoration: none; color: var(--ink); display: grid; gap: 2px; }
.pager a span { font-size: var(--s-sm); color: var(--muted); }
.pager a b { font-size: 1.4rem; font-stretch: 70%; font-variation-settings: "wdth" 70; }
.pager a:hover b { color: var(--brand); }
.pager .next { text-align: right; }

/* ---------- Experiencia ---------- */
.jobs { border-top: 2px solid var(--ink); }
.job { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; padding-block: 26px; border-bottom: 1px solid var(--line); }
.job .when { color: var(--muted); font-size: 0.95rem; }
.job h3 { font-size: 1.6rem; font-stretch: 75%; font-variation-settings: "wdth" 75; }
.job .role { color: var(--muted); margin-top: 2px; }
.job .ticks { margin-top: 14px; }
@media (max-width: 680px) { .job { grid-template-columns: 1fr; gap: 6px; } }
.edu { display: grid; gap: 0; border-top: 2px solid var(--ink); }
.edu-item { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; padding-block: 22px; border-bottom: 1px solid var(--line); }
.edu-item h3 { font-size: 1.25rem; }
.edu-item p { color: var(--muted); margin-top: 4px; max-width: var(--measure); }
@media (max-width: 680px) { .edu-item { grid-template-columns: 1fr; gap: 4px; } }

/* ---------- Banda de contacto (único uso del amarillo) ---------- */
.signal-band { background: var(--signal); color: var(--signal-ink); }
.signal-band .wrap { padding-block: 48px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center; }
.signal-band h2 { font-size: calc(var(--s-lg) * 1.2); font-stretch: 62%; font-variation-settings: "wdth" 62; text-transform: uppercase; line-height: 0.95; }
.signal-band p { margin-top: 10px; max-width: 52ch; }
.signal-band .btn { border-color: var(--signal-ink); color: var(--signal-ink); }
.signal-band .btn:hover { background: var(--signal-ink); color: var(--signal); }
@media (max-width: 700px) { .signal-band .wrap { grid-template-columns: 1fr; } }

.contact-list { border-top: 2px solid var(--ink); }
.contact-item { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; padding-block: 22px; border-bottom: 1px solid var(--line); align-items: baseline; }
.contact-item a { font-size: 1.3rem; font-weight: 700; word-break: break-word; }
@media (max-width: 680px) { .contact-item { grid-template-columns: 1fr; gap: 4px; } }

.site-foot { padding-block: 28px 44px; font-size: var(--s-sm); color: var(--muted); }
.site-foot .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.site-foot a { color: var(--muted); }

/* ---------- Componentes de las demos ---------- */
.label { font-size: var(--s-sm); color: var(--muted); font-weight: 600; }
.demo-banner { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 0.92rem; color: var(--muted); margin-bottom: 16px; }
.demo-banner .badge { font-size: 0.78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--ink); }
.demo-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; }
.demo-grid > *, .table-wrap { min-width: 0; }
@media (max-width: 800px) { .demo-grid { grid-template-columns: 1fr; } }
.stage { position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sunken); overflow: hidden; }
.stage canvas { display: block; width: 100%; touch-action: none; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.controls label { font-size: 0.88rem; color: var(--muted); display: inline-flex; gap: 8px; align-items: center; }
input[type="range"] { accent-color: var(--brand); }
.log {
  font-family: var(--font-mono); font-size: 0.75rem; line-height: 1.5; background: var(--sunken);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; height: 300px; overflow: auto;
  white-space: pre-wrap; word-break: break-word; margin-top: 6px;
}
.log .ev { padding-block: 5px; border-bottom: 1px dashed var(--line); }
.log .ev:last-child { border-bottom: 0; }
.log .k-enter { color: var(--ok); }
.log .k-exit, .log .k-alert { color: var(--alert); }
.log .k-alert { font-weight: 700; }
.log .dim { color: var(--muted); }
.field { display: grid; gap: 4px; }
.field label { font-size: 0.88rem; color: var(--muted); }
input[type="text"], input[type="search"], input[type="password"] {
  font: inherit; font-size: 0.95rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 11px; width: 100%; min-width: 0;
}
input.mono { font-family: var(--font-mono); font-size: 0.85rem; }
.card-sub { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--bg); display: grid; gap: 10px; min-width: 0; align-content: start; }
.result { font-family: var(--font-mono); font-size: 0.8rem; padding: 10px; border-radius: 4px; background: var(--sunken); min-height: 2.6em; white-space: pre-wrap; word-break: break-word; }
.result.bad { background: var(--alert-soft); color: var(--alert); }
.result.good { background: var(--brand-soft); color: var(--ink); }
pre.code { margin: 0; font-family: var(--font-mono); font-size: 0.78rem; background: var(--sunken); border: 1px solid var(--line); border-radius: 4px; padding: 10px; overflow-x: auto; }
details summary { cursor: pointer; font-size: 0.9rem; font-weight: 600; }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 760px) { .cols { grid-template-columns: 1fr; } }
.chip { font: inherit; font-size: 0.82rem; font-weight: 600; padding: 5px 11px; border-radius: 999px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.small { padding: 7px 12px; font-size: 0.85rem; border-width: 1px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.data { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
table.data th, table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.data th { font-size: 0.8rem; color: var(--muted); font-weight: 600; background: var(--bg); }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover { background: var(--sunken); }
table.data tbody tr[aria-selected="true"] { background: var(--brand-soft); }
.sev { font-size: 0.72rem; font-weight: 700; padding: 2px 7px; border-radius: 4px; color: #fff; }
.sev.CRITICAL { background: #9f1239; }
.sev.HIGH { background: #c2410c; }
.sev.MEDIUM { background: #a16207; }
.sev.LOW { background: #4d7c0f; }
.bars { display: grid; gap: 8px; }
.bars .bar { display: grid; grid-template-columns: 76px minmax(0, 1fr) 24px; gap: 8px; align-items: center; font-size: 0.8rem; }
.bars .track { height: 10px; background: var(--sunken); border-radius: 3px; overflow: hidden; }
.bars .fill { height: 100%; border-radius: 3px; }
.habit { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.habit:last-child { border-bottom: 0; }
.habit input { width: 18px; height: 18px; accent-color: var(--brand); }
.week { display: flex; gap: 3px; margin-top: 4px; }
.week i { width: 12px; height: 12px; border-radius: 3px; background: var(--sunken); border: 1px solid var(--line); }
.week i.on { background: var(--brand); border-color: var(--brand); }
.tg { display: grid; gap: 8px; }
.tg .msg { background: var(--surface); border: 1px solid var(--line); border-radius: 12px 12px 12px 3px; padding: 8px 11px; font-size: 0.9rem; max-width: 92%; }
.tg .msg small { display: block; color: var(--muted); font-size: 0.72rem; margin-top: 2px; }
.chunks { display: grid; gap: 8px; margin-top: 6px; }
.chunk { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--bg); font-size: 0.88rem; }
.chunk header { display: flex; justify-content: space-between; gap: 8px; font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); margin-bottom: 4px; }
.chunk mark { background: var(--brand-soft); color: var(--ink); border-radius: 2px; }
.answer { border-left: 3px solid var(--brand); padding: 12px 14px; background: var(--brand-soft); font-size: 1rem; border-radius: 0 var(--radius) var(--radius) 0; }
.answer sup { color: var(--brand); font-weight: 700; }
.meter { display: grid; gap: 6px; }
.meter .row-m { display: flex; justify-content: space-between; font-size: 0.88rem; }
.meter .track { height: 8px; border-radius: 4px; background: var(--sunken); overflow: hidden; }
.meter .fill { height: 100%; background: var(--brand); transition: width 0.3s; }
.verdict { font-weight: 800; font-size: 1.3rem; font-stretch: 75%; font-variation-settings: "wdth" 75; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--alert); }
.cams { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.demo-subhead { font-size: var(--s-sm); color: var(--muted); font-weight: 600; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Tecnologías ---------- */
.skills { border-top: 2px solid var(--ink); }
.skill-row { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; padding-block: 18px; border-bottom: 1px solid var(--line); align-items: baseline; }
.skill-row h3 { font-size: 1.05rem; font-weight: 700; }
.skill-row .stack li { font-size: 0.9rem; padding: 4px 10px; background: var(--surface); border: 1px solid var(--line); }
@media (max-width: 680px) { .skill-row { grid-template-columns: 1fr; gap: 10px; } }

/* ---------- Capturas ---------- */
.shots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.shot { margin: 0; display: grid; gap: 8px; min-width: 0; }
.shot.lead { grid-column: 1 / -1; }
.shot a { display: block; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--sunken); }
.shot img { display: block; width: 100%; height: auto; }
.shot a:hover { border-color: var(--brand); }
.shot figcaption { font-size: 0.9rem; color: var(--muted); }
@media (max-width: 680px) { .shots { grid-template-columns: 1fr; } }

.mail-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.mail-row a { font-size: 1.3rem; font-weight: 700; word-break: break-word; }
