/* ===== Tokens ===== */
:root {
  --bg: #11151d;        /* pizarra */
  --bg-2: #161b25;      /* paneles */
  --bg-3: #1d2330;      /* hover / campos */
  --line: #283042;
  --text: #e4e7ef;
  --muted: #8f97aa;
  --faint: #5d6579;

  /* Un color por proyecto: se mantiene en el explorador y en su sección */
  --aeab: #ef4b4b;
  --panel: #f2a93b;
  --chess: #4fbf8b;
  --link: #8fb3ff;

  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Code", Consolas, monospace;

  --top: 52px;
  --status: 28px;
  --side: 244px;
  --measure: 68ch;
  --c: var(--link);
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--top) + 24px); }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  padding-bottom: var(--status);
}
a { color: inherit; }
ul, ol { list-style: none; }
kbd {
  font: 500 11px/1 var(--mono);
  padding: 3px 5px; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; color: var(--muted); background: var(--bg);
}
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 4px; }

.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--text); color: var(--bg); padding: 8px 12px; border-radius: 6px; }
.skip:focus { left: 8px; }

/* ===== Barra superior ===== */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--top); z-index: 30;
  display: flex; align-items: center; gap: 20px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.logo { font: 600 15px var(--mono); text-decoration: none; width: calc(var(--side) - 40px); }
.crumbs { font: 400 13px var(--mono); color: var(--faint); display: flex; gap: 6px; min-width: 0; }
.crumbs #crumb { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-btn {
  margin-left: auto; display: flex; align-items: center; gap: 6px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--muted);
  font: 400 13px var(--sans); padding: 6px 8px 6px 12px; border-radius: 8px; cursor: pointer;
}
.palette-btn span { margin-right: 8px; }
.palette-btn:hover { color: var(--text); border-color: var(--faint); }
.menu-btn { display: none; }

/* ===== Disposición ===== */
.layout { display: grid; grid-template-columns: var(--side) 1fr; padding-top: var(--top); }

/* ===== Explorador ===== */
.sidebar {
  position: sticky; top: var(--top); align-self: start;
  height: calc(100vh - var(--top) - var(--status));
  border-right: 1px solid var(--line);
  padding: 24px 12px; overflow-y: auto;
  display: flex; flex-direction: column;
  font: 400 14px var(--mono);
}
.tree-title { color: var(--faint); font-size: 12px; padding: 0 10px 10px; }
.tree a {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: 6px;
  color: var(--muted); text-decoration: none;
  border-left: 2px solid transparent;
}
.tree a:hover { color: var(--text); background: var(--bg-2); }
.tree a.active { color: var(--text); background: var(--bg-3); border-left-color: var(--c, var(--link)); }
.tree .ico { width: 10px; color: var(--faint); text-align: center; }
.tree .dot, .index .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.folder-name { display: block; padding: 10px 10px 4px; color: var(--faint); }
.folder ul { padding-left: 14px; border-left: 1px solid var(--line); margin-left: 14px; }
.folder ul a { padding-left: 8px; }
.side-links { margin-top: auto; display: flex; gap: 16px; padding: 16px 10px 0; border-top: 1px solid var(--line); font-size: 13px; }
.side-links a { color: var(--muted); text-decoration: none; }
.side-links a:hover { color: var(--text); }
.scrim { display: none; }

