/* Portfolio additions to Tufte CSS. Keep the upstream reading scale and colors. */
@font-face {
    font-family: "Libre Franklin";
    src: url("fonts/LibreFranklin-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Geist Mono";
    src: url("fonts/GeistMono-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    color-scheme: light dark;
    --quiet: #595950;
    --ink: #111;
    --paper: #fffff8;
    --nav-rule: rgba(89, 89, 80, .18);
    --nav-paper: #f0efe5;
    --nav-hover: rgba(17, 17, 17, .06);
    --image-border: #c9c9bd;
    --viewer-backdrop: rgba(255, 255, 248, .88);
    --contact-wash: rgba(234, 192, 63, .16);
}

html { scroll-padding-top: 8rem; }
body { margin-top: 0; margin-bottom: 0; background-color: var(--paper); color: var(--ink); }
a { overflow-wrap: anywhere; }
a:focus-visible { outline: 2px solid currentColor; outline-offset: 5px; }
.skip-link { position: absolute; left: 1rem; top: -5rem; z-index: 20; background: var(--paper); }
.skip-link:focus { top: 1rem; }

.site-nav {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: .45rem 0;
    background: var(--nav-paper);
}
/* Extend the band into Tufte’s outer margins without widening the layout. */
.site-nav::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--nav-paper);
    box-shadow: 0 0 0 100vmax var(--nav-paper);
    clip-path: inset(0 -100vmax);
}
.nav-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 85%;
    max-width: 1000px;
}
.nav-links {
    font-family: "Libre Franklin", "Franklin Gothic Book", "Franklin Gothic", Arial, sans-serif;
    display: flex;
    flex-wrap: wrap;
    gap: 0 .35rem;
    flex: 1;
    min-width: 0;
    margin-left: -.7rem;
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--ink);
}
.nav-links a {
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
    min-height: 44px;
    padding: 0 .7rem;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    text-decoration: none;
}
.nav-links a:hover { background: var(--nav-hover); }
.nav-links a:focus-visible { outline-offset: 2px; }
.nav-links a[aria-current="page"] { border-bottom-color: currentColor; }
.theme-toggle {
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--quiet);
    cursor: pointer;
}
.theme-toggle[hidden] { display: none; }
.theme-track {
    position: relative;
    display: block;
    box-sizing: border-box;
    width: 36px;
    height: 20px;
    border: 1px solid var(--image-border);
    border-radius: 20px;
}
.theme-thumb { position: absolute; top: 0; left: 0; width: 18px; height: 18px; }
.theme-toggle svg { display: block; width: 18px; height: 18px; }
.theme-toggle .theme-moon { display: none; }
.theme-toggle[aria-checked="true"] .theme-thumb { left: 16px; }
.theme-toggle[aria-checked="true"] .theme-sun { display: none; }
.theme-toggle[aria-checked="true"] .theme-moon { display: block; }
.theme-toggle:hover { color: var(--ink); }
.theme-toggle:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; border-radius: 3px; }
.portfolio { padding: 2.5rem 0 3rem; }
.page-header h1 { margin-top: 1rem; }
.page-header { margin-bottom: 2rem; }
.site-name { margin: 0 0 1.1rem; font-size: 1.4rem; }
.work-header { margin-bottom: .5rem; }
.work-header h1 { margin-bottom: 1rem; }
section { scroll-margin-top: .5rem; }
.bio-layout {
    display: grid;
    grid-template-columns: minmax(0, 55%) minmax(0, 18%);
    column-gap: 4%;
    align-items: start;
}
.bio-copy { grid-column: 1; grid-row: 1; min-width: 0; }
.bio-copy > p:first-child { margin-top: 0; }
.bio-copy > p:last-child { margin-bottom: 0; }
.portrait {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    max-width: 190px;
    margin: .35rem 0 0;
}
.portrait img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 5;
    object-fit: cover;
    object-position: 50% 35%;
}

