/* ==========================================================================
   Blog - additive layer on top of site.css.
   Only what the blog needs and the design system does not already provide:
   the filter chips, the featured card, the article layout, the pager and the
   in-article calculator block. Everything else reuses .card, .prose, .toc,
   .post-grid, .pill and .crumbs from site.css.
   Tokens only, so light and dark both come for free.
   ========================================================================== */

/* --- Archive head and category chips ------------------------------------ */

.blog-head .section__head { margin-bottom: 1.5rem; }

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .5rem .95rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: .87rem;
    font-weight: 600;
    text-decoration: none;
    line-height: 1.2;
    transition: border-color .2s var(--ease-out), background .2s var(--ease-out),
                color .2s var(--ease-out), transform .2s var(--ease-out);
}

.chip:hover {
    border-color: var(--brand-400);
    background: var(--brand-50);
    color: var(--brand-600);
    transform: translateY(-2px);
}

.chip.is-active {
    border-color: var(--brand-600);
    background: var(--brand-600);
    color: #fff;
}

.chip.is-active:hover { color: #fff; background: var(--brand-600); }

.chip__count {
    display: inline-grid;
    place-items: center;
    min-width: 1.35em;
    padding: 0 .35em;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--text-faint);
    font-size: .74rem;
    font-weight: 700;
}

.chip.is-active .chip__count { background: rgba(255, 255, 255, .22); color: #fff; }

.chip--tag { font-weight: 500; }

.chips--tags { margin-top: 2.5rem; }

/* --- Featured post ------------------------------------------------------- */

.feature {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
    gap: clamp(1.5rem, 1rem + 2.5vw, 3rem);
    align-items: center;
    padding: clamp(1.6rem, 1.1rem + 2vw, 2.8rem);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background:
        radial-gradient(120% 140% at 100% 0%, var(--brand-50), transparent 62%),
        var(--surface);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    transition: transform .3s var(--ease-out), box-shadow .3s var(--ease-out), border-color .3s var(--ease-out);
}

.feature:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--brand-300);
    color: inherit;
}

.feature__flag {
    position: absolute;
    top: 0;
    left: clamp(1.6rem, 1.1rem + 2vw, 2.8rem);
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .8rem .4rem;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    background: var(--accent-500);
    color: #21160a;
    font-size: .74rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.feature__body { padding-top: 1.2rem; }

.feature__title {
    font-family: var(--font-display);
    font-size: var(--step-3);
    font-weight: 800;
    letter-spacing: -0.025em;
    margin-bottom: .5rem;
}

.feature__text {
    font-size: var(--step-0);
    color: var(--text-muted);
    max-width: 56ch;
    margin-bottom: 1.1rem;
}

.feature:hover .card__meta .icon { translate: 4px 0; transition: translate .2s; }

.feature__aside {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    padding: 1.4rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.feature__asideLabel {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    font-weight: 700;
    color: var(--text-faint);
}

.feature__asideValue {
    font-family: var(--font-display);
    font-size: var(--step-2);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--brand-600);
}

.feature__asideNote { font-size: .8rem; color: var(--text-muted); }

.feature__bars {
    display: flex;
    align-items: flex-end;
    gap: .4rem;
    height: 62px;
    margin-top: 1rem;
}

.feature__bar {
    flex: 1;
    border-radius: 4px 4px 0 0;
    background: linear-gradient(180deg, var(--brand-300), var(--brand-500));
    transform-origin: bottom;
}

.feature__bar--accent { background: linear-gradient(180deg, var(--accent-400), var(--accent-600)); }

/* --- Pager --------------------------------------------------------------- */

.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    margin-top: clamp(2rem, 1.5rem + 1.5vw, 3rem);
}

.pager__step {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .6rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: .88rem;
    font-weight: 600;
    text-decoration: none;
}

.pager__step:hover { border-color: var(--brand-400); color: var(--brand-600); background: var(--brand-50); }
.pager__back { transform: rotate(180deg); }

.pager__pages { display: flex; gap: .35rem; list-style: none; margin: 0; padding: 0; }
.pager__pages li { margin: 0; }

.pager__page {
    display: grid;
    place-items: center;
    min-width: 2.4rem;
    height: 2.4rem;
    padding: 0 .5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    font-size: .88rem;
    font-weight: 700;
    text-decoration: none;
}

.pager__page:hover { border-color: var(--brand-400); color: var(--brand-600); }

