/* Engineering parts share the reference's receding assembly axis.
   Cascade, pointer parallax and assembly travel each own a separate wrapper. */
.maker-engineering {
  --world-tint: #d6eaff;
  --assembly-timing: 9s cubic-bezier(.45, 0, .25, 1) infinite;
  --housing-x: 67.46cqw;
  --housing-y: 11.18cqw;
  --housing-width: 22cqw;
  --housing-travel-x: -11.2cqw;
  --housing-travel-y: 3.808cqw;
}
/* Layout uses cqw for the mechanical centreline, independent of stage height.
   Each offset accounts for the visible spindle/hub inside its transparent image. */
/* All shaft centres lie on y = 55 − .34x in stage-width coordinates.
   Asset anchors (source px): gripper rear flange 1065,520 / 1254;
   bearings front bore 510,650 / 1254; shaft nose 150,706 / 1536;
   housing front bore 509,655 / 1312; motor nose 326,644 / 1367.
   Travel follows that same axis; compressed seams are flange 54,
   bearings 54.6/57.5, housing 64.8, motor 72.2 cqw. */
.engineering-background { width: 114%; left: -6%; top: 16cqw; bottom: auto; z-index: 0; }
.engineering-background img { display: block; width: 100%; }
.engineering-guide { left: 27%; top: 22cqw; width: 70%; height: 24cqw; z-index: 1; pointer-events: none; }
.engineering-guide svg { width: 100%; height: 100%; overflow: visible; }
.engineering-guide line { stroke: #338eff; stroke-width: 1.3; stroke-dasharray: 7 6; opacity: .5; }
.engineering-part { margin-top: 7cqw; z-index: 3; pointer-events: none; }
.engineering-axis { animation: engineering-assemble var(--assembly-timing); }
.engineering-axis img { display: block; width: 100%; height: auto; user-select: none; }
.engineering-gripper { left: 7.77%; top: 27.77cqw; width: 25%; z-index: 9; --join-x: 25cqw; --join-y: -8.5cqw; }
/* Larger races retain their bore anchors on the shaft throughout travel. */
.engineering-bearing-front { left: 34.33%; top: 28.78cqw; width: 11.5%; z-index: 8; --join-x: 15.6cqw; --join-y: -5.304cqw; }
.engineering-bearing-rear { left: 44.33%; top: 25.38cqw; width: 11.5%; z-index: 7; --join-x: 8.5cqw; --join-y: -2.89cqw; }
.engineering-drive { --metal-x: 53.14cqw; --metal-y: 20.57cqw; --metal-art: url('../img/makers/engineering/drive.webp'); left: var(--metal-x); top: var(--metal-y); width: 19%; z-index: 6; --join-x: 0cqw; --join-y: 0cqw; }
.engineering-housing { left: var(--housing-x); top: var(--housing-y); width: var(--housing-width); z-index: 5; --join-x: var(--housing-travel-x); --join-y: var(--housing-travel-y); }
/* The mask follows the far lip of the bore in housing.webp coordinates.
   Metal approaching and entering the hole stays in front of the plastic;
   only metal beyond that lip is diffused. Do not mask the whole front plate.
   Both metal parts use the housing's travel relative to their own movement,
   with the same timing and parallax. Keep each original img as its only
   accessible description. */
:is(.engineering-drive, .engineering-motor) .engineering-axis { position: relative; }
:is(.engineering-drive, .engineering-motor) .engineering-axis > img,
:is(.engineering-drive, .engineering-motor) .engineering-axis::after {
  mask-image: linear-gradient(#000, #000), url('../img/makers/engineering/housing-shell-mask.svg?v=2');
  mask-size: 100% 100%, var(--housing-width) auto;
  mask-repeat: no-repeat;
  mask-position: 0 0, calc(var(--housing-x) - var(--metal-x)) calc(var(--housing-y) - var(--metal-y));
  mask-composite: exclude;
  animation: engineering-metal-mask var(--assembly-timing);
  animation-play-state: inherit;
}
:is(.engineering-drive, .engineering-motor) .engineering-axis::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--metal-art) center / 100% 100% no-repeat;
  filter: blur(.24cqw);
  opacity: .42;
  mask-composite: intersect;
}
@keyframes engineering-metal-mask {
  0%, 8%, 86%, 100% {
    mask-position: 0 0, calc(var(--housing-x) - var(--metal-x)) calc(var(--housing-y) - var(--metal-y));
  }
  36%, 60% {
    mask-position: 0 0, calc(var(--housing-x) - var(--metal-x) + var(--housing-travel-x) - var(--join-x)) calc(var(--housing-y) - var(--metal-y) + var(--housing-travel-y) - var(--join-y));
  }
}
/* The motor follows the housing in DOM order: sharing its stack level puts
   the diffused overlap over the plastic artwork, still beneath the drive. */
