/* Shared foundations */
:root {
    --ink: #1b2431;
    --burgundy: #800000;
    --body-text: #555554;
    --muted-text: #4a5565;
    --link-hover: #ff4e2f;
    --soft-surface: #f5f5f4;
    --hover-surface: #e7e5e4;
    --border: #d1d5dc;
    --action: #0084d1;
    --action-hover: #0069a8;
    --error: #9f0712;
    --radius: 0.5rem;
    --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font: 100%/1.5 system-ui, sans-serif;
    -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: #fafaf9; }
h1, h2, h3, h4, h5, h6, p, pre, figure, blockquote, ul, ol, dl, dd { margin: 0; }
h1, h2, h3, h4, h5 { color: var(--ink); line-height: 1.2; font-weight: 800; }
h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3, h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font: inherit; }
p, li { color: var(--body-text); line-height: 1.75; }
p { margin-bottom: 1rem; }
ul, ol { padding-inline-start: 1.5rem; }
a, .btn-link { color: var(--ink); text-decoration: underline; }
a:hover, .btn-link:hover { color: var(--link-hover); }
hr { margin: 0; border: 0; border-top: 1px solid var(--border); }
table { border-collapse: collapse; }
img, svg, video, iframe { display: block; }
img, video { max-width: 100%; height: auto; }
button, input, select, textarea { margin: 0; font: inherit; color: inherit; }
button { border: 0; padding: 0; background: transparent; cursor: pointer; }
textarea { resize: vertical; }
:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
[hidden] { display: none !important; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    clip-path: inset(50%);
    overflow: hidden;
    white-space: nowrap;
}

