/* =========================================================
   Motion — токени й CSS-частина анімацій.
   Усе, що працює без JS (ховери, натискання), живе тут.
   Скрол і послідовності — у js/motion.js.
   ========================================================= */
:root {
  /* криві — єдині на весь сайт */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);       /* поява, відповідь на дію */
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);   /* рух уже видимого елемента */
  --ease-drop: cubic-bezier(0.4, 0, 0.2, 1);        /* «падіння блока» — крива з keyframes макета */
  /* тривалості */
  --t-press: 120ms;
  --t-hover: 200ms;
  --t-ui: 260ms;
}

/* ---------- Кнопка ↳: перелив градієнта + стрілка «повертається» ---------- */
.btn { transition: transform var(--t-press) var(--ease-out); }
.btn:active { transform: scale(.97); }
.btn--fill::before {
  /* світлий відблиск, що проходить по кнопці при наведенні */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.28) 50%, transparent 70%);
  transform: translateX(-120%);
}
.btn--line { transition: transform var(--t-press) var(--ease-out), background-color var(--t-hover) ease, color var(--t-hover) ease; }
.btn__ic .arr + .arr { transform: translate(-110%, -110%); }

@media (hover: hover) and (pointer: fine) {
  .btn--fill:hover::before { transform: translateX(120%); transition: transform 700ms var(--ease-out); }
  .btn--line:hover { background: #f3f5ff; }
  .btn:hover .btn__ic .arr:first-child,
  .nav__contact:hover .nav__contact-ic .arr:first-child { transform: translate(110%, 110%); transition: transform var(--t-ui) var(--ease-out); }
  .btn:hover .btn__ic .arr + .arr,
  .nav__contact:hover .nav__contact-ic .arr + .arr { transform: translate(0, 0); transition: transform var(--t-ui) var(--ease-out) 60ms; }
}
.btn__ic .arr, .nav__contact-ic .arr { transition: transform 0ms; }
.nav__contact-ic .arr { position: absolute; inset: 22.5%; }
.nav__contact-ic .arr + .arr { transform: translate(-110%, -110%); }

/* ---------- Підкреслення посилань: заходить зліва, виходить праворуч ---------- */
.ulink::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 1px; background: currentColor;
  transform: scaleX(0); transform-origin: right; transition: transform 320ms var(--ease-out);
}
.ulink.is-on::after { transform: scaleX(1); }
@media (hover: hover) and (pointer: fine) {
  .ulink:hover::after { transform: scaleX(1); transform-origin: left; }
  .nav__contact:hover .ulink.is-on::after { animation: relink 520ms var(--ease-out); }
}
@keyframes relink { 0% { transform: scaleX(1); transform-origin: right; } 45% { transform: scaleX(0); transform-origin: right; } 46% { transform-origin: left; } 100% { transform: scaleX(1); transform-origin: left; } }

/* ---------- Навігація: ховається вниз, зʼявляється вгору; колір за темою ---------- */
.nav { transition: transform 420ms var(--ease-out), color 300ms ease; }
.nav.is-hidden { transform: translateY(-110%); }
.nav::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--bg); opacity: 0; transition: opacity 300ms ease; }
.nav.is-scrolled::before { opacity: .86; }
@supports (backdrop-filter: blur(1px)) { .nav.is-scrolled::before { backdrop-filter: blur(14px); opacity: .72; } }

/* ---------- Тема сторінки (світла / темна) — тягне скрол ---------- */
body { transition: none; }
body, .nav { background-color: transparent; }
html { background: var(--bg); }

