/* ==========================================================================
   CONTACT SECTION & ABOUT -> CONTACT TRANSITION
   - Seamless continuation of About over an inverted color scheme using ONLY
     existing CSS palette tokens:
       * Background: var(--color-text) (#CCCCCC)
       * Typography & pill stroke/fill: var(--color-bg) (#151515)
   - Synchronized 1:1 with scroll (--contact-enter-tl) and 100% reversible:
       1. About text exits upward out of focus (translateY -48px + blur)
       2. The single portrait glides smoothly RIGHT -> LEFT across the screen
          (calc(100cqi - 51.2%) -> -51.2%), revealing the opposite half of the
          face cropped cleanly by the left viewport edge (no mirroring)
       3. Full-viewport .contact-backdrop smoothly shifts #0a0a0a -> #CCCCCC
       4. Contact content rises smoothly out of blur on the right side
   - Fixed top BLUE wordmark (mix-blend-mode: difference) automatically inverts
     to dark charcoal over #CCCCCC; bottom dock stays sharp above everything
   ========================================================================== */

/* Full-viewport inverted #CCCCCC backdrop layered above .about-backdrop (z:2) */
.contact-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background-color: var(--color-text);
  opacity: 0;
}

/* Contact section stage — right-aligned editorial block opposite the left portrait */
.contact-stage {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  padding-left: clamp(1.5rem, 4vw, 4rem);
  padding-right: clamp(1.5rem, 6vw, 6.5rem);
  padding-top: clamp(6rem, 12dvh, 8rem);
  padding-bottom: calc(clamp(3.5rem, 8dvh, 5.5rem) + 72px);
  background: transparent;
}

/* Mirror editorial column on the right facing the left-cropped portrait */
.contact__layout {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: clamp(1.5rem, 3.6dvh, 2.5rem);
  width: min(52vw, 720px);
}

.contact__headline {
  color: var(--color-bg);
  font-family: var(--font-sans);
  font-size: clamp(1.5rem, 2.75vw, 2.65rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.015em;
  text-align: left;
  text-wrap: balance;
  font-kerning: none;
}

.contact__divider {
  width: 100%;
  height: 1px;
  background-color: var(--color-bg);
  opacity: 0.2;
  transform-origin: left center;
}

.contact__description {
  max-width: 44ch;
  color: var(--color-bg);
  font-family: var(--font-sans);
  font-size: clamp(0.92rem, 1.12vw, 1.08rem);
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: 0.02em;
  text-align: left;
  text-wrap: pretty;
  font-kerning: none;
}

.contact__action {
  padding-top: clamp(0.25rem, 1dvh, 0.75rem);
}

/* Clickable rounded email pill matching Work category tag geometry, adapted to inverted Contact scheme */
.contact__email-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 48px;
  padding: clamp(0.7rem, 1vw, 0.9rem) clamp(1.4rem, 2vw, 1.85rem);
  border-radius: 9999px;
  border: 1px solid var(--color-bg);
  background-color: transparent;
  color: var(--color-bg);
  font-family: var(--font-sans);
  font-size: clamp(0.84rem, 0.98vw, 0.96rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.03em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 0.45s var(--ease-brutalist),
    color 0.45s var(--ease-brutalist),
    transform 0.45s var(--ease-brutalist);
}

.contact__email-pill:hover {
  background-color: var(--color-bg);
  color: var(--color-text);
  transform: translate3d(0, -2px, 0);
}

.contact__email-pill:active {
  transform: translate3d(0, 0, 0);
}

.contact__email-pill:focus-visible {
  outline: 2px solid var(--color-bg);
  outline-offset: 4px;
}

/* --------------------------------------------------------------------------
   Native CSS Scroll-Driven About -> Contact Transition (100% Reversible)
   - Hoisted --contact-enter-tl on #main-content coordinates all 4 tracks:
     1. About text upward blur-exit (entry 0% -> 52%)
     2. Single portrait quick smooth glide Right -> Left (entry 10% -> 70%)
     3. Background inversion #0a0a0a -> #CCCCCC (entry 10% -> 76%)
     4. Staggered Contact blur-rise entrance (entry 44% -> 98%)
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  @supports (
    (animation-timeline: view()) and
    (animation-range: entry) and
    (timeline-scope: --contact-enter-tl)
  ) {
    .contact-stage {
      view-timeline: --contact-enter-tl block;
    }

    /* 1. About copy exits smoothly upward with blur */
    .about__layout {
      will-change: transform, opacity, filter;
      animation: about-layout-exit auto linear both;
      animation-timeline: --contact-enter-tl;
      animation-range: entry 0% entry 52%;
    }

    /* 2. Single portrait glides smoothly Right (nose at 100cqi) -> Left (nose at 0) */
    .about__portrait-glide {
      will-change: transform;
      animation: portrait-glide-to-contact auto cubic-bezier(0.785, 0.135, 0.15, 0.86) both;
      animation-timeline: --contact-enter-tl;
      animation-range: entry 10% entry 70%;
    }

    /* 3. Full-viewport background transitions smoothly from #0a0a0a -> #CCCCCC */
    .contact-backdrop {
      will-change: opacity;
      animation: contact-backdrop-reveal auto linear both;
      animation-timeline: --contact-enter-tl;
      animation-range: entry 10% entry 76%;
    }

    /* 4. Contact editorial blocks rise smoothly out of blur sequentially */
    .contact__reveal {
      will-change: transform, opacity, filter;
      animation: contact-block-reveal auto linear both;
      animation-timeline: --contact-enter-tl;
    }

    .contact__headline {
      animation-range: entry 44% entry 80%;
    }

    .contact__divider {
      will-change: transform, opacity;
      animation: contact-divider-draw auto linear both;
      animation-timeline: --contact-enter-tl;
      animation-range: entry 52% entry 84%;
    }

    .contact__description {
      animation-range: entry 56% entry 90%;
    }

    .contact__action {
      animation-range: entry 64% entry 98%;
    }
  }
}

