/* Bullish Media — portfolio
   Layout mechanics follow the reference build: a flex row of full-viewport
   slides over a visor layer whose blur/scale/overlay are CSS custom properties
   written by JS. Fluid type uses the same clamp() proportions. */

:root {
  /* palette — from the Bullish Media brand */
  --white:      #f5f5f5;
  --black:      #0a0a0a;
  --orange:     #ff5500;
  --green:      #22c55e;
  --muted:      #606060;
  --muted-lt:   #909090;

  --primary:    var(--white);
  --bg:         var(--black);

  --font-sans:  'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:  'JetBrains Mono', ui-monospace, monospace;
  --font-serif: 'EB Garamond', serif;

  /* fluid type, matching the reference's ratio */
  --min-font-size: 12px;
  --max-font-size: 48px;
  --zoom: 1;
  --font-size: clamp(var(--min-font-size), calc(1.1111vw * var(--zoom)), var(--max-font-size));
  --font-size-s: 13px;
  --font-size-l: 36px;

  --line-height: 1.375;
  --padding-s: 0.75rem;
  --padding-m: 1.5rem;
  --padding: var(--padding-m);

  --progress-gap: 2.5em;
  --line-width: 1px;

  --vh: 1vh;
}

@media (max-width: 900px) {
  :root {
    --padding: var(--padding-s);
    --font-size-l: 26px;
    --progress-gap: 1.5em;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--primary);
  font-family: var(--font-sans);
  font-size: var(--font-size);
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
}

/* Native scrolling is never used — the gallery is driven by virtual scroll. */
body {
  overflow: hidden;
  overscroll-behavior: none;
}
body.is-scrollable { overflow-y: auto; }

img, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

:focus-visible { outline: 2px dashed var(--orange); outline-offset: 3px; }

/* ----------------------------------------------------------------- intro */

.intro {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--black);
  display: grid;
  place-items: center;
  pointer-events: all;
}
.intro__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.intro__counter {
  position: relative;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.8;
  text-transform: uppercase;
  color: var(--white);
  will-change: transform, clip-path;
}
.intro__counter::after { content: '%'; }

/* WebGL unavailable: plain fade, no shader. */
.intro--fallback { transition: opacity .6s ease; }
.intro--fallback.is-leaving { opacity: 0; }

.intro-done .site { opacity: 1; }

/* ------------------------------------------------------------------- nav */

.header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--padding);
  mix-blend-mode: difference;
  pointer-events: none;
}
.header a, .header button { pointer-events: all; }

