/* SPACE BETWEEN THE NAV TITLES: half the gap on each side of every title.
   12px -> 24px between the boxes. Change this one number to move them closer / further apart. */
:root{
    --nav-gap: 12px;
}

.nav{
    position: fixed;
    top: 15px;
    left: 0;
    right: 0;                   /* full width, so the middle column can sit in the centre */
    z-index: 10;                /* keeps the nav above the video */
    mix-blend-mode: difference; /* blends the whole nav with the video behind it */
    transform: translateZ(0);   /* own layer: phones (iOS) otherwise often don't blend over videos / filtered pictures */

    /* 3 columns: HOME | PROJECTS (or the project title) | ABOUT
       The two outer columns are always equally wide (1fr each), so the middle
       word is always in the centre of the screen. When it gets longer or shorter,
       HOME and ABOUT both move out / in by half the difference. */
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: start;
    pointer-events: none;       /* the empty part of the nav doesn't block clicks ... */
}
.nav > *{
    pointer-events: auto;       /* ... but the titles themselves stay clickable */
}
.nav > a:first-child{
    justify-self: end;          /* HOME sits at the right end of the first column */
}
.nav > a:last-of-type{
    justify-self: start;        /* ABOUT sits at the left end of the last column */
}

.nav a,
.dropdown summary{
color: white;                   /* white + difference = inverted colour of the background */
text-decoration: none;
font-size: 13px;
margin: 0 var(--nav-gap);
font-family: Helvetica, sans-serif;
padding: 2px 4px;               /* on EVERY link, not only the active one,
                                   so the titles never shift when the box moves */
display: inline-block;
line-height: 15px;              /* text height 15px + padding 2px above and below
                                   = every black box is exactly 19px tall */
}

/* the page you are on right now: box behind the link.
   Written as white box + black text, because the nav uses "difference":
   on a white page that turns into a BLACK box with WHITE text,
   and over the video/images it inverts like the rest of the nav. */
.nav .active{
    background: white;
    color: black;
}

/* ---------- INDEX DROPDOWN ---------- */
/* <details> opens and closes by itself when you click <summary> (INDEX).
   All lines are white: the nav's "difference" turns them black on white pages. */

.dropdown{
    display: inline-block;
    position: relative;         /* the list below is placed relative to INDEX */
    margin: 0 var(--nav-gap);   /* same spacing as the other titles */
}

.dropdown summary{
    display: inline-block;
    margin: 0;                  /* the dropdown itself is not spaced again */
    cursor: pointer;
    list-style: none;           /* removes the little triangle */
    vertical-align: top;        /* same height as HOME and ABOUT (no 1px drop) */
}
.dropdown summary::-webkit-details-marker{ display: none; } /* triangle in Safari */

/* ---------- PROJECT TITLE REPLACES INDEX ---------- */
/* On a project page the summary holds two words stacked on top of each other:
   the project title glitches in where INDEX was, INDEX glitches out (see TITLE GLITCH below).
   (Only plays when you open the project page directly, e.g. from an image on HOME.
   Coming from the dropdown, the title already flew there - see js/nav.js.) */

.swap{
    display: inline-grid;       /* both words in the same grid cell = on top of each other */
    vertical-align: top;
    justify-items: start;       /* each word keeps its own width, so js/nav.js can measure it */
}

/* the box around INDEX / the project title changes width smoothly
   (js/nav.js sets the width to whichever word is showing) */
.dropdown summary{
    white-space: nowrap;
    overflow: hidden;           /* the words only show inside the box - sliding in/out
                                   or a longer word while the box grows is cut off at its edge */
    transition: width 0.4s cubic-bezier(0.65, 0, 0.35, 1);
}
.swap > span{
    grid-area: 1 / 1;           /* same cell for both */
}

/* TITLE GLITCH: the words don't slide any more - they swap in place with a glitch
   (like the PREVIOUS / NEXT cursor): flicker, jump sideways, cut into slices.
   js/title-glitch.js scrambles the letters at the same time, from the middle of the word outwards.
   Every title change below uses these two. */
@keyframes title-glitch-in{
    0%  { opacity: 0; transform: none; }
    20% { opacity: 1;   translate: 4px 0;  clip-path: inset(0 0 55% 0); }
    35% { opacity: 0; }
    50% { opacity: 1;   translate: -3px 0; clip-path: inset(45% 0 0 0); }
    65% { opacity: 0.4; translate: 2px 0;  clip-path: inset(20% 0 30% 0); }
    80% { opacity: 1;   translate: -1px 0; clip-path: none; }
    100%{ opacity: 1; transform: none; translate: 0; clip-path: none; }
}
@keyframes title-glitch-out{
    0%  { opacity: 1; transform: none; }
    15% { translate: -4px 0; clip-path: inset(50% 0 0 0); }
    30% { opacity: 0; }
    45% { opacity: 1;   translate: 3px 0;  clip-path: inset(0 0 40% 0); }
    60% { opacity: 0.3; translate: -2px 0; clip-path: inset(30% 0 20% 0); }
    75% { opacity: 1;   translate: 1px 0;  clip-path: none; }
    90% { opacity: 0; }
    100%{ opacity: 0; transform: none; translate: 0; clip-path: none; }
}

.swap-old{
    animation: title-glitch-out 0.5s steps(1) 0.3s both;
}
.swap-new{
    animation: title-glitch-in 0.5s steps(1) 0.3s both;
}

/* title is in place (arrived from the dropdown, or the first animation is done):
   no animation, INDEX is hidden, the title sits in the box */
.arrived .swap-old{ animation: none; opacity: 0; }
.arrived .swap-new{ animation: none; }

/* DROPDOWN OPENS on a project page: INDEX glitches back in, the title glitches out */
.dropdown[open] .swap-old{
    animation: title-glitch-in 0.4s steps(1) both;
}
.dropdown[open] .swap-new{
    animation: title-glitch-out 0.4s steps(1) both;
}

/* DROPDOWN CLOSES: the title glitches back in, INDEX glitches out again */
.dropdown.closing[open] .swap-old{
    animation: title-glitch-out 0.4s steps(1) 0.2s both;
}
.dropdown.closing[open] .swap-new{
    animation: title-glitch-in 0.4s steps(1) 0.2s both;
}

/* a project was just chosen (js/nav.js): for one moment everything holds still -
   INDEX in the box, the chosen title waiting hidden.
   Right after, "closing" plays the swap above with the new title. */
.dropdown.choosing[open] .swap-old{
    animation: none;
    opacity: 1;
}
.dropdown.choosing[open] .swap-new{
    animation: none;
    opacity: 0;
}

/* INDEX gets the box while the dropdown is open */
.dropdown[open] summary{
    background: white;          /* black on white pages because of "difference" */
    color: black;
}

/* ...and it's the ONLY box: the current page's title (e.g. ABOUT) loses its box
   while the dropdown is open, and gets it back when the dropdown closes.
   "picked" = a project was chosen: then it doesn't come back, the project page opens. */
.nav:has(.dropdown[open]:not(.closing)) > a.active,
.nav:has(.dropdown.picked) > a.active{
    background: none;
    color: white;
}
/* ...and loses it again when the dropdown closes (not on project pages: the title keeps it) */
.dropdown.closing[open] summary:not(.active){
    background: none;
    color: white;
}

/* the list: starts at the middle of INDEX, then the items sit further down */
.dropdown-list{
    position: absolute;
    top: 50%;                   /* vertical line starts at the middle of INDEX */
    left: -12px;                /* line sits a little left of INDEX */
    margin: 0;
    padding: 130px 0 0 0;       /* distance from INDEX down to the first project */
    list-style: none;
    white-space: nowrap;        /* long titles stay on one line */
    pointer-events: none;       /* the empty part of the list lies over PROJECTS -
                                   let clicks through, so PROJECTS can close it again */
}

/* the vertical line: from INDEX down to the middle of the last project */
.dropdown-list::before{
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 1px;
    height: calc(100% - 10px);  /* stops at the middle of the last line (20px / 2) */
    background: white;
}

/* the short line from the vertical line to INDEX */
.dropdown-list::after{
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 12px;
    height: 1px;
    background: white;
}

/* each project */
.dropdown-list li{
    pointer-events: auto;       /* ...but the projects themselves stay clickable */
    position: relative;
    padding-left: 28px;         /* room for its little line */
    line-height: 20px;          /* distance between the projects */
}

/* the short line in front of each project */
.dropdown-list li::before{
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 22px;
    height: 1px;
    background: white;
}

