/* Caladan Research: the shared foundation for every page.

   Tokens, paper, type, the masthead and the parts the discipline pages are
   built from. The gateway (/) adds its own composition inline; everything it
   shares with the rest of the site lives here. */

:root {
    --paper: #f4f1ea;
    --paper-2: #edeade;
    --ink: #191714;
    --ink-soft: #55504a;
    --ink-faint: #6a6459;
    --rule: #d9d1c0;
    --marine: #14424e;
    /* a pencil line: darker than a rule, quieter than text */
    --graphite: rgba(25, 23, 20, 0.3);
    --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, monospace;
    --gutter: clamp(1.5rem, 5vw, 4.5rem);
    --max: 1200px;
    /* one easing for everything that settles into place */
    --settle: cubic-bezier(0.22, 0.61, 0.24, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--serif);
    font-optical-sizing: auto;
    font-size: 1.0625rem;
    line-height: 1.62;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ─────────── paper ───────────
   Three layers, none of them meant to be noticed on its own: a broad
   unevenness in tone, the way a sheet takes light; a scatter of fibres;
   and the fine grain. All three sit above the page and multiply into it,
   so text, tinted bands and ink take the same texture as the paper. */
body::before,
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 9;
    pointer-events: none;
}

body::before {
    opacity: 0.5;
    mix-blend-mode: multiply;
    background-image:
        url("paper-fibres.svg"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='960' height='720'%3E%3Cfilter id='m' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.0032 0.0042' numOctaves='3' seed='11'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.38 0 0 0 0 0.27 1.1 0 0 0 -0.5'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23m)' opacity='0.16'/%3E%3C/svg%3E");
    background-size: 960px 960px, cover;
    background-repeat: repeat, no-repeat;
}

