/* taken over from github.com/kevquirk/simple.css */

/* from typeset */
.pull-double{margin-left:-.46em}.push-double{margin-right:.46em}.pull-single{margin-left:-.27em}.push-single{margin-right:.27em}.pull-T,.pull-V,.pull-W,.pull-Y{margin-left:-.07em}.push-T,.push-V,.push-W,.push-Y{margin-right:.07em}.pull-C,.pull-O,.pull-c,.pull-o{margin-left:-.04em}.push-C,.push-O,.push-c,.push-o{margin-right:.04em}.pull-A{margin-left:-.03em}.push-A{margin-right:.03em}

/* Global variables. */
:root,
::backdrop {
    /* Set sans-serif & mono fonts */
    --sans-font: IBM Plex Sans, Inter, Roboto, 'Helvetica Neue', 'Arial Nova', 'Nimbus Sans', Arial, sans-serif;
    --serif-font: "Source Serif 4", Georgia, Cambria, "Times New Roman", Times, serif;
    --mono-font: "IBM Plex Mono", Consolas, Menlo, Monaco, "Andale Mono", "Ubuntu Mono",
        monospace;
    --standard-border-radius: 5px;

    /* Default (light) theme */
    --bg: #fff;
    --text: black;
    --text-light: #585858;
    --border: black;
    --accent-bg: #fff4ff;
    --accent: #008632;
    --accent-text: var(--bg);
    --code: #dc3522;
    --preformatted: #444;
    --marked: #ffdd33;
    --disabled: #efefef;
}

/* Dark theme - follows system preference */
@media (prefers-color-scheme: dark) {
    :root,
    ::backdrop {
        color-scheme: dark;
        --bg: #18182b;
        --accent-bg: #0c0c13;
        --text: #dcdcdc;
        --text-light: #ababab;
        --border: #dcdcdc;
        --accent: #f06292;
        --accent-text: var(--bg);
        --code: #afea00;
        --preformatted: #ccc;
        --disabled: #111;
    }

    /* White background for transparent images */
    img {
        background-color: #fff;
    }
}

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

/* Reset default appearance */
input,
progress {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

html {
    /* Set the font globally */
    font-family: var(--sans-font);
    font-size: 14px;
    scroll-behavior: smooth;
    /* Make page slightly taller than viewport to ensure scrollbar is always visible */
    min-height: 101vh;
    /* Prevent horizontal scrolling */
    overflow-x: hidden;
}

/* Make the body a nice central block */
body {
    color: var(--text);
    background-color: var(--bg);
    font-size: 1.15rem;
    line-height: 1.55;
    display: grid;
    grid-template-columns: 1fr min(50rem, 92%) 1fr;
    margin: 0;
    /* Prevent horizontal scrolling */
    overflow-x: hidden;
}

/* Break long words/URLs to prevent horizontal overflow */
a {
    word-break: break-word;
    overflow-wrap: break-word;
}
body > * {
    grid-column: 2;
}

/* Make the header bg full width, but the content inline with body */
body > header {
    background-color: var(--accent-bg);
    border-bottom: 1px solid var(--border);
    text-align: center;
    padding: 0.5rem;
    grid-column: 1 / -1;
}

body > header > *:only-child {
    margin-block-start: 0;
}

body > header h1 {
    margin: 0;
    font-size: 3.2rem;
}

body > header p {
    max-width: 40rem;
    margin: 1rem auto;
}

.footnotes {
    margin-top: 3rem;
    /* Extend lines to match image width: calc(100% + 1rem) */
    width: calc(100% + 1rem);
    margin-left: -0.5rem;
}

/* Format headers */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--serif-font);
    font-style: italic;
    font-weight: 800;
}

h1 {
    font-size: 3rem;
    /* Match image/h2 width on desktop */
    width: calc(100% + 1rem);
    margin-left: -0.5rem;
}

