/*
  MOTION + LAYOUT FIX — final layer (loads after vibrant-brand.css)
  Resolves Framer-style motion conflicts, section rhythm, carousel layout
*/

/* ─── DISABLE content-visibility (causes scroll/layout jumps) ─────── */
.bento-section,
.bento-section:not(#process) {
  content-visibility: visible !important;
  contain-intrinsic-size: auto !important;
}

/* ─── UNIFIED MOTION — override legacy main.css .reveal ──────────── */
.reveal:not(.motion-fly) {
  transform: translateY(28px);
  transition:
    opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal:not(.motion-fly).visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal.motion-fly {
  opacity: 0;
  will-change: transform, opacity;
  transition:
    opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.65s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.55s cubic-bezier(0.22, 1, 0.36, 1) !important;
  filter: none;
}

.reveal.motion-fly[data-fly="up"]:not(.visible) {
  transform: translate3d(0, 28px, 0) scale(0.992) !important;
  filter: blur(2px) !important;
}

.reveal.motion-fly[data-fly="left"]:not(.visible) {
  transform: translate3d(-24px, 16px, 0) scale(0.992) !important;
  filter: blur(2px) !important;
}

.reveal.motion-fly[data-fly="right"]:not(.visible) {
  transform: translate3d(24px, 16px, 0) scale(0.992) !important;
  filter: blur(2px) !important;
}

.reveal.motion-fly[data-fly="pop"]:not(.visible) {
  transform: translate3d(0, 16px, 0) scale(0.98) !important;
  filter: blur(2px) !important;
}

.reveal.motion-fly[data-fly="fade"]:not(.visible) {
  transform: translate3d(0, 12px, 0) scale(1) !important;
  filter: none !important;
}

.reveal.motion-fly.visible {
  opacity: 1 !important;
  transform: translate3d(0, 0, 0) scale(1) rotate(0) !important;
  filter: blur(0) !important;
  will-change: auto;
}

/* Stagger — only when becoming visible */
.reveal.motion-fly.reveal-delay-1 { transition-delay: 0.07s; }
.reveal.motion-fly.reveal-delay-2 { transition-delay: 0.14s; }
.reveal.motion-fly.reveal-delay-3 { transition-delay: 0.21s; }
.reveal.motion-fly.reveal-delay-4 { transition-delay: 0.28s; }
.reveal.motion-fly.reveal-delay-5 { transition-delay: 0.35s; }

/* Process carousel cards — no fly (GSAP / horizontal scroll) */
.process-carousel-track .bento-process-cell,
.process-carousel-track .bento-process-cell.reveal,
.process-carousel-rail .bento-process-cell,
.process-carousel-rail .bento-process-cell.reveal {
  opacity: 1 !important;
  transform: none !important;
  filter: none !important;
  transition: transform 0.35s ease, box-shadow 0.35s ease, filter 0.35s ease !important;
}

/* Page sections — subtle fade only, no blur */
.page-section.reveal.motion-fly:not(.visible) {
  transform: translate3d(0, 20px, 0) !important;
  filter: none !important;
}

/* ─── LAYOUT RHYTHM — fix double gaps ───────────────────────────── */
#materials,
#process,
#metrics,
#projects,
#workshop,
#cta {
  margin-top: 0 !important;
}

.bento-section + .bento-section,
.pin-spacer + .bento-section {
  padding-top: var(--section-v) !important;
}

.pin-spacer + #metrics.bento-section {
  padding-top: clamp(36px, 5vh, 64px) !important;
}

#philosophy.bento-section {
  padding-top: calc(var(--section-v) + 16px) !important;
}

@media (max-width: 900px) {
  .bento-section + .bento-section,
  .pin-spacer + .bento-section {
    padding-top: var(--section-v-sm) !important;
  }

  .pin-spacer + #metrics.bento-section {
    padding-top: clamp(28px, 4vh, 48px) !important;
  }
  #philosophy.bento-section {
    padding-top: calc(var(--section-v-sm) + 12px) !important;
  }
}

