/* ==========================================================================
   Product showcase — scroll-driven 3D chapter sequence
   ========================================================================== */

.showcase {
  --chapters: 7;
  --cover-run: 88vh;
  --cover-run: 88svh;
  --fg: #111111;
  --fg-muted: rgba(17, 17, 17, 0.56);
  --fg-faint: rgba(17, 17, 17, 0.16);
  --accent: #2b60ad;
  --chip: rgba(255, 255, 255, 0.78);

  position: relative;
  height: calc(100svh + (var(--chapters) - 1) * 68svh + var(--cover-run));
  background: #ffffff;
  overflow-anchor: none;
}

.showcase.is-dark {
  --fg: #ffffff;
  --fg-muted: rgba(255, 255, 255, 0.62);
  --fg-faint: rgba(255, 255, 255, 0.22);
  --accent: #ffb469;
  --chip: rgba(18, 13, 9, 0.55);
}

.showcase-pin {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;
  isolation: isolate;
  outline: none;
}

/* -- 3D stage -------------------------------------------------------------- */

.showcase-stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(180deg, #ffffff 0%, #e7e1d5 100%);
}

.showcase-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: pan-y;
  opacity: 0;
  transition: opacity 0.9s ease 0.1s;
}

.showcase.is-live .showcase-stage canvas {
  opacity: 1;
}

.showcase-stage canvas.is-grabbing {
  cursor: grabbing;
}

.showcase-fallback {
  position: absolute;
  inset: 0;
}

.showcase-fallback img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* -- Annotations ----------------------------------------------------------- */

.showcase-annotations {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.annotation {
  transition: opacity 0.25s linear;
}

.annotation-lead,
.annotation-span,
.annotation-tick {
  stroke: var(--accent);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.annotation-lead {
  stroke-dasharray: 3 3;
  opacity: 0.65;
}

.annotation-dot {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.4;
}

.annotation-arrow-shaft,
.annotation-arrow-head {
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.annotation-arrow-head {
  fill: none;
}

.showcase-markers {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.annotation-label {
  position: absolute;
  top: 0;
  left: 0;
  white-space: nowrap;
  font-family: var(--display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--chip);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: 2px;
  padding: 4px 8px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.25s linear;
  will-change: transform;
}

.annotation-label--marker {
  color: var(--fg);
  border-color: var(--fg-faint);
}

/* -- Chrome ---------------------------------------------------------------- */

.showcase-ui {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  color: var(--fg);
  transition: color 0.6s ease;
}

.showcase-ui button {
  pointer-events: auto;
}

.showcase-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Chapter copy */

.showcase-copy {
  position: absolute;
  left: var(--pad);
  bottom: clamp(96px, 14vh, 160px);
  width: min(430px, 34vw);
  height: 260px;
  overflow: hidden;
}

.showcase-card {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  visibility: hidden;
  transform-origin: 0% 0%;
  backface-visibility: hidden;
  will-change: opacity, transform;
}

.showcase-card-index {
  font-family: var(--display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--accent);
  margin: 0 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--fg-faint);
  transition: color 0.6s ease, border-color 0.6s ease;
}

.showcase-card-title {
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(28px, 3.1vw, 44px);
  line-height: 1.06;
  letter-spacing: -0.035em;
  margin: 0 0 12px;
}

.showcase-card-body {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--fg-muted);
  max-width: 34ch;
  transition: color 0.6s ease;
}

/* Chapter rail */

.showcase-rail {
  position: absolute;
  right: var(--pad);
  top: 50%;
  transform: translateY(-50%);
  pointer-events: auto;
}

.showcase-rail-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.showcase-rail-item {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  width: 100%;
  min-height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--fg-muted);
  font-family: var(--display);
  transition: color 0.3s ease;
}

.showcase-rail-item:hover,
.showcase-rail-item:focus-visible {
  color: var(--fg);
}

.showcase-rail-num {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  opacity: 0;
  transform: translateX(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.showcase-rail-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  transition: max-width 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s ease;
}

.showcase-rail-tick {
  display: block;
  width: 22px;
  height: 1px;
  background: currentColor;
  opacity: 0.4;
  transition: width 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s ease;
}

.showcase-rail-item.is-active {
  color: var(--accent);
}

.showcase-rail-item.is-active .showcase-rail-num,
.showcase-rail-item:hover .showcase-rail-num {
  opacity: 1;
  transform: none;
}

.showcase-rail-item.is-active .showcase-rail-label,
.showcase-rail-item:hover .showcase-rail-label {
  max-width: 22ch;
  opacity: 1;
}

.showcase-rail-item.is-active .showcase-rail-tick {
  width: 40px;
  opacity: 1;
}

/* Progress + counter */

.showcase-progress {
  position: absolute;
  right: calc(var(--pad) - 14px);
  top: 22%;
  bottom: 22%;
  width: 1px;
  background: var(--fg-faint);
  transition: background 0.6s ease;
}

.showcase-progress i {
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform-origin: top center;
  transform: scaleY(0);
  transition: background 0.6s ease;
}

.showcase-count {
  position: absolute;
  left: var(--pad);
  bottom: clamp(44px, 6vh, 64px);
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--fg-muted);
  transition: color 0.6s ease;
}

.showcase-count b {
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--fg);
}

/* Hints */