pre, code, kbd, samp { font-family: var(--mono); }
pre { overflow-x: auto; }
code { padding: 0.125rem 0.25rem; border-radius: 0.25rem; color: #d63384; font-size: 0.875em; }
pre code { padding: 0; color: inherit; }

/* Page layout */
.container {
    width: 100%;
    max-width: var(--container-width, 100%);
    margin-inline: auto;
    padding: 1rem var(--gutter, 1rem);
}

@media (min-width: 40rem) { :root { --container-width: 40rem; --gutter: 1.5rem; } }
@media (min-width: 48rem) { :root { --container-width: 48rem; } }
@media (min-width: 64rem) { :root { --container-width: 64rem; --gutter: 2rem; } }
@media (min-width: 80rem) { :root { --container-width: 80rem; } }
@media (min-width: 96rem) { :root { --container-width: 96rem; } }

.site-main { padding-bottom: 3rem; }
.page-content > h1:first-child { margin-bottom: 1rem; }
.page-content { display: flow-root; overflow-wrap: break-word; }

/* Navigation and search */
.site-header, .header-menu, .primary-links {
    display: flex;
    align-items: center;
}
.site-header { justify-content: space-between; padding-block: 0.75rem; }
.header-menu { gap: 1.5rem; }
.primary-links { flex-wrap: wrap; gap: 0.25rem; }
.nav-link {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    color: var(--muted-text);
    font-weight: 500;
    text-decoration: none;
}
.nav-link[aria-current] {
    color: var(--ink);
    text-decoration: underline 2px var(--burgundy);
    text-underline-offset: 0.35em;
}
.nav-link:hover { color: var(--link-hover); background: var(--hover-surface); }
.menu-toggle { display: none; padding: 0.625rem; border-radius: var(--radius); }
.menu-toggle:hover { background: var(--hover-surface); }
.nav-search-box { position: relative; width: 10rem; transition: width 200ms ease; }
.nav-search-box:focus-within { width: min(25rem, 37vw); }
.nav-search {
    width: 100%;
    padding: 0.375rem 1rem;
    border: 1px solid #d6d3d1;
    border-radius: var(--radius);
    background: transparent;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.nav-search:focus { border-color: #79716b; }
.search-dropdown {
    position: absolute;
    z-index: 1;
    inset-inline: 0;
    margin-top: 0.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    background: white;
    box-shadow: 0 10px 15px -3px #0001, 0 4px 6px -4px #0002;
}

.search-dropdown ul, .site-footer ul, .blog-sidebar ul, .blog-sidebar ol, .utility-links {
    padding: 0;
    list-style: none;
}

.search-dropdown ul { padding-block: 0.25rem; }
.autocomplete-item { display: block; padding: 0.5rem 1rem; font-size: 0.875rem; text-decoration: none; }
.autocomplete-item:hover, .autocomplete-item:focus-visible { background: var(--hover-surface); }

@media (width < 48rem) {
    .site-header { flex-wrap: wrap; }
    .menu-toggle { display: block; }
    .menu-toggle:not([hidden])[aria-expanded="false"] + .header-menu { display: none; }
    .header-menu { flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 0.5rem; padding-top: 0.75rem; }
    .nav-search-box, .nav-search-box:focus-within { width: 100%; }
}

@media (min-width: 64rem) {
    .nav-search-box { width: 14rem; }
}

/* Footer */
.site-footer { background: var(--soft-surface); color: var(--muted-text); font-size: 0.9375rem; }
.site-links {
    display: grid;
    gap: 1.25rem 2rem;
    padding-block: 1.5rem;
    overflow-wrap: anywhere;
}
.site-links h2 { margin-bottom: 0.375rem; font-size: 1.0625rem; }
.site-links a { text-decoration-color: #b6b1ad; text-underline-offset: 0.18em; }
.tag-links { display: flex; flex-wrap: wrap; column-gap: 0.5rem; }
.footer-tags { margin-top: 0.375rem; }
.footer-tags summary { width: fit-content; cursor: pointer; color: var(--ink); font-weight: 600; }
.footer-tags .tag-links { margin-top: 0.5rem; gap: 0.125rem 0.75rem; }
.footer-bar, .footer-brand, .footer-nav { display: flex; align-items: center; }
.footer-bar {
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
    padding-block: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.875rem;
}
.footer-brand { gap: 0.625rem; }
.footer-brand p { margin: 0; }
.footer-nav { gap: 1rem; }
.footer-nav a { padding-block: 0.25rem; }
@media (width < 40rem) {
    .footer-bar { flex-direction: column; align-items: flex-start; }
}
@media (min-width: 48rem) {
    .site-links { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Blog sidebar */
.blog-sidebar h4 { font-style: italic; }
.blog-sidebar { position: sticky; top: 2rem; }
.blog-sidebar > div { padding: 0.75rem 1rem; }

/* Home */
.home-features {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 1.5rem 2rem;
    max-width: 48rem;
    margin-inline: auto;
}

.featured-photo { width: fit-content; max-width: 100%; justify-self: center; }
.featured-photo > a { display: block; }
.featured-photo img { width: auto; max-height: 72svh; border-radius: var(--radius); }
.featured-photo figcaption {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    text-underline-offset: 0.15em;
}

.featured-photo figcaption a:first-child { font-weight: 650; }
.home-posts > .post-snippet:first-child { padding-top: 0; }

@media (min-width: 72rem) {
    .home-features { max-width: none; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
    .home-features > :only-child { grid-column: 1 / -1; }
}

/* Posts and photos */
.post-snippet {
    max-width: 48rem;
    padding-block: 1.125rem;
}

.post-snippet + .post-snippet { border-top: 1px solid #d8d5d1; }
.post-meta, .post-tag-links { font-size: 0.8125rem; }
.post-meta {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    color: var(--muted-text);
}

.post-meta a { color: var(--burgundy); font-weight: 700; text-decoration: none; }
.post-meta a:is(:hover, :focus-visible) { color: var(--link-hover); text-decoration: underline; }
.snippet-title {
    margin-top: 0.25rem;
    font-size: clamp(1.3125rem, 3.2vw, 1.6875rem);
    font-weight: 750;
    line-height: 1.14;
    letter-spacing: -0.025em;
    text-wrap: balance;
}

.snippet-title a { text-decoration: none; }
.post-snippet a:hover, .post-snippet a:focus-visible { color: var(--link-hover); text-decoration: underline; }
.snippet-excerpt {
    max-width: 68ch;
    margin-top: 0.375rem;
    color: var(--body-text);
    font-size: 0.9375rem;
}

.snippet-excerpt :is(p, li) { line-height: 1.5; }
.snippet-excerpt > :last-child { margin-bottom: 0; }
/* Archive teasers can include inline formatting. Keep links and media fully visible. */
.snippet-excerpt > p:only-child:not(:has(*)),
.topic-archive .snippet-excerpt:not(:has(:not(p, br, code, em, strong, i, b))),
.search-hit .snippet-excerpt {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: var(--excerpt-lines, 3);
    overflow: hidden;
}

.post-tag-links { margin-top: 0.5rem; gap: 0.125rem 0.75rem; }
.post-tag-links a { color: var(--muted-text); text-decoration-color: #b6b1ad; text-underline-offset: 0.2em; }
.post-tag-links a:is(:hover, :focus-visible) { color: var(--link-hover); }

/* The reading column opens up for screenshots, figures and code samples. */
.reading-page {
    --reading-width: 43rem;
    max-width: 56rem;
    margin-inline: auto;
    padding-top: clamp(0.5rem, 2vw, 1.75rem);
}

.reading-column, .post-heading, .post-prose > *, .post-endnotes {
    max-width: var(--reading-width);
    margin-inline: auto;
}

.post-heading { margin-bottom: clamp(1.25rem, 3vw, 2rem); }
.page-title {
    margin-top: 0.5rem;
    font-size: clamp(2rem, 4.2vw, 3rem);
    line-height: 1.08;
    letter-spacing: -0.035em;
    text-wrap: balance;
}

.prose, .about-intro { color: var(--body-text); font-size: 1.0625rem; }
.prose > * { margin-block: 0; }
.prose > * + * { margin-top: 1.125rem; }
.prose > :is(h2, h3, h4):not(:first-child) { margin-top: 2rem; }
.prose > :is(h2, h3, h4) + * { margin-top: 0.5rem; }
.prose a { text-underline-offset: 0.15em; }
.post-prose blockquote { border-inline-start: 3px solid var(--border); padding-inline-start: 1rem; }
.post-prose > :is(pre, code, figure, img, video, .text-center),
.post-prose > p:has(> img:only-child) { max-width: 100%; }
.post-prose img { margin-inline: auto; }
.post-prose iframe { max-width: 100%; }
.post-prose > table { display: block; overflow-x: auto; }
.post-prose :is(pre, code) { font-family: var(--mono); }
.post-prose pre, .post-prose > code {
    display: block;
    padding: 1rem;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--soft-surface);
    color: var(--ink);
    font-size: 0.875rem;
    line-height: 1.6;
}

.post-prose pre code { font-size: inherit; }
.post-prose > code { white-space: pre-wrap; overflow-wrap: anywhere; }
.post-prose > code:has(br) { white-space: normal; }
.post-endnotes { margin-top: 2rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }

/* Photo posts keep the whole photograph in view and link to its original size. */
.photo-detail { max-width: 70rem; }
.photo-detail .post-heading { text-align: center; }
.photo-detail :is(.post-meta, .post-endnotes) { justify-content: center; }
.post-figure { text-align: center; }
.post-figure a { display: block; width: fit-content; max-width: 100%; margin-inline: auto; cursor: zoom-in; }
.post-figure img {
    width: auto;
    height: auto;
    max-height: clamp(50svh, 100svh - 18rem, 75svh);
    border-radius: var(--radius);
}
.post-figure figcaption, .photo-note { margin: 0.625rem auto 0; max-width: var(--reading-width); color: var(--muted-text); font-size: 0.875rem; text-align: center; }
.post-figure + .post-prose > :first-child { margin-top: 1.5rem; }

.photo-gallery {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2rem 1.5rem;
    align-items: start;
}

@media (min-width: 40rem) {
    .photo-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 64rem) {
    .photo-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.photo-gallery a { display: block; text-decoration: none; }
.photo-gallery img { width: 100%; height: auto; border-radius: var(--radius); }
.gallery-unavailable {
    display: grid;
    place-items: center;
    aspect-ratio: 4 / 3;
    border-radius: var(--radius);
    background: var(--soft-surface);
    color: var(--muted-text);
    font-size: 0.875rem;
}
.photo-gallery img:not([hidden]) + .gallery-unavailable { display: none; }
.photo-gallery h2 { margin-top: 0.625rem; color: inherit; font-size: 1.25rem; line-height: 1.2; letter-spacing: -0.02em; }
.photo-gallery a:is(:hover, :focus-visible) h2 { text-decoration: underline; text-underline-offset: 0.15em; }
.photo-gallery time { margin-top: 0.25rem; }
.gallery-pagination, .archive-pagination { padding-top: 1rem; border-top: 1px solid var(--border); }
.gallery-pagination { margin-top: 2rem; }
.topic-archive > header { margin-bottom: 0.5rem; }
.archive-pagination { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem; }
.archive-pagination .page-number { margin: 0; color: var(--muted-text); font-size: 0.875rem; }

/* About */
.about-intro {
    display: grid;
    align-items: start;
    gap: 1rem 2rem;
    margin-block: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}
.about-intro > p { margin: 0; }
.author-photo { width: 15rem; border-radius: var(--radius); }

@media (min-width: 40rem) {
    .about-intro { grid-template-columns: min(34%, 15rem) minmax(0, 1fr); grid-template-rows: auto 1fr; }
    .author-photo { grid-column: 1; grid-row: 1 / 3; }
}
.pill {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 1rem;
    border-radius: 999px;
    background: var(--soft-surface);
    color: #292524;
    font-size: 0.875rem;
    line-height: 1.25rem;
    font-weight: 500;
    text-decoration: none;
}

.pill:hover { color: #292524; background: var(--hover-surface); }
.page-number { margin-inline: 0.5rem; vertical-align: middle; }

/* Map callouts created by site.js */
.callout { padding: 0.75rem; border-radius: 0.25rem; box-shadow: 0 1px 3px #0002; }
.callout .btn-close { float: inline-end; }
.callout .btn-close::before { content: "×"; }
.callout-content { margin-top: 0.25rem; }
.callout .btn-primary { margin-top: 0.5rem; }

/* Forms */
.form-stack {
    display: grid;
    gap: 1rem;
    max-width: 42rem;
}

.form-stack > :is(button, input[type=submit]) { justify-self: start; }
.form-stack > p { margin-bottom: 0; }
.reading-column > .form-stack { max-width: none; margin-top: 1.5rem; }
.form-row { display: grid; gap: inherit; }
#contact-captcha { overflow-x: auto; }

@media (min-width: 40rem) {
    .form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.form-label { display: block; margin-bottom: 0.25rem; color: #364153; font-size: 0.875rem; font-weight: 500; }
.form-input {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: #101828;
}

.form-input::placeholder { color: #99a1af; }
.form-input:focus { border-color: var(--action); outline: 2px solid #b8e6fe; outline-offset: 0; }
.btn-primary {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    border: 0;
    border-radius: var(--radius);
    background: var(--action);
    color: white;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn-primary:hover { background: var(--action-hover); color: white; }
.validation-message, .form-alert { color: var(--error); }
.form-input:is(.is-invalid, .input-validation-error) { border-color: var(--error); }
.validation-summary-valid, .field-validation-valid, .validation-message:empty { display: none; }
.status-message { color: #166534; }
.form-alert {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid #ff6467;
    border-radius: var(--radius);
    background: #fef2f2;
}

.form-alert li, .validation-message li { color: inherit; }
.dismiss-alert { color: var(--error); }
.utility-tool { max-width: none; }

/* Search results */
.search-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
    margin-top: 1.5rem;
}
.search-summary { margin: 0.75rem 0 0; color: var(--muted-text); font-size: 0.875rem; }
.search-hit .snippet-excerpt { --excerpt-lines: 2; margin-bottom: 0; line-height: 1.5; }
.search-hit mark { background: #f6e6c9; color: inherit; }
