/* ==========================================================================
 * GamePanel V3 Flair Pack — γ Tower Vanguard
 *
 * Atmosphère "espace profond / station spatiale" — CSS pur, zéro IP tierce.
 * Activé par body.ui-v3.theme-direction-vanguard
 * Désactivé par body.v3-flair-disabled
 *
 * Z-index hiérarchie :
 *   -2  : fond d'écran étoiles (body::before)
 *   -1  : nébuleuse + orbites (body::after)
 *    0  : patrol map, décorations ambiantes
 *    1  : sphère lumineuse, orbites en layer
 *   10  : sidebar
 *   20  : topbar
 *   50  : content cards
 *  100  : modals
 *  200  : tooltips / toasts / class banner
 * ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  body.ui-v3.theme-direction-vanguard::before,
  body.ui-v3.theme-direction-vanguard::after,
  .vg-ghost-svg, .ghost-body, .ghost-fragments,
  .vg-ghost, .vg-patrol-map-bg,
  .vg-class-banner,
  .vg-orbit-ring, .vg-star-layer,
  .vg-nebula-blob { animation: none !important; transition: none !important; }
}

/* ============================================================
   FOND D'ÉCRAN IMMERSIF — position:fixed z-index:-2
   Deep space : étoiles CSS parallax 3 couches
   ============================================================ */

body.ui-v3.theme-direction-vanguard:not(.v3-flair-disabled)::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    /* Nébuleuse cyan diffuse haut-droite */
    radial-gradient(ellipse 55% 40% at 80% 20%, rgba(74, 158, 255, 0.07) 0%, transparent 65%),
    /* Nébuleuse or/ambre bas-gauche */
    radial-gradient(ellipse 45% 35% at 15% 75%, rgba(200, 154, 58, 0.06) 0%, transparent 60%),
    /* Cœur lumineux central très subtil */
    radial-gradient(ellipse 30% 20% at 50% 45%, rgba(74, 158, 255, 0.04) 0%, transparent 55%),
    /* Noir profond de base */
    linear-gradient(180deg, #03040a 0%, #060810 40%, #040608 100%);
  will-change: transform;
  transform: translateZ(0);
}

/* Champ d'étoiles CSS + mouvement parallax lent */
body.ui-v3.theme-direction-vanguard:not(.v3-flair-disabled)::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  /* Étoiles simulées via repeating-radial-gradient — 3 densités */
  background-image:
    /* Couche 1 : étoiles brillantes éparses */
    radial-gradient(1px 1px at 12% 8%,  rgba(245,240,232,0.55) 0%, transparent 100%),
    radial-gradient(1px 1px at 78% 14%, rgba(245,240,232,0.50) 0%, transparent 100%),
    radial-gradient(1px 1px at 34% 22%, rgba(93,213,252,0.45) 0%, transparent 100%),
    radial-gradient(1px 1px at 65% 31%, rgba(245,240,232,0.55) 0%, transparent 100%),
    radial-gradient(1px 1px at 89% 42%, rgba(200,154,58,0.40) 0%, transparent 100%),
    radial-gradient(1px 1px at 22% 55%, rgba(245,240,232,0.50) 0%, transparent 100%),
    radial-gradient(1px 1px at 55% 67%, rgba(93,213,252,0.40) 0%, transparent 100%),
    radial-gradient(1px 1px at 8%  78%, rgba(245,240,232,0.45) 0%, transparent 100%),
    radial-gradient(1px 1px at 92% 82%, rgba(245,240,232,0.55) 0%, transparent 100%),
    radial-gradient(1px 1px at 41% 91%, rgba(200,154,58,0.35) 0%, transparent 100%),
    /* Couche 2 : étoiles moyennes */
    radial-gradient(1.5px 1.5px at 20% 18%, rgba(245,240,232,0.40) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 72% 25%, rgba(93,213,252,0.35) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 46% 40%, rgba(245,240,232,0.38) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 83% 60%, rgba(245,240,232,0.42) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 15% 72%, rgba(200,154,58,0.30) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 60% 85%, rgba(245,240,232,0.38) 0%, transparent 100%),
    /* Couche 3 : étoiles distantes, très petites */
    radial-gradient(0.8px 0.8px at 5%  30%, rgba(245,240,232,0.28) 0%, transparent 100%),
    radial-gradient(0.8px 0.8px at 30% 48%, rgba(245,240,232,0.25) 0%, transparent 100%),
    radial-gradient(0.8px 0.8px at 50% 12%, rgba(93,213,252,0.22) 0%, transparent 100%),
    radial-gradient(0.8px 0.8px at 75% 72%, rgba(245,240,232,0.28) 0%, transparent 100%),
    radial-gradient(0.8px 0.8px at 95% 20%, rgba(245,240,232,0.25) 0%, transparent 100%);
  background-size: 100% 100%;
  animation: vgStarsDrift 80s linear infinite;
  will-change: background-position;
}

