/* SnapByBeyy — the gallery page's scroll sequence.
   Black throughout. Five movements, one per section:
   mosaic (photos arrive from alternating sides, with a ripple near the pointer),
   film strip (scrolling down runs the strip sideways),
   focus pull (each photo sharpens as it reaches the middle of the screen),
   dissolve (one photo gives way to the next through a spreading mask).
   The mosaic is the whole gallery: every photograph, loading 30 at a time. */

.seq {
  --bar-h: 66px;
  --stage-top: calc(var(--nav-h) + var(--bar-h));
  --stage-h: calc(100svh - var(--nav-h) - var(--bar-h));
  background: #000;
}

/* ---------- Opening ---------- */

.seq-intro {
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: calc(var(--nav-h) + clamp(56px, 10vw, 140px)) var(--gutter) clamp(40px, 6vw, 80px);
  text-align: center;
  background: #000;
}

.seq-intro__tag {
  font-family: var(--serif);
  font-size: clamp(17px, 1.7vw, 24px);
  color: var(--muted);
}

.seq-intro__title {
  font-size: clamp(34px, 6.4vw, 96px);
  max-width: 16ch;
}

.seq-intro .lede {
  max-width: 44ch;
}

/* ---------- 0. Prints in space ----------
   Without 3D (no WebGL, or reduced motion) this is just the plain intro above. With it, the intro
   is pinned for a while and the photographs fly past behind it. */

.seq-space.is-3d {
  height: 260vh;
}

.seq-space.is-3d .seq-space__stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: #000;
}

.seq-space__canvas {
  display: none;
}

.seq-space.is-3d .seq-space__canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.seq-space.is-3d .seq-intro {
  position: relative;
  z-index: 1;
  height: 100%;
  align-content: center;
  padding-top: var(--nav-h);
  background: none;
  pointer-events: none;
  /* prints.js fades and lifts the words as the flight begins. */
}

.seq-space.is-3d .seq-intro .btn {
  pointer-events: auto;
}

/* A soft dark pool behind the words, so they stay readable over the prints. */
.seq-space.is-3d .seq-intro::before {
  content: '';
  position: absolute;
  inset: 18% 10%;
  z-index: -1;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0));
}

/* ---------- The infinite reel ----------
   Two bands of photographs crossing the screen at a slight angle. reel.js moves them. */

.reel {
  position: relative;
  overflow: hidden;
  padding: clamp(40px, 7vw, 110px) 0 clamp(28px, 4vw, 56px);
  background: #000;
}

.reel__stage {
  display: grid;
  gap: clamp(10px, 1.4vw, 18px);
  /* The bands cross the page on a slight diagonal, wider than the screen so their ends never show. */
  transform: rotate(-4deg) scale(1.12);
}

.reel__row {
  --h: clamp(190px, 30vh, 360px);
  overflow: hidden;
  cursor: grab;
  /* Up-and-down on a touch screen still scrolls the page; sideways moves the band. */
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.reel__row:active {
  cursor: grabbing;
}

.reel__track {
  display: flex;
  gap: 16px;
  width: max-content;
  will-change: transform;
}

.reel__item {
  position: relative;
  flex: none;
  height: var(--h);
  aspect-ratio: var(--ar);
  overflow: hidden;
  border-radius: 3px;
  background: #0a0a0a;
}

.reel__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  transition: scale 700ms var(--ease-out), filter 500ms ease;
}

:root:not(.is-phone) .reel__item:hover img {
  scale: 1.05;
}

.reel__item:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: -2px;
}

