/*
 * Styles for the main site: /, /news/, /publications/, /teaching/, /group/, /talks/.
 * Course pages under /teaching/<course>/ still use main.css.
 *
 * Colors: Nord (https://www.nordtheme.com). Type: Inter (https://rsms.me/inter/).
 */

/* ---------- Tokens ---------- */

:root {
    /* Nord: Polar Night (0-3), Snow Storm (4-6), Frost (7-10), Aurora (11-15) */
    --nord0: #2e3440;
    --nord1: #3b4252;
    --nord2: #434c5e;
    --nord3: #4c566a;
    --nord4: #d8dee9;
    --nord5: #e5e9f0;
    --nord6: #eceff4;
    --nord8: #88c0d0;
    --nord10: #5e81ac;
    --nord14: #a3be8c;

    --bg: var(--nord6);
    --surface: var(--nord5);
    --border: var(--nord4);
    --text: var(--nord0);
    --muted: var(--nord3);
    --link: var(--nord10);
    --accent: var(--nord8);
    --header-bg: rgb(236 239 244 / 0.85);
    --logo-bg: #fff;

    --header-h: 3.75rem;
    color-scheme: light;
}

/* Dark mode follows the visitor's OS setting. Delete this block to stay light-only. */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: var(--nord0);
        --surface: var(--nord1);
        --border: var(--nord2);
        --text: var(--nord6);
        --muted: var(--nord4);
        --link: var(--nord8);
        --accent: var(--nord10);
        --header-bg: rgb(46 52 64 / 0.85);
        --logo-bg: var(--nord5);
        color-scheme: dark;
    }
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-family: Inter, sans-serif;
    font-feature-settings: 'liga' 1, 'calt' 1;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

@supports (font-variation-settings: normal) {
    html {
        font-family: InterVariable, sans-serif;
    }
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    letter-spacing: -0.011em;
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

a:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 2px;
    border-radius: 2px;
}

h1,
h2,
h3 {
    letter-spacing: -0.022em;
    line-height: 1.25;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 0.75rem;
}

h2 {
    font-size: 1.25rem;
    font-weight: 650;
    margin: 2.75rem 0 1rem;
}

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

p {
    margin: 0 0 1rem;
}

code {
    font-family: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.875em;
    padding: 0.1em 0.35em;
    border-radius: 0.25rem;
    background: var(--surface);
}

[id] {
    scroll-margin-top: calc(var(--header-h) + 1rem);
}

.wrap {
    max-width: 52.5rem;
    margin: 0 auto;
    padding-inline: 1.25rem;
}

.skip {
    position: absolute;
    left: -999px;
}

.skip:focus {
    left: 1rem;
    top: 0.75rem;
    z-index: 20;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    background: var(--bg);
}

/* ---------- Header ---------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--header-bg);
    -webkit-backdrop-filter: saturate(180%) blur(8px);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
}

.site-header .wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem 2rem;
    min-height: var(--header-h);
    padding-block: 0.75rem;
}

.site-name {
    color: var(--text);
    font-weight: 650;
    letter-spacing: -0.02em;
}

/* Homepage: keep the name's space in the header without showing it. */
.site-name.placeholder {
    visibility: hidden;
}

.site-header ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 0.9375rem;
}

.site-header nav a {
    color: var(--muted);
}

.site-header a:hover {
    color: var(--link);
    text-decoration: none;
}

.site-header a[aria-current] {
    color: var(--text);
}

.site-header nav a[aria-current] {
    font-weight: 600;
    text-decoration: underline 2px var(--link);
    text-underline-offset: 0.45em;
}

/* ---------- Page furniture ---------- */

main.wrap {
    padding-block: 3rem 4rem;
}

.lede {
    color: var(--muted);
    font-size: 1.0625rem;
}

.more {
    margin-top: 1rem;
    font-size: 0.9375rem;
    font-weight: 500;
}

.callout {
    padding: 0.75rem 1rem;
    border-left: 3px solid var(--accent);
    border-radius: 0 0.5rem 0.5rem 0;
    background: var(--surface);
}

/* Pill-shaped links: hero profile links, publication links. */
.pills,
.links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.pills a,
.links a {
    display: inline-block;
    padding: 0.3em 0.85em;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.875rem;
    line-height: 1.4;
}

.pills a:hover,
.links a:hover {
    border-color: var(--link);
    color: var(--link);
    text-decoration: none;
}

/* ---------- Home ---------- */

/* Name and title sit beside the photo; profile links go underneath them (desktop) or full width (mobile). */
.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "id    photo"
        "links photo";
    gap: 1.25rem 2.5rem;
    margin-bottom: 2.5rem;
}

.hero-id {
    grid-area: id;
    align-self: end;
}

.hero .pills {
    grid-area: links;
    align-self: start;
}

.hero h1 {
    font-size: 2.5rem;
    margin: 0;
}

.tagline {
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: 1.125rem;
}

.portrait {
    grid-area: photo;
    align-self: center;
    width: 176px;
    height: 176px;
    border-radius: 50%;
    object-fit: cover;
}

.logos {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin: 1.25rem 0 0;
    padding: 0;
    list-style: none;
}

