/* Diseno D (#24): tipografia dev minimal + barra lateral. Sin frameworks,
 * sin fuentes externas, sin url(). El color nunca es la unica senal (links de
 * contenido siempre subrayados, nav activa subrayada, foco visible).
 * Referencia: docs/design/2026-10-05-direccion-d/Mix*.dc.html */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --text: #111111; /* 18.88:1 sobre el fondo */
  --muted: #5a5a5a; /* 6.90:1, meta/fechas/etiquetas */
  --muted-2: #4a4a4a; /* 8.86:1, bio/intro/resumenes */
  --accent: #b4440e; /* 5.56:1, subrayados/marca/boton */
  --border: #ededed;
  --border-strong: #111111; /* corte del bloque subscribe */
  --pill-border: #cfcfcf;
  --details-border: #dcdcdc;
  --input-border: #767676;
  --code-bg: #f3f3f3; /* texto 17.02:1 */
  --pre-bg: #111111;
  --pre-text: #f2f2f2; /* 16.87:1 */
  --btn-bg: #b4440e;
  --btn-text: #ffffff; /* 5.56:1 */
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --text: #ededed; /* 16.00:1 */
    --muted: #a8a8a8; /* 7.88:1 */
    --muted-2: #a8a8a8;
    --accent: #f08a4b; /* 7.53:1 */
    --border: #2e2e2e;
    --border-strong: #ededed;
    --pill-border: #555555;
    --details-border: #444444;
    --input-border: #8a8a8a; /* 5.43:1, borde de UI (3:1) */
    --code-bg: #2b2b2b; /* texto 12.09:1 */
    --pre-bg: #0a0a0a;
    --pre-text: #f2f2f2; /* 17.68:1 */
    --btn-bg: #f08a4b;
    --btn-text: #121212; /* 7.53:1 */
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

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

/* Links de contenido: texto + subrayado 2px en acento (nunca color solo). */
a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 2px;
}

a:hover {
  color: var(--accent);
}

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

/* Salto a contenido: oculto hasta recibir foco por teclado. */
.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--bg);
  padding: 0.5rem 1rem;
  border: 2px solid var(--accent);
  text-decoration: none;
}

.skip-link:focus-visible {
  top: 0.5rem;
}

/* Cascaron: sidebar + columna de contenido con borde izquierdo. */
.shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 48px;
}

.site-sidebar {
  flex: 1 1 220px;
  max-width: 260px;
  padding: 56px 0 32px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  align-self: flex-start;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
}

.content-col {
  flex: 999 1 560px;
  min-width: 0;
  padding: 56px 0 72px 48px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

main {
  overflow-wrap: break-word;
  display: flex;
  flex-direction: column;
}

/* Marca + bio + navegacion (compartidos por sidebar y header mobile). */
.site-brand {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
}

.site-brand .tld {
  color: var(--accent);
}

.site-bio {
  margin: 10px 0 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--muted-2);
}

.main-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--mono);
  font-size: 14px;
}

.main-nav a {
  text-decoration: none;
}

.main-nav a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 2px;
}

/* Nav activa: subrayado en acento (nunca color solo). B5 (#27): 'page' es la
 * pagina exacta; 'true' es la seccion (ej. /writing en un post). */
.main-nav a[aria-current="page"],
.main-nav a[aria-current="true"] {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 2px;
}

/* Sociales: fila mono bajo la nav (sidebar y header mobile). */
.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  font-family: var(--mono);
  font-size: 13.5px;
}

.social-links a {
  text-decoration: none;
}

.social-links a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 2px;
}

/* Topics (sidebar, home): etiqueta + #tag con cantidad. */
.sidebar-label {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.topics-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 12px;
  font-family: var(--mono);
  font-size: 13.5px;
}

.topics-list a {
  display: flex;
  justify-content: space-between;
  text-decoration: none;
}

.topics-list a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 2px;
}

.topics-list .count {
  color: var(--muted);
}

/* Indice del post (sidebar): links a los h2. */
.contents-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
  font-size: 14px;
  line-height: 1.4;
}

.contents-block .sidebar-label {
  margin: 0;
}

.contents-block a {
  text-decoration: none;
}

.contents-block a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 2px;
}

/* Header mobile: marca + nav con targets de 44px. Oculto en desktop. */
.site-header {
  display: none;
}

