/* ==========================================================================
   Lucid — scroll-assembled gallery wall
   ========================================================================== */

:root {
  --bg: #08070d;
  --bg-lift: #0e0c16;
  --fg: #f2eee6;
  --muted: rgba(242, 238, 230, 0.52);
  --faint: rgba(242, 238, 230, 0.28);
  --line: rgba(242, 238, 230, 0.12);

  --sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --serif: 'Instrument Serif', Georgia, serif;

  --tile-radius: 10px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  /* The pinned section drives its own scrub — no smooth-scroll fighting it. */
  scroll-behavior: auto;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; }

/* --- the pinned section -------------------------------------------------- */

.lucid {
  position: relative;
  /* Scroll length is set by ScrollTrigger's end; this is just the pin target. */
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* --- parallax backdrop --------------------------------------------------- */

/* Overscanned past the stage on every side so the parallax never drags an
   edge into view. .stage clips it. */
.backdrop {
  position: absolute;
  inset: -14% -12%;
  z-index: 0;
  opacity: 0;
  will-change: transform;
  pointer-events: none;
}

.backdrop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Pushed well down and softened: this is atmosphere behind the work, and it
     must never compete with the frames on the wall. */
  filter: brightness(0.34) saturate(0.7) blur(3px);
}

/* Sits above the image (later sibling), holds the tiles legible against it. */
.backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(125% 85% at 50% 45%, rgba(8, 7, 13, 0.28) 0%, rgba(8, 7, 13, 0.86) 100%),
    linear-gradient(180deg, rgba(8, 7, 13, 0.66) 0%, rgba(8, 7, 13, 0.2) 42%, rgba(8, 7, 13, 0.88) 100%);
}

/* Full-bleed opening plate. This is the only element whose box is animated;
   every tile after it moves on transform alone. */
.hero {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100vw;
  height: 100vh;
  transform: translate(-50%, -50%);
  border-radius: 0;
  overflow: hidden;
  will-change: width, height, border-radius;
}

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

/* Duotone grade over the opening plate: cool base, warm wash. */
/* Grade on the opening plate. Deliberately light: this is a photograph, and
   the point is a slight cinematic push, not a duotone over someone's work.
   Set --duo-strength to 0 to remove it entirely. */
.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(105deg, rgba(196, 74, 48, 0.16) 0%, rgba(196, 74, 48, 0.03) 48%, rgba(38, 96, 116, 0.15) 100%);
  mix-blend-mode: soft-light;
  /* Lifted by the render loop so the plate matches the ungraded card it
     hands over to. */
  opacity: calc(var(--duo, 1) * var(--duo-strength, 1));
  pointer-events: none;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  background: radial-gradient(120% 90% at 50% 40%, transparent 30%, rgba(8, 7, 13, 0.55) 100%);
  pointer-events: none;
}

/* --- manifesto ----------------------------------------------------------- */

.manifesto {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 4.5vw 12vh;
  pointer-events: none;
}

.manifesto p {
  margin: 0;
  font-size: clamp(10px, 0.86vw, 13px);
  line-height: 2.15;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.86);
  text-shadow: 0 1px 20px rgba(0, 0, 0, 0.4);
}

.manifesto p + p { text-align: right; }

/* --- title --------------------------------------------------------------- */

.title {
  position: absolute;
  z-index: 4;
  top: 50%;
  left: 50%;
  width: min(680px, 78vw);
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  opacity: 0;
}

.title__eyebrow {
  margin: 0 0 14px;
  font-size: 11px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--faint);
}

/* Two lines, deliberately unequal: the name carries at wall scale, the trade
   sits under it in the serif at a third of the weight it would take in caps. */
.title__main {
  margin: 0;
  font-weight: 500;
  line-height: 1;
}

