/* Roboto Mono (Google, SIL Open Font License), served with the site: no request to anyone else */
@font-face {
  font-family: "Roboto Mono"; font-weight: 300 500; font-display: swap;
  src: url("../fonts/roboto-mono-latin.woff2") format("woff2");
}

:root {
  --d: 260ms;
  --ease: cubic-bezier(.7, 0, .2, 1);
  --ink: #111;
  --paper: #fff;
  --grey: #999;
  --faint: #c4c4c4;
  --rule: #e6e6e6;
  --strip: 26px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); }
body {
  font: 300 12px/1.55 "Roboto Mono", ui-monospace, Menlo, monospace;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; }

/* ---------- layout ---------- */
.site { display: flex; height: 100vh; overflow: hidden; }
.col {
  position: relative; min-width: 0; padding: 20px 22px;
  border-right: 1px solid var(--rule); overflow: hidden;
  transition: flex-grow var(--d) var(--ease), flex-basis var(--d) var(--ease), padding var(--d) var(--ease);
}
.col:last-child { border-right: 0; }
/* widths 3 : 6 : 9 (index : text : drawings), padding included: each column starts at its share
   of the full width. Space freed by a shut column is shared out 3 : 6 : 9 again */
.col[data-col="index"] { flex: 3 1 calc(100% * 3 / 18); }
.col[data-col="text"] { flex: 6 1 calc(100% * 6 / 18); }
.col[data-col="drawings"] { flex: 9 1 calc(100% * 9 / 18); }
/* the drawings sit on black; the column's own text and bars turn light */
.col[data-col="drawings"] { background: var(--ink); color: var(--paper); }
.col[data-col="drawings"] .bar { background: var(--paper); color: var(--ink); }
.col[data-col="drawings"].white { background: var(--paper); color: var(--ink); }
.col[data-col="drawings"].white .bar { background: var(--ink); color: var(--paper); }
/* a page made pitch black in the editor */
.col[data-col="drawings"].black { background: #000; }
/* an inverted menu (photography): ink and paper swap inside the index column, so its text,
   boxes, name animation and mode squares all turn round together */
.col[data-col="index"].invert { --ink: #fff; --paper: #111; background: var(--paper); color: var(--ink); }
.col .body { height: 100%; transition: opacity calc(var(--d) * .5) linear; }
.col[data-col="text"] .body, .col[data-col="index"] .body { overflow-y: auto; scrollbar-width: none; }
/* the bars start 5px left of the text; give them room inside the scroll box */
.col[data-col="text"] .body, .col[data-col="index"] .body { margin-left: -6px; padding-left: 6px; }
.col[data-col="drawings"] .body { overflow-y: auto; }

.col.shut { flex-grow: 0; flex-basis: var(--strip); padding-left: 0; padding-right: 0; cursor: pointer; }
/* a shut column keeps its place: index, text, drawings never change order */
.col.shut { flex-shrink: 0; }
.col.shut .body { opacity: 0; pointer-events: none; }
.col .lab {
  position: absolute; top: 48px; left: 0; width: var(--strip);
  display: flex; justify-content: center; color: var(--grey);
  opacity: 0; pointer-events: none; transition: opacity var(--d) linear;
}
.col .lab span { writing-mode: vertical-rl; letter-spacing: .1em; white-space: nowrap; }
.col.shut .lab { opacity: 1; }

/* collapse toggle: grows, no swoosh */
.tg {
  position: absolute; top: 14px; right: 10px; z-index: 3;
  width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
  font-size: 15px; cursor: pointer; transition: transform var(--d) var(--ease);
}
.tg:hover { transform: scale(1.8); }
.tg[hidden] { display: none; }
.col.shut .tg { right: 4px; }

/* ---------- swoosh on clickable text ---------- */
.sw {
  position: relative; display: inline-block; padding: 1px 5px; margin: 1px 0 1px -5px;
  color: var(--ink); cursor: pointer; isolation: isolate;
  transition: color calc(var(--d) * .6) linear;
}
.sw::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background: var(--ink);
  transform: scaleX(0); transform-origin: right;
  transition: transform var(--d) var(--ease);
}
.sw:hover, .sw.on { color: var(--paper); }
.sw:hover::before { transform: scaleX(1); transform-origin: left; }
.sw.on::before { transform: scaleX(1); }
/* in slideshow or shuffle: only the category of the drawing on screen gets the black box */
.sw.here { color: var(--paper); }
.sw.here::before { transform: scaleX(1); }
.ix-cats.browsing .sw.on:not(.here):not(:hover) { color: var(--ink); }
.ix-cats.browsing .sw.on:not(.here):not(:hover)::before { transform: scaleX(0); }
.ix-cats.browsing .sw.on:not(.here):not(:hover) .n { color: var(--faint); }
.sw.here .n { color: var(--grey); }
/* the name: one black box per word, each drawn in 140 ms, the next starting when the one before
   is done. The text stays black, so once covered only the boxes are left. Always one line. */
.ix-name { white-space: nowrap; }
/* in a narrow index column the name shrinks to stay whole on its one line, clear of the "–":
   18 letters of 0.6em plus about 24px of box padding and gaps, the rest kept for the toggle */
.col[data-col="index"] .body { container-type: inline-size; }
.ix-name .sw.words { font-size: min(1em, calc((100cqw - 48px) / 10.8)); }
.sw.words { padding: 1px 0; margin-left: -3px; white-space: nowrap; }
.sw.words::before { display: none; }
.sw.words .w { position: relative; display: inline-block; padding: 1px 3px; isolation: isolate; }
.sw.words .w + .w { margin-left: 3px; }
.sw.words .w::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background: var(--ink);
  transform: scaleX(0); transform-origin: right;
  transition: transform 140ms linear calc(var(--i) * 140ms);
}
.sw.words:hover { color: var(--ink); }
.sw.words:hover .w::before { transform: scaleX(1); transform-origin: left; }
/* clicked: the letters come back, white in the black boxes */
.sw.words .w { transition: color 140ms linear; }
.sw.words.shown .w { color: var(--paper); }
.sw.words.shown .w::before { transform: scaleX(1); transition: none; }

