/* fun.css: слой эффектов. Эффекты действуют только при html.fx-on (ставит fun.js).
 * Размеры и положение чужих блоков не меняются: nav a и h1 получают только
 * position: relative и псевдоэлементы; футер получает один абзац-пасхалку. */

:root {
  --fx-bg: #05060d;
  --fx-panel: #0c1020;
  --fx-line: #232a4a;
  --fx-gold: #ffd54a;
  --fx-cyan: #5ad7ff;
  --fx-red: #ff4d4d;
  --fx-text: #e6ecff;
}

/* ----- Пасхалка в подвале (статичная) ----- */
.fx-joke {
  margin: 0.6rem 0 0;
  font-size: 0.85rem;
  color: var(--fx-gold);
  opacity: 0.8;
  text-align: center;
}

/* ----- Слой дронов и холст (z-index выше фона, ниже шапки) ----- */
.fx-layer {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.fx-canvas {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 6;
  pointer-events: none;
}

.fx-drone {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: auto;
  cursor: pointer;
  border-radius: 50%;
  will-change: transform;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.fx-drone svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.fx-drone:focus-visible {
  outline: 2px solid var(--fx-gold);
  outline-offset: 4px;
}

.fx-eye-glow,
.fx-engine {
  animation: fx-eye 2.4s ease-in-out infinite;
}

@keyframes fx-eye {
  0%, 100% { opacity: 0.15; }
  50% { opacity: 0.55; }
}

/* красная вспышка дрона */
.fx-beam {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 3px;
  margin-top: -1.5px;
  border-radius: 2px;
  transform-origin: 0 50%;
  transform: rotate(var(--fx-angle, 0deg));
  background: linear-gradient(90deg, var(--fx-red), rgba(255, 77, 77, 0));
  box-shadow: 0 0 6px var(--fx-red);
  pointer-events: none;
  animation: fx-beam 0.26s ease-out forwards;
}

@keyframes fx-beam {
  from { width: 0; opacity: 1; }
  to { width: 160px; opacity: 0; }
}

/* звёздочки следа курсора */
.fx-star {
  position: absolute;
  left: 0;
  top: 0;
  color: var(--fx-gold);
  font-size: 11px;
  line-height: 1;
  opacity: 0;
  text-shadow: 0 0 6px var(--fx-gold);
  pointer-events: none;
  will-change: transform, opacity;
}

/* ----- Световой меч в меню ----- */
.fx-on nav a {
  position: relative;
}

.fx-on nav a::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 2px;
  border-radius: 2px;
  background: var(--fx-blade, var(--fx-cyan));
  box-shadow: 0 0 8px var(--fx-blade, var(--fx-cyan));
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 0.3s ease;
  pointer-events: none;
}

.fx-on nav a:hover::after,
.fx-on nav a:focus-visible::after {
  transform: scaleX(1);
}

/* ----- Голографический глитч заголовка h1 (400 мс) ----- */
.fx-on h1 {
  position: relative;
}

.fx-on h1::before,
.fx-on h1::after {
  content: attr(data-fx-text);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  opacity: 0;
  pointer-events: none;
}

.fx-on h1::before {
  color: var(--fx-cyan);
}

.fx-on h1::after {
  color: var(--fx-red);
}

.fx-on h1:hover::before,
.fx-on h1:hover::after {
  animation: fx-glitch 0.4s ease-out 1;
}

.fx-on h1:hover::after {
  animation-direction: reverse;
}

@keyframes fx-glitch {
  0% { opacity: 0.7; transform: translate(0, 0); clip-path: inset(0 0 60% 0); }
  25% { transform: translate(-3px, 1px); clip-path: inset(40% 0 20% 0); }
  50% { transform: translate(3px, -1px); clip-path: inset(10% 0 55% 0); }
  75% { transform: translate(-2px, 0); clip-path: inset(70% 0 5% 0); }
  100% { opacity: 0; transform: none; clip-path: inset(0 0 0 0); }
}

/* голограмма логотипа: один раз в ~25 с, 300 мс */
.fx-holo {
  animation: fx-holo 0.3s ease-out 1;
}

@keyframes fx-holo {
  0% { filter: none; }
  33% { filter: hue-rotate(160deg) saturate(2) drop-shadow(0 0 6px #5ad7ff); }
  66% { filter: hue-rotate(-40deg) brightness(1.3); }
  100% { filter: none; }
}

/* ----- Слова на клавиатуре: свечение страницы (4 с) ----- */
.fx-on.fx-tint-blue::after,
.fx-on.fx-tint-red::after {
  content: '';
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  pointer-events: none;
  animation: fx-tint 0.6s ease-out;
}

.fx-on.fx-tint-blue::after {
  background: radial-gradient(ellipse at center, rgba(90, 215, 255, 0) 40%, rgba(90, 215, 255, 0.28) 100%);
}

.fx-on.fx-tint-red::after {
  background: radial-gradient(ellipse at center, rgba(255, 77, 77, 0) 40%, rgba(255, 77, 77, 0.28) 100%);
}

@keyframes fx-tint {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ----- «дроид» / «r2d2»: катушка катится по низу экрана ----- */
.fx-coil {
  position: fixed;
  left: 0;
  bottom: 6px;
  width: 56px;
  z-index: 3;
  pointer-events: none;
  transform: translateX(-80px);
  animation: fx-coil 6s linear forwards;
}

.fx-coil svg {
  display: block;
  width: 100%;
  height: auto;
}

@keyframes fx-coil {
  from { transform: translateX(-80px); }
  to { transform: translateX(calc(100vw + 80px)); }
}

/* ----- «use the force»: карточки левитируют (5 с) ----- */
.fx-on .fx-float {
  animation: fx-float 2.4s ease-in-out infinite;
}

@keyframes fx-float {
  0%, 100% { transform: translateY(-6px); }
  50% { transform: translateY(6px); }
}

/* ----- Скринсейвер голонета (60 с бездействия) ----- */
.fx-saver {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(5, 6, 13, 0.94);
  overflow: hidden;
  pointer-events: none;
  animation: fx-saver-in 0.8s ease-out both;
}

@keyframes fx-saver-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fx-saver-stage {
  position: absolute;
  left: 0;
  top: 30%;
  width: min(520px, 60vw);
  animation: fx-fly 14s linear infinite;
}

.fx-saver-stage svg {
  display: block;
  width: 100%;
  height: auto;
}

@keyframes fx-fly {
  from { transform: translateX(-80vw); }
  to { transform: translateX(160vw); }
}

.fx-saver-cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12vh;
  text-align: center;
  color: var(--fx-cyan);
  font: 500 16px/1.3 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  letter-spacing: 0.02em;
}

/* ----- Кнопка «Эффекты» и меню ----- */
#fx-ui {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  font: 14px/1.2 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.fx-toggle {
  background: var(--fx-panel);
  color: var(--fx-gold);
  border: 1px solid var(--fx-cyan);
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(90, 215, 255, 0.25);
}

.fx-toggle:focus-visible,
.fx-switch:focus-visible {
  outline: 2px solid var(--fx-gold);
  outline-offset: 2px;
}

.fx-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 240px;
  padding: 10px;
  background: var(--fx-panel);
  border: 1px solid var(--fx-line);
  border-radius: 10px;
}

.fx-menu[hidden] {
  display: none;
}

.fx-switch {
  background: transparent;
  color: var(--fx-text);
  border: 1px solid var(--fx-line);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  text-align: left;
  cursor: pointer;
}

.fx-switch[aria-checked="true"] {
  border-color: var(--fx-cyan);
  color: var(--fx-cyan);
}

/* ----- Тост (тёмная палитра, снизу по центру, не над кнопкой) ----- */
.fx-toast {
  position: fixed;
  left: 50%;
  bottom: 72px;
  width: min(420px, calc(100vw - 32px));
  padding: 0.75rem 1rem;
  background: var(--fx-panel);
  color: var(--fx-text);
  border: 1px solid var(--fx-cyan);
  border-radius: 10px;
  box-shadow: 0 0 14px rgba(90, 215, 255, 0.35);
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.fx-toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (min-width: 600px) {
  .fx-toast {
    bottom: 20px;
    width: min(420px, calc(100vw - 280px));
  }
}

/* ----- prefers-reduced-motion: все анимации выключены ----- */
@media (prefers-reduced-motion: reduce) {
  .fx-layer,
  .fx-canvas,
  .fx-star,
  .fx-coil,
  .fx-saver {
    display: none !important;
  }

  .fx-eye-glow,
  .fx-engine,
  .fx-beam,
  .fx-holo,
  .fx-float,
  .fx-saver-stage,
  .fx-on h1::before,
  .fx-on h1::after,
  .fx-on nav a::after,
  .fx-on.fx-tint-blue::after,
  .fx-on.fx-tint-red::after,
  .fx-on .fx-float,
  .fx-toast,
  .fx-toggle,
  .fx-switch {
    animation: none !important;
    transition: none !important;
  }

  .fx-on h1::before,
  .fx-on h1::after {
    content: none;
  }
}