/* ===== Contenido ===== */
main { min-width: 0; padding: 0 clamp(20px, 5vw, 72px); }
main > section { max-width: 1040px; padding: 88px 0; border-bottom: 1px solid var(--line); }
main > section:last-child { border-bottom: 0; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font: 500 15px var(--sans); padding: 10px 18px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--text);
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--faint); background: var(--bg-3); }
.btn.primary { background: var(--c); border-color: var(--c); color: #0d1016; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }

/* ===== Inicio ===== */
.hero { padding-top: 96px; --c: var(--link); }
.prompt { font: 400 14px var(--mono); color: var(--muted); margin-bottom: 28px; min-height: 1.6em; }
.prompt .ps { color: var(--chess); }
.prompt .cmd { color: var(--text); }
.caret { display: inline-block; width: 8px; height: 1.1em; vertical-align: -3px; margin-left: 2px; background: var(--text); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.hero h1 {
  font: 600 clamp(2.6rem, 6.5vw, 4.75rem)/1.02 var(--sans);
  letter-spacing: -0.035em;
}
.role { font: 400 clamp(1.15rem, 2.2vw, 1.5rem)/1.3 var(--mono); color: var(--muted); margin-top: 14px; letter-spacing: -0.01em; }
.lead { max-width: var(--measure); color: #c5cad6; font-size: 1.08rem; margin-top: 28px; }

.index { margin-top: 64px; border-top: 1px solid var(--line); max-width: 760px; }
.index a {
  display: grid; grid-template-columns: 8px 220px 1fr; align-items: center; gap: 16px;
  padding: 16px 4px; border-bottom: 1px solid var(--line); text-decoration: none;
}
.index strong { font-weight: 600; }
.index span:last-child { color: var(--muted); font-size: 15px; }
.index a:hover strong { color: var(--c); }

/* ===== Proyectos ===== */
.project { position: relative; }
.project::before {
  content: ""; position: absolute; left: 0; top: 88px; width: 48px; height: 3px; background: var(--c); border-radius: 2px;
}
.p-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; padding-top: 28px; }
.p-kind { font: 400 13px var(--mono); color: var(--c); margin-bottom: 8px; }
.project h2 { font: 600 clamp(2rem, 4vw, 2.9rem)/1.05 var(--sans); letter-spacing: -0.03em; }
.p-status { font-size: 14px; color: var(--muted); max-width: 34ch; text-align: right; }
.p-links { display: flex; gap: 10px; flex-wrap: wrap; }
.p-summary { max-width: var(--measure); font-size: 1.1rem; color: #c5cad6; margin-top: 24px; }

.p-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 48px; margin-top: 40px; align-items: start; }
.p-grid.phone { grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.8fr); }

.features { display: grid; gap: 18px; }
.features > div { display: grid; grid-template-columns: 140px 1fr; gap: 16px; padding-bottom: 18px; border-bottom: 1px dashed var(--line); }
.features > div:last-child { border-bottom: 0; padding-bottom: 0; }
.features dt { font: 500 14px/1.6 var(--mono); color: var(--text); }
.features dd { color: #b9bfcc; font-size: 15.5px; }

/* Capturas */
.shot {
  aspect-ratio: 4 / 3; border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  background:
    linear-gradient(var(--bg-2), var(--bg-2)) padding-box,
    repeating-linear-gradient(45deg, transparent 0 10px, rgba(255,255,255,.02) 10px 20px);
  background-color: var(--bg-2);
  display: grid; grid-template-rows: 1fr auto;
}
.shot.tall { aspect-ratio: 9 / 18; max-width: 280px; justify-self: center; width: 100%; }
.shot img { width: 100%; height: auto; display: block; }
.shot:has(img) { aspect-ratio: auto; display: block; background: var(--bg-2); }
.shot:has(img) figcaption { font: 400 13.5px/1.5 var(--sans); color: var(--muted); padding: 10px 14px; }
.duo-imgs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px; align-items: start; }
.duo-imgs img { border-radius: 10px; }
.p-grid.phone { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.shot figcaption {
  font: 400 12px var(--mono); color: var(--faint);
  padding: 8px 12px; border-top: 1px solid var(--line); background: var(--bg);
}
.shot:not(:has(img))::before {
  content: "Captura pendiente"; align-self: center; justify-self: center;
  font: 400 13px var(--mono); color: var(--faint);
}

/* Arquitectura (AEAB) */
.arch { margin-top: 48px; border: 1px solid var(--line); border-radius: 12px; padding: 24px; background: var(--bg-2); }
.arch-title { font: 500 14px var(--mono); color: var(--muted); margin-bottom: 20px; }
.arch-flow { display: grid; grid-template-columns: 1fr 40px 1fr 56px 1fr 40px 1fr; align-items: stretch; }
.node {
  border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: var(--bg);
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
}
.node:first-child { border-color: var(--c); }
.node strong { font-size: 14.5px; font-weight: 600; }
.node span { font: 400 12.5px/1.4 var(--mono); color: var(--muted); }
.node.split { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: baseline; }
.edge { position: relative; display: grid; place-items: center; }
.edge::before { content: ""; position: absolute; left: 4px; right: 8px; top: 50%; height: 1px; background: var(--faint); }
.edge::after { content: ""; position: absolute; right: 4px; top: calc(50% - 4px); border: 4px solid transparent; border-left-color: var(--faint); }
.edge em { position: relative; top: -12px; font: italic 400 11px var(--mono); color: var(--muted); background: var(--bg-2); padding: 0 3px; }
.arch-foot { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-top: 18px; font-size: 14px; color: var(--muted); }
.arch-foot strong { color: var(--text); font-weight: 500; }

/* Etiquetas de tecnología */
.stack { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 36px; }
.stack li {
  font: 400 12.5px var(--mono); padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--line); color: #b9bfcc; background: var(--bg-2);
}
.project .stack li:first-child { border-color: color-mix(in srgb, var(--c) 55%, var(--line)); }

/* Probar la demo */
.try { margin-top: 32px; max-width: 720px; border: 1px solid color-mix(in srgb, var(--c) 45%, var(--line)); border-radius: 12px; padding: 20px; background: var(--bg-2); }
.try label { display: block; font-weight: 600; margin-bottom: 12px; }
.try-row { display: flex; gap: 10px; flex-wrap: wrap; }
.try-prefix {
  display: flex; align-items: center; padding: 0 0 0 14px; margin-right: -14px;
  font: 400 14px var(--mono); color: var(--faint);
  border: 1px solid var(--line); border-right: 0; border-radius: 8px 0 0 8px; background: var(--bg);
}
.try input {
  flex: 1; min-width: 150px; font: 400 15px var(--mono); color: var(--text);
  padding: 10px 14px; border: 1px solid var(--line); border-left: 0; border-radius: 0 8px 8px 0; background: var(--bg);
}
.try input:focus { outline: none; }
.try-row:focus-within .try-prefix, .try-row:focus-within input { border-color: var(--c); }
.try-hint { margin-top: 10px; font-size: 14px; color: var(--muted); }

/* ===== Experiencia ===== */
.plain h2 { font: 600 clamp(1.8rem, 3.5vw, 2.5rem)/1.1 var(--sans); letter-spacing: -0.03em; }
.timeline { margin-top: 36px; border-left: 1px solid var(--line); padding-left: 28px; display: grid; gap: 28px; max-width: var(--measure); }
.timeline li { position: relative; }
.timeline li::before {
  content: ""; position: absolute; left: -33px; top: 8px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--faint);
}
.timeline li.now::before { background: var(--chess); border-color: var(--chess); }
.timeline h3 { font-size: 1.08rem; font-weight: 600; }
.timeline p { color: var(--muted); font-size: 15.5px; }
.sub { font-size: 1.08rem; font-weight: 600; margin-top: 56px; }
.tech { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin-top: 16px; }
.tech p { font: 400 13px var(--mono); color: var(--muted); }
.tech .stack { margin-top: 10px; }

