/* ============================================================
   Фоны главной страницы webpagesdesign.
   Варианты фона под body.fx-demo (демо-страницы index-fx1..5
   и прод-версия index.html, где выбрана комбинация data-fx="3,4").
   ============================================================ */

.fx-demo { scroll-behavior: smooth; }
.fx-demo ::selection { background: var(--accent); color: #fff; }

/* Слой фона внутри hero */
.hero-fx {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
/* подслой для комбинаций вида data-fx="3,4": порядок в DOM = порядок глубины */
.fx-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.fx-demo .hero__container { z-index: 2; }
.fx-demo .hero__stats { position: relative; z-index: 2; }

/* ---------- общая полировка главной (на всех демо) ---------- */
.fx-demo .header {
  transition: box-shadow .25s ease, background-color .25s ease;
}
.fx-demo .header.is-scrolled {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 30px -22px rgba(15, 18, 22, 0.45);
}
.fx-demo .hero__badge {
  box-shadow: 0 10px 24px -16px rgba(255, 91, 31, 0.55);
}
.fx-demo .hero__photo {
  border-radius: 18px;
  border-color: rgba(15, 18, 22, 0.06);
  box-shadow:
    10px 10px 0 -1px #ffffff,
    10px 10px 0 0 rgba(255, 91, 31, 0.28),
    0 34px 70px -38px rgba(15, 18, 22, 0.45);
}
.fx-demo .hero__photo img { transition: transform 6s ease; }
.fx-demo .hero__photo:hover img { transform: scale(1.04); }
.fx-demo .btn--primary { box-shadow: 0 12px 28px -14px rgba(255, 91, 31, 0.75); }
.fx-demo .btn--primary:hover { box-shadow: 0 18px 38px -16px rgba(255, 91, 31, 0.8); }
.fx-demo .btn--ghost { background: rgba(255, 255, 255, 0.6); }
.fx-demo .stat__num { font-variant-numeric: tabular-nums; }
@media (min-width: 861px) {
  .fx-demo .hero__stats .stat + .stat { border-left: 1px solid var(--border); }
}
.fx-demo .work__img { background: linear-gradient(180deg, #f2f1ee, #faf9f7); }

/* ---------- переключатель вариантов ---------- */
.fx-switch {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px -18px rgba(15, 18, 22, 0.5);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}
.fx-switch a {
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--text-mute);
  text-decoration: none;
  transition: background .2s, color .2s;
}
.fx-switch a:hover { background: var(--bg-alt); color: var(--text); }
.fx-switch a.is-active { background: var(--accent); color: #fff; }
.fx-switch .fx-switch__sep { width: 1px; height: 16px; background: var(--border); margin: 0 3px; }
@media (max-width: 560px) { .fx-switch { display: none; } }

/* ============================================================
   1. «Живой чертёж»
   ============================================================ */
.fx-gridpulse {
  position: absolute;
  inset: -25%;
  background-image:
    linear-gradient(to right, rgba(255, 91, 31, 0.26) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 91, 31, 0.26) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(circle 320px at 50% 50%, #000 0%, transparent 70%);
  mask-image: radial-gradient(circle 320px at 50% 50%, #000 0%, transparent 70%);
  -webkit-mask-size: 180% 180%;
  mask-size: 180% 180%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  animation: fxMaskDrift 22s ease-in-out infinite alternate;
}
@keyframes fxMaskDrift {
  0%   { -webkit-mask-position: 0% 0%;   mask-position: 0% 0%; }
  50%  { -webkit-mask-position: 100% 40%; mask-position: 100% 40%; }
  100% { -webkit-mask-position: 30% 100%; mask-position: 30% 100%; }
}
.fx-scan {
  position: absolute;
  top: -10%;
  bottom: -10%;
  width: 34%;
  background: linear-gradient(90deg, transparent, rgba(255, 91, 31, 0.09), transparent);
  transform: skewX(-12deg);
  animation: fxScan 19s linear infinite;
}
@keyframes fxScan {
  0%   { left: -40%; }
  100% { left: 110%; }
}
.fx-sketch { position: absolute; inset: 0; width: 100%; height: 100%; }
.fx-wire { opacity: 0; animation: fxWire 15s ease-in-out infinite; animation-delay: var(--d, 0s); }
.fx-wire rect {
  fill: none;
  stroke: rgba(15, 18, 22, 0.16);
  stroke-width: 1;
  stroke-dasharray: 7 7;
}
.fx-wire--accent rect { stroke: rgba(255, 91, 31, 0.38); }
.fx-wire--soft rect { stroke: rgba(120, 140, 180, 0.30); }
@keyframes fxWire {
  0%        { opacity: 0; transform: translateY(10px); }
  12%       { opacity: 1; transform: none; }
  72%       { opacity: 1; }
  88%, 100% { opacity: 0; }
}
.fx-guides line {
  stroke: rgba(255, 91, 31, 0.20);
  stroke-width: 1;
  stroke-dasharray: 5 9;
  animation: fxMarch 16s linear infinite;
}
.fx-guides line:nth-child(2n) { animation-direction: reverse; animation-duration: 23s; }
@keyframes fxMarch { to { stroke-dashoffset: -300; } }
.fx-cross path {
  stroke: rgba(15, 18, 22, 0.24);
  stroke-width: 1;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: fxCross 10s ease-in-out infinite;
  animation-delay: var(--d, 0s);
}
@keyframes fxCross {
  0%, 100% { opacity: 0; transform: scale(0.5); }
  30%, 62% { opacity: 1; transform: none; }
}

/* ============================================================
   2. «Figma-режим»
   ============================================================ */
.fx-cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 30px;
  height: 30px;
  will-change: transform;
  opacity: 0;
  transition: opacity .5s ease;
}
.fx-cursor svg {
  display: block;
  width: 22px;
  height: 22px;
  filter: drop-shadow(0 4px 6px rgba(15, 18, 22, 0.25));
}
.fx-cursor__ring {
  position: absolute;
  left: -13px;
  top: -13px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 91, 31, 0.5);
  animation: fxRing 2.4s ease-out infinite;
}
@keyframes fxRing {
  0%   { transform: scale(0.35); opacity: .9; }
  100% { transform: scale(1);    opacity: 0; }
}
.fx-cursor__label {
  position: absolute;
  left: 20px;
  top: 18px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: 600 11px/1.25 'Manrope', sans-serif;
  white-space: nowrap;
  box-shadow: 0 6px 14px -8px rgba(255, 91, 31, 0.8);
}
.fx-sel {
  position: absolute;
  left: 58%;
  top: 20%;
  width: 26%;
  aspect-ratio: 16 / 10;
  border: 1.5px solid rgba(255, 91, 31, 0.55);
  border-radius: 8px;
  opacity: 0;
  transition: opacity .4s ease;
}
.fx-sel.is-on { opacity: 1; }
.fx-sel::before, .fx-sel::after,
.fx-sel span {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background: #fff;
  border: 1.5px solid rgba(255, 91, 31, 0.85);
  border-radius: 2px;
}
.fx-sel::before { left: -4px;  top: -4px; }
.fx-sel::after  { right: -4px; bottom: -4px; }
.fx-sel span:nth-child(1) { right: -4px; top: -4px; }
.fx-sel span:nth-child(2) { left: -4px; bottom: -4px; }
.fx-sel__tag {
  position: absolute;
  left: 0;
  top: -26px;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  font: 600 11px/1.25 'Manrope', sans-serif;
  white-space: nowrap;
}
.fx-chip {
  position: absolute;
  padding: 4px 9px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  font: 500 11px/1.25 'JetBrains Mono', monospace;
  color: var(--text-mute);
  opacity: 0;
  transition: opacity .4s ease;
}
.fx-chip.is-on { opacity: 1; }

/* ============================================================
   3. «Код и браузеры»
   ============================================================ */
.fx-card {
  position: absolute;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(15, 18, 22, 0.1);
  box-shadow: 0 24px 50px -28px rgba(15, 18, 22, 0.45);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  animation: fxFloat 10s ease-in-out infinite;
  will-change: transform;
}
@keyframes fxFloat {
  0%, 100% {
    transform: translate3d(calc(var(--px, 0px) * var(--k, 1)), calc(var(--py, 0px) * var(--k, 1) - 7px), 0) rotate(var(--rot, 0deg));
  }
  50% {
    transform: translate3d(calc(var(--px, 0px) * var(--k, 1)), calc(var(--py, 0px) * var(--k, 1) + 7px), 0) rotate(var(--rot, 0deg));
  }
}
.fx-card--browser {
  left: 2%;
  top: 12%;
  width: 258px;
  --k: .55;
  --rot: -3deg;
  animation-duration: 9s;
  opacity: .82;
}
.fx-card--code {
  right: 2%;
  bottom: 15%;
  width: 250px;
  --k: .9;
  --rot: 2.5deg;
  animation-duration: 12s;
  animation-direction: reverse;
  opacity: .85;
}
.fx-card--palette {
  left: 34%;
  bottom: 3%;
  width: 196px;
  --k: .7;
  --rot: -2deg;
  animation-duration: 11s;
  animation-delay: -4s;
  opacity: .85;
}
/* мини-браузер */
.fx-browser__bar {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 10px;
  background: rgba(246, 246, 244, 0.9);
  border-bottom: 1px solid rgba(15, 18, 22, 0.07);
}
.fx-browser__bar i { width: 7px; height: 7px; border-radius: 50%; background: #d9d9d5; }
.fx-browser__bar i:first-child { background: #f0a79a; }
.fx-browser__bar span {
  margin-left: 6px;
  flex: 1;
  padding: 3px 8px;
  border-radius: 4px;
  background: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--text-dim);
}
.fx-browser__body { padding: 14px 14px 16px; }
.fx-browser__logo {
  width: 34px; height: 8px; border-radius: 4px;
  background: var(--accent); margin-bottom: 12px;
}
.fx-browser__line { height: 6px; border-radius: 3px; background: rgba(15, 18, 22, 0.12); margin-bottom: 7px; }
.fx-browser__btn { width: 66px; height: 16px; border-radius: 4px; background: rgba(255, 91, 31, 0.85); margin: 10px 0 14px; }
.fx-browser__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.fx-browser__grid b {
  display: block;
  height: 34px;
  border-radius: 5px;
  background: rgba(15, 18, 22, 0.07);
  border: 1px solid rgba(15, 18, 22, 0.06);
}
/* карточка кода (светлая, в стиле редактора) */
.fx-code {
  background: rgba(255, 255, 255, 0.88);
  color: #2b3138;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  line-height: 1.75;
}
.fx-code__bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-bottom: 1px solid rgba(15, 18, 22, 0.08);
  color: var(--text-dim);
  font-size: 9.5px;
}
.fx-code__bar i { width: 6px; height: 6px; border-radius: 50%; background: #d9d9d5; }
.fx-code__bar i:first-child { background: #f0a79a; }
.fx-code__body { padding: 12px 14px 14px; white-space: pre; }
.fx-code .c-k { color: #d9480f; }
.fx-code .c-s { color: #2f9e44; }
.fx-code .c-p { color: #1971c2; }
.fx-code .c-c { color: #9aa0a6; }
.fx-code__caret {
  display: inline-block;
  width: 6px;
  height: 11px;
  margin-left: 2px;
  background: var(--accent);
  vertical-align: -2px;
  animation: fxCaret 1.1s steps(1) infinite;
}
@keyframes fxCaret { 50% { opacity: 0; } }
/* палитра */
.fx-palette { padding: 10px; }
.fx-palette__row { display: flex; gap: 6px; }
.fx-palette__sw { flex: 1; height: 42px; border-radius: 6px; }
.fx-palette__cap {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 8.5px;
  color: var(--text-dim);
}

/* ============================================================
   4. «Пиксельная сетка»
   ============================================================ */
.fx-pixels { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ============================================================
   5. «Изометрия»
   ============================================================ */
.fx-iso {
  position: absolute;
  right: 1%;
  bottom: 5%;
  width: 400px;
  height: 300px;
  perspective: 900px;
  opacity: .9;
}
.fx-iso__scene {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  animation: fxIsoTurn 20s ease-in-out infinite alternate;
}
@keyframes fxIsoTurn {
  from { transform: rotateX(58deg) rotateZ(-44deg); }
  to   { transform: rotateX(58deg) rotateZ(-32deg); }
}
.fx-iso__page {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 230px;
  height: 150px;
  margin: -75px 0 0 -115px;
  border: 1px solid rgba(15, 18, 22, 0.18);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
  animation: fxIsoFloat 9s ease-in-out infinite;
}
.fx-iso__page::before,
.fx-iso__page::after {
  content: '';
  position: absolute;
  border-radius: 3px;
  background: rgba(15, 18, 22, 0.10);
}
.fx-iso__page::before { left: 16px; top: 18px; width: 96px; height: 8px; }
.fx-iso__page::after  { left: 16px; top: 34px; width: 150px; height: 6px; }
.fx-iso__page:nth-child(1) { transform: translateZ(0);    animation-delay: 0s; }
.fx-iso__page:nth-child(2) { transform: translateZ(34px) translate(-18px, -12px); animation-delay: -3s; }
.fx-iso__page:nth-child(3) { transform: translateZ(68px) translate(-36px, -24px); animation-delay: -6s; }
.fx-iso__page--accent {
  border-color: rgba(255, 91, 31, 0.45);
  background: rgba(255, 243, 236, 0.6);
}
.fx-iso__page--accent::before { background: rgba(255, 91, 31, 0.55); width: 70px; }
.fx-iso__page--accent::after  { background: rgba(255, 91, 31, 0.25); width: 120px; }
@keyframes fxIsoFloat {
  0%, 100% { margin-top: -80px; }
  50%      { margin-top: -70px; }
}
.fx-iso__dot {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 91, 31, 0.35);
}

/* ============================================================
   Адаптив и доступность
   ============================================================ */
@media (max-width: 860px) {
  .fx-card, .fx-iso, .fx-sel, .fx-chip, .fx-cursor { display: none; }
  .fx-gridpulse { opacity: .7; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-fx *, .hero-fx { animation: none !important; }
  .fx-cursor__ring, .fx-chip { display: none; }
  .fx-wire { opacity: 1; }
}
