/* ==========================================================================
   WORK SECTION — Definitive Alpha Tango Card Experience
   - Full ~97% viewport width on entry and while pinned (zero narrow cap)
   - Exact 16:9 image proportions preserved without distortion
   - Top-edge alignment at y = 0 (no permanent top margin, no staircase)
   - Scroll-driven recession follows Alpha Tango's quadratic ease-out curve
     (scale 1.00 -> 0.80, blur 0px -> 4px), then gets 100% covered & retired
     behind the incoming card once it reaches y = 0
   - Independent inner image hover zoom: scale(1.05), 0.5s easeInOutCirc
     (cubic-bezier(0.785, 0.135, 0.15, 0.86)), strictly clipped inside 20px radius
   - Automatically supports any number of project cards (1..N) with zero edits
   - Navigation dock (z-index: 100) stays sharp and interactive above all cards
   ========================================================================== */

:root {
  --work-gutter: clamp(14px, 1.5vw, 32px);
  --work-radius: clamp(16px, 1.4vw, 20px);
}

.work-stage {
  position: relative;
  z-index: 3;
  width: 100%;
  background: transparent;
}

.work__stack {
  position: relative;
  width: 100%;
  margin-inline: auto;
  padding-inline: var(--work-gutter);
}

@media (min-width: 2600px) {
  .work__stack {
    max-width: 2600px;
  }
}

/*
  Non-sticky scroll runway per project card (net vertical step = 118dvh:
  100dvh card travel + 18dvh sharp foreground hold at y = 0).
  Every non-last slot stays pinned across the entire incoming card rise + hold
  and retires invisibly behind it, so any number of cards (1..N) aligns cleanly
  to the bottom of .work__stack with zero dead space.
*/
.work__slot {
  position: relative;
  width: 100%;
  height: 236dvh;
  margin-bottom: -118dvh;
  pointer-events: none;
}

.work__slot:last-child {
  height: 118dvh;
  margin-bottom: 0;
}

/* Full-viewport sticky frame pinning each card's top edge cleanly at y = 0 */
.work__pin {
  position: sticky;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  padding: 0;
}

/* Full-width (~97% viewport) 16:9 card matching Alpha Tango margins & 20px radius */
.work__card {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--work-radius);
  overflow: hidden;
  overflow: clip;
  background-color: var(--color-bg);
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.56),
    0 0 0 1px rgba(255, 255, 255, 0.06);
  transform-origin: center top;
  pointer-events: auto;
  isolation: isolate;
}

/* Inner image owns hover zoom independently of .work__card's scroll transform */
.work__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform: scale3d(1, 1, 1);
  transform-origin: center center;
  transition: transform 0.5s var(--ease-brutalist);
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}

/* Alpha Tango hover zoom: 1.05x on inner media only, activated solely via circular center zone */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .work__card.is-zoom-active .work__image {
    transform: scale3d(1.05, 1.05, 1);
  }
}

/* --------------------------------------------------------------------------
   Project Category Pills (Top-Right Inside Card — Alpha Tango Reference)
   - Stationary during inner image hover zoom; scales/blurs naturally with card
   - Translucent dark glass capsule ensures contrast on both light & dark artwork
   - pointer-events: none so it never blocks circular hover activation
   -------------------------------------------------------------------------- */
.work__tags {
  position: absolute;
  top: clamp(0.75rem, 2.5vw, 2.5rem);
  right: clamp(0.75rem, 2.5vw, 2.5rem);
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: clamp(0.35rem, 0.55vw, 0.5rem);
  max-width: calc(100% - clamp(1.5rem, 5vw, 5rem));
  list-style: none;
  pointer-events: none;
  user-select: none;
}

.work__tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.38rem, 0.52vw, 0.5rem) clamp(0.72rem, 1vw, 1rem);
  border-radius: 9999px;
  background-color: rgba(0, 0, 0, 0.42);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: clamp(0.625rem, 0.78vw, 0.8125rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Native CSS Scroll-Driven Card Stacking (Compositor-Driven, 100% Reversible)
   - Feature-detected with both animation-timeline: view() and animation-range: entry
   - Non-sticky .work__slot defines --work-slot-tl so cover <dvh> offsets map
     1:1 to scroll distance past each card's y = 0 pin point
   - Exact Alpha Tango quadratic ease-out curve (p = 1 - (1 - t)^2):
     scale 1.00 -> 0.80, blur 0px -> 4px, subtle downward tuck (+2.5dvh) so
     the incoming card completely encloses it by 98% before retiring to opacity 0
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    .work__slot {
      view-timeline: --work-slot-tl block;
    }

    .work__slot:not(:last-child) .work__card {
      will-change: transform, filter, opacity;
      animation: work-card-recede auto linear both;
      animation-timeline: --work-slot-tl;
      /*
        cover 100dvh = active card reaches y = 0 and pins at full ~97% width
        cover 118dvh = 18dvh sharp foreground hold completes; next card enters bottom (0%)
        cover 218dvh = next card reaches y = 0 and completely covers this card (100%)
      */
      animation-range: cover 118dvh cover 218dvh;
    }
  }
}

