/* W4 — vitrine 3D (scroll-driven CAD showcase). Left = copy, right = sticky 3D stage.
   Strict CSP: no inline styles; everything lives in this file. */
.showcase {
  padding-top: clamp(1.5rem, 1rem + 4vw, 6rem);
}
.showcase-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-large);
}
.showcase-copy {
  display: grid;
  gap: clamp(3rem, 2rem + 6vw, 7rem);
  min-width: 0;
  align-content: start;
}
.showcase-intro {
  display: grid;
  gap: 0;
  align-content: center;
  min-height: calc(100svh - 8rem);
  min-height: calc(100vh - 8rem);
}
.showcase-intro .lead {
  margin-top: var(--space-medium);
  max-width: 44ch;
}
.scene-copy {
  display: grid;
  gap: var(--space-medium);
  align-content: center;
  min-height: 130vh;
  min-width: 0;
  border-top: 1px solid var(--rule);
  padding-top: var(--space-large);
  scroll-margin-top: 1rem;
}
.scene-copy .annotation {
  margin: 0;
}
.scene-copy h2 {
  max-width: 20ch;
}
.scene-copy > p {
  max-width: 52ch;
}
.scene-figure {
  margin: 0;
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 1rem;
  min-width: 0;
}
.scene-figure img {
  width: 100%;
  height: auto;
}
.scene-figure figcaption {
  margin-top: 0.75rem;
}
.spec-table {
  margin: 0;
  border: 1px solid var(--rule);
  font-size: var(--text-small);
}
.spec-table div {
  display: grid;
  grid-template-columns: minmax(7rem, 11rem) minmax(0, 1fr);
  gap: 0.25rem 1rem;
  padding: 0.5rem 0.75rem;
}
.spec-table div + div {
  border-top: 1px solid var(--rule);
}
.spec-table dt {
  font-family: var(--annotation-font);
  letter-spacing: 0.025em;
}
.spec-table dd {
  margin: 0;
  font-family: var(--annotation-font);
  overflow-wrap: anywhere;
}

/* ---------- sticky 3D stage ---------- */
.showcase-stage {
  order: -1;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--graphite);
  padding-block: 0.5rem;
  min-width: 0;
}
.stage-sticky {
  display: grid;
  gap: 0.5rem;
}
.stage-frame {
  position: relative;
  margin: 0;
  border: 1px solid var(--rule);
  background-color: var(--surface);
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 31px, var(--grid) 31px, var(--grid) 32px),
    repeating-linear-gradient(90deg, transparent, transparent 31px, var(--grid) 31px, var(--grid) 32px);
  /* Mobile: height from the viewport, width from the column (an aspect ratio plus a min-height overflowed 375 px screens). */
  width: 100%;
  height: 38vh;
  height: 38svh;
  min-height: 13rem;
  overflow: hidden;
  min-width: 0;
}
.stage-frame img.stage-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.stage-frame canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.stage-frame canvas[hidden] {
  display: none;
}
.stage-overlay {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: end;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  font-family: var(--annotation-font);
  font-size: 0.75rem;
  line-height: 1.5;
  background: linear-gradient(transparent, rgba(30, 30, 46, 0.88));
  pointer-events: none;
}
.stage-overlay[hidden] {
  display: none;
}
.stage-overlay ol,
.stage-overlay ul,
.stage-overlay dl {
  list-style: none;
  margin: 0;
  padding: 0;
}
.feat-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
}
.feat-list li {
  opacity: 0.55;
}
.feat-list li[data-active="true"] {
  opacity: 1;
  color: var(--signal);
}
.feat-list li::before {
  content: "▸ ";
}
.param-mirror {
  display: flex;
  gap: 1rem;
}
.param-mirror div {
  display: grid;
}
.param-mirror dt {
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  opacity: 0.8;
}
.param-mirror dd {
  margin: 0;
  color: var(--signal);
}
.stage-badge {
  position: absolute;
  top: 0.5rem;
  inset-inline-start: 0.75rem;
  font-family: var(--annotation-font);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  border: 1px solid var(--signal);
  color: var(--signal);
  padding: 0.25rem 0.625rem;
  background: rgba(30, 30, 46, 0.82);
  pointer-events: none;
}
.stage-badge[hidden] {
  display: none;
}
.stage-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  border: 1px solid var(--rule);
  border-top: 0;
  padding: 0.375rem 0.75rem;
  min-height: 3rem;
}
.stage-caption {
  margin: 0;
}
.edge-toggle {
  font: inherit;
  font-family: var(--annotation-font);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  background: transparent;
  color: var(--paper);
  border: 1px solid var(--rule);
  min-height: 2.75rem;
  padding: 0.375rem 0.875rem;
  cursor: pointer;
}
.edge-toggle:hover {
  border-color: var(--signal);
  color: var(--signal);
}
.edge-toggle[aria-pressed="true"] {
  border-color: var(--signal);
  color: var(--signal);
}

