/* mrdirby.eu motion: living lines, the water jar, moving doodles, the receipt that prints.
   js/motion.js adds .motion to <body> unless the visitor asked for reduced motion, and most rules
   depend on it, so without it the page is the normal, still one. */

/* ---------- several drawings of each line ---------- */
.rough g.f:not(.f0) { visibility: hidden; }
/* photo spots and pictures (.ph) have one drawing only, so they hold still */
.motion [data-sk].on:not(.wait):not(.drawing):not(.ph) > .rough > g.f { animation: boil 720ms linear infinite; }
.motion [data-sk] > .rough > g.f1 { animation-delay: -480ms !important; }
.motion [data-sk] > .rough > g.f2 { animation-delay: -240ms !important; }
@keyframes boil { 0%, 33.3% { visibility: visible; } 33.4%, 100% { visibility: hidden; } }

/* ---------- lines that draw themselves ---------- */
.wait > .rough path.ln { stroke-dasharray: 1 1; stroke-dashoffset: 1; }
.wait:not([data-sk="box"]) > .rough path.sf { opacity: 0; }
.drawing > .rough path.ln { stroke-dasharray: 1 1; animation: ink var(--dur, 800ms) var(--d, 0ms) cubic-bezier(.45, .05, .35, 1) both; }
.drawing:not([data-sk="box"]) > .rough path.sf { animation: ink-fill 400ms calc(var(--d, 0ms) + var(--dur, 800ms) * .6) ease both; }
@keyframes ink { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes ink-fill { from { opacity: 0; } }

.hero span.t[data-sk] { display: inline-block; }

/* ---------- the doodles move ---------- */
.motion [data-doodle="vacuum"].on > .rough { animation: vac 1.2s ease-in-out infinite; transform-origin: 40% 60%; }
@keyframes vac { 0%, 100% { transform: rotate(-4deg) translateX(-2px); } 50% { transform: rotate(4deg) translateX(3px); } }
.motion [data-doodle="steam"].on > .rough > g.f > g:nth-child(n+3) { animation: steam 2.2s ease-in-out infinite; }
.motion [data-doodle="steam"].on > .rough > g.f > g:nth-child(4) { animation-delay: -.7s; }
.motion [data-doodle="steam"].on > .rough > g.f > g:nth-child(5) { animation-delay: -1.4s; }
@keyframes steam { 0% { transform: translateY(6px); opacity: 0; } 35% { opacity: 1; } 100% { transform: translateY(-8px); opacity: 0; } }
.motion [data-doodle="jar"].on > .rough > g.f > g:nth-child(n+4) { animation: bob 2.6s ease-in-out infinite; }
.motion [data-doodle="jar"].on > .rough > g.f > g:nth-child(5) { animation-delay: -.9s; }
.motion [data-doodle="jar"].on > .rough > g.f > g:nth-child(6) { animation-delay: -1.7s; }
@keyframes bob { 50% { transform: translateY(-5px); } }
.motion [data-doodle="clock"].on > .rough > g.f > g:nth-child(2) { animation: tick 6s linear infinite; transform-origin: var(--cx) var(--cy); }
@keyframes tick { to { transform: rotate(360deg); } }

/* ---------- the jar with real water ---------- */
.ljar { display: block; width: 100%; height: 100%; overflow: visible; }
.ljar .lf:not(.f0) { visibility: hidden; }
.ljar.on .lf { animation: boil 720ms linear infinite; }
.ljar .lf.f1 { animation-delay: -480ms; }
.ljar .lf.f2 { animation-delay: -240ms; }
.ljar .wave { animation: wave 2.4s linear infinite; }
@keyframes wave { to { transform: translateX(60px); } }
.ljar .bub { fill: none; stroke: rgba(255, 252, 244, .85); stroke-width: 1.6; animation: rise 3s ease-in infinite; }
.ljar .bub:nth-of-type(2) { animation-delay: -1s; }
.ljar .bub:nth-of-type(3) { animation-delay: -2s; }
@keyframes rise { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(-62px); opacity: 0; } }
.ljar .speck { animation: bob 3.4s ease-in-out infinite; }

/* ---------- "Как работим": the jar stays, the cards pass ---------- */
.water-stage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 64px; align-items: start; margin-top: 40px; }
.jar-stick { position: sticky; top: 110px; display: flex; flex-direction: column; align-items: center; gap: 12px; padding-top: 20px; }
.jar-big { width: min(46vh, 340px); aspect-ratio: 120 / 150; }
.jar-cap { font-family: var(--hand); font-size: 36px; line-height: 1.1; text-align: center; color: var(--teal-text); transform: rotate(-2deg); min-height: 2.2em; max-width: 16ch; }
.water-stage .strip { grid-template-columns: minmax(0, 1fr); gap: 34vh; margin-top: 0; padding-block: 12vh 22vh; }
.water-stage .panel { opacity: .45; transition: opacity 320ms ease, transform 320ms cubic-bezier(.22, 1, .36, 1); }
.water-stage .panel.now { opacity: 1; transform: rotate(var(--tilt, 0deg)) scale(1.03); }
.water-stage .panel .art { height: 110px; }
.water-stage .panel .art > div { width: 100px; height: 100px; }
.water-stage .panel h3 { font-size: 46px; }
.water-stage .panel p { font-size: 18px; }

@media (max-width: 880px) {
  .water-stage { grid-template-columns: minmax(0, 1fr); gap: 0; margin-top: 18px; }
  .jar-stick { top: 0; z-index: 6; flex-direction: row; justify-content: flex-start; gap: 18px; margin-inline: calc(var(--gutter) * -1); padding: 10px var(--gutter); background: var(--kraft); border-bottom: 2px dashed rgba(58, 42, 31, .3); }
  .jar-big { width: 92px; flex: none; }
  .jar-cap { font-size: 28px; text-align: left; min-height: 0; max-width: none; flex: 1; }
  .water-stage .strip { gap: 22vh; padding-block: 16vh 18vh; }
  .water-stage .panel .art { height: 84px; }
  .water-stage .panel .art > div { width: 78px; height: 78px; }
  .water-stage .panel h3 { font-size: 40px; }
}
@media (min-width: 601px) and (max-width: 880px) { .jar-stick { top: 86px; } }

/* ---------- the receipt prints ---------- */
.receipt.printing { animation: print 760ms steps(14) both; }
@keyframes print { from { transform: translateY(-62%); } }
.r-items li.printed { animation: line-in 1100ms ease-out both; }
@keyframes line-in {
  0% { opacity: 0; transform: translateY(-10px); background-color: rgba(244, 169, 133, .6); }
  30% { opacity: 1; transform: none; background-color: rgba(244, 169, 133, .6); }
  100% { background-color: transparent; }
}
.fly { position: fixed; z-index: 60; font-family: var(--hand); font-weight: 700; font-size: 30px; color: var(--peach); pointer-events: none; text-shadow: 0 1px 0 var(--board); }

/* never move for someone who asked for stillness */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}