/* ─── HOMEPAGE: hero, marquee, journey alignment ─────────────────── */
body.home-page #hero {
  margin-left: calc(-1 * var(--site-edge)) !important;
  margin-right: calc(-1 * var(--site-edge)) !important;
  width: calc(100% + (var(--site-edge) * 2)) !important;
  max-width: none !important;
}

body.home-page .bento-marquee {
  margin-left: calc(-1 * var(--site-edge));
  margin-right: calc(-1 * var(--site-edge));
  width: calc(100% + (var(--site-edge) * 2));
  padding-left: var(--h-pad);
  padding-right: var(--h-pad);
  box-sizing: border-box;
}

body.home-page .journey-strip {
  margin-left: auto;
  margin-right: auto;
  width: calc(100% - (var(--site-edge) * 0));
  max-width: calc(var(--max-w));
  box-sizing: border-box;
}

@media (max-width: 900px) {
  body.home-page .journey-strip {
    width: calc(100% + (var(--site-edge) * 0));
    margin-left: 0;
    margin-right: 0;
  }
}

/* ─── BENTO GRID — consistent cell sizing ─────────────────────────── */
.bento-grid-12 {
  align-items: stretch;
}

.bento-cell,
.bento-material-cell,
.bento-project-cell {
  min-height: 0;
}

.bento-section-header {
  margin-bottom: 56px !important;
  max-width: calc(var(--max-w) - (var(--h-pad) * 2));
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

.bento-section-header.reveal.motion-fly:not(.visible) {
  transform: translate3d(0, 20px, 0) !important;
  filter: none !important;
}

/* ─── PROCESS CAROUSEL — horizontal layout + GSAP pin (authoritative) ─ */
#process.bento-section.has-process-carousel,
#process.bento-section.carousel-gsap {
  display: flex !important;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  box-sizing: border-box;
  padding-top: clamp(72px, 10vh, 128px);
  padding-bottom: clamp(28px, 4vh, 48px);
}

#process .process-carousel-section {
  position: relative;
  overflow: hidden;
  flex: 1 1 auto;
  width: 100%;
  max-width: none;
  min-height: clamp(420px, 52vh, 540px);
}

#process .process-carousel-section.carousel-gsap {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
  padding-left: 0;
  padding-right: 0;
  box-sizing: border-box;
}

#process.carousel-gsap .bento-section-header,
#process.bento-section.has-process-carousel .bento-section-header {
  padding-left: var(--h-pad);
  padding-right: var(--h-pad);
  max-width: calc(var(--max-w) - (var(--h-pad) * 2));
  margin-left: auto;
  margin-right: auto;
  width: 100%;
  box-sizing: border-box;
}

#process .process-carousel-track {
  overflow: hidden;
  width: 100%;
}

#process .process-carousel-rail {
  display: flex !important;
  flex-flow: row nowrap !important;
  align-items: stretch;
  width: max-content;
  gap: 18px;
  padding-left: 0;
  padding-right: max(var(--site-edge), 24px);
  will-change: transform;
}

#process .process-carousel-rail .bento-process-cell {
  flex: 0 0 auto !important;
  display: flex;
  flex-direction: column;
  width: clamp(300px, 28vw, 400px);
  min-height: clamp(400px, 50vh, 500px);
  opacity: 1 !important;
  transform: none !important;
  filter: none !important;
  box-sizing: border-box;
}

@media (max-width: 700px) {
  #process.bento-section.has-process-carousel,
  #process.bento-section.carousel-gsap {
    min-height: 100svh;
    padding-top: clamp(48px, 8vh, 88px);
    padding-bottom: clamp(20px, 3vh, 36px);
  }

  #process .process-carousel-section.carousel-gsap {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
    min-height: clamp(380px, 58svh, 520px);
  }

  #process.carousel-gsap .bento-section-header,
  #process.bento-section.has-process-carousel .bento-section-header {
    padding-left: var(--h-pad-sm);
    padding-right: var(--h-pad-sm);
  }

  #process .process-carousel-rail {
    gap: 16px;
    padding-left: 0;
    padding-right: max(var(--site-edge), 20px);
  }

  #process .process-carousel-rail .bento-process-cell {
    width: min(78vw, 360px);
    min-height: 420px;
  }
}