@keyframes vgStarsDrift {
  0%   { background-position: 0 0; }
  100% { background-position: -15px -20px; }
}

/* ============================================================
   VANGUARD INSIGNIA — sidebar logo (3 triangles, aucune IP)
   ============================================================ */

body.ui-v3.theme-direction-vanguard:not(.v3-flair-disabled) .sidebar-logo-mark {
  width: 36px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.vg-insignia-svg {
  width: 36px;
  height: 32px;
  filter: drop-shadow(0 0 5px rgba(200, 154, 58, 0.25));
  animation: vgInsigniaGlow 4s ease-in-out infinite;
}

@keyframes vgInsigniaGlow {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(200, 154, 58, 0.20)); }
  50%       { filter: drop-shadow(0 0 10px rgba(74, 158, 255, 0.35)) drop-shadow(0 0 5px rgba(200, 154, 58, 0.30)); }
}

/* ============================================================
   SPHÈRE LUMINEUSE ABSTRAITE — coin top-right (aucune IP)
   Remplace le "Traveler Sphere" protégé — sphère générique
   ============================================================ */

.vg-ambient-sphere {
  position: fixed;
  top: 60px;
  right: 20px;
  z-index: 1;
  pointer-events: none;
  width: 64px;
  height: 64px;
}

.vg-ambient-sphere-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 35%, rgba(200, 220, 255, 0.12) 0%, rgba(74, 158, 255, 0.06) 40%, transparent 70%),
    radial-gradient(circle at 60% 65%, rgba(200, 154, 58, 0.05) 0%, transparent 60%);
  border: 1px solid rgba(245, 240, 232, 0.10);
  box-shadow:
    0 0 16px rgba(74, 158, 255, 0.12),
    0 0 40px rgba(74, 158, 255, 0.06),
    inset 0 0 20px rgba(200, 220, 255, 0.05);
  animation: vgSpherePulse 5s ease-in-out infinite;
  will-change: box-shadow;
}

@keyframes vgSpherePulse {
  0%, 100% {
    box-shadow:
      0 0 16px rgba(74, 158, 255, 0.12),
      0 0 40px rgba(74, 158, 255, 0.06),
      inset 0 0 20px rgba(200, 220, 255, 0.05);
  }
  50% {
    box-shadow:
      0 0 28px rgba(74, 158, 255, 0.22),
      0 0 60px rgba(74, 158, 255, 0.10),
      inset 0 0 30px rgba(200, 220, 255, 0.10);
  }
}

/* Orbite autour de la sphère */
.vg-ambient-sphere-orbit {
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 1px solid rgba(74, 158, 255, 0.12);
  animation: vgSphereOrbit 8s linear infinite;
  will-change: transform;
}

.vg-ambient-sphere-orbit::after {
  content: '';
  position: absolute;
  top: 50%;
  left: -3px;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(200, 154, 58, 0.55);
  box-shadow: 0 0 6px rgba(200, 154, 58, 0.4);
}

