/* Blog (/blog, /blog/categoria/<slug>, /blog/autor/<slug>, /blog/<slug>).
   Mismo estilo "mosaico" que la home y /casos: se apoya en los tokens de
   bento.css (.bx), así que funciona en claro y en oscuro. */

a.bx-chip { display: inline-flex; align-items: center; text-decoration: none; }
a.bx-chip[aria-current="page"] { background: var(--bx-fg); color: var(--bx-bg); border-color: var(--bx-fg); }

.bx-section--tight { padding-top: clamp(32px, 4vw, 56px); }
.bx-blog-lead { margin: -12px 0 28px; max-width: 60ch; font-size: 1.1rem; line-height: 1.55; color: var(--bx-text); }

/* ── Tarjetas de artículo ─────────────────────────────────────────── */
.bx-posts { margin-top: var(--bx-gap); }
.bx-post {
    grid-column: span 4;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 260px;
    color: var(--bx-fg);
    text-decoration: none;
    transition: background var(--transition, .2s);
}
.bx-post:hover { background: color-mix(in srgb, var(--bx-card) 82%, var(--bx-accent)); }
.bx-post:focus-visible, .bx-post-feature:focus-visible { outline: 3px solid var(--bx-accent); outline-offset: 3px; }
.bx-post-img {
    display: block;
    margin: calc(-1 * clamp(24px, 2.4vw, 36px)) calc(-1 * clamp(24px, 2.4vw, 36px)) 8px;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: var(--bx-radius) var(--bx-radius) 0 0;
    background: var(--bx-line);
}
.bx-post-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.bx-post-cat { margin: 0; color: var(--bx-accent); }
.bx-post-title {
    margin: 0;
    font-family: var(--bx-head);
    font-weight: 500;
    font-size: clamp(1.35rem, 1.8vw, 1.7rem);
    line-height: 1.12;
    letter-spacing: -0.025em;
    color: inherit;
    text-wrap: balance;
}
.bx-post-excerpt {
    margin: 0;
    line-height: 1.55;
    color: var(--bx-text);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.bx-post-meta { margin: auto 0 0; padding-top: 8px; color: var(--bx-text); }

/* Destacado: tinta, a todo el ancho */
.bx-post-feature {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: clamp(24px, 3vw, 48px);
    align-items: stretch;
    min-height: 360px;
    color: var(--bx-ink-fg);
    text-decoration: none;
}
.bx-post-feature-copy { display: flex; flex-direction: column; gap: 16px; }
.bx-post-feature .bx-post-cat { color: var(--bx-ink-accent); }
.bx-post-feature .bx-post-excerpt { color: var(--bx-ink-text); -webkit-line-clamp: 4; max-width: 52ch; }
.bx-post-feature .bx-post-meta { color: var(--bx-ink-text); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; }
.bx-post-go { color: var(--bx-ink-fg); font-weight: 700; }
.bx-post-feature-title {
    margin: 0;
    font-family: var(--bx-head);
    font-weight: 500;
    font-size: clamp(2rem, 4vw, 3.6rem);
    line-height: 0.98;
    letter-spacing: -0.04em;
    color: inherit;
    text-wrap: balance;
}
.bx-post-feature .bx-post-img { margin: 0; border-radius: calc(var(--bx-radius) - 8px); aspect-ratio: auto; min-height: 220px; }
.bx-post-feature:not(:has(.bx-post-img)) { grid-template-columns: 1fr; min-height: 300px; }

/* ── Artículo ─────────────────────────────────────────────────────── */
.bx-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-bottom: 14px; color: var(--bx-text); }
.bx-crumbs a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: var(--bx-text); font-weight: 600; text-decoration: none; }
.bx-crumbs a:hover { color: var(--bx-fg); }
.bx-post-intro { display: flex; flex-direction: column; min-height: 340px; }
.bx-post-intro .bx-case-sector { margin: 0; color: var(--bx-text); }
.bx-post-h1 {
    margin: auto 0 0;
    padding-top: 40px;
    max-width: 22ch;
    font-family: var(--bx-head);
    font-weight: 500;
    font-size: clamp(2.3rem, 5.2vw, 4.8rem);
    line-height: 0.98;
    letter-spacing: -0.045em;
    overflow-wrap: break-word;
    text-wrap: balance;
    color: inherit;
}
.bx-post-lead { max-width: 62ch; }
.bx-post-byline { margin: 24px 0 0; color: var(--bx-text); line-height: 1.6; }
.bx-post-byline a { color: var(--bx-fg); text-decoration: underline; text-decoration-color: var(--bx-accent); text-underline-offset: 3px; }
.bx-post-cover { margin: var(--bx-gap) 0 0; }
.bx-post-cover img {
    display: block;
    width: 100%;
    max-height: 640px;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: var(--bx-radius);
    background: var(--bx-card);
}