.description {
    font-family: "Gill Sans", "Gill Sans MT", Calibri, sans-serif;
    font-size: 1.2rem;
    line-height: 1.55;
    letter-spacing: .005em;
}
.publication {
    font-family: "Geist Mono", Menlo, monospace;
    font-size: .8rem;
    line-height: 1.6;
    color: var(--quiet);
    margin: 0 0 .45rem;
}
section > .writing-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2.5rem;
    width: 85%;
    max-width: 1000px;
    padding: 0;
    margin: 2rem 0 3rem;
    list-style: none;
}
.writing-list > li {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    min-width: 0;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--nav-rule);
    scroll-margin-top: .5rem;
}
.story-copy { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.story-thumbnail { display: block; }
.story-thumbnail img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.writing-list .story-actions { margin-top: auto; padding-top: .65rem; }
.writing-list .publication, .media-copy .publication { margin: .5rem 0 .55rem; }
.writing-list h2, .media-copy h2 {
    font-style: normal;
    font-size: 1.7rem;
    line-height: 1.2;
    margin: 0 0 .6rem;
}
.writing-list .description, .media-copy .description { margin: .6rem 0; }
.story-actions { font-size: 1.2rem; line-height: 1.6; margin: .65rem 0 0; }
.story-actions span { margin: 0 .35rem; }
.more-work { font-size: 1.2rem; }

/* CSS columns keep differently proportioned charts compact without a library. */
.chart-gallery {
    width: 85%;
    max-width: 1000px;
    columns: 2;
    column-gap: 2rem;
    margin: 2rem 0 .5rem;
}
.chart-figure {
    display: inline-block;
    vertical-align: top;
    width: 100%;
    max-width: none;
    margin: 0 0 2rem;
    break-inside: avoid;
}
.chart-figure > a { display: block; cursor: zoom-in; }
.chart-figure img { display: block; width: 100%; border: 1px solid var(--image-border); box-sizing: border-box; }
.chart-figure figcaption {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .25rem .6rem;
    float: none;
    clear: none;
    width: 100%;
    max-width: none;
    margin: .65rem 0 0;
    font-size: 1.15rem;
    line-height: 1.5;
}
.chart-viewer-open { overflow: hidden; }
.chart-dialog {
    width: calc(100% - 2rem);
    max-width: 1200px;
    max-height: calc(100dvh - 2rem);
    box-sizing: border-box;
    padding: 3.5rem 0 0;
    border: 0;
    background: transparent;
    color: inherit;
}
.chart-dialog::backdrop {
    background: var(--viewer-backdrop);
    backdrop-filter: blur(3px);
}
.chart-dialog img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(100dvh - 6rem);
    margin: 0 auto;
    border: 1px solid var(--image-border);
    box-sizing: border-box;
    object-fit: contain;
}
.dialog-close {
    position: absolute;
    top: 0;
    right: 0;
    width: 2.8rem;
    height: 2.8rem;
    padding: 0;
    border: 1px solid var(--image-border);
    background: var(--paper);
    color: inherit;
    font: 2rem/1 Arial, sans-serif;
    cursor: pointer;
}
.dialog-close:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

.media-piece {
    width: 80%;
    max-width: 850px;
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
    margin: 2.5rem 0 3.5rem;
}
.media-preview { display: block; }
.media-preview img { display: block; width: 100%; height: auto; }
.video-preview .media-preview { width: 180px; aspect-ratio: 9 / 16; }
.video-preview .media-preview img { width: 100%; height: 100%; object-fit: contain; }
.media-meta { font-size: 1.1rem; line-height: 1.5; color: var(--quiet); margin: .7rem 0 0; }

#contact {
    scroll-margin-block: 4rem;
    border-radius: .15rem;
    outline: none;
}
#contact.contact-glow { animation: contact-glow 1.8s ease-out; }
@keyframes contact-glow {
    0%, 25% { background-color: var(--contact-wash); box-shadow: 0 0 8px 3px var(--contact-wash); }
    100% { background-color: transparent; box-shadow: 0 0 8px 3px transparent; }
}

.back-link { font-size: 1.2rem; margin-top: 2rem; }
.thesis-header { width: 65%; }
.thesis-header h1 { line-height: 1.1; }
.thesis-header .publication { margin: 1.5rem 0; }
.thesis-image { margin: 2rem 0; }
.thesis-image img { display: block; }

/* Full-text stories retain Tufte’s main column and publication margin note. */
.reading-header { width: 70%; max-width: 850px; margin-bottom: 1.2rem; }
.reading-header h1 { line-height: 1.1; }
.reading-header .reading-dek { font-size: 1.55rem; line-height: 1.4; }
.reading-byline { font-size: 1.2rem; margin: 1.25rem 0 0; }
.reading-credit { font-size: 1.05rem; line-height: 1.5; color: var(--quiet); margin: 1rem 0 0; }
.reading-content > .reading-section:first-child { padding-top: 0; }
.reading-content > .reading-section:first-child > p:first-child { margin-top: 1rem; }
.reading-section h2 { width: 55%; line-height: 1.15; }
.reading-section h3 { width: 55%; font-size: 1.7rem; line-height: 1.25; }
.reading-section > ul, .reading-section > ol { box-sizing: border-box; width: 55%; padding-left: 1.4rem; }
.reading-section li { margin: .65rem 0; }
.reading-section .marginnote {
    float: right;
    clear: right;
    margin-right: -60%;
    width: 50%;
    margin-top: .3rem;
    margin-bottom: 0;
    font-size: 1.1rem;
    line-height: 1.3;
    vertical-align: baseline;
    position: relative;
    color: var(--quiet);
}
.reading-section > .reading-figure {
    display: block;
    clear: both;
    width: 65%;
    max-width: 740px;
    margin: 2rem 0;
}
.reading-figure img { display: block; width: 100%; }
.reading-figure figcaption { font-size: 1.05rem; line-height: 1.5; color: var(--quiet); margin-top: .65rem; }
.reading-resources > p, .reading-audio { width: 55%; font-size: 1.1rem; line-height: 1.5; color: var(--quiet); }
.reading-correction { font-size: 1.2rem; line-height: 1.6; }
.reading-sidebar {
    float: right;
    clear: right;
    box-sizing: border-box;
    width: 27.5%;
    margin: .3rem 12% 1.5rem 0;
    position: relative;
    color: var(--quiet);
}
.reading-sidebar h3 { width: 100%; font-size: 1.2rem; font-weight: 700; font-style: normal; line-height: 1.35; margin: 0 0 .7rem; }
.reading-sidebar p, .reading-sidebar ul { width: 100%; font-size: 1.1rem; line-height: 1.45; margin: .7rem 0; }
.reading-sidebar ul { box-sizing: border-box; padding-left: 1.2rem; }
.reading-sidebar li { margin: .65rem 0; }
.reading-sidebar > :first-child { margin-top: 0; }
.reading-sidebar > :last-child { margin-bottom: 0; }
/* Tufte-style quotations belong to the reading column, apart from margin notes. */
.reading-section > .reading-pullquote {
    box-sizing: border-box;
    width: 55%;
    margin: 2.5rem 0;
    padding: 0 1.5rem;
    font-style: italic;
    color: var(--ink);
}
.reading-pullquote p { width: 100%; font-size: 1.6rem; line-height: 1.45; margin: 0; }

