/* ==========================================================================
   /services/web-apps/ — «Веб-приложения». Concept: «Структура» — a product is
   connected parts that work together.
   Hero: cosmic dust as the ground, the Capricorn constellation on top —
   stars and the lines between them, drawn to the real star positions — as
   a system of connected parts. Signals run along the lines, stars light up
   in turn and answer the pointer; three notes are pinned to stars, the same
   chart notation as on the expert page. Below: the four parts assemble into a grid, links draw between them.
   ========================================================================== */

.service-web-apps { --ap-w: 104vw; }

/* --- Hero: dust ---------------------------------------------------------- */
.ap-sky .ap-dust {
  position: absolute;
  top: calc(var(--ap-w) * -0.59);
  left: 0;
  display: block;
  width: var(--ap-w);
  mix-blend-mode: screen;
}
.ap-sky .ap-dust img { width: 100%; height: auto; }
@media (prefers-reduced-motion: no-preference) {
  .ap-sky .ap-dust { animation: ap-drift 40s ease-in-out infinite alternate; }
}
@keyframes ap-drift { from { transform: translate(0, 0); } to { transform: translate(-36px, 14px); } }

.ap-sky::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(14, 15, 15, .9) 0%, rgba(14, 15, 15, .62) 36%, rgba(14, 15, 15, .12) 60%, rgba(14, 15, 15, .3) 100%);
}

.service-web-apps .svc-hero-copy { max-width: 640px; }

