/* ==================================================================
   Design System — Monochrome, minimal, mobile-first
   ================================================================== */

/* ---- Theme tokens ---- */
:root,
[data-theme="light"] {
    --bg: #faf5ee;
    --bg-secondary: #f1e6d8;
    --text: #2b2420;
    --text-muted: #8a7a68;
    --border: #e4d5c1;
    --accent: #b5502e;
    --accent-secondary: #6e7f5c;

    --cat-homelab: #b5502e;
    --cat-retro-gaming: #b08a3e;
    --cat-certs: #6e7f5c;
    --cat-musings: #9c6b63;

    --code-bg: #f1e6d8;
    --code-border: #e4d5c1;

    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
    --font-serif: 'Playfair Display', 'Merriweather', 'Georgia', serif;

    --max-width: 680px;
    --header-height: 56px;
}

[data-theme="dark"] {
    --bg: #1c1712;
    --bg-secondary: #262019;
    --text: #f0e6d8;
    --text-muted: #a8987f;
    --border: #3b3226;
    --accent: #e08a5b;
    --accent-secondary: #8fa379;

    --cat-homelab: #e08a5b;
    --cat-retro-gaming: #d1a85c;
    --cat-certs: #8fa379;
    --cat-musings: #be8a81;

    --code-bg: #262019;
    --code-border: #3b3226;
}

/* ---- Reset ---- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ---- Base ---- */
html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    font-weight: 400;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg);
    transition: background 0.15s ease, color 0.15s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: opacity 0.15s ease;
}

a:hover {
    opacity: 0.6;
}

img {
    max-width: 100%;
    height: auto;
}

/* ---- Fluid typography ---- */
h1 {
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.75rem;
}

h2 {
    font-size: clamp(1.35rem, 3vw, 1.65rem);
    font-weight: 600;
    line-height: 1.3;
    margin-top: 2rem;
    margin-bottom: 0.5rem;
}

h3 {
    font-size: clamp(1.1rem, 2.5vw, 1.3rem);
    font-weight: 600;
    line-height: 1.4;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

h4,
h5,
h6 {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
}


/* ==================================================================
   Header
   ================================================================== */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    height: var(--header-height);
    transition: background 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.site-header.scrolled {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border-bottom-color: transparent;
}

[data-theme="dark"] .site-header.scrolled {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.header-inner {
    padding: 0 1.5rem;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.4rem;
    text-decoration: none;
    letter-spacing: -0.03em;
    white-space: nowrap;
    flex-shrink: 0;
}

.header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

/* ---- Reading Progress Bar ---- */
#reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: var(--accent);
    z-index: 1000;
    width: 0%;
    transition: width 0.1s ease-out;
    pointer-events: none;
}


/* ---- Search bar ---- */

.search-bar {
    flex: 1;
    max-width: 420px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    transition: border-color 0.15s ease;
}

.search-bar:focus-within {
    border-color: var(--accent);
}

.search-icon {
    flex-shrink: 0;
    color: var(--text-muted);
}

.search-bar input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-family: var(--font-sans);
    font-size: 0.88rem;
    color: var(--text);
    min-width: 0;
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

.search-shortcut {
    flex-shrink: 0;
    font-family: var(--font-sans);
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.1em 0.4em;
    line-height: 1.4;
}


/* ---- Nav ---- */

.site-nav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-shrink: 0;
    margin-left: auto;
}

.site-nav a {
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-muted);
    transition: color 0.15s ease;
    white-space: nowrap;
}

.site-nav a:hover {
    color: var(--accent);
    opacity: 1;
}


/* ---- Theme toggle ---- */

.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    width: 34px;
    height: 34px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s ease;
    flex-shrink: 0;
}

.theme-toggle:hover {
    border-color: var(--accent);
}

/* Sun icon (shown in dark mode — click to go light) */
[data-theme="dark"] .theme-icon::before {
    content: "☀";
    font-size: 1rem;
}

/* Moon icon (shown in light mode — click to go dark) */
[data-theme="light"] .theme-icon::before {
    content: "☽";
    font-size: 1rem;
}

