* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #ffffff;
    --text: #111111;
    --text-body: #1a1a1a;
    --text-muted: #555555;
    --text-faint: #999999;
    --link: #111111;
    --link-hover: #000000;
    --nav-muted: #444444;
    --serif: "Source Serif 4", Charter, "Bitstream Charter", "Iowan Old Style", Georgia, "Times New Roman", serif;
    --sans: var(--serif);
    --mono: var(--serif);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111111;
        --text: #f5f5f5;
        --text-body: #e8e8e8;
        --text-muted: #a8a8a8;
        --text-faint: #7d7d7d;
        --link: #f5f5f5;
        --link-hover: #ffffff;
        --nav-muted: #b4b4b4;
    }
}

a {
    color: inherit;
    text-decoration: none;
}

html {
    background-color: var(--bg);
    scroll-behavior: smooth;
}

body {
    font-family: var(--serif);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-body);
    background-color: var(--bg);
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

.container {
    max-width: 42rem;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Top bar — date left, links right */
.nav-header {
    padding: 1.6rem 0 3.6rem;
}

.nav-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem 1.5rem;
}

.nav-date {
    font-family: var(--serif);
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-faint);
    letter-spacing: 0;
}

a.nav-date:hover {
    color: var(--text-muted);
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.005em;
}

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

.nav-links {
    display: flex;
    align-items: baseline;
    gap: 1.35rem;
}

.nav-link {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--nav-muted);
    text-decoration: none;
    transition: color 0.15s ease;
}

.nav-link:hover {
    color: var(--text);
}

.nav-link[aria-current="page"] {
    color: var(--text);
}

/* Index hero */
.index-hero {
    padding-top: 0;
    margin-bottom: 0;
}

.index-name {
    font-size: clamp(1.75rem, 4vw, 2.125rem);
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.015em;
    line-height: 1.15;
    margin-bottom: 0.35rem;
}

.index-role {
    font-family: var(--serif);
    font-size: 0.9375rem;
    color: var(--text-faint);
    margin-bottom: 3rem;
    white-space: nowrap;
}

.index-role a {
    color: var(--text-faint);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    transition: color 0.15s ease;
}

.index-role a:hover {
    color: var(--text-muted);
}

.index-tagline {
    color: var(--text-muted);
    line-height: 1.6;
    max-width: 30em;
}

.index-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    font-family: var(--serif);
    font-size: 0.875rem;
}

.index-links a {
    color: var(--text-faint);
    transition: color 0.15s ease;
}

.index-links a:hover {
    color: var(--text);
}

/* Home index — year | title | meta */
.index-main {
    padding-bottom: 5rem;
}

.index-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.index-list > li {
    margin: 0;
    padding: 0;
}

.index-link {
    display: grid;
    grid-template-columns: 2.8rem minmax(0, 1fr) minmax(4rem, max-content);
    gap: 0 1rem;
    align-items: baseline;
    padding: 0.4rem 0;
    text-decoration: none;
    color: inherit;
}

.index-link:focus-visible {
    outline: 2px solid var(--text-muted);
    outline-offset: 2px;
}

.index-year {
    font-family: var(--serif);
    font-size: 0.875rem;
    color: var(--text-faint);
    font-weight: 400;
    line-height: 1.5;
    font-variant-numeric: lining-nums tabular-nums;
}

.index-year--empty {
    visibility: hidden;
}

.index-title {
    font-family: var(--serif);
    font-size: 0.9375rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text);
    text-decoration: none;
    min-width: 0;
}

.index-link:hover .index-title {
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}

.index-meta {
    font-family: var(--serif);
    font-size: 0.875rem;
    color: var(--text-faint);
    font-weight: 400;
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: lining-nums tabular-nums;
}


/* Post pages */
.post {
    padding-bottom: 5rem;
}

.post-title {
    font-size: clamp(1.375rem, 3vw, 1.625rem);
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.012em;
    line-height: 1.2;
    margin-bottom: 0.4rem;
}

.post-date {
    font-family: var(--serif);
    font-size: 0.875rem;
    color: var(--text-faint);
    margin-bottom: 2rem;
    font-variant-numeric: lining-nums tabular-nums;
}

.post-date a {
    color: var(--text-faint);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    transition: color 0.15s ease;
}

.post-date a:hover {
    color: var(--text-muted);
}

.post-body p {
    margin-bottom: 1.15rem;
    line-height: 1.7;
    color: var(--text-body);
}

.post-body p:last-child {
    margin-bottom: 0;
}

.post-body a {
    color: var(--link);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}

.post-body a:hover {
    color: var(--link-hover);
}

