/* ============================================================
   04 · המנגנון - scroll-scrubbed exploded view of a live system.
   Outside: one calm screen. Inside: 5 precision layers.
   Pure CSS 3D + one canvas overlay, driven by /js/mechanism.js.
   No libraries; works with Lenis (window scroll) and native touch.
   ============================================================ */
.mx{position:relative;z-index:5;height:720vh;overflow-x:clip;--live:0}
.mx-pin{position:sticky;top:0;height:100vh;height:100svh;overflow:hidden;
  display:grid;grid-template-columns:minmax(320px,36%) 1fr;align-items:center}
.mx-pin::before{content:'';position:absolute;inset:0;pointer-events:none;
  background:
    radial-gradient(52% 60% at 38% 55%,rgba(20,184,166,calc(.05 + var(--live)*.09)),transparent 70%),
    radial-gradient(90% 70% at 50% 50%,rgba(7,15,24,.55),rgba(7,15,24,.82) 100%)}

/* ---------- copy column (visual right in RTL) ---------- */
.mx-copy{position:relative;z-index:6;height:min(560px,72svh);padding-inline:clamp(22px,4.6vw,76px) 12px}
.mx-ch{position:absolute;inset:0 clamp(22px,4.6vw,76px) 0 12px;display:flex;flex-direction:column;justify-content:center;
  opacity:0;transform:translateY(26px);filter:blur(6px);pointer-events:none;
  transition:opacity .55s ease,transform .9s cubic-bezier(.22,1,.36,1),filter .6s ease}
.mx-ch.on{opacity:1;transform:none;filter:none;pointer-events:auto}
.mx-ch .tag{margin-bottom:18px}
.mx-ch h2,.mx-ch h3{font-size:clamp(2rem,3.6vw,3.3rem);font-weight:900;line-height:1.12;letter-spacing:-.02em;color:#fff;
  text-shadow:0 2px 40px rgba(8,16,26,.8);margin-bottom:18px}
