/* ===== "How your SMS reaches people" motion scene =====
   Default (no JS / reduced motion) = a finished, still picture.
   JS adds .is-animated and drives data-phase (1..4) / data-step (1..3). */

.motion-section {
  padding: 72px 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.motion-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 480px);
  gap: 56px;
  align-items: center;
}
.motion-copy h2 { font-size: clamp(24px, 3.2vw, 34px); }

.motion-steps { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 10px; }
.motion-steps li {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 16px; border-radius: 14px; border: 1px solid transparent;
  transition: background .3s ease, border-color .3s ease, opacity .3s ease;
}
.motion-steps .num {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: rgba(108, 92, 231, .12); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 800;
  transition: background .3s ease, color .3s ease;
}
.motion-steps h3 { font-size: 16px; margin: 0 0 2px; }
.motion-steps p { margin: 0; font-size: 14px; }

.motion-inner.is-animated .motion-steps li { opacity: .45; }
.motion-inner.is-animated[data-step="1"] li[data-step="1"],
.motion-inner.is-animated[data-step="2"] li[data-step="2"],
.motion-inner.is-animated[data-step="3"] li[data-step="3"] {
  opacity: 1; background: rgba(108, 92, 231, .07); border-color: var(--border);
}
.motion-inner.is-animated[data-step="1"] li[data-step="1"] .num,
.motion-inner.is-animated[data-step="2"] li[data-step="2"] .num,
.motion-inner.is-animated[data-step="3"] li[data-step="3"] .num {
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff;
}

/* ---- the scene ---- */
.scene {
  position: relative; width: 100%; max-width: 480px; margin-inline: auto;
  aspect-ratio: 100 / 118;
  container-type: inline-size;
  font-size: 13px;
  transition: opacity .4s ease;
}
.motion-inner.is-fading .scene { opacity: 0; }
.scene-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

