/* Preview 16 — "Working Paper, Revised Edition".
   Preview-1's editorial DNA carrying the live site's substance: the
   animated yield curve sits in the abstract as "Figure 1". Warm paper by
   default, a matched warm-dark theme on toggle. One new motion moment: the
   heavy section rules draw in left-to-right as each section enters. */

:root {
    /* Light — warm paper (default; <html class="is-light">) */
    --paper: #faf7f2;
    --paper-deep: #f3eee5;
    --ink: #1c1917;
    --ink-soft: #57534e;
    --oxblood: #8c2f1b;
    --hairline: rgba(28, 25, 23, 0.18);
    --frame: rgba(28, 25, 23, 0.55);
    --display: "Fraunces", "Georgia", serif;
    --body: "Atkinson Hyperlegible", "Helvetica Neue", sans-serif;
    --mono: "Space Grotesk", system-ui, sans-serif;
    color-scheme: light;
}

html.is-dark {
    /* Dark — warm near-black, same editorial character */
    --paper: #15130f;
    --paper-deep: #1d1a14;
    --ink: #ece7dd;
    --ink-soft: #a59c90;
    --oxblood: #d77b5e;
    --hairline: rgba(236, 231, 221, 0.16);
    --frame: rgba(236, 231, 221, 0.32);
    color-scheme: dark;
}

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

@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

body {
    background: radial-gradient(120% 60% at 50% 0%, var(--paper-deep) 0%, var(--paper) 55%);
    color: var(--ink);
    font-family: var(--body);
    font-size: 1.0625rem;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    transition: background 0.4s ease, color 0.4s ease;
}

.sheet {
    max-width: 68rem;
    margin: 0 auto;
    padding: 1.5rem clamp(1.25rem, 4vw, 3rem) 4rem;
}

/* ── Entrance: hero settles on load, sections reveal on scroll ──
   Reveals are IntersectionObserver-driven (site-16-reveal.js) and degrade
   to visible-by-default — content is never gated on the animation firing,
   so background tabs / headless renders never ship blank. */
@media (prefers-reduced-motion: no-preference) {
    .hero > * { animation: rise 0.7s cubic-bezier(0.23, 1, 0.32, 1) backwards; }
    .hero__lead { animation-delay: 60ms; }
    .figure { animation-delay: 160ms; }
    @keyframes rise {
        from { opacity: 0; transform: translateY(14px); }
        to   { opacity: 1; transform: none; }
    }
    html.js section.reveal {
        opacity: 0; transform: translateY(16px);
        transition: opacity 0.6s cubic-bezier(0.23, 1, 0.32, 1), transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    }
    html.js section.reveal.is-in { opacity: 1; transform: none; }
}

/* ── Signature motion: section rules draw in ───────────────────── */
.rule--heavy { border-top: 2px solid var(--ink); margin-bottom: 0.85rem; }
@media (prefers-reduced-motion: no-preference) {
    html.js .rule--heavy.reveal {
        transform: scaleX(0);
        transform-origin: left center;
        transition: transform 0.75s cubic-bezier(0.23, 1, 0.32, 1);
    }
    html.js .rule--heavy.reveal.is-in { transform: scaleX(1); }
}

/* ── Utility ───────────────────────────────────────────────────── */
.sr-only {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link {
    position: absolute; left: 1rem; top: -3rem; z-index: 10;
    background: var(--ink); color: var(--paper);
    padding: 0.5rem 1rem; text-decoration: none;
    transition: top 0.15s ease;
}
.skip-link:focus-visible { top: 1rem; }
.gallery-link {
    position: fixed; right: 1rem; bottom: 1rem; z-index: 10;
    font-size: 0.75rem; letter-spacing: 0.06em;
    color: var(--ink-soft); text-decoration: none;
    background: var(--paper); border: 1px solid var(--hairline);
    padding: 0.35rem 0.7rem; border-radius: 2rem;
}
.gallery-link:hover, .gallery-link:focus-visible { color: var(--oxblood); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--oxblood); outline-offset: 3px; }
a, button { touch-action: manipulation; }
h1, h2, h3 { text-wrap: balance; }

