/* Blog: índice y artículos. Reutiliza las variables de site.css (día y noche). */

/* Fondo infantil: cielo claro con lunares de colores muy suaves (patrón, no ilustración). El texto largo va
   siempre sobre una hoja blanca (.art-paper, tarjetas), así el contraste no depende del fondo. */
body.page-blog {
  --blog-bg: #CDEEFF;
  --blog-dot-1: rgba(255, 90, 90, .20); --blog-dot-2: rgba(255, 194, 26, .34); --blog-dot-3: rgba(91, 227, 125, .30); --blog-dot-4: rgba(155, 123, 255, .20);
  background-color: var(--blog-bg);
  background-image:
    radial-gradient(circle, var(--blog-dot-1) 0 7px, transparent 7.5px),
    radial-gradient(circle, var(--blog-dot-2) 0 6px, transparent 6.5px),
    radial-gradient(circle, var(--blog-dot-3) 0 6px, transparent 6.5px),
    radial-gradient(circle, var(--blog-dot-4) 0 7px, transparent 7.5px);
  background-size: 128px 128px;
  background-position: 0 0, 64px 64px, 32px 96px, 96px 32px;
}
:root[data-theme="night"] body.page-blog {
  --blog-bg: var(--bg);
  --blog-dot-1: rgba(255, 90, 90, .07); --blog-dot-2: rgba(255, 194, 26, .08); --blog-dot-3: rgba(91, 227, 125, .07); --blog-dot-4: rgba(155, 123, 255, .08);
}
.page-blog .blog-wrap { padding-top: clamp(28px, 5vw, 64px); padding-bottom: clamp(48px, 8vw, 96px); }
.blog-hero { max-width: 760px; margin-bottom: 28px; }
.blog-hero h1 { font-size: clamp(34px, 5vw, 56px); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.filter { cursor: pointer; font: 600 15px/1 var(--f-title); padding: 10px 14px; min-height: 44px; border-radius: 999px; background: var(--surface); color: var(--text); border: 2px solid var(--ink); }
:root[data-theme="night"] .filter { border-color: var(--line); }
.filter span { opacity: .65; margin-left: 4px; }
.filter.is-on { background: var(--gold); color: var(--ink); border-color: var(--ink); }
.cat-section { margin: 40px 0 8px; }
.cat-section h2 { font-size: clamp(24px, 3.2vw, 34px); margin-bottom: 6px; }
.cat-lead { color: var(--text-dim); max-width: 70ch; margin-bottom: 18px; }
.cat-section[hidden] { display: none; }
.post-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); }
.post-card { display: flex; flex-direction: column; text-decoration: none; background: var(--surface); border: 3px solid var(--ink); border-radius: 18px; overflow: hidden; box-shadow: 5px 5px 0 var(--shadow); color: var(--text); transition: transform .15s ease; }
:root[data-theme="night"] .post-card { border-color: var(--line); }
.post-card:hover { transform: translate(-2px, -2px); }
.post-card img { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; background: var(--bg-2); border-bottom: 3px solid var(--ink); }
:root[data-theme="night"] .post-card img { border-bottom-color: var(--line); }
.post-card:focus-visible, .side-card:focus-visible { outline: 4px solid var(--focus); outline-offset: 4px; }
.card-body { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px 16px; }
.card-body strong { font: 600 19px/1.25 var(--f-title); }
.card-desc { color: var(--text-dim); font-size: 15px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { font-size: 13px; color: var(--text-dim); }
.chip { display: inline-block; align-self: flex-start; font: 600 12px/1 var(--f-title); letter-spacing: .06em; text-transform: uppercase; padding: 6px 10px; border-radius: 999px; border: 2px solid var(--ink); color: var(--ink); margin: 0; }
.chip-pain { background: #FFB4A6; } .chip-features { background: #A9E8B8; } .chip-market { background: #B7D8FF; } .chip-learn { background: #FFE08A; }

.blog-hero { background: var(--surface); border: 3px solid var(--ink); border-radius: 22px; box-shadow: 5px 5px 0 var(--shadow); padding: clamp(18px, 3vw, 30px); max-width: none; }
:root[data-theme="night"] .blog-hero { border-color: var(--line); }
.blog-hero > * { max-width: 760px; }

/* Artículo: ilustración 16:9 arriba (el hero), título y texto debajo; a la derecha, índice fijo y parecidos. */
.art-layout { display: grid; gap: 22px; align-items: start; }
.art-side { display: contents; }
.art-side .toc { order: -1; }
.side-related { order: 2; }
@media (min-width: 1024px) {
  .art-layout { grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; }
  .art-side { display: flex; flex-direction: column; gap: 22px; align-self: stretch; }
  .art-side .toc { position: sticky; top: 84px; z-index: 2; }
  .toc-box { max-height: calc(100vh - 108px); overflow-y: auto; }
}
.blog-article { min-width: 0; background: var(--surface); border: 3px solid var(--ink); border-radius: 22px; box-shadow: 6px 6px 0 var(--shadow); overflow: hidden; }
:root[data-theme="night"] .blog-article { border-color: var(--line); }
.art-hero { margin: 0; border-bottom: 3px solid var(--ink); background: var(--bg-2); }
:root[data-theme="night"] .art-hero { border-bottom-color: var(--line); }
.art-cover { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; }
.art-paper { padding: clamp(18px, 4vw, 44px); }
.crumbs { font-size: 14px; color: var(--text-dim); margin-bottom: 14px; }
.crumbs a { text-underline-offset: 3px; }
.art-head h1 { font-size: clamp(30px, 4.4vw, 48px); margin: 10px 0 12px; }
.art-head .lead { max-width: none; }
.byline { font-size: 14px; color: var(--text-dim); margin-bottom: 8px; }

.toc-box { background: var(--surface); border: 3px solid var(--ink); border-radius: 18px; box-shadow: 4px 4px 0 var(--shadow); padding: 4px 16px; }
:root[data-theme="night"] .toc-box { border-color: var(--line); }
.toc-h { font: 600 15px/1.2 var(--f-title); text-transform: uppercase; letter-spacing: .08em; color: var(--accent-text); padding: 12px 0; min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; list-style: none; }
.toc-h::-webkit-details-marker { display: none; }
.toc-h::after { content: ""; width: 9px; height: 9px; border-right: 3px solid currentColor; border-bottom: 3px solid currentColor; transform: rotate(45deg) translateY(-3px); transition: transform .2s ease; flex: none; }
.toc-box[open] > .toc-h::after { transform: rotate(-135deg) translateY(-2px); }
.toc-box.is-fixed > .toc-h { cursor: default; }
.toc-box.is-fixed > .toc-h::after { display: none; }
.toc ol { margin: 0 0 12px; padding-left: 22px; display: grid; gap: 0; font-size: 15px; line-height: 1.35; }
.toc li::marker { color: var(--accent-text); font-weight: 700; }
.toc a[aria-current] { font-weight: 800; text-decoration-color: var(--gold); text-decoration-thickness: 3px; }

.side-h { font: 600 15px/1.2 var(--f-title); text-transform: uppercase; letter-spacing: .08em; margin: 0 0 10px; color: var(--ink); background: var(--gold); border: 3px solid var(--ink); border-radius: 999px; padding: 8px 14px; display: inline-block; }
.side-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
@media (min-width: 1024px) { .side-list { grid-template-columns: 1fr; } }
.side-card { display: flex; flex-direction: column; text-decoration: none; color: var(--text); background: var(--surface); border: 3px solid var(--ink); border-radius: 16px; overflow: hidden; box-shadow: 4px 4px 0 var(--shadow); transition: transform .15s ease; height: 100%; }
:root[data-theme="night"] .side-card { border-color: var(--line); }
.side-card:hover { transform: translate(-2px, -2px); }
.side-img { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; background: var(--bg-2); border-bottom: 3px solid var(--ink); }
:root[data-theme="night"] .side-img { border-bottom-color: var(--line); }
.side-body { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px 12px; }
.side-body strong { font: 600 16px/1.25 var(--f-title); }
.side-body .chip { font-size: 10.5px; padding: 4px 8px; }
.toc a { text-underline-offset: 3px; display: block; padding: 6px 0; }
.blog-body { max-width: none; overflow-wrap: anywhere; }
.blog-body h2 { margin-top: 1.8em; }
.blog-body h3 { margin-top: 1.4em; }
.blog-body p, .blog-body li { color: var(--text); }
.blog-body ul, .blog-body ol { padding-left: 22px; margin: 0 0 1.1em; }
.blog-body li { margin-bottom: .4em; }
.blog-body blockquote { margin: 1.2em 0; padding: 10px 18px; border-left: 6px solid var(--gold); background: var(--surface-2); border-radius: 0 12px 12px 0; }
.blog-body blockquote p { margin: 0; }
.blog-body code { font-size: .92em; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); }
.blog-body hr { border: 0; border-top: 2px dashed var(--line); margin: 2em 0; }

.diagram { margin: 1.4em auto; max-width: 340px; text-align: center; }
.diagram svg.board { width: 100%; height: auto; border: 3px solid var(--ink); border-radius: 10px; background: var(--surface); }
:root[data-theme="night"] .diagram svg.board { border-color: var(--line); }
.board .sq-l { fill: var(--sq-light); } .board .sq-d { fill: var(--sq-dark); }
.board .coord { font: 700 10px var(--f-body); fill: var(--text-dim); }
.board .mark { fill: rgba(255, 194, 26, .62); }
.board .dot { fill: rgba(18, 50, 74, .45); }
.board .arrow { stroke: #E0451B; stroke-width: 6; stroke-linecap: round; opacity: .85; }
.board .arrowhead { fill: #E0451B; opacity: .9; }
.diagram figcaption { font-size: 14px; color: var(--text-dim); margin-top: 8px; line-height: 1.4; }

.blog-cta { display: grid; gap: 16px; align-items: center; margin: 2.4em 0; padding: 22px; background: var(--gold); color: var(--ink); border: 3px solid var(--ink); border-radius: 20px; box-shadow: 5px 5px 0 var(--shadow); }
.blog-cta h2 { font-size: clamp(22px, 3vw, 28px); margin: 0 0 6px; color: var(--ink); }
.blog-cta p { margin: 0; color: var(--ink); }
.cta-btns { display: flex; flex-wrap: wrap; gap: 10px; }
.blog-cta .btn { --fill: var(--ink); --btn-text: #fff; border-color: var(--ink); }
.blog-cta .btn.ghost { --fill: #fff; --btn-text: var(--ink); }
@media (min-width: 720px) { .blog-cta { grid-template-columns: 1fr auto; } }
.market-block { margin: 2em 0; padding: 18px 20px; background: var(--surface-2); border: 2px solid var(--ink); border-radius: 16px; }
:root[data-theme="night"] .market-block { border-color: var(--line); }
.market-block h2 { margin-top: 0; font-size: clamp(22px, 2.8vw, 28px); }
.market-block ul { padding-left: 20px; margin: 0 0 1em; }
.market-block li { margin-bottom: .6em; }
.keep-reading { margin-top: clamp(32px, 5vw, 56px); }
.keep-reading h2 { font-size: clamp(26px, 3.4vw, 36px); display: inline-block; background: var(--surface); border: 3px solid var(--ink); border-radius: 999px; padding: 6px 20px; box-shadow: 4px 4px 0 var(--shadow); }
:root[data-theme="night"] .keep-reading h2 { border-color: var(--line); }
.post-grid.grid-3 { grid-template-columns: 1fr; }
@media (min-width: 700px) { .post-grid.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.blog-body .tablewrap { overflow-x: auto; margin: 0 0 1.2em; border: 2px solid var(--ink); border-radius: 14px; }
:root[data-theme="night"] .blog-body .tablewrap { border-color: var(--line); }
.blog-body table { border-collapse: collapse; width: 100%; min-width: 520px; font-size: 15px; }
.blog-body th, .blog-body td { text-align: left; vertical-align: top; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.blog-body th { font-family: var(--f-title); background: var(--surface-2); }
.blog-body tr:last-child td { border-bottom: 0; }
.blog-body .faq-item { margin: 0 0 10px; }
.blog-body .faq-item summary h3 { margin: 0; font-size: 18px; }
@media (max-width: 480px) { .blog-article, .post-card, .blog-hero { border-radius: 16px; } }