/* project links: no extra spacing like the main titles */
.nav .dropdown-list a{
    margin: 0;
    padding: 0;
    display: inline-block;      /* needed so the link can fly up when it's chosen */
    line-height: 15px;          /* same text height as the nav, so its box is 19px tall too
                                   (the space between projects comes from the li: 20px) */
}

/* the year next to each project (not part of the link, so it never becomes the page title) */
.dropdown-list .year{
    margin-left: 6px;
    color: white;               /* like the titles (turned black on light pages by "difference") */
    font-family: Helvetica, sans-serif;
    font-size: 13px;
    line-height: 15px;          /* same as the titles, so the rows keep their spacing */
    cursor: pointer;            /* clickable like the title (js/nav.js passes the click on) */
}
/* a project was clicked and flies up as the new title: its year disappears */
.dropdown-list li.selected .year{
    visibility: hidden;
}

/* the chosen project: same box as the current page in the nav */
.nav .dropdown-list li.selected a{
    background: white;          /* black on white pages because of "difference" */
    color: black;
    padding: 2px 4px;
    margin-left: -4px;          /* the box grows around the text, the text stays put */
}

/* ---------- DROPDOWN ANIMATION ---------- */
/* Plays every time the dropdown opens, in this order:
   1. short line grows out towards INDEX
   2. vertical line grows downwards
   3. each project's line grows out, then its name fades in - one after the other */

@keyframes grow-x{
    from{ transform: scaleX(0); }
    to  { transform: scaleX(1); }
}
@keyframes grow-y{
    from{ transform: scaleY(0); }
    to  { transform: scaleY(1); }
}
/* FLICKERY: names flicker on (on / 20% / on ...) instead of fading,
   lines grow in jumps instead of smoothly (steps(...) = number of jumps) */
@keyframes name-flicker-in{
    0%   { opacity: 0; }
    20%  { opacity: 1; }
    40%  { opacity: 0.2; }
    60%  { opacity: 1; }
    75%  { opacity: 0.2; }
    88%, 100% { opacity: 1; }   /* fully on for a moment before it ends */
}

/* 1. short line into INDEX */
.dropdown[open] .dropdown-list::after{
    transform-origin: left;     /* grows from the vertical line towards INDEX */
    animation: grow-x 0.15s steps(2) both;
}

/* 2. vertical line */
.dropdown[open] .dropdown-list::before{
    transform-origin: top;      /* grows from INDEX downwards */
    animation: grow-y 0.5s steps(6) 0.1s both;
}

/* 3. each project: its line, then its name */
.dropdown[open] .dropdown-list li::before{
    transform-origin: left;
    animation: grow-x 0.2s steps(3) var(--delay) both;
}
.dropdown[open] .dropdown-list li a,
.dropdown[open] .dropdown-list li .year{
    animation: name-flicker-in 0.3s steps(1) calc(var(--delay) + 0.1s) both;
}
/* hovering a project makes it flicker.
   The flicker-in is listed again (unchanged) so the browser doesn't restart it when the
   mouse leaves - otherwise the name would vanish for the length of its delay. */
/* hovering the title OR its year: both flicker together */
.dropdown[open] .dropdown-list li:has(a:hover, .year:hover) a,
.dropdown[open] .dropdown-list li:has(a:hover, .year:hover) .year{
    animation:
        name-flicker-in 0.3s steps(1) calc(var(--delay) + 0.1s) both,
        flicker 0.2s steps(1) infinite;
}

/* SETTLED: once a name has flickered in, its animation is taken off completely (js/nav.js).
   (Phones sometimes kept the last 20% step of the flicker on screen: some names stayed light grey) */
.dropdown[open]:not(.closing) .dropdown-list li .settled{
    animation: none !important;
    opacity: 1;
}
@media (hover: hover){
    .dropdown[open]:not(.closing) .dropdown-list li:not(.selected):has(a:hover, .year:hover) .settled{
        animation: flicker 0.2s steps(1) infinite !important;
    }
}

/* when each project starts: a little later for every next one */
.dropdown-list li:nth-child(1) { --delay: 0.30s; }
.dropdown-list li:nth-child(2) { --delay: 0.33s; }
.dropdown-list li:nth-child(3) { --delay: 0.36s; }
.dropdown-list li:nth-child(4) { --delay: 0.39s; }
.dropdown-list li:nth-child(5) { --delay: 0.42s; }
.dropdown-list li:nth-child(6) { --delay: 0.45s; }
.dropdown-list li:nth-child(7) { --delay: 0.48s; }
.dropdown-list li:nth-child(8) { --delay: 0.51s; }
.dropdown-list li:nth-child(9) { --delay: 0.54s; }
.dropdown-list li:nth-child(10){ --delay: 0.57s; }
.dropdown-list li:nth-child(11){ --delay: 0.60s; }
.dropdown-list li:nth-child(n+12){ --delay: 0.63s; } /* any project after the 11th */

/* ---------- DROPDOWN CLOSING ANIMATION ---------- */
/* The opening, backwards: js/nav.js adds the class "closing", waits 0.65s, then closes.
   1. projects disappear from the bottom up (name fades, then its line pulls back)
   2. vertical line pulls back up into INDEX
   3. short line into INDEX disappears */

@keyframes shrink-x{
    from{ transform: scaleX(1); }
    to  { transform: scaleX(0); }
}
@keyframes shrink-y{
    from{ transform: scaleY(1); }
    to  { transform: scaleY(0); }
}
@keyframes name-flicker-out{
    0%   { opacity: 1; }
    25%  { opacity: 0.2; }
    50%  { opacity: 1; }
    75%  { opacity: 0.2; }
    100% { opacity: 0; }
}

/* 1. projects: name, then line */
.dropdown.closing[open] .dropdown-list li a,
.dropdown.closing[open] .dropdown-list li .year{
    animation: name-flicker-out 0.2s steps(1) var(--close-delay) both;
}
.dropdown.closing[open] .dropdown-list li::before{
    animation: shrink-x 0.15s steps(3) calc(var(--close-delay) + 0.1s) both;
}

/* 2. vertical line: pulls back up into INDEX */
.dropdown.closing[open] .dropdown-list::before{
    animation: shrink-y 0.3s steps(5) 0.25s both;
}

/* 3. short line into INDEX */
.dropdown.closing[open] .dropdown-list::after{
    animation: shrink-x 0.1s steps(2) 0.55s both;
}

/* the chosen project doesn't flicker while it has the box
   (when the dropdown closes, it fades out like the others) */
.dropdown[open]:not(.closing) .dropdown-list li.selected a{
    animation: none;
}

/* closing goes from the bottom up: the LAST project starts first */
.dropdown-list li:nth-last-child(1) { --close-delay: 0.00s; }
.dropdown-list li:nth-last-child(2) { --close-delay: 0.02s; }
.dropdown-list li:nth-last-child(3) { --close-delay: 0.04s; }
.dropdown-list li:nth-last-child(4) { --close-delay: 0.06s; }
.dropdown-list li:nth-last-child(5) { --close-delay: 0.08s; }
.dropdown-list li:nth-last-child(6) { --close-delay: 0.10s; }
.dropdown-list li:nth-last-child(7) { --close-delay: 0.12s; }
.dropdown-list li:nth-last-child(8) { --close-delay: 0.14s; }
.dropdown-list li:nth-last-child(9) { --close-delay: 0.16s; }
.dropdown-list li:nth-last-child(10){ --close-delay: 0.18s; }
.dropdown-list li:nth-last-child(n+11){ --close-delay: 0.20s; }

/* ---------- INDEX PAGE ---------- */

/* THE GRID LINES are switched off (transparent) - the layout still follows the grid.
   To see them again: --grid-line: rgba(230, 80, 80, 0.25); (pink) */
:root{
    --grid-line: transparent;
}

/* 50 x 50px pink grid (the one home used to have), on pages with <body class="grid-page">
   (the ?#@!+/ page). Change --grid-cell for bigger / smaller squares. */
.grid-page{
    --grid-cell: 50px;
    background-image:
        linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
    background-size: var(--grid-cell) var(--grid-cell);
    min-height: 100vh;              /* grid covers the whole screen, even with little content */
}

/* GRID GALLERY (?#@!+/ page): the pictures are placed on the grid by js/grid-gallery.js */
.grid-gallery{
    position: relative;
}
.grid-gallery img,
.grid-gallery video{
    position: absolute;
    display: block;
    object-fit: contain;            /* never cropped */
}

/* THUMBNAILS PAGE (<body class="thumbs-page">, the ?#@!+/ page): one screen, no scrolling.
   The thumbnails fill the screen; js/grid-gallery.js moves, grows and exposes them. */
