/*
 * johancarlberg.se: Material 3 in hand-written CSS, built like the dflag.se front page (quiet tinted surfaces instead
 * of outlines, rounded shapes, light and dark after the device). The top bar and the start page's stage stay dark in
 * both, like a theatre with the house lights down. Headings in Raleway (the old site's heading font), text in Nunito.
 * Every text colour pair is at least 4.5:1 (WCAG AA). The tones: rida (theatre red, default), natt and guld
 * (?ton= locally). Omtag 2: the page moves as it scrolls (the motion section at the end: transform and opacity only,
 * CSS scroll-driven animations with an IntersectionObserver fallback, nothing at all with reduced motion).
 */

@font-face {
    font-family: "Raleway";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/raleway-latin-700-normal.woff2") format("woff2");
}

@font-face {
    font-family: "Raleway";
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url("../fonts/raleway-latin-800-normal.woff2") format("woff2");
}

@font-face {
    font-family: "Nunito";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/nunito-latin-400-normal.woff2") format("woff2");
}

@font-face {
    font-family: "Nunito";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/nunito-latin-700-normal.woff2") format("woff2");
}

:root {
    color-scheme: light dark;
    --font: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: "Raleway", "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    --radius-card: 24px;
    --radius-small: 16px;
    --max: 1080px;
    --gutter: max(16px, env(safe-area-inset-left));
    --gutter-r: max(16px, env(safe-area-inset-right));
    /* the stage (top bar and the start page's hero), the same in light and dark */
    --stage-bg: #120c0d;
    --stage-surface: #231a1b;
    --stage-text: #f4ecea;
    --stage-text-2: #cdbfbd;
    --nav-h: 80px;
    --outline: color-mix(in srgb, var(--text) 45%, transparent);
    --error-container: #ffdad6;
    --on-error-container: #410002;
}

:root,
:root[data-tone="rida"] {
    --primary: #9c2a33;
    --on-primary: #ffffff;
    --container: #ffdad8;
    --on-container: #410008;
    --bg: #fff8f7;
    --surface: #fbeeec;
    --surface-high: #f5e1df;
    --text: #231918;
    --text-2: #534341;
    --accent: #ffb3ae;
    --on-accent: #5c0011;
}

:root[data-tone="natt"] {
    --primary: #3a4ba8;
    --on-primary: #ffffff;
    --container: #dee0ff;
    --on-container: #00105c;
    --bg: #fbf8ff;
    --surface: #f0effa;
    --surface-high: #e4e4f2;
    --text: #1b1b21;
    --text-2: #46464f;
    --accent: #bac3ff;
    --on-accent: #08218a;
    --stage-bg: #0c0d14;
    --stage-surface: #1b1c26;
    --stage-text: #e8e8f4;
    --stage-text-2: #c3c4d4;
}

:root[data-tone="guld"] {
    --primary: #765400;
    --on-primary: #ffffff;
    --container: #ffdea3;
    --on-container: #261900;
    --bg: #fff8f2;
    --surface: #faefe2;
    --surface-high: #f2e4d2;
    --text: #1f1b13;
    --text-2: #4e4639;
    --accent: #f5bf48;
    --on-accent: #3a2800;
    --stage-bg: #12100b;
    --stage-surface: #221e15;
    --stage-text: #f3ede2;
    --stage-text-2: #cfc6b6;
}

@media (prefers-color-scheme: dark) {
    :root {
        --error-container: #93000a;
        --on-error-container: #ffdad6;
    }

    :root,
    :root[data-tone="rida"] {
        --primary: #ffb3ae;
        --on-primary: #5c0011;
        --container: #7f1a24;
        --on-container: #ffdad8;
        --bg: #1a1111;
        --surface: #271d1c;
        --surface-high: #332827;
        --text: #f1dedc;
        --text-2: #d8c2bf;
    }

    :root[data-tone="natt"] {
        --primary: #bac3ff;
        --on-primary: #08218a;
        --container: #283b91;
        --on-container: #dee0ff;
        --bg: #121318;
        --surface: #1e1f25;
        --surface-high: #292a31;
        --text: #e4e1e9;
        --text-2: #c6c5d0;
    }

    :root[data-tone="guld"] {
        --primary: #f5bf48;
        --on-primary: #3a2800;
        --container: #5a4000;
        --on-container: #ffdea3;
        --bg: #17130b;
        --surface: #241f16;
        --surface-high: #2f2920;
        --text: #ebe1d4;
        --text-2: #d1c5b4;
    }
}

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: 80px;
}