/* the grain */
body::after {
    opacity: 0.045;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection {
    background: var(--marine);
    color: var(--paper);
}

a {
    color: inherit;
    text-decoration: none;
}

:focus-visible {
    outline: 1px solid var(--marine);
    outline-offset: 4px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.wrap {
    width: 100%;
    max-width: var(--max);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.mark {
    width: 1.75rem;
    height: 1.75rem;
    display: block;
    color: var(--ink);
    flex: none;
}

/* ─────────── route transitions ───────────
   Moving between the gateway and a discipline is a cross-fade on the same
   sheet of paper, with the mark carried across: it settles from the centre
   of the gateway into the masthead, and back. Browsers without cross-document
   view transitions simply navigate. */
@view-transition {
    navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.5s;
    animation-timing-function: var(--settle);
}

::view-transition-group(mark) {
    animation-duration: 0.75s;
    animation-timing-function: var(--settle);
}

@media (prefers-reduced-motion: reduce) {
    @view-transition {
        navigation: none;
    }
}

/* ─────────── masthead ─────────── */
.masthead {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
}

/* anchors would otherwise land underneath the sticky masthead */
section[id] {
    scroll-margin-top: 5.25rem;
}

.masthead-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    padding: 1.4rem var(--gutter);
}

.wordmark {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.wordmark .mark {
    view-transition-name: mark;
}

.wordmark span {
    font-family: var(--mono);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.19em;
    text-transform: uppercase;
}

/* the two disciplines, the current one set in ink */
.disciplines {
    display: flex;
    gap: clamp(1.25rem, 3vw, 2.25rem);
    font-family: var(--mono);
    font-size: 0.6875rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.disciplines a {
    position: relative;
    color: var(--ink-faint);
    padding: 0.35rem 0;
    transition: color 0.3s;
}

.disciplines a::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.45s var(--settle);
}

.disciplines a:hover {
    color: var(--marine);
}

.disciplines a:hover::after,
.disciplines a[aria-current="page"]::after {
    transform: scaleX(1);
}

.disciplines a[aria-current="page"] {
    color: var(--ink);
}

.disciplines .short {
    display: none;
}

/* ─────────── shared typographic parts ─────────── */
.eyebrow {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--mono);
    font-size: 0.6875rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.eyebrow b {
    font-weight: 500;
    color: var(--marine);
}

.eyebrow i {
    flex: none;
    width: 3.25rem;
    height: 1px;
    background: var(--rule);
}

h1 {
    font-weight: 400;
    font-size: clamp(2.4rem, 5vw, 3.85rem);
    line-height: 1.04;
    letter-spacing: -0.021em;
    margin: 1.75rem 0 0;
}

h1 .l {
    display: block;
}

.lead {
    color: var(--ink-soft);
    max-width: 46ch;
    margin-top: 1.6rem;
    font-size: 1.09rem;
    line-height: 1.66;
}

/* ─────────── hero ─────────── */
.hero {
    display: grid;
    grid-template-columns: minmax(0, 7.6fr) minmax(0, 4.4fr);
    gap: clamp(2.5rem, 6vw, 5.5rem);
    align-items: start;
    padding: clamp(3.5rem, 8vw, 6.5rem) var(--gutter) clamp(3rem, 6vw, 5rem);
}

.team {
    margin-top: 1.5rem;
    max-width: 46ch;
    color: var(--ink-soft);
    font-size: 1rem;
}

/* ─────────── figure ─────────── */
figure {
    margin-top: 0.4rem;
}

.plate {
    display: block;
    width: 100%;
    max-width: 460px;
    margin-left: auto;
    overflow: visible;
}

.grid-line {
    fill: none;
    stroke: #d5ccb9;
    stroke-width: 1;
}

.grid-axis,
.wire {
    fill: none;
    stroke: #bdb2a0;
    stroke-width: 1.2;
}

.grid-tick {
    fill: none;
    stroke: #c6bba3;
    stroke-width: 1.4;
}

.trace {
    fill: none;
    stroke: var(--marine);
    stroke-width: 3.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    transform-box: view-box;
    transform-origin: 214px 206px;
}

.edge {
    fill: none;
    stroke: var(--marine);
    stroke-width: 1.5;
    opacity: 0.45;
}

.node {
    fill: var(--paper);
    stroke: var(--marine);
    stroke-width: 2;
}

.origin {
    fill: var(--marine);
}

.tint .node {
    fill: var(--paper-2);
}

/* the logarithmic spiral */
.curve {
    fill: none;
    stroke: var(--marine);
    stroke-width: 3.4;
    stroke-linecap: round;
    transform-box: view-box;
    transform-origin: 330px 330px;
}

/* oscillators falling into step */
.stream {
    fill: none;
    stroke: var(--marine);
    stroke-width: 1.4;
    opacity: 0.38;
}

/* paths under uncertainty and their envelope */
.env {
    fill: none;
    stroke: var(--marine);
    stroke-width: 2.2;
    opacity: 0.62;
}

.walk {
    fill: none;
    stroke: var(--marine);
    stroke-width: 1.4;
    opacity: 0.28;
}

figcaption {
    max-width: 460px;
    margin-left: auto;
    margin-top: 1.5rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--rule);
    font-family: var(--mono);
    font-size: 0.6875rem;
    line-height: 1.75;
    letter-spacing: 0.02em;
    color: var(--ink-faint);
}

figcaption b {
    font-weight: 500;
    color: var(--ink-soft);
}

/* ─────────── sections ─────────── */
section {
    padding: clamp(3.5rem, 7vw, 6rem) 0;
}

.band {
    border-top: 1px solid var(--rule);
}

.tint {
    background: var(--paper-2);
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
}

/* the footer draws its own top rule, so don't stack two hairlines */
#contact.tint {
    border-bottom: 0;
}

/* a figure and its description, alternating sides down the page */
.figrow {
    display: grid;
    grid-template-columns: minmax(0, 6fr) minmax(0, 6fr);
    gap: clamp(2.5rem, 6vw, 5rem);
    align-items: center;
    margin-top: clamp(2rem, 4vw, 3rem);
}

.figrow-left .plate,
.figrow-left figcaption {
    margin-left: 0;
    margin-right: auto;
}

/* a section with no figure: the heading keeps the left column */
.textrow {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: clamp(1.25rem, 6vw, 5rem);
    align-items: start;
    margin-top: clamp(2rem, 4vw, 3rem);
}

.copy h2 {
    font-weight: 400;
    font-size: clamp(1.7rem, 3vw, 2.2rem);
    letter-spacing: -0.018em;
    line-height: 1.12;
    margin-bottom: 1.1rem;
}

.copy p {
    color: var(--ink-soft);
    font-size: 1.06rem;
    line-height: 1.62;
    max-width: 52ch;
}

.copy p + p {
    margin-top: 1.05rem;
}

.copy h3 {
    font-weight: 400;
    font-size: clamp(1.25rem, 2vw, 1.45rem);
    letter-spacing: -0.012em;
    line-height: 1.2;
    margin: 2rem 0 0.75rem;
}

.copy p a {
    color: var(--ink);
    border-bottom: 1px solid var(--rule);
    transition: color 0.2s, border-color 0.2s;
}

.copy p a:hover {
    color: var(--marine);
    border-color: var(--marine);
}

/* a short ruled list */
.uses {
    list-style: none;
    margin-top: 1.6rem;
    max-width: 52ch;
    border-top: 1px solid var(--rule);
}

.uses li {
    display: flex;
    gap: 1rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--rule);
    font-size: 0.98rem;
    color: var(--ink-soft);
}