@keyframes work-card-recede {
  0% {
    opacity: 1;
    filter: blur(0px);
    transform: translate3d(0, 0, 0) scale3d(1, 1, 1);
  }
  25% {
    opacity: 1;
    filter: blur(1.75px);
    transform: translate3d(0, 0.75dvh, 0) scale3d(0.9125, 0.9125, 1);
  }
  50% {
    opacity: 1;
    filter: blur(3px);
    transform: translate3d(0, 1.5dvh, 0) scale3d(0.85, 0.85, 1);
  }
  75% {
    opacity: 1;
    filter: blur(3.75px);
    transform: translate3d(0, 2.1dvh, 0) scale3d(0.8125, 0.8125, 1);
  }
  98% {
    opacity: 1;
    filter: blur(3.99px);
    transform: translate3d(0, 2.5dvh, 0) scale3d(0.8002, 0.8002, 1);
  }
  100% {
    opacity: 0;
    filter: blur(4px);
    transform: translate3d(0, 2.5dvh, 0) scale3d(0.8, 0.8, 1);
  }
}

/* --------------------------------------------------------------------------
   Responsive Refinements — Tall Panoramic Portrait Cards on Mobile & Vertical
   - Fills vertical space cleanly between the top BLUE wordmark and bottom dock
   - Uses the exact same 2560x1440 images at full portrait height (zero stretch)
   - Scroll-driven horizontal panoramic sweep (0% -> 100%) reveals the full
     width of every widescreen artwork as you scroll through each card
   -------------------------------------------------------------------------- */
@keyframes work-portrait-pan {
  0% {
    object-position: 0% 50%;
  }
  100% {
    object-position: 100% 50%;
  }
}

@media (max-width: 1024px) {
  :root {
    --work-gutter: clamp(14px, 2vw, 24px);
    --work-radius: 18px;
  }
}

@media (max-aspect-ratio: 10/11), (max-width: 768px) {
  .work__slot {
    height: 310dvh;
    margin-bottom: -155dvh;
  }

  .work__slot:last-child {
    height: 155dvh;
    margin-bottom: 0;
  }

  .work__pin {
    align-items: center;
    padding-top: clamp(4.25rem, 9dvh, 5.25rem);
    padding-bottom: calc(clamp(1.25rem, 3.5dvh, 2rem) + 76px);
  }

  .work__card {
    height: 100%;
    aspect-ratio: auto;
  }

  .work__image {
    object-position: 50% 50%;
  }

  .work__tags {
    top: auto;
    bottom: clamp(0.75rem, 2.4vw, 1.25rem);
    right: clamp(0.75rem, 2.4vw, 1.25rem);
    gap: 0.35rem;
    max-width: calc(100% - 1.5rem);
  }

  .work__tag {
    padding: 0.34rem 0.66rem;
    font-size: clamp(0.58rem, 2.4vw, 0.7rem);
    letter-spacing: 0.045em;
  }
}

@media (prefers-reduced-motion: no-preference) and ((max-aspect-ratio: 10/11) or (max-width: 768px)) {
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    .work__slot .work__image {
      animation: work-portrait-pan auto linear both;
      animation-timeline: --work-slot-tl;
      animation-range: cover 100dvh cover 155dvh;
    }

    .work__slot:not(:last-child) .work__card {
      animation-range: cover 155dvh cover 255dvh;
    }
  }
}

@media (max-width: 600px) {
  :root {
    --work-gutter: 14px;
    --work-radius: 18px;
  }
}

/* --------------------------------------------------------------------------
   Reduced Motion Accessibility — Clean Non-Overlapping Vertical Gallery
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .work__stack {
    display: flex;
    flex-direction: column;
    gap: clamp(1.5rem, 4dvh, 2.5rem);
    padding-top: clamp(2rem, 5dvh, 3.5rem);
    padding-bottom: calc(clamp(2.5rem, 6dvh, 4rem) + 84px);
  }

  .work__slot,
  .work__slot:last-child {
    height: auto;
    margin-bottom: 0;
  }

  .work__pin {
    position: relative;
    top: auto;
    height: auto;
    padding: 0;
  }

  .work__card {
    height: auto;
    aspect-ratio: 16 / 9;
    animation: none !important;
    filter: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .work__image {
    animation: none !important;
    object-position: center !important;
    transition: none;
    transform: none !important;
  }
}