.bx-post-body {
    display: grid;
    grid-template-columns: minmax(0, 72ch);
    justify-content: center;
    gap: clamp(32px, 4vw, 64px);
    padding-top: clamp(40px, 5vw, 72px);
}
.bx-post-body.has-toc { grid-template-columns: minmax(200px, 280px) minmax(0, 72ch); }
.bx-toc { position: sticky; top: calc(var(--nav-height, 64px) + 24px); align-self: start; max-height: calc(100vh - var(--nav-height, 64px) - 48px); overflow: auto; }
.bx-toc .bx-mono { margin: 0 0 14px; color: var(--bx-text); }
.bx-toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--bx-line); }
.bx-toc li a { display: block; padding: 7px 0 7px 16px; margin-left: -1px; border-left: 2px solid transparent; color: var(--bx-text); font-size: 0.93rem; line-height: 1.4; text-decoration: none; }
.bx-toc li a:hover { color: var(--bx-fg); border-left-color: var(--bx-accent); }
.bx-toc .bx-toc-l3 a { padding-left: 30px; font-size: 0.88rem; }

/* Cuerpo del artículo: el HTML viene del editor (Quill) o de scripts/blog_upsert.py */
.bx-prose { min-width: 0; font-size: 1.1rem; line-height: 1.75; color: var(--bx-text); }
.bx-prose > :first-child { margin-top: 0; }
.bx-prose h1, .bx-prose h2, .bx-prose h3, .bx-prose h4 {
    font-family: var(--bx-head);
    font-weight: 500;
    color: var(--bx-fg);
    letter-spacing: -0.03em;
    scroll-margin-top: calc(var(--nav-height, 64px) + 24px);
    text-wrap: balance;
}
.bx-prose h1, .bx-prose h2 { margin: 2.4em 0 0.6em; font-size: clamp(1.7rem, 2.6vw, 2.25rem); line-height: 1.1; }
.bx-prose h3 { margin: 2em 0 0.5em; font-size: clamp(1.3rem, 1.8vw, 1.55rem); line-height: 1.2; }
.bx-prose h4 { margin: 1.6em 0 0.4em; font-size: 1.15rem; letter-spacing: -0.01em; }
.bx-prose p, .bx-prose ul, .bx-prose ol, .bx-prose blockquote, .bx-prose pre, .bx-prose figure, .bx-prose table { margin: 0 0 1.25em; }
.bx-prose ul, .bx-prose ol { padding-left: 1.4em; }
.bx-prose li { margin-bottom: 0.4em; }
.bx-prose li::marker { color: var(--bx-accent); }
.bx-prose strong, .bx-prose b { color: var(--bx-fg); font-weight: 700; }
.bx-prose a { color: var(--bx-fg); text-decoration: underline; text-decoration-color: var(--bx-accent); text-decoration-thickness: 2px; text-underline-offset: 3px; overflow-wrap: anywhere; }
.bx-prose a:hover { color: var(--bx-accent); }
.bx-prose img, .bx-prose video, .bx-prose iframe { display: block; max-width: 100%; height: auto; margin: 1.6em auto; border-radius: 16px; }
.bx-prose iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; }
.bx-prose figure img { margin-bottom: 0.6em; }
.bx-prose figcaption { font-size: 0.9rem; color: var(--bx-text); text-align: center; }
.bx-prose blockquote {
    padding: 1.1em 1.4em;
    border-left: 3px solid var(--bx-accent);
    border-radius: 0 16px 16px 0;
    background: var(--bx-card);
    color: var(--bx-fg);
}
.bx-prose blockquote > :last-child { margin-bottom: 0; }
.bx-prose hr { margin: 2.5em 0; border: 0; border-top: 1px solid var(--bx-line); }
.bx-prose code {
    padding: 0.12em 0.4em;
    border-radius: 6px;
    background: var(--bx-card);
    color: var(--bx-fg);
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.88em;
}
.bx-prose pre, .bx-prose pre.ql-syntax {
    padding: 1.1em 1.3em;
    overflow-x: auto;
    border-radius: 16px;
    background: var(--bx-ink-bg);
    color: var(--bx-ink-fg);
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.88rem;
    line-height: 1.6;
    white-space: pre;
}
.bx-prose pre code { padding: 0; background: none; color: inherit; font-size: inherit; }
.bx-prose table { display: block; width: 100%; overflow-x: auto; border-collapse: collapse; font-size: 0.96rem; }
.bx-prose th, .bx-prose td { padding: 0.65em 0.9em; border-bottom: 1px solid var(--bx-line); text-align: left; vertical-align: top; }
.bx-prose th { color: var(--bx-fg); font-weight: 700; }
/* Clases de alineado/sangría que deja Quill */
.bx-prose .ql-align-center { text-align: center; }
.bx-prose .ql-align-right { text-align: right; }
.bx-prose .ql-align-justify { text-align: justify; }
.bx-prose .ql-indent-1 { padding-left: 2em; }
.bx-prose .ql-indent-2 { padding-left: 4em; }