@keyframes vgSphereOrbit {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ============================================================
   ORBITES CIRCULAIRES EN BACKGROUND
   Décoration ambiante — pas de logo
   ============================================================ */

.vg-orbit-rings-container {
  position: fixed;
  bottom: 5%;
  left: max(260px, 3%);
  z-index: 0;
  pointer-events: none;
  width: 180px;
  height: 180px;
}

.vg-orbit-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid transparent;
  will-change: transform;
  animation: vgOrbitSpin 30s linear infinite;
}

.vg-orbit-ring:nth-child(1) {
  inset: 10%;
  border-color: rgba(74, 158, 255, 0.08);
  animation-duration: 30s;
}

.vg-orbit-ring:nth-child(2) {
  inset: 25%;
  border-color: rgba(200, 154, 58, 0.10);
  animation-duration: 20s;
  animation-direction: reverse;
}

.vg-orbit-ring:nth-child(3) {
  inset: 40%;
  border-color: rgba(74, 158, 255, 0.12);
  animation-duration: 12s;
}

.vg-orbit-ring:nth-child(1)::after,
.vg-orbit-ring:nth-child(2)::after,
.vg-orbit-ring:nth-child(3)::after {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 3px; height: 3px;
  border-radius: 50%;
}

.vg-orbit-ring:nth-child(1)::after { background: rgba(74, 158, 255, 0.45); }
.vg-orbit-ring:nth-child(2)::after { background: rgba(200, 154, 58, 0.50); }
.vg-orbit-ring:nth-child(3)::after { background: rgba(74, 158, 255, 0.60); }

@keyframes vgOrbitSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ============================================================
   GHOST COMPANION — fixed bas-droite (SVG abstrait, aucune IP)
   ============================================================ */

#vg-ghost {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  width: 52px;
  height: 52px;
  cursor: pointer;
  user-select: none;
}

.vg-ghost-svg {
  width: 52px;
  height: 52px;
  filter: drop-shadow(0 0 8px rgba(74, 158, 255, 0.25));
}

/* Corps du Ghost — rotation lente */
.ghost-body {
  animation: ghostBodySpin 12s linear infinite;
  transform-origin: 24px 24px;
  will-change: transform;
}

@keyframes ghostBodySpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Fragments — flottement indépendant */
.ghost-fragments {
  animation: ghostFragmentsFloat 6s ease-in-out infinite;
}

@keyframes ghostFragmentsFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  33%       { transform: translateY(-3px) rotate(5deg); }
  66%       { transform: translateY(2px) rotate(-3deg); }
}

/* Hover : glow renforcé */
#vg-ghost:hover .vg-ghost-svg {
  filter: drop-shadow(0 0 16px rgba(74, 158, 255, 0.60)) drop-shadow(0 0 6px rgba(200, 154, 58, 0.30));
  transition: filter 0.3s ease;
}

/* Pulsation idle */
#vg-ghost {
  animation: ghostIdlePulse 5s ease-in-out infinite;
}

@keyframes ghostIdlePulse {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-4px); }
}

/* ============================================================
   VANGUARD TOAST
   ============================================================ */

