/* ==========================================================================
   One stylesheet for the whole site: the homepage and the /writing/ pages.
   A single column of text, capped at ~68 characters, set in Roboto. No
   framework, no script. The palette follows the essay sites for cbomctl and
   simframe so the three read as one body of work.
   ========================================================================== */

:root {
    color-scheme: light dark;
    --accent: #68c3a3;
    --accent-blue: #52b3d9;
    --ink: #2c3e50;
    --ink-strong: #1f2d3a;
    --ink-muted: #5a6a78;
    --link: #2f7d67;
    --rule: #e4e8ec;
    --bg: #ffffff;
    --code-bg: #f4f6f7;
    --pre-bg: #f7f9fa;
}
@media (prefers-color-scheme: dark) {
    :root {
        --ink: #d5dce3;
        --ink-strong: #eef2f5;
        --ink-muted: #96a2ae;
        --link: #7fd0b3;
        --rule: #2a323b;
        --bg: #14181d;
        --code-bg: #1e252c;
        --pre-bg: #1a2026;
    }
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    font-size: 17px;
    line-height: 1.7;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Cap the measure at ~68 characters. Past roughly 75 the eye loses the
   line it is tracking back to. */
.wrap {
    max-width: 68ch;
    margin: 0 auto;
    padding: 0 24px 96px;
}

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */
.topbar {
    padding: 28px 0 0;
    font-size: 15px;
    color: var(--ink-muted);
}
.topbar a { color: var(--ink-muted); text-decoration: none; }
.topbar a:hover { color: var(--accent); text-decoration: underline; }
.topbar .sep { margin: 0 8px; opacity: 0.5; }

/* --------------------------------------------------------------------------
   Headings
   -------------------------------------------------------------------------- */
.piece-head {
    margin: 56px 0 44px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--rule);
}
.piece-head h1 {
    margin: 0;
    font-size: 34px;
    line-height: 1.22;
    font-weight: 300;
    letter-spacing: -0.01em;
}
.piece-head .meta {
    margin: 14px 0 0;
    font-size: 14px;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

article h2 {
    margin: 52px 0 18px;
    font-size: 25px;
    line-height: 1.3;
    font-weight: 400;
    letter-spacing: -0.005em;
}
article h3 {
    margin: 36px 0 14px;
    font-size: 19px;
    font-weight: 500;
}

/* --------------------------------------------------------------------------
   Body copy
   -------------------------------------------------------------------------- */
p { margin: 0 0 1.15em; }

a {
    color: var(--link);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}
a:hover { color: var(--accent); }

strong { font-weight: 500; color: var(--ink-strong); }

ul, ol { margin: 0 0 1.3em; padding-left: 1.4em; }
li { margin-bottom: 0.5em; }
li > ul, li > ol { margin-top: 0.5em; margin-bottom: 0.6em; }

blockquote {
    margin: 1.6em 0;
    padding: 2px 0 2px 20px;
    border-left: 2px solid var(--accent);
    color: var(--ink-muted);
    font-style: italic;
}
blockquote p:last-child { margin-bottom: 0; }

em { font-style: italic; }

hr {
    margin: 52px 0;
    border: 0;
    border-top: 1px solid var(--rule);
}

/* Trailing note after the final rule. */
article > hr + p em,
article > p > em:only-child { color: var(--ink-muted); }

/* --------------------------------------------------------------------------
   Code
   -------------------------------------------------------------------------- */
code, pre, kbd, samp {
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}
code {
    font-size: 0.88em;
    background: var(--code-bg);
    padding: 0.14em 0.36em;
    border-radius: 3px;
}
pre {
    margin: 1.6em 0;
    padding: 18px 20px;
    background: var(--pre-bg);
    border: 1px solid var(--rule);
    border-radius: 4px;
    overflow-x: auto;
    font-size: 13.5px;
    line-height: 1.55;
}
pre code {
    background: none;
    padding: 0;
    font-size: inherit;
}

/* --------------------------------------------------------------------------
   Writing index
   -------------------------------------------------------------------------- */
.index-head {
    margin: 56px 0 8px;
}
.index-head h1 {
    margin: 0;
    font-size: 34px;
    font-weight: 300;
    letter-spacing: -0.01em;
}
.index-lede {
    margin: 12px 0 48px;
    color: var(--ink-muted);
}

.pieces { list-style: none; margin: 0; padding: 0; }
.pieces li {
    margin: 0;
    padding: 26px 0;
    border-top: 1px solid var(--rule);
}
.pieces li:last-child { border-bottom: 1px solid var(--rule); }
.pieces h2 {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 400;
    line-height: 1.35;
}
.pieces h2 a { color: var(--ink); text-decoration: none; }
.pieces h2 a:hover { color: var(--link); text-decoration: underline; }
.pieces .meta {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.pieces p.dek { margin: 0; color: var(--ink-muted); font-size: 16px; }
.pieces h3 {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 400;
    line-height: 1.35;
}
.pieces h3 a { color: var(--ink); text-decoration: none; }
.pieces h3 a:hover { color: var(--link); text-decoration: underline; }
/* A bare h2 between lists on the writing index. */
.wrap > h2 { font-size: 25px; font-weight: 400; letter-spacing: -0.005em; }
.pieces .elsewhere { font-size: 14px; }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.piece-foot {
    margin-top: 64px;
    padding-top: 24px;
    border-top: 1px solid var(--rule);
    font-size: 15px;
}
.piece-foot a { color: var(--ink-muted); text-decoration: none; }
.piece-foot a:hover { color: var(--accent); text-decoration: underline; }

/* ==========================================================================
   Homepage
   ========================================================================== */

/* Masthead: name, one line of role, the photo, and where to find me. */
.masthead {
    margin: 56px 0 44px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--rule);
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "name photo" "role photo" "links photo";
    column-gap: 28px;
    align-items: start;
}
.masthead h1 {
    grid-area: name;
    margin: 0;
    font-size: 34px;
    line-height: 1.22;
    font-weight: 300;
    letter-spacing: -0.01em;
}
.masthead .role {
    grid-area: role;
    margin: 10px 0 0;
    color: var(--ink-muted);
}
.masthead .links {
    grid-area: links;
    margin: 18px 0 0;
    padding: 0;
    list-style: none;
    font-size: 15px;
}
.masthead .links li { display: inline; margin: 0; }
.masthead .links li + li::before { content: "·"; margin: 0 9px; color: var(--ink-muted); }
.masthead .links a { color: var(--ink-muted); text-decoration: none; }
.masthead .links a:hover { color: var(--link); text-decoration: underline; }
.masthead .photo {
    grid-area: photo;
    width: 104px;
    height: 138px;
    margin: 4px 0 0;
    border-radius: 4px;
    overflow: hidden;
    background: var(--code-bg);
}
.masthead .photo img { display: block; width: 100%; height: 100%; object-fit: cover; }

.lede { font-size: 19px; line-height: 1.6; }

/* Sections */
main h2 {
    margin: 60px 0 20px;
    font-size: 25px;
    line-height: 1.3;
    font-weight: 400;
    letter-spacing: -0.005em;
}
main h3 {
    margin: 34px 0 10px;
    font-size: 19px;
    font-weight: 500;
    line-height: 1.35;
}
main h3 .tag { font-weight: 400; color: var(--ink-muted); }
main h3 a { color: inherit; text-decoration: none; }
main h3 a:hover { color: var(--link); text-decoration: underline; }

/* "Source · Documentation · npm" under a project. */
.where {
    margin: -2px 0 0;
    font-size: 15px;
    color: var(--ink-muted);
}
.where a { text-decoration: none; }
.where a:hover { text-decoration: underline; }
.where .sep { margin: 0 8px; opacity: 0.5; }

/* Dated entries: experience and education. A narrow left column for the
   years, so the eye can run down the dates without reading. */
.dated { list-style: none; margin: 0; padding: 0; }
.dated > li {
    display: grid;
    grid-template-columns: 9.5ch 1fr;
    column-gap: 22px;
    margin: 0;
    padding: 22px 0;
    border-top: 1px solid var(--rule);
}
.dated > li:last-child { border-bottom: 1px solid var(--rule); }
.dated .when {
    font-size: 14px;
    color: var(--ink-muted);
    letter-spacing: 0.02em;
    padding-top: 4px;
    white-space: nowrap;
}
.dated h3 { margin: 0 0 2px; font-size: 18px; }
.dated .org { margin: 0 0 10px; color: var(--ink-muted); }
.dated ul { margin: 0; padding-left: 1.1em; font-size: 16px; }
.dated li li { margin-bottom: 0.35em; }
.dated p { font-size: 16px; }
.dated p:last-child { margin-bottom: 0; }

/* Skills: a short definition list, not an inventory. */
.skills { margin: 0; display: grid; grid-template-columns: 9.5ch 1fr; column-gap: 22px; row-gap: 10px; }
.skills dt { color: var(--ink-muted); font-size: 15px; padding-top: 2px; }
.skills dd { margin: 0; }

/* Contact */
.contact { list-style: none; margin: 0; padding: 0; }
.contact li { margin: 0 0 6px; }
.contact .k { display: inline-block; min-width: 9.5ch; color: var(--ink-muted); font-size: 15px; }

.site-foot {
    margin-top: 72px;
    padding-top: 24px;
    border-top: 1px solid var(--rule);
    font-size: 14px;
    color: var(--ink-muted);
}

/* --------------------------------------------------------------------------
   Focus, motion, small screens, print
   -------------------------------------------------------------------------- */
a:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
    border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    * { animation: none !important; transition: none !important; }
}

