@import "variables.less";

// ─────────────────────────────────────────────────────────────
// HERO: Industrial automaton at work
// A geometric robot arm picks up tools (label, chip, scanner)
// from a carousel and places them on a conveyor.
// Built from divs/SVG primitives — no humanoid illustration.
// ─────────────────────────────────────────────────────────────

.automaton {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  perspective: 1400px;
}

.automaton-scene {
  position: relative;
  width: 720px;
  height: 320px;
  transform-style: preserve-3d;
  transform: rotateX(8deg);
}

// Floor — subtle radial shadow under the rig
.floor-shadow {
  position: absolute;
  bottom: 6px; left: 50%;
  width: 520px; height: 28px;
  transform: translateX(-50%);
  background: radial-gradient(50% 100% at 50% 50%, color-mix(in oklab, var(--ink) 18%, transparent), transparent 70%);
  filter: blur(4px);
}

// ── Conveyor belt running along the bottom ──────────────────
.conveyor {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 36px;
  border-radius: 6px;
  background: var(--bg-sub);
  border: 1px solid var(--line-2);
  overflow: hidden;
}
.conveyor::before {
  content: "";
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent 14px,
    var(--line-2) 14px,
    var(--line-2) 15px
  );
  animation: conveyorRoll 4s linear infinite;
}
@keyframes conveyorRoll {
  to { transform: translateX(-30px); }
}
.conveyor-rail {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 18px; width: 600px; height: 6px;
  border-radius: 3px;
  background: var(--ink-3);
  opacity: 0.18;
}

// ── Robot arm base ──────────────────────────────────────────
.arm-base {
  position: absolute;
  left: 50%;
  bottom: 60px;
  transform: translateX(-50%);
  width: 80px; height: 18px;
  border-radius: 4px;
  background: var(--ink-2);
  z-index: 5;
}
.arm-base::after {
  content: "";
  position: absolute; left: 50%; bottom: 100%;
  transform: translateX(-50%);
  width: 28px; height: 22px;
  background: var(--ink-2);
  border-radius: 4px 4px 0 0;
}

// Pivot point — segments rotate around it
.arm-pivot {
  position: absolute;
  left: 50%;
  bottom: 96px;
  width: 0; height: 0;
  z-index: 6;
  animation: armSwing 6s @ease-in-out infinite;
}
@keyframes armSwing {
  0%   { transform: rotate(-55deg); }   // reach left to pick
  18%  { transform: rotate(-55deg); }
  35%  { transform: rotate(0deg); }     // swing center
  50%  { transform: rotate(55deg); }    // place right
  68%  { transform: rotate(55deg); }
  85%  { transform: rotate(0deg); }
  100% { transform: rotate(-55deg); }
}

.arm-upper {
  position: absolute;
  left: 0; top: 0;
  width: 12px; height: 110px;
  margin-left: -6px;
  background: linear-gradient(180deg, var(--ink-2) 0%, var(--ink) 100%);
  border-radius: 6px;
  transform-origin: 50% 0%;
  box-shadow: inset -2px 0 0 color-mix(in oklab, var(--ink) 30%, transparent);
}
// Forearm pivots from elbow at the top of upper arm
.elbow {
  position: absolute;
  left: 0; top: -6px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--bg-elev);
  margin-left: -7px;
  z-index: 2;
}
.arm-fore {
  position: absolute;
  left: 0; top: 0;
  width: 10px; height: 90px;
  margin-left: -5px;
  background: linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 100%);
  border-radius: 5px;
  transform-origin: 50% 0%;
  animation: foreSwing 6s @ease-in-out infinite;
}
@keyframes foreSwing {
  0%   { transform: rotate(70deg); }
  18%  { transform: rotate(70deg); }
  35%  { transform: rotate(20deg); }
  50%  { transform: rotate(-70deg); }
  68%  { transform: rotate(-70deg); }
  85%  { transform: rotate(20deg); }
  100% { transform: rotate(70deg); }
}

