/* ==================================================================================================
   PORTFOLIO — the work, first and large.

   The page opens on a website we built, big enough to read, with the client's name under it and a link
   to the live site. There is no hero and nothing to work out.

   THE SCREENS STAND IN SPACE. Each one carries its own `perspective()` in its own transform, so it is a
   real object turned a few degrees and set back at its own distance — not a flat picture with a shadow
   drawn on it, and not a shared room that would stretch anything far from its vanishing point. Every
   fifth screen takes the full width and faces you square on, which breaks the rhythm and lets one of
   them be genuinely large. Pointing at a screen squares it up and brings it out of the wall towards you.

   WHY THE DEPTH NEVER MOVES ON SCROLL. Translating in Z rescales, and a rescale re-rasterises: one
   full-bleed screenshot doing that every frame costs half this page's frame rate, and two cost two
   thirds — measured. So every angle and distance here is written once from the item's index and left
   alone, and the only thing that ever moves is the one screen under the pointer. The wall is dimensional
   AND still, which is the only way a page of twelve large photographs runs at sixty.

   No card, no panel, no fill, no border: a screen is the screenshot, and its name sits on the page
   underneath it. The only colour on the page comes from the work.
   ================================================================================================== */

.pf { position: relative; z-index: 2;
  padding-top: var(--rx-header-h);          /* the site header is fixed; the page starts under it */
  --pf-ease: cubic-bezier(.2, .8, .3, 1);
  --pf-bar: 54px; }

.pf-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* ==================================================================================================
   THE BAR — one category today, and this is how the next one arrives
   ================================================================================================== */
/* Opaque, with a short fade under it. A preview scrolling up behind a half-transparent bar showed
   through it — the site inside, its own slider arrows and all — which read as the layout breaking. */
.pf-bar { position: sticky; top: var(--rx-header-h); z-index: 6;
  height: var(--pf-bar); display: flex; align-items: center;
  background: var(--rx-bg); }
.pf-bar::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 26px;
  pointer-events: none;
  background: linear-gradient(180deg, var(--rx-bg), rgba(3, 4, 7, 0)); }
.pf-bar__inner { display: flex; align-items: baseline; justify-content: space-between; gap: 20px;
  width: 100%; }
.pf-bar__cats { list-style: none; margin: 0; padding: 0; display: flex; gap: clamp(14px, 2vw, 34px); }
.pf-bar__cats a { display: inline-flex; align-items: baseline; gap: 8px; text-decoration: none;
  color: rgba(245, 239, 238, .42); transition: color .4s var(--rx-ease); }
.pf-bar__cats a span { font: 500 clamp(13px, 1.1vw, 15.5px)/1 var(--rx-sans); letter-spacing: -.012em; }
.pf-bar__cats a b { font: 500 10px/1 var(--rx-sans); letter-spacing: .1em; opacity: .5; }
.pf-bar__cats a.is-at { color: var(--rx-ink); }
.pf-bar__cats a.is-at b { opacity: .85; }
.pf-bar__note { margin: 0; font: 400 11.5px/1 var(--rx-sans); letter-spacing: .04em;
  color: rgba(245, 239, 238, .3); }

.pf-cat { position: relative; }
/* only once the bar can actually switch between them */
.pf.is-filtered .pf-cat { display: none; }
.pf.is-filtered .pf-cat.is-on { display: block; }

/* ==================================================================================================
   THE RAIL — every project, one move away
   ================================================================================================== */
.pf-rail { position: fixed; z-index: 5; right: clamp(8px, 1.2vw, 20px); top: 50%;
  transform: translateY(-50%);
  max-height: 72svh; overflow: auto; scrollbar-width: none; }
.pf-rail::-webkit-scrollbar { display: none; }
.pf-rail ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.pf-rail a { display: flex; align-items: baseline; justify-content: flex-end; gap: 8px;
  padding: 3px 6px; text-decoration: none; border-radius: 4px;
  color: rgba(245, 239, 238, .3); transition: color .3s var(--rx-ease); }