@media (max-width: 600px) {
    body { font-size: 16px; }
    .wrap { padding: 0 18px 64px; }
    .piece-head { margin: 36px 0 32px; }
    .piece-head h1, .index-head h1, .masthead h1 { font-size: 27px; }
    article h2, main h2 { font-size: 22px; margin-top: 44px; }
    .lede { font-size: 17px; }
    .masthead {
        margin: 36px 0 32px;
        grid-template-columns: 1fr;
        grid-template-areas: "photo" "name" "role" "links";
    }
    .masthead .photo { width: 84px; height: 112px; margin: 0 0 18px; }
    .dated > li, .skills { grid-template-columns: 1fr; row-gap: 4px; }
    .dated .when { padding-top: 0; }
}

@media print {
    body { font-size: 11pt; color: #000; background: #fff; }
    .wrap { max-width: none; padding: 0; }
    .topbar, .piece-foot, .site-foot, .masthead .photo, .masthead .links { display: none; }
    .masthead { grid-template-columns: 1fr; grid-template-areas: "name" "role"; }
    main h2 { page-break-after: avoid; margin-top: 28pt; }
    .dated > li { page-break-inside: avoid; }
    a { color: #000; text-decoration: none; }
    .where a[href^="http"]::after { content: " " attr(href); font-size: 8.5pt; color: #444; }
    pre { border: 1px solid #999; }
}