body {
    margin: 0;
    min-height: 100vh;
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

h1,
h2,
h3,
p,
ul,
ol,
figure {
    margin: 0;
}

ul,
ol {
    padding: 0;
    list-style: none;
}

img {
    display: block;
    max-width: 100%;
}

[hidden] {
    display: none !important;
}

a {
    color: var(--primary);
}

.icon {
    display: block;
    flex: none;
    width: 24px;
    height: 24px;
    fill: currentColor;
}

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

.app-bar :focus-visible,
.stage :focus-visible {
    outline-color: var(--accent);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.skip {
    position: absolute;
    top: -100px;
    left: 16px;
    z-index: 30;
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 700;
    text-decoration: none;
}

.skip:focus {
    top: 12px;
}

/* ---------------------------------------------------------------- the top bar */

.app-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--stage-bg);
    color: var(--stage-text);
    padding-top: env(safe-area-inset-top);
}

.app-bar__inner {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: var(--max);
    min-height: 64px;
    margin: 0 auto;
    padding: 0 var(--gutter-r) 0 var(--gutter);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.brand__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--accent);
}

.brand__name {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: .01em;
    white-space: nowrap;
}

.tabs {
    display: none;
}

.icon-btn {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin-left: auto;
    border-radius: 50%;
    color: var(--stage-text);
}

.icon-btn:hover,
.icon-btn[aria-current="page"] {
    background: var(--stage-surface);
    color: var(--accent);
}

@media (min-width: 900px) {
    .tabs {
        display: flex;
        gap: 4px;
        margin-left: auto;
    }

    .tabs__link {
        padding: 10px 16px;
        border-radius: 999px;
        color: var(--stage-text-2);
        font-weight: 700;
        text-decoration: none;
        white-space: nowrap;
    }

    .tabs__link:hover {
        background: var(--stage-surface);
        color: var(--stage-text);
    }

    .tabs__link[aria-current="page"] {
        background: var(--accent);
        color: var(--on-accent);
    }

    .app-bar__contact {
        display: none;
    }
}

/* ---------------------------------------------------------------- the stage (start page) */

.stage {
    position: relative;
    overflow: hidden;
    background: var(--stage-bg);
    color: var(--stage-text);
}

/* the spotlight: a soft light in the tone's accent, drifting as the page scrolls (motion below) */
.stage__light {
    position: absolute;
    inset: -20% -20% auto auto;
    width: 90%;
    height: 90%;
    background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 30%, transparent), transparent);
    pointer-events: none;
}

.stage__inner {
    position: relative;
    display: grid;
    max-width: var(--max);
    margin: 0 auto;
    padding: 0 var(--gutter-r) 40px var(--gutter);
}

.stage__portrait {
    position: relative;
    margin: 0 calc(-1 * var(--gutter-r)) 0 calc(-1 * var(--gutter));
    overflow: hidden;
}

.stage__portrait img {
    width: 100%;
    height: min(50vh, 440px);
    object-fit: cover;
    object-position: 50% 30%;
    transform-origin: 50% 40%;
}

.stage__portrait::after {
    content: "";
    position: absolute;
    inset: 40% 0 0;
    background: linear-gradient(to bottom, transparent, var(--stage-bg));
}

.stage__text {
    position: relative;
    z-index: 1;
    margin-top: -72px;
}

.stage__kicker {
    color: var(--accent);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    font-size: .8125rem;
}

.stage__name {
    margin-top: 4px;
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 11vw, 5rem);
    font-weight: 800;
    line-height: 1.02;
    letter-spacing: -.015em;
}

.stage__tag {
    margin-top: 12px;
    max-width: 30em;
    color: var(--stage-text-2);
    font-size: 1.125rem;
}

.stage .actions {
    margin-top: 24px;
}

.stage__scroll {
    display: none;
}

@media (min-width: 840px) {
    .stage__inner {
        grid-template-columns: 1fr minmax(320px, 420px);
        align-items: center;
        gap: 56px;
        min-height: calc(100svh - 64px);
        padding-top: 48px;
        padding-bottom: 88px;
    }

    .stage__portrait {
        order: 2;
        margin: 0;
        border-radius: 32px;
        box-shadow: 0 16px 40px rgb(0 0 0 / .45);
    }

    .stage__portrait img {
        height: auto;
        aspect-ratio: 525 / 799;
    }

    .stage__portrait::after {
        display: none;
    }

    .stage__text {
        margin-top: 0;
    }

    .stage__scroll {
        position: absolute;
        left: 50%;
        bottom: 24px;
        display: block;
        width: 28px;
        height: 44px;
        margin-left: -14px;
        border: 2px solid var(--stage-text-2);
        border-radius: 14px;
    }

    .stage__scroll span {
        position: absolute;
        left: 50%;
        top: 8px;
        width: 4px;
        height: 8px;
        margin-left: -2px;
        border-radius: 2px;
        background: var(--stage-text);
    }
}

