/* Shared styles for the site pages. The gear on the front page (index.html) carries its own. */

@font-face {
    font-family: "Instrument Sans";
    src: url("fonts/instrument-sans-wght.woff2") format("woff2");
    font-weight: 400 700;
    font-display: swap;
}

@font-face {
    font-family: "Geist Pixel";
    src: url("fonts/geist-pixel-square.woff2") format("woff2");
    font-display: swap;
}

:root {
    --void: #000000;
    --lit: #e6e8ea;
    --text: #c3c7cb;
    --steel: #8b9198;
    --gun: #2b2e31;

    --pixel: "Geist Pixel", ui-monospace, "SF Mono", Menlo, monospace;
    --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

    --pad: clamp(18px, 3.2vw, 44px);
    --rail: 248px;
    --measure: 660px;
    --gutter: 116px;
    --gear: min(calc(var(--rail) + var(--pad) - 8px), 38vh);

    /* A rule drawn as alternating lit and dark pixels. */
    --dash: linear-gradient(90deg, var(--gun) 50%, transparent 0) 0 0 / 4px 2px repeat-x;

    color-scheme: dark;
}

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

* {
    margin: 0;
    padding: 0;
}

html {
    background: var(--void);
    scrollbar-color: var(--gun) var(--void);
    scrollbar-width: thin;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    min-height: 100svh;
    font: 400 16px/1.65 var(--sans);
    color: var(--text);
    background: var(--void);
    -webkit-font-smoothing: antialiased;
}

::selection {
    color: var(--void);
    background: var(--lit);
}

/* Links are dotted until touched, then flip to black on a lit block,
   the same one-bit switch the landing page uses. */
a {
    color: var(--lit);
    text-decoration: underline dotted var(--steel) 2px;
    text-underline-offset: 4px;
}

a:hover {
    color: var(--void);
    background: var(--lit);
    text-decoration-color: transparent;
}

:focus-visible {
    outline: 2px solid var(--lit);
    outline-offset: 3px;
}

strong {
    font-weight: 600;
    color: var(--lit);
}

/* ---------- Rail: wordmark and section menu down the left ---------- */

.rail {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 2;
    width: var(--rail);
    padding: var(--pad);
    display: flex;
    flex-direction: column;
    gap: 46px;
}

.mark {
    width: fit-content;
    margin-left: -8px;
    padding: 3px 8px 5px;
    font: 400 26px/1 var(--pixel);
    text-decoration: none;
}

.rail nav {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-left: -10px;
}

.rail nav a {
    padding: 7px 10px 9px;
    font: 400 20px/1 var(--pixel);
    color: var(--steel);
    text-decoration: none;
}

.rail nav a:hover {
    color: var(--lit);
    background: none;
}

/* The open section. Keyed off the root so it is right before any script runs. */
.rail nav a[aria-current],
[data-open="bio"] .rail nav a[href="#bio"],
[data-open="projects"] .rail nav a[href="#projects"],
[data-open="ai-with-ai"] .rail nav a[href="#ai-with-ai"],
[data-open="contact"] .rail nav a[href="#contact"] {
    color: var(--void);
    background: var(--lit);
}

/* The corner of the gear the visitor came in through. */
.gear {
    position: fixed;
    left: 0;
    bottom: 0;
    z-index: -1;
    width: var(--gear);
    height: var(--gear);
    image-rendering: pixelated;
    pointer-events: none;
}

/* ---------- Stage: the column that changes ---------- */

.stage {
    min-height: 100vh;
    min-height: 100svh;
    margin-left: var(--rail);
    padding: var(--pad);
    padding-bottom: 96px;
}

.panel,
.post {
    max-width: var(--measure);
    margin-inline: auto;
}

/* Without script every section is simply stacked down the page. */
.panel {
    scroll-margin-top: 120px;
}

.panel + .panel {
    margin-top: 112px;
}

/* With script only one shows at a time. The oversized scroll margin stops the
   browser from scrolling a section named in the address up under the menu. */
.tabs .panel {
    display: none;
    margin-top: 0;
    scroll-margin-top: 100vh;
}

[data-open="bio"] #bio,
[data-open="projects"] #projects,
[data-open="ai-with-ai"] #ai-with-ai,
[data-open="contact"] #contact {
    display: block;
}

