@font-face {
    font-family: "JetBrains Mono";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/jetbrains-mono-400.woff2") format("woff2");
}
@font-face {
    font-family: "JetBrains Mono";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/jetbrains-mono-700.woff2") format("woff2");
}

:root {
    --bg: #ffffff;
    --fg: #1b1f24;
    --muted: #5b6570;
    --accent: #b5179e;
    --accent-2: #3a0ca3;
    --border: #e6e8eb;
    --code-bg: #2b303b;
    --max: 46rem;
    --font: -apple-system, "BlinkMacSystemFont", "Segoe UI", "Roboto", "Helvetica", "Arial", sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", "SF Mono", "Menlo", "Consolas", "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1419;
        --fg: #e6e6e6;
        --border: #232a31;
        --muted: #9aa4af;
        --accent: #ff5fd2;
        --accent-2: #b8a6ff;
    }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; color-scheme: light dark; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font);
    font-size: 1.05rem;
    line-height: 1.7;
}

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 1.2rem; }

.skip-link {
    position: absolute; left: -999px;
}
.skip-link:focus { left: 1rem; top: 1rem; background: var(--accent); color: #fff; padding: .4rem .8rem; border-radius: .4rem; z-index: 10; }

/* Header */
.site-header { border-bottom: 1px solid var(--border); position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); z-index: 5; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: .9rem; padding-bottom: .9rem; }
.brand { font-weight: 700; text-decoration: none; color: var(--fg); letter-spacing: -.01em; }
.brand-mark { color: var(--accent); font-family: var(--mono); }
.site-nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.site-nav a { color: var(--muted); text-decoration: none; font-size: .92rem; }
.site-nav a:hover { color: var(--accent); }

/* Headings & text */
h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -.02em; }
h1 { font-size: 2.1rem; margin: 1.6rem 0 .6rem; }
h2 { font-size: 1.5rem; margin: 2.2rem 0 .6rem; }
h3 { font-size: 1.2rem; margin: 1.8rem 0 .5rem; }
a { color: var(--accent-2); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent); }
p, ul, ol { margin: 0 0 1.1rem; }
hr { border: none; border-top: 1px solid var(--border); margin: 2.5rem 0; }

/* Intro / landing */
.intro { padding: 1.5rem 0 .5rem; }
.intro h1 { margin-top: .5rem; }

/* Post list */
.post-list { padding-bottom: 3rem; }
ol.posts { list-style: none; margin: 0; padding: 0; }
.post-row { padding: 1.1rem 0; border-bottom: 1px solid var(--border); }
.post-row-title { font-size: 1.25rem; font-weight: 650; text-decoration: none; color: var(--fg); }
.post-row-title:hover { color: var(--accent); }
.post-row-meta { color: var(--muted); font-size: .85rem; margin-top: .15rem; display: flex; gap: .8rem; }
.post-row-meta .part { font-family: var(--mono); }
.post-row-desc { color: var(--muted); margin: .35rem 0 0; }

/* Post */
.post { padding: 1rem 0 3rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; color: var(--accent); font-family: var(--mono); margin: 1.4rem 0 .2rem; }
.byline { color: var(--muted); font-size: .9rem; margin-top: .2rem; }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; margin: .6rem 0 0; }
.tags a { font-size: .8rem; color: var(--muted); text-decoration: none; border: 1px solid var(--border); border-radius: 999px; padding: .1rem .6rem; }
.tags a:hover { border-color: var(--accent); color: var(--accent); }
.post-body { margin-top: 1.5rem; }
.post-body img { max-width: 100%; height: auto; border-radius: .5rem; }

/* Code */
pre {
    overflow-x: auto;
    padding: 1rem 1.1rem;
    border-radius: .6rem;
    font-family: var(--mono);
    font-feature-settings: "liga" 1, "calt" 1;
    font-size: .86rem;
    line-height: 1.55;
    border: 1px solid var(--border);
    background: light-dark(#f6f8fa, #161b22);
}
/* Giallo highlighter line layout (Zola 0.22+) */
.giallo-l { display: inline-block; min-height: 1lh; width: 100%; }
.giallo-ln { display: inline-block; user-select: none; margin-right: .4em; padding: .4em; min-width: 3ch; text-align: right; opacity: .8; }
:not(pre) > code {
    font-family: var(--mono);
    font-size: .88em;
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    padding: .1rem .35rem;
    border-radius: .3rem;
}
.source-note { font-size: .8rem; color: var(--muted); margin: -.4rem 0 1.4rem; }
.source-note code { background: none; padding: 0; }

/* Blockquotes / asides */
blockquote { margin: 1.4rem 0; padding: .4rem 0 .4rem 1.1rem; border-left: 3px solid var(--accent); color: var(--muted); font-style: italic; }

/* Diagram */
figure.diagram { margin: 1.8rem 0; text-align: center; }
figure.diagram pre.mermaid { background: transparent; border: none; display: inline-block; text-align: left; min-width: 60%; }
figure.diagram figcaption { color: var(--muted); font-size: .85rem; margin-top: .4rem; }

/* Benchmark table */
figure.bench { margin: 1.8rem 0; overflow-x: auto; }
figure.bench table { border-collapse: collapse; width: 100%; font-size: .9rem; }
figure.bench th, figure.bench td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--border); }
figure.bench thead th { border-bottom: 2px solid var(--border); font-weight: 650; }
figure.bench tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.bench-title { font-weight: 650; margin-bottom: .5rem; }
.bench-meta { color: var(--muted); font-size: .78rem; margin-top: .5rem; }
.bench-meta code { background: none; padding: 0; }