/* (phones and small screens scroll instead - keep 900px the same as SCROLL_BELOW in js/grid-gallery.js) */
.thumbs-page .grid-gallery{
    position: relative;             /* scrolls with the page; js/grid-gallery.js sets its height */
    z-index: 0;                     /* below the nav */
}
@media (min-width: 900px){
    html:has(body.thumbs-page){
        overflow: hidden;
    }
    .thumbs-page{
        height: 100vh;
    }
    .thumbs-page .grid-gallery{
        position: fixed;
        inset: 0;                   /* same corner as the grid, so the boxes sit on its lines */
    }
}
/* small screens: while a picture is tapped big the page stays where it is */
@media (max-width: 899.98px){
    html:has(body.picture-pinned){
        overflow: hidden;
    }
}
.thumbs-page .grid-gallery > *{
    /* --lit = how exposed (blown out) a thumbnail is while another one is hovered (0 to 1),
       the same look as when the dropdown is open */
    filter: contrast(calc(1 - 0.55 * var(--lit, 0)))
            brightness(calc(1 + 1.8 * var(--lit, 0)))
            opacity(calc(1 - var(--hide, 0)));   /* --hide = no room next to a clicked picture */
    transition: none;               /* moved frame by frame by the script, no CSS fade */
    cursor: pointer;
    user-select: none;
    -webkit-user-drag: none;
    opacity: 0;                     /* invisible until it's its turn (LOADING in js/grid-gallery.js) */
    pointer-events: none;
}
/* LOADING: each thumbnail flickers in when it's its turn (same flicker as the boxes on home) */
@keyframes thumb-in{
    0%   { opacity: 0; }
    25%  { opacity: 1; }
    45%  { opacity: 0.2; }
    65%  { opacity: 1; }
    100% { opacity: 1; }
}
.thumbs-page .grid-gallery > .shown{
    opacity: 1;
    pointer-events: auto;
    animation: thumb-in 0.3s steps(1) both;
}
@media (prefers-reduced-motion: reduce){
    .thumbs-page .grid-gallery > .shown{ animation: none; }
}

/* ---------- FILTERS (?#@!+/ page, bottom) ---------- */
/* one centred row, the same look and distances as the nav: a black box slides under the chosen word
   (js/grid-gallery.js, "FILTERS"; the box itself is css "SLIDING BOX"), the others flicker on hover */
.filters{
    position: fixed;
    left: 0;
    right: 0;
    bottom: 15px;                   /* like the nav from the top */
    z-index: 10;
    mix-blend-mode: difference;
    display: flex;
    justify-content: center;
    pointer-events: none;           /* the empty part doesn't block clicks on the pictures */
}
.filters-list{
    display: contents;              /* wide screens: the options are part of the row */
}
.filters button{
    all: unset;
    pointer-events: auto;
    cursor: pointer;
    color: white;
    font-family: Helvetica, sans-serif;
    font-size: 13px;
    line-height: 15px;
    padding: 2px 4px;               /* box is 19px tall, like the nav boxes */
    margin: 0 var(--nav-gap);
    white-space: nowrap;
    mix-blend-mode: difference;     /* white on the black box, black next to it - also while it slides */
}
.filters button:focus-visible{
    outline: 1px solid white;
}
@media (hover: hover){
    .filters button:not(.active):not(.glitch):hover{
        animation: flicker 0.2s steps(1) infinite;
    }
}
/* GLITCH: a word that was just clicked (the letters scramble by themselves, js/title-glitch.js) */
.filters button.glitch{
    animation: title-glitch-in 0.4s steps(1) both;
}
/* wide screens: the word FILTERS is only a label */
@media (min-width: 900px){
    .filters .filters-title{
        pointer-events: none;
    }
    .filters .filters-title::after{
        content: ":";
    }
}
/* NARROW SCREENS: only FILTERS, its options open upwards (3 columns).
   (keep 900px the same as SCROLL_BELOW in js/grid-gallery.js) */
@media (max-width: 899.98px){
    .filters{
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }
    .filters button{
        margin: 0;
    }
    .filters .filters-title{
        order: 2;                   /* below its options */
    }
    .filters-list{
        order: 1;
        display: grid;
        grid-template-columns: repeat(3, auto);
        justify-content: space-between;
        justify-items: start;
        row-gap: 8px;
        box-sizing: border-box;
        width: min(100%, 430px);
        padding: 0 10px;
        visibility: hidden;
    }
    .filters-list button{
        pointer-events: none;
    }
    .filters.open .filters-list,
    .filters.closing .filters-list{
        visibility: visible;
    }
    .filters.open .filters-list button{
        pointer-events: auto;
    }
    /* opening: one option after the other glitches in | closing: they glitch out (--i = which one) */
    .filters.opening .filters-list button{
        animation: title-glitch-in 0.4s steps(1) calc(var(--i) * 0.03s) both;
    }
    .filters.closing .filters-list button{
        animation: title-glitch-out 0.3s steps(1) both;
    }
    .filters.opening .nav-box:not(.title-box){
        animation: name-flicker-in 0.3s steps(1) 0.15s both;
    }
    .filters.closing .nav-box:not(.title-box){
        opacity: 0 !important;
    }
}

/* pink grid background, only on pages with <body class="index-page"> */
.index-page{
    box-sizing: border-box;         /* the 100vh include the room for the ragdoll (js/doll.js) */
    background-color: white;
    background-image:
        linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
    background-size: 30px 30px;     /* size of one grid cell */
    min-height: 100vh;              /* grid covers the whole screen, even with little content */
}

.index-list{
    position: absolute;
    top: 150px;                     /* 5 grid cells down (5 x 30px) */
    left: 48.5%;                      /* starts at the middle of the page ... */
    transform: translateX(-20px);   /* ... nudged left so it lines up with INDEX */

    list-style: none;               /* removes the bullet points */
    margin: 0;                      /* removes the browser's default list spacing */
    padding: 0;
}

.index-list a{
    color: black;
    text-decoration: none;
    font-family: Helvetica, sans-serif;
    font-size: 13px;
    line-height: 15px;              /* 2 lines per 30px grid cell */
}

.index-list a:hover{
    text-decoration: underline;
}

html{
    background: white;      /* a real background colour the nav can blend with */
    overflow-x: clip;       /* no scrolling left / right: whatever sticks out at the sides is cut off
                               ("clip", not "hidden" - that would break the sticky Nokia animation) */
}

body{
    margin: 0;              /* removes the browser's default 8px border around the page */
    overflow-x: clip;
}

/* ---------- SCROLLBAR (every page) ---------- */
/* Only a small bar that shows where you are on the page (no line, no outline), 11px wide,
   blended with "difference" like the nav, so it inverts whatever is behind it
   (black on white, light on dark images).
   The browser's own scrollbar can't blend, so it's hidden and the page draws its own:
   js/scrollbar.js on every page, the home page has its own (same class, own script). */
html{
    scrollbar-width: none;               /* hide the browser's scrollbar (Firefox) */
}
::-webkit-scrollbar{
    display: none;                       /* ... (Chrome, Safari) */
}
.scrollbar{
    position: fixed;
    top: 0;
    right: 0;
    width: 11px;
    height: 100vh;
    z-index: 1000;
    mix-blend-mode: difference;          /* like the nav */
    background: transparent;             /* invisible: only the bar inside shows (still clickable) */
    cursor: pointer;
    touch-action: none;
}
.scrollbar .thumb{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: white;                   /* the bar (white + difference = inverted) */
}

.image-1{
    width: 100%;            /* container = full screen width */
    height: 100vh;          /* container = full screen height */
    gap: 200px;
}

.image-1 img,
.image-1 video{
    width: 100%;            /* image fills the container's width */
    height: 100%;           /* image fills the container's height */
    object-fit: cover;      /* crops instead of stretching, keeps proportions */
    display: block;         /* removes the small gap under images */
    
}

/* first image / video shown COMPLETE instead of cropped to fill the screen
   (e.g. an upright video): <div class="image-1 whole"> - empty space left and right */
.image-1.whole img,
.image-1.whole video{
    object-fit: contain;
}

/* "whole" + a thin stripe at the RIGHT edge of the video itself (e.g. the grey line in Cancerous):
   <div class="image-1 whole trim-right" style="--ratio: 0.5625; --trim: 1.4%">
   --ratio = width / height of the video, --trim = how much of its width is cut off on the right.
   The video box gets exactly the video's proportions, so the cut lands on the video's edge */
