/* Layout: full-bleed film behind everything; type sits in the corners like a title card. */
:root {
  --ts: 1.1;              /* text size: 1 = original, 1.1 = 10% bigger */
  --ink: #0d0c0b;          /* ground behind the film */
  --paper: #ede7dc;        /* all text, warm off-white */
  --dim: rgba(237, 231, 220, 0.5);
  --faint: rgba(237, 231, 220, 0.18);
  --veil: rgba(13, 12, 11, 0.62);
  --split: cubic-bezier(0.5, 0.25, 0, 1);  /* slow start, long soft stop */
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --gx: max(20px, env(safe-area-inset-left, 0px));
  --gr: max(20px, env(safe-area-inset-right, 0px));
  --gt: calc(18px + env(safe-area-inset-top, 0px));
  --gb: calc(18px + env(safe-area-inset-bottom, 0px));
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font: 300 calc(15px * var(--ts))/1.45 var(--serif);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button {
  font: inherit; color: inherit; background: none; border: 0; padding: 0;
  cursor: pointer; text-align: left;
}
button:focus-visible, a:focus-visible { outline: 1px solid var(--paper); outline-offset: 3px; }
a { color: inherit; }

/* ── Film layer ─────────────────────────────── */
#stage { position: fixed; inset: 0; overflow: hidden; }
/* Sizing. --pw/--ph is the box the film's picture fills.
   In a normal window it covers the whole page (edges trimmed as needed).
   In Fullscreen it fits inside the screen, so the whole frame shows.
   --R is the picture's shape; --F is the video file's shape, which differs
   only when the file has black bars built in (Scope, Saso): the file is then
   sized larger so its bars fall outside the page. */
.layer {
  position: absolute; inset: 0;
  opacity: 0; transition: opacity 550ms cubic-bezier(0.4, 0, 0.2, 1);
  --R: var(--ratio, 1.7778);
  --F: var(--frame, var(--R));
  --pw: max(100vw, calc(100vh * var(--R)));
  --ph: calc(var(--pw) / var(--R));
}
:root:fullscreen .layer { --pw: min(100vw, calc(100vh * var(--R))); }
:root:-webkit-full-screen .layer { --pw: min(100vw, calc(100vh * var(--R))); }
/* Fullscreen: pure black around a film that isn't 16:9 */
:root:fullscreen, :root:fullscreen body, :root:fullscreen #stage,
:root:fullscreen .layer, :root:fullscreen::backdrop { background: #000; }
:root:-webkit-full-screen, :root:-webkit-full-screen body, :root:-webkit-full-screen #stage,
:root:-webkit-full-screen .layer { background: #000; }
.layer.in { opacity: 1; }
/* Hovering between projects: a crossfade. The new one eases in while the
   old one eases out over the same half second, then the old one is removed. */
.layer.xfade { transition: opacity 500ms cubic-bezier(0.22, 0.61, 0.36, 1); }
.layer.out, .layer.in.out, .layer.split.out {
  opacity: 0;
  transition: opacity 500ms cubic-bezier(0.55, 0.06, 0.68, 0.19);
}
/* Opening a film: it parts from a vertical line in the middle of the screen */
.layer.split {
  opacity: 1;
  clip-path: inset(0 50% 0 50%);
  transition: clip-path 1.1s var(--split);
}
.layer.split.in { clip-path: inset(0 0 0 0); }
.layer.behind { filter: brightness(0.35); transition: opacity 900ms ease, filter 1s ease; }
/* The still is cropped to the picture, so it fills the picture box exactly. */
.layer img {
  position: absolute; top: 50%; left: 50%;
  width: var(--pw); height: var(--ph);
  transform: translate(-50%, -50%);
  object-fit: cover; display: block;
}
/* Once the video is playing, the still is hidden so there's never a double */
.layer.playing img { visibility: hidden; }
/* The video file's box: the picture box, grown to the file's own shape when
   the file has bars, so the picture inside lands exactly on the still. */
.layer iframe,
.layer video {
  position: absolute; top: 50%; left: 50%;
  width: max(var(--pw), calc(var(--ph) * var(--F)));
  height: max(var(--ph), calc(var(--pw) / var(--F)));
  transform: translate(-50%, -50%);
  display: block;
}
.layer iframe {
  border: 0; pointer-events: none;
  opacity: 0; transition: opacity 600ms ease;
}
/* The video appears the instant it starts playing; the still underneath is
   lined up with it exactly, so the swap from still to video is invisible. */
.layer video { object-fit: cover; opacity: 0; }
.layer iframe.ready, .layer video.ready { opacity: 1; }
.scrim {
  position: fixed; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(13,12,11,.45) 0%, rgba(13,12,11,0) 55%),
    linear-gradient(180deg, rgba(13,12,11,.45) 0%, rgba(13,12,11,0) 38%),
    linear-gradient(0deg, rgba(13,12,11,.5) 0%, rgba(13,12,11,0) 40%);
  transition: background-color 400ms ease;
}
body.reading .scrim { background-color: rgba(13,12,11,.35); }

/* ── Small type everywhere ──────────────────── */
.views button, .filters button, .meta, .credits dt, .now, .steps button, .close, .play, .archive th {
  font-family: var(--mono);
  font-size: calc(11px * var(--ts));
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── Top-left navigation ────────────────────── */
.top {
  position: fixed; top: 0; left: 0; z-index: 7; /* above the About/Archive veil so you can always click back */
  padding: var(--gt) var(--gr) 0 var(--gx);
}
.views { display: flex; gap: 22px; }
.views button { color: var(--dim); transition: color 200ms; }
.views button:hover, .views button.on { color: var(--paper); }

/* ── Centre name ────────────────────────────── */
.mark {
  position: fixed; top: 50%; left: 50%; z-index: 5; margin: 0; /* above the project list so it stays clickable */
  transform: translate(-50%, -50%);
  font-family: var(--mono); font-size: calc(12px * var(--ts)); letter-spacing: 0.32em; text-transform: uppercase;
  white-space: nowrap; cursor: pointer; /* clicking the name opens About */
  display: flex; gap: 0.9em;
  transition: opacity 400ms;
}
.mark:hover { opacity: 0.6; }
body.reading .mark, body.watching .mark { pointer-events: none; }
.mark.one-word { gap: 0; } /* "MARQ" + "EZZI" read as one word at rest */
.mark span { display: block; transition: transform 1.1s var(--split), opacity 700ms ease; }
body.reading .mark { opacity: 0; }
/* The name halves slide apart as the film opens, then come back on Back */
body.watching .mark #name-a { transform: translateX(-38vw); opacity: 0; }
body.watching .mark #name-b { transform: translateX(38vw); opacity: 0; }

/* ── Projects index ─────────────────────────── */
.index {
  position: fixed; z-index: 4;
  top: calc(var(--gt) + 34px); left: 0;
  padding-left: var(--gx); padding-right: var(--gr);
  max-width: 100%;
  transition: opacity 300ms;
}
body.reading .index { opacity: 0; pointer-events: none; }
.filters { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 20px; }
.filters button { color: var(--dim); }
.filters button:hover, .filters button.on { color: var(--paper); }
.list { list-style: none; margin: 0; padding: 0; }
.list button {
  display: grid; grid-template-columns: minmax(9rem, 13rem) minmax(0, 12rem);
  gap: 24px; width: 100%;
  padding: 1px 0;
  color: var(--paper);
  transition: opacity 200ms;
}
.list:hover button { opacity: 0.4; }
.list:hover button:hover, .list button:focus-visible { opacity: 1; }
/* Phones: while a finger slides over the list, light up the title under it */
.list.scrubbing button { opacity: 0.4; }
.list.scrubbing button.scrub { opacity: 1; }
.list .t { font-size: calc(17px * var(--ts)); }
.list .c { font-style: italic; color: var(--dim); font-size: calc(15px * var(--ts)); padding-top: 2px; }
.list li.out { display: none; }
.list li.empty { font-style: italic; color: var(--dim); font-size: calc(17px * var(--ts)); }

/* ── Now showing (bottom right) ─────────────── */
.now {
  position: fixed; right: 0; bottom: 0; z-index: 3; margin: 0;
  padding: 0 var(--gr) var(--gb) var(--gx);
  color: var(--dim); text-align: right;
  font-variant-numeric: tabular-nums;
}
body.reading .now { opacity: 0; }

/* ── Panels ─────────────────────────────────── */
.panel { position: fixed; z-index: 6; }

.desc p { margin: 0 0 0.7em; max-width: 34em; font-size: calc(16px * var(--ts)); }

/* ── Film page ──────────────────────────────── */
body.watching .top,
body.watching .index,
body.watching .now { opacity: 0; pointer-events: none; }
.top, .mark, .now { transition: opacity 400ms ease; }
body.watching .scrim { background: transparent; } /* no shading over the film */

.film {
  position: fixed; inset: 0; z-index: 6;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto;
  padding: var(--gt) var(--gr) var(--gb) var(--gx);
  gap: 18px;
  color: var(--paper);
  animation: film-in 600ms ease 550ms both; /* text arrives once the split is mostly open */
  transition: color 300ms ease;
}
@keyframes film-in { from { opacity: 0; } to { opacity: 1; } }

.film-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.film-title { margin: 0; font-weight: 300; font-size: calc(17px * var(--ts)); line-height: 1.3; }
.film-title span:last-child { font-style: italic; }
.film-tabs { display: flex; gap: 22px; flex-shrink: 0; }
.film-tabs button, .film-steps button, .film-controls button, .label {
  font-family: var(--mono); font-size: calc(11px * var(--ts)); letter-spacing: 0.06em; text-transform: uppercase;
}
.film-tabs button { opacity: 1; transition: opacity 200ms; }
.film-tabs button.on { opacity: 0.45; }
.film-tabs button:hover { opacity: 1; }

/* Info and Stills: a dark, blurred veil over the still-playing film, light type on top */
.film-info, .film-stills { grid-row: 2; grid-column: 1; overflow-y: auto; min-height: 0; }
.film-info { max-width: 36rem; display: flex; flex-direction: column; gap: 14px; padding-top: 10px; }
.film-year { margin: 0; font-variant-numeric: tabular-nums; }
.label { margin: 14px 0 0; font-weight: 400; color: var(--dim); }
.film-info .credits dt { color: var(--dim); }
.wash {
  position: fixed; inset: 0; z-index: 5; pointer-events: none;
  background: var(--veil);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  opacity: 0; transition: opacity 400ms ease;
}
body.info .wash,
body.stills .wash { opacity: 1; }

/* Stills: a loose grid of frames */
.film-stills {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 10px; align-content: start; padding-top: 10px;
}
.film-stills img { width: 100%; aspect-ratio: var(--ratio, 1.7778); object-fit: cover; display: block; }

/* Controls fade out when the mouse rests */
.film-controls {
  /* One row across the middle of the screen, over the film */
  grid-row: 2; grid-column: 1; align-self: center; /* shares the cell with Info/Stills */
  display: flex; align-items: center; gap: 24px;
  transition: opacity 500ms ease;
}
.film.idle .film-controls, .film.idle .film-top, .film.idle .film-steps { opacity: 0; }
.film.idle { cursor: none; }
.film-top, .film-steps { transition: opacity 500ms ease; }
body.info .film-controls, body.stills .film-controls { visibility: hidden; }
.ctrl-side { flex: 1; display: flex; justify-content: space-around; gap: 16px; }
.film-controls #f-sound { opacity: 0.45; }
.film-controls #f-sound[aria-pressed="true"] { opacity: 1; }
.progress {
  position: relative; flex: none; width: clamp(140px, 20vw, 400px); height: 15px;
  cursor: pointer; touch-action: none;
}
.progress::before {
  content: ""; position: absolute; left: 0; right: 0; top: 7px; height: 1px;
  background: var(--faint);
}
.progress span {
  position: absolute; left: 0; top: 7px; height: 1px; width: 0;
  background: var(--paper);
}
/* Small upright tick marks where the film is */
.progress span::after {
  content: ""; position: absolute; right: 0; top: -4px; width: 1px; height: 9px;
  background: var(--paper);
}
.film-steps { grid-row: 4; display: flex; justify-content: space-between; gap: 20px; }
.film-steps .pair { display: none; gap: 22px; }
body.info .film-steps .pair,
body.stills .film-steps .pair,
.film:has(#f-controls[hidden]) .film-steps .pair { display: flex; }

.credits {
  display: grid; grid-template-columns: max-content minmax(0, 1fr);
  gap: 3px 22px; margin: 0;
}
.credits dt { color: var(--dim); padding-top: 3px; }
.credits dd { margin: 0; }
.steps { display: flex; gap: 22px; }
.steps button { color: var(--dim); }
.steps button:hover { color: var(--paper); }

/* About + Archive sheets */
.sheet {
  inset: 0; background: var(--veil);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  overflow-y: auto;
  padding: calc(var(--gt) + 46px) var(--gr) var(--gb) var(--gx);
}
.sheet-inner { max-width: 34rem; display: flex; flex-direction: column; gap: 28px; }
.sheet-inner.wide { max-width: 56rem; }
.sheet .desc p { font-size: calc(clamp(19px, 2.4vw, 26px) * var(--ts)); line-height: 1.3; max-width: 26em; }
.close { align-self: flex-start; color: var(--dim); }
.close:hover { color: var(--paper); }

.table-wrap { overflow-x: auto; }
.archive { border-collapse: collapse; width: 100%; min-width: 30rem; font-variant-numeric: tabular-nums; }
.archive th { text-align: left; font-weight: 400; color: var(--dim); padding: 0 16px 10px 0; }
.archive td { padding: 7px 16px 7px 0; border-top: 1px solid var(--faint); vertical-align: top; }
.archive tr[data-slug] { cursor: pointer; }
.archive tr[data-slug]:hover td { color: var(--paper); background: rgba(237,231,220,.05); }
.archive td:nth-child(2) { font-style: italic; font-size: calc(16px * var(--ts)); }
.archive td:nth-child(3), .archive td:nth-child(4) { color: var(--dim); }


/* ── Phones ─────────────────────────────────── */
@media (max-width: 640px) {
  :root { --ts: 1; } /* phones keep the original size */
  body { overflow: auto; }
  .mark { top: auto; bottom: calc(var(--gb) + 6px); left: var(--gx); transform: none; letter-spacing: 0.22em; }
  .now { display: none; }
  .list button { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
  .list .t { font-size: calc(16px * var(--ts)); }
  body.watching { overflow: hidden; }
  .film-top { flex-direction: column; gap: 10px; }
  /* Credits: role on its own line, names underneath, so nothing runs off the edge */
  .credits { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .credits dd { margin-bottom: 12px; overflow-wrap: anywhere; }
  /* Buttons on one line, time bar full width underneath */
  .film-controls { flex-wrap: wrap; justify-content: space-between; gap: 14px 10px; }
  .ctrl-side { display: contents; }
  .progress { order: 3; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .layer, .layer img, .layer iframe, .layer video, .mark span { transition: none; }
  .layer.split { clip-path: none; }
  .film { animation: none; }
}

/* Text for search engines and screen readers only */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* A little space between the English and Spanish About text */
#about-text p[lang="es"]:first-of-type,
#about-text p:not([lang]) + p[lang="es"] { margin-top: 1.4em; }