/* ── Masthead ──────────────────────────────────────────────────── */
.masthead {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap;
    padding-bottom: 1rem; margin-bottom: clamp(2.5rem, 7vh, 5rem);
    border-bottom: 1px solid var(--hairline);
}
.masthead__mark {
    font-family: var(--display);
    font-weight: 600; font-size: 1.2rem; letter-spacing: 0.04em;
    margin-right: auto;
}
.masthead__mark a { color: inherit; text-decoration: none; }
.masthead nav { display: flex; gap: clamp(0.9rem, 2.5vw, 1.75rem); flex-wrap: wrap; align-items: baseline; }
.masthead nav a {
    color: var(--ink-soft); text-decoration: none;
    font-size: 0.875rem; letter-spacing: 0.04em;
    display: inline-block; padding: 0.55rem 0.25rem;
}
.masthead nav a:hover { color: var(--oxblood); }
.masthead__cv span[aria-hidden] { font-size: 0.85em; }

/* Hamburger — hidden on desktop and whenever JS hasn't revealed it */
.nav-toggle {
    display: none;
    width: 2.4rem; height: 2.1rem; align-self: center;
    background: transparent; border: 1px solid var(--hairline);
    border-radius: 4px; cursor: pointer; padding: 0;
    place-items: center;
    transition: border-color 0.18s ease;
}
.nav-toggle:hover { border-color: var(--oxblood); }
.nav-toggle__bars { display: grid; gap: 4px; width: 1.05rem; }
.nav-toggle__bars span {
    display: block; height: 2px; background: var(--ink-soft); border-radius: 2px;
}
.nav-toggle:hover .nav-toggle__bars span { background: var(--oxblood); }

/* Theme toggle */
.theme-toggle {
    display: inline-grid; place-items: center;
    width: 2.1rem; height: 2.1rem; align-self: center;
    background: transparent; color: var(--ink-soft);
    border: 1px solid var(--hairline); border-radius: 999px;
    cursor: pointer; transition: color 0.18s ease, border-color 0.18s ease;
}
.theme-toggle:hover { color: var(--oxblood); border-color: var(--oxblood); }
.theme-toggle__sun { display: none; }
.theme-toggle__moon { display: block; }
html.is-dark .theme-toggle__sun { display: block; }
html.is-dark .theme-toggle__moon { display: none; }

/* ── Hero: lead column + Figure 1 plate ────────────────────────── */
.hero {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: clamp(2rem, 5vw, 4rem);
    align-items: end;
    margin-bottom: clamp(3.5rem, 9vh, 6.5rem);
}
.eyebrow {
    font-size: 0.8125rem; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--oxblood); margin-bottom: 1.1rem;
}
.hero__lead h1 {
    font-family: var(--display);
    font-weight: 500;
    font-size: clamp(3rem, 7.5vw, 5.6rem);
    line-height: 1.04;
    letter-spacing: -0.02em;
    font-variation-settings: "opsz" 144;
}
.hero__standfirst {
    margin-top: 1.05rem; max-width: 42ch;
    font-size: 1rem; line-height: 1.55; color: var(--ink-soft);
}
.hero__standfirst a {
    color: var(--oxblood); text-decoration: none;
    border-bottom: 1px solid color-mix(in oklab, var(--oxblood) 45%, transparent);
}
.hero__standfirst a:hover { border-bottom-color: var(--oxblood); }
.hero__abstract {
    border-left: 2px solid var(--ink);
    padding-left: clamp(1.1rem, 2.5vw, 1.75rem);
    margin-top: clamp(1.75rem, 4vh, 2.75rem);
}
.abstract-label {
    font-family: var(--display); font-style: italic; font-weight: 500;
    font-size: 1.05rem; margin-bottom: 0.6rem;
}
.hero__abstract > p { font-size: 0.9875rem; color: var(--ink); max-width: 46ch; }
.hero__keywords { margin-top: 0.85rem; font-size: 0.8125rem; color: var(--ink-soft); }
.hero__actions { display: flex; gap: 0.75rem; margin-top: 1.4rem; flex-wrap: wrap; }