/* Dissolve played over the stage when the section changes. */
.veil {
    position: fixed;
    inset: 0 0 0 var(--rail);
    z-index: 3;
    width: calc(100% - var(--rail));
    height: 100%;
    image-rendering: pixelated;
    pointer-events: none;
    visibility: hidden;
}

.title {
    margin-bottom: 34px;
    font: 400 clamp(32px, 4.6vw, 46px)/1.1 var(--pixel);
    letter-spacing: -0.01em;
    color: var(--lit);
}

.title:focus {
    outline: none;
}

.lead {
    max-width: 30em;
    font-size: clamp(19px, 1.9vw, 22px);
    line-height: 1.45;
    color: var(--lit);
}

.panel p + p {
    margin-top: 1.1em;
}

.lead + p {
    margin-top: 1.6em;
}

/* ---------- Lists of projects and posts ---------- */

.list {
    list-style: none;
    background: var(--dash);
    background-position: 0 100%;
}

.title + .list {
    margin-top: -6px;
}

.lead + .list {
    margin-top: 34px;
}

.list li {
    background: var(--dash);
}

.row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 28px;
    align-items: baseline;
    padding: 24px 0 27px;
    color: inherit;
    text-decoration: none;
}

.row:hover {
    color: inherit;
    background: none;
}

.row h3 {
    width: fit-content;
    margin-left: -7px;
    padding: 2px 7px 4px;
    font: 400 22px/1.2 var(--pixel);
    color: var(--lit);
}

.row:hover h3,
.row:focus-visible h3 {
    color: var(--void);
    background: var(--lit);
}

.row .meta {
    font: 400 14px/1.2 var(--pixel);
    color: var(--steel);
    white-space: nowrap;
}

.row p {
    grid-column: 1;
    max-width: 34em;
}

.row .tech {
    margin-top: 0;
    font-size: 14px;
    color: var(--steel);
}

/* ---------- Contact ---------- */

.reach {
    margin-top: 40px;
    font: 400 clamp(20px, 3.2vw, 30px)/1.2 var(--pixel);
}

.reach a,
.elsewhere a {
    margin-left: -8px;
    padding: 3px 8px 5px;
}

.elsewhere {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 30px;
    margin-top: 26px;
    list-style: none;
    font: 400 18px/1.2 var(--pixel);
}

/* ---------- Posts: conversation transcripts ---------- */

.post {
    max-width: calc(var(--measure) + var(--gutter));
}

.post header {
    margin-bottom: 44px;
}

.back-link {
    display: inline-block;
    margin: 0 0 44px -8px;
    padding: 4px 8px 6px;
    font: 400 15px/1 var(--pixel);
    color: var(--steel);
    text-decoration: none;
}

.post h1 {
    margin-bottom: 14px;
    font: 400 clamp(30px, 4.4vw, 44px)/1.12 var(--pixel);
    letter-spacing: -0.01em;
    color: var(--lit);
}

.post-date {
    font: 400 14px/1.2 var(--pixel);
    color: var(--steel);
}

/* Speaker in the margin, their words beside it, like a script. */
.message {
    position: relative;
    padding: 30px 0 34px var(--gutter);
    background: var(--dash);
}

.speaker {
    position: absolute;
    top: 30px;
    left: 0;
    font: 400 15px/1.75 var(--pixel);
    color: var(--steel);
}

.speaker.dm {
    color: var(--lit);
}

.message p,
.details-content p {
    margin-bottom: 0.9em;
}

.message > :last-child,
.details-content > :last-child {
    margin-bottom: 0;
}

.speaker.dm ~ p {
    color: var(--lit);
}

.message .instruction {
    font-size: 14.5px;
    font-style: italic;
    color: var(--steel);
}

.message h2,
.message h3 {
    font-family: var(--pixel);
    font-weight: 400;
    line-height: 1.25;
    color: var(--lit);
}

.message h2 {
    margin: 2em 0 0.7em;
    font-size: 23px;
}

.message h3 {
    margin: 1.8em 0 0.6em;
    font-size: 18px;
}