.site-footer {
    width: 85%;
    max-width: 1000px;
    margin: 0 0 2rem;
    color: var(--quiet);
    font-family: "Libre Franklin", Arial, sans-serif;
    font-size: .95rem;
    line-height: 1.6;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --quiet: #b3b3a9; --ink: #ddd; --paper: #151515;
        --nav-rule: rgba(179, 179, 169, .2); --image-border: #55554f;
        --nav-paper: #252523; --nav-hover: rgba(221, 221, 221, .08);
        --viewer-backdrop: rgba(21, 21, 21, .88);
    }
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
    color-scheme: dark;
    --quiet: #b3b3a9; --ink: #ddd; --paper: #151515;
    --nav-rule: rgba(179, 179, 169, .2); --image-border: #55554f;
    --nav-paper: #252523; --nav-hover: rgba(221, 221, 221, .08);
    --viewer-backdrop: rgba(21, 21, 21, .88);
}
@media (max-width: 1000px) and (min-width: 761px) {
    .media-piece { width: 90%; grid-template-columns: 150px minmax(0, 1fr); gap: 1.6rem; }
    .video-preview .media-preview { width: 150px; }
}
@media (max-width: 760px) {
    .site-nav { padding: .35rem 0; }
    .nav-bar { width: 100%; gap: .5rem; }
    .nav-links { gap: 0 .2rem; font-size: 1.1rem; margin-left: -.45rem; }
    .nav-links a { min-height: 40px; padding: 0 .45rem; }
    .portfolio { padding: 1rem 0 2rem; }
    .page-header { margin-bottom: 1.25rem; }
    .page-header h1 { margin: .5rem 0 .75rem; font-size: 2.6rem; line-height: 1.05; }
    .page-header .subtitle { margin: .65rem 0 0; font-size: 1.5rem; }
    .site-name { margin-bottom: 1rem; font-size: 1.25rem; }
    .work-header { margin-bottom: .25rem; }
    .bio-layout { display: flow-root; }
    .portrait { float: right; width: clamp(112px, 34vw, 150px); max-width: none; margin: .3rem 0 .65rem 1rem; }
    .bio-copy { display: contents; }
    section > .writing-list, .chart-gallery, .media-piece, .thesis-header, .site-footer { width: 100%; max-width: 100%; }
    .chart-gallery { columns: 1; }
    .media-piece { grid-template-columns: minmax(0, 1fr); gap: 1.2rem; }
    .media-preview { width: 160px; }
    .video-preview .media-preview { width: min(240px, 100%); }
    .thesis-image { max-width: 100%; }
    .reading-header, .reading-section h2, .reading-section h3, .reading-section > .reading-figure,
    .reading-section > ul, .reading-section > ol,
    .reading-resources > p, .reading-audio { width: 100%; max-width: 100%; }
    .reading-header h1 { font-size: 2.25rem; line-height: 1.12; }
    .reading-section .marginnote {
        display: block;
        float: none;
        width: 100%;
        margin: 0 0 1.5rem;
    }
    .reading-sidebar {
        float: none;
        clear: both;
        width: 100%;
        margin: 1.5rem 0 1.8rem;
        padding-left: 1rem;
        border-left: 1px solid var(--nav-rule);
    }
    .reading-sidebar p, .reading-sidebar ul { font-size: 1.2rem; line-height: 1.55; }
    .reading-section > .reading-pullquote { width: 100%; padding: 0 1rem; margin: 2rem 0; }
    .reading-pullquote p { font-size: 1.5rem; }
}
@media (max-width: 900px) {
    section > .writing-list { grid-template-columns: minmax(0, 1fr); max-width: 640px; }
}
@media (prefers-reduced-motion: reduce) {
    #contact.contact-glow { animation: none; background-color: var(--contact-wash); }
}
