/* ==========================================================================
   The finale — the closing scene, two stills.
   Frame 1 (vishal1) rises out of the dark the first time the footer is seen;
   the extra scroll room (the section is 340svh, pinned) then drives frame 2
   (vishal2) in from the left over it, and after it frame 3 (vishal3) in from
   the right. The functional row holds the bottom edge throughout.
   ========================================================================== */

.fin {
  position: relative;
  /* over the fixed hero layer, like the scenes in .flow */
  z-index: 2;
  height: 340svh;
  background: #000;
}

.fin__pin {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;
  background: #000;
}

.fin__stage1,
.fin__frame2,
.fin__frame3 {
  position: absolute;
  inset: 0;
  margin: 0;
  overflow: hidden;
}

.fin__stage1 {
  z-index: 1;
  will-change: transform;
}

/* The stills carry type right up to their edges, so they are never cropped:
   each is shown whole above the footer row, and any spare width or height
   is filled by a blurred, darkened copy of the same still behind it. */
.fin {
  --bar-h: clamp(46px, 5.4vh, 58px);
}
.fin__stage1,
.fin__frame2,
.fin__frame3 {
  background: #02040a;
}
.fin__stage1::before,
.fin__frame2::before,
.fin__frame3::before {
  content: '';
  position: absolute;
  inset: -40px;
  background: var(--still) center / cover no-repeat;
  filter: blur(30px) brightness(.4) saturate(.9);
}
.fin__stage1 { --still: url('../../public/fin/vishal1.jpg'); }
.fin__frame2 { --still: url('../../public/fin/vishal2.jpg?v=2'); }
.fin__frame3 { --still: url('../../public/fin/vishal3.jpg?v=2'); }

.fin__img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: calc(100% - var(--bar-h));
  object-fit: contain;
  object-position: 50% 50%;
  display: block;
  user-select: none;
}

/* --------------------------------------------------------------------------
   Frame 1 reveal: black -> the frame surfaces blurred and pushed in -> it
   sharpens and settles -> one sweep of light crosses it -> it keeps a very
   slow breathing push so the still never freezes.
   -------------------------------------------------------------------------- */
.fin__stage1 .fin__img {
  opacity: 0;
  transform: scale(1.09);
  filter: blur(14px) brightness(.35) saturate(.7);
}
.fin.is-in .fin__stage1 .fin__img {
  opacity: 1;
  transform: scale(1.02);
  filter: blur(0) brightness(1) saturate(1);
  transition:
    opacity 1.3s ease .15s,
    transform 3.2s cubic-bezier(.16, 1, .3, 1) .15s,
    filter 2.1s cubic-bezier(.16, 1, .3, 1) .25s;
  animation: finBreathe 14s ease-in-out 3.4s infinite alternate;
}
@keyframes finBreathe {
  from { transform: scale(1.02); }
  to   { transform: scale(1.055); }
}

.fin__sweep {
  position: absolute;
  inset: -10% -40%;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(105deg,
    transparent 38%, rgba(140, 180, 255, .10) 46%, rgba(255, 255, 255, .22) 50%,
    rgba(140, 180, 255, .10) 54%, transparent 62%);
  transform: translateX(-70%);
  mix-blend-mode: screen;
  opacity: 0;
}
.fin.is-in .fin__sweep {
  animation: finSweep 1.9s cubic-bezier(.45, 0, .2, 1) 1.9s both;
}
@keyframes finSweep {
  0%   { transform: translateX(-70%); opacity: 1; }
  100% { transform: translateX(70%);  opacity: 1; }
}

/* dims frame 1 as frame 2 advances over it */
.fin__dim {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: #000;
  opacity: 0;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Frame 2 — full-bleed, entering from the LEFT under scroll control (boot6
   writes its transform). Its leading edge throws a soft shadow onto frame 1.
   -------------------------------------------------------------------------- */
.fin__frame2 {
  z-index: 6;
  transform: translate3d(-104%, 0, 0);
  will-change: transform, filter;
  pointer-events: none;
  box-shadow: 42px 0 110px rgba(0, 0, 0, 0.62);
  background: #030612;
}
.fin__frame2 .fin__img { transform: scale(1.03); }

/* frame 3 — the same move, mirrored: in from the RIGHT over frame 2 */
.fin__frame3 {
  z-index: 7;
  transform: translate3d(104%, 0, 0);
  will-change: transform, filter;
  pointer-events: none;
  box-shadow: -42px 0 110px rgba(0, 0, 0, 0.62);
  background: #030612;
}
.fin__frame3 .fin__img { transform: scale(1.03); }

/* a whisper of the site's grain over both stills */
.fin__stage1::after,
.fin__frame2::after,
.fin__frame3::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  background: url('../../public/tex/grain.png') repeat;
  background-size: 340px;
  opacity: 0.05;
  mix-blend-mode: overlay;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   The functional row — a real footer, whispering on the bottom edge, over a
   soft shade so it stays legible on either still.
   -------------------------------------------------------------------------- */

.fin__bar {
  position: absolute;
  z-index: 8;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  height: var(--bar-h);
  padding: 0 clamp(20px, 3.6vw, 62px);
  background: #02040a;
  border-top: 1px solid rgba(120, 150, 210, .12);
  font-family: var(--ui);
  font-size: clamp(8px, 0.66vw, 11px);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(200, 210, 230, 0.55);
  opacity: 0;
  transform: translateY(12px);
}
.fin.is-in .fin__bar {
  opacity: 1;
  transform: none;
  transition: opacity 1s ease 2.6s, transform 1.2s cubic-bezier(0.22, 1, 0.36, 1) 2.6s;
}

.fin__bar a {
  color: rgba(225, 232, 245, 0.75);
  text-decoration: none;
  transition: color 0.35s ease, text-shadow 0.35s ease;
}
.fin__bar a:hover,
.fin__bar a:focus-visible {
  color: #fff;
  text-shadow: 0 0 14px rgba(80, 140, 255, 0.6);
  outline: none;
}
.fin__soc {
  display: flex;
  gap: 2.4em;
}
.fin__c { font-size: inherit; letter-spacing: 0.24em; }

/* --------------------------------------------------------------------------
   Portrait — the row stacks, and the stills sit in the band above it
   -------------------------------------------------------------------------- */

.fin.is-portrait { --bar-h: 118px; }
.fin.is-portrait .fin__bar {
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}

@media (prefers-reduced-motion: reduce) {
  .fin .fin__img,
  .fin.is-in .fin__stage1 .fin__img { transition: none; animation: none; }
  .fin.is-in .fin__sweep { animation: none; }
  .fin.is-in .fin__bar { transition: none; }
}