.pf-rail b { order: 2; flex: none; width: 14px; height: 2px; border-radius: 2px; background: currentColor; opacity: .45; align-self: center; transition: width .4s var(--rx-ease), opacity .4s var(--rx-ease); }   /* a tick per project (no index numbers) */
.pf-rail a.is-at b { width: 24px; }
.pf-rail span { font: 400 11.5px/1.2 var(--rx-sans); letter-spacing: -.008em; white-space: nowrap;
  max-width: 0; overflow: hidden; opacity: 0;
  transition: max-width .45s var(--pf-ease), opacity .3s var(--rx-ease); }
.pf-rail a.is-at { color: var(--rx-ink); }
.pf-rail a.is-at b { opacity: 1; }
.pf-rail:hover span, .pf-rail:focus-within span { max-width: 16ch; opacity: 1; }

/* ==================================================================================================
   THE WALL
   ================================================================================================== */
/* ONE PROJECT A ROW, AND THE SAME ROW EVERY TIME. Information on one side, the screen on the other, and
   the next project is the mirror of it. The split is identical for all of them: varying the widths left
   some captions a sixth of the page to live in, and text that cannot fit beside a screen drops below it,
   which is exactly the inconsistency this now cannot produce. Only the depth and the angle vary, and
   those are what make the wall dimensional rather than a list.

   BOTH CHILDREN ARE PINNED TO ROW 1. Naming only the columns is not enough: on the mirrored rows the
   screen takes column 2 first, and the caption — asked for column 1, which the cursor has already passed
   — gets auto-placed onto a second row and lands underneath. That is the bug in the screenshot, and it
   could only ever show on every other project. */
.pf-wall { display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(38px, 7vh, 98px);
  padding-top: clamp(14px, 2.6vh, 34px);
  padding-bottom: clamp(30px, 6vh, 80px);
  padding-right: clamp(30px, 3.6vw, 58px);   /* the rail has a gutter of its own */ }

.pf-item { margin: 0;
  display: grid; align-items: center;
  grid-template-columns: minmax(0, 31%) minmax(0, 1fr);
  gap: clamp(20px, 3vw, 56px);
  /* no screen is ever taller than the window less the header and the bar, so a project is always whole
     and named on one screen */
  --cap: clamp(70px, 11vh, 120px);
  --fit: calc(100svh - var(--rx-header-h) - var(--pf-bar) - var(--cap));
  content-visibility: auto; contain-intrinsic-size: auto 520px; }
.pf-item .pf-said { grid-area: 1 / 1; text-align: left; justify-items: start; }
.pf-item .pf-frame { grid-area: 1 / 2; min-width: 0; position: relative; }
/* every other project is the mirror of the one before it */
.pf-item:nth-child(even) { grid-template-columns: minmax(0, 1fr) minmax(0, 31%); }
.pf-item:nth-child(even) .pf-said { grid-area: 1 / 2; text-align: right; justify-items: end; }
.pf-item:nth-child(even) .pf-frame { grid-area: 1 / 1; }

/* ---------- the screen ---------- */
/* THE WINDOW. A frame of a fixed shape with the whole page scrolling inside it, so the work can actually
   be read rather than glimpsed. Scrolling chains at the ends on purpose: reach the bottom of a site and
   the page carries on, which is what stops a full-width scroller trapping the visitor.

   Its angle and distance are written once from the item's index and never touched while you scroll. */
.pf-shot { display: block; position: relative;
  width: min(100%, calc(var(--fit) * 1.6));
  aspect-ratio: 16 / 10;
  border-radius: clamp(5px, .55vw, 10px);
  overflow-x: hidden; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* a phone chains to the page at either end, which is what stops a full-width scroller trapping a
     finger; a desktop keeps it and ui/portfolio.js hands the page the wheel once the site has run out */
  overscroll-behavior-y: auto;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .28) transparent;
  transform: perspective(1500px)
             translate3d(0, var(--in, 0px), calc(var(--z, 0px) * -1))
             rotateY(var(--ry, 0deg));
  transform-origin: 50% 50%;
  box-shadow: 0 46px 80px -38px rgba(0, 0, 0, .92), 0 6px 18px -10px rgba(0, 0, 0, .7);
  transition: transform .6s var(--pf-ease), opacity .8s var(--rx-ease), box-shadow .6s var(--pf-ease); }
