/* The Assay Index - live bench (js/lab3d.js). Uses the palette from style.css */

.bench {
  --bench-radius: var(--radius-lg, 0.75rem);
  border-radius: var(--bench-radius);
  background: var(--paper-2, #fbf9f3);
  box-shadow: var(--shadow-md), inset 0 0 0 1px var(--rule, #d8d2c4);
  overflow: hidden;
}

.bench-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  min-height: 260px;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(251, 249, 243, 0.95), rgba(236, 231, 219, 0.9) 60%, rgba(223, 228, 216, 0.85)),
    var(--paper-deep, #ece7db);
  cursor: grab;
  touch-action: pan-y;
  outline: none;
}
.bench-stage:focus-visible { box-shadow: inset 0 0 0 2px var(--sage, #5c6f5a); }
.bench-stage.is-dragging { cursor: grabbing; }
.bench-stage::after {
  /* soft vignette for depth */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(130% 95% at 50% 40%, transparent 62%, rgba(42, 38, 32, 0.08));
}
.bench-canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; max-width: none; }

/* instrument label, top-left */
.bench-tag {
  position: absolute; z-index: 2; left: var(--space-4, 1rem); top: var(--space-4, 1rem);
  display: flex; flex-direction: column; gap: 1px;
  max-width: min(60%, 22rem);
  padding: var(--space-2, 0.5rem) var(--space-3, 0.75rem);
  border-radius: var(--radius-md, 0.5rem);
  background: rgba(251, 249, 243, 0.82);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px rgba(216, 210, 196, 0.7);
  pointer-events: none;
}
.bench-tag-k { font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--wood-deep, #8a683f); font-weight: 600; }
.bench-tag-v { font-family: var(--font-display); font-size: var(--text-base, 1rem); line-height: 1.2; color: var(--ink, #2a2620); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bench-tag-s { font-size: var(--text-xs, 0.75rem); color: var(--ink-muted, #6e6759); }

/* phase rail, top-right */
.bench-rail {
  position: absolute; z-index: 2; right: var(--space-4, 1rem); top: var(--space-4, 1rem);
  list-style: none; margin: 0; padding: 6px;
  display: flex; gap: 2px;
  border-radius: 999px;
  background: rgba(251, 249, 243, 0.82);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px rgba(216, 210, 196, 0.7);
  pointer-events: none;
}
.bench-rail li {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.75rem; line-height: 1.4; color: var(--ink-faint, #a49b89); white-space: nowrap;
  max-width: none;
  transition: background var(--transition), color var(--transition);
}
.bench-rail li span { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.6; }
.bench-rail li.is-on { background: var(--sage-tint, #dfe4d8); color: var(--sage-deep, #43503f); font-weight: 600; }
.bench-rail li.is-on span { opacity: 1; background: var(--amber, #c67b2e); box-shadow: 0 0 0 3px rgba(198, 123, 46, 0.18); }

.bench-hint {
  position: absolute; z-index: 2; right: var(--space-4, 1rem); bottom: var(--space-3, 0.75rem);
  font-size: var(--text-xs, 0.75rem); color: var(--ink-muted, #6e6759);
  padding: 2px 10px; border-radius: 999px; background: rgba(251, 249, 243, 0.7);
  pointer-events: none; transition: opacity 400ms ease;
}
.bench.has-orbited .bench-hint, .bench-stage.is-fallback .bench-hint { opacity: 0; }

/* fallback */
.bench-stage.is-fallback { cursor: default; display: grid; place-items: center; }
.bench-fallback {
  position: relative; z-index: 1; display: grid; gap: var(--space-1, 0.25rem); text-align: center;
  max-width: 34ch; padding: var(--space-6, 1.5rem);
  color: var(--ink-muted, #6e6759); font-size: var(--text-sm, 0.9rem);
}
.bench-fallback b { font-family: var(--font-display); font-weight: 500; font-size: var(--text-lg, 1.25rem); color: var(--ink, #2a2620); }

/* control bar */
.bench-bar {
  display: grid; grid-template-columns: auto 1fr; align-items: center;
  gap: var(--space-2, 0.5rem) var(--space-4, 1rem);
  padding: var(--space-3, 0.75rem) var(--space-4, 1rem) var(--space-4, 1rem);
  border-top: 1px solid var(--rule, #d8d2c4);
  background: var(--paper-2, #fbf9f3);
}
.bench-controls { display: inline-flex; gap: 4px; padding: 3px; border-radius: 999px; background: var(--paper-deep, #ece7db); }
.bench-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  color: var(--ink-muted, #6e6759);
}
.bench-btn:hover { background: var(--paper-2, #fbf9f3); color: var(--ink, #2a2620); }
.bench-btn.bench-play { background: var(--sage-deep, #43503f); color: var(--paper-2, #fbf9f3); }
.bench-btn.bench-play:hover { background: var(--sage, #5c6f5a); color: #fff; }
.bench-btn svg { display: block; }

.bench-caption {
  margin: 0; min-width: 0; max-width: none;
  font-size: var(--text-sm, 0.95rem); line-height: 1.45; color: var(--ink, #2a2620);
  min-height: 2.9em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.bench-caption .bench-k { font-family: var(--font-display); color: var(--wood-deep, #8a683f); font-weight: 500; margin-right: 0.15em; }

.bench-progress { grid-column: 1 / -1; display: flex; gap: 4px; }
.bench-progress span { flex: 1; height: 4px; border-radius: 2px; background: var(--paper-deep, #ece7db); overflow: hidden; }
.bench-progress span i { display: block; height: 100%; width: 0; background: var(--sage, #5c6f5a); border-radius: inherit; }
.bench-progress span.done i { background: var(--sage-deep, #43503f); }
.bench-progress span.cur i { background: var(--amber, #c67b2e); }

/* linked protocol list */
ol.protocol.bench-linked li { cursor: pointer; border-radius: var(--radius-sm, 0.375rem); transition: background var(--transition), color var(--transition); }
ol.protocol.bench-linked li:hover { background: rgba(223, 228, 216, 0.45); }
ol.protocol.bench-linked li.is-active { background: var(--sage-tint, #dfe4d8); color: var(--ink, #2a2620); box-shadow: inset 3px 0 0 var(--amber, #c67b2e); }
ol.protocol.bench-linked li.is-active::before { color: var(--amber, #c67b2e); font-weight: 600; }
ol.protocol.bench-linked li { padding-top: var(--space-2, 0.5rem); padding-right: var(--space-3, 0.75rem); }
ol.protocol.bench-linked li::before { left: 0.6em; top: var(--space-2, 0.5rem); }

@media (max-width: 640px) {
  .bench-stage { aspect-ratio: 4 / 3; }
  .bench-rail li { padding: 3px 7px; font-size: 0; gap: 0; }
  .bench-rail li span { width: 7px; height: 7px; }
  .bench-rail li.is-on { font-size: 0.6875rem; gap: 5px; }
  .bench-tag { max-width: calc(100% - 2rem); left: var(--space-3, 0.75rem); top: var(--space-3, 0.75rem); padding: 6px 10px; }
  .bench-tag-v { font-size: var(--text-sm, 0.95rem); }
  .bench-rail { top: auto; right: auto; left: var(--space-3, 0.75rem); bottom: var(--space-3, 0.75rem); padding: 4px; }
  .bench-hint { display: none; }
  .bench-btn { width: 34px; height: 34px; }
  /* show the full step text on small screens */
  .bench-caption { display: block; -webkit-line-clamp: unset; overflow: visible; min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .bench-rail li, .bench-hint, ol.protocol.bench-linked li { transition: none; }
}

/* 3D book: once WebGL has painted, hide the CSS poster title from style.css */
.book-stage.is-live::after { display: none; }
