:root {
    --background: #faf8f4;
    --surface: #ffffff;
    --surface-sunken: #f2efe8;
    --text: #1c1a17;
    --text-muted: #6b665d;
    --border: #e4dfd5;
    --accent: #c2410c;
    --accent-soft: #fdeee4;
    --point: #c9c3b8;
    --point-active: #c2410c;
    --shadow: 0 1px 2px rgba(28, 26, 23, 0.06), 0 8px 24px rgba(28, 26, 23, 0.06);
    --font-sans: 'Inter', system-ui, sans-serif;
    --font-serif: 'Newsreader', Georgia, serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
    --content-width: 68rem;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --background: #151412;
        --surface: #1d1c19;
        --surface-sunken: #23211e;
        --text: #ece8e1;
        --text-muted: #a39d92;
        --border: #34312c;
        --accent: #fb923c;
        --accent-soft: #3a2416;
        --point: #4a4640;
        --point-active: #fb923c;
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --background: #151412;
    --surface: #1d1c19;
    --surface-sunken: #23211e;
    --text: #ece8e1;
    --text-muted: #a39d92;
    --border: #34312c;
    --accent: #fb923c;
    --accent-soft: #3a2416;
    --point: #4a4640;
    --point-active: #fb923c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 4.5rem;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
}

img {
    max-width: 100%;
    display: block;
}

code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--surface-sunken);
    padding: 0.1em 0.35em;
    border-radius: 0.25rem;
}

h1, h2, h3 {
    line-height: 1.2;
    margin: 0;
}

.muted {
    color: var(--text-muted);
}

.eyebrow {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent);
    margin: 0 0 1rem;
}

.tags {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 1rem 0 0;
}