h2 {
    font-size: 2.6rem;
    margin-top: 3rem;
    /* Line-through heading style with small caps */
    display: flex;
    align-items: center;
    gap: 1rem;
    font-variant: small-caps;
    font-style: normal;
    /* Extend lines to match image width: calc(100% + 1rem) */
    width: calc(100% + 1rem);
    margin-left: -0.5rem;
}

h2::before,
h2::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border);
}

h3 {
    font-size: 2rem;
    margin-top: 3rem;
}

h4 {
    font-size: 1.44rem;
}

h5 {
    font-size: 1.15rem;
}

h6 {
    font-size: 0.96rem;
}

p {
    margin: 1.2rem 0;
}

li:not(:last-child) {
    margin-bottom: 0.3rem;
}

/* Prevent long strings from overflowing container */
p,
h1,
h2,
h3,
h4,
h5,
h6 {
    overflow-wrap: break-word;
}

/* Fix line height when title wraps */
h1,
h2,
h3 {
    line-height: 1.1;
}

/* Format links & buttons */
a,
a:visited {
    color: var(--accent);
}

a:hover {
    text-decoration: none;
}

/* Set the cursor to '?' on an abbreviation and style the abbreviation to show that there is more information underneath */
abbr[title] {
    cursor: help;
    text-decoration-line: underline;
    text-decoration-style: dotted;
}

/* Format navigation */
header > nav {
    font-size: 1rem;
    line-height: 2;
    padding: 0.6rem 0 0.75rem;
}

header > nav a,
header > nav a:visited {
    color: var(--text);
    text-decoration: none;
}

header > nav a:hover {
    color: var(--accent);
}


/* Consolidate box styling */
aside,
details,
progress {
    background-color: var(--accent-bg);
    border: 1px solid var(--border);
    border-radius: var(--standard-border-radius);
    margin-bottom: 1rem;
}

aside {
    font-size: 1rem;
    width: 30%;
    padding: 0 15px;
    margin-inline-start: 15px;
    float: right;
}
*[dir="rtl"] aside {
    float: left;
}

article,
fieldset,
dialog {
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: var(--standard-border-radius);
    margin-bottom: 1rem;
}

article h2:first-child,
section h2:first-child,
article h3:first-child,
section h3:first-child {
    margin-top: 1rem;
}

section {
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 2rem 1rem;
    margin: 3rem 0;
}

/* Don't double separators when chaining sections */
section + section,
section:first-child {
    border-top: 0;
    padding-top: 0;
}

section + section {
    margin-top: 0;
}

section:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

details {
    padding: 0.7rem 1rem;
}

summary {
    cursor: pointer;
    font-weight: bold;
    padding: 0.7rem 1rem;
    margin: -0.7rem -1rem;
    word-break: break-all;
}

details[open] > summary + * {
    margin-top: 0;
}

details[open] > summary {
    margin-bottom: 0.5rem;
}

details[open] > :last-child {
    margin-bottom: 0;
}

/* Format tables */
table {
    border-collapse: collapse;
    margin: 1.5rem 0;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
}

figure > table {
    width: max-content;
    margin: 0;
}

td,
th {
    border: 1px solid var(--border);
    text-align: start;
    padding: 0.5rem;
}

th {
    background-color: var(--accent-bg);
    font-weight: bold;
}

tr:nth-child(even) {
    /* Set every other cell slightly darker. Improves readability. */
    background-color: var(--accent-bg);
}

table caption {
    font-weight: bold;
    margin-bottom: 0.5rem;
}

/* Basic input styling */
input {
    font-size: inherit;
    font-family: inherit;
    padding: 0.5rem;
    border-radius: var(--standard-border-radius);
    max-width: 100%;
    color: var(--text);
    background-color: var(--bg);
    border: 1px solid var(--border);
}

.site-footer {
    width: calc(100% + 1rem);
    margin: 3rem 0 0 -0.5rem;
}

body:has(.post-card) .site-footer {
    width: 100%;
    margin-left: 0;
}

