/* ==========================================================================
   Ховер-эффекты кейсов: 10 вариантов + плашка выбора (hover-fx.js)
   Всё живёт в .fx-root внутри .work-card__media. Анимации идут только
   пока на карточке класс .fx-hover. Двигаем только transform / opacity.
   Удалить целиком: убрать hover-fx.css и hover-fx.js из index.html.
   ========================================================================== */

/* без z-index и opacity на самом контейнере: иначе он становится отдельной
   группой и mix-blend-mode (инверсия, голограмма) не видит картинку под ним */
.fx-root {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: inherit;
  visibility: hidden;
  transition: visibility 0s linear 0.3s;
  --fx-h: var(--hue, 210);
}

.fx-root > * {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.work-card.fx-hover .fx-root {
  visibility: visible;
  transition: none;
}

.work-card.fx-hover .fx-root > * {
  opacity: 1;
  transition: none;
}

/* клоны не нужны в полёте и в попапе */
.work-card__lift .fx-root,
.work-card__fly .fx-root,
.work-card.is-morphing .fx-root,
.work-card.is-case-active .fx-root,
.work-card.is-case-closing .fx-root {
  display: none;
}

.fx-layer {
  position: absolute;
  inset: 0;
}

/* копия картинки/лица карточки для эффектов, где нужна «вторая картинка» */
.fx-src {
  position: absolute;
  inset: 0;
}

.fx-src--vis {
  inset: -56px;
  transform: translate3d(0, 0, 0) scale(1.24);
}

.fx-src--vis img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fx-src--vis .fx-live {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
}
.fx-vid .fx-src--vis .fx-live { display: block; }

.fx-src .work-card__face {
  border-radius: 0;
}

/* ---------- 1. Глитч ---------- */
.fx-g {
  position: absolute;
  inset: 0;
  opacity: 0;
  will-change: transform;
}

.fx-g--r { filter: url(#fx-ch-r); mix-blend-mode: screen; }
.fx-g--c { filter: url(#fx-ch-c); mix-blend-mode: screen; }

.fx-g--s1 { clip-path: inset(10% 0 78% 0); --a: 34px; }
.fx-g--s2 { clip-path: inset(34% 0 55% 0); --a: -52px; }
.fx-g--s3 { clip-path: inset(57% 0 30% 0); --a: 26px; }
.fx-g--s4 { clip-path: inset(80% 0 9% 0); --a: -40px; }

.fx-hover .fx-g--s1,
.fx-hover .fx-g--s2,
.fx-hover .fx-g--s3,
.fx-hover .fx-g--s4 {
  animation: fx-slice 2.6s steps(1, end) infinite;
}
.fx-hover .fx-g--s2 { animation-delay: 0.03s; }
.fx-hover .fx-g--s3 { animation-delay: 0.06s; }
.fx-hover .fx-g--s4 { animation-delay: 0.02s; }

.fx-hover .fx-g--r { animation: fx-chan-r 2.6s steps(1, end) infinite; }
.fx-hover .fx-g--c { animation: fx-chan-c 2.6s steps(1, end) infinite; }

.fx-g-bar {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  top: 40%;
  background: rgba(255, 255, 255, 0.85);
  opacity: 0;
}
.fx-hover .fx-g-bar { animation: fx-gbar 2.6s steps(1, end) infinite; }

@keyframes fx-slice {
  0%    { opacity: 1; transform: translate3d(var(--a), 0, 0); }
  2.5%  { opacity: 1; transform: translate3d(calc(var(--a) * -0.7), 0, 0); }
  5%    { opacity: 1; transform: translate3d(calc(var(--a) * 0.4), 0, 0); }
  7.5%  { opacity: 1; transform: translate3d(calc(var(--a) * -1.2), 0, 0); }
  10%   { opacity: 0; transform: none; }
  54%   { opacity: 1; transform: translate3d(calc(var(--a) * 0.6), 0, 0); }
  56%   { opacity: 1; transform: translate3d(calc(var(--a) * -0.5), 0, 0); }
  58%   { opacity: 0; transform: none; }
  100%  { opacity: 0; }
}

@keyframes fx-chan-r {
  0%   { opacity: 0.9; transform: translate3d(-10px, 2px, 0); }
  3%   { opacity: 0.9; transform: translate3d(8px, -1px, 0); }
  6%   { opacity: 0.9; transform: translate3d(-5px, 0, 0); }
  9%   { opacity: 0.7; transform: translate3d(-3px, 0, 0); }
  12%  { opacity: 0; transform: none; }
  54%  { opacity: 0.8; transform: translate3d(6px, 0, 0); }
  58%  { opacity: 0; transform: none; }
  100% { opacity: 0; }
}

@keyframes fx-chan-c {
  0%   { opacity: 0.9; transform: translate3d(10px, -2px, 0); }
  3%   { opacity: 0.9; transform: translate3d(-8px, 1px, 0); }
  6%   { opacity: 0.9; transform: translate3d(5px, 0, 0); }
  9%   { opacity: 0.7; transform: translate3d(3px, 0, 0); }
  12%  { opacity: 0; transform: none; }
  54%  { opacity: 0.8; transform: translate3d(-6px, 0, 0); }
  58%  { opacity: 0; transform: none; }
  100% { opacity: 0; }
}

@keyframes fx-gbar {
  0%   { opacity: 1; transform: translate3d(0, 0, 0); }
  2%   { opacity: 1; transform: translate3d(0, 90px, 0) scaleY(2); }
  4%   { opacity: 1; transform: translate3d(0, -60px, 0); }
  6%   { opacity: 0; }
  55%  { opacity: 1; transform: translate3d(0, 130px, 0); }
  57%  { opacity: 0; }
  100% { opacity: 0; }
}

/* ---------- 2. CRT ---------- */
.fx-crt-lines {
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.32) 0 1px,
    transparent 1px 3px
  );
  box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.55);
}
.fx-hover .fx-crt-lines { animation: fx-flicker 0.18s steps(2, end) infinite; }

.fx-crt-sweep {
  top: -30%;
  bottom: auto;
  height: 30%;
  background: linear-gradient(
    180deg,
    transparent,
    rgba(255, 255, 255, 0.07) 60%,
    rgba(255, 255, 255, 0.22) 94%,
    transparent
  );
}
.fx-hover .fx-crt-sweep { animation: fx-sweep 2.4s linear infinite; }

.fx-crt-on {
  background: #f4f4f0;
  opacity: 0;
}
.fx-hover .fx-crt-on { animation: fx-power 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both; }

@keyframes fx-flicker {
  0%   { opacity: 1; }
  50%  { opacity: 0.82; }
}
@keyframes fx-sweep {
  0%   { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(0, 440%, 0); }
}
@keyframes fx-power {
  0%   { opacity: 1; transform: scale(1, 1); }
  35%  { opacity: 1; transform: scale(1, 0.006); }
  70%  { opacity: 1; transform: scale(0.02, 0.006); }
  100% { opacity: 0; transform: scale(0, 0.006); }
}

/* ---------- 3. Жалюзи ---------- */
.fx-blinds {
  display: flex;
}
.fx-blind {
  flex: 1 1 0;
  height: 100%;
  background: #0b0b0c;
  transform: translate3d(0, -101%, 0);
}
.fx-blind:nth-child(3n + 2) { background: hsl(var(--fx-h), 70%, 58%); }
.fx-blind:nth-child(3n) { background: #f2f1ec; }

.fx-hover .fx-blind {
  animation: fx-blind 0.9s cubic-bezier(0.7, 0, 0.2, 1) both;
  animation-delay: calc(var(--i) * 45ms);
}

@keyframes fx-blind {
  0%   { transform: translate3d(0, -101%, 0); }
  45%  { transform: translate3d(0, 0, 0); }
  55%  { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(0, 101%, 0); }
}

/* ---------- 4. Пиксели ---------- */
.fx-px {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  grid-template-rows: repeat(11, 1fr);
}
.fx-px i {
  display: block;
  margin: -0.5px;
  background: var(--c);
  opacity: 0;
}
.fx-hover .fx-px i {
  animation: fx-pxo var(--t) steps(1, end) var(--d);
}
@keyframes fx-pxo {
  0%, 100% { opacity: 1; }
}

/* ---------- 5. Фонарик ---------- */
.fx-spot {
  position: absolute;
  left: -150%;
  top: -150%;
  width: 300%;
  height: 300%;
  background: radial-gradient(
    circle at 50% 50%,
    transparent 0,
    transparent 118px,
    rgba(255, 255, 255, 0.7) 119px,
    rgba(255, 255, 255, 0.7) 120.5px,
    rgba(6, 6, 8, 0.2) 122px,
    rgba(6, 6, 8, 0.62) 190px,
    rgba(6, 6, 8, 0.66) 100%
  );
  will-change: transform;
}

/* ---------- 6. Видоискатель ---------- */
.fx-vf {
  color: #fff;
  font: 600 12px/1 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: 0.12em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.fx-vf-grid {
  background:
    linear-gradient(90deg, transparent calc(33.33% - 0.5px), rgba(255, 255, 255, 0.28) calc(33.33% - 0.5px) calc(33.33% + 0.5px), transparent calc(33.33% + 0.5px) calc(66.66% - 0.5px), rgba(255, 255, 255, 0.28) calc(66.66% - 0.5px) calc(66.66% + 0.5px), transparent calc(66.66% + 0.5px)),
    linear-gradient(0deg, transparent calc(33.33% - 0.5px), rgba(255, 255, 255, 0.28) calc(33.33% - 0.5px) calc(33.33% + 0.5px), transparent calc(33.33% + 0.5px) calc(66.66% - 0.5px), rgba(255, 255, 255, 0.28) calc(66.66% - 0.5px) calc(66.66% + 0.5px), transparent calc(66.66% + 0.5px));
  opacity: 0;
}
.fx-hover .fx-vf-grid { animation: fx-fade 0.5s 0.25s ease both; }

.fx-vf-c {
  position: absolute;
  width: 34px;
  height: 34px;
  border: 0 solid #fff;
  opacity: 0;
}
.fx-vf-c--tl { left: 9%; top: 12%; border-width: 2px 0 0 2px; --dx: -40px; --dy: -40px; }
.fx-vf-c--tr { right: 9%; top: 12%; border-width: 2px 2px 0 0; --dx: 40px; --dy: -40px; }
.fx-vf-c--bl { left: 9%; bottom: 12%; border-width: 0 0 2px 2px; --dx: -40px; --dy: 40px; }
.fx-vf-c--br { right: 9%; bottom: 12%; border-width: 0 2px 2px 0; --dx: 40px; --dy: 40px; }
.fx-hover .fx-vf-c { animation: fx-corner 0.55s cubic-bezier(0.3, 1.6, 0.4, 1) both; }

.fx-vf-rec {
  position: absolute;
  left: calc(9% + 16px);
  top: calc(12% + 16px);
  padding-left: 16px;
  opacity: 0;
}
.fx-vf-rec::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 9px;
  height: 9px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: #ff3b30;
  box-shadow: 0 0 8px rgba(255, 59, 48, 0.8);
}
.fx-hover .fx-vf-rec { animation: fx-fade 0.3s 0.2s ease both; }
.fx-hover .fx-vf-rec::before { animation: fx-blink 1s steps(1, end) infinite; }

.fx-vf-tc {
  position: absolute;
  right: calc(9% + 16px);
  bottom: calc(12% + 16px);
  opacity: 0;
}
.fx-vf-meta {
  position: absolute;
  right: calc(9% + 16px);
  top: calc(12% + 16px);
  opacity: 0;
}
.fx-hover .fx-vf-tc,
.fx-hover .fx-vf-meta { animation: fx-fade 0.3s 0.25s ease both; }

.fx-vf-x {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  background:
    linear-gradient(#fff, #fff) center / 100% 1.5px no-repeat,
    linear-gradient(#fff, #fff) center / 1.5px 100% no-repeat;
  opacity: 0;
}
.fx-hover .fx-vf-x { animation: fx-pop 0.4s 0.15s cubic-bezier(0.3, 1.6, 0.4, 1) both; }

@keyframes fx-corner {
  0%   { opacity: 0; transform: translate3d(var(--dx), var(--dy), 0); }
  100% { opacity: 1; transform: none; }
}
@keyframes fx-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes fx-blink {
  0%  { opacity: 1; }
  50% { opacity: 0; }
}
@keyframes fx-pop {
  0%   { opacity: 0; transform: scale(2.4) rotate(45deg); }
  100% { opacity: 0.9; transform: none; }
}

/* ---------- 7. Бегущая строка ---------- */
.fx-band {
  position: absolute;
  left: -15%;
  width: 130%;
  height: 21%;
  display: flex;
  align-items: center;
  overflow: hidden;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(20px, 2.6vw, 38px);
  letter-spacing: -0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.fx-band--a {
  top: 26%;
  background: #f2f1ec;
  color: #0b0b0c;
  transform: rotate(-7deg) scaleY(0);
}
.fx-band--b {
  top: 56%;
  background: hsl(var(--fx-h), 80%, 60%);
  color: #0b0b0c;
  transform: rotate(5deg) scaleY(0);
}
.fx-hover .fx-band--a { animation: fx-band-a 0.45s cubic-bezier(0.3, 1.4, 0.4, 1) both; }
.fx-hover .fx-band--b { animation: fx-band-b 0.45s 0.08s cubic-bezier(0.3, 1.4, 0.4, 1) both; }

.fx-band__track {
  display: flex;
  flex: none;
  will-change: transform;
}
.fx-band__track span { padding-right: 0.6em; }
.fx-hover .fx-band--a .fx-band__track { animation: fx-marq 9s linear infinite; }
.fx-hover .fx-band--b .fx-band__track { animation: fx-marq 7s linear infinite reverse; }

@keyframes fx-band-a {
  from { transform: rotate(-7deg) scaleY(0); }
  to   { transform: rotate(-7deg) scaleY(1); }
}
@keyframes fx-band-b {
  from { transform: rotate(5deg) scaleY(0); }
  to   { transform: rotate(5deg) scaleY(1); }
}
@keyframes fx-marq {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(-50%, 0, 0); }
}

/* ---------- 8. Инверсная капля ---------- */
.fx-inv {
  position: absolute;
  left: 0;
  top: 0;
  width: 190px;
  height: 190px;
  margin: -95px 0 0 -95px;
  border-radius: 50%;
  background: #fff;
  mix-blend-mode: difference;
  will-change: transform;
}

/* ---------- 9. Дешифровка ---------- */
.fx-dec-bg {
  background: #08080a;
  opacity: 0;
}
.fx-hover .fx-dec-bg { animation: fx-decbg 0.8s ease both; }
@keyframes fx-decbg {
  0%   { opacity: 0.9; }
  100% { opacity: 0.18; }
}

.fx-dec-txt {
  margin: 0;
  padding: 6px 8px;
  color: hsl(var(--fx-h), 85%, 72%);
  font: 500 13px/14px ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  white-space: pre;
  overflow: hidden;
}

.fx-dec-title {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 16px;
  background: rgba(8, 8, 10, 0.82);
  color: #fff;
  font: 600 14px/1 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: pre;
  border-radius: 6px;
  border: 1px solid hsla(var(--fx-h), 85%, 72%, 0.6);
}

/* ---------- 10. Голограмма ---------- */
.fx-holo {
  position: absolute;
  left: -50%;
  top: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    115deg,
    transparent 36%,
    rgba(255, 0, 170, 0.34) 41%,
    rgba(255, 220, 0, 0.3) 46%,
    rgba(0, 255, 170, 0.3) 50%,
    rgba(0, 170, 255, 0.34) 54%,
    rgba(170, 0, 255, 0.3) 59%,
    transparent 64%
  );
  mix-blend-mode: color-dodge;
  will-change: transform;
}
.fx-holo-foil {
  background: repeating-linear-gradient(
    60deg,
    rgba(255, 255, 255, 0) 0 5px,
    rgba(255, 255, 255, 0.16) 5px 6px
  );
  mix-blend-mode: overlay;
}
.fx-holo-glare {
  position: absolute;
  left: 0;
  top: 0;
  width: 420px;
  height: 420px;
  margin: -210px 0 0 -210px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 62%);
  mix-blend-mode: soft-light;
  will-change: transform;
}

/* ==========================================================================
   Плашка выбора
   ========================================================================== */
.fx-panel {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 30000;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: calc(100vw - 32px);
  padding: 6px;
  border-radius: 999px;
  background: rgba(14, 14, 16, 0.9);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  /* PERF: без backdrop-filter — под плашкой каждый кадр меняется WebGL-фон,
     и размытие пересчитывалось каждый кадр. Фон и так почти непрозрачный */
  color: #eee;
  font: 500 12px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow-x: auto;
  scrollbar-width: none;
}
.fx-panel::-webkit-scrollbar { display: none; }

.fx-panel__label {
  flex: none;
  padding: 0 8px 0 10px;
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
}

.fx-panel button {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.fx-panel button b {
  font-weight: 700;
  opacity: 0.45;
}
.fx-panel button:hover { background: rgba(255, 255, 255, 0.1); }
.fx-panel button.is-on {
  background: #f2f1ec;
  color: #0b0b0c;
}
.fx-panel button.is-on b { opacity: 0.6; }

.fx-panel__hide {
  width: 30px;
  padding: 0 !important;
  justify-content: center;
  color: rgba(255, 255, 255, 0.5) !important;
}

.fx-panel.is-min > :not(.fx-panel__hide):not(.fx-panel__cur) { display: none; }
.fx-panel__cur { display: none; padding: 0 6px 0 10px; white-space: nowrap; }
.fx-panel.is-min .fx-panel__cur { display: inline; }

@media (hover: none), (prefers-reduced-motion: reduce) {
  .fx-root,
  .fx-panel { display: none !important; }
}

/* плашка выбора видна только с ?fx=N */
.fx-panel[hidden] { display: none !important; }