/* ---- Mobile header ---- */
@media (max-width: 640px) {
    .header-inner {
        gap: 0.75rem;
        padding: 0 1rem;
    }

    .site-logo {
        font-size: 1.15rem;
    }

    .search-shortcut {
        display: none;
    }

    .site-nav a {
        font-size: 0.8rem;
    }

    .site-nav {
        gap: 0.75rem;
    }
}


/* ==================================================================
   Main content area
   ================================================================== */

.site-main {
    flex: 1;
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 2.5rem 3rem;
}


/* ==================================================================
   Footer
   ================================================================== */

.site-footer {
    border-top: 1px solid var(--border);
    padding: 1.5rem 2.5rem;
}

.footer-inner {
    max-width: 1020px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.footer-copy {
    margin: 0;
}

.footer-social {
    display: flex;
    gap: 1rem;
}

.footer-social a {
    display: flex;
    align-items: center;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.footer-social a:hover {
    transform: translateY(-2px);
    filter: brightness(1.2);
}

.footer-social svg {
    width: 20px;
    height: 20px;
}

@media (max-width: 640px) {
    .footer-inner {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }
}


/* ==================================================================
   About page
   ================================================================== */

.about-page {
    max-width: var(--max-width);
}

.about-hero {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.about-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.about-intro h1 {
    font-family: var(--font-serif);
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.about-tagline {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin: 0;
}

.about-social {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.about-social-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.about-social-link:hover {
    transform: translateY(-2px);
    filter: brightness(1.2);
    opacity: 1;
}

.about-social-link svg {
    width: 28px;
    height: 28px;
}

@media (max-width: 640px) {
    .about-hero {
        flex-direction: column;
        text-align: center;
    }

    .about-social {
        flex-wrap: wrap;
        justify-content: center;
    }
}


/* ==================================================================
   Bio section (landing page)
   ================================================================== */

.bio {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem 0 1.75rem;
    margin-bottom: 1rem;
}

.bio-avatar {
    flex-shrink: 0;
}

.bio-avatar img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid var(--border);
    object-fit: cover;
}

[data-theme="dark"] .bio-avatar img {
    filter: invert(1);
}

.bio-name {
    font-size: clamp(1.5rem, 3.5vw, 1.85rem);
    letter-spacing: -0.03em;
    margin-bottom: 0.2rem;
}

.bio-text {
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1.55;
    max-width: 460px;
}

@media (max-width: 640px) {
    .bio {
        flex-direction: column;
        text-align: center;
    }

    .bio-text {
        max-width: 100%;
    }
}


/* ==================================================================
   Latest posts section (landing page)
   ================================================================== */

.section-heading {
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.view-all-link {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.post-card-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}


/* ==================================================================
   Index two-column layout
   ================================================================== */

.index-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem 2.5rem;
    align-items: start;
}

.index-layout .bio {
    grid-column: 1 / -1;
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.index-layout .bento-grid {
    grid-column: 1 / -1;
}

.index-layout .recent-strip {
    grid-column: 1 / -1;
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}


/* ==================================================================
   Bento category grid (landing page)
   ================================================================== */

.bento-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: 116px 116px;
    gap: 12px;
    margin-bottom: 2.5rem;
}

.bento-tile-homelab { grid-column: 1 / 3; grid-row: 1 / 3; }
.bento-tile-retro-gaming { grid-column: 3 / 4; grid-row: 1 / 2; }
.bento-tile-certs { grid-column: 4 / 5; grid-row: 1 / 2; }
.bento-tile-musings { grid-column: 3 / 5; grid-row: 2 / 3; }

.bento-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1rem 1.15rem;
    border-radius: 16px;
    text-decoration: none;
    color: var(--text);
    background: color-mix(in srgb, var(--tile-color) 10%, var(--bg));
    border: 1px solid var(--border);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.bento-tile:hover {
    transform: translateY(-2px);
    border-color: var(--tile-color);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
    opacity: 1;
}

[data-theme="dark"] .bento-tile:hover {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.bento-tile-icon {
    display: block;
    width: 26px;
    height: 26px;
    color: var(--tile-color);
}

.bento-tile-icon svg {
    width: 100%;
    height: 100%;
}

.bento-tile-homelab .bento-tile-icon {
    width: 36px;
    height: 36px;
}

.bento-tile-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 0.15rem;
}

.bento-tile-homelab .bento-tile-title {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    letter-spacing: -0.01em;
}

.bento-tile-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0;
}

.bento-tile-soon {
    font-style: italic;
}

.bento-tile-empty {
    border-style: dashed;
    background: var(--bg-secondary);
}

.bento-tile-empty .bento-tile-icon {
    opacity: 0.55;
}

@media (max-width: 640px) {
    .bento-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: 100px 100px;
    }

    .bento-tile-homelab { grid-column: 1 / 3; grid-row: 1 / 2; }
    .bento-tile-retro-gaming { grid-column: 1 / 2; grid-row: 2 / 3; }
    .bento-tile-certs { grid-column: 2 / 3; grid-row: 2 / 3; }
    .bento-tile-musings { grid-column: 1 / 3; grid-row: 3 / 4; }

    .bento-grid {
        grid-template-rows: 90px 90px 90px;
    }
}


/* ==================================================================
   Recently added strip (landing page)
   ================================================================== */

.recent-strip-items {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.recent-strip-item {
    display: block;
    text-decoration: none;
    color: var(--text);
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: border-color 0.15s ease, transform 0.2s ease;
}

.recent-strip-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    opacity: 1;
}

.recent-strip-cat {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.35rem;
}

.recent-strip-title {
    font-size: 0.88rem;
    font-weight: 600;
    margin: 0 0 0.35rem;
    line-height: 1.35;
}

.recent-strip-date {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .recent-strip-items {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .recent-strip-items {
        grid-template-columns: 1fr;
    }
}

/* Wider main area for the index page */
.site-main.index-wide {
    max-width: 1020px;
    margin: 0 auto;
}

/* Wider main area for post pages to accommodate ToC */
.site-main.post-wide {
    max-width: 1040px;
}


/* ==================================================================
   Topics sidebar
   ================================================================== */

.topics-sidebar {
    position: sticky;
    top: calc(var(--header-height) + 2rem);
    align-self: flex-start;
    padding-left: 2.5rem;
    border-left: 1px solid var(--border);
}

.topics-sidebar .section-heading {
    margin-bottom: 1rem;
}

.topic-card {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    text-decoration: none;
    color: var(--text);
    padding: 1rem 1.15rem;
    border: 1px solid var(--border);
    border-radius: 16px;
    margin-bottom: 0.75rem;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.topic-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    opacity: 1;
}

[data-theme="dark"] .topic-card:hover {
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.04);
}

.topic-badge {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.topic-badge-alt {
    color: var(--accent-secondary);
}

.topic-info {
    min-width: 0;
}

.topic-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
}

.topic-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.45;
    margin: 0.2rem 0 0;
}

/* ---- Social Links ---- */
.social-icons {
    display: flex;
    gap: 1.25rem;
}

.social-icons a {
    transition: transform 0.2s ease, filter 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.social-icons a:hover {
    transform: translateY(-3px);
    filter: brightness(1.2);
}

.social-icons svg {
    width: 32px;
    height: 32px;
    transition: fill 0.2s ease;
}

.icon-github {
    fill: var(--text);
}

.icon-linkedin {
    fill: #0A66C2;
}

.icon-youtube {
    fill: #FF0000;
}

/* ---- Mobile: stack sidebar below content ---- */
@media (max-width: 768px) {
    .index-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .topics-sidebar {
        position: static;
        border-top: 1px solid var(--border);
        border-left: none;
        padding-left: 0;
        padding-top: 1.5rem;
    }

    .site-main.index-wide {
        max-width: var(--max-width);
    }
}


/* ==================================================================
   Blog list
   ================================================================== */

.blog-list h1 {
    margin-bottom: 1.5rem;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.3rem 0.85rem;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.filter-pill:hover {
    color: var(--accent);
    border-color: var(--accent);
    opacity: 1;
}

.filter-pill.active {
    color: var(--bg);
    background: var(--accent);
    border-color: var(--accent);
}

.filter-pill-count {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.filter-pill.active .filter-pill-count {
    color: var(--bg);
    opacity: 0.75;
}

.post-card {
    display: block;
    position: relative;
    text-decoration: none;
    color: var(--text);
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: 16px;
    margin-bottom: 1rem;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.post-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    opacity: 1;
}

[data-theme="dark"] .post-card:hover {
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.04);
}

.post-card-link {
    color: inherit;
    text-decoration: none;
}

.post-card-link::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1;
}

.post-card-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
}

.post-card-thumbnail {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    display: block;
}

.post-card-date {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.post-card-summary {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}


/* ---- Tags ---- */

.tag {
    display: inline-block;
    position: relative;
    z-index: 2;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.15em 0.5em;
    margin-right: 0.35rem;
    text-decoration: none;
    transition: color 0.15s ease, border-color 0.15s ease;
}

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

.post-tags {
    margin-top: 0.75rem;
}


/* ==================================================================
   Blog post
   ================================================================== */

.post-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 240px;
    gap: 3rem;
    align-items: start;
}

@media (max-width: 900px) {
    .post-layout {
        grid-template-columns: 1fr;
    }

    #toc-container {
        display: none;
    }

    .site-main.post-wide {
        max-width: var(--max-width);
    }
}