.message h4 {
    margin: 1.6em 0 0.5em;
    font-size: 16px;
    font-weight: 600;
    color: var(--lit);
}

.message > h2:first-of-type,
.message > h3:first-of-type {
    margin-top: 0.4em;
}

.message ul,
.message ol {
    margin: 0 0 0.9em 1.3em;
}

.message li {
    margin-bottom: 0.4em;
    padding-left: 0.2em;
}

.message li::marker {
    color: var(--steel);
}

.message pre {
    margin: 1.2em 0;
    padding: 14px 18px;
    overflow-x: auto;
    font: 400 13.5px/1.6 var(--mono);
    color: var(--lit);
    border-left: 2px solid var(--steel);
}

.message code {
    font-family: var(--mono);
    font-size: 0.9em;
    color: var(--lit);
}

.message pre code {
    font-size: inherit;
}

math {
    color: var(--lit);
}

math[display="block"] {
    display: block;
    margin: 1.4em 0;
    overflow-x: auto;
    font-size: 1.12em;
    text-align: center;
}

table {
    width: 100%;
    margin: 1.4em 0;
    border-collapse: collapse;
    font-size: 15px;
}

th,
td {
    padding: 10px 14px 11px 0;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--gun);
}

th {
    font: 400 14px/1.3 var(--pixel);
    color: var(--lit);
    border-bottom-color: var(--steel);
}

details {
    margin-top: 1.2em;
}

summary {
    display: flex;
    gap: 12px;
    align-items: baseline;
    padding: 14px 0 16px;
    font: 400 17px/1.3 var(--pixel);
    color: var(--lit);
    list-style: none;
    cursor: pointer;
    background: var(--dash);
}

summary::-webkit-details-marker {
    display: none;
}

summary::before {
    content: "+";
    flex: none;
    width: 1ch;
    color: var(--steel);
}

details[open] > summary::before {
    content: "\2212";
}

summary:hover {
    color: var(--void);
    background: var(--lit);
}

summary:hover::before {
    color: var(--void);
}

.details-content {
    padding: 10px 0 8px;
}

.details-content h2,
.details-content h3 {
    font-family: var(--pixel);
    font-weight: 400;
    line-height: 1.25;
    color: var(--lit);
}

.details-content h2 {
    margin: 2em 0 0.7em;
    font-size: 23px;
}

.details-content h3 {
    margin: 1.8em 0 0.6em;
    font-size: 18px;
}

.details-content h4 {
    margin: 1.6em 0 0.5em;
    font-size: 16px;
    font-weight: 600;
    color: var(--lit);
}

/* ---------- Layout changes ---------- */

/* Enough room to centre the column on the page, not just beside the rail. */
@media (min-width: 1240px) {
    .stage {
        margin-right: var(--rail);
    }
}

/* And room for more of the gear. */
@media (min-width: 1480px) {
    :root {
        --gear: min(360px, 42vh);
    }
}

/* The gear would run into the menu on short windows. */
@media (max-height: 600px) {
    .gear {
        display: none;
    }
}

/* Narrow screens: the rail becomes a bar across the top. */
@media (max-width: 899px) {
    .rail {
        position: sticky;
        inset: 0 0 auto;
        width: auto;
        flex-flow: row wrap;
        gap: 6px 18px;
        align-items: center;
        justify-content: space-between;
        padding: 12px var(--pad) 14px;
        background: var(--dash), var(--void);
        background-position: 0 100%, 0 0;
    }

    .mark {
        font-size: 22px;
    }

    .rail nav {
        flex-flow: row wrap;
        gap: 2px;
        margin-left: -8px;
    }

    .rail nav a {
        padding: 6px 8px 8px;
        font-size: 16px;
    }

    .gear {
        display: none;
    }

    .stage {
        min-height: 0;
        margin-left: 0;
        padding-top: 34px;
    }

    .veil {
        inset: 0;
        width: 100%;
    }

    .title {
        margin-bottom: 26px;
    }

    .row {
        grid-template-columns: minmax(0, 1fr);
        gap: 6px;
    }

    .row .meta {
        grid-row: 1;
    }
}

@media (max-width: 599px) {
    .message {
        padding-left: 0;
    }

    .speaker {
        position: static;
        margin-bottom: 6px;
    }
}