@keyframes about-layout-exit {
  0% {
    opacity: 1;
    filter: blur(0px);
    transform: translate3d(0, 0, 0);
  }
  100% {
    opacity: 0;
    filter: blur(8px);
    transform: translate3d(0, -48px, 0);
  }
}

@keyframes portrait-glide-to-contact {
  0% {
    transform: translate3d(calc(100cqi - 51.2%), 0, 0);
  }
  100% {
    transform: translate3d(-51.2%, 0, 0);
  }
}

@keyframes contact-backdrop-reveal {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@keyframes contact-divider-draw {
  0% {
    opacity: 0;
    transform: scaleX(0);
  }
  100% {
    opacity: 0.2;
    transform: scaleX(1);
  }
}

@keyframes contact-block-reveal {
  0% {
    opacity: 0;
    filter: blur(10px);
    transform: translate3d(0, 28px, 0);
  }
  99% {
    opacity: 1;
    filter: blur(0px);
    transform: translate3d(0, 0, 0);
  }
  100% {
    opacity: 1;
    filter: none;
    transform: translate3d(0, 0, 0);
  }
}

/* --------------------------------------------------------------------------
   Responsive Refinements (Tablet & Mobile)
   -------------------------------------------------------------------------- */
@media (max-width: 1120px) {
  .contact__layout {
    width: min(58vw, 620px);
  }
}

@media (max-width: 820px) {
  .contact-stage {
    justify-content: flex-start;
    padding-inline: 1.5rem;
    padding-top: clamp(5.5rem, 11dvh, 7rem);
    padding-bottom: calc(2.75rem + 72px);
  }

  .contact__layout {
    width: min(88vw, 540px);
    gap: 1.4rem;
  }

  .contact__headline {
    font-size: clamp(1.35rem, 5.4vw, 1.85rem);
  }

  .contact__description {
    font-size: clamp(0.86rem, 3.6vw, 0.98rem);
    line-height: 1.58;
  }

  .contact__email-pill {
    font-size: clamp(0.8rem, 3.3vw, 0.92rem);
    padding: 0.72rem 1.35rem;
  }
}

/* Reduced motion: clean static inverted Contact surface without scroll motion */
@media (prefers-reduced-motion: reduce) {
  .contact-backdrop {
    display: none;
  }

  .contact-stage {
    background-color: var(--color-text);
  }

  .about__layout,
  .contact__reveal,
  .contact__divider {
    animation: none !important;
    filter: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .contact__divider {
    opacity: 0.2 !important;
  }

  .contact__email-pill {
    transition: none;
  }
}