.brand {
  display: flex;
  align-items: center;
  gap: 0.6em;
  color: var(--white);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.brand svg { width: 22px; height: 22px; color: var(--white); }

.nav {
  display: flex;
  gap: 1.6em;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.nav a { position: relative; padding-bottom: 2px; }
.nav a::after {
  content: '';
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: 100% 0;
  transition: transform .5s cubic-bezier(.165,.84,.44,1);
}
.nav a:hover::after,
.nav a[aria-current='page']::after { transform: scaleX(1); transform-origin: 0 0; }

@media (max-width: 700px) {
  .nav { gap: 1em; font-size: 10px; }
  .brand span { display: none; }
}

/* ----------------------------------------------------------------- visor */

.visor {
  --overlay: 0.14;
  --scale: 1;
  --blur: 0px;
  --grayscale: 0;

  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100vw;
  height: 100vh;
  height: calc(var(--vh) * 100);
  filter: blur(var(--blur)) grayscale(var(--grayscale));
  transform: scale3d(var(--scale), var(--scale), var(--scale));
  transform-origin: center center;
  will-change: transform, filter;
}
/* One figure per item, stacked full-bleed. Only the active one is visible —
   this is the layer the visitor actually watches change. */
.visor figure {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  transition: opacity .8s cubic-bezier(.165,.84,.44,1);
}
.visor figure.is-active { opacity: 1; }
.visor figure img, .visor figure video { transform: scale(1.02); }
.visor img, .visor video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}
.visor::after {
  content: '';
  position: absolute;
  inset: 0;
  background-color: rgb(0 0 0 / var(--overlay));
  pointer-events: none;
}

/* Portrait frames: the photo floats as a window inset from the viewport
   edges, over a pre-blurred backdrop (blur + darkening baked into the 320w
   -blur.webp by build/media.sh — a live blur() here re-rasterizes under the
   visor's animated heat filter and stutters). The frame is sized from the
   photo's probed ratio (--r) so it hugs the image exactly within an
   88vw x 84vh box, letting a plain box-shadow (tight contact + wide ambient)
   sell the hover. --vh not vh: iOS chrome, same as every other layer here. */
.visor figure.is-portrait .visor__frame {
  --r: 0.75;
  position: absolute;
  inset: 0;
  margin: auto;
  width: min(88vw, calc(var(--vh) * 84 * var(--r)));
  height: min(calc(var(--vh) * 84), calc(88vw / var(--r)));
  overflow: hidden;
  box-shadow: 0 6px 22px rgb(0 0 0 / 0.4),
              0 34px 90px rgb(0 0 0 / 0.55);
}

/* ------------------------------------------------------------------ hero */

.hero {
  position: relative;
  z-index: 5;
  width: 100vw;
  height: 100vh;
  height: calc(var(--vh) * 100);
  display: grid;
  place-items: center;
  pointer-events: none;
}
.hero__media {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
/* The 1.06 is overscan for the pointer lean below: --hero-x/y reach ±2.2%,
   and translating a frame that exactly fills its box walks its own edge into
   view. Caught the moment the cursor trail gave us a reason to drive real
   mousemoves through a screenshot — a black band appeared down the right. */
.hero__media video, .hero__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale3d(calc(var(--hero-scale, 1) * 1.06), calc(var(--hero-scale, 1) * 1.06), 1)
             translate3d(var(--hero-x, 0), var(--hero-y, 0), 0);
  transition: transform .6s cubic-bezier(.165,.84,.44,1);
}
.hero__title {
  position: relative;
  z-index: 2;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(38px, 9vw, 160px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  text-align: center;
  margin: 0;
  mix-blend-mode: difference;
}
/* Cursor trail (src/trail.js). Inside .hero__media so it paints over the
   reel but under .hero__scroll, and outside the video's own transform — the
   trail is drawn in screen space, and the reference's hero video never moves
   at all. Never a hit target. */
.hero__trail {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hero__scroll {
  position: absolute;
  bottom: var(--padding);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.7;
}

/* --------------------------------------------------------------- gallery */

.gallery {
  --padding: var(--padding-m);
  position: relative;
  z-index: 10;
  width: 100vw;
  height: 100vh;
  height: calc(var(--vh) * 100);
  pointer-events: none;
  overflow: hidden;
}
.gallery a, .gallery button { pointer-events: all; }

/* Vertical column, one viewport per item. Measured on the reference: items sit
   exactly one viewport height apart and the list translates on Y. */
.gallery__list {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  width: 100%;
  height: 100%;
  will-change: transform;
  transform: translate3d(0, 0, 0);
}
.gallery__list li {
  flex: 1 0 100%;
  width: 100%;
  height: 100vh;
  height: calc(var(--vh) * 100);
  position: relative;
  list-style: none;
}
.gallery__list { margin: 0; padding: 0; }

/* Slides are INVISIBLE. They drive the scroll and carry the hit areas; all
   imagery lives in the visor. Matches the reference, where the per-project
   figure is opacity:0. */
.slide { position: relative; width: 100%; height: 100%; display: block; }
.slide figure {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
}

/* Centred article overlay — client above, italic title, director below. */
.article {
  --article-opacity: 1;
  position: absolute;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  opacity: var(--article-opacity);
}
.article .title,
.article .director,
.article .client {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: var(--padding);
  font-family: var(--font-serif);
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1;
  text-align: center;
  text-transform: capitalize;
}
.article .title {
  font-style: italic;
  font-size: var(--font-size-l);
  /* Optical centring: the large italic sits high against the meta line. */
  top: calc((var(--font-size-l) - var(--font-size)) * -0.41);
}
.article .director { font-size: var(--font-size); top: 3em; }

/* Client sits on the RIGHT edge, vertically centred — measured on the
   reference, where it reads as a lone word opposite the roman counter.
   It only moves to centred-above-title at narrow widths. */
.article .client {
  font-size: var(--font-size);
  justify-content: flex-end;
  top: 0;
}
@media (max-width: 700px) {
  .article .client { justify-content: center; top: -4em; }
}

/* progress rail — vertical line + roman counter */
.progress {
  position: absolute;
  left: 0; top: 0;
  height: 100%;
  padding: 0 var(--padding);
  display: flex;
  align-items: center;
  font-family: var(--font-serif);
  font-size: var(--font-size);
  line-height: 1;
  letter-spacing: -0.01em;
  z-index: 20;
  pointer-events: none;
}
.progress__line {
  --progress: 0;
  position: absolute;
  left: var(--padding);
  top: calc(50% + var(--progress-gap));
  width: var(--line-width);
  height: calc(100% - var(--progress-gap) * 2);
  background-color: rgb(255 255 255 / 0.4);
  overflow: hidden;
  transform: translateY(-50%);
}
.progress__line::after {
  content: '';
  position: absolute;
  inset: 0;
  background-color: var(--orange);
  transform: scaleY(var(--progress));
  transform-origin: 0 0;
}
.progress__counter {
  position: absolute;
  left: var(--padding);
  top: calc(50% - var(--progress-gap));
  font-family: var(--font-serif);
  opacity: 0.75;
  transform: translateY(-50%);
}

/* meta strip */
.meta {
  position: fixed;
  bottom: 0; left: 0;
  z-index: 20;
  display: flex;
  gap: 1.5em;
  padding: var(--padding);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  pointer-events: none;
}
.meta__count { color: var(--muted-lt); }

/* grid toggle — how 183 slides stay navigable */
.grid-toggle {
  position: fixed;
  right: var(--padding);
  bottom: var(--padding);
  z-index: 30;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.6em 1em;
  border: 1px solid rgb(255 255 255 / 0.3);
  border-radius: 2px;
  backdrop-filter: blur(6px);
  transition: border-color .4s ease, background-color .4s ease;
}
.grid-toggle:hover { border-color: var(--orange); background: rgb(255 85 0 / 0.12); }

.grid-view {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: var(--black);
  overflow-y: auto;
  padding: calc(var(--padding) * 3) var(--padding) var(--padding);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 4px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .5s ease, visibility .5s;
}
.grid-view.is-open { opacity: 1; visibility: visible; }
.grid-view button {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  padding: 0;
}
.grid-view img {
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0.75;
  transition: opacity .4s ease, transform .6s cubic-bezier(.165,.84,.44,1);
}
.grid-view button:hover img { opacity: 1; transform: scale(1.05); }

/* --------------------------------------------------------------- cascade */

/* Scroll-state preview chain over the blurred visor: a contiguous L of
   cover-cropped squares flowing around the bottom-left corner (upcoming items
   along the bottom edge, active square in the corner, passed items stacked up
   the left edge). Per-item x/y/w/h and the layer's fly-in/out transform are
   set inline by Gallery each frame; this only styles the pieces. */
.cascade {
  position: fixed;
  inset: 0;
  z-index: 18;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
  will-change: transform, opacity;
}
/* Each item IS its thumbnail's box — the figure fills it edge to edge, so
   consecutive boxes tile with no gaps. The label overflows to the right. */
.cascade__item {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  padding: 0;
  pointer-events: all;
  will-change: transform, width, height;
}
/* Centre-cover crop into whatever rectangle the corner flow dictates —
   squares in the chain, stretched panels during the corner handoff. */
.cascade__item figure {
  position: absolute;
  inset: 0;
  margin: 0;
  overflow: hidden;
}
.cascade__item figure img,
.cascade__item figure video {
  height: 100%;
  width: 100%;
  max-width: none;
  object-fit: cover;
  display: block;
}
/* Rides the thumb's top-right corner (reference: fillText at x+w+24px, y with
   baseline top) — this is what produces the 45° label diagonal. */
.cascade__label {
  position: absolute;
  left: 100%;
  top: 0;
  padding-left: clamp(16px, 1.25vw, 32px);
  display: flex;
  gap: 1.6em;
  align-items: baseline;
  font-family: var(--font-serif);
  font-size: var(--font-size);
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1;
  white-space: nowrap;
  text-transform: capitalize;
  color: var(--white);
}
.cascade__counter { opacity: 0.75; }

@media (prefers-reduced-motion: reduce) {
  .cascade { display: none; }
}

/* --------------------------------------------------------------- content */

.page {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  padding: calc(var(--padding) * 5) var(--padding) var(--padding);
  max-width: 1100px;
  margin: 0 auto;
}
.page h1 {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(34px, 6vw, 92px);
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0 0 0.6em;
}
.page p {
  max-width: 62ch;
  font-size: clamp(15px, 1.35vw, 21px);
  line-height: 1.55;
  color: rgb(245 245 245 / 0.82);
}
.page .label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-lt);
  margin-bottom: 1.4em;
}

/* --------------------------------------------------------- magnetic hover */

[data-cursor-follow],
[data-cursor-follow] .__target {
  transform-origin: 50% 50%;
  transition: transform .5s cubic-bezier(.165,.84,.44,1);
}

/* --------------------------------------------------- reduced motion / a11y */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
  .slide figure { transform: none; opacity: 1; }
  .slide figure img { transform: none; }
  .visor { filter: none; transform: none; }
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