#toc-container {
    position: sticky;
    top: calc(var(--header-height) + 2rem);
    font-size: 0.85rem;
}

#toc-container ul {
    list-style: none;
    padding-left: 0;
}

#toc-container ul ul {
    padding-left: 1rem;
    margin-top: 0.35rem;
}

#toc-container li {
    margin-bottom: 0.5rem;
}

#toc-container a {
    text-decoration: none;
    color: var(--text-muted);
    transition: color 0.15s ease;
}

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

.header-anchor {
    text-decoration: none;
    color: var(--border);
    margin-left: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease, color 0.2s ease;
    font-weight: normal;
}

h2:hover .header-anchor,
h3:hover .header-anchor,
h4:hover .header-anchor {
    opacity: 1;
}

.header-anchor:hover {
    color: var(--accent);
}

.post-hero-thumbnail {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 2rem;
    border: 1px solid var(--border);
    display: block;
}

.post-header {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.post-header h1 {
    font-family: var(--font-serif);
    font-size: clamp(2.25rem, 5vw, 3rem);
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.post-header time {
    display: block;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.post-footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.post-footer a {
    font-size: 0.9rem;
    font-weight: 500;
}


/* ==================================================================
   Prose — rendered Markdown content
   ================================================================== */

.prose p {
    margin-bottom: 1.25rem;
}

.prose ul,
.prose ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}

.prose li {
    margin-bottom: 0.35rem;
}

.prose blockquote {
    border-left: 3px solid var(--border);
    padding-left: 1rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    font-style: italic;
}

.prose hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

.prose img {
    margin: 1.5rem 0;
    border-radius: 4px;
}

/* Inline code */
.prose code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 3px;
    padding: 0.15em 0.35em;
}

/* Code blocks */
.prose pre {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 4px;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.prose pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.85rem;
}

/* Tables */
.prose table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

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

.prose th {
    font-weight: 600;
}


/* ==================================================================
   Docs layout
   ================================================================== */

.docs-layout {
    display: flex;
    gap: 2rem;
}

.docs-sidebar {
    flex-shrink: 0;
    width: 180px;
    position: sticky;
    top: calc(var(--header-height) + 2rem);
    align-self: flex-start;
}

.sidebar-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-link {
    font-size: 0.9rem;
    text-decoration: none;
    color: var(--text-muted);
    padding: 0.3rem 0.5rem;
    border-radius: 3px;
    transition: color 0.15s ease, background 0.15s ease;
}

.sidebar-link:hover {
    color: var(--accent);
    opacity: 1;
}

.sidebar-link.active {
    color: var(--accent);
    font-weight: 600;
    background: var(--bg-secondary);
}

.docs-content {
    flex: 1;
    min-width: 0;
}

/* ---- Mobile: stack sidebar above content ---- */
@media (max-width: 640px) {
    .docs-layout {
        flex-direction: column;
    }

    .docs-sidebar {
        position: static;
        width: 100%;
        border-bottom: 1px solid var(--border);
        padding-bottom: 1rem;
        margin-bottom: 1rem;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

/* Expand max-width for docs to accommodate sidebar */
.site-main.docs-wide {
    max-width: calc(var(--max-width) + 220px);
}


/* ==================================================================
   Utility
   ================================================================== */

.empty-state {
    color: var(--text-muted);
    font-style: italic;
    padding: 2rem 0;
}


/* ==================================================================
   Pygments syntax highlighting overrides
   Tokens rendered by Pygments get class names like .k, .s, .c, etc.
   We apply colours that work in both themes via CSS variables.
   ================================================================== */

/* -- Light mode Pygments -- */
[data-theme="light"] pre code .c,
[data-theme="light"] pre code .cm,
[data-theme="light"] pre code .c1,
[data-theme="light"] pre code .cs {
    color: #6a737d;
    font-style: italic;
}

/* Comments */
[data-theme="light"] pre code .k,
[data-theme="light"] pre code .kn,
[data-theme="light"] pre code .kd,

/* ==================================================================
   Back to Top Button
   ================================================================== */

#back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2.5rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    z-index: 90;
}

[data-theme="dark"] #back-to-top {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

#back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#back-to-top:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] #back-to-top:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.8);
}

@media (max-width: 640px) {
    #back-to-top {
        bottom: 1.5rem;
        right: 1.5rem;
    }
}