/* Fallback: keep horizontal row, native swipe if GSAP unavailable */
#process .process-carousel-section.carousel-fallback {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#process .process-carousel-section.carousel-fallback::-webkit-scrollbar {
  display: none;
}

#process .process-carousel-section.carousel-fallback .process-carousel-rail {
  transform: none !important;
}

#process .process-carousel-section.carousel-fallback .bento-process-cell {
  scroll-snap-align: start;
}

/* ─── PROCESS CAROUSEL ───────────────────────────────────────────── */
#process .process-carousel-section {
  max-width: none;
  margin-top: 0;
}

#process .process-carousel-section.carousel-gsap {
  width: 100%;
  max-width: 100%;
}

@media (max-width: 700px) {
  #process .process-carousel-section.carousel-gsap {
    width: calc(100% + (var(--h-pad-sm) * 2));
  }

  #process .process-carousel-section:not(.carousel-gsap) {
    width: calc(100% + (var(--h-pad-sm) * 2));
    max-width: none;
    min-height: 0;
  }
}

.process-carousel-section {
  overflow: hidden;
  min-height: 580px;
}

/* Hide native scrollbars when fallback horizontal scroll is active */
.process-carousel-section.carousel-fallback,
.process-carousel-section:not(.carousel-gsap) {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.process-carousel-section.carousel-fallback::-webkit-scrollbar,
.process-carousel-section:not(.carousel-gsap)::-webkit-scrollbar {
  display: none;
}

@media (max-width: 900px) {
  .process-carousel-section:not(.carousel-gsap) {
    min-height: 0;
  }

  #process.carousel-gsap {
    min-height: 100svh;
    padding-top: clamp(48px, 8vh, 88px);
    padding-bottom: clamp(48px, 8vh, 88px);
  }

  .process-carousel-section.carousel-gsap {
    overflow: hidden;
    margin-left: calc(-1 * var(--h-pad-sm));
    margin-right: calc(-1 * var(--h-pad-sm));
    width: calc(100% + (var(--h-pad-sm) * 2));
    padding-left: var(--h-pad-sm);
    padding-right: 0;
    box-sizing: border-box;
    min-height: clamp(380px, 58svh, 520px);
  }

  .process-carousel-section.carousel-gsap .process-carousel-rail {
    gap: 0;
    padding-right: var(--h-pad-sm);
  }

  .process-carousel-section.carousel-gsap .process-carousel-rail .bento-process-cell {
    width: min(84vw, 320px);
    min-height: 420px;
  }
}

@media (min-width: 901px) {
  .process-carousel-section.carousel-gsap {
    overflow: hidden;
    min-height: clamp(420px, 52vh, 540px);
  }

  .process-carousel-section.carousel-gsap .process-carousel-rail .bento-process-cell {
    width: clamp(280px, 26vw, 380px);
    min-height: clamp(400px, 50vh, 500px);
  }
}

.process-carousel-track {
  overflow: hidden;
  width: 100%;
}

.process-carousel-rail {
  display: flex;
  gap: 18px;
  width: max-content;
  padding-right: max(var(--h-pad), 24px);
  padding-left: 0;
  align-items: stretch;
}

.process-carousel-rail .bento-process-cell {
  flex: 0 0 auto;
  width: clamp(300px, 30vw, 420px);
  min-height: 520px;
  display: flex;
  flex-direction: column;
}

/* Mobile: native horizontal scroll (no GSAP pin) */
@media (max-width: 900px) {
  .process-carousel-section:not(.carousel-gsap) {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scroll-padding-left: var(--h-pad-sm);
    min-height: 0;
    padding-bottom: 12px;
    margin-left: calc(-1 * var(--h-pad-sm));
    margin-right: calc(-1 * var(--h-pad-sm));
    padding-left: var(--h-pad-sm);
    padding-right: var(--h-pad-sm);
    width: calc(100% + (var(--h-pad-sm) * 2));
    box-sizing: border-box;
  }

  .process-carousel-section:not(.carousel-gsap) .process-carousel-track {
    overflow: visible;
    width: auto;
  }

  .process-carousel-section:not(.carousel-gsap) .process-carousel-rail {
    transform: none !important;
    padding-right: var(--h-pad-sm);
    gap: 16px;
  }

  .process-carousel-section:not(.carousel-gsap) .process-carousel-rail .bento-process-cell {
    flex: 0 0 auto;
    width: min(78vw, 360px);
    min-height: 460px;
    scroll-snap-align: start;
  }
}

