/* Prioridad: legibilidad y accesibilidad. Sin animaciones, contraste alto, foco visible. */
:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #4a4a4a;
  --border: #767676;
  --soft: #f3f3f3;
  --code-bg: #ffffff;
  --link: #0b4fa8;
  --accent: #8a3b00;
  --focus: #b35900;
  --current-bg: #e4ecf8;
  --sidebar-w: 19rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --fg: #f2f2f2;
    --muted: #c4c4c4;
    --border: #8c8c8c;
    --soft: #1e1e1e;
    --code-bg: #0d1117;
    --link: #8fbcff;
    --accent: #ffb27a;
    --focus: #ffcc66;
    --current-bg: #1f3350;
  }
}

* { box-sizing: border-box; }

html { font-size: 112.5%; } /* 18px base, respeta el zoom del usuario */

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.65;
}

a { color: var(--link); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 0.15em; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  background: var(--bg);
  color: var(--fg);
  border: 2px solid var(--fg);
  padding: 0.5rem 1rem;
  z-index: 10;
}
.skip:focus { top: 0.5rem; }

.site-header {
  border-bottom: 2px solid var(--border);
  padding: 0.75rem 1.25rem;
}
.brand {
  color: var(--fg);
  font-weight: 700;
  text-decoration: none;
}
.brand span {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 0.85rem;
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
}

#lateral {
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  padding: 1rem 1rem 2rem 1.25rem;
  border-right: 2px solid var(--border);
}
#lateral .group-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  margin: 1.25rem 0 0.35rem;
}
#lateral section:first-child .group-title { margin-top: 0; }
#lateral ul { list-style: none; margin: 0; padding: 0; }
#lateral a {
  display: block;
  padding: 0.4rem 0.6rem;
  color: var(--fg);
  text-decoration: none;
  border-left: 4px solid transparent;
}
#lateral a:hover { background: var(--soft); text-decoration: underline; }
#lateral a[aria-current="page"] {
  background: var(--current-bg);
  border-left-color: var(--accent);
  font-weight: 700;
}
#lateral .meta {
  display: block;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
}

main {
  padding: 1.5rem clamp(1rem, 4vw, 3rem) 4rem;
  max-width: 62rem;
  min-width: 0;
}
main:focus { outline: none; }

article > :first-child { margin-top: 0; }
h1 { font-size: 2rem; line-height: 1.25; margin: 0 0 1rem; }
h2 {
  font-size: 1.5rem;
  line-height: 1.3;
  margin: 2.5rem 0 0.75rem;
  padding-top: 1rem;
  border-top: 2px solid var(--border);
  scroll-margin-top: 1rem;
}
h3 { font-size: 1.2rem; margin: 1.75rem 0 0.5rem; scroll-margin-top: 1rem; }
p, ul, ol { max-width: 70ch; }
li { margin: 0.25rem 0; }

blockquote {
  margin: 1rem 0;
  padding: 0.25rem 1rem;
  border-left: 4px solid var(--accent);
  background: var(--soft);
}

code, pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.88rem; }
:not(pre) > code {
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.05em 0.3em;
  overflow-wrap: anywhere;
}
pre {
  margin: 1rem 0;
  padding: 1rem;
  overflow-x: auto;
  line-height: 1.5;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--code-bg);
  tab-size: 2;
}
pre code.hljs { padding: 0; background: transparent; }

.table-wrap { overflow-x: auto; margin: 1rem 0; }
table { border-collapse: collapse; min-width: 100%; }
th, td { border: 1px solid var(--border); padding: 0.5rem 0.75rem; text-align: left; vertical-align: top; }
th { background: var(--soft); }

hr { border: 0; border-top: 2px solid var(--border); margin: 2rem 0; }

.toc { margin: 0 0 1.5rem; max-width: 70ch; }
.toc details { border: 2px solid var(--border); border-radius: 4px; padding: 0.5rem 1rem; }
.toc summary { cursor: pointer; font-weight: 700; }
.toc ol { margin: 0.5rem 0 0.25rem; padding-left: 1.25rem; }

.source-note { color: var(--muted); }

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--border);
}
.pager a {
  display: block;
  max-width: 48%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: 4px;
  font-weight: 700;
}
.pager .next { text-align: right; margin-left: auto; }
.pager .dir { display: block; font-size: 0.8rem; font-weight: 400; color: var(--muted); }

/* Pantallas angostas o zoom alto: el lateral pasa arriba del contenido */
@media (max-width: 52rem) {
  .layout { display: block; }
  #lateral {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 2px solid var(--border);
  }
}

