/* Jack's TILs — dark dev-notebook theme.
   Geist for display and body, Geist Mono for metadata and code; cool zinc
   ground with a single desaturated amber accent. Every token lives in the
   :root block below; nothing further down hard-codes a colour. */

@font-face {
    font-family: "Geist";
    src: url("/static/fonts/Geist-Variable.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

@font-face {
    font-family: "Geist Mono";
    src: url("/static/fonts/GeistMono-Variable.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

:root {
    color-scheme: dark;

    /* Ground: a cool near-black, never pure #000. */
    --bg: #0f1012;
    --surface: #16181c;
    --surface-border: #26292f;

    --border: #1e2126;
    --border-strong: #2d3138;

    /* Text ramp, brightest to faintest. */
    --text: #f1f3f5;
    --text-body: #d2d6db;
    --text-soft: #b3b8c0;
    --muted: #8a9099;
    --faint: #656b75;

    /* Amber. One accent for the whole site. */
    --accent: #e3a84e;
    --accent-hover: #f0c37c;
    --accent-rule: rgba(227, 168, 78, 0.45);
    --accent-underline: rgba(227, 168, 78, 0.4);
    --accent-tint: rgba(227, 168, 78, 0.14);
    --accent-tint-text: #eed3a6;

    /* Solid button: dark text on the accent fill clears WCAG AA. */
    --accent-contrast: #14100a;

    --font-display: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-body: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo,
        Consolas, "Liberation Mono", monospace;

    /* One radius scale for the page: soft-small everywhere. */
    --radius: 6px;

    /* The measure. The wide margins either side of it are the design. */
    --measure: 680px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15.5px;
    line-height: 1.7;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
}

/* Figures set tabular wherever they stand as data — dates, counts, columns. */
.tnum, time, .count, .created, .entry-meta, .til-meta {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid var(--accent-underline);
    transition: color 0.15s ease, border-color 0.15s ease;
}

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

:focus { outline: none; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

::selection {
    background: var(--accent-tint);
    color: var(--text);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin: 0;
    text-wrap: balance;
}

.skip-link {
    position: absolute;
    left: 16px;
    top: -48px;
    z-index: 10;
    padding: 8px 14px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
}

.skip-link:focus { top: 12px; }

/* ── Navigation ─────────────────────────────────────────────────────────── */

.site-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 28px;
    border-bottom: 1px solid var(--border);
}

.site-nav .brand {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--text);
    border-bottom: 0;
}

.site-nav .brand:hover { color: var(--accent); }

.site-nav .feed {
    display: flex;
    color: var(--muted);
    border-bottom: 0;
}

.site-nav .feed:hover { color: var(--accent); }

/* ── The page column ────────────────────────────────────────────────────── */

section.body {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 72px 20px 88px;
}

/* The home page opens higher up so the feed is visible without scrolling. */
section.body:has(.masthead) { padding-top: 48px; }

/* Small functional labels, mono and quiet. Sentence case, not shouted. */
.kicker,
.label {
    margin: 0 0 14px;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 450;
    letter-spacing: 0.01em;
    color: var(--muted);
}

.kicker-accent { color: var(--accent); }

.hr {
    height: 1px;
    border: 0;
    margin: 0;
    background: var(--border);
}

/* ── Home masthead ──────────────────────────────────────────────────────── */

.masthead { text-align: left; }

.masthead h1 {
    font-size: 40px;
    font-weight: 650;
    letter-spacing: -0.03em;
    line-height: 1.05;
}

.lede {
    margin: 14px 0 0;
    font-size: 15px;
    line-height: 1.7;
    color: var(--muted);
    max-width: 56ch;
    text-wrap: pretty;
}

/* ── Search ─────────────────────────────────────────────────────────────── */

.search {
    display: flex;
    gap: 8px;
    margin: 28px 0 0;
}

.search-box {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 0 12px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    transition: border-color 0.15s ease;
}

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

.search-box svg {
    flex: none;
    color: var(--muted);
}

.search-box input[type=search] {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14.5px;
}

.search-box input[type=search]::placeholder { color: var(--faint); }

.search input[type=submit] {
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 550;
    line-height: 1.2;
    padding: 0 20px;
    color: var(--accent-contrast);
    background: var(--accent);
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

.search input[type=submit]:hover { background: var(--accent-hover); }
.search input[type=submit]:active { transform: translateY(1px); }

/* ── Topic run ──────────────────────────────────────────────────────────── */

.topics {
    margin: 36px 0 0;
    padding-top: 22px;
    border-top: 1px solid var(--border);
}

/* Gap, not whitespace, carries the spacing between topics. */
.topic-run {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 9px 18px;
    font-size: 14px;
}

.topic-run > span {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
}

.topic-run a {
    color: var(--text-body);
    border-bottom: 1px solid var(--border-strong);
}

.topic-run a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent-underline);
}

.topic-run .count {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--faint);
}

.topic-run .more {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: var(--muted);
    border-bottom: 0;
}

.topic-run .more:hover { color: var(--accent); }

/* ── Listing entries (home, topic pages) ────────────────────────────────── */

.entry {
    padding: 28px 0;
    border-bottom: 1px solid var(--border);
}

/* The first entry under a section label sits a little tighter to it. */
.label + .entry { padding-top: 20px; }

.entry-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 8px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted);
}