.post-body h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
}

.post-body h2:first-child {
    margin-top: 0;
}

/* About page */
.about-page {
    padding-bottom: 5rem;
}

.about-title {
    font-size: clamp(1.375rem, 3vw, 1.625rem);
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.012em;
    line-height: 1.2;
    margin-bottom: 2rem;
}

.about-intro {
    margin-bottom: 2.75rem;
}

.about-intro-text p {
    margin-bottom: 1.15rem;
    line-height: 1.7;
    color: var(--text-body);
}

.about-intro-text p:last-child {
    margin-bottom: 0;
}

.about-page a {
    color: var(--link);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}

.about-page a:hover {
    color: var(--link-hover);
}

.about-h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
}

.about-h2:first-of-type {
    margin-top: 0;
}

.about-page > p {
    margin-bottom: 1.1rem;
    line-height: 1.7;
    color: var(--text-body);
}

.about-page > p:last-of-type {
    margin-bottom: 0;
}

.dash-list {
    list-style: none;
    padding: 0;
    margin: 0 0 0.5rem;
}

.dash-list li {
    position: relative;
    padding-left: 1.1rem;
    margin-bottom: 0.75rem;
    line-height: 1.7;
    color: var(--text-body);
}

.dash-list li::before {
    content: "-";
    position: absolute;
    left: 0;
    color: var(--text-muted);
}

footer {
    margin-top: auto;
    padding: 3rem 0 1.75rem;
}

footer .container {
    font-family: var(--serif);
    font-size: 0.8125rem;
    color: var(--text-faint);
    font-weight: 400;
}

.footer-inner {
    max-width: none;
    margin: 0;
    padding: 0 2rem;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.footer-copy {
    margin: 0;
}

.footer-papers {
    color: var(--text-faint);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    white-space: nowrap;
    transition: color 0.15s ease;
}

.footer-papers:hover,
.footer-papers[aria-current="page"] {
    color: var(--text);
}

::selection {
    background-color: var(--text-muted);
    color: var(--bg);
}

@media (max-width: 560px) {
    .container {
        padding: 0 1.25rem;
    }

    .footer-inner {
        padding: 0 1.25rem;
    }

    .nav-header {
        padding: 1.25rem 0 2.25rem;
    }

    .index-role {
        margin-bottom: 2rem;
        white-space: normal;
    }

    .index-link {
        grid-template-columns: 2.6rem minmax(0, 1fr);
        grid-template-rows: auto auto;
        column-gap: 0.75rem;
        row-gap: 0.15rem;
        padding: 0.5rem 0;
    }

    .index-year {
        grid-column: 1;
        grid-row: 1;
    }

    .index-meta {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
        text-align: right;
    }

    .index-title {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .index-year--empty {
        display: none;
    }

    .index-link:has(.index-year--empty) .index-title {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    .index-link:has(.index-year--empty) .index-meta {
        grid-row: 2;
        grid-column: 1 / -1;
        justify-self: start;
        text-align: left;
    }
}

/* Passphrase gate — papers.html */
.gate {
    padding-top: 4rem;
    padding-bottom: 6rem;
    max-width: 28rem;
    margin: 0 auto;
}

.gate-title {
    font-size: clamp(1.5rem, 3.5vw, 1.875rem);
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.015em;
    margin-bottom: 0.5rem;
}

.gate-note {
    font-size: 0.9375rem;
    color: var(--text-faint);
    margin-bottom: 2rem;
}

.gate-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.gate-label {
    font-size: 0.8125rem;
    color: var(--text-faint);
    letter-spacing: 0.02em;
}

.gate-input {
    font-family: var(--serif);
    font-size: 1rem;
    color: var(--text);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--text-faint);
    padding: 0.4rem 0;
    transition: border-color 0.15s ease;
}

.gate-input:focus {
    outline: none;
    border-bottom-color: var(--text);
}

.gate-button {
    font-family: var(--serif);
    font-size: 0.9375rem;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--text-faint);
    border-radius: 2px;
    padding: 0.5rem 1rem;
    margin-top: 1.25rem;
    cursor: pointer;
    align-self: flex-start;
    transition: border-color 0.15s ease, opacity 0.15s ease;
}

.gate-button:hover:not(:disabled) {
    border-color: var(--text);
}

.gate-button:disabled {
    opacity: 0.5;
    cursor: default;
}

.gate-status {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 1rem;
    min-height: 1.4em;
}

/* ---------------------------------------------------------------------------
   Intro sequence

   Ten stills — farmland, sail, ice, the first flight, space — with a white
   orbital mark over them, shown on first arrival and on any reload, then
   faded out to reveal the page underneath.

   The frames are stacked in DOM order and each one only ever fades *in*: a
   later frame reaching opacity 1 covers its predecessor, so nothing needs a
   fade-out and the whole run is driven by staggered animation-delay rather
   than per-frame JavaScript.
   --------------------------------------------------------------------------- */

:root {
    --intro-hold: 0.2s;   /* time between frames */
    --intro-fade: 0.09s;  /* crossfade length; 0s gives hard cuts */
    --intro-exit: 0.45s;
}

.intro {
    position: fixed;
    inset: 0;
    z-index: 50;
    background-color: var(--bg);
    overflow: hidden;
    contain: paint;
    will-change: opacity;
    pointer-events: none;
}

.intro[hidden] {
    display: none;
}

.intro-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
}