@media (max-width: 600px) {
  .process-carousel-section:not(.carousel-gsap) .process-carousel-rail .bento-process-cell {
    width: min(84vw, 320px);
    min-height: 420px;
  }
}

/* Desktop fallback when GSAP unavailable or track fits viewport */
@media (min-width: 901px) {
  .process-carousel-section.carousel-fallback {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    min-height: 0;
    padding-bottom: 16px;
  }

  .process-carousel-section.carousel-fallback .process-carousel-track {
    overflow-x: auto;
    overflow-y: visible;
  }

  .process-carousel-section.carousel-fallback .process-carousel-rail {
    transform: none !important;
  }

  .process-carousel-section.carousel-fallback .bento-process-cell {
    scroll-snap-align: start;
  }
}

/* ─── NO-JS / reduced scripting — keep content visible ───────────── */
@media (scripting: none) {
  .reveal,
  .reveal.motion-fly,
  .reveal.motion-fly[data-fly="up"],
  .reveal.motion-fly[data-fly="left"],
  .reveal.motion-fly[data-fly="right"],
  .reveal.motion-fly[data-fly="pop"],
  .reveal.motion-fly[data-fly="fade"] {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    transition: none !important;
  }

  .process-carousel-section {
    overflow-x: auto !important;
  }

  .process-carousel-rail {
    transform: none !important;
  }
}

/* ─── INTERACTIVE MOTION — buttons & links ───────────────────────── */
@media (prefers-reduced-motion: no-preference) {
  .btn,
  .nav-cta,
  .contact-cta-actions a,
  .service-card,
  .footer-social a {
    transition:
      transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
      box-shadow 0.28s cubic-bezier(0.22, 1, 0.36, 1),
      opacity 0.28s ease;
  }

  .btn:hover,
  .nav-cta:hover,
  .contact-cta-actions a:hover {
    transform: translateY(-2px);
  }

  .service-card.visible:hover {
    transform: translateY(-4px);
  }
}

/* ─── SKIP LINK ──────────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 10000;
  padding: 12px 20px;
  background: var(--vibrant-gold, #e8b84a);
  color: #0a0812;
  font-family: var(--font-mono, "DM Mono", monospace);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  border-radius: 4px;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 16px;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ─── CTA + FOOTER spacing ───────────────────────────────────────── */
#cta.bento-section {
  padding-bottom: clamp(32px, 4vh, 52px) !important;
}

footer {
  margin-top: 0 !important;
  padding-top: 72px;
}

/* ─── INNER PAGES ────────────────────────────────────────────────── */
.page-main {
  padding-top: 0;
}

.page-hero {
  margin-left: calc(-1 * var(--site-edge));
  margin-right: calc(-1 * var(--site-edge));
  width: calc(100% + (var(--site-edge) * 2));
  padding-left: var(--h-pad);
  padding-right: var(--h-pad);
  box-sizing: border-box;
}

.page-with-sidebar {
  padding-top: 48px;
}

.page-section {
  padding-top: 72px;
  padding-bottom: 72px;
}

.page-section--surface,
.page-section--graphite {
  border-radius: var(--border-r);
  margin-bottom: var(--grid-gap);
}

/* ─── NAV — prevent overflow with 7 links ────────────────────────── */
@media (max-width: 1180px) {
  .nav-links {
    gap: 16px !important;
  }
  .nav-links a {
    font-size: 9px !important;
    letter-spacing: 0.14em !important;
  }
  .nav-cta {
    padding: 10px 14px !important;
    font-size: 9px !important;
  }
}

@media (max-width: 900px) {
  .nav-links {
    display: none;
  }
}