.logos li {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 5.5rem;
    padding: var(--pad, 1.25rem);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--logo-bg);
}

.logos img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* ---------- Dated lists: news, teaching, talks, press ---------- */

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

.dated li {
    display: grid;
    grid-template-columns: 8rem minmax(0, 1fr);
    gap: 1.5rem;
    padding: 0.75rem 0;
    border-top: 1px solid var(--border);
}

.dated li:first-child {
    border-top: 0;
    padding-top: 0;
}

.dated .date {
    padding-top: 0.1rem;
    color: var(--muted);
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.dated p {
    margin: 0;
}

/* ---------- Publications ---------- */

.jump {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 0.9375rem;
}

/* A group of papers, with its label (year or "Preprints") in a sticky left gutter. */
.pub-group {
    display: grid;
    grid-template-columns: 6rem minmax(0, 1fr);
    column-gap: 1.5rem;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.pub-group > h2 {
    grid-column: 1;
    grid-row: 1 / span 99;
    align-self: start;
    position: sticky;
    top: calc(var(--header-h) + 1.25rem);
    margin: 0;
    padding-top: 0.15rem;
    color: var(--muted);
    font-size: 0.9375rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.pub-group > .pub {
    grid-column: 2;
}

.pub {
    margin: 0 -0.75rem 1.25rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
}

.pub:target {
    background: var(--surface);
    box-shadow: inset 3px 0 var(--accent);
}

.pub h3 {
    margin-bottom: 0.3rem;
    font-size: 1.0625rem;
}

.pub p {
    margin: 0;
    font-size: 0.9375rem;
}

.pub .me {
    text-decoration: underline 1px;
    text-underline-offset: 0.2em;
}

.pub .venue {
    color: var(--muted);
    font-style: italic;
}

.pub .note {
    color: var(--muted);
    font-size: 0.875rem;
    font-style: italic;
}

.pub .links {
    margin-top: 0.6rem;
    gap: 0.4rem;
}

.pub .links a {
    font-size: 0.8125rem;
}

/* Short venue name, e.g. "CCS '25". */
.tag {
    display: inline-block;
    margin-right: 0.45em;
    padding: 0.05em 0.5em;
    border: 1px solid var(--border);
    border-radius: 0.3rem;
    background: var(--surface);
    color: var(--text);
    font-size: 0.75rem;
    font-style: normal;
    font-weight: 600;
    letter-spacing: 0;
    vertical-align: 0.1em;
    white-space: nowrap;
}

/* "Artifact reproduced" and similar badges in a paper's link list. */
.links a.badge {
    border-color: var(--nord14);
    background: rgb(163 190 140 / 0.18);
}

/* ---------- Group ---------- */

.people {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.people li {
    padding: 0.85rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--surface);
    font-weight: 500;
}

/* ---------- Course pages (/teaching/<course>/) ---------- */

/* Course name and term with the college logo centered beside them; course links underneath. */
.course-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "title logo"
        "links links";
    align-items: center;
    gap: 1.25rem 1.5rem;
    margin-bottom: 2rem;
}

.course-title {
    grid-area: title;
}

.course-head h2 {
    margin: 0;
}

.course-head h1 {
    margin: 0;
    font-size: 2.5rem;
}

.course-head .logo {
    display: block;
    width: 88px;
    height: 88px;
}

.course-head > a {
    grid-area: logo;
}

.course-head .pills {
    grid-area: links;
}

/* Course text often runs a bare <span> into a <p>, so paragraphs need space above too. */
.course p {
    margin-top: 1rem;
}

.underline {
    text-decoration: underline 1px;
    text-underline-offset: 0.2em;
}

code.class-id {
    letter-spacing: -0.05em;
}

td,
th {
    vertical-align: top;
}

table.center {
    margin: 0 auto 1rem;
}

td.org-right {
    text-align: right;
}

blockquote {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    border-left: 3px solid var(--accent);
    border-radius: 0 0.5rem 0.5rem 0;
    background: var(--surface);
}

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
    .site-header {
        position: static;
    }

    main.wrap {
        padding-top: 2rem;
    }

    .hero {
        grid-template-areas:
            "id    photo"
            "links links";
        column-gap: 1rem;
    }

    .hero-id {
        align-self: center;
    }

    .hero h1 {
        font-size: 1.75rem;
    }

    .tagline {
        font-size: 1rem;
    }

    /* Put the institution on its own line under the title. */
    .tagline .sep {
        display: none;
    }

    .tagline .org {
        display: block;
    }

    .portrait {
        width: 96px;
        height: 96px;
    }

    .course-head h1 {
        font-size: 2rem;
    }

    .course-head .logo {
        width: 64px;
        height: 64px;
    }

    .logos {
        grid-template-columns: repeat(2, 1fr);
    }

    .dated li {
        grid-template-columns: 1fr;
        gap: 0.15rem;
    }

    .pub-group {
        display: block;
    }

    .pub-group > h2 {
        position: static;
        margin-bottom: 1rem;
    }
}

/* ---------- Print ---------- */

@media print {
    .site-header,
    .skip,
    .jump {
        display: none;
    }

    .pub,
    .dated li {
        break-inside: avoid;
    }
}