/* ---------- «Ви» / «Ми»: загоряються по черзі ---------- */
.principles [data-vymy] { color: #fff; transition: color 600ms var(--ease-out); }
.principles.is-lit [data-vymy] { color: var(--blue-text); }
.principles.is-lit [data-vymy="2"] { transition-delay: 450ms; }

/* ---------- Проєкти: ховер ---------- */
.proj__img img { transition: transform 900ms var(--ease-out); }
.proj__name { transition: color var(--t-hover) ease; }
@media (hover: hover) and (pointer: fine) {
  .proj:hover .proj__img img { transform: scale(1.04); }
  .proj:hover .proj__name { color: var(--blue-text); }
}

/* ---------- Логотипи: ховер на окремому лого ---------- */
.logos-svg g[clip-path] { transition: opacity var(--t-hover) ease; }

/* ---------- Етапи: картка трохи «дихає» під мишею ---------- */
.stage { transition: background-color 300ms ease; }
@media (hover: hover) and (pointer: fine) {
  .stage:hover { background-color: #e2e6f0; }
}

/* ---------- Команда ---------- */
.team__viewport.is-dragging { cursor: grabbing; }
.member__ph img { transform: scale(1.12); }

/* ---------- Конвеєр цін: статичний режим (телефон / зменшений рух) ---------- */
.price.is-static { height: auto; padding: 120px 0; }
.price.is-static .price__stage { position: relative; }
.price.is-static .price__head { position: relative; left: auto; top: auto; transform: none; margin: 0 auto; padding: 0 var(--pad); width: auto; max-width: 920px; }
.price.is-static .price__cards { position: relative; overflow-x: auto; scroll-snap-type: x mandatory; padding: 48px var(--pad) 24px; pointer-events: auto; }
.price.is-static .price__track { --ch: min(560px, 120vw); --gap: 16px; position: relative; left: auto; top: auto; bottom: auto; transform: none !important; }
.price.is-static .pcard { scroll-snap-align: center; transform: none !important; }

/* =========================================================
   Зменшений рух: лишаємо прозорість і колір, прибираємо переміщення.
   (motion.js теж читає prefers-reduced-motion і не вмикає скрол-сцени)
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  .btn--fill::before { display: none; }
  .btn:active { transform: none; }
  .proj__img img, .member__ph img { transform: none !important; transition: none; }
  .nav { transition: color 300ms ease; }
}
html.rm .btn--fill::before { display: none; }
html.rm .proj__img img, html.rm .member__ph img { transform: none !important; }

/* ---- In progress: кейси без посилання — легкі пікселі + мітка з крапками ---- */
.wip { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.wip__px { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 300ms var(--ease-out); }
.is-px .wip__px { opacity: 1; }
/* поки мозаїка не готова (або без JS) — сильне розмиття, щоб кейс не можна було роздивитись */
.proj__img:has(.wip) img, .case__media:has(.wip) img { filter: blur(18px); transform: scale(1.12) !important; }
.proj__img:has(.wip), .case__media:has(.wip) { isolation: isolate; }
.wip__tag {
  position: absolute; left: calc(24 * var(--u)); top: calc(24 * var(--u));
  display: inline-flex; align-items: center; gap: calc(10 * var(--u));
  height: calc(44 * var(--u)); padding: 0 calc(18 * var(--u)) 0 calc(16 * var(--u));
  border-radius: 999px; background: rgba(255, 255, 255, .86); color: var(--blue);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  font-size: max(calc(20 * var(--u)), 13px); line-height: 1; white-space: nowrap; letter-spacing: -.01em;
}
.wip__sq { width: calc(10 * var(--u)); height: calc(10 * var(--u)); min-width: 6px; min-height: 6px; background: var(--blue); animation: wipSq 1.6s steps(1) infinite; }
.wip__dots { display: inline-flex; gap: .22em; margin-left: .08em; }
.wip__dots i { font-style: normal; opacity: .15; animation: wipDot 1.4s steps(1) infinite; }
.wip__dots i:nth-child(2) { animation-delay: .25s; }
.wip__dots i:nth-child(3) { animation-delay: .5s; }
@keyframes wipDot { 0%, 100% { opacity: .15; } 18%, 70% { opacity: 1; } }
@keyframes wipSq { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.case .wip__tag { left: calc(32 * var(--u)); top: calc(32 * var(--u)); }
@media (max-width: 1199px) {
  .wip__tag { left: calc(12 * var(--m)); top: calc(12 * var(--m)); height: calc(32 * var(--m)); padding: 0 calc(12 * var(--m)); gap: calc(7 * var(--m)); font-size: calc(14 * var(--m)); }
  .case .wip__tag { left: calc(12 * var(--m)); top: calc(12 * var(--m)); }
}
@media (prefers-reduced-motion: reduce) {
  .wip__dots i, .wip__sq { animation: none; opacity: 1; }
}
html.rm .wip__dots i, html.rm .wip__sq { animation: none; opacity: 1; }

/* ---- Відеокружечок (головна, UA): закріплений праворуч, клік — більший і зі звуком ---- */
.vnote {
  --d: 520; --s: .66;                                     /* розмір відкритого кружка в u; закритий = d × s (≈345u) */
  position: fixed; z-index: 44; right: calc(20 * var(--u)); top: calc(220 * var(--u));
  width: calc(var(--d) * var(--u)); height: calc(var(--d) * var(--u)); pointer-events: none;
}
.vnote__circle {
  position: absolute; inset: 0; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  background: none; pointer-events: auto; -webkit-tap-highlight-color: transparent;
  transform-origin: 100% 0; transform: scale(calc(var(--s) * .8)); opacity: 0;
  transition: transform 650ms cubic-bezier(0.23, 1, 0.32, 1), opacity 400ms ease;
}
.vnote.is-in .vnote__circle { transform: scale(var(--s)); opacity: 1; }
.vnote.is-open .vnote__circle { transform: scale(1); }
.vnote__clip {
  /* саме відео — трохи менше за кнопку: довкола лишається місце для кільця прогресу, як у Telegram */
  position: absolute; inset: 4.2%; border-radius: 50%; overflow: hidden; background: #d9dce3;
  box-shadow: 0 0 0 3px #fff, 0 calc(20 * var(--u)) calc(50 * var(--u)) calc(-16 * var(--u)) rgba(20, 30, 70, .45);
  transition: box-shadow 300ms ease;
}
.vnote.is-open .vnote__clip { box-shadow: 0 calc(20 * var(--u)) calc(50 * var(--u)) calc(-16 * var(--u)) rgba(20, 30, 70, .45); }
.vnote video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scale(1.02); }
.vnote__full { opacity: 0; transition: opacity 250ms ease; }
.vnote.is-open .vnote__full { opacity: 1; }
.vnote__ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); pointer-events: none; }
/* таймлайн по колу: дуга від 12-ї години за годинниковою стрілкою = скільки вже минуло; повзунок можна тягнути */
.vnote__ring circle { fill: none; stroke-width: 1.1; opacity: 0; transition: opacity 250ms ease; }
.vnote__track { stroke: rgba(140, 146, 160, .35); }
.vnote__bar { stroke: #2f5bff; stroke-linecap: round; stroke-dasharray: 301.59; stroke-dashoffset: 301.59; }
.vnote__knob { fill: #2f5bff !important; stroke: #fff !important; stroke-width: .8 !important; }
.vnote__hit { stroke: transparent; stroke-width: 8 !important; }
.vnote.is-open .vnote__ring circle { opacity: 1; }
.vnote.is-open .vnote__hit { pointer-events: stroke; cursor: pointer; touch-action: none; }
.vnote.is-seeking .vnote__knob { r: 3.2; }
/* залишок часу, як у Telegram */
.vnote__time {
  position: absolute; left: 50%; bottom: 7%; transform: translateX(-50%); padding: .3em .7em; border-radius: 999px;
  background: rgba(0, 0, 0, .45); color: #fff; font-size: max(calc(20 * var(--u)), 13px); line-height: 1; font-variant-numeric: tabular-nums;
  opacity: 0; transition: opacity 250ms ease;
}
.vnote.is-open .vnote__time { opacity: 1; }
.vnote__badge {
  position: absolute; left: 14%; bottom: 8%; display: grid; place-items: center; width: 22%; aspect-ratio: 1; border-radius: 50%;
  background: #2f5bff; color: #fff; transition: opacity 250ms ease, transform 450ms cubic-bezier(0.23, 1, 0.32, 1);
}
.vnote__badge svg { width: 52%; height: 52%; }
.vnote.is-open .vnote__badge { opacity: 0; transform: scale(.6); }
.vnote__x {
  position: absolute; z-index: 1; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; cursor: pointer; pointer-events: auto;
  width: max(calc(32 * var(--u)), 24px); height: max(calc(32 * var(--u)), 24px); background: #fff; color: var(--ink);
  box-shadow: 0 4px 14px rgba(20, 30, 70, .18);
  /* у закритому стані — біля верхнього лівого краю малого кружка */
  right: calc(var(--d) * var(--s) * var(--u) - max(calc(32 * var(--u)), 24px) * .6); top: 0;
  opacity: 0; transform: scale(.6); transition: opacity 300ms ease, transform 450ms cubic-bezier(0.23, 1, 0.32, 1), right 650ms cubic-bezier(0.23, 1, 0.32, 1);
}
.vnote__x svg { width: 50%; height: 50%; }
.vnote.is-in .vnote__x { opacity: 1; transform: none; }
.vnote.is-open .vnote__x { right: calc(var(--d) * var(--u) * .86); top: calc(var(--d) * var(--u) * .08); }
.vnote.is-gone { display: none; }
@media (hover: hover) and (pointer: fine) {
  .vnote.is-in:not(.is-open) .vnote__circle:hover { transform: scale(calc(var(--s) * 1.06)); }
}
.vnote__circle:focus-visible { outline: 2px solid #2f5bff; outline-offset: 4px; }
@media (max-width: 1199px) {
  /* на телефоні — у нижньому правому куті, щоб не закривати заголовок */
  .vnote { --d: 320; --s: .53; --u: 1px; top: auto; right: 12px; bottom: calc(16px + env(safe-area-inset-bottom)); }
  .vnote__circle { transform-origin: 100% 100%; }
  .vnote__x { top: auto; bottom: calc(var(--d) * var(--s) * 1px - 18px); right: calc(var(--d) * var(--s) * 1px - 14px); }
  .vnote.is-open .vnote__x { bottom: calc(var(--d) * 1px - 34px); right: calc(var(--d) * 1px - 34px); }
  .menu-open .vnote { opacity: 0; pointer-events: none; }
}
@media (prefers-reduced-motion: reduce) {
  .vnote__circle, .vnote__x, .vnote__badge { transition: opacity 200ms ease; }
}
