/* perf tier tweaks */
:root {
  --perf-particles: 20;
  --perf-atomElectronCap: 32;
  --perf-sceneParticles: 150;
  --perf-dprCap: 2;
  --perf-motion-scale: 1;
}

html[data-perf-tier="very-low"] { --perf-motion-scale: 0; }
html[data-perf-tier="low"] { --perf-motion-scale: 0.6; }
html[data-perf-tier="medium"] { --perf-motion-scale: 0.85; }
html[data-perf-tier="high"] { --perf-motion-scale: 1; }
html[data-perf-tier="very-high"] { --perf-motion-scale: 1; }

html[data-perf-tier="very-low"] *,
html[data-perf-tier="very-low"] *::before,
html[data-perf-tier="very-low"] *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

html[data-perf-tier="very-low"] .perf-panel,
html[data-perf-tier="very-low"] .perf-panel *,
html[data-perf-tier="very-low"] .perf-toast,
/* perf toast */
html[data-perf-tier="very-low"] .perf-toast * {
  transition: opacity 0.12s linear !important;
}

html[data-perf-tier="low"] *,
html[data-perf-tier="low"] *::before,
html[data-perf-tier="low"] *::after {
  animation-duration: 0.001s !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.12s !important;
}

html[data-perf-tier="low"] .shell,
html[data-perf-tier="low"] .atom-orbit,
html[data-perf-tier="low"] .perf-panel,
html[data-perf-tier="low"] .perf-panel *,
html[data-perf-tier="low"] .perf-toast,
html[data-perf-tier="low"] .perf-toast * {
  animation-duration: revert !important;
  animation-iteration-count: revert !important;
  transition-duration: revert !important;
}

html[data-perf-blur="off"] * {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

html[data-perf-tier="very-low"] .animated-bg,
html[data-perf-tier="very-low"] .aurora,
html[data-perf-tier="very-low"] .bg-container,
html[data-perf-tier="very-low"] .grid-overlay,
html[data-perf-tier="very-low"] .particles,
html[data-perf-tier="very-low"] .particles-container,
html[data-perf-tier="very-low"] .mouse-glow,
html[data-perf-tier="low"] .animated-bg,
html[data-perf-tier="low"] .aurora,
html[data-perf-tier="low"] .grid-overlay,
html[data-perf-tier="low"] .particles,
html[data-perf-tier="low"] .particles-container,
/* mouse glow */
html[data-perf-tier="low"] .mouse-glow {
  display: none !important;
}

html[data-perf-tier="very-low"] .element-cell,
/* element cell */
html[data-perf-tier="low"] .element-cell {
  box-shadow: none !important;
}

html[data-perf-tier="very-low"] .element-cell::before,
html[data-perf-tier="very-low"] .element-cell::after,
html[data-perf-tier="low"] .element-cell::before,
html[data-perf-tier="low"] .element-cell::after {
  display: none !important;
}

html[data-perf-tier="very-low"] .element-cell:hover,
html[data-perf-tier="low"] .element-cell:hover {
  transform: none !important;
}

html[data-perf-motion="reduced"] * {
  animation-play-state: paused !important;
}

html[data-perf-motion="reduced"] .perf-panel *,
/* perf toast */
html[data-perf-motion="reduced"] .perf-toast * {
  animation-play-state: running !important;
}

/* perf fab */
.perf-fab {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(124, 92, 255, 0.45);
  background: rgba(16, 16, 28, 0.86);
  color: #9db8ff;
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* light theme */
body.light-theme .perf-fab,
html[data-theme="light"] .perf-fab {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(0, 102, 204, 0.35);
  color: #0b5cad;
  box-shadow: 0 2px 10px rgba(20, 30, 60, 0.14);
}

.perf-fab:hover {
  transform: scale(1.08);
  border-color: rgba(0, 212, 255, 0.75);
  color: #00d4ff;
}

.perf-fab svg { width: 22px; height: 22px; }

/* perf panel */
.perf-panel {
  position: fixed;
  bottom: 86px;
  right: 30px;
  width: min(310px, calc(100vw - 40px));
  background: rgba(14, 14, 26, 0.97);
  border: 1px solid rgba(124, 92, 255, 0.32);
  border-radius: 16px;
  padding: 16px;
  z-index: 9999;
  color: #e9e9ff;
  font-family: var(--font-family, "Vazirmatn", sans-serif);
  direction: rtl;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

body.light-theme .perf-panel,
html[data-theme="light"] .perf-panel {
  background: rgba(255, 255, 255, 0.985);
  border-color: rgba(0, 102, 204, 0.28);
  color: #16182b;
  box-shadow: 0 10px 34px rgba(20, 30, 60, 0.16);
}

.perf-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.perf-panel h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 4px;
  color: #00d4ff;
}

body.light-theme .perf-panel h3,
html[data-theme="light"] .perf-panel h3 { color: #0b5cad; }

.perf-panel .perf-sub {
  font-size: 0.72rem;
  opacity: 0.72;
  margin: 0 0 12px;
  line-height: 1.7;
}

/* perf options */
.perf-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* perf option */
.perf-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.035);
  color: inherit;
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  text-align: right;
  transition: border-color 0.18s ease, background 0.18s ease;
}

body.light-theme .perf-option,
html[data-theme="light"] .perf-option {
  border-color: rgba(16, 24, 48, 0.1);
  background: rgba(16, 24, 48, 0.03);
}

.perf-option:hover { border-color: rgba(0, 212, 255, 0.5); }

.perf-option[aria-checked="true"] {
  border-color: #7c5cff;
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.22), rgba(0, 212, 255, 0.14));
}

/* perf badge */
.perf-badge {
  font-size: 0.62rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0, 212, 255, 0.16);
  color: #00d4ff;
  white-space: nowrap;
}

body.light-theme .perf-badge,
html[data-theme="light"] .perf-badge {
  background: rgba(0, 102, 204, 0.12);
  color: #0b5cad;
}

/* perf meta */
.perf-meta {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.68rem;
  opacity: 0.6;
  line-height: 1.9;
}

body.light-theme .perf-meta,
html[data-theme="light"] .perf-meta { border-top-color: rgba(16, 24, 48, 0.1); }

/* perf toast */
.perf-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  max-width: min(430px, calc(100vw - 32px));
  background: rgba(14, 14, 26, 0.97);
  border: 1px solid rgba(255, 176, 32, 0.45);
  border-radius: 13px;
  padding: 12px 16px;
  color: #f2f2ff;
  font-family: var(--font-family, "Vazirmatn", sans-serif);
  font-size: 0.78rem;
  line-height: 1.85;
  direction: rtl;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

body.light-theme .perf-toast,
html[data-theme="light"] .perf-toast {
  background: rgba(255, 255, 255, 0.99);
  color: #16182b;
  box-shadow: 0 10px 30px rgba(20, 30, 60, 0.16);
}

.perf-toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.perf-toast-actions {
  display: flex;
  gap: 8px;
  margin-top: 9px;
}

.perf-toast button {
  flex: 1;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 0.74rem;
  cursor: pointer;
}

.perf-toast button.primary {
  border-color: transparent;
  background: linear-gradient(135deg, #7c5cff, #00d4ff);
  color: #fff;
}

/* mobile 768px */
@media (max-width: 768px) {
  .perf-fab { bottom: 20px; right: 20px; width: 42px; height: 42px; }
  .perf-panel { bottom: 72px; right: 16px; left: 16px; width: auto; }
  .perf-toast { bottom: 20px; }
}
