/* Cloudung — homepage, section "Leistungen": one line through four services.
   Markup: inc/mo-services.php. Glyphs: tools/motion_services.py.

   The plain styles describe the finished picture: the accent line runs once through all four
   cards (01 to 04) and ends in an arrow, every card has its node on the line, an ink numeral
   and a small glyph. The motion only replays how that picture comes about: the line travels
   from 01 to 04 and each card switches on when the line reaches it. One pass, about 2.3s.

   Three routes for the same line:
     four in a row     along the top of the cards
     two by two        along the top of row one, back through the row gap, along row two
     one column        down the left edge (like the iteration timeline on phones)

   Every piece of the line uses the same keyframes (mo-sv-draw) in every layout; only custom
   properties change at the breakpoints. A resize or a rotated tablet therefore never restarts
   the motion.                                                                                */

.svc.four.mo-sv {
  --mo-sv-num: clamp(2.6rem, 4vw, 3.6rem);   /* size of the numerals, as in site.css */
  --mo-sv-pad: 0px;                          /* left inset of the card content */
  --mo-sv-gw: clamp(48px, var(--mo-sv-num), 58px);   /* glyph width, follows the numerals; height is 37/58 of it */
  --mo-sv-rg: 0px;                           /* row gap, where the line needs it */
  --mo-sv-seg: .45s;                         /* time the line needs for one card */
  --mo-sv-ease: cubic-bezier(.2, .7, .2, 1);
}
.svc.mo-sv > li { position: relative; border-top-color: var(--hair); }

/* moment at which the line reaches each card */
.svc.mo-sv > li:nth-child(1) { --mo-sv-t: .15s; }
.svc.mo-sv > li:nth-child(2) { --mo-sv-t: .6s; }
.svc.mo-sv > li:nth-child(3) { --mo-sv-t: 1.05s; }
.svc.mo-sv > li:nth-child(4) { --mo-sv-t: 1.5s; }

