/* MotorAtlas: 3D machine (hero plate + parts locator) */
.hero-plate.machine {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #0b0e0f;
}
.machine-stage {
  position: relative;
  height: clamp(360px, 46vh, 470px);
  background: #0b0e0f url("media/machine-gas.jpg") center / cover no-repeat;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
.machine-stage[data-mode="hybrid"] {
  background-image: url("media/machine-hybrid.jpg");
}
.machine-stage[data-mode="ev"] {
  background-image: url("media/machine-ev.jpg");
}
.machine-stage.is-ready {
  background-image: none !important;
}
.m3-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.8s ease;
  touch-action: pan-y;
}
.is-ready > .m3-canvas {
  opacity: 1;
}
.machine-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 60%, transparent 55%, rgba(9, 11, 12, 0.55) 100%);
}
.machine-hint {
  position: absolute;
  z-index: 3;
  right: 12px;
  top: 12px;
  font: 500 0.5rem var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8b979c;
  border: 1px solid var(--line);
  background: rgba(9, 11, 12, 0.7);
  padding: 6px 9px;
  pointer-events: none;
  transition: opacity 0.5s;
}
.machine-stage.no-webgl .machine-hint {
  display: none;
}
.machine-card {
  position: absolute;
  z-index: 4;
  left: 12px;
  top: 12px;
  max-width: min(330px, calc(100% - 24px));
  background: rgba(10, 13, 14, 0.92);
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  padding: 12px 14px 13px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: mcIn 0.35s ease;
}
.machine-card[hidden] {
  display: none;
}
.machine-card .mc-close {
  position: absolute;
  right: 4px;
  top: 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
}
.machine-card .mc-close:hover {
  color: var(--paper);
}
.machine-card .mc-code {
  padding-right: 18px;
}
.is-focused .machine-hint {
  opacity: 0;
}
.machine-card .mc-code {
  display: block;
  font: 500 0.52rem var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c, var(--amber));
  margin-bottom: 5px;
}
.machine-card b {
  display: block;
  font: 700 1.5rem/1 var(--head);
  text-transform: uppercase;
  letter-spacing: 0.01em;
  margin-bottom: 6px;
}
.machine-card p {
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--steel);
}
.machine-card small {
  display: block;
  margin-top: 8px;
  font: 500 0.5rem var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.machine-card .mc-open {
  margin-top: 10px;
  border: 1px solid rgba(240, 164, 59, 0.5);
  background: rgba(240, 164, 59, 0.1);
  color: var(--amber2);
  font: 600 0.6rem var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 10px;
  cursor: pointer;
}
.machine-card .mc-open:hover {
  background: var(--amber);
  color: var(--ink);
}
@keyframes mcIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
.machine-bar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.machine-seg {
  display: inline-flex;
  border: 1px solid var(--line);
}
.machine-seg button {
  border: 0;
  border-left: 1px solid var(--line);
  background: #0f1314;
  color: var(--muted);
  font: 600 0.56rem var(--mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 8px 11px;
  cursor: pointer;
  min-height: 34px;
}
.machine-seg button:first-child {
  border-left: 0;
}
.machine-seg button:hover {
  color: var(--paper);
}
.machine-seg button[aria-pressed="true"] {
  background: var(--amber);
  color: var(--ink);
}
.machine-systems {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.ms-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border: 0;
  border-right: 1px solid var(--line2);
  border-bottom: 1px solid var(--line2);
  background: transparent;
  color: var(--steel);
  text-align: left;
  font: 600 0.56rem var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 10px 11px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition:
    background 0.2s,
    color 0.2s;
}
.ms-chip i {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent);
}
.ms-chip:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--paper);
}
.ms-chip.is-on {
  background: rgba(240, 164, 59, 0.08);
  color: var(--paper);
  box-shadow: inset 0 -2px 0 var(--amber);
}