.uses li::before {
    content: "→";
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--marine);
    padding-top: 0.2rem;
}

/* ─────────── contact ─────────── */
.contact {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: clamp(2rem, 5vw, 4.5rem);
    border-top: 1px solid var(--rule);
    margin-top: 2.75rem;
    padding-top: 2.5rem;
}

.contact h2 {
    font-weight: 400;
    font-size: clamp(1.9rem, 3.6vw, 2.6rem);
    letter-spacing: -0.018em;
    line-height: 1.1;
}

.contact p {
    color: var(--ink-soft);
    margin-top: 1rem;
    max-width: 34ch;
}

.reach {
    display: flex;
    flex-direction: column;
    gap: 1.6rem;
}

.reach-item .k {
    font-family: var(--mono);
    font-size: 0.6875rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-faint);
    display: block;
    margin-bottom: 0.45rem;
}

.reach-item a {
    font-size: clamp(1.15rem, 2.1vw, 1.45rem);
    overflow-wrap: anywhere;
    border-bottom: 1px solid var(--rule);
    padding-bottom: 3px;
    transition: color 0.2s, border-color 0.2s;
}

.reach-item a:hover {
    color: var(--marine);
    border-color: var(--marine);
}

/* ─────────── footer ─────────── */
footer {
    border-top: 1px solid var(--rule);
    padding: 1.6rem 0 2.25rem;
}

.footer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    font-family: var(--mono);
    font-size: 0.6875rem;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.footer-row a {
    transition: color 0.2s;
}

.footer-row a:hover {
    color: var(--marine);
}

/* ─────────── responsive ─────────── */
@media (max-width: 900px) {
    .hero {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

    .plate,
    figcaption {
        margin-left: 0;
        max-width: 360px;
    }

    .figrow,
    .textrow {
        grid-template-columns: 1fr;
        gap: 2.5rem;
    }

    .textrow {
        gap: 0;
    }

    /* description first, figure under it, on every section */
    .figrow > figure {
        order: 2;
    }

    .figrow > .copy {
        order: 1;
    }

    .contact {
        grid-template-columns: 1fr;
        gap: 2.5rem;
    }
}

@media (max-width: 760px) {
    .disciplines .long {
        display: none;
    }

    .disciplines .short {
        display: inline;
    }
}

@media (max-width: 640px) {
    h1 .l {
        display: inline;
    }

    h1 {
        max-width: 15ch;
    }

    .footer-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}

/* the masthead row is the widest fixed element on the page — it set the
   document width on small screens until these were tightened */
@media (max-width: 560px) {
    .masthead-row {
        gap: 1rem;
    }

    .wordmark {
        gap: 0.55rem;
    }

    .wordmark .mark {
        width: 1.5rem;
        height: 1.5rem;
    }

    .wordmark span {
        font-size: 0.6875rem;
        letter-spacing: 0.13em;
    }

    .disciplines {
        gap: 1rem;
        letter-spacing: 0.1em;
    }
}

/* with the name, the mark and two links, the smallest phones keep the mark
   and let the name go; the mark still reads as home */
@media (max-width: 390px) {
    .wordmark span {
        display: none;
    }
}

/* Figures start hidden via inline stroke-dashoffset / opacity and are drawn
   by JS. With no JS at all, show them complete instead. */
html:not(.js) .draw {
    stroke-dashoffset: 0 !important;
}

html:not(.js) .pop {
    opacity: 1 !important;
}

@media (prefers-reduced-motion: reduce) {
    .draw {
        stroke-dashoffset: 0 !important;
    }

    .pop {
        opacity: 1 !important;
    }
}

@media print {
    body::before,
    body::after {
        display: none;
    }

    body {
        background: #fff;
        font-size: 11pt;
    }

    .masthead {
        position: static;
    }
}
