/* ---------- tokens ---------- */
:root {
    color-scheme: light;
    --paper: #efede3;
    --ink: #302f2c;
    --ink-soft: #565449;
    --rule: #cfccbd;

    --font-display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
    --font-sans: "Hanken Grotesk", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

    --r-pane: 0.5rem;
    --shell: 84rem;
    --measure: 40rem;
    --gutter: clamp(1rem, 3vw, 2rem);
    --bar-height: 2.875rem;
}

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

html {
    scroll-behavior: auto;
    scroll-padding-top: calc(var(--bar-height) + 1rem);
}

body {
    background-color: var(--paper);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 1.0625rem;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
}

a:hover {
    color: var(--ink-soft);
}

a:focus-visible,
.btn:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 3px;
}

.mono {
    font-family: var(--font-mono);
    font-size: 0.9em;
}

/* Whole-value buttons inside the profile card (email copies, GitHub opens) */
.field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--ink);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.9em;
    line-height: 1.4;
    text-decoration: none;
    cursor: pointer;
}

.field:hover {
    background-color: var(--ink);
    color: var(--paper);
}

.field__hint {
    font-size: 0.8em;
    opacity: 0.7;
}

.muted {
    color: var(--ink-soft);
}

/* ---------- header ---------- */
.site-header {
    z-index: 100;
    position: sticky;
    top: 0;
    background-color: var(--paper);
    border-bottom: 2px solid var(--ink);
}

.site-header__inner {
    max-width: var(--shell);
    min-height: var(--bar-height);
    justify-content: space-between;
    align-items: center;
    display: flex;
    position: relative;
    padding: 0 var(--gutter);
    gap: 1rem;
    margin: 0 auto;
}

.site-brand {
    min-width: 0;
    color: var(--ink);
    align-items: center;
    display: inline-flex;
    white-space: nowrap;
    gap: 0.5rem;
    text-decoration: none;
}

.site-brand__word {
    font-family: var(--font-display);
    letter-spacing: 0.01em;
    font-size: 1.75rem;
    font-weight: 400;
}

.site-brand:hover .site-brand__word {
    color: var(--ink-soft);
}

.site-brand__mark {
    width: 2rem;
    height: 2rem;
}

.site-nav {
    display: flex;
    gap: 0.75rem;
    font-size: 0.95rem;
}

.site-nav a {
    padding: 0.15rem 0.6rem;
    border: 1px solid transparent;
    border-radius: 4px;
    text-decoration: none;
}

.site-nav a:hover {
    text-decoration: underline;
}

/* Active nav state: border on "Projects" while the projects section is in view */
body {
    timeline-scope: --projects, --project-one;
}

#projects {
    view-timeline: --projects block;
}

@keyframes nav-active {
    from, to { border-color: var(--ink); }
}

.site-nav a[href="#projects"] {
    animation: nav-active 1s linear;
    animation-timeline: --projects;
}

/* Fallback for browsers without scroll-driven animations: highlight after click */
body:has(#projects:target) .site-nav a[href="#projects"] {
    border-color: var(--ink);
}

/* ---------- layout ---------- */
.shell {
    max-width: var(--shell);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

/* ---------- buttons ---------- */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    font: inherit;
    font-size: 0.95rem;
    line-height: 1.3;
    text-decoration: none;
    border: 1px solid var(--ink);
    border-radius: 4px;
    cursor: pointer;
}

.btn--primary {
    background-color: var(--ink);
    color: var(--paper);
}

.btn--primary:hover {
    background-color: var(--ink-soft);
    border-color: var(--ink-soft);
    color: var(--paper);
}

.btn--secondary {
    background-color: transparent;
    color: var(--ink);
}

.btn--secondary:hover {
    background-color: var(--ink);
    color: var(--paper);
}

.btn--small {
    padding: 0.3rem 0.75rem;
    font-size: 0.875rem;
}

/* ---------- hero ---------- */
.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    gap: clamp(2rem, 5vw, 4rem);
    align-items: center;
    padding: clamp(4rem, 12vw, 9rem) 0 clamp(3rem, 8vw, 6rem);
}

.hero__code {
    width: 100%;
    max-width: 30rem;
    justify-self: end;
}

.code {
    padding: 1rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 1.1vw, 0.85rem);
    line-height: 1.75;
    tab-size: 4;
}

.hero__title {
    font-family: var(--font-display);
    font-size: clamp(2.75rem, 7vw, 5rem);
    font-weight: 400;
    line-height: 1.05;
    letter-spacing: -0.01em;
}

.hero__lede {
    max-width: var(--measure);
    margin-top: 1.75rem;
    color: var(--ink-soft);
}

.hero__lede__sub {
    font-weight: 600;
    max-width: var(--measure);
    margin-top: 1.75rem;
    color: var(--ink-soft);
}

.hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

/* ---------- panels (shared) ---------- */
.panel,
.index {
    border: 2px solid var(--ink);
    border-radius: var(--r-pane);
    overflow: hidden;
}

.panel__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--rule);
}

.panel__title {
    font-size: 0.95rem;
    font-weight: 600;
}