.reel__hint {
  margin: clamp(26px, 4vw, 44px) var(--gutter) 0;
  text-align: center;
  font-family: var(--display);
  font-stretch: 112%;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.reel__hint-touch,
.reel.is-touch .reel__hint-mouse {
  display: none;
}

.reel.is-touch .reel__hint-touch {
  display: inline;
}

/* Phones and tablets: bigger photographs, made for the thumb. */
:root.is-tablet .reel__row {
  --h: clamp(240px, 32vh, 400px);
}

:root.is-phone .reel__row {
  --h: clamp(200px, 34svh, 320px);
}

:root.is-phone .reel__track {
  gap: 10px;
}

:root.is-phone .reel__stage {
  transform: rotate(-5deg) scale(1.2);
}

/* Reduced motion: the bands sit still and simply scroll sideways by hand. */
.seq--static .reel__row {
  overflow-x: auto;
}

/* ---------- Section bar: jump between movements, sound on or off ---------- */

.seq-bar {
  position: sticky;
  top: var(--nav-h);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 4px clamp(14px, 3vw, 40px);
  min-height: var(--bar-h);
  padding: 10px var(--gutter);
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-block: 1px solid var(--line-soft);
  overflow-x: auto;
  scrollbar-width: none;
}

.seq-bar::-webkit-scrollbar {
  display: none;
}

.seq-bar .chip[aria-current='true'] {
  color: var(--paper);
  text-decoration: underline;
  text-underline-offset: 8px;
  text-decoration-thickness: 2px;
}

.seq-bar__sound {
  margin-left: auto;
  flex: none;
  min-height: 44px;
  padding: 0 16px;
}

.seq-bar__sound[aria-pressed='true'] {
  border-color: var(--gold);
  color: var(--gold-hi);
}

/* ---------- Section headings ---------- */

.act__head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 0 var(--gutter);
}

.act__no {
  font-family: var(--serif);
  font-size: clamp(16px, 1.5vw, 22px);
  color: var(--muted);
  font-variant-numeric: lining-nums tabular-nums;
}

.act__title {
  font-size: clamp(26px, 3.6vw, 54px);
}

/* Anything in the sequence that opens the viewer */
.seq [data-open] {
  display: block;
  padding: 0;
  cursor: pointer;
}

/* ---------- 1. Mosaic ---------- */

.seq-mosaic {
  position: relative;
  padding: clamp(48px, 7vw, 110px) 0 clamp(64px, 9vw, 140px);
  overflow: hidden;
}

.seq-mosaic .act__head {
  margin-bottom: 18px;
}

/* One block per batch of 30. The space between blocks leaves room for the columns' drift. */
.mosaic {
  display: grid;
  gap: 14vh;
  /* Headroom, so a column drifting upward never covers the filters. */
  padding-top: 7vh;
}

.mosaic__block {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr));
  align-items: start;
}

.mosaic__col {
  position: relative;
  display: grid;
  margin-top: var(--drop, 0vw);
  /* sequence.js moves each column (drift and lean) by setting its transform directly. */
  transform: translate3d(0, 0, 0);
  will-change: transform;
}

/* Odd columns sit above even ones, so a tile can slide out from behind its neighbour. */
.mosaic__col:nth-child(odd) {
  z-index: 2;
}

.tile {
  position: relative;
  overflow: hidden;
  background: #0a0a0a;
  transition: transform 1100ms var(--ease-out), clip-path 1200ms var(--ease-out), opacity 700ms ease;
  transition-delay: var(--d, 0ms);
}

.tile img {
  width: 100%;
  height: auto;
  aspect-ratio: var(--ar);
  object-fit: cover;
  transition: transform 1200ms var(--ease-out);
}

:root:not(.is-phone) .tile:hover img {
  transform: scale(1.04);
}

/* Developing: each photo rises out of blank white paper as it arrives, the way a print comes up
   in the developer tray. Only opacity changes, so it costs nothing to draw. */
.tile::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #cdcac3;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1300ms cubic-bezier(0.77, 0, 0.175, 1);
  transition-delay: calc(var(--d, 0ms) + 200ms);
}

.tile:not(.is-in)::after {
  opacity: 1;
  transition: none;
}

/* The image itself starts faint under the paper and comes up to full strength. */
.tile:not(.is-in) img {
  opacity: 0.25;
}

.tile img {
  transition: transform 1200ms var(--ease-out), opacity 1800ms cubic-bezier(0.77, 0, 0.175, 1) calc(var(--d, 0ms) + 260ms);
}

/* Until a tile scrolls into view it waits off to one side. */
.tile:not(.is-in) {
  opacity: 0;
}

.tile:not(.is-in)[data-enter='up'] {
  transform: translate3d(0, 90px, 0);
}

.tile:not(.is-in)[data-enter='down'] {
  transform: translate3d(0, -90px, 0);
}