/* ---------------------------------------------------------------- Scen. Film. Röst. Impro. (pinned while it lights up) */

.statement {
    position: relative;
    background: var(--stage-bg);
    color: var(--stage-text);
}

.statement__sticky {
    display: grid;
    place-content: center;
    gap: 20px;
    padding: 72px var(--gutter-r) 80px var(--gutter);
    text-align: center;
}

.statement__line {
    font-family: var(--font-display);
    font-size: clamp(2.75rem, 13vw, 8.5rem);
    font-weight: 800;
    line-height: 1.02;
    letter-spacing: -.02em;
}

.w {
    display: inline-block;
}

.w4 {
    color: var(--accent);
}

.statement__sub {
    color: var(--stage-text-2);
    font-size: clamp(1.125rem, 3vw, 1.5rem);
}

/* ---------------------------------------------------------------- buttons */

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 10px 24px 10px 18px;
    border-radius: 999px;
    font-weight: 700;
    text-decoration: none;
}

button.btn {
    border: 0;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.btn .icon {
    width: 20px;
    height: 20px;
}

.btn--filled {
    background: var(--primary);
    color: var(--on-primary);
}

.stage .btn--filled {
    background: var(--accent);
    color: var(--on-accent);
}

.btn--on-dark {
    color: var(--stage-text);
    box-shadow: inset 0 0 0 1px var(--stage-text-2);
}

.btn--tonal {
    background: var(--container);
    color: var(--on-container);
}

.btn:hover {
    filter: brightness(1.06);
}

.btn--on-dark:hover {
    background: var(--stage-surface);
}

/* ---------------------------------------------------------------- page and sections */

.page {
    max-width: var(--max);
    margin: 0 auto;
    padding: 24px var(--gutter-r) 32px var(--gutter);
}

.page--narrow {
    max-width: 760px;
}

.section {
    margin-top: 40px;
}

.section h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.25;
}

.section__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.section__sub {
    margin-top: 4px;
    color: var(--text-2);
}

.link-more {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex: none;
    font-weight: 700;
    text-decoration: none;
}

.link-more .icon {
    width: 20px;
    height: 20px;
}

.intro {
    margin-top: 16px;
}

.prose {
    max-width: 68ch;
}

.prose p,
.prose .bullets {
    margin-top: 14px;
    font-size: 1.0625rem;
    line-height: 1.65;
}

.section > h2 + .prose,
.intro .prose {
    margin-top: 4px;
}

.prose em {
    font-style: italic;
}

.prose .list-intro {
    font-weight: 700;
}

.prose .list-intro + .bullets {
    margin-top: 8px;
}

.bullets li {
    position: relative;
    margin-top: 6px;
    padding-left: 22px;
}

.bullets li::before {
    content: "";
    position: absolute;
    left: 4px;
    top: .7em;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
}

.lead {
    margin-top: 8px;
    color: var(--text-2);
    font-size: 1.125rem;
}

/* the page head: the old site's banner, the page's name and its own heading */

.page-head__title {
    margin-top: 4px;
    font-family: var(--font-display);
    font-size: clamp(1.875rem, 7vw, 3rem);
    font-weight: 800;
    line-height: 1.1;
}

.banner {
    margin-bottom: 20px;
    border-radius: var(--radius-card);
    overflow: hidden;
    background: var(--surface-high);
}



.page-head--plain {
    padding-top: 16px;
}

.page-head + .actions {
    margin-top: 24px;
}

/* ---------------------------------------------------------------- clips (YouTube, on press) */

.clips {
    display: grid;
    gap: 16px;
    margin-top: 16px;
}