/* automation parameter panel (left column, works without 3D) */
.param-panel {
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 1rem;
  display: grid;
  gap: 0.75rem;
}
.param-panel .param-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  align-items: baseline;
}
.rule-badge {
  font-family: var(--annotation-font);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--highlight);
  border: 1px solid var(--highlight);
  padding: 0.25rem 0.625rem;
}
.param-row {
  display: grid;
  gap: 0.375rem;
}
.param-row label {
  font-family: var(--annotation-font);
  font-size: var(--text-small);
}
.param-row output {
  font-family: var(--annotation-font);
  color: var(--signal);
}
.param-values {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin: 0;
}
.param-values div {
  display: grid;
  gap: 0.125rem;
}
.param-values dt {
  font-family: var(--annotation-font);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}
.param-values dd {
  margin: 0;
  font-family: var(--annotation-font);
  color: var(--signal);
}
input[type="range"].param-slider {
  width: 100%;
  min-height: 2.75rem;
  accent-color: var(--signal);
  background: transparent;
}
.param-rule {
  margin: 0;
  font-size: 0.75rem;
}

/* vault states + pack line (drawing scene, reused W3 pattern) */
.state-chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 0;
  padding: 0;
}
.state-chips li {
  border: 1px solid var(--rule);
  padding: 0.375rem 0.75rem;
  font-family: var(--annotation-font);
  font-size: var(--text-small);
}
.state-chips li.done {
  border-color: var(--validated);
  color: var(--validated);
}
.state-chips li.current {
  border-color: var(--signal);
  color: var(--signal);
}
.pack-line {
  margin: 1rem 0 0;
  border: 1px solid var(--rule);
}
.pack-line div {
  display: grid;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
}
.pack-line div + div {
  border-top: 1px solid var(--rule);
}
.pack-line dt {
  font-family: var(--annotation-font);
  font-size: var(--text-small);
}
.pack-line dd {
  margin: 0;
}

/* 3D live state: hide in-flow posters, reveal canvas */
html.w4-live .scene-figure {
  display: none;
}
html.w4-live .stage-frame img.stage-poster {
  display: none;
}

/* debug screenshot mode (?scene=N[&seg=..&p=..]): stage only, fullscreen */
body.w4-debug {
  overflow: hidden;
}
body.w4-debug .site-header,
body.w4-debug .showcase-copy,
body.w4-debug main > *:not(.showcase),
body.w4-debug .site-footer,
body.w4-debug .stage-bar,
body.w4-debug .skip-link {
  display: none !important;
}
body.w4-debug .showcase-grid {
  display: block;
}
body.w4-debug .showcase-stage {
  position: static;
  padding: 0;
}
body.w4-debug .stage-frame {
  max-height: none;
  aspect-ratio: auto;
  height: calc(100vh - 1rem);
  height: calc(100svh - 1rem);
}
body.w4-debug .stage-overlay,
body.w4-debug .stage-badge {
  font-size: 0.875rem;
}

@media (min-width: 960px) {
  .showcase-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--space-large);
    align-items: start;
  }
  .showcase-stage {
    order: 0;
    top: 1rem;
    padding-block: 0;
    background: transparent;
  }
  .stage-frame {
    height: auto;
    min-height: 0;
    aspect-ratio: 4 / 3;
    max-height: calc(100vh - 8rem);
    max-height: calc(100svh - 8rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

@media (forced-colors: active) {
  .feat-list li[data-active="true"],
  .param-values dd,
  .param-mirror dd,
  .param-row output {
    color: Highlight;
  }
  .stage-badge,
  .rule-badge {
    border-color: CanvasText;
    color: CanvasText;
  }
}

[data-bend-status] {
  margin: 0;
}
