/* ------------------------------------------------------------------ *
 * Tokens — change the look here
 * ------------------------------------------------------------------ */
:root {
  --bg: #f4f2ee;            /* overridable via background: in content/site.txt */
  --fg: #1b1a18;
  --muted: #85817a;
  --line: rgba(0, 0, 0, .12);
  --font: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --text-size: 13px;
  --pad: 16px;              /* page side gutter */
  --gap-x: 16px;            /* horizontal space between tiles */
  --gap-y: 20px;            /* vertical space between rows */
  --header-h: 64px;
  --cols: 2;                /* tiles per row, "medium" grid (mobile) */
}
@media (min-width: 760px)  { :root { --pad: 28px; --gap-x: 32px; --gap-y: 32px; --cols: 3; --text-size: 13px; } }
@media (min-width: 1200px) { :root { --cols: 4; --gap-x: 48px; --gap-y: 40px; } }
@media (min-width: 1700px) { :root { --cols: 5; } }

/* ------------------------------------------------------------------ *
 * Base
 * ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 var(--text-size)/1.45 var(--font);
  letter-spacing: .01em;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--muted); }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, p { font-size: inherit; font-weight: inherit; margin: 0; }
main { flex: 1; padding: 0 var(--pad); }
:focus-visible { outline: 1px solid var(--fg); outline-offset: 3px; }

/* ------------------------------------------------------------------ *
 * Header / footer
 * ------------------------------------------------------------------ */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1em;
  padding: 20px var(--pad);
  min-height: var(--header-h);
}
.site-nav { display: flex; gap: 1.4em; }
.site-nav .lang { color: var(--muted); }
.site-nav .lang:hover { color: var(--fg); }

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: .5em 1.4em;
  padding: 80px var(--pad) 24px;
  color: var(--muted);
}

/* ------------------------------------------------------------------ *
 * Long-edge grid
 *
 * Every tile sits in a square slot. The image's LONG edge always equals
 * the slot width, no matter if it's portrait or landscape:
 *   landscape (r > 1): width = 100%,      height = 100% / r
 *   portrait  (r < 1): width = 100% * r,  height = 100%
 * --r (width / height) is written into the HTML by the build script,
 * so space is reserved before the image loads (no jumping layout).
 * ------------------------------------------------------------------ */
.grid {
  --c: var(--cols);
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(var(--c), minmax(0, 1fr));
  gap: var(--gap-y) var(--gap-x);
}
.grid--small { --c: calc(var(--cols) + 1); }
.grid--large { --c: max(1, calc(var(--cols) - 1)); }

.frame {
  display: flex;
  align-items: flex-end;        /* images sit on a common baseline */
  justify-content: center;
  aspect-ratio: 1 / 1;
}
.grid .frame img {
  width: calc(100% * min(1, var(--r)));
  height: auto;
  aspect-ratio: var(--r);
  background: rgba(0, 0, 0, .04);
}
/* only the visible image reacts to the mouse, not the empty part of its square slot */
.grid a { pointer-events: none; }
.grid a img, .grid a.tile-caption { pointer-events: auto; }
.grid a img:hover, .stack a:hover img { opacity: .88; }
.grid img { transition: opacity .2s; }

.tile { display: flex; flex-direction: column; }
.tile-caption { display: flex; flex-direction: column; padding-top: 10px; text-align: center; }
.tile-meta { color: var(--muted); }

.page-home main { padding-top: 24px; }

/* ------------------------------------------------------------------ *
 * Project pages
 * ------------------------------------------------------------------ */
.project-head { padding: 40px 0 56px; max-width: 40em; }
.project-head h1 { font-size: inherit; }
.project-meta { color: var(--muted); }

.block { margin-bottom: 96px; }
.block-title { margin-bottom: 24px; }
.block-text, .block-credits { max-width: 40em; }
.block-text p + p, .block-credits p + p { margin-top: 1em; }
.block a, .page a { text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }

/* stack: images one after another, long-edge sized, centred */
.stack { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 64px; }
.stack .item { width: 100%; display: flex; flex-direction: column; align-items: center; }
.stack .thumb { width: 100%; display: flex; justify-content: center; }
.stack .frame { display: contents; }
.stack img {
  /* long edge = --le, but never taller than the screen */
  --le: min(var(--stack-le), calc((100svh - var(--header-h) - 40px) * max(1, var(--r))));
  width: calc(var(--le) * min(1, var(--r)));
  aspect-ratio: var(--r);
  height: auto;
}
.stack--small  { --stack-le: min(100%, 520px); }
.stack--medium { --stack-le: min(100%, 860px); }
.stack--large  { --stack-le: min(100%, 1300px); }
.stack--full   { --stack-le: 100%; }
.stack figcaption { padding-top: 10px; color: var(--muted); }

/* ------------------------------------------------------------------ *
 * Video (Vimeo loads only after click: no cookies, no tracking before)
 * ------------------------------------------------------------------ */
.video { margin: 0 auto; width: min(100%, calc((100svh - var(--header-h) - 60px) * var(--r))); }
.video--small  { max-width: 640px; }
.video--medium { max-width: 960px; }
.video--large  { max-width: 1400px; }
.video-box { position: relative; aspect-ratio: var(--r); background: var(--bg); overflow: hidden; }
.video-box > *, .video-box img { position: absolute; inset: 0; width: 100%; height: 100%; }
/* overscan the player by 2px so no dark hairline shows at the edges */
.video-box iframe { inset: -2px; width: calc(100% + 4px); height: calc(100% + 4px); }
.video-box img { object-fit: cover; }
.video-play { display: block; }
.play-icon {
  position: absolute; left: 50%; top: 50%;
  width: 64px; height: 64px; margin: -32px 0 0 -32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .9);
  transition: transform .2s, background .2s;
}
.play-icon::after {
  content: ""; position: absolute; left: 26px; top: 21px;
  border-style: solid; border-width: 11px 0 11px 17px;
  border-color: transparent transparent transparent #111;
}
.video-play:hover .play-icon { transform: scale(1.06); background: #fff; }
.video-missing span { position: absolute; inset: auto 0 12px; text-align: center; color: #fff; }
.video figcaption { padding-top: 10px; color: var(--muted); }

/* intro: title + credits left, video right (video block with "align: right").
   Mobile: one column, video below. Desktop: two columns, the video fills the right one. */
.intro { display: grid; gap: 40px 48px; align-items: start; padding-top: 40px; margin-bottom: 96px; }
.intro .project-head { padding-top: 0; }
.intro .block { margin-bottom: 40px; }
.intro .block:last-child { margin-bottom: 0; }
@media (min-width: 1000px) {
  .intro { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1.05fr); }
}

/* ------------------------------------------------------------------ *
 * Viewer: grid disappears, large image takes its place, nav stays
 * ------------------------------------------------------------------ */
.viewer[hidden] { display: none; }
body.is-viewing main, body.is-viewing .site-footer { display: none; }
body.is-viewing { height: 100svh; min-height: 360px; }
.viewer {
  flex: 1;
  min-height: 0;               /* lets the stage shrink to the screen */
  display: flex;
  flex-direction: column;
  padding: 0 var(--pad) 16px;
}
.viewer-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.viewer-img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; transition: opacity .15s; }
.viewer-img.is-loading { opacity: .4; }
.viewer-prev, .viewer-next { position: absolute; top: 0; bottom: 0; width: 40%; }
.viewer-prev { left: 0;  cursor: w-resize; }
.viewer-next { right: 0; cursor: e-resize; width: 60%; }
.viewer-bar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 1.4em;
  align-items: baseline;
  padding-top: 14px;
}
.viewer-caption { color: var(--fg); min-width: 0; }
.viewer-count { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ *
 * Text pages
 * ------------------------------------------------------------------ */
.page-text main { max-width: calc(40em + 2 * var(--pad)); }
.notfound { padding: 40px 0; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* "align: left" on an image or video block: aligned to the text column instead of centred */
.block--left .stack, .block--left .stack .item { align-items: flex-start; }
.block--left .stack .thumb { justify-content: flex-start; }
.block--left .video { margin-left: 0; }