/* ─── HOVER — don't fight motion transform when not hovering ─────── */
.bento-cell.visible:hover,
.bento-material-cell.visible:hover,
.bento-project-cell.visible:hover {
  transform: translateY(-4px) scale(1.006) !important;
}

/* ─── REDUCED MOTION ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .reveal,
  .reveal.motion-fly,
  .reveal.motion-fly[data-fly="up"],
  .reveal.motion-fly[data-fly="left"],
  .reveal.motion-fly[data-fly="right"],
  .reveal.motion-fly[data-fly="pop"],
  .reveal.motion-fly[data-fly="fade"] {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    transition: none !important;
  }

  /* Keep scroll-scrubbed carousel — user-controlled, not auto-animated */
  .process-carousel-section:not(.carousel-gsap) .process-carousel-rail {
    transform: none !important;
  }
}

/* Leather material card — photo on inner bg layer (must beat global card glass) */
#materials .bento-mat-leather-cell.bento-material-cell.bento-cell,
#materials .bento-mat-velvet-cell.bento-material-cell.bento-cell,
#materials .bento-mat-linen-cell.bento-material-cell.bento-cell,
#materials .bento-mat-suede-cell.bento-material-cell.bento-cell {
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

#materials .bento-mat-leather-cell .bento-material-bg.bento-mat-leather {
  background:
    linear-gradient(
      180deg,
      rgba(12, 6, 3, 0.12) 0%,
      rgba(8, 4, 2, 0.35) 55%,
      rgba(5, 2, 1, 0.55) 100%
    ),
    url("../assets/aniline-leather.jpg") center center / cover no-repeat !important;
}

#materials .bento-mat-velvet-cell .bento-material-bg.bento-mat-velvet {
  background:
    linear-gradient(
      180deg,
      rgba(4, 14, 10, 0.14) 0%,
      rgba(6, 20, 14, 0.38) 55%,
      rgba(3, 10, 7, 0.62) 100%
    ),
    url("../assets/performance-velvet.jpg") center center / cover no-repeat !important;
}

#materials .bento-mat-linen-cell .bento-material-bg.bento-mat-linen {
  background:
    linear-gradient(
      180deg,
      rgba(18, 16, 12, 0.1) 0%,
      rgba(14, 12, 10, 0.34) 55%,
      rgba(10, 8, 6, 0.58) 100%
    ),
    url("../assets/heritage-linen.jpg") center center / cover no-repeat !important;
}

#materials .bento-mat-suede-cell .bento-material-bg.bento-mat-suede {
  background:
    linear-gradient(
      180deg,
      rgba(8, 7, 12, 0.12) 0%,
      rgba(10, 9, 14, 0.36) 55%,
      rgba(6, 5, 10, 0.62) 100%
    ),
    url("../assets/alcantara-microfibre.jpg") center center / cover no-repeat !important;
}

/* Process phase cards — photo on inner bg layer */
#process .bento-process-photo-cell.bento-process-cell.bento-cell {
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Breathing room between Materials and Process */
#materials.bento-section {
  padding-bottom: calc(var(--section-v) + 64px) !important;
}

#materials + #process.bento-section,
#materials + .pin-spacer {
  margin-top: 72px !important;
}

/* Breathing room between Process (GSAP pin-spacer) and Metrics */
#process.bento-section.has-process-carousel {
  padding-bottom: clamp(28px, 4vh, 48px) !important;
}

.pin-spacer + #metrics.bento-section,
#metrics.bento-section {
  margin-top: 0 !important;
  padding-top: clamp(36px, 5vh, 64px) !important;
}

@media (max-width: 900px) {
  #materials.bento-section {
    padding-bottom: calc(var(--section-v-sm) + 48px) !important;
  }

  #materials + #process.bento-section,
  #materials + .pin-spacer {
    margin-top: 56px !important;
  }

  #process.bento-section.has-process-carousel {
    padding-bottom: clamp(20px, 3vh, 36px) !important;
  }

  .pin-spacer + #metrics.bento-section,
  #metrics.bento-section {
    margin-top: 0 !important;
    padding-top: clamp(28px, 4vh, 48px) !important;
  }
}