/* A quiet separator dot between a date and its topic. */
.entry-meta .tick {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--faint);
}

.topic,
.entry-meta a {
    color: var(--accent);
    border-bottom: 0;
}

.topic a { color: inherit; border-bottom: 0; }
.topic:hover,
.entry-meta a:hover { color: var(--accent-hover); }

.entry-title {
    margin: 0 0 9px;
    font-size: 22px;
    line-height: 1.25;
}

.entry-title a {
    color: var(--text);
    border-bottom: 0;
}

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

/* The excerpt comes out of first_paragraph() as its own <p>. */
.entry p {
    margin: 0;
    font-size: 14.5px;
    line-height: 1.7;
    color: var(--text-soft);
}

.entry p code { font-size: 13px; }

.more-link { margin: 36px 0 0; }

.more-link a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 15px;
    font-weight: 500;
    padding-bottom: 2px;
    border-bottom: 1px solid var(--accent-underline);
}

/* ── Topic page ─────────────────────────────────────────────────────────── */

.chapter h1 {
    font-size: 36px;
    font-weight: 650;
    letter-spacing: -0.03em;
    line-height: 1.05;
}

.chapter-meta {
    margin: 14px 0 0;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--muted);
}

.chapter + .hr { margin-top: 30px; }

.entry-compact .entry-title { font-size: 20px; }

/* ── All TILs — the register ────────────────────────────────────────────── */

.register {
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin-top: 44px;
}

.register-group {
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.register-group h2 {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 0 0 12px;
    font-weight: 600;
    font-size: 17px;
    letter-spacing: -0.01em;
}

.register-group h2 .count {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 11px;
    color: var(--faint);
}

.register-group ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.register-group li {
    display: flex;
    align-items: baseline;
    gap: 16px;
}

.register-group time {
    flex: none;
    min-width: 78px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--faint);
}

.register-group a {
    font-size: 14px;
    color: var(--text-body);
    border-bottom: 0;
}

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

/* ── Search results ────────────────────────────────────────────────────── */

.result-count {
    margin: 22px 0 0;
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--muted);
}

.results {
    margin-top: 28px;
    border-top: 1px solid var(--border);
}

.result {
    padding: 24px 0;
    border-bottom: 1px solid var(--border);
}

.result h2 {
    margin: 0 0 9px;
    font-size: 19px;
    line-height: 1.3;
}

.result h2 a { color: var(--text); border-bottom: 0; }
.result h2 a:hover { color: var(--accent-hover); }

.result .entry-meta {
    margin: 10px 0 0;
    font-size: 11.5px;
    color: var(--faint);
}

/* The FTS snippet keeps its whitespace but reads as prose, not a code block. */
.search-snippet {
    margin: 0;
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.65;
    color: var(--text-soft);
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

/* <strong> marks the matched terms. */
.search-snippet strong {
    font-weight: inherit;
    background: var(--accent-tint);
    color: var(--accent-tint-text);
    padding: 0 3px;
    border-radius: 3px;
}

.no-results {
    margin: 40px 0 0;
    font-size: 15px;
    color: var(--muted);
}

/* ── A single TIL ──────────────────────────────────────────────────────── */

.til-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--muted);
}

.til-meta .tick {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--faint);
}

.til-meta a { border-bottom: 0; }

.til h1 {
    font-size: 32px;
    font-weight: 650;
    line-height: 1.15;
    letter-spacing: -0.025em;
}

.til > .hr { margin: 26px 0 30px; }

/* Long-form body copy. */
.til p,
.til li {
    font-size: 15.5px;
    line-height: 1.75;
    color: var(--text-body);
}

.til p { margin: 0 0 20px; }

.til ul, .til ol { margin: 0 0 20px; padding-left: 1.4em; }
.til li { margin-bottom: 6px; }
.til li::marker { color: var(--faint); }

.til h2, .til h3, .til h4 {
    margin: 44px 0 14px;
    font-weight: 600;
    line-height: 1.25;
}