// Gripper at the end of forearm
.gripper {
  position: absolute;
  left: 50%; bottom: -18px;
  transform: translateX(-50%);
  width: 28px; height: 22px;
}
.gripper .head {
  position: absolute; top: 0; left: 50%;
  transform: translateX(-50%);
  width: 16px; height: 8px;
  background: var(--ink);
  border-radius: 2px;
}
.gripper .claw {
  position: absolute; top: 6px;
  width: 4px; height: 14px;
  background: var(--ink);
  border-radius: 1px;
  transform-origin: 50% 0;
  animation: clawClench 6s @ease-in-out infinite;
}
.gripper .claw.l { left: 6px; }
.gripper .claw.r { right: 6px; }
@keyframes clawClench {
  0%, 18% { transform: rotate(0deg); }
  20%, 65% { transform: rotate(-4deg); }    // closed (carrying)
  70%, 100% { transform: rotate(0deg); }
}
.gripper .claw.r { animation-name: clawClenchR; }
@keyframes clawClenchR {
  0%, 18% { transform: rotate(0deg); }
  20%, 65% { transform: rotate(4deg); }
  70%, 100% { transform: rotate(0deg); }
}

// Item that rides with the gripper
.payload {
  position: absolute;
  left: 50%; bottom: -38px;
  transform: translateX(-50%) scale(0.9);
  width: 44px; height: 28px;
  border-radius: 4px;
  background: var(--label-fill);
  border: 1px solid var(--line-2);
  box-shadow: 0 6px 14px -6px rgba(0,0,0,0.25);
  animation: payloadCycle 6s @ease-in-out infinite;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.payload .barcode {
  width: 32px; height: 14px;
  background-image: repeating-linear-gradient(
    90deg,
    var(--barcode) 0 1px,
    transparent 1px 2px,
    var(--barcode) 2px 4px,
    transparent 4px 6px,
    var(--barcode) 6px 7px,
    transparent 7px 9px
  );
}
@keyframes payloadCycle {
  0%, 18%   { opacity: 0; transform: translateX(-50%) scale(0.7); }
  20%, 65%  { opacity: 1; transform: translateX(-50%) scale(1); }
  70%, 100% { opacity: 0; transform: translateX(-50%) scale(0.7); }
}

// ── Source bin (left) — items waiting to be picked ─────────
.bin {
  position: absolute;
  bottom: 60px;
  width: 96px; height: 70px;
  border-radius: 8px 8px 4px 4px;
  border: 1px solid var(--line-2);
  background: var(--bg-elev);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  padding: 6px;
  gap: 4px;
  box-shadow: 0 8px 20px -10px rgba(0,0,0,0.2);
}
.bin.left { left: calc(50% - 280px); }
.bin.right { right: calc(50% - 280px); }
.bin-label {
  position: absolute;
  bottom: -22px; left: 50%;
  transform: translateX(-50%);
  font-family: @font-mono;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
}
.bin-item {
  width: 70%; height: 14px;
  border-radius: 2px;
  background: var(--bg-sub);
  border: 1px solid var(--line-2);
  position: relative;
}
.bin-item::after {
  content: "";
  position: absolute; left: 6px; top: 4px; right: 6px; height: 6px;
  background-image: repeating-linear-gradient(90deg, var(--ink-2) 0 1px, transparent 1px 2px);
  opacity: 0.5;
}
.bin-item.stack-1 { animation: binConsume 6s @ease-in-out infinite; }
@keyframes binConsume {
  0%, 18% { opacity: 1; transform: translateY(0); }
  22%, 30% { opacity: 0; transform: translateY(-30px); }
  31%, 100% { opacity: 1; transform: translateY(0); }
}

// Marker on conveyor where item gets dropped
.drop-zone {
  position: absolute;
  bottom: 24px;
  right: calc(50% - 200px);
  width: 50px; height: 36px;
  border: 1.5px dashed var(--line-2);
  border-radius: 4px;
  z-index: 1;
}
.drop-item {
  position: absolute;
  bottom: 28px;
  right: calc(50% - 198px);
  width: 44px; height: 28px;
  border-radius: 4px;
  background: var(--label-fill);
  border: 1px solid var(--line-2);
  z-index: 2;
  opacity: 0;
  animation: dropAppear 6s @ease-in-out infinite;
  display: grid; place-items: center;
}
.drop-item .barcode {
  width: 32px; height: 14px;
  background-image: repeating-linear-gradient(
    90deg,
    var(--barcode) 0 1px,
    transparent 1px 2px,
    var(--barcode) 2px 4px,
    transparent 4px 6px,
    var(--barcode) 6px 7px,
    transparent 7px 9px
  );
}
@keyframes dropAppear {
  0%, 60% { opacity: 0; }
  68%, 90% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-40px); }
}