.panel__meta {
    font-size: 0.85rem;
    color: var(--ink-soft);
}

.panel__body {
    padding: 1.25rem 1rem;
}

/* ---------- overview: profile + latest post ---------- */
.overview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

.facts__row {
    display: grid;
    grid-template-columns: 7rem 1fr;
    align-items: center;
    gap: 0rem;
    min-height: 2.75rem;
    padding: 0.2rem 0.5rem;
    border-bottom: 1px solid var(--rule);
    font-size: 0.95rem;
}

.facts__row:last-child {
    border-bottom: 0;
}

.facts__row dt {
    color: var(--ink-soft);
}

.post__title {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.3;
}

.post__excerpt {
    max-width: var(--measure);
    margin: 0.75rem 0 1.25rem;
    color: var(--ink-soft);
    font-size: 0.95rem;
}

/* ---------- projects ---------- */
.projects {
    padding-top: clamp(3rem, 8vw, 5rem);
}

.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-bottom: 1.5rem;
}

.section-head__title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 400;
    letter-spacing: -0.005em;
}

.section-head__note {
    font-size: 0.9rem;
    color: var(--ink-soft);
}

.projects__layout {
    display: grid;
    grid-template-columns: 16rem 1fr;
    gap: 1.5rem;
    align-items: start;
}

.index {
    position: sticky;
    top: calc(var(--bar-height) + 1.5rem);
}

.index__list {
    list-style: none;
    display: grid;
    gap: 0.25rem;
    padding: 0.4rem;
}

.index__list a {
    display: block;
    padding: 0.5rem 0.75rem;
    border: 1px solid transparent;
    border-radius: 4px;
    text-decoration: none;
}

.index__list a:hover {
    border-color: var(--ink);
}

/* Active index entry: bordered + tinted while its project card is on screen.
   Repeat these four lines per project (change the id and the timeline name). */
#project-one {
    view-timeline: --project-one block;
}

@keyframes index-active {
    from, to {
        border-color: var(--ink);
        background-color: var(--rule);
    }
}

.index__list a[href="#project-one"] {
    animation: index-active 1s linear;
    animation-timeline: --project-one;
    animation-range: entry 60% exit 40%;
}

/* Fallback for browsers without scroll-driven animations: highlight after click */
body:has(#project-one:target) .index__list a[href="#project-one"] {
    border-color: var(--ink);
    background-color: var(--rule);
}

.index__name {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
}

.index__sub {
    display: block;
    font-size: 0.8rem;
    color: var(--ink-soft);
}

.projects__list {
    display: grid;
    gap: 1.5rem;
}

.project__body {
    display: grid;
    grid-template-columns: minmax(10rem, 18rem) 1fr;
    gap: 1.5rem;
    padding: 1.25rem 1rem;
}

.project__media {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 11rem;
    border: 1px dashed var(--ink-soft);
    border-radius: 4px;
    color: var(--ink-soft);
    font-size: 0.85rem;
}

.project__text {
    max-width: var(--measure);
}

.project__headline {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.6rem;
}

.project__text p {
    color: var(--ink-soft);
    font-size: 0.95rem;
}

.project__stack {
    margin: 1rem 0;
    padding-top: 0.75rem;
    border-top: 1px solid var(--rule);
}

/* ---------- footer / contact ---------- */
.site-footer {
    margin-top: clamp(3rem, 8vw, 5rem);
    border: 2px solid var(--ink);
    border-radius: var(--r-pane);
}

.site-footer__inner {
    padding: 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 2rem;
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

.site-footer__label {
    color: var(--ink-soft);
}

.site-footer__links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.75rem;
}

.copyright {
    max-height: 1rem;
    max-width: 100vw;
    margin-top: 3rem;
    padding: 1rem var(--gutter);
    font-size: 0.8rem;
    color: var(--ink-soft);
    border-top: 1px solid #302f2c;
}

/* ---------- toast (copy confirmation) ---------- */
.toast {
    position: fixed;
    z-index: 200;
    top: calc(var(--bar-height) + 1.75rem);
    right: var(--gutter);
    max-width: calc(100vw - 2 * var(--gutter));
    padding: 0.6rem 1rem;
    background-color: var(--ink);
    color: var(--paper);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.4;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s linear, visibility 0.2s linear;
}

.toast.is-visible {
    opacity: 1;
    visibility: visible;
}

/* ---------- small screens ---------- */
/* Hero code panel needs room, so it goes first (tablets and phones) */
@media (max-width: 64rem) {
    .hero {
        grid-template-columns: 1fr;
    }

    .hero__code {
        display: none;
    }
}

@media (max-width: 52rem) {
    .overview,
    .projects__layout {
        grid-template-columns: 1fr;
    }

    .index {
        display: none;
    }
}

@media (max-width: 42rem) {
    .project__body {
        grid-template-columns: 1fr;
    }

    .facts__row {
        grid-template-columns: 1fr;
        gap: 0.1rem;
    }

    .site-nav {
        gap: 0.25rem;
    }

    .site-nav a {
        padding: 0.15rem 0.4rem;
    }

    .site-footer__inner {
        flex-direction: column;
        align-items: flex-start;
    }
}