/* ==========================================================================
   Telamorph — Composite Development (scrollytelling)
   A single design "comes into focus": one media panel pins in place and
   evolves (CAD → DFM → laminate → mold → finished part) while the development
   stages scroll past beside it. Distinct from Manufacturing's production line.
   Reuses service.css for the hero, CTA, chips and catch line.
   ========================================================================== */

/* ==========================================================================
   Ambient backdrop (Composite Development page only)
   A faint blue accent sheen drifts across the page for depth, on body::after,
   pulled behind content via negative z-index. For a negative-z layer to show,
   <body> must be transparent: the `html body` selector (specificity 0,0,2)
   overrides this page's inline `html, body { background-color: #111215 }`
   (0,0,1) without editing the HTML; <html> keeps the base colour, so there is
   no white flash. This file only loads on composite-development.html, so no
   other page is affected.
   ========================================================================== */
html body {
  background-color: transparent;
}

/* Slow-drifting accent sheen — blue only (on-palette), oversized so the drift
   never exposes an edge. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-color: var(--bg-primary);
}

body::after {
  content: "";
  position: fixed;
  inset: -25%;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(
      40% 50% at 28% 22%,
      rgba(91, 168, 245, 0.18),
      transparent 70%
    ),
    radial-gradient(
      45% 55% at 78% 82%,
      rgba(61, 147, 237, 0.13),
      transparent 70%
    );
  filter: blur(40px);
  animation: cf-sheen 26s ease-in-out infinite alternate;
}

@keyframes cf-sheen {
  from {
    transform: translate3d(-9%, -6%, 0) scale(1.05);
  }
  to {
    transform: translate3d(11%, 7%, 0) scale(1.2);
  }
}

@media (prefers-reduced-motion: reduce) {
  body::after {
    animation: none;
  }
}

.cd-scrolly {
  padding: clamp(1.5rem, 5vh, 3.5rem) 0 clamp(3rem, 9vh, 6rem);
}

.cd-scrolly-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 5vw, 5.5rem);
  align-items: start;
}

/* ----- Sticky media column ----- */
/* The sticky element holds the full available viewport height and centres the
   media inside it, so a short (landscape) stage settles in the middle instead
   of clinging to the top while taller stages still fill the space. */
.cd-sticky {
  position: sticky;
  top: calc(var(--nav-height, 72px) + 25px + 1.75rem);
  height: calc(100vh - var(--nav-height, 72px) - 25px - 3.5rem);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cd-stage-media {
  position: relative;
  aspect-ratio: 4 / 5;
  width: 100%;
  max-height: 100%;
  margin-inline: auto;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background-color: var(--bg-elevated);
  box-shadow: 0 28px 60px -30px rgba(0, 0, 0, 0.85);
}

.cd-stage-img {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: var(--focus, center);
  opacity: 0;
  transform: scale(1.05);
  transition:
    opacity 0.75s ease,
    transform 1.4s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
  /* Inactive layers stay stacked and hit-testable even at opacity:0, so the
     last one (stage 5) would otherwise sit on top and swallow clicks meant for
     the active stage — including the carousel dots. Only the active layer
     receives pointer events. */
  pointer-events: none;
}

.cd-stage-img.is-active {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.cd-stage-media::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    to top,
    rgba(17, 18, 21, 0.72) 0%,
    transparent 45%
  );
  pointer-events: none;
}

.cd-stage-tag {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  z-index: 2;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
  color: var(--text-primary);
  padding: 0.4rem 0.9rem;
  border-radius: 2rem;
  background: rgba(17, 18, 21, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Progress rail — dots track which stage is in focus */
.cd-progress {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.cd-progress-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition:
    background-color var(--transition),
    transform var(--transition);
}

.cd-progress-dot.is-active {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.35);
}

/* ----- Scrolling steps column ----- */
.cd-steps {
  display: flex;
  flex-direction: column;
}

.cd-step {
  min-height: 68vh;
  padding: clamp(2rem, 6vh, 4rem) 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* When JS drives the focus effect, dim the stages not in focus */
.cd-scrolly.is-enhanced .cd-step {
  opacity: 0.4;
  transition: opacity 0.45s ease;
}

.cd-scrolly.is-enhanced .cd-step.is-active {
  opacity: 1;
}

.cd-step-num {
  font-size: clamp(2.5rem, 1.5rem + 3vw, 4.5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  opacity: 0.85;
  margin-bottom: 0.75rem;
}

.cd-step-title {
  font-size: clamp(1.7rem, 1.2rem + 1.8vw, 2.7rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.015em;
  color: var(--accent);
  margin: 0 0 1.1rem;
}

.cd-step-body {
  font-size: clamp(1.02rem, 0.97rem + 0.25vw, 1.18rem);
  color: var(--text-primary);
  line-height: 1.65;
  margin: 0;
  max-width: 46ch;
}

/* Takeaway line — glass "pill" CTA; hover lift + cursor streak (::before)
   come from streak.css, which also drives --streak-x via main.js */
.cd-catch {
  position: relative;
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 0.65rem;
  margin: 1.75rem 0 0;
  padding: 0.85rem 1.5rem;
  font-size: clamp(1.15rem, 1rem + 0.7vw, 1.5rem);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1.5px solid rgba(255, 255, 255, 0.09);
  background-color: rgba(24, 26, 32, 0.55);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  transition:
    border-color var(--transition),
    color var(--transition),
    transform var(--transition),
    box-shadow var(--transition);
}

.cd-catch:hover,
.cd-catch:focus-visible {
  color: var(--accent-hover);
  border-color: var(--border-light);
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

/* Inline media — only shown on the stacked mobile layout */
.cd-step-media {
  display: none;
  position: relative;
  aspect-ratio: 16 / 11;
  margin-bottom: 1.5rem;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background-size: cover;
  background-position: var(--focus, center);
}

.cd-step-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(17, 18, 21, 0.5) 0%,
    transparent 55%
  );
}

.cd-step-media-tag {
  position: absolute;
  left: 0.9rem;
  bottom: 0.9rem;
  z-index: 1;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
  color: var(--text-primary);
  padding: 0.35rem 0.8rem;
  border-radius: 2rem;
  background: rgba(17, 18, 21, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* ==========================================================================
   Mobile / tablet
   A plain stacked read — each step shows its own inline image (no pinning).
   The per-step text fade-in comes from the site-wide `.reveal` system (main.js)
   applied to each step's content in the markup, so there is nothing layout- or
   scroll-position-dependent here — just the stacked layout itself.
   ========================================================================== */
@media (max-width: 991.98px) {
  .cd-scrolly-grid {
    display: block;
  }

  /* ---- Safe fallback: stacked inline images ---- */
  .cd-sticky {
    display: none;
  }

  .cd-step-media {
    display: block;
  }

  .cd-step {
    min-height: 0;
    padding: clamp(2.25rem, 7vh, 3.5rem) 0;
  }

  .cd-step-num {
    margin-bottom: 0.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cd-stage-img {
    transition: opacity 0.2s ease;
    transform: none;
  }
  .cd-stage-img.is-active {
    transform: none;
  }
}