/* Pie: nav + canonica como texto seleccionable (§5 convenciones). */
.site-footer {
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.site-footer p {
  margin: 0 0 0.5rem;
}

/* D2 (#27): sociales en el pie solo en mobile (en desktop estan en la sidebar). */
.footer-social {
  display: none;
}

/* Home: h1 + intro + lista en grid con fecha a la izquierda. */
.page-title {
  margin: 0 0 8px;
  font-size: 36px;
  line-height: 1.15;
  font-weight: 750;
  letter-spacing: -0.015em;
}

.page-intro {
  margin: 0 0 28px;
  font-size: 17px;
  line-height: 1.6;
  color: var(--muted-2);
}

.post-card {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 4px 20px;
  padding: 18px 0;
  border-top: 1px solid var(--border);
}

.post-card-date {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  padding-top: 4px;
}

.post-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

h2.post-card-title {
  margin: 0;
  font-size: 19px;
  line-height: 1.35;
  font-weight: 650;
}

.post-card-title a {
  text-decoration: none;
}

.post-card-title a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 2px;
}

/* D1 (#27): resumenes a 2 lineas en desktop (3 en mobile), sin tocar contenido. */
.post-card .post-description {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--muted-2);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.post-card-tags {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
}

.older-posts {
  margin-top: 20px;
  font-family: var(--mono);
  font-size: 14px;
}

/* Fila de topics mobile: deslizable horizontal bajo la intro, nunca al pie. */
.topics-row {
  display: none;
}

