/* ==========================================================================
   Blog styles: /blog/ index, article pages and the series card used on the
   home page. Uses the tokens defined in /styles.css.
   ========================================================================== */

/* ---------- Series card (home + blog index) ---------- */
.series-feature-inner {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.25fr);
    gap: clamp(1.75rem, 4vw, 3rem);
    padding: clamp(1.5rem, 3vw, 2.25rem);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background:
        radial-gradient(90% 120% at 0% 0%, var(--accent-soft), transparent 55%),
        var(--surface);
}

.series-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.9rem;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500;
}

.series-feature-title {
    font-size: clamp(1.5rem, 1.5vw + 1rem, 1.9rem);
    letter-spacing: -0.03em;
}

.series-feature-head > p:not(.series-label) {
    margin: 0.8rem 0 1.6rem;
    color: var(--muted);
}

.series-feature-list li + li {
    border-top: 1px solid var(--line);
}

.series-feature-list a {
    display: flex;
    gap: 1rem;
    padding: 0.85rem 0.6rem;
    border-radius: var(--radius-sm);
    color: inherit;
    text-decoration: none;
    transition: background-color 0.2s var(--ease);
}

.series-feature-list a:hover {
    background: var(--surface-2);
}

.series-num {
    padding-top: 0.1rem;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.series-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.series-title {
    color: var(--ink);
    font-weight: 600;
    line-height: 1.35;
}

.series-desc {
    color: var(--muted);
    font-size: 0.875rem;
}

/* ---------- Post cards ---------- */
.post-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: 1.25rem;
}

.post-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease), transform 0.25s var(--ease);
}

.post-card:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}

.post-card-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1.4rem 1.5rem;
    color: inherit;
    text-decoration: none;
}

.post-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.9rem;
}

.post-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.55rem;
    border-radius: 5px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 600;
}

.post-part {
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
}