.bx-post-tags { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 2.5em 0 0 !important; padding: 0 !important; }
.bx-post-tags li { margin: 0; padding: 8px 14px; border: 1px solid var(--bx-line); border-radius: 999px; color: var(--bx-text); }
.bx-post-tags li::before { content: "#"; margin-right: 2px; color: var(--bx-accent); }

.bx-post-faq details p { max-width: 60ch; }

/* ── Autor ────────────────────────────────────────────────────────── */
.bx-author { display: flex; flex-wrap: wrap; align-items: flex-start; gap: clamp(20px, 3vw, 40px); }
.bx-author-photo { flex: 0 0 auto; width: 160px; height: 160px; border-radius: 20px; object-fit: cover; }
.bx-author--small .bx-author-photo { width: 96px; height: 96px; border-radius: 16px; }
.bx-author-copy { flex: 1 1 320px; display: flex; flex-direction: column; gap: 10px; }
.bx-author-copy > * { margin: 0; }
.bx-author-name {
    font-family: var(--bx-head);
    font-weight: 500;
    font-size: clamp(2.4rem, 5vw, 4.4rem);
    line-height: 0.95;
    letter-spacing: -0.045em;
    color: var(--bx-fg);
}
.bx-author--small .bx-author-name { font-size: clamp(1.5rem, 2.4vw, 2rem); letter-spacing: -0.03em; }
.bx-author-name a { color: inherit; text-decoration: none; }
.bx-author-name a:hover { color: var(--bx-accent); }
.bx-author-role { font-weight: 700; color: var(--bx-fg); }
.bx-author-bio { max-width: 64ch; line-height: 1.6; color: var(--bx-text); }
.bx-author-knows { color: var(--bx-text); line-height: 1.6; }
.bx-author-links { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.bx-author-links a { display: inline-flex; align-items: center; min-height: 44px; color: var(--bx-fg); font-weight: 600; text-decoration: underline; text-decoration-color: var(--bx-accent); text-underline-offset: 3px; }

.bx-cta-kicker { margin: 0 0 20px !important; color: var(--bx-ink-accent) !important; }

/* ── Pantallas medianas y móvil ───────────────────────────────────── */
@media (max-width: 1100px) {
    .bx-post { grid-column: span 6; }
    .bx-post-body.has-toc { grid-template-columns: minmax(0, 72ch); }
    .bx-toc { position: static; max-height: none; padding: 20px 24px; border-radius: var(--bx-radius); background: var(--bx-card); }
    .bx-toc ol { border-left: 0; }
    .bx-toc li a { padding-left: 0; border-left: 0; }
    .bx-toc .bx-toc-l3 a { padding-left: 16px; }
}
@media (max-width: 720px) {
    .bx-post { min-height: 0; }
    .bx-post-feature { grid-template-columns: 1fr; min-height: 0; }
    .bx-post-feature .bx-post-img { order: -1; aspect-ratio: 16 / 9; min-height: 0; }
    .bx-post-intro { min-height: 260px; }
    .bx-prose { font-size: 1.04rem; }
    .bx-author-photo { width: 96px; height: 96px; }
}