.vg-toast {
  position: fixed;
  bottom: 88px;
  right: 24px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(17, 21, 31, 0.95);
  border: 1px solid rgba(74, 158, 255, 0.30);
  border-left: 3px solid rgba(74, 158, 255, 0.70);
  border-radius: 4px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 12px;
  color: rgba(245, 240, 232, 0.90);
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
  max-width: 260px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.vg-toast.show {
  opacity: 1;
  transform: translateX(0);
}

.vg-toast.hide {
  opacity: 0;
  transform: translateX(12px);
}

.vg-toast-icon {
  color: rgba(74, 158, 255, 0.80);
  font-size: 10px;
  flex-shrink: 0;
}

.vg-toast.vg-toast-match {
  border-left-color: rgba(16, 201, 124, 0.70);
  color: rgba(140, 240, 180, 0.90);
}

.vg-toast.vg-toast-match .vg-toast-icon {
  color: rgba(16, 201, 124, 0.80);
}

/* ============================================================
   LIGHT / DARK AMBIENT CYCLE
   ============================================================ */

body.ui-v3.theme-direction-vanguard.vg-ambient-light:not(.v3-flair-disabled) {
  --bg-0: #0c0f1a;
  --bg-1: #13182a;
  --bg-2: #1a2036;
  --border: rgba(74, 158, 255, 0.18);
}

body.ui-v3.theme-direction-vanguard.vg-ambient-dark:not(.v3-flair-disabled) {
  --bg-0: #080a10;
  --bg-1: #0d101a;
  --bg-2: #131722;
  --primary: #7b6fcf;
  --primary-glow: rgba(123, 111, 207, 0.40);
  --secondary: #c8943a;
}

/* ============================================================
   POWER LEVEL — topbar widget
   ============================================================ */

.vg-power-level {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 100%;
  border-right: 1px solid rgba(200, 154, 58, 0.12);
  border-left: 1px solid rgba(200, 154, 58, 0.12);
  flex-shrink: 0;
}

.vg-power-icon {
  font-size: 14px;
  color: rgba(200, 154, 58, 0.70);
  animation: vgPowerPulse 4s ease-in-out infinite;
}

@keyframes vgPowerPulse {
  0%, 100% { color: rgba(200, 154, 58, 0.65); filter: none; }
  50%       { color: rgba(200, 154, 58, 1); filter: drop-shadow(0 0 4px rgba(200, 154, 58, 0.5)); }
}

.vg-power-text {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: rgba(200, 154, 58, 0.65);
  white-space: nowrap;
}

.vg-power-text span {
  color: rgba(245, 240, 232, 0.90);
  font-size: 12px;
  margin-left: 2px;
}

/* ============================================================
   CLASS BANNER — Titan / Warlock / Hunter (generique, pas de logo Bungie)
   ============================================================ */

#vg-class-banner {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(8, 10, 16, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.4s ease;
}

#vg-class-banner.show { opacity: 1; }

#vg-class-banner.vg-class-fade {
  opacity: 0;
  transition: opacity 0.5s ease;
}

.vg-class-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  max-width: 540px;
  width: 92%;
  padding: 40px 32px;
  background: var(--bg-1, #11151f);
  border: 1px solid rgba(200, 154, 58, 0.25);
  border-radius: 10px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(74, 158, 255, 0.08);
  position: relative;
}

.vg-class-inner::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, rgba(74, 158, 255, 0.8), rgba(200, 154, 58, 0.8));
  border-radius: 10px 10px 0 0;
}

.vg-class-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.vg-class-insignia .vg-insignia-svg {
  width: 56px;
  height: 48px;
}

.vg-class-title {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: rgba(245, 240, 232, 0.95);
  margin: 0;
  text-transform: uppercase;
}

.vg-class-sub {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: rgba(200, 154, 58, 0.55);
  margin: 0;
  text-transform: uppercase;
}

.vg-class-options {
  display: flex;
  gap: 16px;
  width: 100%;
}

.vg-class-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  background: rgba(245, 240, 232, 0.02);
  border: 1px solid rgba(200, 154, 58, 0.15);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.vg-class-btn:hover {
  transform: translateY(-4px);
  border-color: rgba(200, 154, 58, 0.40);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
}

.vg-class-btn:focus-visible {
  outline: 2px solid rgba(74, 158, 255, 0.60);
  outline-offset: 2px;
}

.vg-class-triangle {
  font-size: 28px;
  line-height: 1;
}

.vg-triangle-titan   { color: rgba(210, 58, 58, 0.90); }
.vg-triangle-warlock { color: rgba(200, 154, 58, 0.90); }
.vg-triangle-hunter  { color: rgba(245, 240, 232, 0.90); }

.vg-class-btn.vg-titan:hover {
  background: rgba(210, 58, 58, 0.06);
  border-color: rgba(210, 58, 58, 0.40);
}

.vg-class-btn.vg-warlock:hover {
  background: rgba(200, 154, 58, 0.06);
  border-color: rgba(200, 154, 58, 0.40);
}

.vg-class-btn.vg-hunter:hover {
  background: rgba(74, 158, 255, 0.05);
  border-color: rgba(74, 158, 255, 0.35);
}

.vg-class-name {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(245, 240, 232, 0.90);
}