// HUD ticks scattered behind the rig
.hud-tick {
  position: absolute;
  font-family: @font-mono;
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  text-transform: uppercase;
  opacity: 0.7;
}
.hud-tick.t1 { top: 18%; left: 12%; }
.hud-tick.t2 { top: 14%; right: 14%; }
.hud-tick.t3 { bottom: 8%; left: 8%; }

// ─────────────────────────────────────────────────────────────
// ZPL TILE — drag elements snap onto a label
// ─────────────────────────────────────────────────────────────
.zpl-anim {
  position: absolute; inset: 0;
  display: grid; place-items: center;
}
.zpl-canvas {
  position: relative;
  width: 280px; height: 180px;
  background: var(--label-fill);
  border-radius: 6px;
  border: 1px solid var(--line-2);
  box-shadow: 0 24px 48px -24px rgba(0,0,0,0.3);
  overflow: hidden;
}
.zpl-canvas::before {
  content: "";
  position: absolute; inset: 8px;
  border: 1px dashed rgba(10,10,10,0.18);
  border-radius: 3px;
  pointer-events: none;
}

// Snapped elements on the label
.zpl-el {
  position: absolute;
  background: rgba(10,10,10,0.85);
  border-radius: 1px;
  opacity: 0;
  transform: translate(var(--from-x, 0), var(--from-y, 0)) scale(0.6);
  animation: zplSnap 8s @ease-out infinite;
}
@keyframes zplSnap {
  0% { opacity: 0; transform: translate(var(--from-x), var(--from-y)) scale(0.6); }
  8% { opacity: 1; }
  20% { opacity: 1; transform: translate(0,0) scale(1); }
  88% { opacity: 1; transform: translate(0,0) scale(1); }
  92% { opacity: 0; transform: translate(0,0) scale(1); }
  100% { opacity: 0; }
}