.showcase-hint,
.showcase-drag {
  position: absolute;
  margin: 0;
  font-family: var(--display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-muted);
  transition: opacity 0.5s ease, color 0.6s ease;
}

.showcase-hint {
  left: 50%;
  bottom: clamp(44px, 6vh, 64px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.showcase-hint::after {
  content: "";
  width: 1px;
  height: 34px;
  background: linear-gradient(180deg, currentColor, transparent);
  animation: showcase-hint-slide 2.1s ease-in-out infinite;
}

@keyframes showcase-hint-slide {
  0%,
  100% {
    transform: scaleY(0.35);
    transform-origin: top;
    opacity: 0.3;
  }
  50% {
    transform: scaleY(1);
    transform-origin: top;
    opacity: 1;
  }
}

.showcase-drag {
  right: var(--pad);
  bottom: clamp(44px, 6vh, 64px);
  opacity: 0.7;
}

/* -- Static fallback ------------------------------------------------------- */

.showcase.is-static {
  height: auto;
  padding: 96px 0;
}

.showcase.is-static .showcase-pin {
  position: static;
  height: auto;
  display: grid;
  gap: 40px;
}

.showcase.is-static .showcase-stage {
  position: relative;
  height: 60vh;
}

.showcase.is-static .showcase-ui {
  position: static;
}

.showcase.is-static .showcase-copy,
.showcase.is-static .showcase-count {
  position: static;
  width: auto;
  height: auto;
  max-width: none;
  padding: 0 var(--pad);
}

.showcase.is-static .showcase-copy {
  display: grid;
  gap: 40px;
  margin-top: 40px;
  overflow: visible;
  -webkit-mask-image: none;
  mask-image: none;
}

.showcase.is-static .showcase-card {
  position: static;
  opacity: 1;
  visibility: visible;
  max-width: 46ch;
  transform: none;
  -webkit-mask-image: none;
  mask-image: none;
}

.showcase.is-static .showcase-rail,
.showcase.is-static .showcase-progress,
.showcase.is-static .showcase-hint,
.showcase.is-static .showcase-drag,
.showcase.is-static .showcase-annotations,
.showcase.is-static .showcase-markers {
  display: none;
}

/* -- Capture mode (headless poster rendering) ------------------------------ */

body.is-capture .chrome,
body.is-capture .cookie-bar,
body.is-capture .showcase-ui,
body.is-capture .showcase-annotations,
body.is-capture .showcase-markers {
  display: none !important;
}

body.is-capture .showcase-stage canvas {
  opacity: 1;
  transition: none;
}

/* -- Responsive ------------------------------------------------------------ */

@media (max-width: 1180px) {
  .showcase-copy {
    width: min(390px, 42vw);
  }
  .showcase-rail-label {
    display: none;
  }
}

@media (max-width: 900px) {
  .showcase {
    height: calc(100svh + (var(--chapters) - 1) * 94svh + var(--cover-run));
  }

  .showcase-pin {
    display: flex;
    flex-direction: column;
  }

  .showcase-stage {
    position: relative;
    flex: 0 0 54svh;
    height: 54svh;
  }

  .showcase-ui {
    position: relative;
    inset: auto;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    padding: 18px var(--pad) calc(20px + env(safe-area-inset-bottom));
  }

  /* The UI sits on its own light panel here rather than over the render, so a
     dark chapter must not invert the text with it. */
  .showcase.is-dark .showcase-ui {
    --fg: #111111;
    --fg-muted: rgba(17, 17, 17, 0.56);
    --fg-faint: rgba(17, 17, 17, 0.16);
    --accent: #b4600f;
  }

  .showcase-copy {
    position: relative;
    left: auto;
    bottom: auto;
    width: 100%;
    height: 240px;
    flex: 0 0 auto;
    min-height: 0;
  }

  .showcase-card {
    top: 0;
    bottom: auto;
  }

  .showcase-card-index {
    margin-bottom: 10px;
    padding-bottom: 8px;
  }

  .showcase-card-title {
    font-size: clamp(24px, 6.6vw, 32px);
  }

  .showcase-card-body {
    font-size: 14px;
    max-width: none;
  }

  /* Rail collapses to a row of ticks under the copy. */
  .showcase-rail {
    position: static;
    transform: none;
    margin-top: auto;
  }

  .showcase-rail-list {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
  }

  .showcase-rail-item {
    min-height: 40px;
    min-width: 32px;
    justify-content: center;
  }

  .showcase-rail-num,
  .showcase-rail-label {
    display: none;
  }

  .showcase-rail-tick {
    width: 100%;
    max-width: 34px;
    height: 2px;
  }

  .showcase-rail-item.is-active .showcase-rail-tick {
    width: 100%;
  }

  .showcase-progress,
  .showcase-drag {
    display: none;
  }

  /* The dimensions are the point of the section, so they stay on the phone —
     just smaller, since the stage is roughly a third of the desktop width. */
  .annotation-label {
    font-size: 9px;
    letter-spacing: 0.08em;
    padding: 3px 6px;
  }

  .showcase-count {
    position: absolute;
    right: var(--pad);
    left: auto;
    top: -34px;
    bottom: auto;
  }

  .showcase-hint {
    bottom: auto;
    top: 40svh;
  }

  .showcase.is-static .showcase-stage {
    height: 46vh;
  }
}

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