@import url(reset.css);

/*-------------- GLOBALS --------------*/

:root {
    --columns: 8;
    --nav-height: 11px;                      /* height of the grey nav bar (taller on phones, see MOBILE) */
    --side: 11px;                            /* margin on the left and right edge of the page */
    --bg: #FFFFFF;
    --text: #000000;
    --nav-bg: #E6E6E6;
    --current: #ACACAC;
    --vh: 1vh;                               /* 1% of the screen height (becomes dvh below, see VISIBLE SCREEN HEIGHT) */
    --img-height: calc(40 * var(--vh));                      /* archive hover images, default height (was 25vh) */
    --dim: 0.35;                             /* opacity of hovered / selected images on selected projects */
}

@supports (height: 1dvh) {
    :root {
        --vh: 1dvh;
    }
}

/* archive page: inverted colours */
.archive {
    --bg: #000000;
    --text: #FFFFFF;
    --nav-bg: #676767;
    --current: #363636;

    /* light text on dark looks bolder on macOS, this thins it back out */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* colour schemes, switched with the dots top left (js/theme.js) */

/* dark */
:root[data-theme="dark"] {
    --bg: #000000;
    --text: #A4A4A4;
    --nav-bg: #2A2A2A;
    --current: #000000;

    /* light text on dark looks bolder on macOS, this thins it back out */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

:root[data-theme="dark"] .archive {
    --bg: #2A2A2A;                           /* background and nav bar swapped */
    --text: #A4A4A4;
    --nav-bg: #000000;
    --current: #3E3E3E;                      /* black would be invisible on the black bar */
}

/* neon */
:root[data-theme="neon"] {
    --bg: #E2DFDC;
    --text: #875B0F;
    --nav-bg: #CEFF10;
    --current: #C9BEAC;
}

:root[data-theme="neon"] .archive {
    --bg: #CEFF10;
    --text: #875B0F;
    --nav-bg: #E2DFDC;
    --current: #C9BEAC;
}

/* kobai: calm, warm version of turquoise green 白緑, vandyke red 紅海老茶 and spinel red 紅梅色 */
:root[data-theme="kobai"] {
    --bg: #D5DACC;                           /* sage linen: muted, warm green */
    --text: #541913;                         /* vandyke red */
    --nav-bg: #541913;
    --nav-text: #B79E8C;                     /* warm clay: darker + warmer than the background, 5.4:1 on the bar */
    --current: #C46A76;                      /* softened spinel red */
}

:root[data-theme="kobai"] .archive {
    --bg: #541913;                           /* background and nav bar swapped */
    --text: #F7F0E6;
    --nav-bg: #D5DACC;
    --nav-text: #541913;
    --current: #C46A76;
}

body {
    margin: 0;
    min-height: calc(100 * var(--vh));       /* the visible screen height (the reset's 100vh is too tall on phones) */
    background-color: var(--bg);
    color: var(--text);
    transition: background-color 300ms ease, color 300ms ease;   /* soft change of colour scheme */
    font-family: "Times New Roman", Times, serif;
    font-size: 16px;
}

/* smooth crossfade between pages */
@view-transition {
    navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 300ms;               /* same timing as the link hover */
    animation-timing-function: ease;
}

/* arriving on the archive AND leaving it: slower, softer fade (also for the nav bar colour).
   html.from-archive = the page you go to after the archive (set in js/theme.js) */
html:has(body.archive)::view-transition-group(*),
html:has(body.archive)::view-transition-old(*),
html:has(body.archive)::view-transition-new(*),
html.from-archive::view-transition-group(*),
html.from-archive::view-transition-old(*),
html.from-archive::view-transition-new(*) {
    animation-duration: 500ms;
    animation-timing-function: ease-in-out;  /* starts and ends gently */
}

/* leaving the archive: its text is its own part of the page change, so it can fade out quickly
   (and sink slightly) AT THE SAME TIME as the background fades */
.archive .projects {
    view-transition-name: archive-text;
}

@keyframes archive-text-out {
    to {
        opacity: 0;
        transform: translateY(4px);
    }
}

html.from-archive::view-transition-old(archive-text) {
    animation: archive-text-out 200ms cubic-bezier(0.55, 0.085, 0.68, 0.53) both;
}

.main-nav {
    position: fixed;
    top: 50%;
    left: 0;
    width: 100%;
    transform: translateY(-50%);
    z-index: 1000;
    view-transition-name: main-nav;          /* nav stays still, only the content fades */
}

.main-nav__list {
    display: grid;
    grid-template-columns: repeat(var(--columns), 1fr);
    grid-template-rows: var(--nav-height);
    align-items: end;
    column-gap: 11px;
    line-height: 1;
    margin: 0;
    padding: 0 var(--side);
    list-style: none;
    color: var(--nav-text, var(--text));     /* nav text: its own colour if the scheme sets --nav-text, otherwise the page text */
    background-color: var(--nav-bg);
    transition: background-color 300ms ease, color 300ms ease;
}

/* colour scheme dots, top left (under the fullscreen view, above everything else).
   only the two dots named in <html data-dot1 / data-dot2> are shown, in that order (set in js/theme.js) */
.theme-dots {
    position: fixed;
    top: 11px;                               /* same 11px gutter as the rest of the page */
    left: var(--side);
    z-index: 1500;
    display: flex;
    gap: 5.5px;
}

.theme-dot {
    width: 16.5px;                           /* 1.5 × 11px */
    height: 16.5px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    overflow: hidden;                        /* the hover half (::after) only shows inside the circle */
    transition: background-color 300ms ease;
}

/* hover: the second colour of the scheme slides in diagonally from the bottom right,
   until the dot is split along its diagonal (--dot-second, set per dot below) */
.theme-dot::after {
    content: "";
    position: absolute;
    inset: 0;
    background-color: var(--dot-second);
    clip-path: polygon(100% 0, 100% 100%, 0 100%);   /* the bottom-right half */
    transform: translate(40%, 40%);                  /* waiting just outside the circle */
    transition: transform 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.theme-dot {
    display: none;
}

:root[data-dot1="default"] .theme-dot[data-set-theme="default"],
:root[data-dot1="dark"] .theme-dot[data-set-theme="dark"],
:root[data-dot1="neon"] .theme-dot[data-set-theme="neon"],
:root[data-dot1="kobai"] .theme-dot[data-set-theme="kobai"] {
    display: block;
    order: 1;
}

:root[data-dot2="default"] .theme-dot[data-set-theme="default"],
:root[data-dot2="dark"] .theme-dot[data-set-theme="dark"],
:root[data-dot2="neon"] .theme-dot[data-set-theme="neon"],
:root[data-dot2="kobai"] .theme-dot[data-set-theme="kobai"] {
    display: block;
    order: 2;
}

:root[data-dot3="default"] .theme-dot[data-set-theme="default"],
:root[data-dot3="dark"] .theme-dot[data-set-theme="dark"],
:root[data-dot3="neon"] .theme-dot[data-set-theme="neon"],
:root[data-dot3="kobai"] .theme-dot[data-set-theme="kobai"] {
    display: block;
    order: 3;
}

.theme-dot[data-set-theme="default"] {
    --dot-second: #E6E6E6;                   /* the grey of the default nav bar */
    background-color: #FFFFFF;
}

/* thin ring around the white and the black dot, so they stay visible on white / black backgrounds.
   it's its own layer ABOVE the sliding hover half, so the hover colour stays inside the ring */
.theme-dot[data-set-theme="default"]::before,
.theme-dot[data-set-theme="dark"]::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px var(--text);
    transition: box-shadow 300ms ease;
}

.theme-dot[data-set-theme="dark"] {
    --dot-second: #2A2A2A;                   /* the grey of the dark archive */
    background-color: #000000;
}

.theme-dot[data-set-theme="neon"] {
    --dot-second: #E2DFDC;                   /* the background of the neon scheme */
    background-color: #CEFF10;
}

.theme-dot[data-set-theme="kobai"] {
    --dot-second: #D5DACC;                   /* the sage linen background */
    background-color: #C46A76;
}

@media (hover: hover) {
    .theme-dot:hover::after {
        transform: none;
    }
}

/* on the neon archive the background is neon itself, so the neon dot takes the nav colour
   (and its hover half is neon instead) */
:root[data-theme="neon"] .archive .theme-dot[data-set-theme="neon"] {
    --dot-second: #CEFF10;
    background-color: var(--nav-bg);
}

.main-nav__item {
    text-box: trim-both cap alphabetic;
    min-width: 0;                            /* long content (the breadcrumb) runs into the next columns instead of widening its own */
}

/* BREADCRUMB (selected projects, built in js/main.js): while a project is open the nav shows
   "selected projects / project name". the name is highlighted (= where you are),
   "selected projects" goes back to the normal colour (= a link back to the strip) */
.main-nav__crumb {
    white-space: nowrap;
    color: var(--current);
    opacity: 0;
    pointer-events: none;
    transition: opacity 300ms ease;
}

.project-open .main-nav__crumb {
    opacity: 1;
}

.project-open .main-nav__link[aria-current="page"] {
    color: var(--nav-text, var(--text));
}

.main-nav__back {
    display: none;                           /* the ← is only used on phones (see MOBILE) */
}

/* smooth colour fade, both on hover and when the mouse leaves */
.main-nav__link {
    white-space: nowrap;                     /* a link (and its arrow) never breaks onto two lines */
    transition: color 300ms ease;
}

/* link of the page you're currently on + link colour on hover (hover only with a mouse, on touch screens it would "stick") */
.main-nav__link[aria-current="page"] {
    color: var(--current);
}

@media (hover: hover) {
    .main-nav__link:hover,
    .project-open .main-nav__link[aria-current="page"]:hover {
        color: var(--current);
    }
}

/* diagonal arrow after external links (e.g. instagram) */
/* drawn as a tiny svg instead of the ↗ character: fonts (and emoji) differ from device to device,
   the drawing looks the same everywhere and takes the link colour (currentColor) */
.main-nav__link[href^="http"]::after {
    content: "";
    display: inline-block;
    width: 0.6em;
    height: 0.6em;
    margin-left: 3px;
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M1 9L9 1M3 1H9V7' fill='none' stroke='black' stroke-width='1.1'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M1 9L9 1M3 1H9V7' fill='none' stroke='black' stroke-width='1.1'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* last item (archive) sits in the last column, right-aligned */
.main-nav__item:last-child {
    grid-column: -2;
    justify-self: end;
}




/*-------------- ABOUT--------------*/
/* about + archive content: fixed in the lower half, 11px below the nav (same gap as the image strip above it).
   the page itself never scrolls. only if the content is taller than the lower half (small phones)
   it scrolls inside this area */
.about,
.projects {
    position: fixed;
    top: calc(50 * var(--vh) + var(--nav-height) / 2 + 11px);   /* 11px below the nav */
    bottom: 11px;
    left: 0;
    right: 0;
    display: grid;
    grid-template-columns: repeat(var(--columns), 1fr);   /* same grid as the nav */
    align-content: start;
    column-gap: 11px;
    padding: 0 var(--side);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
}

.about::-webkit-scrollbar,
.projects::-webkit-scrollbar {
    display: none;
}

.about {
    line-height: 1.2;
}

.about__intro {
    grid-column: 1 / 4;                      /* columns 1–3 */
}

.cv {
    grid-column: 1 / 4;
    display: grid;
    grid-template-columns: subgrid;          /* reuse the page's columns inside the cv */
    margin-top: 1lh;                         /* one empty line above */
}

.cv__title {
    grid-column: 1;
    font: inherit;                           /* h2 looks like normal text */
}

.cv__list {
    grid-column: 2 / 4;                      /* columns 2–3 */
    list-style: none;
}

.cv__item {
    display: flex;
    justify-content: space-between;          /* text left, year right */
    gap: 11px;
}

.cv__item span:last-child {
    white-space: nowrap;                     /* the year ("since 2025") always stays on one line */
}


/*-------------- ARCHIVE --------------*/
.projects {
    line-height: 1.5;                        /* row spacing */
}

.projects__list,
.projects__item {
    grid-column: 1 / -1;                     /* full width */
    display: grid;
    grid-template-columns: subgrid;          /* every row uses the page's 8 columns */
    list-style: none;
}

/* the 4 spans of each project, placed in their columns */
.projects__item span:nth-child(1) { grid-column: 1 / 3; }              /* title: columns 1–2 */
.projects__item span:nth-child(2) { grid-column: 3; }                  /* type: under @charoquinn */
.projects__item span:nth-child(3) { grid-column: 4 / 6; }              /* where: under selected projects */
.projects__item span:nth-child(4) { grid-column: -2; justify-self: end; } /* year: last column, right */

/* project images: hidden, shown above the nav when hovering the project row */
.projects__images {
    position: fixed;
    left: var(--side);
    bottom: calc(50 * var(--vh) + var(--nav-height) / 2 + 11px);       /* middle of screen + half the nav bar + 11px space */
    height: var(--img-height);               /* set in :root, can be overridden per project */
    display: flex;
    gap: 11px;
    align-items: center;                     /* images of different heights are centred vertically */
    opacity: 0;
    pointer-events: none;                    /* images never block the mouse */
    transition: opacity 300ms ease;
}

.projects__images img,
.projects__images video {
    height: 100%;
    width: auto;                             /* keeps the image proportions */
}

/* show a project's images: hover with a mouse, tap on touch screens (.is-open, set in js/main.js) */
@media (hover: hover) {
    .projects__item:hover .projects__images {
        opacity: 1;
    }
}

.projects__item.is-open .projects__images {
    opacity: 1;
}

/* wider spacing, e.g. for the pictograms */
.projects__images--wide {
    gap: 44px;                               /* 4 × 11px */
}


/*-------------- SELECTED PROJECTS --------------*/
/* endless, side-scrollable image strip above the nav (behaviour in js/main.js) */
.strip {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(50 * var(--vh) + var(--nav-height) / 2 + 11px);       /* 11px above the nav */
    height: calc(25 * var(--vh));                            /* tallest image = half of the upper half */
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;                   /* hide scrollbar (Firefox) */
    opacity: 0;                              /* hidden until the sizes are calculated */
    transition: opacity 300ms ease;
}

.strip::-webkit-scrollbar {
    display: none;                           /* hide scrollbar (Chrome, Safari) */
}

.strip.is-ready {
    opacity: 1;
}

.strip__track {
    display: flex;
    align-items: flex-end;                   /* all images sit on the same bottom line */
    width: max-content;
    height: 100%;
}

.strip__img {
    display: block;
    height: 100%;                            /* overwritten per image by js/main.js */
    width: auto;
    max-width: none;
    transition: opacity 300ms ease;          /* same timing as the link hover */
}

/* RISING / SINKING IMAGES
   rise-in: the images slide up out of the nav bar and fade in, one after another (--i = position, set in js/main.js)
   sink-out: when leaving they slide back down and fade out (shorter, so leaving doesn't feel slow;
             SINK in js/main.js = how long the page waits for it)
   the strip cuts off everything below its lower edge, so they appear to come out of / go into the bar */
/* every image moves the same short distance (not its own height), so tall and low images move at the same speed */
@keyframes rise-in {
    from {
        transform: translateY(32px);
        opacity: 0;
    }
}

@keyframes sink-out {
    to {
        transform: translateY(32px);
        opacity: 0;
    }
}

.strip.is-risen .strip__img {
    animation: rise-in 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94) backwards;
    animation-delay: calc(var(--i, 0) * 25ms);
}

.strip.is-sinking .strip__img {
    animation: sink-out 250ms cubic-bezier(0.55, 0.085, 0.68, 0.53) forwards;
    animation-delay: calc(min(var(--i, 0), 8) * 12ms);
}

@media (hover: hover) {
    .strip__img:hover {
        opacity: var(--dim);
    }
}

.strip__img {
    cursor: pointer;
}

/* a project is open: the strip fades out */
.project-open .strip {
    opacity: 0;
    pointer-events: none;
}

/* ---- opened project ---- */
.project-view {
    opacity: 0;
    visibility: hidden;
    transition: opacity 300ms ease, visibility 0s 300ms;   /* hide completely after fading out */
}

.project-open .project-view {
    opacity: 1;
    visibility: visible;
    transition: opacity 300ms ease;
}

/* upper half: all images of the project, same sizing as the strip */
.project-view__strip {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(50 * var(--vh) + var(--nav-height) / 2 + 11px);       /* 11px above the nav */
    height: calc(25 * var(--vh));
    display: flex;
    align-items: flex-end;
    gap: 11px;
    padding: 0 var(--side);
    overflow-x: auto;                        /* side-scrollable if a project has many images */
    overflow-y: hidden;
    scrollbar-width: none;
}

.project-view__strip::-webkit-scrollbar {
    display: none;
}

.project-view__thumb {
    flex-shrink: 0;
    display: block;
    height: 0;                               /* real height is set by js/main.js once the file is loaded */
    width: auto;
    max-width: none;
    cursor: pointer;
    opacity: 0;                              /* hidden until loaded */
    transition: opacity 300ms ease;
}

.project-view__thumb.is-sized {
    opacity: 1;
    animation: rise-in 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94) backwards;   /* rises up once loaded, like the main strip */
    animation-delay: calc(var(--i, 0) * 25ms);
}

.project-view__thumb.is-selected {
    opacity: var(--dim);
}

@media (hover: hover) {
    .project-view__thumb:hover {
        opacity: var(--dim);
    }
}

/* closing a project: its thumbnails sink back into the nav bar, the lower half fades out */
.project-view.is-closing .project-view__thumb {
    animation: sink-out 250ms cubic-bezier(0.55, 0.085, 0.68, 0.53) forwards;
    animation-delay: calc(min(var(--i, 0), 8) * 12ms);
}

.project-view.is-closing .project-view__detail {
    opacity: 0;
    transition: opacity 300ms ease;
}

/* lower half: big image (columns 1–3) + text (columns 4–5) */
.project-view__detail {
    position: fixed;
    top: calc(50 * var(--vh) + var(--nav-height) / 2 + 11px);          /* 11px below the nav */
    bottom: 11px;
    left: 0;
    right: 0;
    display: grid;
    grid-template-columns: repeat(var(--columns), 1fr);
    grid-template-rows: minmax(0, 1fr);
    column-gap: 11px;
    padding: 0 var(--side);
    line-height: 1.2;
}

.project-view__stage {
    grid-column: 1 / 4;
    min-height: 0;
    position: relative;                      /* old + new image lie on top of each other while cross-fading */
}

.project-view__big {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;                         /* as big as possible inside columns 1–3 ... */
    max-height: 100%;                        /* ... and inside the lower half, proportions kept */
    opacity: 0;
    transition: opacity 200ms ease-in-out;   /* cross-fade between images (same as FADE in js/main.js) */
}

/* parts of the old image that stick out beside a narrower new one fade away faster */
.project-view__big.is-leaving,
.lightbox__img.is-leaving {
    transition-duration: 100ms;
}

.project-view__big.is-visible {
    opacity: 1;
}

.project-view__text {
    grid-column: 4 / 6;
}

.project-view__text p + p {
    margin-top: 1lh;                         /* one empty line between paragraphs */
}

/* label + list of names next to it, e.g. "Mentored by:" */
.credits {
    display: grid;
    grid-template-columns: max-content 1fr;  /* column 1 = as wide as the label, column 2 = the names */
    column-gap: 0.25em;                      /* about one space between label and names */
}

.credits dd {
    grid-column: 2;                          /* every name goes into the second column, one per line */
    margin: 0;
}

.credits + p {
    margin-top: 1lh;                         /* one empty line after the names */
}

.project-view__stage {
    cursor: zoom-in;                         /* click the big image -> fullscreen */
}

/* ---- fullscreen (lightbox) ---- */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;                           /* above the nav */
    background-color: color-mix(in srgb, var(--bg) 85%, transparent);   /* page shines through slightly */
    opacity: 0;
    visibility: hidden;
    transition: opacity 300ms ease, visibility 0s 300ms;
}