@media (min-width: 600px) {
    .clips {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 960px) {
    .clips {
        grid-template-columns: repeat(3, 1fr);
    }
}

.clip {
    border-radius: var(--radius-card);
    overflow: hidden;
    background: var(--surface);
}

.clip__body {
    padding: 14px 18px 18px;
}

.clip__title {
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 700;
}

.clip__text {
    margin-top: 4px;
    color: var(--text-2);
}

.player {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #000;
}

.player__start,
.player iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.player__start img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player__button {
    position: absolute;
    left: 50%;
    top: 50%;
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin: -32px 0 0 -32px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: 0 4px 16px rgb(0 0 0 / .4);
}

.player__button .icon {
    width: 36px;
    height: 36px;
}

.player__start:hover .player__button {
    transform: scale(1.06);
}

/* ---------------------------------------------------------------- voice clips (our own mp3 files) */

.voices {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

@media (min-width: 720px) {
    .voices {
        grid-template-columns: 1fr 1fr;
    }

    .voices--one {
        grid-template-columns: minmax(0, 560px);
    }
}

.voice {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 14px;
    align-items: start;
    padding: 16px;
    border-radius: var(--radius-card);
    background: var(--surface);
}

.voice__pic {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-small);
    background: #fff;
    object-fit: cover;
}

.voice__title {
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 700;
}

.voice__text {
    margin-top: 2px;
    color: var(--text-2);
}

.voice__audio {
    display: block;
    width: 100%;
    margin-top: 12px;
}

@media (min-width: 420px) {
    .voice {
        grid-template-columns: 80px 1fr;
    }

    .voice__pic {
        width: 80px;
        height: 80px;
    }
}

/* ---------------------------------------------------------------- next page, links */

.next {
    margin-top: 48px;
}

.next__link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-radius: var(--radius-card);
    background: var(--container);
    color: var(--on-container);
    text-decoration: none;
}

.next__dir {
    font-size: .8125rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.next__title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
}

.next__link .icon {
    margin-left: auto;
}

.card-links {
    display: grid;
    gap: 12px;
}

.card-link {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    border-radius: var(--radius-card);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
}

.card-link:hover {
    background: var(--surface-high);
}

.card-link__icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--container);
    color: var(--on-container);
}

.card-link__body {
    display: grid;
    min-width: 0;
}

.card-link__title {
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 700;
}

.card-link__text {
    color: var(--text-2);
    overflow-wrap: anywhere;
}

.card-link__go {
    margin-left: auto;
    color: var(--text-2);
}

/* ---------------------------------------------------------------- the facts (counted, not written) */

.facts__list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (min-width: 840px) {
    .facts__list {
        grid-template-columns: repeat(4, 1fr);
    }
}

.fact {
    display: grid;
    align-content: start;
    gap: 4px;
    padding: 20px;
    border-radius: var(--radius-card);
    background: var(--surface);
}

.fact--wide {
    grid-column: span 2;
}

@media (min-width: 840px) {
    .fact--wide {
        grid-column: auto;
    }
}

.fact__num {
    color: var(--primary);
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 8vw, 3.5rem);
    font-weight: 800;
    line-height: 1;
}

.fact__title {
    font-family: var(--font-display);
    font-size: 1.375rem;
    font-weight: 800;
    line-height: 1.2;
}

.fact__label {
    color: var(--text-2);
}

/* ---------------------------------------------------------------- the chapters (start page): a menu that stays */

.chapters__grid {
    margin-top: 16px;
}

.chapters__nav {
    position: sticky;
    top: calc(64px + env(safe-area-inset-top));
    z-index: 5;
    display: flex;
    gap: 8px;
    margin: 0 calc(-1 * var(--gutter-r)) 16px calc(-1 * var(--gutter));
    padding: 10px var(--gutter-r) 10px var(--gutter);
    overflow-x: auto;
    background: var(--bg);
    scrollbar-width: none;
}

.chapters__nav::-webkit-scrollbar {
    display: none;
}

.chapters__link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: none;
    padding: 8px 16px 8px 12px;
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-2);
    font-weight: 700;
    text-decoration: none;
}

.chapters__link .icon {
    width: 20px;
    height: 20px;
}

.chapters__link[aria-current] {
    background: var(--container);
    color: var(--on-container);
}

.chapter {
    margin-bottom: 48px;
    scroll-margin-top: 140px;
}

.chapter__media {
    display: block;
    border-radius: var(--radius-card);
    overflow: hidden;
    background: var(--surface-high);
}

.chapter__media img,
.banner img {
    width: 100%;
    aspect-ratio: 12 / 5;
    object-fit: cover;
    object-position: 78% 40%;
    transform-origin: 70% 50%;
}

.chapter__body {
    padding-top: 18px;
}

.chapter__kicker,
.page-head__kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    font-size: .8125rem;
}

.chapter__kicker .icon,
.page-head__kicker .icon {
    width: 20px;
    height: 20px;
}