.vg-class-desc {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 10px;
  color: rgba(155, 163, 180, 0.65);
  text-align: center;
  letter-spacing: 0.04em;
  line-height: 1.4;
}

.vg-class-skip {
  background: none;
  border: none;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 0.10em;
  color: rgba(155, 163, 180, 0.40);
  cursor: pointer;
  text-transform: uppercase;
  transition: color 0.2s ease;
}

.vg-class-skip:hover { color: rgba(155, 163, 180, 0.70); }

body[data-guardian-class="titan"] .nav-item.active {
  border-left-color: rgba(210, 58, 58, 0.75) !important;
  background: rgba(210, 58, 58, 0.08) !important;
}

body[data-guardian-class="warlock"] .nav-item.active {
  border-left-color: rgba(200, 154, 58, 0.75) !important;
  background: rgba(200, 154, 58, 0.08) !important;
}

/* ============================================================
   PATROL MAP BACKGROUND
   ============================================================ */

.vg-patrol-map-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.vg-patrol-svg {
  position: absolute;
  inset: 0;
  opacity: 0.75;
}

body.ui-v3.theme-direction-vanguard:not(.v3-flair-disabled) #dashboard-cards > *:not(.vg-patrol-map-bg) {
  position: relative;
  z-index: 1;
}

/* ============================================================
   VANGUARD FOOTER WATERMARK
   ============================================================ */

.vg-tower-footer {
  position: relative;
  padding: 8px 24px;
  text-align: center;
  pointer-events: none;
}

.vg-tower-watermark {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 9px;
  letter-spacing: 0.16em;
  color: rgba(200, 154, 58, 0.15);
  text-transform: uppercase;
  user-select: none;
}

/* ============================================================
   FLAIR TOGGLE — section Profil
   ============================================================ */

.flair-toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-top: 1px solid var(--border-subtle, rgba(200,154,58,0.07));
  gap: 16px;
}

.flair-toggle-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-0, #f5f0e8);
  font-weight: 500;
}

.flair-toggle-icon {
  display: inline;
  margin-right: 6px;
  color: var(--secondary, #c89a3a);
}

.flair-toggle-sub {
  font-size: 11px;
  color: var(--text-2, #5a647a);
  font-weight: 400;
}

.flair-toggle-btn {
  position: relative;
  width: 44px;
  height: 24px;
  background: rgba(200, 154, 58, 0.15);
  border: 1px solid rgba(200, 154, 58, 0.30);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease;
  flex-shrink: 0;
}

.flair-toggle-btn.active,
.flair-toggle-btn[aria-checked="true"] {
  background: rgba(200, 154, 58, 0.35);
  border-color: rgba(200, 154, 58, 0.60);
}

.flair-toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: var(--text-1, #9ba3b4);
  border-radius: 50%;
  transition: transform 0.25s ease, background 0.25s ease;
}

.flair-toggle-btn[aria-checked="true"] .flair-toggle-thumb {
  transform: translateX(20px);
  background: rgba(200, 154, 58, 0.90);
}

.flair-toggle-btn:focus-visible {
  outline: 2px solid rgba(74, 158, 255, 0.60);
  outline-offset: 2px;
}

/* ============================================================
   Masque global si flair désactivé
   ============================================================ */

body.v3-flair-disabled .vg-insignia-svg,
body.v3-flair-disabled #vg-ghost,
body.v3-flair-disabled .vg-toast,
body.v3-flair-disabled .vg-power-level,
body.v3-flair-disabled #vg-class-banner,
body.v3-flair-disabled .vg-patrol-map-bg,
body.v3-flair-disabled .vg-tower-footer,
body.v3-flair-disabled .vg-tower-watermark,
body.v3-flair-disabled .vg-ambient-sphere,
body.v3-flair-disabled .vg-orbit-rings-container {
  display: none !important;
}

/* Masque les pseudo-éléments fond quand flair désactivé */
body.ui-v3.theme-direction-vanguard.v3-flair-disabled::before,
body.ui-v3.theme-direction-vanguard.v3-flair-disabled::after {
  display: none;
}