.image-1.whole.trim-right video{
    width: min(100vw, 100vh * var(--ratio));
    height: min(100vh, 100vw / var(--ratio));
    margin: 0 auto;
    object-fit: fill;
    clip-path: inset(0 var(--trim) 0 0);
    transform: translateX(calc(var(--trim) / 2));   /* what is left stays centred */
}

/* first image / video rotated, still filling the whole screen:
   <div class="image-1 turned" style="--turn: 180deg"> */
.image-1.turned img,
.image-1.turned video{
    /* --shift: moves it sideways (e.g. 3.7% = to the right), to centre what's in it
       --zoom: a little bigger, so the shift leaves no empty edge (at least 1 + 2 x shift) */
    transform: translateX(var(--shift, 0)) rotate(var(--turn, 0deg)) scale(var(--zoom, 1));
    /* --crop-y: which part of the height stays visible when it's cropped (50% = the middle).
       Turned 180deg it works upside down: a HIGHER value shows more at the TOP of the screen */
    object-position: 50% var(--crop-y, 50%);
}

/* first image / video turned by 90° and STILL filling the whole screen:
   <div class="image-1 turned-90">. The video box is made as wide as the screen is tall
   (and the other way round), then turned - so after turning it covers the screen exactly. */
.image-1.turned-90{
    position: relative;
    overflow: hidden;
}
.image-1.turned-90 img,
.image-1.turned-90 video{
    position: absolute;
    left: 50%;
    top: 50%;
    width: 100vh;
    height: 100vw;
    object-fit: cover;
    transform: translate(-50%, -50%) rotate(90deg);   /* -90deg = the other way */
}
/* ...and the video file has black bars above and below its actual picture (format --pic, e.g. 3:2):
   <div class="image-1 turned-90 crop-bars"> - made big enough that only the picture covers the screen */
.image-1.turned-90.crop-bars video{
    width: max(calc(var(--pic, 1.5) * 100vw), 100vh);
    max-width: none;
    max-height: none;
    height: auto;
    object-fit: fill;
    aspect-ratio: auto;
}

/* first video with black bars LEFT and RIGHT in the video file itself (a 16:9 file with a
   narrower picture inside, format --pic, e.g. 3:2 = 1.5):
   <div class="image-1 crop-sides" style="--pic: 1.48"> - the video is made big enough that only
   the picture covers the screen, the bars stick out at the sides and are cut off.
   (--pic a bit smaller than the real format = a little safety margin against thin black edges) */
.image-1.crop-sides{
    position: relative;
    overflow: hidden;
}
.image-1.crop-sides video{
    position: absolute;
    left: 50%;
    top: 50%;
    /* wide enough that the PICTURE covers the screen width, and high enough for the screen height */
    width: max(calc(100vw * 16 / 9 / var(--pic, 1.5)), calc(100vh * 16 / 9));
    height: auto;
    max-width: none;
    max-height: none;
    aspect-ratio: 16 / 9;
    object-fit: fill;
    transform: translate(-50%, -50%);
}

/* first image / video shown in a FRAME of a chosen format (e.g. the format of the book in it),
   as big as fits on the screen, centred. Inside the frame it can be rotated and zoomed:
   <div class="image-1 framed" style="--format: 1.39; --zoom: 1.32; --turn: 180deg">
     <div class="frame"> <video ...> </div>
   </div>
     --format = width / height of the frame
     --zoom   = how far it's zoomed in inside the frame (1 = not at all)
     --turn   = how far it's rotated */
.image-1.framed .frame{
    height: 100%;
    max-width: 100%;
    aspect-ratio: var(--format, 1.5);
    margin: 0 auto;
    overflow: hidden;            /* whatever is outside the frame is cut off */
}
.image-1.framed .frame img,
.image-1.framed .frame video{
    object-fit: cover;
    transform: rotate(var(--turn, 0deg)) scale(var(--zoom, 1));
}

/* video with black bars baked in above and below (e.g. a 3:2 picture inside a taller file):
   <div class="image-1 crop-bars"> shows only the picture (3:2), as big as fits, centered */
.image-1.crop-bars video{
    width: auto;
    max-width: 100%;
    height: 100%;
    aspect-ratio: 3 / 2;         /* the format of the actual picture inside the file */
    object-fit: cover;           /* cut off whatever is outside (= the black bars) */
    margin: 0 auto;
}

/* video with black bars baked in LEFT and RIGHT, still filling the whole screen:
   <div class="image-1 cut-sides" style="--keep: 0.72">
     --keep = how much of the file's width is the actual picture (0.72 = 72%, bars = the rest).
   The video is made wider than the screen by exactly that much, so the bars fall outside it.
   Works together with "turned". */
.image-1.cut-sides{
    overflow: hidden;
}
.image-1.cut-sides video,
.image-1.cut-sides img{
    width: calc(100% / var(--keep, 1));
    margin-left: calc((100% - 100% / var(--keep, 1)) / 2);   /* centred: half sticks out on each side */
    max-width: none;
}

/* PHONE: the first video / image is as wide as the screen (100vw) and as tall as its own format makes it -
   not cropped to fill the screen's height. (Rotations and zooms stay, cut off at its edges.) */
@media (max-width: 600px){
    .image-1:not(.type-area){
        width: 100vw;
        height: auto;
        overflow: hidden;
    }
    .image-1:not(.type-area):not(.turned-90):not(.framed):not(.trim-right) video,
    .image-1:not(.type-area):not(.turned-90):not(.framed):not(.trim-right) img{
        height: auto;
        object-position: 50% 50% !important;   /* nothing is cropped, so no shifting either (Cancerous) */
    }
}

/* ---------- RAGDOLL (about page, js/doll.js) ---------- */
/* a layer over the whole page; only the body parts can be touched */
.doll{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;                 /* height: set by the script (the page's height) */
    overflow: hidden;
    z-index: 5;                  /* above the text, below the nav */
    pointer-events: none;
}
.doll img{
    position: absolute;
    top: 0;
    left: 0;
    max-width: none;
    pointer-events: auto;
    cursor: grab;
    touch-action: none;          /* dragging a part doesn't scroll the page */
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
    will-change: transform;
}
.doll.dragging img{
    cursor: grabbing;
}
/* HOME: the doll inside a gallery frame - it can't be grabbed there, a click goes to the frame */
.doll.framed{
    z-index: auto;
    transform-origin: 0 0;       /* scaled to the frame's size by the script */
}
.doll.framed img{
    pointer-events: none;
    cursor: inherit;
}

/* ---------- PROJECT TEXT (between the full-screen video and the gallery) ---------- */
/* Same 6 columns as the gallery. A paragraph is never wider than 3 of the 6 columns
   and sits in the middle of the page (3 columns can't start on a column line when
   centred, so the width is calculated: 3 columns + the 2 gaps between them).
   175px above it (to the video) - the 175px below it comes from the gallery's padding. */
.project-text{
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    column-gap: 10px;
    padding: 175px 10px 0;
}
.project-text p,
.project-body{
    grid-column: 1 / -1;         /* the whole row ... */
    justify-self: center;        /* ... centred in it ... */
    width: 100%;
    max-width: calc((100% - 50px) / 2 + 20px);   /* ... at most 3/6: (row - 5 gaps) / 6 * 3 + 2 gaps */
    margin: 0;
    font-family: Helvetica, sans-serif;
    font-size: 14.4px;           /* all texts that aren't in caps */
    line-height: 20px;
}
/* ABOUT: SKILLS and LANGUAGES as two lists next to each other, under the text (one empty line above).
   Same width as the text; the second list starts one column of the text block further right
   (desktop: the text is 3 columns, so 1 of them | slim screens: 5 columns, 2 of them | phones: half). */
.about-lists{
    grid-column: 1 / -1;
    justify-self: center;
    width: 100%;
    max-width: calc((100% - 50px) / 2 + 20px);
    margin-top: 20px;
    display: grid;
    grid-template-columns: calc((100% - 20px) / 3 + 10px) 1fr;
    font-family: Helvetica, sans-serif;
    font-size: 14.4px;
    line-height: 20px;
}
.about-lists > div{ display: flex; flex-direction: column; }
.about-lists span:first-child{ font-size: 13px; }   /* the heading: caps text size */
@media (max-width: 899.98px){
    .about-lists{
        max-width: calc((100% - 50px) / 6 * 5 + 40px);
        grid-template-columns: calc((100% - 40px) / 5 * 2 + 20px) 1fr;
    }
}
@media (max-width: 600px){
    .about-lists{ grid-template-columns: 1fr 1fr; }
}
/* SLIM SCREENS: 5 of the 6 columns wide (instead of 3) */
@media (max-width: 899.98px){
    .project-text p,
    .project-body{
        max-width: calc((100% - 50px) / 6 * 5 + 40px);   /* (row - 5 gaps) / 6 * 5 + 4 gaps */
    }
    .project-body p{
        max-width: none;             /* fills the text block */
    }
}
/* ZOOM: a picture with style="--zoom: 1.2" is shown 1.2x bigger inside its own frame - the edges
   are cut off, the frame keeps its size and place (1 = normal) */