.chapter__heading {
    margin-top: 4px;
    font-family: var(--font-display);
    font-size: clamp(1.625rem, 5vw, 2.25rem);
    font-weight: 800;
    line-height: 1.15;
}

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

.chapter__text {
    max-width: 60ch;
    margin-top: 10px;
    color: var(--text-2);
    font-size: 1.0625rem;
}

.chapter__roles {
    display: grid;
    gap: 6px;
    margin-top: 14px;
}

.chapter__roles li {
    display: flex;
    gap: 12px;
}

.chapter__year,
.tl__year {
    flex: none;
    min-width: 5.5em;
    color: var(--primary);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.chapter__count {
    margin-top: 12px;
    font-weight: 700;
}

.chapter .link-more {
    margin-top: 14px;
}

@media (min-width: 840px) {
    .chapters__grid {
        display: grid;
        grid-template-columns: 220px 1fr;
        gap: 48px;
        align-items: start;
    }

    .chapters__nav {
        top: 104px;
        flex-direction: column;
        margin: 0;
        padding: 0;
        overflow: visible;
        background: none;
    }

    .chapters__link {
        padding: 12px 18px 12px 14px;
        background: none;
        font-size: 1.0625rem;
    }

    .chapters__link:hover {
        background: var(--surface);
    }

    .chapter {
        margin-bottom: 72px;
    }

    .chapter__media img,
    .banner img {
        aspect-ratio: 900 / 220;
    }
}

/* ---------------------------------------------------------------- the clip rail (start page) */

.rail {
    margin-top: 16px;
}

.rail__track {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 84%;
    gap: 14px;
    margin: 0 calc(-1 * var(--gutter-r)) 0 calc(-1 * var(--gutter));
    padding: 0 var(--gutter-r) 6px var(--gutter);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 var(--gutter);
    scrollbar-width: none;
}

.rail__track::-webkit-scrollbar {
    display: none;
}

.rail__item {
    scroll-snap-align: start;
}

.rail__dots {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 14px;
}

.rail__dot {
    width: 8px;
    height: 8px;
    border-radius: 4px;
    background: var(--text-2);
    opacity: .3;
}

.rail__dot.is-on {
    opacity: 1;
    transform: scaleX(2.2);
}

@media (min-width: 840px) {
    .rail__track {
        grid-auto-columns: calc((100% - 28px) / 3);
        margin: 0;
        padding: 0;
    }

    .rail__dots {
        display: none;
    }
}

/* ---------------------------------------------------------------- the roles: a timeline that draws itself */

.timeline {
    position: relative;
    display: grid;
    gap: 10px;
    margin-top: 18px;
    padding-left: 30px;
}

.timeline::before,
.timeline::after {
    content: "";
    position: absolute;
    left: 9px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    border-radius: 1px;
    background: var(--surface-high);
}

.timeline::after {
    background: var(--primary);
    transform-origin: 50% 0;
}

.tl {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 14px;
    padding: 14px 16px;
    border-radius: var(--radius-small);
    background: var(--surface);
}

.tl__dot {
    position: absolute;
    left: -27px;
    top: 19px;
    width: 14px;
    height: 14px;
    border: 3px solid var(--primary);
    border-radius: 50%;
    background: var(--bg);
}

.tl__main {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.tl__title {
    font-weight: 700;
}

.tl__label,
.tl__by,
.tl__note {
    color: var(--text-2);
}

.tl__note {
    font-style: italic;
}

.tl__link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    width: fit-content;
    margin-top: 4px;
    font-weight: 700;
}

.tl__link .icon {
    width: 18px;
    height: 18px;
}

.tl__clip {
    margin-top: 6px;
}

.tl__clip summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}

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

.tl__clip summary .icon {
    width: 20px;
    height: 20px;
}

.tl__clip .player {
    margin-top: 10px;
    border-radius: var(--radius-small);
    overflow: hidden;
}

@media (min-width: 720px) {
    .tl__main {
        grid-template-columns: 1fr minmax(160px, 36%);
        column-gap: 16px;
    }

    .tl__by {
        grid-column: 2;
        grid-row: 1;
        text-align: right;
    }
}

.tl__pic {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 3 / 2;
    margin-bottom: 8px;
    border-radius: 12px;
    object-fit: cover;
    background: var(--surface-high);
}

@media (min-width: 720px) {
    .tl__pic {
        grid-column: 1 / -1;
    }
}

/* ---------------------------------------------------------------- the contact form */