body:has(.post-card) .newsletter-form {
    background: var(--bg);
}

.newsletter-form {
    background: var(--accent-bg);
    border: 1px solid var(--border);
    border-radius: 0;
    padding: 1rem;
}

.newsletter-form p {
    margin: 0;
}

.newsletter-kicker {
    color: var(--text);
    font-family: var(--serif-font);
    font-size: 1.6rem;
    font-style: italic;
    font-weight: 800;
    line-height: 1.1;
}

.newsletter-form .newsletter-note {
    color: var(--text);
    margin-top: 0.35rem;
}

.newsletter-field {
    margin-top: 0.6rem;
}

.newsletter-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
}

.newsletter-row input {
    min-width: 0;
    border-radius: 0;
}

.newsletter-row input::placeholder {
    color: var(--text);
    opacity: 1;
}

.newsletter-row input[type="submit"] {
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
}

.newsletter-row input[type="submit"]:hover {
    color: var(--accent);
}

.newsletter-form .site-contact {
    margin: 1.5rem 0 0;
}

/* Misc body elements */
hr {
    border: none;
    height: 1px;
    background: var(--border);
    margin: 0.5rem auto;
}

mark {
    padding: 2px 5px;
    border-radius: var(--standard-border-radius);
    background-color: var(--marked);
    color: black;
}

mark a {
    color: #0d47a1;
}

img,
video {
    max-width: none;
    width: calc(100% + 1rem);
    margin-left: -0.5rem;
    height: auto;
}

figure {
    margin: 0;
    display: block;
    overflow-x: auto;
}

figure > img,
figure > picture > img {
    display: block;
    margin-inline: auto;
}

figcaption {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-light);
    margin-block: 1rem;
}

blockquote {
    margin-inline-start: 0;
    margin-inline-end: 0;
    margin-block: 0;
    padding-block: 0;
    border-inline-start: 0.35rem solid var(--accent);
    color: var(--text);
    font-style: normal;
}

blockquote p {
    padding-left: 2rem;
}
blockquote p:first-child {
    margin-top: 0;
}

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

/* Use mono font for code elements */
code,
pre,
pre span,
kbd,
samp {
    font-family: var(--mono-font);
    font-size: 0.9em;
    color: var(--code);
}

/* Inline code should break to prevent horizontal overflow */
code {
    word-break: break-word;
    overflow-wrap: break-word;
}

kbd {
    color: var(--preformatted);
    border: 1px solid var(--preformatted);
    border-bottom: 3px solid var(--preformatted);
    border-radius: var(--standard-border-radius);
    padding: 0.1rem 0.4rem;
}

pre {
    background-color: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0;
    padding: 1rem 1.4rem;
    max-width: 100%;
    overflow: auto;
    color: var(--preformatted);
    line-height: 1;
    margin-bottom: 1rem;
}

/* Fix embedded code within pre */
pre code {
    color: var(--preformatted);
    line-height: inherit;
    background: none;
    margin: 0;
    padding: 0;
}

/* Superscript & Subscript */
/* Prevent scripts from affecting line-height. */
sup,
sub {
    vertical-align: baseline;
    position: relative;
}

sup {
    top: -0.4em;
}

sub {
    top: 0.3em;
}

/* Article list grid layout (home page) */
.article-link {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: baseline;
    margin-bottom: 0.5rem;
}