.intro.is-playing .intro-frame {
    animation: intro-frame-in var(--intro-fade) linear forwards;
}

.intro.is-playing .intro-frame:nth-of-type(1)  { animation-delay: calc(0 * var(--intro-hold)); }
.intro.is-playing .intro-frame:nth-of-type(2)  { animation-delay: calc(1 * var(--intro-hold)); }
.intro.is-playing .intro-frame:nth-of-type(3)  { animation-delay: calc(2 * var(--intro-hold)); }
.intro.is-playing .intro-frame:nth-of-type(4)  { animation-delay: calc(3 * var(--intro-hold)); }
.intro.is-playing .intro-frame:nth-of-type(5)  { animation-delay: calc(4 * var(--intro-hold)); }
.intro.is-playing .intro-frame:nth-of-type(6)  { animation-delay: calc(5 * var(--intro-hold)); }
.intro.is-playing .intro-frame:nth-of-type(7)  { animation-delay: calc(6 * var(--intro-hold)); }
.intro.is-playing .intro-frame:nth-of-type(8)  { animation-delay: calc(7 * var(--intro-hold)); }
.intro.is-playing .intro-frame:nth-of-type(9)  { animation-delay: calc(8 * var(--intro-hold)); }
.intro.is-playing .intro-frame:nth-of-type(10) { animation-delay: calc(9 * var(--intro-hold)); }

.intro.is-complete {
    animation: intro-exit var(--intro-exit) ease-in-out forwards;
}

@keyframes intro-frame-in {
    to { opacity: 1; }
}

@keyframes intro-exit {
    to { opacity: 0; visibility: hidden; }
}

/* The mark: a core with two orbits that draw themselves on, then swell
   gently. It lives inside .intro, so the container's intro-exit fade carries
   it out with the photographs and it needs no exit of its own. */

.intro-mark {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    width: min(22vw, 260px);
    height: auto;
    /* translate and scale are separate properties, so the swell animates
       scale alone without disturbing the centring translate. */
    translate: -50% -50%;
    scale: 0.9;
    fill: none;
    stroke: #ffffff;
    stroke-width: 2;
    /* Halo: white alone sits at ~2.3:1 against the mid-grey frames. */
    filter: drop-shadow(0 0 18px rgba(0, 0, 0, 0.55));
}

.intro-core {
    fill: #ffffff;
    stroke: none;
    opacity: 0;
}

.intro-orbit {
    /* Circumference of an rx 52 / ry 21 ellipse is ~239.8 (Ramanujan). */
    stroke-dasharray: 240;
    stroke-dashoffset: 240;
}

.intro.is-playing .intro-mark {
    animation: intro-mark-swell calc(10 * var(--intro-hold)) ease-out forwards;
}

.intro.is-playing .intro-core {
    animation: intro-core-in 0.3s ease-out 0.1s forwards;
}

.intro.is-playing .intro-orbit {
    animation: intro-orbit-draw 0.7s ease-out forwards;
}

.intro.is-playing .intro-orbit:nth-of-type(1) { animation-delay: 0.15s; }
.intro.is-playing .intro-orbit:nth-of-type(2) { animation-delay: 0.45s; }

@keyframes intro-mark-swell {
    to { scale: 1; }
}

@keyframes intro-core-in {
    to { opacity: 1; }
}

@keyframes intro-orbit-draw {
    to { stroke-dashoffset: 0; }
}

@media (max-width: 560px) {
    .intro-mark {
        width: min(46vw, 200px);
    }
}

/* Hold the page still while the sequence runs. */
html.intro-active,
html.intro-active body {
    overflow: hidden;
}

/* Already seen this session — skip it before anything paints. */
html[data-intro-seen="true"] .intro {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .intro {
        display: none;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
