/* Shared styles: fonts, colors, the site bar and the home page.
   The article pages add assets/css/article.css on top of this file. */

@font-face {
    font-family: "Schibsted Grotesk";
    src: url("../fonts/schibsted-grotesk-latin-wght-normal.woff2") format("woff2");
    font-weight: 400 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "STIX Two Text";
    src: url("../fonts/stix-two-text-latin-wght-normal.woff2") format("woff2");
    font-weight: 400 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "STIX Two Text";
    src: url("../fonts/stix-two-text-latin-wght-italic.woff2") format("woff2");
    font-weight: 400 700;
    font-style: italic;
    font-display: swap;
}

/* ---------- Colors ---------- */

:root {
    --paper: #ffffff;
    --ink: #111111;
    --muted: #5c5c5c;
    --rule: #dcdcdc;
    --panel: #f4f4f4;
    --link: #111111;
    --dot: #c9c9c9;
    color-scheme: light;
}

/* Dark: by the visitor's system setting, or by the button in the bar. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper: #111111;
        --ink: #ececec;
        --muted: #a8a8a8;
        --rule: #333333;
        --panel: #1c1c1c;
        --link: #ececec;
        --dot: #3d3d3d;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --paper: #111111;
    --ink: #ececec;
    --muted: #a8a8a8;
    --rule: #333333;
    --panel: #1c1c1c;
    --link: #ececec;
    --dot: #3d3d3d;
    color-scheme: dark;
}

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

:root {
    --sans: "Schibsted Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --serif: "STIX Two Text", "Times New Roman", Times, serif;

    --gutter: clamp(1.25rem, 5vw, 3.5rem);
    --label: 11rem;
    --measure: 43rem;
}

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

html {
    background: var(--paper);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    color: var(--ink);
    font-family: var(--sans);
    font-size: 1.0625rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { display: block; max-width: 100%; height: auto; }

a {
    color: var(--link);
    text-decoration-line: underline;
    text-decoration-thickness: 0.06em;
    text-underline-offset: 0.2em;
}

a:hover { text-decoration-thickness: 0.13em; }

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

.skip {
    position: absolute;
    left: var(--gutter);
    top: -4rem;
    padding: 0.5rem 0.9rem;
    background: var(--ink);
    color: var(--paper);
    font-weight: 600;
    z-index: 10;
}

.skip:focus { top: 0.75rem; color: var(--paper); }

.wrap {
    max-width: 72rem;
    margin: 0 auto;
    padding-inline: var(--gutter);
}

/* ---------- Site bar ---------- */

.bar {
    display: flex;
    align-items: center;
    gap: 0.75rem 1.5rem;
    padding-block: 1.1rem;
    font-size: 0.9375rem;
    font-weight: 600;
}

.bar a { text-decoration: none; }
.bar a:hover { text-decoration: underline; text-decoration-thickness: 0.13em; }

.bar .home {
    font-size: 1.125rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.bar-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.2rem 1.5rem;
    margin-left: auto;
}

/* ---------- Light and dark button ---------- */

.toggle {
    flex: none;
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid var(--rule);
    border-radius: 50%;
    background: none;
    color: var(--ink);
    cursor: pointer;
}

.toggle:hover { border-color: var(--ink); }
.toggle svg { width: 1.05rem; height: 1.05rem; }
.toggle[hidden] { display: none; }

/* ---------- Introduction ---------- */

.intro {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(10rem, 21vw, 14.5rem);
    column-gap: clamp(1.5rem, 5vw, 4.5rem);
    align-items: start;
    /* Room inside the clipped box for the focus ring of the links. */
    margin-inline: -0.5rem;
    padding: clamp(1.25rem, 4vw, 2.75rem) 0.5rem clamp(2rem, 5vw, 3.25rem);
}

.intro h1 {
    font-size: clamp(2.6rem, 7vw, 4.5rem);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.04em;
}

.role {
    margin-top: 0.7rem;
    font-size: clamp(1.0625rem, 1.9vw, 1.25rem);
    font-weight: 600;
    line-height: 1.3;
}

.bio {
    margin-top: 1.1rem;
    max-width: 36rem;
    font-family: var(--serif);
    font-size: 1.1875rem;
    line-height: 1.55;
}

.links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.4rem;
    font-size: 0.9375rem;
    font-weight: 600;
}

.intro .links { margin-top: 1.3rem; font-size: 1rem; }

.portrait {
    overflow: hidden;
    aspect-ratio: 4 / 5;
    background: var(--panel);
}

.portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 38%;
}

/* ---------- Sections: a label in the margin, entries beside it ---------- */

.section {
    display: grid;
    grid-template-columns: var(--label) minmax(0, var(--measure));
    column-gap: clamp(2rem, 5vw, 4.5rem);
    padding-block: 1.6rem 1.9rem;
    border-top: 1px solid var(--rule);
}