/* Post: meta + titulo + cuerpo de 680px. */
.post {
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.post-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.post-meta {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}

.post-title {
  margin: 0;
  font-size: 42px;
  line-height: 1.1;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.post-hero {
  margin: 0;
}

/* Tags bajo el h1: solo mobile (en desktop van en la linea de meta). */
.post-tags {
  display: none;
}

/* Indice mobile: <details> plegado. Oculto en desktop. */
.post-toc {
  display: none;
}

/* Cuerpo del post migrado. */
.post-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  font-size: 18px;
  line-height: 1.7;
}

.post-content > * {
  margin: 0;
  min-width: 0;
}

.post-content h2 {
  margin-top: 14px;
  font-size: 25px;
  line-height: 1.25;
  font-weight: 700;
}

/* Prefijo ## en acento (maqueta); solo visual, no entra al DOM/texto. */
.post-content h2::before {
  content: "## ";
  font-family: var(--mono);
  color: var(--accent);
  font-weight: 400;
}

.post-content h3 {
  font-size: 21px;
  line-height: 1.3;
  font-weight: 700;
}

.post-content h4 {
  font-size: 18px;
  line-height: 1.4;
  font-weight: 700;
}

/* Toda imagen fluida, incluido el hero (fuera de .post-content). */
img {
  display: block;
  max-width: 100%;
  height: auto;
}

.post-content figure {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.post-content figcaption {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}

/* Epigrafes con prefijo fig. (maqueta); solo visual. */
.post-content figcaption::before {
  content: "fig. ";
}

.post-content blockquote {
  padding: 0.25rem 0 0.25rem 1rem;
  border-left: 3px solid var(--muted);
  color: var(--muted);
}

.post-content ul,
.post-content ol {
  padding-left: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.post-content code {
  font-family: var(--mono);
  font-size: 15.5px;
  background: var(--code-bg);
  padding: 1px 6px;
  border-radius: 4px;
  overflow-wrap: break-word;
}

/* Codigo en bloque oscuro en ambos temas. */
.post-content pre {
  margin: 4px 0;
  background: var(--pre-bg);
  color: var(--pre-text);
  padding: 18px 20px;
  border-radius: 6px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 14.5px;
  line-height: 1.6;
}

@media (prefers-color-scheme: dark) {
  .post-content pre {
    border: 1px solid #3a3a3a;
  }
}

.post-content pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

.post-content table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95rem;
}

.post-content th,
.post-content td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.post-content th {
  font-weight: 700;
}

.post-content hr {
  border: 0;
  border-top: 1px solid var(--border);
}

/* Bloque $ subscribe: SOLO maquetado (#4 lo conecta; sin form ni JS). */
.subscribe-block {
  margin-top: 24px;
  border-top: 1px solid var(--border-strong);
  padding-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.subscribe-block .subscribe-prompt {
  margin: 0;
  font-family: var(--mono);
  font-size: 14px;
}

.subscribe-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.subscribe-row input[type="email"] {
  flex: 1 1 240px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  font-size: 16px;
  font-family: var(--mono);
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}

.subscribe-row input[type="email"]::placeholder {
  color: var(--muted);
  opacity: 1;
}

.subscribe-row button {
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 4px;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.sr-only {
  position: absolute;
  left: -9999px;
}

/* Anterior/siguiente. */
.prevnext {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  font-size: 15px;
  margin-top: 12px;
}

/* D4 (#27): archivos tag/categoria con la grilla de la home (PostCard) y
 * titulo #slug en monoespaciada. */
.archive-title {
  margin: 0 0 16px;
  font-family: var(--mono);
  font-size: 30px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow-wrap: break-word;
}

.archive-empty {
  color: var(--muted);
}

/* Paginas simples (about/subscribe/404/blog): h1 + parrafos del sistema. */
.prose-title {
  margin: 0 0 16px;
  font-size: 36px;
  line-height: 1.15;
  font-weight: 750;
  letter-spacing: -0.015em;
}

.prose-body {
  font-size: 17px;
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.prose-body > * {
  margin: 0;
}

@media (max-width: 880px) {
  .shell {
    padding: 0;
    gap: 0;
  }

  .site-sidebar {
    display: none;
  }

  .content-col {
    padding: 0 0 48px;
    border-left: 0;
  }

  .site-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 20px 14px;
    border-bottom: 1px solid var(--border);
  }

  .site-header .site-brand {
    font-size: 16px;
  }

  .site-header .main-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px 18px;
  }

  .site-header .main-nav a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  main {
    padding: 24px 20px 0;
  }

  .page-title {
    font-size: 30px;
  }

  .page-intro {
    font-size: 16px;
    line-height: 1.55;
    margin-bottom: 8px;
  }

  .topics-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    white-space: nowrap;
    font-family: var(--mono);
    font-size: 13.5px;
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    margin: 12px -20px 0;
  }

  .topics-row a {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--pill-border);
    border-radius: 4px;
    text-decoration: none;
    flex: none;
  }

  .post-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    border-top: 0;
    border-bottom: 1px solid var(--border);
  }

  .post-card-date {
    font-size: 12.5px;
    padding-top: 0;
  }

  .post-card-title {
    font-size: 18px;
  }

  .post-card .post-description {
    font-size: 15px;
    line-height: 1.5;
    -webkit-line-clamp: 3;
    line-clamp: 3;
  }

  /* La maqueta mobile lista fecha, titulo y resumen, sin tags. */
  .post-card-tags {
    display: none;
  }

  .post {
    gap: 18px;
  }

  .post-head {
    gap: 10px;
    padding-bottom: 0;
    border-bottom: 0;
  }

  .post-meta {
    font-size: 12.5px;
  }

  .post-title {
    font-size: 32px;
    line-height: 1.12;
  }

  .meta-tags-inline {
    display: none;
  }

  .post-tags {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    font-family: var(--mono);
    font-size: 13.5px;
  }

  .post-toc {
    display: block;
    border: 1px solid var(--details-border);
    border-radius: 4px;
    padding: 0 14px;
  }

  .post-toc summary {
    min-height: 44px;
    display: flex;
    align-items: center;
    font-family: var(--mono);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
  }

  .post-toc summary::-webkit-details-marker {
    display: none;
  }

  .post-toc nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 0 14px;
    font-size: 14px;
    line-height: 1.4;
  }

  /* Targets tactiles >= 24px (WCAG 2.2 AA 2.5.8): 44px por link
     inflaria un indice de 15 entradas sin beneficio proporcional. */
  .post-toc nav a {
    display: block;
    padding: 6px 0;
    text-decoration: none;
  }

  .post-content {
    font-size: 17px;
  }

  .post-content h2 {
    font-size: 22px;
    margin-top: 10px;
  }

  .post-content h3 {
    font-size: 19px;
  }

  .post-content pre {
    padding: 14px 16px;
    font-size: 13.5px;
  }

  .post-content figcaption {
    font-size: 12.5px;
  }

  .subscribe-block {
    margin-top: 12px;
    padding-top: 20px;
  }

  .subscribe-block .subscribe-prompt {
    font-size: 13.5px;
  }

  .subscribe-row {
    flex-direction: column;
  }

  .subscribe-row input[type="email"] {
    flex: none;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  }

  .prevnext {
    flex-direction: column;
  }

  .prose-title {
    font-size: 30px;
  }

  .archive-title {
    font-size: 26px;
  }

  .site-footer {
    margin: 2.5rem 20px 0;
  }

  /* D2 (#27): los sociales viven en el pie en mobile, con targets de 44px. */
  .footer-social {
    display: flex;
    margin-bottom: 0.75rem;
  }

  .footer-social a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}
