/* Dispenser walkthrough only. Page chrome, tables and figures come from site.css.
   Normal document scrolling throughout; nothing captures the wheel. */

/* ---------- Layout: stage in columns 1-8, chapter text in 9-12 ---------- */

#electronics-placement {
  --tour-top: calc(var(--bar) + 16px);
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--gutter);
  margin: 48px 0 0;
  padding-bottom: 48px;
}
#electronics-placement [hidden] { display: none !important; }
#electronics-placement .section-anchor { position: absolute; }

/* ---------- Stage ---------- */

#electronics-placement .tour-stage {
  grid-column: 1 / 9;
  grid-row: 1;
  position: sticky;
  top: var(--tour-top);
  align-self: start;
  min-width: 0;
  z-index: 3;
  background: var(--bg);
  padding-bottom: 8px;
}
#electronics-placement .tour-viewport {
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 58%, #2a3031 0, #1a1e1f 55%, #141617 100%);
}
#electronics-placement model-viewer {
  display: block;
  width: 100%;
  height: clamp(340px, calc(100svh - var(--tour-top) - 96px), 660px);
  background: transparent;
  --progress-bar-color: var(--accent);
  --progress-bar-height: 2px;
}
#electronics-placement model-viewer img[slot="poster"] {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #1a1e1f;
}
/* One line of status over the model, on a solid strip, gone for good after the first scroll or drag. */
#electronics-placement .tour-status {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  margin: 0;
  padding: 8px 16px;
  background: rgb(14 15 16 / .8);
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.5;
  pointer-events: none;
}
#electronics-placement .tour-overlay-actions { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 8px; }
#electronics-placement .tour-caption { display: none; }

/* ---------- Controls row: Play, six step segments, then two quiet text buttons ---------- */

#electronics-placement button {
  min-height: 44px;
  border: 0;
  border-radius: 0;
  padding: 8px 4px;
  color: var(--muted);
  background: none;
  font: 14px/1.3 var(--sans);
  cursor: pointer;
  transition: color 150ms, border-color 150ms, opacity 150ms;
}
#electronics-placement button:hover:not(:disabled) { color: var(--ink); }
#electronics-placement button:disabled { opacity: .35; cursor: default; }
#electronics-placement .tour-overlay-actions button {
  padding: 8px 16px;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: rgb(14 15 16 / .92);
}
#electronics-placement .tour-toolbar { display: flex; align-items: center; gap: 16px; padding-top: 12px; }
#electronics-placement .tour-play {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--ink);
}
#electronics-placement .tour-play:hover:not(:disabled) { border-color: var(--ink); }
#electronics-placement .tour-play[aria-pressed="true"] { border-color: var(--accent); }
#electronics-placement .tour-play svg { width: 16px; height: 16px; fill: currentColor; }
#electronics-placement .tour-play path { display: none; }
#electronics-placement .tour-play[data-state="play"] .icon-play,
#electronics-placement .tour-play[data-state="resume"] .icon-play,
#electronics-placement .tour-play[data-state="pause"] .icon-pause,
#electronics-placement .tour-play[data-state="replay"] .icon-replay { display: block; }
#electronics-placement .tour-steps { flex: 1; display: flex; gap: 8px; min-width: 0; }
#electronics-placement .tour-steps button {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 0 16px;
  color: var(--muted);
  overflow: hidden;
  text-align: left;
}
#electronics-placement .tour-steps button[aria-current] { color: var(--ink); }
#electronics-placement .step-number { font: 400 12px/1 var(--mono); font-variant-numeric: tabular-nums; }
#electronics-placement .step-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
#electronics-placement .step-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  height: 2px;
  background: var(--line);
  overflow: hidden;
  transition: background-color 150ms;
}
#electronics-placement .tour-steps button:hover .step-fill { background: var(--line-strong); }
#electronics-placement .step-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(var(--fill, 0));
}
#electronics-placement .tour-extras { flex: none; display: flex; gap: 16px; }
#electronics-placement .tour-extras button {
  padding-inline: 0;
  color: var(--ink-2);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 4px;
  white-space: nowrap;
}
#electronics-placement .tour-extras button:hover { text-decoration-color: currentColor; }