.til h2 {
    font-size: 21px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.til h3 { font-size: 18px; }
.til h4 { font-size: 16px; }

/* The generated # anchor beside each heading. */
.heading-anchor {
    font-size: 0.75em;
    color: var(--faint);
    border-bottom: 0;
}

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

.til blockquote {
    margin: 0 0 24px;
    padding: 2px 0 2px 18px;
    border-left: 2px solid var(--accent-rule);
    color: var(--muted);
    font-size: 15px;
    line-height: 1.7;
}

.til blockquote p {
    margin: 0 0 10px;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
}

.til blockquote p:last-child { margin-bottom: 0; }

/* ── Code ──────────────────────────────────────────────────────────────── */

pre, code, kbd, samp { font-family: var(--font-mono); }

code {
    font-size: 0.86em;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
}

pre {
    margin: 0 0 24px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    padding: 16px 18px;
    font-size: 13px;
    line-height: 1.65;
    color: var(--text-body);
    white-space: pre-wrap;
    overflow: auto;
}

pre code {
    background: none;
    border: 0;
    padding: 0;
    font-size: inherit;
}

pre[lang=wide] { white-space: pre; overflow: auto; }

a, pre, code { overflow-wrap: break-word; }

/* ── Language badge ────────────────────────────────────────────────────────
   A fence that declares a language (```python) comes back from GitHub's
   Markdown renderer wrapped in <div class="highlight highlight-source-python">.
   That wrapper takes the frame and a header strip naming the language; the
   <pre> inside goes borderless. A bare ``` fence has no wrapper and stays a
   plain bordered <pre> with no badge — which is most older TILs. */

.highlight {
    margin: 0 0 24px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.highlight > pre {
    margin: 0;
    border: 0;
    border-radius: 0;
    padding: 14px 18px 16px;
}

.highlight::before {
    content: "code";
    display: block;
    padding: 7px 18px;
    border-bottom: 1px solid var(--surface-border);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
}

/* One rule per language: CSS cannot read a class name, so the label is
   spelled out. Anything not listed falls back to "code" above. */
.highlight-source-python::before { content: "python"; }
.highlight-text-python-console::before { content: "python console"; }
.highlight-source-sql::before { content: "sql"; }
.highlight-source-shell::before { content: "shell"; }
.highlight-text-shell-session::before { content: "console"; }
.highlight-source-js::before { content: "javascript"; }
.highlight-source-ts::before { content: "typescript"; }
.highlight-source-json::before { content: "json"; }
.highlight-source-yaml::before { content: "yaml"; }
.highlight-source-toml::before { content: "toml"; }
.highlight-source-ini::before { content: "ini"; }
.highlight-source-css::before { content: "css"; }
.highlight-text-html-basic::before { content: "html"; }
.highlight-text-xml::before { content: "xml"; }
.highlight-text-xml-svg::before { content: "svg"; }
.highlight-text-md::before { content: "markdown"; }
.highlight-source-diff::before { content: "diff"; }
.highlight-source-dockerfile::before { content: "dockerfile"; }
.highlight-source-rust::before { content: "rust"; }
.highlight-source-go::before { content: "go"; }
.highlight-source-ruby::before { content: "ruby"; }
.highlight-source-java::before { content: "java"; }
.highlight-source-c::before { content: "c"; }
.highlight-source-graphql::before { content: "graphql"; }
.highlight-text-html-django::before { content: "template"; }

/* ── Media, rules and tables inside long-form content ──────────────────── */

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

.til img {
    margin: 0 0 24px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
}

.til hr {
    height: 1px;
    border: 0;
    margin: 40px 0;
    background: var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 24px;
    font-size: 14px;
}

th, td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    word-wrap: anywhere;
}

th {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 12px;
    color: var(--muted);
}

audio { width: 100%; margin: 0 0 24px; }

/* ── Related + colophon footer ─────────────────────────────────────────── */

.til-footer {
    margin: 56px 0 0;
    padding-top: 22px;
    border-top: 1px solid var(--border);
}

/* Both of these sit inside .til, so they have to out-specify .til p. */
.til-footer .label {
    margin: 0 0 16px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--muted);
}

ul.related {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

ul.related li {
    display: flex;
    align-items: baseline;
    gap: 14px;
    font-size: 14px;
}

ul.related time {
    flex: none;
    min-width: 78px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--faint);
}

ul.related .topic { display: none; }

ul.related a {
    color: var(--text-body);
    border-bottom: 0;
}

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

.created,
.til .created {
    margin: 28px 0 0;
    font-family: var(--font-mono);
    font-size: 11.5px;
    line-height: 1.7;
    color: var(--faint);
}

/* ── Reduced motion ────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* ── Narrow screens ───────────────────────────────────────────────────── */

@media (max-width: 640px) {
    body { font-size: 15px; }

    .site-nav { padding: 14px 20px; }

    section.body { padding: 44px 20px 64px; }

    .masthead h1 { font-size: 32px; }
    .chapter h1 { font-size: 30px; }
    .til h1 { font-size: 26px; }
    .entry-title { font-size: 19px; }
    .entry-compact .entry-title { font-size: 18px; }
    .result h2 { font-size: 17px; }

    .til p, .til li { font-size: 15px; }

    .search { flex-wrap: wrap; }
    .search-box { flex-basis: 100%; }
    .search input[type=submit] { min-height: 40px; }

    .register-group li,
    ul.related li { flex-wrap: wrap; gap: 2px 14px; }
}