/* ===== Contacto ===== */
.contact .lead { margin-top: 14px; }
.contact-row { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-top: 28px; }
.mail { font: 500 clamp(1.3rem, 3vw, 2rem) var(--mono); text-decoration: none; border-bottom: 2px solid var(--line); letter-spacing: -0.02em; }
.mail:hover { border-bottom-color: var(--link); }

/* ===== Barra de estado ===== */
.statusbar {
  position: fixed; inset: auto 0 0 0; height: var(--status); z-index: 30;
  display: flex; align-items: center; gap: 18px; padding: 0 14px;
  font: 400 12px var(--mono); color: var(--muted);
  background: var(--bg-2); border-top: 1px solid var(--line);
}
.statusbar .branch::before { content: "⎇ "; }
.statusbar .grow { flex: 1; }
.statusbar a { text-decoration: none; }
.statusbar a:hover { color: var(--text); }

/* ===== Buscador de comandos ===== */
.palette { position: fixed; inset: 0; z-index: 50; background: rgba(5, 7, 11, .6); display: flex; justify-content: center; padding-top: 14vh; }
.palette[hidden] { display: none; }
.palette-box {
  width: min(560px, calc(100% - 32px)); align-self: flex-start;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}
#palette-input { width: 100%; font: 400 16px var(--sans); color: var(--text); background: transparent; border: 0; border-bottom: 1px solid var(--line); padding: 16px 18px; }
#palette-input:focus { outline: none; }
#palette-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
#palette-list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 15px; }
#palette-list li .k { font: 400 12px var(--mono); color: var(--faint); width: 64px; flex: none; }
#palette-list li .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--faint)); }
#palette-list li[aria-selected="true"] { background: var(--bg-3); }
#palette-list li.empty { color: var(--muted); cursor: default; }
.palette-help { font-size: 12px; color: var(--faint); padding: 10px 18px; border-top: 1px solid var(--line); display: flex; gap: 6px; align-items: center; }