.title__mark {
  display: block;
  font-size: clamp(38px, 5.4vw, 74px);
  /* Tracking has to be added back by hand — the spaced caps are the logotype. */
  letter-spacing: 0.16em;
  text-transform: uppercase;
  /* Letter-spacing pads the right edge; pull it back so the block stays centred. */
  text-indent: 0.16em;
}

.title__word {
  display: block;
  margin-top: clamp(6px, 0.8vw, 12px);
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(19px, 2.3vw, 32px);
  letter-spacing: 0.01em;
  color: var(--muted);
}

.title__sub {
  /* Held well inside the title box: at full width this line runs under the
     right-hand corner stack, which is still on screen when the title resolves. */
  margin: 16px auto 0;
  max-width: 46ch;
  font-family: var(--serif);
  font-style: italic;
  /* Tracks the viewport more closely than the rest of the type: the corner
     stacks either side of the title move in with the viewport, and this line
     is the widest thing between them. */
  font-size: clamp(13px, 1.25vw, 19px);
  line-height: 1.5;
  color: var(--muted);
}

/* --- the wall ------------------------------------------------------------ */

/* Pan lives on this wrapper so the per-tile transforms stay untouched. */
.pan {
  position: absolute;
  inset: 0;
  z-index: 3;
  will-change: transform;
}

.tile {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--tile-w);
  height: var(--tile-h);
  margin: calc(var(--tile-h) / -2) 0 0 calc(var(--tile-w) / -2);
  border-radius: var(--tile-radius);
  overflow: hidden;
  will-change: transform, opacity;
  /* The layout engine writes transform/opacity every frame — no CSS
     transition here or the two fight each other. */
}

.tile__inner {
  position: absolute;
  inset: 0;
  transition:
    transform 0.55s var(--ease-out),
    filter 0.45s var(--ease-out);
}

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

/* Default wall state sits back a little so hover has somewhere to go. Held
   higher than it was for the synthetic plates — real frames lose too much
   at 0.62. */
.wall-live .tile__inner { filter: brightness(0.74) saturate(0.94); }

.wall-live .tile { cursor: pointer; }

.wall-live .tile.is-hot .tile__inner {
  transform: scale(1.055);
  filter: brightness(1.08) saturate(1.05);
}

.wall-live .tile.is-hot { z-index: 40 !important; }

/* Caption that rides in on hover. */
.tile__cap {
  position: absolute;
  z-index: 3;
  right: 10px;
  bottom: 9px;
  left: 10px;
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 0.35s var(--ease-out),
    transform 0.35s var(--ease-out);
  text-align: right;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.tile__num {
  display: block;
  font-size: 9px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
}

.tile__name {
  display: block;
  margin-top: 2px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: #fff;
}

.wall-live .tile.is-hot .tile__cap {
  opacity: 1;
  transform: translateY(0);
}

/* --- print view (click a tile) ------------------------------------------- */

.print {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: none;
}

.print.is-open { display: block; }

.print__scrim {
  position: absolute;
  inset: 0;
  background: rgba(6, 5, 10, 0.82);
  opacity: 0;
}

.print__frame {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: var(--tile-radius);
  overflow: hidden;
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.7);
  will-change: transform, width, height;
}

/* Stays `cover` even though the open frame is sized to the photograph's own
   aspect: during the flight the box is still morphing out of the tile's 2:3,
   and cover crops through that instead of letterboxing. Once it lands the two
   aspects agree, so cover and contain show the same thing — minus the hairline
   gaps sub-pixel rounding would leave under contain. */
.print__frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Positioned by the open animation (xPercent lives in GSAP so it does not get
   clobbered when the caption tweens on y). */
.print__cap {
  position: absolute;
  left: 50%;
  width: min(560px, 84vw);
  text-align: center;
  opacity: 0;
}

.print__num {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}

.print__line {
  margin: 12px 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(19px, 2vw, 26px);
  color: #fff;
}

.print__meta {
  margin: 18px auto 0;
  padding-top: 14px;
  max-width: 420px;
  border-top: 1px solid var(--line);
  font-size: 9.5px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--faint);
}