.lightbox-open .lightbox {
    opacity: 1;
    visibility: visible;
    transition: opacity 300ms ease;
}

.lightbox__stage {
    position: absolute;
    inset: 33px;                             /* 3 × 11px space to the screen edges */
}

.lightbox__img {
    position: absolute;
    inset: 0;
    margin: auto;                            /* centred */
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;                         /* as big as possible, proportions kept */
    max-height: 100%;
    opacity: 0;
    transition: opacity 200ms ease-in-out;
}

.lightbox__img.is-visible {
    opacity: 1;
}



/* TEXT FADE (archive + about): the text fades in and rises slightly when the page opens, one line / block
   after another (--i = order, set in js/main.js), and fades out quickly when leaving.
   in the archive the spans move, not the row itself, so the hover images aren't affected */
@keyframes text-in {
    from {
        transform: translateY(8px);
        opacity: 0;
    }
}

.projects__item > span,
.about__intro,
.cv__title,
.cv__item {
    animation: text-in 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94) backwards;
    animation-delay: calc(var(--i, 0) * 40ms);
}

/* leaving: quick and subtle (250 in js/main.js = how long the page waits) */
@keyframes text-out {
    to {
        transform: translateY(4px);
        opacity: 0;
    }
}

.about.is-leaving .about__intro,
.about.is-leaving .cv__title,
.about.is-leaving .cv__item {
    animation: text-out 150ms cubic-bezier(0.55, 0.085, 0.68, 0.53) forwards;
    animation-delay: calc(min(var(--i, 0), 8) * 12ms);
}