[data-theme="light"] pre code .kc {
    color: #d73a49;
}

/* Keywords */
[data-theme="light"] pre code .s,
[data-theme="light"] pre code .s1,
[data-theme="light"] pre code .s2,
[data-theme="light"] pre code .sa {
    color: #032f62;
}

/* Strings */
[data-theme="light"] pre code .mi,
[data-theme="light"] pre code .mf {
    color: #005cc5;
}

/* Numbers */
[data-theme="light"] pre code .nb,
[data-theme="light"] pre code .bp {
    color: #005cc5;
}

/* Builtins */
[data-theme="light"] pre code .nf,
[data-theme="light"] pre code .fm {
    color: #6f42c1;
}

/* Functions */
[data-theme="light"] pre code .nn {
    color: #005cc5;
}

/* Module names */
[data-theme="light"] pre code .o,
[data-theme="light"] pre code .ow {
    color: #d73a49;
}

/* Operators */

/* -- Dark mode Pygments -- */
[data-theme="dark"] pre code .c,
[data-theme="dark"] pre code .cm,
[data-theme="dark"] pre code .c1,
[data-theme="dark"] pre code .cs {
    color: #6a737d;
    font-style: italic;
}

[data-theme="dark"] pre code .k,
[data-theme="dark"] pre code .kn,
[data-theme="dark"] pre code .kd,
[data-theme="dark"] pre code .kc {
    color: #ff7b72;
}