.pager__page.is-active {
    border-color: var(--brand-600);
    background: var(--brand-600);
    color: #fff;
}

/* --- Article ------------------------------------------------------------- */

.post-hero { max-width: 76ch; margin-bottom: clamp(1.75rem, 1.2rem + 2vw, 2.75rem); }

.post-hero__title {
    font-size: var(--step-4);
    letter-spacing: -0.03em;
    margin-bottom: .55rem;
}

.post-hero__updated {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    margin: 1rem 0 0;
    padding: .38rem .8rem;
    border-radius: 999px;
    background: var(--good-100);
    color: var(--good-600);
    font-size: .8rem;
    font-weight: 600;
}

.post-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: clamp(1.75rem, 1rem + 3vw, 3.5rem);
    align-items: start;
}

.post-main { min-width: 0; }
.post-main .toc { margin-bottom: 2.5rem; }
.post-main .prose { max-width: 74ch; }

/* Markdig gives every heading an id; the anchor styling keeps them quiet until hovered. */
.prose h2 > a, .prose h3 > a { text-decoration: none; }

.post-aside {
    position: sticky;
    top: 92px;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.aside__list--plain li {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: .5rem;
    border-bottom: 1px dashed var(--border);
}

.aside__list--plain li:last-child { border-bottom: 0; padding-bottom: 0; margin-bottom: 0; }
.aside__list--plain li > span:first-child { color: var(--text-faint); }
.aside__list--plain li > span:last-child,
.aside__list--plain li > a { font-weight: 700; color: var(--text); text-align: right; }
.aside__list--plain li > a { color: var(--brand-600); text-decoration: none; }
.aside__list--plain li > a:hover { text-decoration: underline; }

/* --- In-article calculator block ----------------------------------------- */

.calc-block {
    margin-top: 3rem;
    padding: clamp(1.4rem, 1rem + 1.6vw, 2.2rem);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-2);
}

.calc-block__title {
    display: flex;
    align-items: center;
    gap: .55rem;
    font-size: var(--step-1);
    margin-bottom: .35rem;
}

.calc-block__title .icon { color: var(--brand-500); }
.calc-block__text { font-size: .92rem; color: var(--text-muted); margin-bottom: 1.4rem; }

.calc-cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.calc-card { background: var(--surface); }

/* --- Author -------------------------------------------------------------- */

.author {
    display: flex;
    gap: 1.1rem;
    margin-top: 2.5rem;
    padding: 1.4rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.author__mark {
    display: grid;
    place-items: center;
    flex: none;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(140deg, var(--brand-100), var(--brand-50));
    color: var(--brand-600);
}

.author__name { font-family: var(--font-display); font-weight: 700; margin-bottom: .2rem; }
.author__text { font-size: .88rem; color: var(--text-muted); margin: 0; }

/* --- Closing call to action ---------------------------------------------- */

.blog-cta {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: clamp(1.5rem, 1rem + 2vw, 3rem);
    align-items: center;
    padding: clamp(1.75rem, 1.2rem + 2.4vw, 3rem);
    border-radius: var(--radius-lg);
    background: linear-gradient(140deg, var(--brand-700), var(--brand-900));
    box-shadow: var(--shadow-glow);
}

.blog-cta__label {
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    font-weight: 700;
    color: rgba(255, 255, 255, .68);
    margin-bottom: .35rem;
}

.blog-cta__title { color: #fff; margin-bottom: .6rem; font-size: var(--step-2); }
.blog-cta__text { color: rgba(234, 242, 251, .82); font-size: .95rem; max-width: 56ch; margin: 0; }

.blog-cta__actions { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: flex-end; }

/* --- Responsive ---------------------------------------------------------- */

@media (max-width: 1000px) {
    .post-layout { grid-template-columns: minmax(0, 1fr); }
    .post-aside { position: static; flex-direction: row; flex-wrap: wrap; }
    .post-aside > .aside__panel { flex: 1 1 260px; }
}

@media (max-width: 860px) {
    .feature { grid-template-columns: minmax(0, 1fr); }
    .feature__aside { order: -1; }
    .blog-cta { grid-template-columns: minmax(0, 1fr); }
    .blog-cta__actions { justify-content: flex-start; }
}

@media (max-width: 560px) {
    .chips { gap: .4rem; }
    .chip { padding: .42rem .75rem; font-size: .82rem; }
    .pager__pages { order: 3; width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
    .chip, .feature, .pager__step { transition: none; }
    .feature:hover { transform: none; }
}