.section > h2 {
    font-size: 1.0625rem;
    font-weight: 800;
    line-height: 1.4;
}

.body > * + * { margin-top: 1.2rem; }

.entry {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 1.25rem;
    align-items: baseline;
}

.entry h3 {
    font-size: 1.0625rem;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: -0.005em;
}

/* What follows the name in a heading: the association, the degree. */
.entry h3 span {
    margin-left: 0.35em;
    color: var(--muted);
    font-weight: 400;
}

.when {
    color: var(--muted);
    font-size: 0.875rem;
    white-space: nowrap;
}

.entry > .meta,
.entry > .text,
.entry > .links { grid-column: 1 / -1; }

.meta {
    color: var(--muted);
    font-size: 0.9375rem;
    line-height: 1.45;
}

.text {
    margin-top: 0.25rem;
    font-family: var(--serif);
    font-size: 1.0625rem;
    line-height: 1.5;
}

.entry > .links { margin-top: 0.35rem; }

/* Leadership: one line of role and dates, one line of what it was. */
.compact > * + * { margin-top: 0.75rem; }
.compact .text { margin-top: 0; color: var(--muted); font-size: 1rem; line-height: 1.45; }

/* ---------- Footer ---------- */

.foot {
    padding-block: 1.5rem 2.5rem;
    border-top: 1px solid var(--rule);
    color: var(--muted);
    font-size: 0.875rem;
}

/* ---------- Parallax in the introduction ---------- */

/* A field of dots behind the introduction. It scrolls more slowly than the
   page, and the portrait drifts inside its frame; --sy is the scroll
   position in pixels, set by assets/js/site.js. */
.backdrop {
    position: absolute;
    z-index: -1;
    top: -2rem;
    right: 0;
    width: min(46rem, 100%);
    height: calc(100% + 16rem);
    pointer-events: none;
    background-image: radial-gradient(circle, var(--dot) 1.1px, transparent 1.7px);
    background-size: 1.375rem 1.375rem;
    -webkit-mask-image: radial-gradient(ellipse 62% 48% at 72% 34%, #000 18%, transparent 78%);
    mask-image: radial-gradient(ellipse 62% 48% at 72% 34%, #000 18%, transparent 78%);
}

@media (prefers-reduced-motion: no-preference) {
    .backdrop {
        transform: translate3d(0, calc(var(--sy, 0) * 0.42px), 0);
        will-change: transform;
    }

    .portrait img {
        transform: translate3d(0, calc(-8% + min(var(--sy, 0) * 0.09px, 16%)), 0) scale(1.2);
        will-change: transform;
    }
}

/* ---------- Narrow screens ---------- */

@media (max-width: 54rem) {
    .section { grid-template-columns: minmax(0, 1fr); row-gap: 0.9rem; }
}

@media (max-width: 40rem) {
    .bar { align-items: flex-start; gap: 0.75rem; }
    .bar-links { flex: 1; justify-content: flex-start; gap: 0.2rem 1rem; margin-left: 0; }
    .bar .home + .bar-links { padding-top: 0.15rem; }
    .toggle { flex: none; margin-top: -0.35rem; }

    /* The dots stay around the name and the portrait, off the text. */
    .backdrop {
        -webkit-mask-image: radial-gradient(ellipse 75% 26% at 70% 16%, #000 20%, transparent 80%);
        mask-image: radial-gradient(ellipse 75% 26% at 70% 16%, #000 20%, transparent 80%);
    }

    .intro { grid-template-columns: minmax(0, 1fr) 6.5rem; column-gap: 1rem; }
    .intro-text { display: contents; }
    .intro h1 { grid-column: 1; grid-row: 1; align-self: end; }
    .role { grid-column: 1; grid-row: 2; }
    .portrait { grid-column: 2; grid-row: 1 / 3; align-self: start; }
    .bio, .intro .links { grid-column: 1 / -1; }

    .entry { grid-template-columns: minmax(0, 1fr); }
}

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

@media print {
    :root,
    :root[data-theme="dark"],
    :root:not([data-theme="light"]) {
        --paper: #ffffff;
        --ink: #111111;
        --muted: #5c5c5c;
        --rule: #dcdcdc;
        --panel: #f4f4f4;
        --link: #111111;
        color-scheme: light;
    }

    body { font-size: 10pt; }
    .skip, .bar, .backdrop { display: none; }
    .wrap { max-width: none; padding: 0; }
    .intro { margin: 0; padding: 0 0 1.5rem; grid-template-columns: minmax(0, 1fr) 8rem; }
    .portrait img { transform: none; }
    .section { padding-block: 0.9rem; break-inside: avoid; }
}