.print__close {
  position: absolute;
  z-index: 3;
  top: 26px;
  right: 26px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(20, 17, 28, 0.7);
  backdrop-filter: blur(10px);
  color: var(--fg);
  cursor: pointer;
  opacity: 0;
  transition: background 0.25s var(--ease-out);
}

.print__close:hover { background: rgba(40, 34, 54, 0.9); }

/* Wall recedes while a print is up. */
.stage {
  transition: filter 0.5s var(--ease-out);
}

.print-open .stage { filter: blur(9px) brightness(0.34); }

/* --- opening curtain ----------------------------------------------------- */

/* Above every tile (max z 60) and the hero, below the print view. The whole
   thing is inert: it must never intercept a click, not even mid-part. */
.curtain {
  position: absolute;
  z-index: 65;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.curtain__half {
  position: absolute;
  top: 0;
  /* Half a percent of overlap at the centre. Without it a hairline of the
     photograph shows through the seam while the curtain is shut. */
  width: 50.5%;
  height: 100%;
  background: #000;
  will-change: transform;
}

.curtain__half--l { left: 0; }
.curtain__half--r { right: 0; }

.curtain__type {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(760px, 84vw);
  transform: translate(-50%, -50%);
  text-align: center;
}

.curtain__word {
  margin: 0;
  font-size: clamp(30px, 4.4vw, 60px);
  font-weight: 500;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  /* Tracking pads the right edge; pull it back so the word stays centred. */
  text-indent: 0.34em;
  color: var(--fg);
  /* The glow follows the letterforms rather than sitting behind the block as
     one haze — five stacked shadows, tight to loose, so each letter carries
     its own falloff instead of the word sharing a single pool of light. The
     near layers do the bloom, the 190px one is what puts light on the curtain
     around the word. */
  text-shadow:
    0 0 6px rgba(255, 255, 255, 0.95),
    0 0 20px rgba(255, 255, 255, 0.80),
    0 0 52px rgba(255, 255, 255, 0.55),
    0 0 110px rgba(255, 255, 255, 0.34),
    0 0 190px rgba(255, 255, 255, 0.22);
}

.curtain__line {
  margin: 18px 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(16px, 1.5vw, 21px);
  color: var(--muted);
}

/* --- grain + scroll cue -------------------------------------------------- */

.grain {
  position: fixed;
  z-index: 70;
  inset: 0;
  opacity: 0.055;
  pointer-events: none;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

.cue {
  position: absolute;
  z-index: 8;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  pointer-events: none;
}

.cue::after {
  content: '';
  display: block;
  width: 1px;
  height: 26px;
  margin: 12px auto 0;
  background: linear-gradient(rgba(255, 255, 255, 0.7), transparent);
}

/* --- what comes after ---------------------------------------------------- */

.after {
  position: relative;
  z-index: 2;
  padding: 18vh 6vw 22vh;
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.after__eyebrow {
  margin: 0 0 18px;
  font-size: 11px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: var(--faint);
}

.after h2 {
  margin: 0;
  max-width: 16ch;
  font-size: clamp(30px, 4vw, 56px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.06;
}

.after p {
  margin: 26px 0 0;
  max-width: 46ch;
  font-size: 16px;
  line-height: 1.7;
  color: var(--muted);
}

.after__link {
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.after__link a {
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  padding-bottom: 3px;
  transition: border-color 0.25s var(--ease-out);
}

.after__link a:hover { border-color: var(--fg); }

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

@media (prefers-reduced-motion: reduce) {
  .cue { display: none; }
  .tile__inner,
  .tile__cap { transition: none; }
}

/* --- narrow screens ------------------------------------------------------ */

@media (max-width: 700px) {
  .manifesto {
    padding: 0 6vw 9vh;
    font-size: 9px;
  }
  .manifesto p { letter-spacing: 0.18em; line-height: 2; }
}