.article-link a {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.article-date {
    color: var(--text);
    font-size: 1rem;
    white-space: nowrap;
}


/* Page metadata (all pages) */
.page-meta {
    margin-bottom: 1rem;
    text-align: right;
}

/* Inline emoji: displays image, copies as text (all pages) */
.inline-emoji-image {
    display: inline-block;
    width: 1.3rem;
    height: 1.3rem;
    background-image: url('/img/smile.webp');
    background-size: contain;
    background-repeat: no-repeat;
    color: transparent;
    vertical-align: middle;
    font-size: 1px;
    line-height: 0;
    overflow: hidden;
}

/* Reduce gap between header and content */
main > h1:first-child,
main > .page-meta + h1 {
    margin-top: 0;
}

/* Breathing room at the bottom of every page */
main {
    padding-bottom: 2rem;
}

/* ============================================
   PROTOTYPE: Card-based homepage layout
   Inspired by Applied Divinity Studies / Simon Willison
   ============================================ */

/* Pink background for the whole page on homepage */
body:has(.post-card) {
    background-color: var(--accent-bg);
}

/* Remove header border for seamless transition to pink bg */
body:has(.post-card) > header {
    border-bottom: none;
    background-color: var(--accent-bg);
}

/* Hide the hr separator on homepage */
body:has(.post-card) > hr {
    display: none;
}

/* Post wrapper - positions date outside card */
.post-wrapper {
    position: relative;
    margin-bottom: 2.5rem;
}

/* Date outside card - upper right */
.post-date-outside {
    position: absolute;
    top: -1.5rem;
    right: 0;
    color: var(--text);
    font-size: 1rem;
}

/* Post cards - override global article styles */
.post-card {
    background: var(--bg);
    border: 1px solid var(--border);
    overflow: hidden;
    border-radius: 0;
    padding: 0;
    margin-bottom: 0;
}

/* Article entry - the post content, no horizontal padding for edge-to-edge elements */
.post-card .article-entry {
    padding: 1rem 0;
    overflow-x: hidden;
}

/* Title h1 as link */
.post-card .article-entry > h1:first-child {
    font-size: 2rem;
    margin-top: 0;
    margin-bottom: 1rem;
    width: 100%;
    margin-left: 0;
    padding: 0 1rem;
}

.post-card .article-entry > h1:first-child a {
    color: var(--text);
    text-decoration: none;
}

.post-card .article-entry > h1:first-child a:hover {
    color: var(--accent);
}

/* Article entry container for container queries */
.post-card .article-entry {
    container-type: inline-size;
}

/* Article excerpt - max aspect ratio 3:5 */
.article-excerpt {
    position: relative;
    overflow: hidden;
    max-height: calc(90cqi * 5 / 3);
}

.article-excerpt:not(.full-article) {
    display: flow-root;
    overflow: clip;
}

/* Fade out at the bottom of excerpt */
.article-excerpt::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 8rem;
    background: linear-gradient(transparent 0%, var(--bg) 65%);
    pointer-events: none;
}

/* Full article - no max-height, no gradient */
.article-excerpt.full-article {
    max-height: none;
    overflow: visible;
}

.article-excerpt.full-article::after {
    display: none;
}

.article-excerpt.full-article .post-footer {
    position: static;
    margin-top: 1rem;
    padding: 0 1rem;
}

/* Hide h1 in excerpt (we show our own linked title) */
.article-excerpt > h1:first-child {
    display: none;
}

/* Images in excerpt - edge to edge */
.article-excerpt img {
    width: 100%;
    max-width: none;
    margin: 0;
    height: auto;
    display: block;
}

/* Paragraphs containing only images should have no padding */
.article-excerpt p:has(> img:only-child),
.article-excerpt p:has(> a.image-link:only-child) {
    padding: 0;
    margin: 0;
}

/* Every image is wrapped in a link that opens it in a new tab. Keep the
   wrapper layout-neutral: block so it spans the image's column, line-height 0
   so no descender gap appears under the image, and let the inner <img> keep
   all its own sizing/centering/padding rules. */
a.image-link {
    display: block;
    line-height: 0;
    text-decoration: none;
}

/* Article image utilities. Keep after .article-excerpt img so preview cards don't clobber them. */
img.image-padding-small {
    padding: 0 1rem;
}

img.image-padding-roomy {
    padding: 0 clamp(4rem, 8vw, 6rem);
}

img.image-small-and-centered {
    display: block;
    width: 240px;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}

