/* Project page (project.js). Same tokens, type and rhythm as the home page: hairlines, radius 16,
   big light headings, grey secondary text, numbered sections like the brief form. */

/* until the hero cover is decoded nothing paints, so the browser keeps showing the grown cover from the
   previous page and the switch is invisible (project.js removes the class) */
html.is-pending body { visibility: hidden; animation: p-show 0s 2s forwards; } /* failsafe if JS never runs */
@keyframes p-show { to { visibility: visible; } }

/* ---------- hero: the cover the transition lands on ---------- */
.p-hero { position: relative; height: 100vh; height: 100svh; overflow: hidden; background: #111; color: var(--white); }
.p-hero__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.p-hero::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 180px; pointer-events: none;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0));
}
.p-hero__bar {
  position: absolute; z-index: 1; left: var(--gutter); right: var(--gutter); bottom: 24px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; font-size: 15px;
}
.p-hero__meta { color: rgba(255, 255, 255, 0.78); }
.p-hero__link { justify-self: start; border-bottom: 1px solid currentColor; padding-bottom: 2px; transition: opacity .3s var(--ease); }
.p-hero__link:last-child { justify-self: end; }
.p-hero__link:hover { opacity: .7; }

/* 16:9 projects: the film itself plays in the hero, fading in over the cover once frames move */
.p-hero__film {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); border: 0; pointer-events: none;
  width: max(100vw, 177.78svh); height: max(100svh, 56.25vw);
  opacity: 0; transition: opacity .8s var(--ease);
}
.p-hero.is-playing .p-hero__film { opacity: 1; }
/* a deeper scrim when a moving film sits under the controls and the cue */
.p-hero--film::after { height: 320px; background: linear-gradient(to top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0)); }
.p-hero__ui {
  position: absolute; z-index: 2; left: 0; right: 0; bottom: 0; height: 96px; color: var(--white);
  transition: opacity .5s var(--ease);
}
.p-hero__ui.is-idle { opacity: 0; }
/* touch screens have no mouse to bring it back, and there it sits on the black below the film */
@media (hover: none) { .p-hero__ui.is-idle { opacity: 1; } }
.p-hero__ui .player-bar { grid-template-columns: auto auto 1fr auto auto auto; }
/* the way down to the story sits in the bar and hides with it, so nothing covers the picture */
.p-hero__more { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; }
.p-hero__more svg { width: 9px; height: 15px; overflow: visible; transition: transform .6s var(--ease); }
.p-hero__more path { fill: none; stroke: currentColor; stroke-width: 1.1; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.p-hero__more:hover svg { transform: translateY(3px); }
.p-hero__more:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* there is more below: a quiet line with a light running down it */
.p-cue {
  position: absolute; z-index: 2; left: 50%; bottom: 112px; transform: translateX(-50%);
  display: grid; justify-items: center; gap: 12px; color: var(--white); font-size: 15px;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.5);
  transition: opacity .6s var(--ease);
}
.p-hero:not(.p-hero--film) .p-cue { bottom: 76px; }
.p-cue__line { position: relative; width: 1px; height: 48px; overflow: hidden; background: rgba(255, 255, 255, 0.4); }
.p-cue__line::after {
  content: ""; position: absolute; left: 0; top: 0; width: 1px; height: 40%;
  background: var(--white); animation: p-cue 2.2s var(--ease) infinite;
}
@keyframes p-cue { from { transform: translateY(-100%); } to { transform: translateY(250%); } }
.is-scrolled .p-cue { opacity: 0; pointer-events: none; }
.p-cue:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }

/* ---------- reveal ---------- */
.rv { opacity: 0; transform: translateY(24px); transition: opacity 1s var(--ease), transform 1.2s var(--ease); }
.rv.is-in { opacity: 1; transform: none; }