.tile:not(.is-in)[data-enter='left'] {
  transform: translate3d(-70px, 0, 0);
}

.tile:not(.is-in)[data-enter='right'] {
  transform: translate3d(70px, 0, 0);
}

/* Opens from a narrow strip into the full frame. */
.tile[data-enter='strip'] {
  clip-path: inset(0 0 0 0);
}

.tile:not(.is-in)[data-enter='strip'] {
  opacity: 1;
  clip-path: inset(0 47% 0 47%);
}

/* Slides out from behind the column beside it. */
.tile:not(.is-in)[data-enter='behind'] {
  opacity: 1;
  transform: translate3d(var(--from, 62%), 0, 0);
}

/* ---------- 2. Film strip ---------- */

.seq-strip {
  position: relative;
  /* height is set by the script: the longer the strip, the further there is to scroll */
}

.seq-strip__stage {
  position: sticky;
  top: var(--stage-top);
  height: var(--stage-h);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-content: center;
  gap: clamp(14px, 2.4vh, 28px);
  padding-block: clamp(14px, 3vh, 36px);
  overflow: hidden;
}

.deck {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
}

.deck__cards {
  position: relative;
  height: clamp(300px, calc(var(--stage-h) - 230px), 620px);
  aspect-ratio: 4 / 5;
  max-width: calc(100vw - 2 * var(--gutter));
}

.deck__card {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #0a0a0a;
  box-shadow: 0 50px 90px -40px rgba(0, 0, 0, 0.95);
  transform-origin: 50% 80%;
  will-change: transform, opacity;
  pointer-events: none;
}

.deck__card.is-top {
  pointer-events: auto;
}

.deck__card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: scale 600ms var(--ease-out);
}

/* Cards further down the deck sit in shadow. */
.deck__card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #000;
  opacity: var(--dim, 0);
  pointer-events: none;
}

.deck__card.is-top::after {
  opacity: 0;
}

:root:not(.is-phone) .deck__card.is-top:hover img {
  scale: 1.03;
}

/* The big number beside the deck: which card is on top. */
.deck__count {
  position: absolute;
  right: var(--gutter);
  bottom: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--serif);
  font-size: clamp(54px, 8vw, 120px);
  line-height: 1;
  font-variant-numeric: lining-nums tabular-nums;
}

.deck__of {
  font-size: 0.3em;
  color: var(--muted);
  letter-spacing: 0.06em;
}

@media (max-width: 760px) {
  .deck__count {
    position: static;
    margin-top: 14px;
    font-size: 44px;
  }
}

.seq-strip__foot {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 var(--gutter);
}

.seq-strip__line {
  flex: 1;
  height: 1px;
  background: var(--line);
}

.seq-strip__line span {
  display: block;
  height: 3px;
  margin-top: -1px;
  background: var(--paper);
  transform: scaleX(0);
  transform-origin: left;
}