.pf-shot::-webkit-scrollbar { width: 6px; }
.pf-shot::-webkit-scrollbar-track { background: transparent; }
.pf-shot::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .22); border-radius: 3px; }
/* the page inside the window: its real width, its real length */
.pf-shot img { display: block; width: 100%; height: auto; }

/* said once, and gone the moment you scroll the window. It hangs on the FRAME, not inside the
   scrolling page — sticky inside the scroller it came loose and floated over the site header. */
.pf-shot__hint { position: absolute; z-index: 2; right: 10px; bottom: 10px;
  display: inline-block; padding: 5px 11px; border-radius: 100px;
  background: rgba(6, 8, 13, .72); border: 1px solid rgba(255, 255, 255, .12);
  font: 500 10.5px/1 var(--rx-sans); letter-spacing: .1em; text-transform: uppercase;
  color: rgba(245, 239, 238, .66);
  transition: opacity .4s var(--rx-ease); }
.pf-frame.is-read .pf-shot__hint { opacity: 0; }

/* ---------- what it is, in the space the alternation opens up ---------- */
.pf-said { display: grid; gap: clamp(8px, 1.2vh, 14px);
  min-width: 0; padding: 0;
  transform: translateY(var(--in, 0px));
  transition: opacity .7s var(--rx-ease) .1s, transform .8s var(--pf-ease) .1s; }
.pf-said__no { margin: 0; font: 500 11px/1 var(--rx-sans); letter-spacing: .14em;
  color: rgba(245, 239, 238, .32); }
.pf-said__body { min-width: 0; }
.pf-said__name { margin: 0 0 6px; font: 500 clamp(21px, 2.1vw, 34px)/1.08 var(--rx-sans);
  letter-spacing: -.036em; }
.pf-said__line { margin: 0; font: 400 clamp(13px, .95vw, 15px)/1.55 var(--rx-sans);
  color: var(--rx-dim); }
.pf-said__kind { display: block; font: 500 var(--rx-eyebrow)/1 var(--rx-sans); letter-spacing: .18em;
  text-transform: uppercase; color: rgba(245, 239, 238, .5); margin-bottom: 6px; }
.pf-said__go { position: relative; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
  font: 500 13px/1 var(--rx-sans); letter-spacing: .01em; color: var(--rx-ink); text-decoration: none;
  padding: 9px 0 9px; }
.pf-said__go i { font-style: normal; display: inline-block;
  transition: transform .4s var(--pf-ease); }
.pf-said__go::after { content: ""; position: absolute; left: 0; right: 0; bottom: 4px; height: 1px;
  background: rgba(255, 255, 255, .22);
  transform: scaleX(1); transform-origin: 0 50%;
  transition: background .4s var(--rx-ease); }

/* ==================================================================================================
   ARRIVING — each project comes forward out of its own depth as it reaches the screen, once.
   ui/rise.js decides when; this is the whole of what happens. Nothing is tied to scroll position, so a
   visitor can stop anywhere and read, and scrolling back up does not run anything in reverse.
   ================================================================================================== */
.js .pf-frame { opacity: 0; transition: opacity .8s var(--rx-ease); }
.pf-item.is-up .pf-frame { opacity: 1; }
.js .pf-said { --in: 20px; opacity: 0; }
.pf-item.is-up .pf-shot, .pf-item.is-up .pf-said { --in: 0px; opacity: 1; }
/* without the script, or without an observer, everything is simply there */
.no-js .pf-frame, .no-js .pf-said,
.rx-no-rise .pf-frame, .rx-no-rise .pf-said { --in: 0px; opacity: 1; }

/* ==================================================================================================
   THE TAIL
   ================================================================================================== */