/* ---------- title, facts, lead ---------- */
.p-head { padding: 16vh var(--gutter) 12vh; }
.p-title { font-size: clamp(56px, 8.4vw, 136px); font-weight: 400; line-height: 0.96; letter-spacing: -0.04em; max-width: 12ch; }
.p-sub { margin-top: 24px; font-size: clamp(22px, 2.2vw, 34px); line-height: 1.2; letter-spacing: -0.015em; color: var(--grey); }
.p-intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 40px; margin-top: 12vh; align-items: start; }
.p-facts { display: grid; }
.p-facts__row { display: grid; grid-template-columns: 6em 1fr; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); font-size: 16px; }
.p-facts__row:last-child { border-bottom: 1px solid var(--line); }
.p-facts dt { color: var(--grey); }
.p-lead { font-size: clamp(22px, 2.2vw, 34px); line-height: 1.3; letter-spacing: -0.015em; max-width: 30ch; transition-delay: .1s; }

/* ---------- film frames ---------- */
.p-film { padding: 0 var(--gutter) 6vh; }
.p-frame {
  position: relative; display: block; width: 100%; overflow: hidden; border-radius: var(--radius);
  background: #111; cursor: pointer; color: var(--white); text-align: left;
}
.p-frame__poster, .p-frame__film { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.p-frame__poster { object-fit: cover; }
.p-frame__film { pointer-events: none; opacity: 0; transition: opacity .8s var(--ease); }
.p-frame.is-live .p-frame__film { opacity: 1; }
.p-frame::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 120px; pointer-events: none;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0));
}
.p-frame__cta {
  position: absolute; z-index: 1; left: 20px; bottom: 18px; font-size: 15px;
  border-bottom: 1px solid currentColor; padding-bottom: 2px; transition: opacity .3s var(--ease);
}
.p-frame:hover .p-frame__cta { opacity: .75; }
.p-frame:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* a 9:16 film stands beside the first chapter instead of being cropped to the page width */
.p-film--tall { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8vw; align-items: center; }
.p-film--tall .p-frame { width: auto; height: min(86vh, 920px); }
.p-film--tall .p-sec { padding: 0; margin: 0; border: 0; grid-template-columns: 1fr; gap: 28px; }

/* ---------- chapters ---------- */
.p-sec {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 40px;
  margin: 0 var(--gutter); padding: 10vh 0; border-top: 1px solid var(--line);
}
.p-film + .p-sec { border-top: 0; }
.p-sec__head { display: grid; gap: 10px; align-content: start; }
.p-sec__num { font-size: 15px; color: var(--grey); font-variant-numeric: tabular-nums; }
.p-sec__title { font-size: clamp(28px, 2.6vw, 40px); font-weight: 400; letter-spacing: -0.025em; line-height: 1.05; }
.p-sec__text { font-size: clamp(18px, 1.35vw, 21px); line-height: 1.55; max-width: 56ch; }
.p-items { list-style: none; display: grid; }
.p-items li {
  display: grid; grid-template-columns: minmax(10em, 1fr) 2fr; gap: 24px; padding: 18px 0;
  border-top: 1px solid var(--line); font-size: 17px; line-height: 1.45;
}
.p-items__v { color: var(--grey); }

/* ---------- stills ---------- */
.p-stills { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 2vh var(--gutter) 8vh; }
.p-still { margin: 0; overflow: hidden; border-radius: var(--radius); background: var(--card); aspect-ratio: 16 / 9; }
.p-still.is-wide { grid-column: 1 / -1; }
.p-still img { width: 100%; height: 100%; object-fit: cover; }
.p-still:nth-child(even) { transition-delay: .1s; }

/* ---------- more films of a series ---------- */
.p-series { padding: 6vh var(--gutter) 10vh; }
.p-series__title { font-size: clamp(28px, 2.6vw, 40px); font-weight: 400; letter-spacing: -0.025em; margin-bottom: 40px; }
.p-series__row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.p-series__row .p-frame:nth-child(2) { transition-delay: .08s; }
.p-series__row .p-frame:nth-child(3) { transition-delay: .16s; }
.p-series__row .p-frame:nth-child(4) { transition-delay: .24s; }