.seq-strip__hint {
  font-family: var(--display);
  font-stretch: 112%;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- 3. Focus pull ---------- */

.seq-focus {
  padding: clamp(64px, 9vw, 140px) 0;
}

.focus {
  display: grid;
  gap: clamp(40px, 9vh, 120px);
  margin-top: clamp(28px, 4vw, 56px);
  padding: 0 var(--gutter);
}

.focus__item {
  --f: 0;
  position: relative;
  width: min(100%, calc(var(--ar) * 78svh));
  overflow: hidden;
  background: #0a0a0a;
  transform: scale(calc(0.94 + var(--f) * 0.06));
  will-change: transform;
}

.focus__item:nth-child(odd) {
  justify-self: start;
  margin-left: clamp(0px, 8vw, 140px);
}

.focus__item:nth-child(even) {
  justify-self: end;
  margin-right: clamp(0px, 8vw, 140px);
}

.focus__item img {
  width: 100%;
  height: auto;
  aspect-ratio: var(--ar);
  object-fit: cover;
}

/* Out of focus: the whole frame, soft and a little dark. */
.focus__soft {
  filter: blur(14px) brightness(0.62);
  transform: scale(1.06);
}

/* In focus: the same frame, sharp, let through a soft-edged window that opens as the photo
   reaches the middle of the screen. The edges of the frame stay soft, like a shallow depth of field. */
.focus__sharp {
  position: absolute;
  inset: 0;
  opacity: calc(0.15 + var(--f) * 0.85);
  -webkit-mask-image: radial-gradient(ellipse 78% 70% at 50% 42%, #000 calc(var(--f) * 62%), transparent calc(var(--f) * 62% + 42%));
  mask-image: radial-gradient(ellipse 78% 70% at 50% 42%, #000 calc(var(--f) * 62%), transparent calc(var(--f) * 62% + 42%));
}

/* ---------- 4. Dissolve ---------- */

.seq-dissolve {
  position: relative;
}

.seq-dissolve__stage {
  position: sticky;
  top: var(--stage-top);
  height: var(--stage-h);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(12px, 2vh, 24px);
  padding-block: clamp(14px, 3vh, 36px);
  overflow: hidden;
}

.dissolve {
  position: relative;
  justify-self: center;
  height: 100%;
  aspect-ratio: 4 / 5;
  max-width: calc(100vw - 2 * var(--gutter));
  background: #0a0a0a;
}

.dissolve__layer {
  --t: 0;
  --ox: 50%;
  --oy: 50%;
  position: absolute;
  inset: 0;
  -webkit-mask-image: radial-gradient(circle at var(--ox) var(--oy), #000 calc(var(--t) * 170% - 24%), transparent calc(var(--t) * 170%));
  mask-image: radial-gradient(circle at var(--ox) var(--oy), #000 calc(var(--t) * 170% - 24%), transparent calc(var(--t) * 170%));
  transform: scale(calc(1.08 - var(--t) * 0.08));
  will-change: transform;
}

.dissolve__layer[data-state='done'] {
  -webkit-mask-image: none;
  mask-image: none;
  transform: none;
}

.dissolve__layer[data-state='wait'] {
  visibility: hidden;
}

.dissolve__layer img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.seq-dissolve__foot {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 14px;
  padding: 0 var(--gutter);
  font-family: var(--serif);
  font-size: clamp(20px, 2vw, 28px);
  font-variant-numeric: lining-nums tabular-nums;
}

.seq-dissolve__foot small {
  font-size: 0.55em;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* The gallery's filters sit in the flow, under its heading. */
.filters.filters--inline {
  background: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: 0;
  padding-block: 0;
  margin-bottom: 0;
  position: relative;
  top: auto;
  z-index: 3;
}

.mosaic__more {
  position: relative;
  z-index: 3;
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: clamp(36px, 5vw, 72px) var(--gutter) 0;
}

.mosaic__more[hidden] {
  display: none;
}

.mosaic__count {
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-variant-numeric: lining-nums tabular-nums;
}

/* ---------- Reduced motion: everything laid out plainly, nothing pinned ---------- */

.seq--static .seq-strip {
  height: auto !important;
}

.seq--static .seq-strip__stage,
.seq--static .seq-dissolve__stage {
  position: static;
  height: auto;
}

.seq--static .deck__cards {
  display: flex;
  gap: 12px;
  height: auto;
  aspect-ratio: auto;
  max-width: 100%;
  overflow-x: auto;
}

.seq--static .deck__card {
  position: relative;
  flex: 0 0 min(70vw, 360px);
  aspect-ratio: 4 / 5;
  transform: none !important;
  opacity: 1 !important;
  pointer-events: auto;
}

.seq--static .deck__count {
  display: none;
}

.seq--static .seq-strip__foot,
.seq--static .seq-dissolve__foot {
  display: none;
}

.seq--static .seq-dissolve {
  height: auto !important;
}

.seq--static .dissolve {
  height: auto;
  aspect-ratio: auto;
  display: grid;
  gap: 16px;
  width: min(100%, 520px);
}

.seq--static .dissolve__layer {
  position: static;
  visibility: visible !important;
  -webkit-mask-image: none;
  mask-image: none;
  transform: none;
  aspect-ratio: 4 / 5;
}

.seq--static .focus__item {
  transform: none;
}

.seq--static .focus__soft {
  display: none;
}

.seq--static .focus__sharp {
  position: static;
  opacity: 1;
  -webkit-mask-image: none;
  mask-image: none;
}