/* Headings in excerpt - edge to edge */
.article-excerpt h2 {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    gap: 0;
}

.article-excerpt h2::before {
    margin-right: 1rem;
}

.article-excerpt h2::after {
    margin-left: 1rem;
}

.article-excerpt h3 {
    font-size: 1.15rem;
    margin-top: 1rem;
    padding: 0 1rem;
}

/* Paragraphs in excerpt */
.article-excerpt p {
    margin: 0.8rem 0;
    padding: 0 1rem;
}

/* Lists in excerpt */
.article-excerpt ul,
.article-excerpt ol {
    margin: 0.8rem 0;
    padding-left: 2.5rem;
    padding-right: 1rem;
}

/* Blockquotes in excerpt */
.article-excerpt blockquote {
    margin: 0.8rem 0;
    margin-left: 1rem;
    padding-left: 0;
    padding-right: 1rem;
}

/* Blockquote text in excerpt - align with body text */
.article-excerpt blockquote p {
    padding-left: 0.65rem;
}

/* Code blocks in excerpt - edge to edge */
.article-excerpt pre {
    margin: 0.8rem 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
}

/* Post footer - on top of gradient */
.post-footer {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    z-index: 10;
}


.read-more {
    text-decoration: none;
}

.read-more:hover {
    text-decoration: underline;
}

.pagination {
    --pagination-slot-width: calc((var(--pagination-slot-digits, 1) * 1ch) + 1.75rem);
    font-variant-numeric: tabular-nums;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin: 2.5rem 0;
}

.pagination-pages {
    display: grid;
    grid-template-columns: repeat(7, var(--pagination-slot-width));
    gap: 0.35rem;
    justify-content: center;
    list-style: none;
    margin: 0;
    padding: 0;
}

.pagination li {
    margin-bottom: 0;
}

.pagination a,
.pagination a:visited,
.pagination-disabled,
.pagination-ellipsis,
.pagination-spacer {
    display: inline-block;
    padding: 0.25rem 0.55rem;
    color: var(--text);
    text-align: center;
    text-decoration: none;
}

.pagination-pages a,
.pagination-ellipsis,
.pagination-spacer {
    width: var(--pagination-slot-width);
}

.pagination a,
.pagination-disabled {
    border: 1px solid var(--border);
    background: var(--bg);
}

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

.pagination a[aria-current="page"] {
    background: var(--text);
    color: var(--bg);
}

.pagination-disabled {
    border-color: var(--text-light);
    color: var(--text-light);
    cursor: default;
    opacity: 0.6;
}

.pagination-ellipsis {
    color: var(--text-light);
}

.pagination-slot-spacer {
    visibility: hidden;
}

.pagination-step {
    width: var(--pagination-slot-width);
}

/* ============================================
   Mobile styles (max-width: 720px)
   ============================================ */
@media only screen and (max-width: 720px) {
    /* Remove bleed on headings */
    h1 {
        font-size: 2.5rem;
        width: 100%;
        margin-left: 0;
    }

    h2 {
        font-size: 2.1rem;
        width: 96%;
        margin-left: auto;
        margin-right: auto;
    }

    h3 {
        font-size: 1.75rem;
    }

    h4 {
        font-size: 1.25rem;
    }

    /* Aside full-width */
    aside {
        width: 100%;
        float: none;
        margin-inline-start: 0;
    }

    /* Images centered */
    img,
    video {
        width: 96%;
        max-width: 96%;
        margin-left: auto;
        margin-right: auto;
        display: block;
    }

    .pagination {
        --pagination-slot-width: 2rem;
        gap: 0.68rem;
        font-size: 1rem;
    }

    .pagination-pages {
        gap: 0.08rem;
    }

    .pagination a,
    .pagination a:visited,
    .pagination-disabled,
    .pagination-ellipsis,
    .pagination-spacer {
        padding: 0.2rem 0.25rem;
    }

}