.gallery img[style*="--zoom"]{
    transform: scale(var(--zoom));
    clip-path: inset(calc((1 - 1 / var(--zoom)) * 50%));
}
/* CAPTION: one sentence above the text, one empty line between them */
.project-caption{
    margin-bottom: 20px !important;
}
/* a caption BELOW the text (about page): the empty line goes above it instead */
.project-caption.below{
    margin-bottom: 0 !important;
    margin-top: 20px !important;
}
/* the text block: the paragraph inside fills it; the technical data hangs on its left */
.project-body{
    position: relative;
}
.project-body p{
    max-width: none;
}
/* TECHNICAL DATA: right-aligned, just left of the text, starting on its first line */
.project-facts{
    position: absolute;
    top: 0;
    right: calc(100% + 8px);
    display: flex;
    flex-direction: column;
    text-align: right;
    white-space: nowrap;
    font-size: 10px;
    line-height: 14px;          /* line spacing (Zeilenabstand) */
    padding-top: 2px;           /* first line sits level with the text's first line (its line is 18px) */
}

/* ---------- FOOTER (project pages) ---------- */
/* At the very bottom of the page, after the gallery - it scrolls with the page, it doesn't stick.
   Same 6 columns as the gallery: the facts (format, category, year) in the 1st column,
   the collaborators in the 2nd, the client from the 3rd. In caps: 13px. */
.project-footer{
    display: grid;
    box-sizing: border-box;     /* the 100px include the padding */
    min-height: 100px;          /* at least 100px tall, on desktop and phone */
    align-content: end;         /* the text stays at the bottom, 15px from the edge */
    grid-template-columns: repeat(6, 1fr);
    column-gap: 10px;
    padding: 0 10px 15px;       /* 15px from the bottom edge, like the nav from the top */
    font-family: Helvetica, sans-serif;
    font-size: 13px;            /* texts in caps stay 13px */
    line-height: 18px;
}
.project-footer .project-facts,
.project-footer .project-collaborators,
.project-footer .project-client{
    position: static;           /* not hanging next to the text any more */
    white-space: nowrap;        /* names stay on one line, also on the phone */
    font-size: inherit;         /* the footer's 13px, not the 10px the facts had next to the text */
    line-height: inherit;
    display: flex;
    flex-direction: column;
    text-align: left;
    padding: 0;
}

/* FIXED SPOTS, the same on every page (a missing one leaves its space empty):
   facts = 1st column, collaborators = 2nd, client = 3rd to last (long names) */