/* ---------- more like this: three related projects as cards (cards.js) ---------- */
.p-related { padding: 10vh var(--gutter) 4vh; border-top: 1px solid var(--line); }
.p-related__head { display: flex; justify-content: space-between; align-items: baseline; gap: 24px; margin-bottom: 48px; }
.p-related__title { font-size: clamp(28px, 2.6vw, 40px); font-weight: 400; letter-spacing: -0.025em; }
.p-related__all { font-size: 15px; border-bottom: 1px solid currentColor; padding-bottom: 2px; transition: color .3s var(--ease); }
.p-related__all:hover { color: var(--accent); }
.p-related__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 24px; row-gap: 56px; }
.p-related .card.is-in, .p-related .card.is-in .card__frame { transform: none; }
.p-related .card__frame { transform: none; }
.p-related .tli { transform: none; }
.p-related .card__title { font-size: clamp(20px, 1.6vw, 26px); }
.p-related .card__year, .p-related .card__tags { font-size: 14px; }
.p-related + .p-next { margin-top: 0; }

/* ---------- next project ---------- */
.p-next { display: grid; gap: 20px; padding: 14vh var(--gutter) 12vh; border-top: 1px solid var(--line); margin-top: 6vh; }
.p-next__label { font-size: 15px; color: var(--grey); }
.p-next__title {
  display: flex; align-items: center; gap: 0.3em;
  font-size: clamp(48px, 7vw, 120px); line-height: 1; letter-spacing: -0.04em;
}
.p-next__title svg { width: 0.9em; height: 0.24em; flex: none; overflow: visible; transition: transform .8s var(--ease); }
.p-next__title path { fill: none; stroke: currentColor; stroke-width: 1.2; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.p-next:hover .p-next__title svg { transform: translateX(0.2em); }
.p-next__frame { display: block; margin-top: 24px; overflow: hidden; border-radius: var(--radius); aspect-ratio: 16 / 9; background: var(--card); }
.p-next__frame img { width: 100%; height: 100%; object-fit: cover; }
.p-next:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }

/* ---------- fullscreen film ---------- */
.pp[hidden] { display: none; }
.pp__stage {
  position: fixed; inset: 0; z-index: 70; background: #000; cursor: pointer;
  opacity: 0; transition: opacity .5s var(--ease);
}
.pp.is-on .pp__stage { opacity: 1; }
.player-idle .pp__stage { cursor: none; }
.pp__film { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; pointer-events: none; }

/* ---------- portrait screens: a 16:9 cover or film is shown whole, centred on black, never cropped ---------- */
@media (max-aspect-ratio: 1/1) {
  .p-hero { background: #000; }
  .p-hero__img { object-fit: contain; }
  .p-hero__film { width: 100vw; height: 56.25vw; }
}

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .p-hero__bar { grid-template-columns: 1fr auto; }
  .p-hero__meta { display: none; }
  .p-hero__ui .player-bar { grid-template-columns: auto 1fr auto auto; }
  .p-head { padding: 10vh var(--gutter) 8vh; }
  .p-intro { grid-template-columns: 1fr; gap: 32px; margin-top: 6vh; }
  .p-film--tall { grid-template-columns: 1fr; gap: 48px; }
  .p-film--tall .p-frame { width: 100%; height: auto; }
  .p-sec { grid-template-columns: 1fr; gap: 20px; padding: 7vh 0; }
  .p-items li { grid-template-columns: 1fr; gap: 4px; font-size: 16px; }
  .p-stills { grid-template-columns: 1fr; gap: 12px; }
  .p-series__row { grid-template-columns: 1fr 1fr; gap: 12px; }
  .p-related__grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .rv { opacity: 1; transform: none; transition: none; }
  .p-frame__film, .pp__stage, .p-next__title svg, .p-hero__film { transition: none; }
  .p-cue__line::after { animation: none; }
}

/* the static text of a project page (tools/build-pages.js), seen only without JavaScript */
.p-static { display: grid; gap: 20px; max-width: 72ch; padding: 20vh var(--gutter) 10vh; font-size: 18px; line-height: 1.55; }
.p-static h1 { font-size: clamp(48px, 7vw, 112px); font-weight: 400; line-height: 1; letter-spacing: -0.04em; }
.p-static h2 { margin-top: 24px; font-size: 28px; font-weight: 400; }