/* Post nav / footer */
.post-footer { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.post-nav { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: .9rem; }
.post-nav .next { margin-left: auto; text-align: right; }
.back { margin-top: 1.2rem; }
.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; padding: 2rem 0; margin-top: 2rem; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent); }

@media (max-width: 640px) {
    body { font-size: 1rem; }
    h1 { font-size: 1.7rem; }
}

/* ============================================================================
   Lively theme + diagram lightbox (layered over the base styles above)
   ============================================================================ */

:root {
    --bg: #fbfaff;
    --surface: #ffffff;
    --border: #ece8f4;
    --accent: #d6248f;     /* magenta */
    --accent-2: #7c3aed;   /* violet  */
    --grad: linear-gradient(120deg, #7c3aed 0%, #d6248f 55%, #ff7a18 100%);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0c0f16;
        --surface: #141a23;
        --border: #242c39;
        --accent: #ff5fd2;
        --accent-2: #b69bff;
        --grad: linear-gradient(120deg, #9d6bff 0%, #ff5fd2 55%, #ff9d4d 100%);
    }
}

/* Soft brand-colored washes instead of a flat white page */
body {
    background:
        radial-gradient(1100px 600px at 100% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%),
        radial-gradient(900px 520px at -10% 2%, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent 60%),
        var(--bg);
    background-attachment: fixed;
}

/* Thin gradient accent bar across the very top */
body::before {
    content: "";
    position: fixed; top: 0; left: 0; right: 0; height: 3px;
    background: var(--grad);
    z-index: 100;
}

.site-header { background: color-mix(in srgb, var(--bg) 80%, transparent); }
.brand-mark { color: var(--accent); font-weight: 800; }

/* Landing hero */
.intro { padding-top: 2.2rem; }
.intro h1 {
    font-size: clamp(2.2rem, 6vw, 3.2rem);
    margin-top: .3rem;
}

/* Post list as cards */
ol.posts { display: grid; gap: .9rem; }
.post-row {
    position: relative;
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    border: 1px solid var(--border);
    border-radius: .85rem;
    padding: 1.1rem 1.2rem 1.15rem;
    overflow: hidden;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.post-row::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: var(--grad); opacity: 0; transition: opacity .15s ease;
}
.post-row:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px color-mix(in srgb, var(--accent-2) 18%, transparent);
    border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}
.post-row:hover::before { opacity: 1; }

/* Post hero accents */
.eyebrow { font-weight: 700; }
.post-header h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); }
.tags a:hover { border-color: transparent; color: #fff; background: var(--grad); }

/* Gradient text only where the browser supports clipping a background to the glyphs,
   so unsupported browsers keep a solid, visible color instead of transparent text. */
@supports ((background-clip: text) or (-webkit-background-clip: text)) {
    .brand-mark, .intro h1, .eyebrow {
        background: var(--grad);
        -webkit-background-clip: text;
        background-clip: text;
        color: transparent;
    }
}

/* Diagrams: presented on a card, click to zoom */
figure.diagram {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: .8rem;
    padding: 1.2rem 1rem .7rem;
    cursor: zoom-in;
    transition: border-color .15s ease, box-shadow .15s ease;
}
figure.diagram:hover {
    border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
    box-shadow: 0 8px 26px color-mix(in srgb, var(--accent-2) 14%, transparent);
}
figure.diagram:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}
figure.diagram::after {
    content: "click to zoom";
    display: block; margin-top: .3rem;
    font-size: .72rem; letter-spacing: .04em; text-transform: uppercase;
    color: var(--muted); opacity: .7;
}

/* Diagram lightbox */
.diagram-modal {
    position: fixed; inset: 0; z-index: 1000; display: none;
    align-items: center; justify-content: center;
    background: rgba(8, 6, 16, .82); backdrop-filter: blur(4px);
}
.diagram-modal.open { display: flex; }
.diagram-stage {
    background: var(--surface);
    border-radius: .9rem; padding: 1.2rem;
    max-width: 96vw; max-height: 90vh; overflow: hidden;
    cursor: grab; touch-action: none;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
}
.diagram-stage.grabbing { cursor: grabbing; }
.diagram-stage svg {
    display: block; width: min(92vw, 1100px); height: auto; max-height: 82vh;
    transform-origin: center center; user-select: none;
}
.diagram-modal-close {
    position: absolute; top: .4rem; right: .9rem;
    font-size: 2.4rem; line-height: 1; color: #fff;
    background: none; border: 0; cursor: pointer; padding: .2rem .6rem;
}
.diagram-modal-close:hover { color: var(--accent); }
.diagram-modal-hint {
    position: absolute; bottom: 1rem; left: 0; right: 0; margin: 0;
    text-align: center; color: rgba(255, 255, 255, .82); font-size: .82rem;
    pointer-events: none;
}