.sw .n { color: var(--faint); margin-left: .5em; transition: color calc(var(--d) * .6) linear; }
.sw:hover .n, .sw.on .n { color: var(--grey); }

/* ---------- cursor: a black square everywhere ---------- */
*, *::before, *::after { cursor: none !important; }
.sq {
  position: fixed; left: 0; top: 0; z-index: 200; pointer-events: none;
  width: 10px; height: 10px; mix-blend-mode: difference; /* black on paper, white on black */
  opacity: 0; transition: opacity 120ms linear;
}
/* the visible square; scaled around its centre (half size over the menu) */
.sq::before {
  content: ""; position: absolute; inset: 0; background: #fff;
  transform: scale(var(--s, 1)); transition: transform var(--d) var(--ease);
}
.sq.show { opacity: 1; }

/* ---------- cover: the emblem of the print cover, before the site ---------- */
.cover {
  position: fixed; inset: 0; z-index: 150; background: var(--paper); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 140ms linear;
}
.cover[hidden] { display: none; }
/* entering: the lines fly out sideways, alternating (name right, TUM left, EPFL right, email
   left), then the white page fades into the site */
.cover { --out: 700ms; }
.cover.gone { opacity: 0; pointer-events: none; transition-delay: var(--out); }
.emblem .ln { transition: transform var(--out) var(--ease); }
.cover.gone .ln:nth-child(odd) { transform: translateX(100vw); }
.cover.gone .ln:nth-child(even) { transform: translateX(-100vw); }
.cover:focus { outline: none; }
/* every line justified edge to edge over one width, like the print; the font is sized so the
   longest line (École Polytechnique Fédérale de Lausanne, 40 letters) fits */
.emblem { --ew: min(640px, 86vw); width: var(--ew); font-size: calc(var(--ew) / 25); font-weight: 400; line-height: 1.12; }
.emblem .ln { margin: 0; text-align: justify; text-align-last: justify; }
.emblem .name { background: var(--ink); color: var(--paper); }

/* ---------- index ---------- */
.ix-name { margin-bottom: 28px; }
.ix-list { list-style: none; margin: 0; padding: 0; }
.ix-list > li { margin: 0; }
.ix-modes { list-style: none; margin: 2px 0 8px 16px; padding: 0; }
/* a mode: its symbol sits in a square as tall as the hover bar, at the left of the entry.
   Picked, only that square is black; hovering a picked mode, the bar starts at the square's
   right edge, so square and bar read as one. Not picked, the bar covers the square too. */