.pf-tail { position: relative; padding: var(--rx-sec-pad) 0 calc(var(--rx-sec-pad) * .7); }
.pf-tail__inner { display: grid; justify-items: center; text-align: center; gap: clamp(18px, 2.6vh, 30px); }
.pf-tail__h { margin: 0; font: 500 var(--rx-close)/1.08 var(--rx-sans); letter-spacing: -.038em; }
.pf-tail__ctas { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

/* ==================================================================================================
   WHAT ONLY A POINTER GETS — the screen squares up and comes out of the wall
   ================================================================================================== */
@media (hover: hover) and (pointer: fine) {
  /* pointing at a screen squares it up and brings it out of the wall — which is also the moment you are
     about to scroll it, so what you scroll is flat and facing you rather than turned away */
  .pf-item:hover .pf-shot, .pf-item:focus-within .pf-shot {
    transform: perspective(1500px) translate3d(0, 0, 54px) rotateY(0deg);
    box-shadow: 0 70px 120px -40px rgba(0, 0, 0, .95), 0 10px 26px -12px rgba(0, 0, 0, .75); }
  .pf-said__go:hover::after, .pf-item:hover .pf-said__go::after { background: var(--rx-ramp); }
  .pf-said__go:hover i { transform: translate(3px, -3px); }
  .pf-bar__cats a:hover { color: var(--rx-ink); }
  .pf-rail a:hover { color: var(--rx-ink); }
}
.pf-said__go:focus-visible, .pf-bar__cats a:focus-visible, .pf-rail a:focus-visible {
  outline: 2px solid var(--rx-ink); outline-offset: 4px; border-radius: 4px; }

/* ==================================================================================================
   THE PHONE — one column, and the screens still stand off the page.
   Two columns of 16:10 on a 390px screen would be thumbnails, and the whole point is that the work is
   large. The turn is taken almost all the way out, because at this width an angled screen loses more to
   foreshortening than it gains in depth; the distance and the shadow carry it instead.
   ================================================================================================== */
@media (max-width: 900px) {
  .pf { --pf-bar: 46px; }
  .pf-wall { gap: clamp(30px, 5vh, 52px); padding-right: var(--rx-pad); }
  .pf-item, .pf-item:nth-child(even) { grid-template-columns: minmax(0, 1fr);
    gap: clamp(12px, 2vh, 18px); contain-intrinsic-size: auto 540px;
    --cap: clamp(150px, 26vh, 230px); }
  /* stacked, so the screen leads and its name follows it — and both are on row 1 of their own column */
  .pf-item .pf-frame, .pf-item:nth-child(even) .pf-frame { grid-area: 1 / 1; width: 100%; }
  .pf-item .pf-said, .pf-item:nth-child(even) .pf-said { grid-area: 2 / 1;
    text-align: left; justify-items: start; }
  .pf-shot { width: 100%; margin-inline: auto; }
  /* flat on a phone: scrolling a page inside a turned frame means re-rendering it at an angle on every
     scrolled frame, and the depth here is carried by the shadow instead */
  .pf-item .pf-shot, .pf-item:hover .pf-shot, .pf-item:focus-within .pf-shot {
    transform: translate3d(0, var(--in, 0px), 0);
    box-shadow: 0 30px 52px -22px rgba(0, 0, 0, .96), 0 4px 14px -6px rgba(0, 0, 0, .8); }
  .pf-shot { aspect-ratio: 4 / 3; }

  .pf-item { position: relative; padding-bottom: clamp(18px, 3vh, 30px); }
  .pf-item + .pf-item::before { content: ""; position: absolute; z-index: 1;
    left: 8%; right: 8%; top: calc(clamp(30px, 5vh, 52px) / -2 - 1px); height: 1px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .1), rgba(255, 255, 255, 0)); }
  .pf-shot { transform: perspective(1100px) translateZ(calc(var(--z, 0px) * -.22))
                        rotateY(calc(var(--ry, 0deg) * .3));
    box-shadow: 0 26px 44px -26px rgba(0, 0, 0, .9); }


  .pf-rail { display: none; }
  .pf-bar__note { display: none; }
}

/* ==================================================================================================
   REDUCED MOTION — the wall is still a wall; it simply does not move when pointed at.
   ================================================================================================== */
@media (prefers-reduced-motion: reduce) {
  .pf-shot, .pf-said__go i, .pf-said__go::after, .pf-rail span { transition: none; }
}