/* ───────── Header ───────── */

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem max(1rem, calc((100vw - var(--content-width)) / 2));
    background: color-mix(in srgb, var(--background) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.site-header__name {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}

.site-header__nav {
    display: flex;
    gap: 1.25rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.site-header__nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    white-space: nowrap;
}

.site-header__nav a:hover {
    color: var(--text);
}

main {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 1rem;
}

/* ───────── Hero ───────── */

.hero {
    padding: 5rem 0 4rem;
}

.hero h1 {
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: clamp(2rem, 5vw, 3.4rem);
    letter-spacing: -0.01em;
    max-width: 22ch;
}

.hero__lede {
    max-width: 42rem;
    font-size: 1.1rem;
    color: var(--text-muted);
    margin: 1.5rem 0 2rem;
}

.hero__links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.hero__facts {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin: 3.5rem 0 0;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.hero__facts dt {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 600;
    line-height: 1;
}

.hero__facts dd {
    margin: 0.4rem 0 0;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.button {
    display: inline-flex;
    align-items: center;
    padding: 0.6rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: 500 0.92rem var(--font-sans);
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s;
}

.button:hover {
    border-color: var(--text-muted);
}

.button--primary {
    background: var(--text);
    border-color: var(--text);
    color: var(--background);
}

.button--primary:hover {
    border-color: var(--text);
    opacity: 0.88;
}

.button--small {
    padding: 0.35rem 0.85rem;
    font-size: 0.82rem;
}

/* ───────── Sections ───────── */

.section {
    padding: 4rem 0;
    border-top: 1px solid var(--border);
}

.section__title {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.section__intro {
    margin: -1rem 0 2rem;
    max-width: 40rem;
}

/* ───────── Experience ───────── */

.job {
    display: grid;
    grid-template-columns: 11rem 1fr;
    gap: 2rem;
    padding: 1.5rem 0;
}

.job + .job {
    border-top: 1px dashed var(--border);
}

.job__meta {
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.job__dates {
    font-family: var(--font-mono);
    color: var(--text);
}

.job h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.job__role {
    display: block;
    font-weight: 400;
    font-size: 1rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.job__context {
    margin: 0.5rem 0 0;
    font-size: 0.92rem;
    color: var(--text-muted);
}

.job ul {
    margin: 1rem 0 0;
    padding-left: 1.1rem;
}

.job li {
    margin-bottom: 0.6rem;
}

.job li::marker {
    color: var(--accent);
}

/* ───────── Featured projects ───────── */

.feature__title {
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: clamp(1.8rem, 4vw, 2.6rem);
}

.feature__lede {
    max-width: 44rem;
    font-size: 1.1rem;
    margin: 1rem 0 2.5rem;
}

.feature__columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    margin: 3rem 0;
}

.feature__columns h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 0.75rem;
}

.feature__columns p {
    margin: 0 0 1.5rem;
}

.steps {
    counter-reset: step;
    list-style: none;
    margin: 0;
    padding: 0;
}

.steps li {
    counter-increment: step;
    position: relative;
    padding-left: 2.4rem;
    margin-bottom: 1rem;
}

.steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0.1rem;
    width: 1.6rem;
    height: 1.6rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font: 600 0.8rem var(--font-mono);
}

.shot {
    margin: 0;
}

.shot img {
    width: 100%;
    border-radius: 0.6rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.shot figcaption {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
}

.shot--crop-top img {
    aspect-ratio: 7 / 5;
    object-fit: cover;
    object-position: top;
}

.shot-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.feature__steps {
    margin: 3rem 0 0;
}

.feature__steps h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 1rem;
}

.steps--two-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 3rem;
}

/* ───────── Cluster explorer ───────── */

.cluster-explorer {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.8rem;
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.cluster-explorer__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.cluster-explorer__header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.cluster-explorer__header p {
    margin: 0.35rem 0 0;
    font-size: 0.9rem;
}

.cluster-explorer__body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 20rem;
    gap: 1.5rem;
    margin-top: 1.25rem;
}

.cluster-explorer__plot {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--surface-sunken);
    border-radius: 0.5rem;
}

.cluster-explorer__plot svg {
    width: 100%;
    height: 100%;
    display: block;
}

.cluster-explorer__plot circle {
    fill: var(--point);
    transition: fill 0.15s, opacity 0.15s;
}

.cluster-explorer__plot circle.is-active {
    fill: var(--point-active);
}

.cluster-explorer__plot.has-selection circle:not(.is-active) {
    opacity: 0.35;
}

.cluster-explorer__plot circle:hover {
    stroke: var(--text);
    stroke-width: 1.5;
}

.cluster-explorer__tooltip {
    position: absolute;
    max-width: 18rem;
    padding: 0.6rem 0.75rem;
    background: var(--text);
    color: var(--background);
    font-size: 0.82rem;
    line-height: 1.45;
    border-radius: 0.4rem;
    pointer-events: none;
    transform: translate(-50%, calc(-100% - 10px));
}

.cluster-explorer__list {
    list-style: none;
    margin: 0;
    padding: 0 0.25rem 0 0;
    max-height: 30rem;
    overflow-y: auto;
    font-size: 0.85rem;
}

.cluster-explorer__list button {
    display: flex;
    gap: 0.6rem;
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 0;
    border-radius: 0.4rem;
    background: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.cluster-explorer__list button:hover {
    background: var(--surface-sunken);
}

.cluster-explorer__list button[aria-pressed="true"] {
    background: var(--accent-soft);
}

.cluster-explorer__count {
    flex: none;
    min-width: 2rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.cluster-explorer__method {
    font-size: 0.8rem;
    margin: 1rem 0 0;
}

/* ───────── Selected projects ───────── */

.project {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: center;
    padding: 2rem 0;
}

.project + .project {
    border-top: 1px dashed var(--border);
}

.project h3 {
    font-family: var(--font-serif);
    font-size: 1.6rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.project__kind {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
    margin-top: 0.4rem;
}

.project__text p {
    margin: 0 0 1rem;
}

.project__links {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
}

.project__media img {
    border-radius: 0.6rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.project__media--tall {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ───────── Cards ───────── */

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
    gap: 1rem;
}

.card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    padding: 1.25rem;
}

.card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.card p {
    margin: 0;
    font-size: 0.9rem;
}

.card .tags {
    margin-top: auto;
    padding-top: 1rem;
}

/* ───────── Skills, about, contact ───────── */

.skills {
    margin: 0;
}

.skills div {
    display: grid;
    grid-template-columns: 11rem 1fr;
    gap: 2rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.skills dt {
    font-weight: 600;
}

.skills dd {
    margin: 0;
    color: var(--text-muted);
}

.about {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
}

.about p {
    margin: 0 0 2rem;
}

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

.plain-list li {
    padding: 0.35rem 0;
}

.contact {
    text-align: center;
    padding: 5rem 0;
}

.contact h2 {
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: clamp(2rem, 5vw, 3rem);
}

.contact h2 {
    margin-bottom: 2rem;
}

.contact p {
    color: var(--text-muted);
    margin: 1rem 0 2rem;
}

.contact .hero__links {
    justify-content: center;
}

.site-footer {
    text-align: center;
    padding: 2rem 1rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* ───────── Narrow screens ───────── */

@media (max-width: 52rem) {
    .hero {
        padding: 3rem 0;
    }

    .hero__facts {
        grid-template-columns: 1fr 1fr;
    }

    .job,
    .skills div {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .feature__columns,
    .steps--two-columns,
    .shot-pair,
    .project,
    .about,
    .cluster-explorer__body {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .cluster-explorer {
        padding: 1rem;
    }

    .cluster-explorer__list {
        max-height: 16rem;
    }

    .site-header__name {
        display: none;
    }
}