.contact {
    display: grid;
    gap: 18px;
    margin-top: 28px;
    padding: 22px 20px 24px;
    border-radius: 28px;
    background: var(--surface);
}

.field {
    display: grid;
    gap: 6px;
}

.field label {
    font-weight: 700;
}

.field input,
.field textarea {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--outline);
    border-radius: var(--radius-small);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.field textarea {
    min-height: 9em;
    resize: vertical;
}

.field input:focus-visible,
.field textarea:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 0;
    border-color: var(--primary);
}

.field__help {
    color: var(--text-2);
    font-size: .9375rem;
}

.field--trap {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.contact__status:empty {
    display: none;
}

.contact__status {
    padding: 12px 16px;
    border-radius: var(--radius-small);
    background: var(--surface-high);
}

.contact__status--ok {
    background: var(--container);
    color: var(--on-container);
    font-weight: 700;
}

.contact__status--error {
    background: var(--error-container);
    color: var(--on-error-container);
    font-weight: 700;
}

.contact__send {
    justify-self: start;
}

.contact__send:disabled {
    opacity: .6;
}

.contact__note {
    margin-top: 20px;
    padding: 16px 18px;
    border-radius: var(--radius-small);
    background: var(--surface);
}

/* ---------------------------------------------------------------- the call to write (start page) */

.cta {
    position: relative;
    overflow: hidden;
    display: grid;
    justify-items: center;
    gap: 14px;
    margin-top: 56px;
    padding: 48px 24px;
    border-radius: 32px;
    background: var(--stage-bg);
    color: var(--stage-text);
    text-align: center;
}

.cta::before {
    content: "";
    position: absolute;
    inset: -40% 10% auto;
    height: 120%;
    background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 28%, transparent), transparent);
    pointer-events: none;
}

.cta > * {
    position: relative;
}

.cta h2 {
    font-family: var(--font-display);
    font-size: clamp(2rem, 7vw, 3rem);
    font-weight: 800;
}

.cta p {
    max-width: 34em;
    color: var(--stage-text-2);
}

.cta .btn--filled {
    background: var(--accent);
    color: var(--on-accent);
}

.footer__updated {
    margin-top: 4px;
    font-size: .875rem;
}

/* ---------------------------------------------------------------- footer and the bottom bar */

.footer {
    max-width: var(--max);
    margin: 24px auto 0;
    padding: 24px var(--gutter-r) 32px var(--gutter);
    color: var(--text-2);
    font-size: .9375rem;
    text-align: center;
}

.nav-bar {
    position: fixed;
    inset: auto 0 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding: 12px max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left));
    background: var(--surface-high);
}

.nav-bar__item {
    display: grid;
    justify-items: center;
    align-content: start;
    gap: 4px;
    color: var(--text-2);
    font-size: .75rem;
    font-weight: 700;
    text-decoration: none;
}

.nav-bar__pill {
    display: grid;
    place-items: center;
    width: 64px;
    height: 32px;
    border-radius: 999px;
}

.nav-bar__item[aria-current="page"] {
    color: var(--text);
}

.nav-bar__item[aria-current="page"] .nav-bar__pill {
    background: var(--container);
    color: var(--on-container);
}