/* ---------- the line: one segment per card, from its node to the next node ---------- */
/* a piece grows from its start: --mo-sv-w0 / --mo-sv-h0 are its size before it is drawn */
.mo-sv-ln, .mo-sv-rt i { position: absolute; background: var(--accent); --mo-sv-w0: 0px; --mo-sv-h0: 2px; }
.mo-sv-ln { left: 0; top: -1px; height: 2px; width: calc(100% + var(--gap)); }
.svc.mo-sv > li:last-child .mo-sv-ln { width: calc(100% - 5px); }
.mo-sv-nd { position: absolute; left: 0; top: -5px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.mo-sv-ar { position: absolute; right: 0; top: -5px; border-left: 9px solid var(--accent); border-block: 5px solid transparent; }

/* the way back through the row gap; only the two-by-two layout shows it */
.mo-sv-rt { position: absolute; inset: 0; pointer-events: none; visibility: hidden; }
.mo-sv-rt i { background: radial-gradient(circle, var(--accent) 1px, transparent 1.3px) 100% 0 / 2px 7px; }
.mo-sv-rt i:nth-child(2) { background-size: 7px 2px; }
.mo-sv-rt i:nth-child(1) { right: 0; top: -1px; width: 2px; height: calc(100% + var(--mo-sv-rg) / 2 + 2px); --mo-sv-w0: 2px; --mo-sv-h0: 0px; }
.mo-sv-rt i:nth-child(2) { right: 0; top: calc(100% + var(--mo-sv-rg) / 2 - 1px); height: 2px; width: calc(200% + var(--gap) - 4px); }
.mo-sv-rt i:nth-child(3) { left: calc(-100% - var(--gap) + 4px); top: calc(100% + var(--mo-sv-rg) / 2 - 1px); width: 2px; height: calc(var(--mo-sv-rg) / 2 + 2px); --mo-sv-w0: 2px; --mo-sv-h0: 0px; }

/* ---------- the glyph next to the numeral ---------- */
.mo-sv .mo-sv-g {
  position: absolute; overflow: visible;
  width: var(--mo-sv-gw); height: calc(var(--mo-sv-gw) * 37 / 58);
  left: calc(var(--mo-sv-pad) + var(--mo-sv-num) * 1.42);
  top: calc(20px + (var(--mo-sv-num) - var(--mo-sv-gw) * 37 / 58) / 2);
}
/* small drawing, lighter lines (as the narrow drawings of the site do) */
.mo-sv-g .pl, .mo-sv-g .b, .mo-sv-g .wire { stroke-width: .95; }
.mo-sv-g .ui { stroke-width: .7; }
.mo-sv-g .mo-sv-loop { stroke-dasharray: 1; stroke-dashoffset: 0; }
.mo-sv-g .mo-sv-loop-arr { fill: var(--ink); }

/* ---------- two by two: the line turns at the end of row one and comes back through the row gap ---------- */
@media (max-width: 1099px) {
  .svc.four.mo-sv { --mo-sv-rg: 48px; --mo-sv-seg: .3s; row-gap: var(--mo-sv-rg); }
  .svc.mo-sv > li { padding-right: 22px; }
  .svc.mo-sv > li:nth-child(2) { --mo-sv-t: .45s; }
  .svc.mo-sv > li:nth-child(3) { --mo-sv-t: 1.3s; }
  .svc.mo-sv > li:nth-child(4) { --mo-sv-t: 1.6s; }
  .svc.mo-sv > li:nth-child(2) .mo-sv-ln { width: 100%; }
  .mo-sv-rt { visibility: visible; }
}

/* ---------- one column: the line runs down the left edge ---------- */
@media (max-width: 819px) {
  .svc.four.mo-sv { --mo-sv-rg: 28px; --mo-sv-pad: 22px; --mo-sv-seg: .45s; row-gap: var(--mo-sv-rg); }
  .svc.mo-sv > li { padding-left: var(--mo-sv-pad); padding-right: 0; }
  .svc.mo-sv > li:nth-child(2) { --mo-sv-t: .6s; }
  .svc.mo-sv > li:nth-child(3) { --mo-sv-t: 1.05s; }
  .svc.mo-sv > li:nth-child(4) { --mo-sv-t: 1.5s; }
  .mo-sv-ln, .svc.mo-sv > li:nth-child(2) .mo-sv-ln { width: 2px; height: calc(100% + var(--mo-sv-rg) + 1px); --mo-sv-w0: 2px; --mo-sv-h0: 0px; }
  .svc.mo-sv > li:last-child .mo-sv-ln { width: 2px; height: calc(100% - 3px); }
  .mo-sv-nd { left: -4px; }
  .mo-sv-ar { right: auto; left: -4px; top: auto; bottom: -2px; border: 0; border-top: 9px solid var(--accent); border-inline: 5px solid transparent; }
  .mo-sv-rt { visibility: hidden; }
}

/* ---------- motion ---------- */
/* before the block scrolls in (script on): the cards are there, but off */
.js .mo-sv:not(.mo-in) .num { color: var(--hair); }
.js .mo-sv:not(.mo-in) .mo-sv-ln,
.js .mo-sv:not(.mo-in) .mo-sv-rt i { width: var(--mo-sv-w0); height: var(--mo-sv-h0); }
.js .mo-sv:not(.mo-in) .mo-sv-ln,
.js .mo-sv:not(.mo-in) .mo-sv-rt i,
.js .mo-sv:not(.mo-in) .mo-sv-nd,
.js .mo-sv:not(.mo-in) .mo-sv-ar,
.js .mo-sv:not(.mo-in) .mo-sv-g { opacity: 0; }

/* the line: constant speed from card to card, it only slows down on the last one */
.mo-sv.mo-in .mo-sv-ln { animation: mo-sv-draw var(--mo-sv-seg) linear var(--mo-sv-t) both; }
.mo-sv.mo-in > li:last-child .mo-sv-ln { animation-duration: calc(var(--mo-sv-seg) + .2s); animation-timing-function: cubic-bezier(.3, .43, .4, 1); }
.mo-sv.mo-in .mo-sv-ar { animation: mo-sv-fade .2s ease-out calc(var(--mo-sv-t) + var(--mo-sv-seg) + .05s) both; }
/* two by two: down the side, back through the row gap, down to row two */
.mo-sv.mo-in .mo-sv-rt i:nth-child(1) { animation: mo-sv-draw .14s linear .75s both; }
.mo-sv.mo-in .mo-sv-rt i:nth-child(2) { animation: mo-sv-draw .38s linear .89s both; }
.mo-sv.mo-in .mo-sv-rt i:nth-child(3) { animation: mo-sv-draw .03s linear 1.27s both; }

/* each card switches on when the line reaches it */
.mo-sv.mo-in .mo-sv-nd { animation: mo-sv-node .25s var(--mo-sv-ease) calc(var(--mo-sv-t) - .08s) both; }
.mo-sv.mo-in .num { animation: mo-sv-num .45s ease-out var(--mo-sv-t) both; }
.mo-sv.mo-in .mo-sv-g { animation: mo-sv-glyph .5s var(--mo-sv-ease) calc(var(--mo-sv-t) + .05s) both; }
/* operation keeps running: the loop of the last glyph is drawn once */
.mo-sv.mo-in .mo-sv-loop { animation: mo-sv-loop .55s ease-out calc(var(--mo-sv-t) + .2s) both; }
.mo-sv.mo-in .mo-sv-loop-arr { animation: mo-sv-fade .15s ease-out calc(var(--mo-sv-t) + .65s) both; }

@keyframes mo-sv-draw { from { width: var(--mo-sv-w0); height: var(--mo-sv-h0); } }
@keyframes mo-sv-node { from { opacity: 0; transform: scale(.3); } }
@keyframes mo-sv-num { from { color: var(--hair); } }
@keyframes mo-sv-glyph { from { opacity: 0; transform: translateY(6px); } }
@keyframes mo-sv-loop { from { stroke-dashoffset: 1; } }
@keyframes mo-sv-fade { from { opacity: 0; } }

/* Review: the iteration timeline directly below ends in the same arrowhead; here the line simply ends. */
.mo-sv .mo-sv-ar { display: none; }