/* --- Hero: the constellation -------------------------------------------- */
.ap-chart {
  position: absolute;
  z-index: -1;
  top: clamp(36px, 4vw, 64px);
  right: calc(var(--nk2-pad) - 1vw);
  width: min(44vw, 640px);
  aspect-ratio: 720 / 510;                            /* the svg's viewBox */
}
.ap-schema { display: block; width: 100%; height: 100%; overflow: visible; }
.ap-links { fill: none; stroke: rgba(241, 235, 221, .26); stroke-width: 1; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.ap-signal { fill: none; stroke: #fff; stroke-width: 1.6; stroke-linecap: round; stroke-dasharray: 6 260; opacity: 0; vector-effect: non-scaling-stroke; }
.ap-nodes circle {
  fill: rgba(241, 235, 221, .8);
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, .55));
  transform-box: fill-box;
  transform-origin: center;
  transition: transform .25s ease, fill .25s ease;
  pointer-events: auto;
  cursor: default;
}
.ap-nodes circle:hover { transform: scale(1.8); fill: #fff; }

@media (prefers-reduced-motion: no-preference) {
  .ap-signal { opacity: 1; animation: ap-flow 9s linear infinite; }
  .ap-s2 { animation-duration: 13s; animation-delay: -5s; }
  .ap-nodes circle { animation: ap-blink 7s ease-in-out infinite; }
  .ap-nodes .ap-n2 { animation-delay: 1s; }
  .ap-nodes .ap-n3 { animation-delay: 2s; }
  .ap-nodes .ap-n4 { animation-delay: 3s; }
  .ap-nodes .ap-n5 { animation-delay: 4s; }
  .ap-nodes .ap-n6 { animation-delay: 5s; }
  .ap-nodes .ap-n7 { animation-delay: 6s; }
  .ap-nodes circle:hover { animation-play-state: paused; }
}
@keyframes ap-flow { to { stroke-dashoffset: -266; } }
@keyframes ap-blink { 0%, 70%, 100% { fill: rgba(241, 235, 221, .72); } 80% { fill: #fff; } }

/* the notes: pinned to α (top right), θ (top middle) and ω (bottom) */
.ap-notes { position: absolute; inset: 0; margin: 0; padding: 0; list-style: none; pointer-events: none; }
.ap-note { position: absolute; width: 0; height: 0; }
.ap-t1 { left: 91.67%; top: 9.8%; }
.ap-t2 { left: 46.81%; top: 36.08%; }
.ap-t3 { left: 59.86%; top: 90.39%; }
.ap-line {
  position: absolute;
  bottom: 10px;
  left: 0;
  width: 1px;
  height: 34px;
  background: linear-gradient(0deg, rgba(241, 235, 221, .6), rgba(241, 235, 221, .2));
}
.ap-label {
  position: absolute;
  bottom: 54px;
  left: -1px;
  color: rgba(241, 235, 221, .86);
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: .18em;
  line-height: 1.3;
  text-transform: uppercase;
  white-space: nowrap;
  text-shadow: 0 0 12px rgba(14, 15, 15, .95);
}
.ap-t1 .ap-label { right: -1px; left: auto; text-align: right; }
.ap-t3 .ap-line { top: 10px; bottom: auto; background: linear-gradient(180deg, rgba(241, 235, 221, .6), rgba(241, 235, 221, .2)); }
.ap-t3 .ap-label { top: 52px; bottom: auto; }

/* --- Scope: four modules, linked ----------------------------------------- */
.ap-modules {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(28px, 3vw, 44px);
  max-width: 1120px;
}
/* the links behind the modules: one horizontal, one vertical, through the centre */
.ap-modules::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  background:
    linear-gradient(rgba(241, 235, 221, .22), rgba(241, 235, 221, .22)) 50% 50% / 100% 1px no-repeat,
    linear-gradient(rgba(241, 235, 221, .22), rgba(241, 235, 221, .22)) 50% 50% / 1px 100% no-repeat;
  pointer-events: none;
}
.ap-modules li {
  position: relative;
  z-index: 1;
  padding: clamp(22px, 2.2vw, 30px);
  border: 1px solid rgba(241, 235, 221, .14);
  border-radius: 12px;
  background: rgba(19, 22, 24, .92);
}
.ap-modules li::before {
  content: "";
  position: absolute;
  top: -4px;
  left: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(241, 235, 221, .7);
}

/* --- Reveal: the modules assemble, the links draw ------------------------ */
.svc-motion .service-web-apps .svc-reveal { transform: translate3d(0, 32px, 0); }
.svc-motion .service-web-apps .svc-reveal.is-visible { transform: none; }
.svc-motion .service-web-apps .svc-reveal-item {
  opacity: 0;
  transition: opacity 1s ease, transform 1.3s cubic-bezier(.16, 1, .3, 1);
  transition-delay: calc(.2s + var(--i, 0) * .16s);
}
.svc-motion .service-web-apps .ap-modules li:nth-child(1) { transform: translate3d(-28px, -24px, 0); }
.svc-motion .service-web-apps .ap-modules li:nth-child(2) { transform: translate3d(28px, -24px, 0); }
.svc-motion .service-web-apps .ap-modules li:nth-child(3) { transform: translate3d(-28px, 24px, 0); }
.svc-motion .service-web-apps .ap-modules li:nth-child(4) { transform: translate3d(28px, 24px, 0); }
.svc-motion .service-web-apps .svc-scope.is-visible .ap-modules li { opacity: 1; transform: none; }
.svc-motion .service-web-apps .ap-modules::before { background-size: 0 1px, 1px 0; transition: background-size 1.6s cubic-bezier(.45, 0, .2, 1) .9s; }
.svc-motion .service-web-apps .is-visible .ap-modules::before { background-size: 100% 1px, 1px 100%; }

/* --- Tablet / mobile ----------------------------------------------------- */
@media (max-width: 960px) {
  .service-web-apps .svc-hero { align-items: flex-end; padding-top: calc(min(620px, 76vw) * .7083 + 90px); }
  .ap-chart { top: 64px; right: auto; left: calc(50% - min(620px, 76vw) / 2); width: min(620px, 76vw); }
  .ap-modules { grid-template-columns: minmax(0, 1fr); }
  .ap-modules::before { background: linear-gradient(rgba(241, 235, 221, .22), rgba(241, 235, 221, .22)) 32px 0 / 1px 100% no-repeat; }
  .svc-motion .service-web-apps .ap-modules::before { background-size: 1px 0; }
  .svc-motion .service-web-apps .is-visible .ap-modules::before { background-size: 1px 100%; }
}
@media (max-width: 680px) {
  .service-web-apps { --ap-w: 180vw; }
  .ap-sky .ap-dust { top: calc(var(--ap-w) * -0.45); }
  .service-web-apps .svc-hero { padding-top: calc(84vw * .7083 + 128px); }
  .ap-chart { top: 56px; left: 6vw; width: 84vw; }
  .ap-label { font-size: .6875rem; letter-spacing: .14em; }
  .ap-line { height: 24px; }
  .ap-label { bottom: 42px; }
  .ap-t3 .ap-label { top: 40px; right: -1px; left: auto; text-align: right; }
}