/* trim edges: a video with data-trim-edges loses a thin edge all around (e.g. a black outline that slipped into
   the export). in percent, so it works at every size: strip preview, big view, fullscreen. raise it if the line still shows */
video[data-trim-edges] {
    clip-path: inset(0.6%);
}

/* people who turned on "reduce motion" in their system settings: no sliding, everything just appears */
@media (prefers-reduced-motion: reduce) {
    .strip__img,
    .project-view__thumb,
    .projects__item > span,
    .about__intro,
    .cv__title,
    .cv__item {
        animation: none !important;
    }
}



/*-------------- MOBILE --------------*/
/* everything for phones is in this block (screens up to 700px wide).
   to undo the mobile version: delete this block, desktop stays exactly the same */
@media (max-width: 700px) {

    :root {
        --columns: 4;                        /* half the desktop grid, same 11px gutter */
        --side: 4px;                       /* narrower page margin on phones */
    }

    /* ---- nav: two rows ----
       row 1: the pages          chika lutz | selected projects | archive
       row 2: contact            @charoquinn↗ | email                        */
    :root {
        --nav-height: 27.5px;                /* two 11px rows + 5.5px between them */
    }

    .main-nav__list {
        grid-template-columns: 1fr auto 1fr;
        grid-template-rows: 11px 11px;
        row-gap: 5.5px;
    }

    .main-nav__item:nth-child(1) { grid-area: 1 / 1; justify-self: start; }   /* chika lutz */
    .main-nav__item:nth-child(4) { grid-area: 1 / 2; justify-self: center; }  /* selected projects */
    .main-nav__item:nth-child(5) { grid-area: 1 / 3; justify-self: end; }    /* archive */
    .main-nav__item:nth-child(3) { grid-area: 2 / 1; justify-self: start; }   /* @charoquinn */
    .main-nav__item:nth-child(2) { grid-area: 2 / 2 / 3 / 4; justify-self: end; }   /* email */

    /* breadcrumb on phones: the middle slot becomes "← project name" while a project is open */
    .main-nav__crumb {
        display: none;
    }

    .project-open .main-nav__crumb {
        display: inline;
        pointer-events: auto;                /* the whole "← name" can be tapped to go back */
        cursor: pointer;
    }

    .main-nav__crumb-sep,
    .project-open .main-nav__label {
        display: none;
    }

    .project-open .main-nav__back {
        display: inline-block;
        width: 0.7em;
        height: 0.6em;
        margin-right: 4px;
        background-color: currentColor;
        -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M9.5 5H1M4.5 1.5L1 5L4.5 8.5' fill='none' stroke='black' stroke-width='1.1'/%3E%3C/svg%3E") center / contain no-repeat;
        mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M9.5 5H1M4.5 1.5L1 5L4.5 8.5' fill='none' stroke='black' stroke-width='1.1'/%3E%3C/svg%3E") center / contain no-repeat;
    }

    /* ---- about ---- */
    .about__intro {
        grid-column: 1 / -1;                 /* full width */
    }

    .cv {
        grid-column: 1 / -1;
    }

    .cv__list {
        grid-column: 2 / -1;                 /* columns 2–4, the label stays in column 1 */
    }

    /* ---- archive ---- */
    /* list: only title | year on phones (type + where are hidden) */
    .projects__item span:nth-child(1) { grid-column: 1 / 4; }
    .projects__item span:nth-child(4) { grid-column: 4; justify-self: end; }
    .projects__item span:nth-child(2),
    .projects__item span:nth-child(3) { display: none; }

    .projects__item {
        cursor: pointer;                     /* tapping a row still shows its images */
    }

    /* tapped project: images above the nav, swipeable sideways if wider than the screen */
    .projects__images {
        left: 0;                             /* full bleed: the images slide all the way to the screen edges ... */
        right: 0;
        height: calc(25 * var(--vh));                        /* one height for all projects on phones */
        padding: 0 var(--side);              /* ... but start and end aligned with the page margin */
        overflow-x: auto;
        scrollbar-width: none;
    }

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

    .projects__images img,
    .projects__images video {
        flex-shrink: 0;
    }

    .projects__item.is-open .projects__images {
        pointer-events: auto;                /* so the images can be swiped */
    }

    /* ---- selected projects: opened project ---- */
    /* lower half: big image full width, text underneath, scrolls if the text is long */
    .project-view__detail {
        grid-template-rows: none;
        grid-auto-rows: max-content;         /* every row exactly as tall as its content (text never slides under the image) */
        align-content: start;
        row-gap: 11px;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: none;
    }

    .project-view__detail::-webkit-scrollbar {
        display: none;
    }

    /* big image: as big as possible — full width for landscape images, portrait images at most as tall
       as the lower half (always completely visible). the text follows below, the lower half scrolls.
       old + new image lie in the same grid cell while cross-fading */
    .project-view__stage {
        grid-column: 1 / -1;
        display: grid;
        min-height: auto;
    }

    .project-view__big {
        position: static;
        grid-area: 1 / 1;
        width: auto;
        max-width: 100%;
        max-height: calc(50 * var(--vh) - var(--nav-height) / 2 - 22px);   /* height of the lower half */
    }

    .project-view__text {
        grid-column: 1 / -1;
    }

    /* fullscreen: less margin, bigger images */
    .lightbox__stage {
        inset: 11px;
    }
}