/* Aviso */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--status) + 16px); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 500;
  padding: 10px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== Movimiento reducido ===== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .caret { animation: none; }
  .toast { transition: none; }
}

/* ===== Tablet ===== */
@media (max-width: 1080px) {
  .arch-flow { grid-template-columns: 1fr; gap: 0; }
  .edge { height: 28px; }
  .edge::before { left: 50%; right: auto; top: 4px; bottom: 8px; width: 1px; height: auto; }
  .edge::after { left: calc(50% - 4px); right: auto; top: auto; bottom: 2px; border-left-color: transparent; border-top-color: var(--faint); }
  .edge em { top: 0; left: 36px; }
}

/* ===== Móvil: el explorador pasa a un panel lateral ===== */
@media (max-width: 860px) {
  :root { --side: 280px; }
  .layout { grid-template-columns: 1fr; }
  .menu-btn {
    display: grid; gap: 4px; width: 36px; height: 36px; place-content: center;
    background: transparent; border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  }
  .menu-btn span { width: 16px; height: 1.5px; background: var(--text); }
  .logo { width: auto; }
  .crumbs { display: none; }
  .palette-btn kbd { display: none; }
  .palette-btn span { margin: 0; }
  .sidebar {
    position: fixed; top: var(--top); left: 0; z-index: 40; width: var(--side);
    background: var(--bg); transform: translateX(-100%); transition: transform .22s ease;
  }
  .sidebar.open { transform: none; }
  .scrim:not([hidden]) { display: block; position: fixed; inset: var(--top) 0 0 0; z-index: 35; background: rgba(5, 7, 11, .55); }
  main > section { padding: 64px 0; }
  .project::before { top: 64px; }
  .p-grid, .p-grid.phone { grid-template-columns: 1fr; gap: 32px; }
  .p-status { text-align: left; }
  .features > div { grid-template-columns: 1fr; gap: 2px; }
  .index a { grid-template-columns: 8px 1fr; }
  .index span:last-child { grid-column: 2; margin-top: -10px; }
  .tech { grid-template-columns: 1fr; }
  .statusbar span:last-child { display: none; }
  .try-prefix { display: none; }
  .try input { border-left: 1px solid var(--line); border-radius: 8px; }
}
@media (max-width: 860px) and (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}
