/* عناصر الرسم داخل المشهد (SVG) وحركتها */
#scene, #hero { direction: rtl; }
.s-ground { stroke: var(--ink); stroke-width: 2; }
.s-thin { stroke: var(--ink); stroke-width: 1; fill: none; }
.s-hair { stroke: var(--rule); stroke-width: .75; fill: none; }
.s-fill { fill: var(--sheet); stroke: var(--ink); stroke-width: 1.25; transition: stroke .2s; }
.s-slab { fill: var(--ink); }
.s-win { fill: var(--sheet-2); stroke: var(--ink-2); stroke-width: .75; }
.s-water { fill: var(--water-bg); }
.s-wline { stroke: var(--water); stroke-width: 1.4; fill: none; }
.s-txt { fill: var(--ink); font: 500 12px var(--font); }
.s-txt.mute { fill: var(--ink-2); font-weight: 400; }
.s-txt.big { font-size: 14px; font-weight: 600; }
.s-num { direction: ltr; unicode-bidi: isolate; }
.s-dim { stroke: var(--ink-2); stroke-width: .75; fill: none; }
.s-arrow { fill: var(--ink-2); }
.s-tagbg { fill: var(--sheet); }

/* ── المواسير ── */
.pipe-wall { fill: none; stroke: var(--ink); stroke-linecap: butt; stroke-linejoin: round; }
.pipe-core { fill: none; stroke-linecap: butt; stroke-linejoin: round; }
.pipe-core.pvc { stroke: var(--sheet); } .pipe-core.steel { stroke: var(--ink-2); } .pipe-core.galv { stroke: var(--hatch); } .pipe-core.cast { stroke: var(--ink-3); }
.pipe-water { fill: none; stroke: var(--water); stroke-opacity: .85; stroke-linecap: butt; stroke-linejoin: round; }
.pipe-water.priming { stroke-dasharray: 100 100; stroke-dashoffset: 100; animation-name: prime; animation-timing-function: ease-in-out; animation-fill-mode: forwards; }
@keyframes prime { to { stroke-dashoffset: 0; } }
.pipe-flow { fill: none; stroke: #fff; stroke-opacity: .7; stroke-linecap: round; stroke-dasharray: 2 14; animation-name: flow, fadein; animation-timing-function: linear, linear; animation-iteration-count: infinite, 1; animation-fill-mode: none, backwards; }
@keyframes flow { to { stroke-dashoffset: -16; } }
@keyframes fadein { from { opacity: 0; } }
.pipe-hit { fill: none; stroke: transparent; stroke-width: 24; cursor: pointer; pointer-events: stroke; }
.is-sel .pipe-wall { stroke: var(--water); }

/* ── الماء في الخزانات ── */
.water-body { transition: transform .35s ease-out; }
.wave { animation: wave 3.2s linear infinite; }
.wave.stir { animation-duration: 1.1s; }
@keyframes wave { to { transform: translateX(-24px); } }
.stream { fill: none; stroke: var(--water); stroke-width: 3.2; stroke-linecap: round; stroke-dasharray: 5 3; animation: fadein .25s linear backwards, pour .35s linear infinite; }
.stream.leak { stroke-width: 2.6; }
@keyframes pour { to { stroke-dashoffset: -8; } }
.ripple { fill: none; stroke: var(--water); stroke-width: 1; transform-box: fill-box; transform-origin: center; animation: ripple 1.2s ease-out infinite backwards; }
@keyframes ripple { from { transform: scale(.3); opacity: .9; } to { transform: scale(2.2); opacity: 0; } }
.float { fill: var(--sheet); stroke: var(--ink); stroke-width: 1; }
.puddle { fill: var(--water); fill-opacity: .55; transform-box: fill-box; transform-origin: center; animation: puddle 4s ease-out backwards; }
@keyframes puddle { from { transform: scale(.05, .4); } }

/* ── المضخة ── */
.impeller { transform-box: fill-box; transform-origin: center; }
.fx-spin { animation: spin .5s linear infinite, spinup 1s ease-in; }
.fx-spin.fast { animation-duration: .25s, 1s; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spinup { from { opacity: .6; } }
.fx-hum { animation: hum .09s linear infinite; }
@keyframes hum { 50% { transform: translate(.35px, -.25px); } }
.fx-shake { animation: shake .11s linear infinite; }
@keyframes shake { 25% { transform: translate(1.4px, -1px); } 75% { transform: translate(-1.2px, .8px); } }
.led { fill: var(--ink-3); }
.led.on { fill: var(--ok); animation: blink 1.4s ease-in-out infinite; }
.led.on.bad { fill: var(--fault); animation-duration: .4s; }
@keyframes blink { 50% { opacity: .35; } }
.fx-intake { fill: var(--water); animation: intake .9s linear infinite; }
@keyframes intake { from { transform: translateX(-10px); opacity: 0; } 30% { opacity: 1; } to { transform: translateX(6px); opacity: 0; } }
.needle { stroke: var(--fault); stroke-width: 1.4; stroke-linecap: round; }
.needle.rise { animation: needle 1.6s cubic-bezier(.2, .9, .3, 1.15) forwards; animation-delay: .4s; transform: rotate(-120deg); }
@keyframes needle { to { transform: rotate(var(--a)); } }
.gauge-txt { font-size: 11px; }

/* ── التفاعل ── */
.hot { cursor: pointer; outline: none; }
.hot:hover .s-fill, .hot:focus-visible .s-fill { stroke: var(--water); }
.hot.is-sel .s-fill { stroke: var(--water); stroke-width: 2; }
.appear { animation: appear .55s cubic-bezier(.2, .8, .2, 1) backwards; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes appear { from { opacity: 0; transform: translateY(14px) scaleY(.92); } }
.dash-move { animation: dashmove 1.6s linear infinite; }
@keyframes dashmove { to { stroke-dashoffset: -16; } }

.slot { cursor: pointer; outline: none; pointer-events: all; }
.slot rect { fill: transparent; stroke: var(--ink-2); stroke-width: 1.2; stroke-dasharray: 6 5; transition: stroke .2s; }
.slot text { fill: var(--ink-2); font: 500 13px var(--font); }
.slot .plus { stroke: var(--ink-2); stroke-width: 1.5; }
.slot:hover rect, .slot:focus-visible rect { stroke: var(--ink); stroke-dasharray: none; }
.slot:hover text, .slot:focus-visible text { fill: var(--ink); }
.slot.next rect { stroke: var(--ink); stroke-width: 1.5; animation: dashmove 1.2s linear infinite; }
.slot.next text { fill: var(--ink); font-weight: 600; }
.slot.next .plus { stroke: var(--ink); animation: nudge 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes nudge { 50% { transform: scale(1.18); } }

/* ── الأعطال ── */
.fx-drop { fill: var(--water); animation: drop .9s ease-in infinite backwards; }
@keyframes drop { from { transform: translateY(0); opacity: 1; } to { transform: translateY(46px); opacity: 0; } }
.fx-bub { fill: var(--sheet); stroke: var(--water); stroke-width: 1; animation: bub 1.1s ease-out infinite; }
@keyframes bub { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-22px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .pipe-flow, .fx-drop, .fx-bub, .fx-shake, .fx-hum, .fx-spin, .wave, .stream, .ripple, .led.on, .fx-intake, .dash-move, .slot.next rect, .slot.next .plus, .appear, .puddle { animation: none !important; }
  .pipe-water.priming { animation: none; stroke-dashoffset: 0; }
  .needle.rise { animation: none; transform: rotate(var(--a)); }
  .water-body { transition: none; }
}