.btn {
    font-family: var(--body); font-size: 0.875rem; letter-spacing: 0.03em;
    text-decoration: none; padding: 0.6rem 1.25rem;
    background: var(--oxblood); color: #fff;
    border: 1px solid var(--oxblood); border-radius: 2px;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.btn:hover {
    background: color-mix(in oklab, var(--oxblood) 82%, #000);
    border-color: color-mix(in oklab, var(--oxblood) 82%, #000); color: #fff;
}
.btn--quiet { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn--quiet:hover { background: transparent; color: var(--oxblood); border-color: var(--oxblood); }

/* Figure 1 plate — the canvas reads as a journal exhibit */
.figure { margin: 0; }
.figure__frame {
    position: relative;
    aspect-ratio: 4 / 3;
    border: 1px solid var(--frame);
    background: linear-gradient(180deg, color-mix(in oklab, var(--paper) 82%, var(--ink) 4%), var(--paper));
    padding: 0.75rem 0.85rem 0.4rem;
}
.figure__canvas { display: block; width: 100%; height: 100%; }
.figure__year {
    position: absolute; top: 0.6rem; left: 0.85rem;
    font-family: var(--mono); font-size: 0.95rem; font-weight: 500;
    color: var(--ink-soft); font-variant-numeric: tabular-nums;
    transition: opacity 0.4s ease;
}
.figure__year.is-fading { opacity: 0; }
.figure figcaption {
    margin-top: 0.7rem;
    font-family: var(--mono); font-size: 0.7rem; line-height: 1.4;
    letter-spacing: 0.02em; color: var(--ink-soft);
}
.figure__no { color: var(--ink); font-weight: 500; }

/* ── Section titles ────────────────────────────────────────────── */
.section-title {
    font-family: var(--display); font-weight: 500; font-style: italic;
    font-size: 1.35rem; margin-bottom: 1.75rem;
}
section { margin-bottom: clamp(3.5rem, 8vh, 6rem); }

/* ── Ledger of posts ───────────────────────────────────────────── */
.ledger__list { list-style: none; padding: 0; }
.entry {
    display: grid; grid-template-columns: 3.5rem 1fr;
    gap: 0.5rem; padding: 1.4rem 0;
    border-top: 1px solid var(--hairline);
}
.entry:last-child { border-bottom: 1px solid var(--hairline); }
.entry__no {
    font-family: var(--display); font-size: 1rem; color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
}
.entry__meta { font-size: 0.8125rem; color: var(--ink-soft); margin-bottom: 0.35rem; }
.entry__section { letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; }
.entry__section--research { color: var(--oxblood); }
.entry__section--writing { color: #2f7184; }
html.is-dark .entry__section--writing { color: #6fc6db; }
.entry__body h3 {
    font-family: var(--display); font-weight: 500;
    font-size: clamp(1.3rem, 2.6vw, 1.7rem); line-height: 1.25;
}
.entry__body h3 a, .work__item h3 a {
    color: inherit; text-decoration: none;
    background-image: linear-gradient(var(--oxblood), var(--oxblood));
    background-repeat: no-repeat; background-position: 0 100%;
    background-size: 0% 1px;
    transition: background-size 0.25s ease;
}
.entry__body h3 a:hover, .work__item h3 a:hover { background-size: 100% 1px; color: var(--oxblood); }
.entry__excerpt { margin-top: 0.5rem; max-width: 56ch; color: var(--ink); }
.entry__tags { margin-top: 0.55rem; font-size: 0.8125rem; font-style: italic; color: var(--ink-soft); }

/* Entry with a cover thumbnail — research/writing rows carry a small visual
   on the right so they read differently from the project cards below. */
.entry--media { grid-template-columns: 3.5rem 1fr clamp(110px, 20vw, 180px); }
.entry__thumb { display: block; align-self: start; }
.entry__thumb img {
    width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
    border: 1px solid var(--frame); border-radius: 6px;
    transition: opacity 0.2s ease;
}
.entry__thumb:hover img { opacity: 0.88; }
@media (max-width: 560px) {
    .entry--media { grid-template-columns: 3.5rem 1fr; }
    .entry__thumb { grid-column: 2; margin-top: 0.7rem; max-width: 260px; }
}
.ledger__more { display: flex; gap: 1.75rem; margin-top: 1.5rem; }
.ledger__more a, .about__more { color: var(--oxblood); text-decoration: none; font-size: 0.9rem; }
.ledger__more a:hover, .about__more:hover { text-decoration: underline; }

/* ── Current work ──────────────────────────────────────────────── */
.work__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(1.5rem, 3vw, 2.5rem);
}
.work__item header { margin-bottom: 0.6rem; }
.work__numeral {
    display: block; font-family: var(--display); font-style: italic;
    font-size: 1.1rem; color: var(--oxblood); margin-bottom: 0.4rem;
}
.work__item h3 {
    font-family: var(--display); font-weight: 500;
    font-size: 1.2rem; line-height: 1.3; display: inline;
}
.work__status {
    display: inline-block; margin-left: 0.5rem; vertical-align: middle;
    font-size: 0.6875rem; letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--ink-soft); border: 1px solid var(--hairline);
    padding: 0.1rem 0.45rem; border-radius: 2rem;
}
.work__item > p { font-size: 0.9375rem; color: var(--ink-soft); }
.work__focus { margin-top: 0.6rem; font-style: italic; font-size: 0.8125rem !important; }

/* ── About: drop cap ───────────────────────────────────────────── */
.about__text { max-width: 62ch; margin-bottom: 1rem; }
.about__text::first-letter {
    font-family: var(--display); font-weight: 600;
    font-size: 3.4em; line-height: 0.85;
    float: left; padding: 0.08em 0.12em 0 0;
    color: var(--oxblood);
}

/* ── Contact: footnotes ────────────────────────────────────────── */
.contact__pitch { max-width: 62ch; margin-bottom: 1.5rem; }
.contact__notes { list-style: none; padding: 0; counter-reset: fn; max-width: 30rem; }
.contact__notes li {
    counter-increment: fn;
    border-top: 1px dotted var(--hairline);
    padding: 0.65rem 0;
    display: flex; gap: 0.85rem; align-items: baseline;
}
.contact__notes li::before {
    content: counter(fn);
    font-size: 0.75rem; vertical-align: super;
    color: var(--oxblood); font-weight: 700;
}
.contact__notes a { color: var(--ink); text-decoration: none; display: inline-block; padding: 0.3rem 0.2rem; margin: -0.3rem -0.2rem; }
.contact__notes a:hover { color: var(--oxblood); text-decoration: underline; }

/* ── Colophon ──────────────────────────────────────────────────── */
.colophon {
    border-top: 2px solid var(--ink);
    padding-top: 1rem;
    font-size: 0.8125rem; color: var(--ink-soft);
}
.colophon__legal { margin-top: 0.35rem; }
.colophon__legal a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.colophon__legal a:hover { text-decoration-thickness: 2px; }

/* Privacy-policy data list */
.ds-list { margin: 0.5rem 0 0; padding-left: 1.25rem; }
.ds-list li { margin: 0.5rem 0; }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 860px) {
    .hero { grid-template-columns: 1fr; align-items: start; }
    .figure { display: none; }
    .work__grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    /* Sticky app-style bar: pins to the viewport top, bleeds the paper
       background edge-to-edge over the sheet gutters, and layers above the
       page content + scroll-reveal animations. */
    .masthead {
        row-gap: 0.7rem; align-items: center;
        position: sticky; top: 0; z-index: 50;
        margin-bottom: clamp(1.5rem, 5vh, 3rem);
        margin-inline: calc(-1 * clamp(1.25rem, 4vw, 3rem));
        padding-inline: clamp(1.25rem, 4vw, 3rem);
        padding-top: 1rem; margin-top: -1.5rem;
        background: var(--paper);
        box-shadow: 0 1px 10px rgba(28, 25, 23, 0.07);
    }
    /* Toggle is revealed by JS (it ships `hidden`); no-JS keeps the full nav. */
    .nav-toggle:not([hidden]) { display: inline-grid; order: 1; }
    .theme-toggle { order: 2; }
    /* With JS the nav collapses into a panel under the bar; without JS it
       stays a normal visible row. */
    html.js .masthead__nav {
        order: 3; flex-basis: 100%;
        flex-direction: column; flex-wrap: nowrap; align-items: flex-start; gap: 0;
        overflow: hidden; max-height: 0; opacity: 0; visibility: hidden;
        transition: max-height 0.28s cubic-bezier(0.23, 1, 0.32, 1),
                    opacity 0.2s ease, visibility 0.28s;
    }
    html.js .masthead__nav.is-open { max-height: 24rem; opacity: 1; visibility: visible; }
    html.js .masthead__nav a {
        width: 100%; padding: 0.7rem 0.15rem; font-size: 1rem;
        border-bottom: 1px solid var(--hairline);
    }
    html.js .masthead__nav a:last-child { border-bottom: none; }
}
@media (prefers-reduced-motion: reduce) {
    html.js .masthead__nav { transition: none; }
}
@media (max-width: 480px) {
    .entry { grid-template-columns: 2.25rem 1fr; }
}