.post-card-title {
    margin-bottom: 0.5rem;
    font-size: 1.15rem;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.post-card-link:hover .post-card-title {
    color: var(--accent);
}

.post-card-desc {
    flex: 1;
    margin-bottom: 1.1rem;
    color: var(--muted);
    font-size: 0.95rem;
}

.post-card-foot {
    display: flex;
    gap: 0.5rem;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

/* ---------- Blog index ---------- */
.blog-hero {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    padding: clamp(3.5rem, 7vw, 5.5rem) 0 clamp(2.5rem, 5vw, 3.5rem);
    border-bottom: 1px solid var(--line);
}

.blog-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image: radial-gradient(var(--grid-dot) 1px, transparent 1.2px);
    background-size: 22px 22px;
    -webkit-mask-image: radial-gradient(ellipse 70% 90% at 85% 0%, #000 20%, transparent 75%);
    mask-image: radial-gradient(ellipse 70% 90% at 85% 0%, #000 20%, transparent 75%);
}

.blog-hero h1 {
    font-size: clamp(2.3rem, 3.5vw + 1rem, 3.5rem);
    line-height: 1.05;
    letter-spacing: -0.04em;
}

.blog-lede {
    max-width: 40rem;
    margin: 1rem 0 2rem;
    color: var(--muted);
    font-size: 1.1rem;
}

.blog-tools {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.blog-search {
    position: relative;
    max-width: 32rem;
}

.blog-search i {
    position: absolute;
    top: 50%;
    left: 1rem;
    color: var(--muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.blog-search input {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 2.6rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font-size: 1rem;
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.blog-search input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 36px;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease);
}

.chip:hover {
    border-color: var(--accent-line);
    color: var(--accent);
}

.chip.active {
    border-color: var(--ink);
    background: var(--ink);
    color: var(--bg);
}

.chip-count {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    opacity: 0.7;
}

.series-feature {
    padding-top: clamp(2.5rem, 5vw, 3.5rem);
}

.blog-list {
    padding: clamp(2.5rem, 5vw, 3.5rem) 0 clamp(4rem, 8vw, 6rem);
}

.blog-list-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.blog-list-head h2 {
    font-size: 1.5rem;
    letter-spacing: -0.025em;
}

.blog-result-count {
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.blog-empty {
    padding: 2.5rem 1rem;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-lg);
    color: var(--muted);
    text-align: center;
}

.link-btn {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    text-decoration: underline;
    text-underline-offset: 0.2em;
    cursor: pointer;
}

/* ---------- Article page ---------- */
.post-container {
    max-width: calc(46rem + 2 * var(--gutter));
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.post-header {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    margin-bottom: clamp(2rem, 5vw, 3rem);
    padding: clamp(2.5rem, 6vw, 4rem) 0 clamp(2rem, 4vw, 2.75rem);
    border-bottom: 1px solid var(--line);
}

.post-header::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image: radial-gradient(var(--grid-dot) 1px, transparent 1.2px);
    background-size: 22px 22px;
    -webkit-mask-image: radial-gradient(ellipse 60% 100% at 90% 0%, #000 15%, transparent 70%);
    mask-image: radial-gradient(ellipse 60% 100% at 90% 0%, #000 15%, transparent 70%);
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.4rem;
    font-size: 0.875rem;
}

.breadcrumb a {
    color: var(--muted);
    text-decoration: none;
}

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

.breadcrumb i {
    color: var(--line-strong);
    font-size: 0.6rem;
}

.post-kicker {
    margin-bottom: 0.75rem;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 500;
}

.post-title {
    font-size: clamp(2rem, 3.2vw + 1rem, 3rem);
    line-height: 1.08;
    letter-spacing: -0.04em;
}

.post-subtitle {
    margin-top: 0.9rem;
    color: var(--muted);
    font-size: clamp(1.1rem, 0.5vw + 1rem, 1.3rem);
    line-height: 1.5;
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.65rem;
    margin-top: 1.6rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.post-author {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--ink);
    font-weight: 550;
}

.post-author img {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    object-fit: cover;
}

.series-box {
    margin-bottom: 2.25rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.series-box summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.1rem;
    color: var(--ink);
    font-weight: 600;
    list-style: none;
    cursor: pointer;
}

.series-box summary::-webkit-details-marker {
    display: none;
}

.series-box summary i {
    margin-right: 0.4rem;
    color: var(--accent);
}

.series-count {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 400;
}

.series-count::after {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 0.2s var(--ease);
}

.series-box[open] .series-count::after {
    transform: translateY(1px) rotate(-135deg);
}

.series-list {
    padding: 0 1.1rem 0.9rem;
    counter-reset: part;
}

.series-list li {
    display: flex;
    gap: 0.75rem;
    padding: 0.4rem 0;
    font-size: 0.95rem;
    counter-increment: part;
}

.series-list li::before {
    content: counter(part, decimal-leading-zero);
    padding-top: 0.15rem;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.series-list a {
    color: var(--text);
    text-decoration: none;
}

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

.series-list li.current a {
    color: var(--accent);
    font-weight: 600;
}

/* Article typography */
.post-body {
    color: var(--text);
    font-size: 1.1rem;
    line-height: 1.78;
}

.post-body > * + * {
    margin-top: 1.3rem;
}

.post-body h2 {
    margin-top: 2.75rem;
    font-size: 1.55rem;
    line-height: 1.25;
    letter-spacing: -0.025em;
}

.post-body h3 {
    margin-top: 2rem;
    font-size: 1.2rem;
}

.post-body strong {
    color: var(--ink);
    font-weight: 600;
}

.post-body ul,
.post-body ol {
    padding-left: 1.35rem;
}

.post-body li + li {
    margin-top: 0.6rem;
}

.post-body li::marker {
    color: var(--accent);
}

.post-body code {
    padding: 0.12em 0.38em;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--surface-2);
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 0.86em;
}

.post-body pre {
    margin: 0;
    padding: 1.2rem 1.35rem;
    overflow-x: auto;
    border: 1px solid var(--code-line);
    border-radius: var(--radius);
    background: var(--code-bg);
    color: var(--code-text);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.7;
    tab-size: 4;
    -webkit-overflow-scrolling: touch;
}

.post-body pre,
.post-body code {
    font-variant-ligatures: none;
}

.post-body pre code {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font-size: inherit;
    white-space: pre;
}

.post-body div.highlighter-rouge,
.post-body figure.highlight {
    margin-inline: 0;
}

.post-body blockquote {
    margin-inline: 0;
    padding: 1.15rem 1.35rem;
    border: 1px solid var(--accent-line);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--accent-soft);
    color: var(--ink);
}

.post-body blockquote p {
    margin: 0;
}

/* Rouge syntax colours (shared palette with the home page code panel) */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .sd { color: #8f8a84; font-style: italic; }
.highlight .k, .highlight .kn, .highlight .kd, .highlight .kc, .highlight .ow { color: #f2a477; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sr, .highlight .sa, .highlight .si { color: #a8dba8; }
.highlight .se { color: #f5d17a; }
.highlight .m, .highlight .mi, .highlight .mf { color: #f2a477; }
.highlight .nf, .highlight .fm { color: #8ec5ff; }
.highlight .nd { color: #f5d17a; }
.highlight .nb, .highlight .bp { color: #8ec5ff; }
.highlight .o, .highlight .p { color: #cfcac4; }

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 2.75rem;
}

.post-tags li {
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--surface-2);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.post-share {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.post-share .icon-btn {
    width: 38px;
    height: 38px;
    color: var(--muted);
}

.post-share .icon-btn:hover,
.post-share .icon-btn.is-copied {
    color: var(--accent);
}

.post-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 2.75rem;
    padding-top: 2rem;
    border-top: 1px solid var(--line);
}

.post-nav-link {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 1rem 1.2rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    text-decoration: none;
    transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.post-nav-link:hover {
    border-color: var(--accent-line);
    transform: translateY(-2px);
}

.post-nav-link.next {
    grid-column: 2;
    text-align: right;
}

.post-nav-label {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
}

.post-nav-title {
    color: var(--ink);
    font-weight: 600;
    line-height: 1.35;
}

.author-box {
    display: flex;
    align-items: flex-start;
    gap: 1.1rem;
    margin: 2.5rem 0 clamp(4rem, 8vw, 6rem);
    padding: 1.5rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.author-box img {
    width: 60px;
    height: 60px;
    flex: none;
    border-radius: 16px;
    object-fit: cover;
}

.author-name {
    color: var(--ink);
    font-weight: 600;
}

.author-bio {
    margin: 0.25rem 0 0.65rem;
    color: var(--muted);
    font-size: 0.95rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .series-feature-inner {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 600px) {
    .post-body {
        font-size: 1.04rem;
    }

    .post-body pre {
        margin-inline: calc(var(--gutter) * -1);
        border-inline: 0;
        border-radius: 0;
    }

    .post-nav {
        grid-template-columns: minmax(0, 1fr);
    }

    .post-nav-link.next {
        grid-column: 1;
    }

    .author-box {
        flex-direction: column;
    }
}