.sw.mode { --mw: calc(1.5em + 8px); padding-left: calc(var(--mw) + .5em); }
.sw.mode .mib {
  position: absolute; left: 0; top: 0; bottom: 0; width: var(--mw);
  display: flex; align-items: center; justify-content: center;
}
.sw.mode .mi { margin: 0; vertical-align: 0; }
.sw.mode.on:not(:hover) { color: var(--ink); }
.sw.mode.on:not(:hover)::before { transform: scaleX(0); }
.sw.mode.on::before { left: var(--mw); }
.sw.mode.on .mib { background: var(--ink); color: var(--paper); }
/* the mode symbols: short arrow (diashow), crossing arrows (shuffle) */
.mi { width: 1.5em; height: .85em; margin-right: .6em; vertical-align: -.05em;
  fill: none; stroke: currentColor; stroke-width: 1.2; overflow: visible; }
.mi path { vector-effect: non-scaling-stroke; } /* same line weight at any icon size */
.ix-cats { list-style: none; margin: 2px 0 6px 32px; padding: 0; } /* a step further in than the modes */
.ix-cv { margin-top: 28px; }

/* ---------- text ---------- */
.tx-title { font-weight: 400; font-size: 20px; line-height: 1.2; margin: 0 0 6px; letter-spacing: .01em; }
.bar { display: inline-block; background: var(--ink); color: var(--paper); padding: 1px 5px; margin: 0 0 14px; }
.tx-meta { color: var(--grey); margin: 0 0 2px; }
.tx-body { margin-top: 22px; }
.tx-body p { margin: 0 0 1em; max-width: 46ch; }
/* concept: paragraphs with their diagrams beside them, zigzagging like the print page */
.tx-body.concept p { max-width: none; text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
.cx-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: center; margin: 0 0 2.2em; }
.cx-row p { margin: 0; }
.cx-row.flip .cx-fig { order: -1; }
.cx-fig { margin: 0; }
.cx-fig img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
/* rows of images after a paragraph: one height across the row, as in the print layout */
.cx-imgs { display: flex; gap: 14px; margin: 1.6em 0 2.2em; align-items: flex-start; }
.cx-imgs .cx-fig { flex: var(--a) 1 0; min-width: 0; }
.cx-fig figcaption { color: var(--grey); padding-top: 6px; line-height: 1.4; }
/* a narrow concept column: each diagram goes under its paragraph, so the text keeps a
   readable width (side by side needs about 2 x 26 letters) */
.col[data-col="text"] .body { container-type: inline-size; }
@container (max-width: 400px) {
  .cx-row { grid-template-columns: 1fr; gap: 1em; }
  .cx-row.flip .cx-fig { order: 0; }
  .cx-row .cx-fig { width: 75%; }
  /* rows of three or more images go two by two; shorter rows keep their shapes */
  .cx-imgs:has(> .cx-fig:nth-child(3)) { flex-wrap: wrap; }
  .cx-imgs:has(> .cx-fig:nth-child(3)) .cx-fig { flex: 1 1 40%; }
}