/* ---------- Chapters: one visible at a time, pinned beside the stage ---------- */

#electronics-placement .tour-chapters { grid-column: 9 / 13; grid-row: 1; min-width: 0; }
#electronics-placement .tour-chapters article {
  --copy-top: clamp(16px, 11svh, 112px);
  min-height: 104svh;
  padding: 0 0 48px;
}
#electronics-placement .tour-chapters article:first-child { min-height: 96svh; padding-top: var(--copy-top); }
#electronics-placement .tour-chapters article[data-chapter="weigh"] { min-height: 150svh; }
#electronics-placement .tour-chapters article[data-chapter="power"] { min-height: 118svh; }
#electronics-placement .tour-chapters article:last-child { min-height: 92svh; }
#electronics-placement .tour-copy {
  position: sticky;
  top: calc(var(--tour-top) + var(--copy-top));
  opacity: 0;
  transition: opacity 200ms linear;
}
#electronics-placement .tour-chapters article[data-active] .tour-copy { opacity: 1; }
#electronics-placement .tour-copy > span {
  font: 500 12px/1.4 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
#electronics-placement .tour-chapters h2 { margin: 12px 0 16px; }
#electronics-placement .tour-chapters p { color: var(--ink-2); max-width: 44ch; }

/* ---------- Hotspot labels: at most three per beat ---------- */

#electronics-placement .tour-hotspot {
  display: block;
  pointer-events: none;
  padding: 4px 8px;
  background: rgb(14 15 16 / .92);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font: 14px/1.4 var(--sans);
  white-space: nowrap;
  transform: translateY(-20px);
  opacity: 0;
  visibility: hidden;
  /* Outgoing labels leave at once, so a handoff never shows two beats' labels together. */
  transition: none;
}
#electronics-placement .tour-hotspot .tag { margin-left: 8px; padding: 0 4px; }
#electronics-placement .tour-hotspot.below { transform: translateY(20px); }
#electronics-placement .tour-hotspot.below.left { transform: translate(-56px, 24px); }
#electronics-placement .tour-hotspot.right { transform: translate(48px, -24px); }
#electronics-placement[data-label="explode"] .tour-hotspot[data-for~="explode"],
#electronics-placement[data-label="select"] .tour-hotspot[data-for~="select"],
#electronics-placement[data-label="home"] .tour-hotspot[data-for~="home"],
#electronics-placement[data-label="open"] .tour-hotspot[data-for~="open"],
#electronics-placement[data-label="shake"] .tour-hotspot[data-for~="shake"],
#electronics-placement[data-label="weigh"] .tour-hotspot[data-for~="weigh"],
#electronics-placement[data-label="close"] .tour-hotspot[data-for~="close"],
#electronics-placement[data-label="power"] .tour-hotspot[data-for~="power"],
#electronics-placement[data-label="driver"] .tour-hotspot[data-for~="driver"],
#electronics-placement[data-label="board"] .tour-hotspot[data-for~="board"] { opacity: 1; visibility: visible; transition: opacity 300ms; }
#electronics-placement[data-mode="original"] .tour-hotspot { opacity: 0 !important; visibility: hidden !important; }

/* Short landscape screens: the stage stops sticking and shows its own caption instead. */
@media (max-height: 560px) and (min-width: 701px), (max-height: 480px) {
  #electronics-placement .tour-stage, #electronics-placement .tour-copy { position: static; }
  #electronics-placement .tour-copy { opacity: 1; }
  #electronics-placement .tour-caption { display: block; padding: 12px 0 0; color: var(--muted); font-size: 14px; }
}

/* ---------- Build grid: 3D drive study ---------- */