.mx-ch p{color:var(--dim);font-size:clamp(1rem,1.25vw,1.16rem);line-height:1.7;max-width:30em}
.mx-ch p b{color:#fff;font-weight:700}
.mx-ch .mx-step{display:inline-flex;align-items:center;gap:8px;margin-top:22px;font-size:.78rem;font-weight:700;letter-spacing:.2em;color:var(--dim2)}
.mx-ch .mx-step i{font-style:normal;color:var(--teal)}
.mx-list{list-style:none;display:grid;gap:9px;margin-top:6px}
.mx-list li{display:flex;align-items:baseline;gap:12px;color:var(--dim);font-size:1rem}
.mx-list li b{font-size:.74rem;letter-spacing:.14em;color:var(--teal);font-weight:800;min-width:2.2em;direction:ltr}
.mx-list li span{color:#fff;font-weight:700}
.mx-srcs{display:flex;flex-wrap:wrap;gap:8px;margin-top:18px}
.mx-srcs span{font-size:.8rem;font-weight:600;padding:6px 12px;border-radius:40px;color:#d9fbf5;
  border:1px solid rgba(94,234,212,.3);background:rgba(20,184,166,.08)}
.mx-cta{display:flex;gap:12px;flex-wrap:wrap;margin-top:26px}
.mx-cta .btn-main,.mx-cta .btn-ghost{padding:14px 30px;font-size:.95rem}

/* ---------- 3D rig ---------- */
.mx-scene{position:relative;z-index:3;height:100%;display:grid;place-items:center;
  perspective:1800px;perspective-origin:50% 38%}
.mx-stack{--W:min(46vw,700px);--H:calc(var(--W)*.62);
  position:relative;width:var(--W);height:var(--H);transform-style:preserve-3d;will-change:transform;
  transform:rotateX(0deg) rotateZ(0deg)}
.mx-l{--hi:0;position:absolute;inset:0;border-radius:18px;
  background:linear-gradient(158deg,rgba(18,36,56,.94),rgba(8,16,27,.96));
  border:1px solid rgba(94,234,212,calc(.16 + var(--hi)*.6));
  box-shadow:0 0 0 1px rgba(255,255,255,.025) inset,0 40px 90px rgba(0,0,0,.45);
  will-change:transform}
/* glow is a pre-painted layer whose opacity changes: no shadow repaint per frame */
.mx-l::before{content:'';position:absolute;inset:-1px;border-radius:inherit;pointer-events:none;opacity:var(--hi);
  box-shadow:0 0 50px rgba(45,212,191,.38),0 0 0 1px rgba(94,234,212,.7)}
.mx-l svg{position:absolute;inset:0;width:100%;height:100%;display:block;overflow:visible}
.mx-l0{background:linear-gradient(158deg,rgba(16,32,50,.97),rgba(9,18,30,.985))}
.mx-l::after{content:'';position:absolute;inset:0;border-radius:inherit;pointer-events:none;
  background:linear-gradient(115deg,rgba(255,255,255,.07),transparent 32%,transparent 70%,rgba(94,234,212,.05))}
.mx-c{position:absolute;width:2px;height:2px}
.mx-c.c0{top:0;left:0}.mx-c.c1{top:0;right:0}.mx-c.c2{bottom:0;right:0}.mx-c.c3{bottom:0;left:0}

/* svg typography */
.mx svg text{font-family:'Heebo','Heebo Fallback',sans-serif;fill:#e8eef2}
.mx .t-h{font-size:15px;font-weight:800}
.mx .t-s{font-size:11px;font-weight:500;fill:rgba(232,238,242,.6)}
.mx .t-xs{font-size:9px;font-weight:700;letter-spacing:.16em;fill:rgba(94,234,212,.75)}
.mx .t-v{font-size:30px;font-weight:900}
.mx .pnl{fill:rgba(255,255,255,.028);stroke:rgba(94,234,212,.16);stroke-width:1}
.mx .ln{fill:none;stroke:rgba(94,234,212,.35);stroke-width:1.4}
.mx .ln-d{fill:none;stroke:rgba(94,234,212,.5);stroke-width:1.4;stroke-dasharray:4 6}
.mx .flow-on .ln-d{animation:mxDash 1.1s linear infinite}
@keyframes mxDash{to{stroke-dashoffset:-20}}
.mx .node{fill:rgba(20,184,166,.08);stroke:rgba(94,234,212,.45);stroke-width:1.2}
.mx .chip{fill:rgba(255,255,255,.04);stroke:rgba(94,234,212,.32);stroke-width:1}
.mx .port{fill:#0b1622;stroke:#2dd4bf;stroke-width:1.5}
.mx .cell{fill:rgba(94,234,212,.09)}
.mx .cell.hot{fill:rgba(94,234,212,.32)}
.mx .fp{fill:none;stroke:rgba(94,234,212,.55);stroke-width:1.6;stroke-linecap:round}

/* dashboard (layer 0) live states */
.mx .g-arc-bg{fill:none;stroke:rgba(255,255,255,.07);stroke-width:12;stroke-linecap:round}
.mx .g-arc{fill:none;stroke:url(#mxGrad);stroke-width:12;stroke-linecap:round;stroke-dasharray:1 1}
.mx .g-tick{stroke:rgba(232,238,242,.3);stroke-width:1.4}
.mx .g-needle{stroke:#fff;stroke-width:2.6;stroke-linecap:round}
.mx .spark{fill:none;stroke:#2dd4bf;stroke-width:2.2;stroke-linejoin:round;stroke-linecap:round;stroke-dasharray:1 1}
.mx .spark-a{fill:url(#mxArea);opacity:calc(var(--live))}
.mx .kpi-v{opacity:calc(.25 + var(--live)*.75)}
.mx .feed text{opacity:0;transition:opacity .4s}
.mx .feed text.on{opacity:1}
.mx .live-pill{fill:rgba(255,255,255,.06);stroke:rgba(255,255,255,.12)}
.mx.is-live .live-pill{fill:rgba(20,184,166,.18);stroke:rgba(94,234,212,.6)}
.mx .live-dot{fill:#4b5a68}
.mx.is-live .live-dot{fill:#2dd4bf;animation:mxBlink 1.4s ease-in-out infinite}
@keyframes mxBlink{50%{opacity:.25}}

/* ---------- labels + fx overlay ---------- */
.mx-fx{position:absolute;inset:0;width:100%;height:100%;z-index:4;pointer-events:none}
.mx-lbls{position:absolute;inset:0;z-index:5;pointer-events:none}
.mx-lbl{position:absolute;top:0;left:0;opacity:0;white-space:nowrap;text-align:left;direction:rtl;
  transform:translate(-100%,-50%);will-change:transform,opacity}
.mx-lbl b{display:block;font-size:.95rem;font-weight:800;color:#fff;line-height:1.25}
.mx-lbl b em{font-style:normal;font-size:.7rem;letter-spacing:.16em;color:var(--teal);margin-inline-end:8px}
.mx-lbl small{display:block;font-size:.76rem;color:var(--dim);line-height:1.4}

/* ---------- hud ---------- */
.mx-hud{position:absolute;z-index:6;left:clamp(18px,3vw,44px);bottom:clamp(18px,4vh,40px);display:flex;align-items:center;gap:14px;
  font-size:.7rem;font-weight:700;letter-spacing:.2em;color:var(--dim2);direction:ltr}
.mx-hud i{display:block;width:22px;height:2px;border-radius:2px;background:rgba(232,238,242,.14);transition:background .4s,width .4s}
.mx-hud i.on{background:var(--teal);width:34px;box-shadow:0 0 10px rgba(45,212,191,.7)}
.mx-hud span{min-width:7em}

.mx-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}

/* ---------- tablet / phone: the model owns the screen, copy rides on top ---------- */
@media(max-width:900px){
  .mx{height:620vh}
  .mx-pin{display:block}
  /* model band right under the header, copy starts right under the model (no dead gap on tall phones) */
  .mx-scene{position:absolute;left:0;right:0;top:64px;height:min(50svh,520px);perspective:1000px;perspective-origin:50% 42%}
  .mx-copy{position:absolute;left:0;right:0;top:calc(64px + min(50svh,520px));bottom:0;height:auto;min-height:0;padding:0}
  .mx-ch{inset:6px 20px auto 20px;justify-content:flex-start;filter:none;transform:translateY(16px)}
  .mx-ch.on{transform:none}
  .mx-ch h2,.mx-ch h3{font-size:clamp(1.55rem,6.8vw,2.1rem);margin-bottom:8px}
  .mx-ch p{font-size:.93rem;line-height:1.55}
  .mx-ch .tag{margin-bottom:8px;font-size:.7rem}
  .mx-cta{margin-top:14px;flex-wrap:nowrap;gap:10px}
  .mx-cta .btn-main,.mx-cta .btn-ghost{padding:11px 18px;font-size:.86rem;white-space:nowrap}
  /* the layer labels and the connector chips already show these on the model */
  .mx:not(.mx-static) .mx-list,.mx:not(.mx-static) .mx-srcs{display:none}
  .mx-ch .mx-step{display:none}
  .mx-stack{--W:min(84vw,520px)}
  .mx-lbl b{font-size:.74rem}.mx-lbl small{display:none}
  .mx-hud{left:20px;transform:none;bottom:calc(30px + env(safe-area-inset-bottom));gap:8px}
  .mx-hud i{width:14px}.mx-hud i.on{width:22px}
  .mx.mx-static .mx-scene{position:relative;top:auto;bottom:auto}
  .mx.mx-static .mx-copy{position:relative;height:auto;background:none}
}

/* ---------- reduced motion: static exploded view, all copy in flow ---------- */
.mx.mx-static{height:auto}
.mx.mx-static .mx-pin{position:relative;height:auto;min-height:100svh}
.mx.mx-static .mx-copy{height:auto;padding-block:12vh}
.mx.mx-static .mx-ch{position:relative;inset:auto;opacity:1;transform:none;filter:none;pointer-events:auto;margin-bottom:46px}
.mx.mx-static .mx-scene{min-height:90svh}
.mx.mx-static .mx-hud{display:none}

/* the journey rail would collide with the layer labels */
.rail{transition:opacity .4s}
body.mx-in .rail{opacity:0!important;visibility:hidden!important;pointer-events:none}

/* ============================================================
   hero teaser: a living miniature of the mechanism (desktop)
   ============================================================ */
.sc-idea .beat>.mxt{position:absolute;z-index:4;left:clamp(96px,8vw,150px);bottom:clamp(28px,7vh,72px);
  display:flex;align-items:center;gap:18px;text-decoration:none;color:#fff;text-align:right;direction:rtl;
  padding:14px 22px 14px 14px;border-radius:20px;
  background:linear-gradient(150deg,rgba(17,33,51,.62),rgba(8,16,26,.72));border:1px solid rgba(94,234,212,.2);
  box-shadow:0 24px 60px rgba(3,8,14,.45);opacity:0;animation:mxtIn 1s cubic-bezier(.22,1,.36,1) 2.6s forwards;
  transition:border-color .35s,box-shadow .35s,transform .45s cubic-bezier(.22,1,.36,1)}
@keyframes mxtIn{from{opacity:0;transform:translateY(18px)}to{opacity:1;transform:none}}
.sc-idea .beat>.mxt:hover,.sc-idea .beat>.mxt:focus-visible{border-color:rgba(94,234,212,.6);outline:none;
  box-shadow:0 28px 70px rgba(3,8,14,.55),0 0 40px rgba(45,212,191,.22)}
.mxt-rig{--mx:0;--my:0;display:block;width:118px;height:96px;perspective:600px;flex:none}
.mxt-stk{position:relative;display:block;width:86px;height:56px;margin:22px auto 0;transform-style:preserve-3d;
  transform:rotateX(calc(56deg + var(--my)*10deg)) rotateZ(calc(-36deg + var(--mx)*14deg));transition:transform .5s cubic-bezier(.22,1,.36,1)}
.mxt-stk i{position:absolute;inset:0;border-radius:7px;display:block;
  background:linear-gradient(158deg,rgba(20,40,62,.95),rgba(8,16,27,.97));border:1px solid rgba(94,234,212,.32);
  transform:translateZ(calc(var(--i)*3px));animation:mxtB 4.8s cubic-bezier(.65,0,.35,1) infinite,mxtG 4.8s linear infinite;
  animation-delay:0s,calc(var(--i)*.14s)}
@keyframes mxtB{0%,12%,100%{transform:translateZ(calc(var(--i)*3px))}45%,70%{transform:translateZ(calc(var(--i)*15px))}}
@keyframes mxtG{0%,30%,100%{border-color:rgba(94,234,212,.28);box-shadow:none}
  48%{border-color:rgba(94,234,212,.95);box-shadow:0 0 14px rgba(45,212,191,.55)}}
.mxt-stk .mxt-top{background:linear-gradient(158deg,rgba(22,46,70,.98),rgba(10,20,33,.98))}
.mxt-top s{position:absolute;bottom:9px;width:9px;border-radius:2px;background:linear-gradient(#5eead4,#0d8a7e)}
.mxt-top s:nth-child(1){right:12px;height:16px}.mxt-top s:nth-child(2){right:25px;height:24px}.mxt-top s:nth-child(3){right:38px;height:31px}
.mxt-top u{position:absolute;left:9px;top:9px;width:22px;height:22px;border-radius:50%;border:2px solid #2dd4bf;border-bottom-color:transparent;transform:rotate(-45deg)}
.mxt-tx{display:flex;flex-direction:column;gap:4px}
.mxt-tx em{font-style:normal;font-size:.68rem;font-weight:800;letter-spacing:.22em;color:var(--teal)}
.mxt-tx b{font-size:.98rem;font-weight:800;line-height:1.3}
.mxt-go{display:inline-flex;align-items:center;gap:8px;font-size:.8rem;font-weight:700;color:#99f6e4}
.mxt-go::after{content:'';width:18px;height:1px;background:currentColor;transition:width .35s}
.mxt:hover .mxt-go::after{width:30px}
@media(max-height:520px){.sc-idea .beat>.mxt{display:none}}
/* phone: a compact living tile bottom-left, mirroring the WhatsApp bubble */
@media(max-width:900px){
  .sc-idea .beat>.mxt{left:14px;bottom:calc(18px + env(safe-area-inset-bottom));flex-direction:column;gap:2px;
    padding:6px 10px 9px;border-radius:16px;animation-delay:1.4s}
  .mxt-rig{width:74px;height:56px;perspective:420px}
  .mxt-stk{width:54px;height:35px;margin-top:12px}
  .mxt-stk i{border-radius:5px}
  @keyframes mxtB{0%,12%,100%{transform:translateZ(calc(var(--i)*2px))}45%,70%{transform:translateZ(calc(var(--i)*10px))}}
  .mxt-top s{bottom:5px;width:6px}.mxt-top s:nth-child(1){right:7px;height:10px}.mxt-top s:nth-child(2){right:15px;height:15px}.mxt-top s:nth-child(3){right:23px;height:20px}
  .mxt-top u{left:6px;top:6px;width:13px;height:13px;border-width:1.5px}
  .mxt-tx b,.mxt-go{display:none}
  .mxt-tx em{font-size:.6rem;letter-spacing:.14em;text-align:center}
}
@media(prefers-reduced-motion:reduce){.mxt-stk i{animation:none}.sc-idea .beat>.mxt{animation:none;opacity:1}}