// Title bar (text)
.zpl-el.e-title {
  top: 18px; left: 18px;
  width: 140px; height: 14px;
  --from-x: -120px; --from-y: -60px;
  animation-delay: 0s;
  background: rgba(10,10,10,0.9);
}
// SKU code
.zpl-el.e-sub {
  top: 38px; left: 18px;
  width: 90px; height: 8px;
  --from-x: -140px; --from-y: -20px;
  animation-delay: 0.4s;
  background: rgba(10,10,10,0.55);
}
// Barcode
.zpl-el.e-barcode {
  bottom: 22px; left: 18px;
  width: 150px; height: 50px;
  --from-x: -100px; --from-y: 80px;
  animation-delay: 1.2s;
  background-image: repeating-linear-gradient(
    90deg,
    #0A0A0A 0 2px,
    transparent 2px 4px,
    #0A0A0A 4px 7px,
    transparent 7px 10px,
    #0A0A0A 10px 12px,
    transparent 12px 15px
  );
  background-color: transparent;
}
// QR
.zpl-el.e-qr {
  top: 22px; right: 18px;
  width: 56px; height: 56px;
  --from-x: 120px; --from-y: -40px;
  animation-delay: 0.8s;
  background:
    linear-gradient(45deg, #0A0A0A 25%, transparent 25%) 0 0/8px 8px,
    linear-gradient(-45deg, #0A0A0A 25%, transparent 25%) 0 0/8px 8px,
    #FFFFFF;
  border: 4px solid #FFFFFF;
  outline: 1px solid #0A0A0A;
}
// Price block
.zpl-el.e-price {
  bottom: 22px; right: 18px;
  width: 56px; height: 26px;
  --from-x: 130px; --from-y: 60px;
  animation-delay: 1.6s;
  background: rgba(10,10,10,0.9);
}

// Cursor pointer that "drags" elements in
.zpl-cursor {
  position: absolute;
  width: 18px; height: 18px;
  pointer-events: none;
  z-index: 10;
  animation: cursorPath 8s @ease-in-out infinite;
}
.zpl-cursor svg { width: 100%; height: 100%; fill: var(--ink); }
@keyframes cursorPath {
  0%   { left: 8%;  top: 18%; opacity: 0; }
  4%   { opacity: 1; }
  10%  { left: 28%; top: 32%; }
  14%  { left: 28%; top: 32%; transform: scale(0.85); }
  18%  { left: 28%; top: 32%; transform: scale(1); }
  25%  { left: 70%; top: 70%; }
  35%  { left: 78%; top: 22%; }
  50%  { left: 22%; top: 70%; }
  65%  { left: 80%; top: 78%; }
  80%  { opacity: 1; }
  90%  { left: 80%; top: 78%; opacity: 0; }
  100% { left: 8%;  top: 18%; opacity: 0; }
}

// Floating element source palette (top edge)
.zpl-palette {
  position: absolute;
  top: 18px; left: 18px; right: 18px;
  display: flex; gap: 6px;
  z-index: 1;
  opacity: 0.45;
}
.zpl-palette .chip {
  width: 32px; height: 12px;
  background: var(--bg-sub);
  border: 1px solid var(--line-2);
  border-radius: 2px;
}

// ─────────────────────────────────────────────────────────────
// CLOUD SERVER TILE — Odoo → Hub → Devices, animated pulse
// ─────────────────────────────────────────────────────────────
.cloud-anim {
  position: absolute; inset: 0;
}
.cloud-svg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
}

.cs-node {
  position: absolute;
  display: flex; flex-direction: column;
  align-items: center; gap: 6px;
  font-family: @font-mono;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  z-index: 2;
}
.cs-node .box {
  width: 56px; height: 40px;
  background: var(--bg-elev);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  display: grid; place-items: center;
  position: relative;
  transition: transform .25s @ease-out;
}
.cs-node .box svg { width: 22px; height: 22px; color: var(--ink-2); }

// Receiving pulse glow — animate ring + .box (which has no transform)
.cs-node.is-active .box {
  border-color: var(--ink);
}

// Position via top/left only — never on .cs-node itself, so .box transform is free
.cs-odoo  { left: 8%;  top: calc(50% - 28px); }
.cs-hub   { left: calc(50% - 36px); top: calc(50% - 36px); }
.cs-hub .box {
  width: 72px; height: 56px;
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.cs-hub .box svg { color: var(--bg); width: 28px; height: 28px; }

.cs-dev1 { right: 8%; top: 14%; }
.cs-dev2 { right: 8%; top: calc(50% - 28px); }
.cs-dev3 { right: 8%; bottom: 14%; }

// Pulse traveling along path
.cs-pulse {
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 50%;
  z-index: 3;
  pointer-events: none;
  transition: background 0.18s @ease-out, box-shadow 0.18s @ease-out, opacity 0.4s @ease-out, transform 0.4s @ease-out;
}
// Outbound from Odoo — orange (job released)
.cs-pulse-out {
  background: #F97316;
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.22), 0 0 14px rgba(249, 115, 22, 0.55);
}
// Arrived at device — green
.cs-pulse-in {
  background: #10B981;
  box-shadow: 0 0 0 5px rgba(16, 185, 129, 0.28), 0 0 18px rgba(16, 185, 129, 0.6);
}
.cs-pulse-fade {
  opacity: 0;
  transform: scale(2);
}

// Active node flash colors: orange when receiving at hub, green at devices
.cs-hub.is-active .box {
  border-color: #F97316 !important;
  animation: hubFlash 0.5s @ease-out;
}
@keyframes hubFlash {
  0%   { box-shadow: 0 0 0 0 rgba(249,115,22,0.55); transform: scale(1); }
  60%  { box-shadow: 0 0 0 14px rgba(249,115,22,0); transform: scale(1.08); }
  100% { box-shadow: 0 0 0 0 transparent; transform: scale(1); }
}
.cs-node.is-active .box {
  border-color: #10B981 !important;
  animation: devFlash 0.6s @ease-out;
}
@keyframes devFlash {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,0.45); transform: scale(1); }
  60%  { box-shadow: 0 0 0 14px rgba(16,185,129,0); transform: scale(1.08); }
  100% { box-shadow: 0 0 0 0 transparent; transform: scale(1); }
}

// Faint static lines drawn by SVG; pulses are JS-driven
.cs-line {
  stroke: var(--line-2);
  stroke-width: 1.5;
  fill: none;
  stroke-dasharray: 3 4;
  opacity: 0.6;
}

// ─────────────────────────────────────────────────────────────
// TILE TILT (cursor parallax)
// Layers inside tiles get a 3D depth
// ─────────────────────────────────────────────────────────────
.tile-stage > * {
  transform: translateZ(0);
  transition: transform .3s @ease-out;
}
.tile:hover .arm-base,
.tile:hover .arm-pivot { /* placeholder, hero only */ }

@media (prefers-reduced-motion: reduce) {
  .conveyor::before,
  .arm-pivot, .arm-fore,
  .gripper .claw, .payload, .drop-item,
  .bin-item.stack-1,
  .zpl-el, .zpl-cursor,
  .brand-mark::after {
    animation: none !important;
  }
}