[data-theme="dark"] pre code .s,
[data-theme="dark"] pre code .s1,
[data-theme="dark"] pre code .s2,
[data-theme="dark"] pre code .sa {
    color: #a5d6ff;
}

[data-theme="dark"] pre code .mi,
[data-theme="dark"] pre code .mf {
    color: #79c0ff;
}

[data-theme="dark"] pre code .nb,
[data-theme="dark"] pre code .bp {
    color: #79c0ff;
}

[data-theme="dark"] pre code .nf,
[data-theme="dark"] pre code .fm {
    color: #d2a8ff;
}

[data-theme="dark"] pre code .nn {
    color: #79c0ff;
}

[data-theme="dark"] pre code .o,
[data-theme="dark"] pre code .ow {
    color: #ff7b72;
}
/* Static build: filtered-out cards and empty states use the hidden attribute. */
[hidden] {
    display: none !important;
}

/* ---- Mobile fixes (static build) ----
   Keep the header and long code inside a phone-width screen. */
.post-content,
.docs-content {
    min-width: 0;
}

.prose :not(pre) > code {
    overflow-wrap: anywhere;
}

@media (max-width: 900px) {
    .post-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 640px) {
    .site-logo-text {
        display: none;
    }

    .site-nav .nav-home {
        display: none;
    }

    .site-nav {
        gap: 0.85rem;
    }

    .search-bar {
        min-width: 0;
    }

    .search-bar input {
        min-width: 0;
        width: 100%;
    }

    .docs-layout {
        flex-direction: column;
    }
}