/* expand: the plate fills the screen (real fullscreen where the browser allows, otherwise a fixed overlay) */
.machine-expand {
  position: absolute;
  z-index: 4;
  right: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid rgba(240, 164, 59, 0.6);
  background: rgba(9, 11, 12, 0.84);
  color: var(--paper);
  font: 600 0.58rem var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition:
    background 0.2s,
    color 0.2s,
    border-color 0.2s;
}
.machine-expand:hover,
.machine-expand:focus-visible {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--ink);
}
.machine-expand svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.machine-expand .mx-close,
.is-expanded .machine-expand .mx-open {
  display: none;
}
.is-expanded .machine-expand .mx-close {
  display: block;
}
.machine-stage.no-webgl .machine-expand {
  display: none;
}
html.m3-lock,
html.m3-lock body {
  overflow: hidden;
}
.hero-plate.machine.is-expanded {
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  background: #0b0e0f;
}
.hero-plate.machine:fullscreen {
  width: 100%;
  height: 100%;
}
.is-expanded .plate-top {
  flex: 0 0 auto;
  gap: 16px;
}
.is-expanded .machine-stage {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  background: radial-gradient(ellipse at 50% 55%, #141a1c, #0b0e0f 72%);
}
.is-expanded .machine-bar,
.is-expanded .machine-systems {
  flex: 0 0 auto;
}
.is-expanded .machine-systems {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}
.is-expanded .machine-expand {
  top: 12px;
  bottom: auto;
}
.is-expanded .machine-hint {
  top: 56px;
}

/* callout labels + tooltip (shared by both mounts) */
.m3-labels {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}
.m3-leaders {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.m3-leaders path {
  fill: none;
  stroke: rgba(241, 239, 232, 0.5);
  stroke-width: 1;
}
.m3-leaders circle {
  fill: #f1efe8;
}
.m3-tag {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: auto;
  display: block;
  background: rgba(9, 11, 12, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-left: 3px solid var(--c);
  color: var(--paper);
  font: 600 0.56rem/1 var(--mono);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 6px 8px;
  white-space: nowrap;
  cursor: pointer;
  will-change: transform;
}
.m3-tag:hover,
.m3-tag.is-sel {
  background: var(--c);
  color: #0b0d0e;
}
.m3-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: rgba(9, 11, 12, 0.94);
  border: 1px solid var(--line);
  padding: 7px 9px;
  font: 600 0.78rem/1.2 var(--body);
  color: var(--paper);
}
.m3-tip span {
  display: block;
  margin-top: 3px;
  font: 500 0.5rem var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* parts-library locator */
.visual-tabs {
  display: inline-flex;
}
.visual-tabs button {
  border: 0;
  background: none;
  color: var(--muted);
  font: 500 0.5rem var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0 10px 0 0;
  cursor: pointer;
}
.visual-tabs button + button {
  padding-left: 10px;
  border-left: 1px solid var(--line);
}
.visual-tabs button[aria-selected="true"] {
  color: var(--amber);
}
.visual-frame {
  position: relative;
}
.locator {
  position: relative;
  height: 270px;
  background: radial-gradient(ellipse at 50% 55%, #121819, #0b0e0f 70%);
}
.locator .m3-tip {
  display: none;
}
.locator-note {
  position: absolute;
  z-index: 3;
  left: 10px;
  right: 10px;
  bottom: 10px;
  font: 500 0.5rem/1.4 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--amber2);
  background: rgba(9, 11, 12, 0.85);
  border: 1px solid rgba(240, 164, 59, 0.3);
  padding: 6px 8px;
}
.locator-note[hidden],
.locator-note:empty {
  display: none;
}
.locator-caption {
  height: 40px;
  padding: 9px 12px;
  font: 500 0.46rem var(--mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #5e696e;
  border-top: 1px solid var(--line2);
}
.visual-frame.is-where img,
.visual-frame.is-where #visualCaption,
.visual-frame.is-where ~ * #visualSource {
  display: none;
}
.visual-frame.is-photo .locator,
.visual-frame.is-photo .locator-caption {
  display: none;
}
.system-visual:has(.visual-frame.is-where) #visualSource {
  visibility: hidden;
}

/* Layout */.manual-page {
  overflow: hidden;
}

@media (max-width: 1100px) {
  .machine-stage {
    height: clamp(320px, 52vw, 460px);
  }
}
@media (max-width: 560px) {
  .machine-stage {
    height: 330px;
  }
  .machine-systems {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .machine-bar {
    padding: 8px;
  }
  .machine-seg button {
    padding: 8px 8px;
    font-size: 0.52rem;
  }
  .machine-card {
    left: 8px;
    right: 8px;
    top: 8px;
    max-width: none;
    padding: 9px 12px;
  }
  .machine-card p {
    font-size: 0.8rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .machine-card b {
    font-size: 1.25rem;
  }
  .machine-hint {
    display: none;
  }
  .machine-expand {
    right: 8px;
    bottom: 8px;
    min-height: 34px;
    padding: 0 10px;
  }
  .is-expanded .machine-expand {
    top: 8px;
  }
  .is-expanded .machine-card {
    top: 52px;
  }
  .is-expanded .plate-top span:first-child {
    display: none;
  }
  .is-expanded .machine-systems {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .is-expanded .machine-systems::-webkit-scrollbar {
    display: none;
  }
  .is-expanded .ms-chip {
    flex: 0 0 auto;
    border-bottom: 0;
  }
  .flow-stage {
    justify-content: flex-start;
    padding: 18px;
  }
  .locator {
    height: 250px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .m3-canvas {
    transition: none;
  }
  .machine-card {
    animation: none;
  }
}