.project-footer{
    grid-template-columns: repeat(6, minmax(0, 1fr));   /* long words don't widen a column */
    align-content: start;
    padding-top: 31px;          /* the first line is always here: 100px - 15px - 3 lines */
}
.project-footer .project-facts{ grid-column: 1; grid-row: 1; min-height: 54px; }   /* always room for 3 lines, so all start at the same height */
.project-footer .project-collaborators{ grid-column: 2; grid-row: 1; }
.project-footer .project-client{ grid-column: 3 / -1; grid-row: 1; white-space: normal; }
/* medium screens: 3 wider columns, otherwise the texts would overlap */
@media (max-width: 999.98px){
    .project-footer{
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
/* phone: facts, collaborators and client below each other, the full width
   (so the footer gets taller than 100px) */
@media (max-width: 600px){
    .project-footer{
        align-content: end;
        padding-top: 0;
        row-gap: 18px;              /* one empty line */
        padding-bottom: 52px;       /* above SOUND / MUTE and EN / DE (15px + 19px + one line) */
    }
    .project-footer .project-facts,
    .project-footer .project-collaborators,
    .project-footer .project-client{
        grid-column: 1 / -1;
        grid-row: auto;
        min-height: 0;
    }
}

/* ---------- GALLERY ---------- */

.gallery{
    display: grid;
    grid-template-columns: repeat(6, 1fr);   /* 6 equal columns, like in your layout */
    grid-template-areas:
        ".     img02 img02 img02 img02 .    "   /* pattern: centered */
        "img03 img03 img03 img04 img04 img04"   /* image + video next to each other */
        ".     img05 img05 img05 img05 .    "   /* TOUT: centered */
        ".     img06 img06 img06 img06 .    ";  /* crowd: centered */
    /* RULES: alone in a row = 4 of 6 columns, centered (". x x x x .")
              two next to each other = 3 + 3 columns
              side by side: 10px apart, and 10px from the page edge
              above and below every image: 175px */
    row-gap: 175px;              /* space between the rows (top / bottom) */
    column-gap: 10px;            /* space between images next to each other */
    padding: 175px 10px;         /* top/bottom: space to the video and below the last image | left/right: page edge */
    align-items: start;          /* images next to each other line up at the top */
}

.gallery img,
.gallery video{
    display: block;
    width: auto;                 /* natural width ... */
    height: auto;                /* ... and height, proportions stay the same */
    max-width: 100%;             /* never wider than its area */
    max-height: 100vh;           /* never taller than the screen */
    justify-self: center;        /* if it gets smaller, it stays centered in its area */
}

.img02{ grid-area: img02; }
.img05{ grid-area: img05; }
.img06{ grid-area: img06; }

/* the pair: both exactly half the width and the same height,
   cropped like the hero video so they line up as one block */
.img03{ grid-area: img03; }
.img04{ grid-area: img04; }

.gallery .img03,
.gallery .img04{
    width: 100%;
    aspect-ratio: 3 / 4;         /* same portrait shape for both */
    object-fit: cover;           /* crop instead of stretching */
}

/* GALLERY WITHOUT NAMED AREAS (cancerous.html and new project pages):
   <div class="gallery rows"> - each image just gets a class, rows follow the HTML order.
     .single = alone in its row: columns 2-5 (4 of 6), centered
     .half   = two next to each other: 3 + 3 columns
     .full   = the entire width (all 6 columns) */
.gallery.rows{
    grid-template-areas: none;
}
.gallery .single{
    grid-column: 2 / 6;
}
.gallery .full{
    grid-column: 1 / -1;         /* all 6 columns: the entire width (10px from the page edges) */
    width: 100%;
    object-fit: cover;           /* if the screen height limits it: crop, don't squash */
}
.gallery .half{
    grid-column: span 3;
    width: 100%;                 /* both fill their half exactly */
    object-fit: cover;           /* if the screen height limits it: crop, don't squash */
}
/* STEPS (timelessdesign.html): three images close together, 10px apart, like a staircase -
   one at the top left (3 of 6 columns), two next to each other underneath (3 + 3) */
.gallery .steps{
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.gallery .steps img{
    width: 100%;
    max-height: none;
}
.gallery .steps .top-left{ grid-column: 1; grid-row: 1; }
.gallery .steps .bottom-left{ grid-column: 1; grid-row: 2; }
.gallery .steps .bottom-right{ grid-column: 2; grid-row: 2; }

/* COLLAGE (trafficjam.html): drawings placed freely over all 6 columns.
   Each <img> gets left / top / width in % in its style="..." (see the page). */
.gallery .collage{
    grid-column: 1 / -1;
    position: relative;
    width: 100%;
}
.gallery .collage img{
    position: absolute;
    height: auto;                /* the height follows the drawing's format */
    max-width: none;
    max-height: none;
}

/* three next to each other: 2 + 2 + 2 columns */
.gallery .third{
    grid-column: span 2;
    width: 100%;
    object-fit: cover;
}
/* a grid of videos inside one row (fanfare.html): 3 per row, 10px apart, all the same shape */
.gallery .video-grid{
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.gallery .video-grid video{
    width: 100%;
    max-height: none;
    aspect-ratio: 9 / 16;        /* portrait, like the videos */
    object-fit: cover;
}

/* a pair cropped to the same format, so both are exactly the same height */
.gallery .same-shape{
    aspect-ratio: 3 / 4;
    height: auto;
}

/* grey stand-in for an image that isn't there yet */
.placeholder{
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e5e5e5;
    color: #888;
    font-family: Helvetica, sans-serif;
    font-size: 13px;
}
.gallery .placeholder{
    aspect-ratio: 3 / 2;
}

/* PAIR: two pictures next to each other in the SAME height, 10px apart, nothing cropped.
   Each gets its proportions as --r (width / height), e.g. <img style="--r: 0.7073" ...>.
   Together they fill the width - unless that would make them taller than the screen,
   then they shrink and stay centered. (Made for two pictures; --r-sum = both --r added up) */
.gallery .pair{
    --r-sum: 1.2698;                                     /* 0.5625 + 0.7073 */
    grid-column: 1 / -1;
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: calc(100vh * var(--r-sum) + 10px);        /* never taller than the screen */
    justify-self: center;
}
.gallery .pair > *{
    flex: var(--r) 1 0;          /* the width shares follow the proportions = same height */
    min-width: 0;
    width: 0;
    height: auto;
    max-width: none;
    max-height: none;
    aspect-ratio: var(--r);
    object-fit: cover;
}

/* box around the video: hides whatever sticks out */
.video-crop{
    overflow: hidden;
    max-height: 100vh;           /* same height limit as the image next to it */
}

/* the video fills the box and is scaled up a little,
   so the black bars at its top and bottom are pushed outside the box */
.gallery .video-crop video{
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: cover;
    transform: scale(1.1);       /* 10% bigger: raise if you still see black edges */
}
.about{
    position: absolute;
    top: 150px;
    left: 710px;
    line-height: 20px;
font-family: Helvetica, sans-serif;
font-size: 14.4px;
}

/* 1. The flicker itself: switches between visible and invisible */
@keyframes flicker{
    0%   { opacity: 1; }
    50%  { opacity: 0.2; }
}

/* 2. Play it while the mouse is on a link - except the page you're already on */
.nav a:not(.active):hover,
.dropdown summary:not(.active):hover{
    animation: flicker 0.2s steps(1) infinite;
}

/* the highlighted INDEX (dropdown open) doesn't flicker */
.dropdown[open] summary:hover{
    animation: none;
}

/* ---------- GRAIN DISSOLVE (while the dropdown is open) ---------- */
/* js/nav.js puts "dissolving" on <body> and steps the filter #grain-dissolve:
   the images, the video, the boxes on HOME and the about text crumble into specks.
   Add any other element that should dissolve to this list. */
body.dissolving .image-1,
body.dissolving .gallery > *,
body.dissolving .grid-gallery > *,
body.dissolving .box,
body.dissolving .about{
    filter: url(#grain-dissolve);
}

/* ---------- BLUR (while the dropdown is open) ---------- */
/* The other option: set MODE: 'blur' at the top of js/nav.js.
   js/nav.js puts "blurred" on <body>; the same elements get soft. */
:root{
    --blur: 12px;               /* how blurry: higher = softer */
}
.image-1,
.project-text,
.project-footer,
.gallery > *,
.grid-gallery > *,
.box,
.about{
    transition: filter 0.4s cubic-bezier(0.65, 0, 0.35, 1);   /* blur fades in and out */
}
body.blurred .image-1,
body.blurred .project-text,
body.blurred .project-footer,
body.blurred .gallery > *,
body.blurred .grid-gallery > *,
body.blurred .box,
body.blurred .about{
    filter: blur(var(--blur));
}

/* ---------- BRIGHT / OVEREXPOSED (while the dropdown is open) ---------- */
/* MODE: 'bright' at the top of js/nav.js. js/nav.js puts "brightened" on <body> and raises
   --exposure step by step (BRIGHT_STEPS), 0 = normal, 1 = fully blown out:
     contrast   - the darks get lifted towards grey (like light falling on them)
     brightness - then everything is pushed up, the lights burn out to white */
body.brightened .image-1,
body.brightened .project-text,
body.brightened .project-footer,
body.brightened .gallery > *,
body.brightened .grid-gallery > *,
body.brightened .box,
body.brightened .preview-caption,
body.brightened .about,
body.brightened .doll,
body.brightened .nokia-stage{
    filter: contrast(calc(1 - 0.55 * var(--exposure, 0)))
            brightness(calc(1 + 1.8 * var(--exposure, 0)));
    transition: none;            /* hard steps, no soft fade (the blur's transition would smooth them) */
}

/* ?#@!+/ page: pictures a filter has already exposed stay exposed */
body.brightened.thumbs-page .grid-gallery > *{
    filter: contrast(calc(1 - 0.55 * max(var(--exposure, 0), var(--lit, 0))))
            brightness(calc(1 + 1.8 * max(var(--exposure, 0), var(--lit, 0))))
            opacity(calc(1 - var(--hide, 0)));
}

/* ---------- PIXELATED (while the dropdown is open) ---------- */
/* MODE: 'pixel' at the top of js/nav.js. js/nav.js puts "pixelated" on <body> and makes
   the blocks of the SVG filter #pixelate bigger step by step (PIXEL_STEPS). */
body.pixelated .image-1,
body.pixelated .project-text,
body.pixelated .project-footer,
body.pixelated .gallery > *,
body.pixelated .grid-gallery > *,
body.pixelated .box,
body.pixelated .about,
body.pixelated .nokia-stage{
    filter: url(#pixelate);
}

/* ---------- SLIDING BOX (js/nav.js) ---------- */
/* One box that slides between the titles, instead of a box behind each title. */
.nav-box{
    position: absolute;
    z-index: -1;                /* behind the titles, but inside the nav */
    background: white;          /* black on white pages because of "difference" */
    pointer-events: none;
    transition:
        left  0.45s cubic-bezier(0.65, 0, 0.35, 1),   /* slow - fast - slow */
        width 0.45s cubic-bezier(0.65, 0, 0.35, 1),
        top   0.45s cubic-bezier(0.65, 0, 0.35, 1),   /* (the filters on a phone: two rows) */
        opacity 0.2s;
}

/* the titles no longer have their own box: the sliding box does the job */
.nav.has-box .active,
.nav.has-box .dropdown summary{
    background: none;
    color: white;
}

/* each title inverts against the box underneath it,
   so it reads white on the black box and black next to it - also while the box slides.
   The project titles and years in the dropdown too (not the chosen one: it has its own box) */
.nav.has-box > a,
.nav.has-box summary,
.nav.has-box .dropdown-list li:not(.selected) a,
.nav.has-box .dropdown-list li:not(.selected) .year{
    mix-blend-mode: difference;
}

/* ---------- LEAVING A PROJECT PAGE (js/nav.js) ---------- */
/* Clicking HOME / ABOUT on a project page: the title turns back into INDEX
   (same animation as opening the dropdown), so the next page doesn't jump.
   The second selector wins over the closing animation, in case the dropdown was open. */
.nav .dropdown.unswap .swap-old,
.nav .dropdown.unswap.closing[open] .swap-old{
    animation: title-glitch-in 0.4s steps(1) both;
}
.nav .dropdown.unswap .swap-new,
.nav .dropdown.unswap.closing[open] .swap-new{
    animation: title-glitch-out 0.4s steps(1) both;
}


/* PAGE SLIDE (js/nav.js): until the new page starts sliding in, keep it hidden
   (otherwise it flashes in its final spot for a moment). The nav stays visible. */
html.page-entering body > :not(.nav):not(.lang-toggle):not(.sound-toggle):not(.square-cursor){
    visibility: hidden !important;   /* !important: the boxes on HOME set their own visibility */
}

/* ---------- PAGE SLIDE: the browser's own page transition ---------- */
/* Between HOME and ABOUT the browser takes a picture of the old and the new page
   and flickers them (old one out, new one in). js/page-slide.js marks these page changes
   ("from-right" / "from-left" - left over from the slide); every other page change gets no animation.
   Works in Chrome and Safari 18.2+ through a server (Live Server), not with file://. */
@view-transition{
    navigation: auto;
}

/* the nav and the language toggle are not part of the sliding picture: they stay put on top */
.nav{
    view-transition-name: site-nav;
}
.lang-toggle{
    view-transition-name: lang-toggle;
}
.sound-toggle{
    view-transition-name: sound-toggle;
}
.square-cursor{
    view-transition-name: square-cursor;   /* the cursor stays put too, it doesn't flicker with the page */
}
/* ...and keeps its "difference" look while the pages slide underneath */
::view-transition-group(site-nav),
::view-transition-group(lang-toggle),
::view-transition-group(sound-toggle),
::view-transition-group(square-cursor){
    animation: none;
    mix-blend-mode: difference;
}
::view-transition-image-pair(site-nav),
::view-transition-image-pair(lang-toggle),
::view-transition-image-pair(sound-toggle),
::view-transition-image-pair(square-cursor){
    isolation: auto;
}
::view-transition-old(site-nav),
::view-transition-old(lang-toggle),
::view-transition-old(sound-toggle){
    display: none;              /* only the new nav, no cross-fade */
}
::view-transition-new(site-nav),
::view-transition-new(lang-toggle),
::view-transition-new(sound-toggle),
::view-transition-old(square-cursor),
::view-transition-new(square-cursor){   /* cursor: old and new both stay (same spot) - no gap if the new page draws it a moment later */
    animation: none;
}

/* the two pages FLICKER: the old one flickers out, then the new one flickers in -
   the same on / off (1 / 0.2) as the hover flicker in the nav.
   steps(1): every keyframe jumps straight to its value, no fading in between */
::view-transition-old(root),
::view-transition-new(root){
    animation-duration: 0.5s;    /* PAGE_FLICKER_TIME */
    animation-timing-function: steps(1, end);
    animation-fill-mode: both;
    mix-blend-mode: normal;
}
@keyframes page-flicker-out{
    0%   { opacity: 1; }
    15%  { opacity: 0.2; }
    30%  { opacity: 1; }
    45%  { opacity: 0.2; }
    50%, 100% { opacity: 0; }
}
@keyframes page-flicker-in{
    0%, 50% { opacity: 0; }
    60%  { opacity: 1; }
    70%  { opacity: 0.2; }
    85%, 100% { opacity: 1; }
}
/* every page change (HOME / ABOUT, dropdown, PREVIOUS / NEXT, pictures on home, back button) */
html:active-view-transition-type(from-right, from-left, from-next, from-prev, from-any, flicker)::view-transition-old(root){ animation-name: page-flicker-out; }
html:active-view-transition-type(from-right, from-left, from-next, from-prev, from-any, flicker)::view-transition-new(root){ animation-name: page-flicker-in; }

/* "reduce motion" switched on in the system: no flicker */
@media (prefers-reduced-motion: reduce){
    ::view-transition-group(*),
    ::view-transition-old(*),
    ::view-transition-new(*){
        animation: none !important;
    }
}

/* ---------- LANGUAGE (js/lang.js) ---------- */
/* Texts written twice (<p lang="en"> and <p lang="de">): only the chosen one shows */
html[data-lang="en"] body [lang="de"],
html[data-lang="de"] body [lang="en"]{
    display: none;
}

/* the EN / DE toggle: top right, same height and look as the nav */
.lang-toggle{
    position: fixed;
    top: 15px;                  /* same as the nav */
    right: 10px;                /* same as the page edge of the gallery */
    z-index: 10;
    mix-blend-mode: difference; /* like the nav: inverts whatever is behind it */
    display: flex;
    gap: 4px;
}
.lang-toggle button{
    all: unset;                 /* no default button look */
    cursor: pointer;
    color: white;               /* white + difference = inverted background */
    font-family: Helvetica, sans-serif;
    font-size: 13px;
    line-height: 15px;
    padding: 2px 4px;           /* box is 19px tall, like the nav boxes */
}
/* the chosen language gets the box */
.lang-toggle button.active{
    background: white;
    color: black;
    cursor: default;
}
/* the other one flickers on hover, like the nav */
.lang-toggle button:not(.active):hover{
    animation: flicker 0.2s steps(1) infinite;
}

/* ---------- SOUND TOGGLE (js/glitch-sound.js) ---------- */
/* SOUND / MUTE: top left, same height and look as the nav and the EN / DE toggle */
.sound-toggle{
    position: fixed;
    top: 15px;                  /* same as the nav */
    left: 10px;                 /* same as the page edge */
    z-index: 10;
    mix-blend-mode: difference;
    display: flex;
    gap: 4px;
}
.sound-toggle button{
    all: unset;
    cursor: pointer;
    color: white;
    font-family: Helvetica, sans-serif;
    font-size: 13px;
    line-height: 15px;
    padding: 2px 4px;
}
.sound-toggle button.active{
    background: white;
    color: black;
    cursor: default;
}
.sound-toggle button:not(.active):hover{
    animation: flicker 0.2s steps(1) infinite;
}

/* ---------- BOTTOM LINKS (about page: INSTAGRAM) ---------- */
/* centred at the bottom, the same look and distances as the nav (15px from the edge, 13px caps).
   Hover: flicker. Click: black box + glitch for a moment (script in about.html), then the link opens. */
.bottom-links{
    position: fixed;
    left: 0;
    right: 0;
    bottom: 15px;
    z-index: 10;                    /* above the ragdoll */
    mix-blend-mode: difference;
    display: flex;
    justify-content: center;
    pointer-events: none;           /* the empty part doesn't block anything */
}
/* the line above the link ("FIND ME ON", typed in by the script in about.html) */
.bottom-links{
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.find-me{
    color: white;
    font-family: Helvetica, sans-serif;
    font-size: 13px;
    line-height: 15px;
    padding: 2px 4px;
    min-height: 15px;               /* keeps its place while it's still empty */
    white-space: nowrap;
}
/* while typing: a blinking block after the letters */
.find-me.typing::after{
    content: "";
    display: inline-block;
    width: 7px;
    height: 11px;
    margin-left: 2px;
    background: white;
    animation: flicker 0.5s steps(1) infinite;
}
.bottom-links a{
    pointer-events: auto;
    color: white;                   /* white + difference = black on the white page */
    text-decoration: none;
    font-family: Helvetica, sans-serif;
    font-size: 13px;
    line-height: 15px;
    padding: 2px 4px;               /* box 19px tall, like the nav */
    margin: 0 var(--nav-gap);
    white-space: nowrap;
}
.bottom-links a:focus-visible{
    outline: 1px solid white;
}
@media (hover: hover){
    .bottom-links a:not(.hit):hover{
        animation: flicker 0.2s steps(1) infinite;
    }
}
.bottom-links a.hit{
    background: white;
    color: black;
    animation: title-glitch-in 0.4s steps(1) both;
}
/* LEAVING (js/nav.js): you clicked HOME / PROJECTS / PREVIOUS / NEXT - INSTAGRAM glitches away
   (like the nav titles, the letters scramble too: js/title-glitch.js) before the page changes.
   ":hover" too, so the hover flicker can't win. */
html.leaving .bottom-links a,
html.leaving .bottom-links a:hover{
    background: none;
    color: white;
    animation: title-glitch-out 0.4s steps(1) both;
}

/* ---------- TYPE TESTER (nokia3410.html) ---------- */
/* Your own typeface. font-display: swap = show text right away, switch to BLURINO once loaded */
@font-face{
    font-family: "BLURINO";
    src: url("../font/BLURINO-Regular.woff2") format("woff2");
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* the first screen: the typing area sits in its middle (left-right AND top-bottom) */
.image-1.type-area{
    display: flex;
    align-items: center;         /* top-bottom */
    justify-content: center;     /* left-right */
    box-sizing: border-box;
    padding: 90px 10px;          /* top + bottom the same (room for the nav), so it's centred on the screen | sides: page edge */
    overflow-y: auto;            /* a very long text can be scrolled inside */
}

/* what visitors type into (an editable text area: it grows from the middle as you type) */
.type-tester{
    max-width: 100%;
    min-width: 1ch;              /* so the empty field can still be clicked */
    outline: none;               /* no blue frame while typing */
    color: black;
    font-family: "BLURINO", Helvetica, sans-serif;
    font-size: var(--type-size, 8vw); /* size of the typed letters - set by the slider top left */
    line-height: 1.1;
    text-align: center;          /* every line centred */
    white-space: pre-wrap;       /* keeps spaces and line breaks as typed */
    overflow-wrap: anywhere;     /* very long words wrap instead of running off the screen */
    caret-color: black;          /* the blinking cursor */
    cursor: text;
}
/* the grey hint before anyone types ("Type here" / "Hier tippen" - see data-placeholder) */
.type-tester:empty::before{
    content: attr(data-placeholder);
    color: #c8c8c8;
    pointer-events: none;
}

/* the font size slider: top left corner, same height and look as the nav */
.size-control{
    position: absolute;          /* scrolls away with the page (not sticky) */
    top: calc(100vh - 15px - 19px); /* at the bottom of the first full screen: 15px from its edge, like the nav at the top */
    left: 50%;
    transform: translateX(-50%); /* centred */
    z-index: 10;
    mix-blend-mode: difference;  /* like the nav: inverts whatever is behind it */
    display: flex;
    align-items: center;
    gap: 8px;
    height: 19px;                /* same as the nav boxes */
    color: white;
    font-family: Helvetica, sans-serif;
    font-size: 13px;
    line-height: 15px;
    cursor: pointer;
}
/* the size in points next to the slider: fixed width + equal-width digits, so the slider doesn't jump */
.size-control .size-value{
    min-width: 4.5em;
    font-variant-numeric: tabular-nums;
}
.size-control input{
    -webkit-appearance: none;
    appearance: none;
    width: 140px;
    height: 19px;
    margin: 0;
    background: transparent;
    cursor: pointer;
}
/* the bar: an outlined rectangle, as tall as the handle (which slides inside it) */
.size-control input::-webkit-slider-runnable-track{
    height: 11px;
    background: transparent;
    box-shadow: inset 0 0 0 1px white;   /* 1px outline, drawn inside so the height stays 11px */
}
.size-control input::-moz-range-track{
    height: 11px;
    background: transparent;
    box-shadow: inset 0 0 0 1px white;
}
/* the handle: a small square */
.size-control input::-webkit-slider-thumb{
    -webkit-appearance: none;
    width: 11px;
    height: 11px;
    margin-top: 0;               /* same height as the bar: sits exactly inside it */
    background: white;
    border: none;
    border-radius: 0;
}
.size-control input::-moz-range-thumb{
    width: 11px;
    height: 11px;
    background: white;
    border: none;
    border-radius: 0;
}

/* ---------- NOKIA ASSEMBLY (nokia3410.html, js/nokia-assemble.js) ---------- */
/* The section is 300vh tall: while you scroll through it, the stage sticks to the screen
   and the parts come together. More height = the animation takes longer to scroll through. */
.nokia-assembly{
    height: 300vh;
    margin-bottom: 175px;        /* same space as below every gallery image */
}
.nokia-stage{
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}
.nokia-part,
.nokia-together{
    position: absolute;
    left: 0;
    top: 0;
    display: block;
    will-change: transform, width, height, opacity;
}
.nokia-together{
    opacity: 0;
}

/* ---------- PREVIOUS / NEXT PROJECT (js/project-nav.js) ---------- */
/* in the first / last column the normal cursor is replaced by a label */
html.edge-zone,
html.edge-zone *{
    cursor: none !important;
}
.edge-cursor{
    position: fixed;
    left: 0;
    top: 0;
    z-index: 20;                 /* above everything, also the nav */
    pointer-events: none;
    mix-blend-mode: difference;  /* like the nav: readable on dark and light */
    color: white;
    font-family: Helvetica, sans-serif;
    font-size: 13px;
    line-height: 15px;
    white-space: nowrap;
    opacity: 0;
}
.edge-cursor.shown{
    opacity: 1;
}
/* the label sits next to the mouse point: left of it on the left side, right of it on the right */
.edge-cursor[data-side="prev"]{ margin: -7px 0 0 4px; }
.edge-cursor[data-side="next"]{ margin: -7px 0 0 -4px; translate: -100% 0; }

/* a project page that is only one full screen (e.g. cmy.html: just the video): no scrolling */
html:has(body.no-scroll),
body.no-scroll{
    height: 100%;
    overflow: hidden;
}

/* ---------- SQUARE CURSOR (js/cursor.js) ---------- */
/* a black square instead of the mouse pointer; over something clickable it grows */
:root{
    --cursor-size: 6px;          /* the normal square */
    --cursor-hover: 16px;        /* over something clickable */
    --cursor-speed: 0.25s;       /* how fast it grows / shrinks back */
}
html.has-square-cursor,
html.has-square-cursor *{
    cursor: none !important;     /* the normal pointer is hidden */
}
.square-cursor{
    position: fixed;
    left: 0;
    top: 0;
    z-index: 30;                 /* above everything */
    pointer-events: none;
    width: var(--cursor-size);
    height: var(--cursor-size);
    margin: calc(var(--cursor-size) / -2) 0 0 calc(var(--cursor-size) / -2);   /* centred on the mouse point */
    background: white;           /* white + "difference" = black on white, white on black (like the nav) */
    mix-blend-mode: difference;
    opacity: 0;
    transition: width var(--cursor-speed) cubic-bezier(0.2, 0.8, 0.2, 1),
                height var(--cursor-speed) cubic-bezier(0.2, 0.8, 0.2, 1),
                margin var(--cursor-speed) cubic-bezier(0.2, 0.8, 0.2, 1);
}
.square-cursor.shown{
    opacity: 1;
}
.square-cursor.big{
    width: var(--cursor-hover);
    height: var(--cursor-hover);
    margin: calc(var(--cursor-hover) / -2) 0 0 calc(var(--cursor-hover) / -2);
}
/* in the PREVIOUS / NEXT columns the label is the cursor - no square there */
html.edge-zone .square-cursor{
    opacity: 0;
}

/* GLITCH between the square cursor and PREVIOUS / NEXT (js/project-nav.js adds "cursor-glitch")
   0.28s - keep the same as GLITCH_TIME in js/project-nav.js */
html.cursor-glitch .square-cursor{
    animation: square-glitch 0.28s steps(1);
}
html.cursor-glitch .edge-cursor{
    animation: label-glitch 0.28s steps(1);
}
/* the square: flickers, jumps sideways and gets squashed / stretched */
@keyframes square-glitch{
    0%  { opacity: 1;   translate: 4px 0;    scale: 2.6 0.4; }
    14% { opacity: 0; }
    28% { opacity: 1;   translate: -5px 1px; scale: 0.5 1.9; }
    42% { opacity: 0.3; translate: 3px -2px; scale: 1.7 1; }
    57% { opacity: 1;   translate: -2px 0;   scale: 1 0.3; }
    71% { opacity: 0; }
    85% { opacity: 1;   translate: 1px 1px;  scale: 1.3 1; }
}
/* the word: jumps sideways, cut into slices, flickers */
@keyframes label-glitch{
    0%  { left: 5px;  clip-path: inset(0 0 55% 0); }
    18% { left: -4px; clip-path: inset(45% 0 0 0); }
    36% { opacity: 0; }
    50% { opacity: 1; left: 2px;  clip-path: inset(20% 0 35% 0); }
    68% { left: -1px; clip-path: inset(0 0 0 30%); }
    84% { opacity: 0.4; left: 0;  clip-path: none; }
}

/* TITLE GLITCH ON PREVIOUS / NEXT (js/project-nav.js): the project title in the nav
   glitches out on the old page and the new title glitches in on the new one
   (the same glitch as opening / closing the dropdown, see "TITLE GLITCH" at the top) */
html.title-leave .nav .swap-new{
    animation: title-glitch-out 0.4s steps(1) both;
}
html.title-arrive .nav .swap-new{
    animation: title-glitch-in 0.4s steps(1) both;
}

/* ---------- PHONE (600px wide or less) ---------- */
/* SOUND / MUTE and EN / DE move to the bottom corners - the same distance from the edges
   as at the top on a big screen (15px from the edge, 10px from the side) */
@media (max-width: 600px){
    .sound-toggle,
    .lang-toggle{
        top: auto;
        bottom: 15px;
    }
}

/* PHONE: the project pages' images are never next to each other - always one below the other,
   the full width (10px from the page edges, like on a big screen), 150px apart
   (and 150px above the first and below the last) */
@media (max-width: 600px){
    .gallery,
    .gallery.rows{
        grid-template-columns: 1fr;
        grid-template-areas: none;
        row-gap: 150px;
        padding: 150px 10px;
    }
    .gallery > *,
    .gallery .single,
    .gallery .full,
    .gallery .half,
    .gallery .third{
        grid-column: 1 / -1;
        grid-area: auto;
    }
    .gallery img,
    .gallery video{
        width: 100%;
        max-height: none;            /* the full width, however tall that makes it */
    }
    /* groups of images (STEPS, the video grid): also one below the other, 150px apart */
    .gallery .steps,
    .gallery .video-grid{
        grid-template-columns: 1fr;
        gap: 150px;
    }
    .gallery .steps .top-left,
    .gallery .steps .bottom-left,
    .gallery .steps .bottom-right{
        grid-column: 1;
        grid-row: auto;
    }
    .video-crop{
        max-height: none;
    }
    /* PAIR: also one below the other */
    .gallery .pair{
        flex-direction: column;
        gap: 150px;
        max-width: none;
    }
    .gallery .pair > *{
        flex: none;
        width: 100%;
    }
}

/* ---------- LINK IN A TEXT (e.g. "Fachklasse Grafik Luzern" on about.html) ----------
   <a class="text-link" href="https://..." target="_blank" rel="noopener">...</a>
   same colour as the text, thin underline, flickers on hover like INSTAGRAM */
.text-link{
    color: inherit;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.15em;
}
.text-link:focus-visible{
    outline: 1px solid currentColor;
}
@media (hover: hover){
    .text-link:hover{
        animation: flicker 0.2s steps(1) infinite;
    }
}