.drive-study model-viewer {
  display: block;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at 50% 58%, #2a3031 0, #1a1e1f 60%, #141617 100%);
  --progress-bar-color: var(--accent);
}
.drive-study .drive-load { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.figure video { background: #000; }

@media (max-width: 1100px) {
  #electronics-placement .tour-stage { grid-column: 1 / 8; }
  #electronics-placement .tour-chapters { grid-column: 8 / 13; }
  #electronics-placement .step-label { display: none; }
}

@media (max-width: 700px) {
  /* Block layout so the sticky stage is bounded by the whole walkthrough. */
  #electronics-placement { --tour-top: var(--bar); display: block; margin-top: 32px; padding-bottom: 24px; }
  #electronics-placement .tour-stage { margin-inline: calc(-1 * var(--margin)); padding: 0 12px 4px; }
  #electronics-placement model-viewer { height: clamp(220px, 38svh, 360px); }
  #electronics-placement .tour-status { padding: 4px 12px; }
  #electronics-placement .tour-overlay-actions { right: 8px; bottom: 8px; }
  #electronics-placement .tour-toolbar { gap: 8px; padding-top: 4px; flex-wrap: wrap; }
  #electronics-placement .tour-steps { gap: 4px; }
  #electronics-placement .tour-steps button { justify-content: center; padding: 8px 0 16px; }
  #electronics-placement .step-number { font-size: 14px; }
  /* The two text buttons sit over the model's lower-left corner so the six steps keep 44 px targets. */
  #electronics-placement .tour-extras { position: absolute; left: 20px; bottom: 64px; gap: 8px; }
  #electronics-placement .tour-extras button { padding: 0 12px; background: rgb(14 15 16 / .8); border: 1px solid var(--line-strong); text-decoration: none; color: var(--ink); }
  #electronics-placement .tour-chapters article { display: block; position: relative; min-height: 108svh; padding: 0 0 24px; }
  #electronics-placement .tour-chapters article[data-active] { z-index: 2; }
  #electronics-placement .tour-copy { top: calc(var(--tour-top) + var(--stage-h, 420px) + 8px); padding-top: 12px; background: var(--bg); }
  #electronics-placement .tour-chapters article:first-child { min-height: 96svh; padding-top: 0; }
  #electronics-placement .tour-chapters article[data-chapter="weigh"] { min-height: 160svh; }
  #electronics-placement .tour-chapters article[data-chapter="power"] { min-height: 124svh; }
  #electronics-placement .tour-chapters article:last-child { min-height: 80svh; }
  #electronics-placement .tour-chapters h2 { margin: 8px 0; }
  #electronics-placement .tour-chapters p { max-width: none; }
  #electronics-placement .tour-hotspot { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) { #electronics-placement *, #electronics-placement *::after { transition: none !important; } }
#electronics-placement[data-reduced] *, #electronics-placement[data-reduced] *::after { transition: none !important; }

/* ---------- Result: the demo video and the recorded doses, before the walkthrough ---------- */

.result {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--gutter);
  row-gap: 32px;
  align-items: start;
  margin-top: 48px;
}
.result-video { grid-column: 1 / 9; }
.result-text { grid-column: 9 / 13; }
.result-text h2 { margin-bottom: 16px; }
.result-text p { color: var(--ink-2); }
.result-text p + .doses { margin-top: 20px; }
.result-text .doses + p { margin-top: 20px; font-size: 15px; }

/* Bars share one scale, 0 to 5 g; the dashed line marks the 3 g target. */
.doses {
  --scale: 5;
  --name: 64px;
  --value: 56px;
  position: relative;
  display: grid;
  gap: 10px;
  padding-top: 28px;
}
.dose {
  display: grid;
  grid-template-columns: var(--name) 1fr var(--value);
  align-items: center;
  column-gap: 10px;
}
.dose-n { font-size: 14px; color: var(--muted); }
.dose-bar {
  height: 14px;
  width: calc(var(--g) / var(--scale) * 100%);
  background: var(--accent);
}
.dose-v { font: 400 14px/1.5 var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); text-align: right; }
.dose-target {
  position: absolute;
  top: 0;
  bottom: 0;
  /* left edge of the bar track plus 3/5 of its width */
  left: calc(var(--name) + 10px + (100% - var(--name) - var(--value) - 20px) * 3 / 5);
  border-left: 2px dashed var(--ink-2);
  pointer-events: none;
}
.dose-target span {
  position: absolute;
  top: 0;
  left: 8px;
  font-size: 13px;
  line-height: 1.2;
  color: var(--ink-2);
  white-space: nowrap;
}

@media (max-width: 900px) {
  .result-video, .result-text { grid-column: 1 / -1; }
  .result { margin-top: 32px; }
}
.result-text .result-more { margin-top: 4px; }