/* ---------- drawings ---------- */
.slides { position: relative; height: 100%; overflow: hidden; }
/* quick clicks are double / triple clicks: never let them select (Safari tints selected images blue) */
.slides, .slides * { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.track { height: 100%; }
.slide { margin: 0; min-width: 0; height: 100%; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.slide figcaption { color: var(--grey); padding-top: 8px; min-height: calc(1.55em + 8px); padding-right: 8ch; }

/* the whole drawing always fits the column */
.pic { position: relative; min-height: 0; display: flex; align-items: center; justify-content: center; }
.pic img {
  display: block; max-width: var(--fit, 100%); max-height: var(--fit, 100%); width: auto; height: auto;
  -webkit-user-drag: none;
}

/* a print page: an A4-shaped area as large as the column allows, drawings placed as in InDesign,
   straight on the black (no white sheet) */
.pic { container-type: size; }
.sheet {
  position: relative; flex: none;
  --a: var(--ar, calc(210 / 297)); width: min(100cqw, 100cqh * var(--a)); aspect-ratio: var(--a);
}
.sheet .item { position: absolute; overflow: hidden; visibility: hidden; }
.sheet .item.on { visibility: visible; } /* appears at once, like the slides */
.sheet .item img { position: absolute; max-width: none; max-height: none; }

/* a drawing category: horizontal slides */
/* no animation: a click shows the next drawing at once. Slides off screen are skipped by the
   browser (content-visibility); slides.js decodes the ones ahead before they are needed */
.row .track { display: flex; }
/* a drawing sits at --px / --py of the free room in its column (the middle without them) */
.row .slide:not(.page) .pic > img {
  position: absolute; left: calc(var(--px, .5) * 100%); top: calc(var(--py, .5) * 100%);
  transform: translate(calc(var(--px, .5) * -100%), calc(var(--py, .5) * -100%));
}
.row .slide { flex: 0 0 100%; content-visibility: auto; contain-intrinsic-size: auto 100vw auto 100vh; }

/* shuffle: each click lays a random drawing on top; the ones before stay underneath */
.shuffle .track { position: relative; }
.shuffle .slide {
  position: absolute; inset: 0;
  opacity: 0; transform: translateX(28px); pointer-events: none; visibility: hidden;
  transition: opacity var(--d) var(--ease), transform var(--d) var(--ease), visibility 0s linear var(--d);
}
.shuffle .slide.under, .shuffle .slide.top { opacity: 1; transform: none; visibility: visible; transition-delay: 0s; }
.shuffle .slide.under figcaption { visibility: hidden; }
/* each shuffled drawing lands smaller, somewhere in the column (--x --y --w --h from slides.js) */
.shuffle .slide { display: block; --cap: 27px; }
.shuffle .pic {
  position: absolute;
  left: calc(var(--x, 0) * 100%); width: calc(var(--w, 1) * 100%);
  top: calc(var(--y, 0) * (100% - var(--cap))); height: calc(var(--h, 1) * (100% - var(--cap)));
}
.shuffle figcaption {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--cap); min-height: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* prev/next buttons: kept for keyboard and screen readers; mouse users get the cursor */
.nav {
  position: absolute; bottom: 0; z-index: 2; padding: 0 6px; background: var(--ink); color: var(--paper);
  clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden;
}
.nav.prev { left: 0; }
.nav.next { left: 40px; }
.shuffle .nav.next { left: 0; }
.nav[hidden] { display: none; }
.nav:focus-visible { clip-path: none; width: auto; height: auto; }
.count { position: absolute; right: 0; bottom: 0; color: var(--grey); line-height: 1.55; }

/* zoomed into a drawing (zoom.js): it takes the whole column; the sharp part lies over the picture */
.slides { touch-action: pan-x pan-y; }
.slides.zoomed { touch-action: none; }
.slides.zoomed figcaption, .slides.zoomed .count { visibility: hidden; }
canvas.sharp { position: absolute; pointer-events: none; }

/* drawings cursor: a big thin arrow left / right, the shuffle icon in shuffle */
.cur {
  position: fixed; left: 0; top: 0; width: 0; height: 0; pointer-events: none; z-index: 100;
  mix-blend-mode: difference; opacity: 0; transition: opacity 120ms linear;
}
.cur.show { opacity: 1; }
.cur svg {
  position: absolute; fill: none; stroke: #fff; stroke-width: 1.5; opacity: 0;
  transition: opacity calc(var(--d) * .6) linear, transform var(--d) var(--ease);
}
.cur .ar { width: 72px; height: 26px; left: -36px; top: -13px; }
.cur .sh { width: 40px; height: 30px; left: -20px; top: -15px; }
.cur.prev .ar { opacity: 1; }
.cur.next .ar { opacity: 1; transform: rotate(180deg); }
.cur.shuffle .sh { opacity: 1; }

/* ---------- cv ---------- */
.cv-photo { width: 100%; max-width: 260px; display: block; margin: 6px 0 16px; filter: grayscale(1); }
.cv-photo.color { filter: none; }
.cv-sec { margin: 0 0 30px; max-width: 640px; }
.cv-sec .bar { margin-bottom: 10px; }
.cv-row { display: grid; grid-template-columns: 17ch 1fr; gap: 12px; padding: 2px 0; }
.cv-row .when { color: var(--grey); }

/* ---------- smaller screens ---------- */
/* below 1000px: same three columns, tighter */
@media (max-width: 999px) {
  .col { padding: 16px 14px; }
  .tx-title { font-size: 17px; }
  .ix-name { margin-bottom: 20px; }
}
/* below 640px: the columns stack, index on top; the page scrolls */
@media (max-width: 639px) {
  .site { flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }
  .col {
    flex: none !important; padding: 16px; border-right: 0; border-bottom: 1px solid var(--rule);
  }
  .col .body { height: auto; }
  .col[data-col="text"] .body, .col[data-col="index"] .body { overflow: visible; }
  .col[data-col="drawings"] { height: 80vh; min-height: 360px; border-bottom: 0; }
  .col[data-col="drawings"] .body { height: 100%; }
  /* a shut column is a 26px band with its name written across */
  .col.shut { height: var(--strip); min-height: 0; padding: 0 16px; }
  .col .lab { top: 0; left: 16px; width: auto; height: var(--strip); align-items: center; }
  .col .lab span { writing-mode: horizontal-tb; }
  .col .tg, .col.shut .tg { top: 4px; right: 10px; }
}