@media (forced-colors: active) {
  #lateral a[aria-current="page"] { border-left-color: Highlight; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

/* El resumen del menú solo se muestra cuando el lateral es colapsable (pantallas angostas) */
#menu > summary { display: none; }
@media (max-width: 52rem) {
  #menu > summary {
    display: block;
    cursor: pointer;
    font-weight: 700;
    padding: 0.5rem 0.25rem;
  }
}

/* El tema claro de highlight.js usa un naranja (#e36209) con 3.5:1 de contraste.
   Se oscurece para llegar a AA (4.5:1) sobre fondo blanco. */
@media (prefers-color-scheme: light), (prefers-color-scheme: no-preference) {
  .hljs-built_in, .hljs-symbol { color: #b34700; }
}

/* ---------- Agregado para el workshop de gastos hormiga ---------- */

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Botón de copiar sobre cada bloque de código */
.bloque { position: relative; }
.bloque pre { padding-top: 2.5rem; }
.copiar {
  position: absolute; top: 0.4rem; right: 0.4rem;
  font: inherit; font-size: 0.8rem; font-weight: 700;
  padding: 0.25rem 0.6rem; cursor: pointer;
  background: var(--bg); color: var(--fg);
  border: 2px solid var(--border); border-radius: 4px;
}
.copiar:hover { background: var(--soft); }

/* Primera línea de cada módulo: el target time */
article > p:first-of-type > em:only-child { color: var(--muted); font-style: normal; font-weight: 700; }

/* Callouts por emoji (render.ts) */
blockquote.costo { border-left-color: #2e7d32; }
blockquote.cuidado { border-left-color: #b00020; }
blockquote.tip { border-left-color: var(--link); }
blockquote.kiro { border-left-color: #7a3b69; }
@media (prefers-color-scheme: dark) {
  blockquote.costo { border-left-color: #81c784; }
  blockquote.cuidado { border-left-color: #ff8a80; }
  blockquote.kiro { border-left-color: #d7a6cb; }
}

/* Bloques colapsables: troubleshooting, reflexiones y respuestas esperadas */
article details {
  margin: 1rem 0; max-width: 70ch;
  border: 2px solid var(--border); border-radius: 4px; padding: 0.5rem 1rem;
}
article details > summary { cursor: pointer; font-weight: 700; }
article details[open] > summary { margin-bottom: 0.5rem; }

/* Diagramas */
article img { max-width: 100%; height: auto; display: block; margin: 1rem 0; }

/* Embeds de YouTube: contenedor con aspect ratio 16:9 */
.video-embed {
  margin: 1rem 0;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}
.video-embed iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* Archivos fuente con número de línea */
pre.fuente code { display: block; }
pre.fuente .ln { display: block; }
pre.fuente .num {
  display: inline-block; width: 3ch; margin-right: 1.25ch; text-align: right;
  color: var(--muted); text-decoration: none; user-select: none;
}
pre.fuente .ln:target { background: var(--current-bg); outline: 2px solid var(--accent); }

/* "Te toca": una acción que el asistente tiene que hacer (render.ts, ✋).
   Más pesado que los demás callouts a propósito: es lo que no te puedes saltar. */
:root {
  --toca: #8a3b00;
  --toca-bg: #fff3e6;
  --toca-titulo-fg: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --toca: #ffb27a;
    --toca-bg: #2a1c10;
    --toca-titulo-fg: #1a1a1a;
  }
}
.te-toca {
  margin: 1.75rem 0;
  padding: 0.9rem 1.25rem 0.5rem;
  border: 3px solid var(--toca);
  border-left-width: 10px;
  border-radius: 6px;
  background: var(--toca-bg);
  box-shadow: 5px 5px 0 var(--toca);
}
.te-toca > p:first-child.te-toca-titulo {
  display: inline-block;
  margin: 0 0 0.6rem;
  padding: 0.2rem 0.7rem;
  border-radius: 4px;
  background: var(--toca);
  color: var(--toca-titulo-fg);
  font-weight: 800;
  font-size: 1rem;
}
.te-toca-titulo code { color: inherit; background: transparent; border-color: currentColor; }
.te-toca pre { background: var(--code-bg); }
.te-toca details { background: var(--bg); }
@media (forced-colors: active) {
  .te-toca { border-color: Highlight; box-shadow: none; }
  .te-toca > p:first-child.te-toca-titulo { border: 2px solid Highlight; }
}

/* Pie con el commit del starter con el que se generó el sitio */
.version { margin-top: 2rem; color: var(--muted); font-size: 0.8rem; }