@media (min-width: 900px) {
    body {
        padding-bottom: 0;
    }

    .nav-bar {
        display: none;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .btn,
    .chapters__link,
    .card-link,
    .player__button {
        transition: background-color .15s ease, transform .15s ease, filter .15s ease;
    }
}

/* ================================================================ motion
 * Only transform and opacity move, so it stays smooth on a phone. js/boot.js puts one class on <html>:
 *   .sda  CSS scroll-driven animations (animation-timeline: view() / scroll() / named view timelines);
 *   .io   the fallback: js/site.js gives .reveal and .zoom the class .is-in (IntersectionObserver) and sets --p (0..1)
 *         on [data-progress] (the hero, the statement, the timeline, the page head);
 *   .rm   reduced motion, and no class without JavaScript: nothing below applies, everything is shown at once.
 */

@keyframes rise {
    from { opacity: 0; transform: translateY(44px); }
    to { opacity: 1; transform: none; }
}

@keyframes enter {
    from { opacity: 0; transform: translateY(28px); }
    to { opacity: 1; transform: none; }
}

@keyframes enter-portrait {
    from { opacity: 0; transform: scale(1.08); }
    to { opacity: 1; transform: none; }
}

@keyframes hero-zoom {
    to { transform: translateY(9%) scale(1.18); }
}

@keyframes hero-text {
    to { opacity: 0; transform: translateY(-56px); }
}

@keyframes hero-light {
    to { opacity: .2; transform: translate(-14%, 22%) scale(1.35); }
}

@keyframes media-zoom {
    from { transform: scale(1.22) translateY(-3%); }
    to { transform: scale(1) translateY(3%); }
}

@keyframes word-on {
    from { opacity: .12; transform: translateY(.16em) scale(.94); }
    to { opacity: 1; transform: none; }
}

@keyframes line-scale {
    from { transform: scale(.88); }
    to { transform: scale(1.04); }
}

@keyframes grow {
    from { transform: scaleY(0); }
    to { transform: scaleY(1); }
}

@keyframes rail-in {
    from { opacity: .45; transform: scale(.9); }
    to { opacity: 1; transform: none; }
}

@keyframes cue {
    0% { opacity: 0; transform: translateY(0); }
    30% { opacity: 1; }
    100% { opacity: 0; transform: translateY(16px); }
}

html.sda,
html.io {
    scroll-behavior: smooth;
}

/* the hero comes in when the page opens (time, not scroll) */
html.sda .stage__portrait,
html.io .stage__portrait {
    animation: enter-portrait 1.2s cubic-bezier(.2, .7, .2, 1) both;
}

html.sda .stage__kicker,
html.sda .stage__name,
html.sda .stage__tag,
html.sda .stage .actions,
html.io .stage__kicker,
html.io .stage__name,
html.io .stage__tag,
html.io .stage .actions {
    animation: enter .9s cubic-bezier(.2, .7, .2, 1) both;
}

html.sda .stage__name,
html.io .stage__name {
    animation-delay: .1s;
}

html.sda .stage__tag,
html.io .stage__tag {
    animation-delay: .22s;
}

html.sda .stage .actions,
html.io .stage .actions {
    animation-delay: .34s;
}

html.sda .stage__scroll span,
html.io .stage__scroll span {
    animation: cue 1.8s ease-in-out infinite;
}

html.sda .statement,
html.io .statement {
    height: 210vh;
}

html.sda .statement__sticky,
html.io .statement__sticky {
    position: sticky;
    top: 0;
    min-height: 100vh;
    min-height: 100svh;
}

@media (min-width: 840px) {
    html.sda .statement,
    html.io .statement {
        height: 260vh;
    }
}

/* ---------------------------------------------------------------- with CSS scroll-driven animations */

html.sda .reveal,
html.sda .bullets.reveal > li {
    animation: rise linear both;
    animation-timeline: view();
    animation-range: entry 0% cover 26%;
}

html.sda .bullets.reveal {
    animation: none;
}

html.sda .stage__portrait img {
    animation: hero-zoom linear both;
    animation-timeline: scroll(root);
    animation-range: 0 100vh;
}

html.sda .stage__text {
    animation: hero-text linear both;
    animation-timeline: scroll(root);
    animation-range: 15vh 85vh;
}

html.sda .stage__light {
    animation: hero-light linear both;
    animation-timeline: scroll(root);
    animation-range: 0 100vh;
}

html.sda .statement {
    view-timeline-name: --statement;
}

html.sda .statement__line {
    animation: line-scale linear both;
    animation-timeline: --statement;
    animation-range: contain 0% contain 100%;
}

html.sda .w {
    animation: word-on linear both;
    animation-timeline: --statement;
}

html.sda .w1 { animation-range: contain 0% contain 15%; }
html.sda .w2 { animation-range: contain 15% contain 30%; }
html.sda .w3 { animation-range: contain 30% contain 45%; }
html.sda .w4 { animation-range: contain 45% contain 60%; }

html.sda .statement__sub {
    animation: rise linear both;
    animation-timeline: --statement;
    animation-range: contain 62% contain 78%;
}

html.sda .chapter__media img,
html.sda .banner img {
    animation: media-zoom linear both;
    animation-timeline: view();
    animation-range: cover 0% cover 100%;
}

html.sda .timeline {
    view-timeline-name: --timeline;
}

html.sda .timeline::after {
    animation: grow linear both;
    animation-timeline: --timeline;
    animation-range: entry 30% cover 75%;
}

html.sda .rail__item {
    animation: rail-in linear both;
    animation-timeline: view(inline);
    animation-range: entry 0% cover 45%;
}

/* ---------------------------------------------------------------- the fallback (IntersectionObserver and --p) */

html.io .reveal,
html.io .bullets.reveal > li {
    opacity: 0;
    transform: translateY(44px);
    transition: opacity .9s cubic-bezier(.2, .7, .2, 1), transform .9s cubic-bezier(.2, .7, .2, 1);
}

html.io .reveal.is-in,
html.io .bullets.reveal.is-in > li {
    opacity: 1;
    transform: none;
}

html.io .bullets.reveal {
    opacity: 1;
    transform: none;
}

html.io .bullets.reveal > li:nth-child(2),
html.io .stagger > .reveal:nth-child(2) { transition-delay: .07s; }
html.io .bullets.reveal > li:nth-child(3),
html.io .stagger > .reveal:nth-child(3) { transition-delay: .14s; }
html.io .bullets.reveal > li:nth-child(4),
html.io .stagger > .reveal:nth-child(4) { transition-delay: .21s; }
html.io .bullets.reveal > li:nth-child(n + 5),
html.io .stagger > .reveal:nth-child(n + 5) { transition-delay: .28s; }

html.io .stage__portrait img {
    transform: translateY(calc(var(--p, 0) * 9%)) scale(calc(1 + var(--p, 0) * .18));
}

html.io .stage__text {
    opacity: calc(1 - var(--p, 0) * 1.5);
    transform: translateY(calc(var(--p, 0) * -56px));
}

html.io .stage__light {
    opacity: calc(1 - var(--p, 0) * .8);
    transform: translate(calc(var(--p, 0) * -14%), calc(var(--p, 0) * 22%)) scale(calc(1 + var(--p, 0) * .35));
}

html.io .statement__line {
    transform: scale(calc(.88 + var(--p, 0) * .16));
}

html.io .w {
    --on: clamp(0, calc((var(--p, 0) - var(--from)) / .15), 1);
    opacity: calc(.12 + var(--on) * .88);
    transform: translateY(calc((1 - var(--on)) * .16em)) scale(calc(.94 + var(--on) * .06));
}

html.io .w1 { --from: 0; }
html.io .w2 { --from: .15; }
html.io .w3 { --from: .3; }
html.io .w4 { --from: .45; }

html.io .statement__sub {
    opacity: clamp(0, calc((var(--p, 0) - .62) / .16), 1);
}

html.io .chapter__media img,
html.io .banner img {
    transform: scale(1.18);
    transition: transform 1.6s cubic-bezier(.2, .7, .2, 1);
}

html.io .chapter__media.is-in img,
html.io .banner.is-in img {
    transform: none;
}

html.io .timeline::after {
    transform: scaleY(var(--p, 0));
}

/* Johan's own pictures: the focus point he set in the editor (lib/Images.php), in steps of 5 per cent. The CSP allows
 * no inline style, so these are classes; they come last so they win over each frame's own object-position. */
img.fp {
    object-position: var(--fx, 50%) var(--fy, 50%);
}

.fx-0 { --fx: 0%; }
.fx-5 { --fx: 5%; }
.fx-10 { --fx: 10%; }
.fx-15 { --fx: 15%; }
.fx-20 { --fx: 20%; }
.fx-25 { --fx: 25%; }
.fx-30 { --fx: 30%; }
.fx-35 { --fx: 35%; }
.fx-40 { --fx: 40%; }
.fx-45 { --fx: 45%; }
.fx-50 { --fx: 50%; }
.fx-55 { --fx: 55%; }
.fx-60 { --fx: 60%; }
.fx-65 { --fx: 65%; }
.fx-70 { --fx: 70%; }
.fx-75 { --fx: 75%; }
.fx-80 { --fx: 80%; }
.fx-85 { --fx: 85%; }
.fx-90 { --fx: 90%; }
.fx-95 { --fx: 95%; }
.fx-100 { --fx: 100%; }
.fy-0 { --fy: 0%; }
.fy-5 { --fy: 5%; }
.fy-10 { --fy: 10%; }
.fy-15 { --fy: 15%; }
.fy-20 { --fy: 20%; }
.fy-25 { --fy: 25%; }
.fy-30 { --fy: 30%; }
.fy-35 { --fy: 35%; }
.fy-40 { --fy: 40%; }
.fy-45 { --fy: 45%; }
.fy-50 { --fy: 50%; }
.fy-55 { --fy: 55%; }
.fy-60 { --fy: 60%; }
.fy-65 { --fy: 65%; }
.fy-70 { --fy: 70%; }
.fy-75 { --fy: 75%; }
.fy-80 { --fy: 80%; }
.fy-85 { --fy: 85%; }
.fy-90 { --fy: 90%; }
.fy-95 { --fy: 95%; }
.fy-100 { --fy: 100%; }