.engineering-motor { --metal-x: 86.47cqw; --metal-y: 8.11cqw; --metal-art: url('../img/makers/engineering/motor.webp'); left: var(--metal-x); top: var(--metal-y); width: 19%; z-index: 5; --join-x: -18.8cqw; --join-y: 6.392cqw; }
/* Front fasteners point into the mounting bores; rear fasteners approach
   the motor's back plate. Their travel stays parallel to the shaft. */
.engineering-coupling { left: 49%; top: 15cqw; width: 8%; z-index: 7; --join-x: 7cqw; --join-y: -2.38cqw; }
.engineering-screw {
  --entry-travel-x: var(--housing-travel-x);
  --entry-travel-y: var(--housing-travel-y);
  --entry-mask: linear-gradient(71.2deg, transparent 50%, #000 50%);
  left: var(--screw-x);
  top: var(--screw-y);
  width: 7%;
  z-index: 10;
}
/* Split at each mounting-hole plane, not the central axle's bore mask.
   Rotate the artwork inside the masks so the entry plane stays in scene
   coordinates. The sharp head remains outside; inserted threads diffuse. */
.engineering-screw .engineering-axis { position: relative; }
.engineering-screw-clear,
.engineering-screw-blur {
  display: block;
  mask-image: linear-gradient(#000, #000), var(--entry-mask);
  mask-size: 100% 100%, 200cqw 200cqw;
  mask-repeat: no-repeat;
  mask-position: 0 0, calc(var(--entry-x) - var(--screw-x) - 100cqw) calc(var(--entry-y) - var(--screw-y) - 100cqw);
  mask-composite: exclude;
  animation: engineering-screw-mask var(--assembly-timing);
  animation-play-state: inherit;
}
.engineering-screw-blur { position: absolute; inset: 0; mask-composite: intersect; }
.engineering-screw-blur img { filter: blur(.24cqw); opacity: .42; }
@keyframes engineering-screw-mask {
  0%, 8%, 86%, 100% {
    mask-position: 0 0, calc(var(--entry-x) - var(--screw-x) - 100cqw) calc(var(--entry-y) - var(--screw-y) - 100cqw);
  }
  36%, 60% {
    mask-position: 0 0, calc(var(--entry-x) - var(--screw-x) - 100cqw + var(--entry-travel-x) - var(--join-x)) calc(var(--entry-y) - var(--screw-y) - 100cqw + var(--entry-travel-y) - var(--join-y));
  }
}
.engineering-screw:is(.engineering-screw--one, .engineering-screw--two, .engineering-screw--three) img { transform: rotate(180deg); }
.engineering-screw--one { --screw-x: 39.4cqw; --screw-y: 26.11cqw; --entry-x: calc(var(--housing-x) + 4.9cqw); --entry-y: calc(var(--housing-y) + 6.7cqw); --join-x: 19.8cqw; --join-y: -6.732cqw; }
.engineering-screw--two { --screw-x: 59.16cqw; --screw-y: 17.97cqw; --entry-x: calc(var(--housing-x) + 11.07cqw); --entry-y: calc(var(--housing-y) + 3.18cqw); --join-x: 6.2cqw; --join-y: -2.108cqw; }
.engineering-screw--three { --screw-x: 59.66cqw; --screw-y: 31.05cqw; --entry-x: calc(var(--housing-x) + 11.57cqw); --entry-y: calc(var(--housing-y) + 16.27cqw); --join-x: 6.2cqw; --join-y: -2.108cqw; }
/* The back plate covers the inserted threads, leaving the heads exposed. */
.engineering-screw:is(.engineering-screw--four, .engineering-screw--five) {
  --entry-mask: linear-gradient(71.2deg, #000 50%, transparent 50%);
  --entry-travel-x: -18.8cqw;
  --entry-travel-y: 6.392cqw;
  --entry-x: 102.45cqw;
  --join-x: -20cqw;
  --join-y: 6.8cqw;
  width: 4.5%;
  z-index: 4;
}
.engineering-screw--four { --screw-x: 100.85cqw; --screw-y: 10.8cqw; --entry-y: 12.35cqw; }
.engineering-screw--five { --screw-x: 100.85cqw; --screw-y: 17.4cqw; --entry-y: 18.95cqw; }
.maker-engineering .engineering-eniac { width: 30%; right: -5%; bottom: 9%; z-index: 11; }
.engineering-loose-spacer { width: 5%; left: 68%; bottom: 9%; z-index: 10; }
.engineering-loose-spacer img { display: block; width: 100%; height: auto; }
/* A separate flat-lying bearing sits under the caliper, sharing Eniac's
   parallax so the jaws keep their position against the rim. */
.engineering-loose-bearing { width: 9%; left: 76%; bottom: calc(9% + 2cqw); z-index: 10; }
.engineering-loose-bearing img { display: block; width: 100%; height: auto; }
.maker-engineering .maker-post { width: 28%; left: 1%; top: -7%; z-index: 15; rotate: -2deg; }
.maker-engineering .maker-docs { width: 38%; right: -1%; top: -6%; z-index: 15; rotate: 4deg; }
.maker-engineering .maker-calendar { width: 31%; left: auto; right: -1%; bottom: -16%; z-index: 15; rotate: 2deg; }
.maker-engineering .maker-goals { width: 21%; left: -5%; right: auto; top: 22.8cqw; bottom: auto; z-index: 15; rotate: -3deg; }
.maker-engineering .maker-card { box-shadow: 0 15px 38px #364c7021, 0 4px 14px #3449630a; }
.engineering-goals { list-style: none; display: grid; gap: .5cqw; padding: 0; margin: 0; color: #536783; }
.engineering-goals li { display: flex; align-items: center; gap: .7cqw; padding: .65cqw; border: 1px solid #e1e8f2; border-radius: .8cqw; }
.engineering-goals li::before { content: ''; width: 1.5cqw; height: 1.5cqw; border: 2px solid #b7c5db; border-radius: 50%; }
.engineering-goals li.is-active { color: #0565ff; background: #eaf4ff; border-color: #cfe4ff; }
.engineering-goals li.is-active::before { border-color: #0565ff; background: #0565ff; box-shadow: inset 0 0 0 3px #eaf4ff; }
.engineering-goals .collab-avatar-stack { margin-left: auto; }
.engineering-goals .collab-avatar { width: 1.9cqw; height: 1.9cqw; }
.engineering-post__author b { color: #0565ff; }
.engineering-post__author small { display: inline; margin-left: .6cqw; }
.engineering-post__preview { height: 9cqw; position: relative; overflow: hidden; background: #edf6ff; margin-top: 1cqw; }
.engineering-post__preview::before { content: ''; position: absolute; inset: 0; background: linear-gradient(#c6e1f9 1px, transparent 1px), linear-gradient(90deg, #c6e1f9 1px, transparent 1px); background-size: 2cqw 2cqw; transform: skewY(-12deg); opacity: .6; }
/* Same closed hub coordinates as the main assembly, cropped to its visible bounds. */
.engineering-post__assembly { position: absolute; width: 80%; aspect-ratio: 54 / 30; left: 10%; top: 50%; transform: translateY(-50%) rotate(15deg); }
.engineering-post__assembly img { display: block; position: absolute; height: auto; }
.engineering-post__gripper { width: 46.296%; left: 0; top: 15.893%; }
.engineering-post__bearing-front { width: 21.296%; left: 31.778%; top: 29.92%; }
.engineering-post__bearing-rear { width: 21.296%; left: 37.148%; top: 26.633%; }
.engineering-post__drive { width: 35.185%; left: 37.722%; top: 20.233%; }
.engineering-post__housing { width: 40.741%; left: 43.5%; top: 1.627%; }
.engineering-post__motor { width: 35.185%; left: 64.63%; top: 0; }
.maker-engineering .maker-reactions img { width: 1.2cqw; height: 1.2cqw; }
.maker-card__body.engineering-docs-layout { display: grid; grid-template-columns: 26% minmax(0, 1fr); gap: 0; padding: 0; align-items: stretch; }
.engineering-docs-menu { display: grid; align-content: start; gap: .4cqw; color: #64718a; font-size: 1cqw; }
.engineering-docs-menu span { padding: .9cqw .8cqw; white-space: nowrap; }
.engineering-docs-menu .is-selected { color: #0565ff; background: #e8f3ff; }
.engineering-drawing { display: block; width: 100%; height: auto; align-self: stretch; object-fit: contain; background: #f9fcff; }
.engineering-calendar__arrows { margin-left: auto; letter-spacing: 1cqw; color: #172340; }
.engineering-calendar-event { display: grid; grid-template-columns: 3.5cqw 1fr; gap: 1.2cqw; }
.engineering-date { padding-right: 1cqw; text-align: center; border-right: 1px solid #dbe5f4; }
.engineering-date span { color: #8a9bb9; font-size: 1cqw; }
.engineering-date b { display: block; font-size: 2.6cqw; color: #0565ff; line-height: 1.15; }
.engineering-meeting { padding: .7cqw 1cqw; background: #eaf4ff; }
.engineering-attendees { display: flex; align-items: center; gap: .3cqw; margin-top: .7cqw; }
.engineering-attendees .collab-avatar { width: 2.2cqw; height: 2.2cqw; }
.engineering-attendees small { margin-left: .4cqw; }
.maker-engineering .maker-pointer--emma { left: 17%; top: -10%; z-index: 17; }
.maker-engineering .maker-pointer--leo { right: 2%; top: -8%; z-index: 17; }
.maker-engineering .maker-pointer--leo .collab-cursor { color: #00b893; }
.maker-engineering .maker-pointer--noah { right: -6%; bottom: 4%; z-index: 17; }
.maker-engineering .maker-pointer--noah .collab-cursor { color: #8024ff; animation-delay: -8s; }
.maker-engineering .maker-pointer--maya { left: 10%; top: 19cqw; bottom: auto; z-index: 17; }
.maker-engineering .maker-pointer--maya .collab-cursor { color: #ff9a22; }
.engineering-motion { position: absolute; left: 28%; bottom: -15%; z-index: 20; display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%; color: #6c84a6; background: #eef5fc; }
.engineering-motion:hover { color: #0565ff; background: #e1efff; }
.engineering-motion:focus-visible { outline: 2px solid #0565ff; outline-offset: 4px; }
.engineering-motion .material-icons { font-size: 19px; }
.home-makers[data-motion-paused] .engineering-axis,
.maker-engineering[data-assembly-paused] .engineering-axis { animation-play-state: paused; }
@keyframes engineering-assemble {
  0%, 8%, 86%, 100% { transform: translate(0, 0); }
  36%, 60% { transform: translate(var(--join-x), var(--join-y)); }
}
@media (min-width: 561px) and (max-width: 1200px) {
  .engineering-background { top: 16cqw; }
  .maker-engineering .maker-goals { top: auto; bottom: 0; }
  .maker-engineering .maker-calendar { bottom: 0; }
  .maker-engineering .engineering-eniac { bottom: 20%; }
  .engineering-loose-bearing { bottom: calc(20% + 2cqw); }
}
@media (max-width: 560px) {
  /* Reserve a row for the enlarged cards before the entire mechanical axis.
     Move parts, guide and blueprint together to preserve their alignment. */
  .home-makers__stage:has(.maker-engineering:not([hidden])) { aspect-ratio: .62; }
  .maker-engineering .maker-post { width: 43%; top: 0; left: 0; }
  .maker-engineering .maker-docs { width: 54%; top: 0; right: 0; }
  .maker-engineering .maker-calendar { width: 51%; bottom: 0; }
  .maker-engineering .maker-goals { width: 43%; top: auto; bottom: 0; left: 0; }
  .engineering-goals li { padding: 1.2cqw; gap: 1.2cqw; }
  .engineering-goals li::before { width: 2.7cqw; height: 2.7cqw; }
  .engineering-goals .collab-avatar { width: 3cqw; height: 3cqw; }
  .engineering-post__preview { height: 17cqw; }
  .maker-card__body.engineering-docs-layout { display: block; }
  .engineering-docs-menu { grid-template-columns: 1fr 1fr; gap: 0; font-size: 1.7cqw; }
  .engineering-docs-menu span { padding: 1cqw; }
  .engineering-background { width: 114%; left: -6%; top: 62cqw; bottom: auto; }
  .engineering-part { margin-top: 45cqw; }
  .maker-engineering .engineering-eniac { width: 35%; right: 1%; bottom: 21%; }
  .engineering-loose-bearing { width: 10.5%; left: 65%; bottom: calc(21% + 2.3cqw); }
  .engineering-loose-spacer { width: 7%; left: 52%; bottom: 20%; }
  .maker-engineering .maker-pointer--emma { top: 24%; left: 9%; }
  .maker-engineering .maker-pointer--leo { top: 24%; right: 2%; }
  .maker-engineering .maker-pointer--noah { bottom: 18%; right: -2%; }
  .engineering-guide { top: 60cqw; height: 24cqw; }
  .engineering-calendar-event { grid-template-columns: 6cqw 1fr; gap: 2cqw; }
  .engineering-date span { font-size: 2cqw; }
  .engineering-date b { font-size: 5cqw; }
  .engineering-meeting { padding: 1.5cqw; }
  .engineering-attendees .collab-avatar { width: 4cqw; height: 4cqw; }
  .maker-engineering .maker-pointer--maya { left: -2%; top: auto; bottom: 19%; }
  .engineering-motion { bottom: 20%; left: 3%; }
}
@media (prefers-reduced-motion: reduce) {
  .engineering-axis,
  .engineering-screw-clear,
  .engineering-screw-blur,
  :is(.engineering-drive, .engineering-motor) .engineering-axis > img,
  :is(.engineering-drive, .engineering-motor) .engineering-axis::after { animation: none; }
  .engineering-motion { display: none; }
}