/* phone composer (HTML, so Persian text wraps/shapes natively) */
.scene-phone {
  position: absolute; top: 0; left: 0; right: 0; height: 29.7%;
  background: linear-gradient(160deg, #20243A, #14162A);
  border-radius: 4.5cqw; padding: 3cqw 3.4cqw;
  display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: 0 2cqw 5cqw rgba(32, 36, 58, .25);
  color: #fff; z-index: 2;
}
.sp-head { display: flex; align-items: center; gap: 1.6cqw; font-size: max(11px, 3cqw); opacity: .65; }
.sp-dot { width: 1.8cqw; height: 1.8cqw; border-radius: 50%; background: var(--accent); }
.sp-text {
  margin: 0; color: #fff;
  font-size: max(12px, 3.7cqw); line-height: 1.7;
  min-height: calc(2 * 1.7em + 3cqw);
  padding: 1.4cqw 2.4cqw; border-radius: 3cqw;
  background: linear-gradient(135deg, var(--primary), var(--accent));
}
.sp-caret { display: none; width: 2px; height: 1em; background: #fff; vertical-align: middle; margin-inline-start: 2px; }
.sp-foot { display: flex; align-items: center; justify-content: space-between; gap: 2cqw; }
.sp-status { font-size: max(11px, 3cqw); color: #7CE3A8; }
.sp-send {
  font-size: max(12px, 3.3cqw); font-weight: 700; padding: 1.4cqw 4cqw; border-radius: 99px;
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff;
  transition: transform .15s ease, filter .15s ease;
}

.motion-inner.is-animated .sp-text { background: rgba(255, 255, 255, .09); transition: background .35s ease; }
.motion-inner.is-animated.is-sent .sp-text { background: linear-gradient(135deg, var(--primary), var(--accent)); }
.motion-inner.is-animated .sp-status { opacity: 0; transition: opacity .3s ease; }
.motion-inner.is-animated.is-sent .sp-status { opacity: 1; }
.motion-inner.is-animated[data-phase="1"] .sp-caret { display: inline-block; animation: blink .9s steps(1) infinite; }
.motion-inner.is-animated[data-phase="2"] .sp-send { transform: scale(.9); filter: brightness(1.25); }
@keyframes blink { 50% { opacity: 0; } }

/* labels */
.scene-label {
  position: absolute; z-index: 1; font-size: max(10.5px, 2.8cqw); font-weight: 700; color: var(--ink-soft);
  background: rgba(255, 255, 255, .9); border: 1px solid var(--border); border-radius: 99px; padding: .4cqw 2.4cqw;
  white-space: nowrap;
}
.label-area { left: 50%; bottom: .6%; transform: translateX(-50%); color: var(--primary); }

/* ---- SVG parts: static defaults ---- */
.link { stroke: var(--accent); stroke-width: .7; stroke-dasharray: 1.4 1.2; opacity: .5; }
.packet { opacity: 0; transform: translate(50px, 36px); }
.beacon { fill: var(--primary); }
.halo { fill: none; stroke: var(--accent); stroke-width: .5; opacity: .4; transform-box: fill-box; transform-origin: center; }
.wave { fill: none; stroke: var(--accent); stroke-width: 2px; transform-origin: 50px 48px; }
.wave:nth-child(1) { transform: scale(4.5); opacity: .3; }
.wave:nth-child(2) { transform: scale(8); opacity: .18; }
.wave:nth-child(3) { display: none; }
.area-zone { fill: rgba(0, 183, 194, .09); stroke: var(--accent); stroke-width: .5; stroke-dasharray: 1.6 1.2; }
.p-screen { fill: #FFD54A; }
.ping { transform-box: fill-box; transform-origin: 50% 100%; }

/* ---- animated mode ---- */
.is-animated .link { opacity: 0; }
.is-animated[data-phase="3"] .link,
.is-animated[data-phase="4"] .link { opacity: .9; animation: flow .5s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -2.6; } }

.is-animated[data-phase="2"] .packet { opacity: 1; transition: opacity .25s ease; }
.is-animated[data-phase="3"] .packet { opacity: 1; transform: translate(50px, 45px); transition: transform 1s cubic-bezier(.5, 0, .2, 1); }
.is-animated[data-phase="4"] .packet { opacity: 0; transform: translate(50px, 45px) scale(.4); transition: opacity .3s ease; }

.is-animated .beacon { fill: #9A96C8; transition: fill .3s ease; }
.is-animated[data-phase="4"] .beacon { fill: var(--accent); }
.is-animated .halo { opacity: 0; }
.is-animated[data-phase="4"] .halo { animation: halo 1.3s ease-out infinite; }
@keyframes halo { 0% { transform: scale(1); opacity: .8; } 100% { transform: scale(2.6); opacity: 0; } }

.is-animated .wave { opacity: 0; }
.is-animated[data-phase="4"] .wave { animation: waveOut 2.6s cubic-bezier(.2, .6, .3, 1) infinite; }
.is-animated[data-phase="4"] .wave:nth-child(2) { animation-delay: .85s; display: inline; }
.is-animated[data-phase="4"] .wave:nth-child(3) { animation-delay: 1.7s; display: inline; }
.is-animated .wave:nth-child(3) { display: inline; }
@keyframes waveOut { 0% { transform: scale(1); opacity: .75; } 100% { transform: scale(12.5); opacity: 0; } }

.is-animated .area-zone,
.is-animated .label-area { opacity: 0; transition: opacity .6s ease; }
.is-animated[data-phase="4"] .area-zone { opacity: 1; transition-delay: .5s; }
.is-animated[data-phase="4"] .label-area { opacity: 1; transition-delay: .5s; }

.is-animated .p-screen { fill: #8E8AB5; transition: fill .3s ease var(--d, 1.2s); }
.is-animated[data-phase="4"] .p-screen { fill: #FFD54A; }

.is-animated .ping {
  opacity: 0; transform: scale(.3);
  transition: opacity .25s ease var(--d, 1.2s), transform .45s cubic-bezier(.3, 1.6, .5, 1) var(--d, 1.2s);
}
.is-animated[data-phase="4"] .ping { opacity: 1; transform: scale(1); }

.motion-inner.no-trans *, .motion-inner.no-trans { transition: none !important; animation: none !important; }

@media (max-width: 860px) {
  .motion-section { padding: 48px 0; }
  .motion-inner { grid-template-columns: 1fr; gap: 24px; }
  /* title -> animation -> steps, so the animation is the first thing on a phone */
  .motion-copy { display: contents; }
  .motion-head { order: 1; }
  .scene { order: 2; max-width: 440px; }
  .motion-steps { order: 3; margin-top: 0; }
  .motion-steps li { padding: 12px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .scene *, .motion-steps * { animation: none !important; transition: none !important; }
}
