/* ══════════════════════════════════════════════════════════════════
   SGS VISUAL ENGINE — Ambient Effects, Particles, Glassmorphism
   Version: 2.0 — Mar 2026
   ──────────────────────────────────────────────────────────────────
   Add to any page: <link rel="stylesheet" href="/assets/css/sgs-visual.css">
   Then add <div id="sgs-ambient"></div> before page content.
   And <script src="/assets/js/sgs-visual.js"></script> before </body>
   ══════════════════════════════════════════════════════════════════ */

/* ── Ambient Background Layer ──────────────────────────────────── */
#sgs-ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

/* Multi-layer gradient depth — true neutral dark, no blue bias */
#sgs-ambient::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 15% 10%, rgba(30,30,30,0.5) 0%, transparent 55%),
    radial-gradient(ellipse 50% 40% at 85% 85%, rgba(26,26,26,0.4) 0%, transparent 50%),
    radial-gradient(ellipse 60% 45% at 50% 50%, rgba(20,20,20,0.35) 0%, transparent 65%),
    radial-gradient(ellipse 35% 25% at 20% 80%, rgba(220,220,220,0.025) 0%, transparent 50%);
}

/* Animated aurora sweep — single pearl wash, extremely subtle */
#sgs-ambient::after {
  content: '';
  position: absolute;
  inset: -50%;
  background: conic-gradient(
    from 0deg at 50% 50%,
    transparent 0deg,
    rgba(220,220,220,0.012) 45deg,
    transparent 90deg,
    transparent 180deg,
    rgba(200,200,200,0.01) 225deg,
    transparent 270deg,
    transparent 360deg
  );
  animation: auroraRotate 80s linear infinite;
}

@keyframes auroraRotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Grid lines overlay */
.sgs-grid-overlay {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(105deg, transparent 0%, transparent 49.5%, rgba(220,220,220,0.02) 50%, transparent 50.5%, transparent 100%),
    linear-gradient(165deg, transparent 0%, transparent 69.5%, rgba(220,220,220,0.015) 70%, transparent 70.5%, transparent 100%);
  background-size: 280px 280px, 420px 420px;
}

/* ── Floating Particles ────────────────────────────────────────── */
.sgs-particle {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
}

.sgs-particle--float {
  animation: particleFloat linear infinite;
  opacity: 0;
}

@keyframes particleFloat {
  0% {
    transform: translateY(10vh) translateX(0) scale(0.5);
    opacity: 0;
  }
  10% {
    opacity: 0.6;
  }
  50% {
    transform: translateY(-40vh) translateX(30px) scale(1);
    opacity: 0.35;
  }
  80% {
    opacity: 0.15;
  }
  100% {
    transform: translateY(-100vh) translateX(-20px) scale(0.3);
    opacity: 0;
  }
}

/* Sparkle cross effect */
.sgs-sparkle {
  position: fixed;
  pointer-events: none;
  z-index: 1;
  animation: sparklePulse ease-in-out infinite;
  opacity: 0;
}
.sgs-sparkle::before,
.sgs-sparkle::after {
  content: '';
  position: absolute;
  background: linear-gradient(135deg, rgba(220,220,220,0.85), rgba(200,200,200,0.5));
  border-radius: 50%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.sgs-sparkle::before {
  width: 1.5px;
  height: 14px;
}
.sgs-sparkle::after {
  width: 14px;
  height: 1.5px;
}

@keyframes sparklePulse {
  0%, 100% { opacity: 0; transform: scale(0.4) rotate(0deg); }
  40% { opacity: 0.75; transform: scale(1) rotate(12deg); }
  60% { opacity: 0.8; transform: scale(1.05) rotate(18deg); }
}

/* Sparkle dot */
.sgs-sparkle-dot {
  position: fixed;
  pointer-events: none;
  z-index: 1;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(220,220,220,0.7);
  box-shadow: 0 0 6px 2px rgba(220,220,220,0.4);
  animation: sparkleDotPulse ease-in-out infinite;
  opacity: 0;
}

@keyframes sparkleDotPulse {
  0%, 100% { opacity: 0; transform: scale(0.3); }
  50% { opacity: 0.6; transform: scale(1); }
}

/* ── Glassmorphism Cards ───────────────────────────────────────── */
.glass-card {
  background: rgba(14,14,14, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(224,224,224,0.1);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s, transform 0.3s, box-shadow 0.3s;
}
.glass-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(220,220,220,0.15), transparent);
}
.glass-card:hover {
  border-color: rgba(224,224,224,0.2);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 0 1px rgba(224,224,224,0.08);
}

/* Glass card glow variants — all unified to pearl, legacy class names kept for backward compat */
.glass-card--pink,
.glass-card--blue,
.glass-card--green,
.glass-card--purple,
.glass-card--gold { box-shadow: 0 4px 24px rgba(220,220,220,0.06), inset 0 0 40px rgba(220,220,220,0.025); }

/* ── Animated Glow Borders ─────────────────────────────────────── */
.glow-border {
  position: relative;
  overflow: hidden;
}
.glow-border::after {
  content: '';
  position: absolute;
  inset: -2px;
  background: conic-gradient(
    from var(--glow-angle, 0deg),
    transparent 0%,
    rgba(220,220,220,0.35) 15%,
    transparent 30%,
    rgba(220,220,220,0.15) 45%,
    transparent 60%,
    rgba(200,200,200,0.2) 75%,
    transparent 90%,
    transparent 100%
  );
  border-radius: inherit;
  z-index: -1;
  animation: glowSpin 10s linear infinite;
}

@keyframes glowSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ── Shimmer Effect ────────────────────────────────────────────── */
.shimmer {
  position: relative;
  overflow: hidden;
}
.shimmer::after {
  content: '';
  position: absolute;
  top: 0;
  left: -150%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(220,220,220,0.04),
    transparent
  );
  animation: shimmerSlide 6s ease-in-out infinite;
}

@keyframes shimmerSlide {
  0%, 100% { left: -150%; }
  50% { left: 150%; }
}

/* ── Vignette Overlay ──────────────────────────────────────────── */
.sgs-vignette {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse 100% 100% at 50% 50%,
    transparent 35%,
    rgba(8,8,8,0.55) 100%
  );
}

/* ── Animated Gradient Text ────────────────────────────────────── */
.gradient-text-animated {
  background: linear-gradient(
    135deg,
    #E0E0E0 0%,
    #ffffff 20%,
    #EEEEEE 40%,
    #ffffff 60%,
    #C8C8C8 80%,
    #EEEEEE 100%
  );
  background-size: 300% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 8s ease-in-out infinite;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* ── Pulse Ring Effect (for buttons, badges) ───────────────────── */
.pulse-ring {
  position: relative;
}
.pulse-ring::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 1px solid rgba(220,220,220,0.3);
  animation: pulseRing 3s ease-out infinite;
}

@keyframes pulseRing {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.15); opacity: 0; }
}

/* ── Page Content z-index ──────────────────────────────────────── */
.sgs-page-content {
  position: relative;
  z-index: 2;
}

/* ── Luxury Dividers ───────────────────────────────────────────── */
.lux-divider {
  width: 120px;
  height: 1px;
  margin: 0 auto;
  background: linear-gradient(90deg,
    transparent,
    rgba(220,220,220,0.45),
    transparent
  );
  position: relative;
}
.lux-divider::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 2px;
  background: rgba(220,220,220,0.7);
  border-radius: 50%;
}

/* ── Enhanced Hub Chapter Rows ─────────────────────────────────── */
.chapter-row-enhanced {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.2s, border-color 0.2s;
  position: relative;
}
.chapter-row-enhanced:hover {
  background: rgba(220,220,220,0.025);
  border-bottom-color: rgba(255,255,255,0.08);
}
.chapter-row-enhanced:hover::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(220,220,220,0.55);
}

/* ── Game Badge Pills (enhanced) ───────────────────────────────── */
.game-badge {
  padding: 5px 12px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-decoration: none;
  font-family: 'Montserrat', sans-serif;
  border-radius: 3px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.game-badge:hover {
  transform: translateY(-1px);
  filter: brightness(1.2);
}
.game-badge::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transition: left 0.4s;
}
.game-badge:hover::after {
  left: 150%;
}

/* Muted metallic badges — differentiated by tone, not hue */
.game-badge--board {
  background: rgba(220,220,220,0.06);
  border: 1px solid rgba(220,220,220,0.35);
  color: #EEEEEE;
}
.game-badge--chair {
  background: rgba(210,210,210,0.05);
  border: 1px solid rgba(210,210,210,0.3);
  color: #C8C8C8;
}
.game-badge--squares {
  background: rgba(180,180,180,0.05);
  border: 1px solid rgba(180,180,180,0.3);
  color: #B0B0B0;
}
.game-badge--test {
  background: rgba(160,160,160,0.08);
  border: 1px solid rgba(160,160,160,0.35);
  color: #A0A0A0;
}
.game-badge--worksheet {
  background: rgba(144,144,144,0.05);
  border: 1px solid rgba(144,144,144,0.3);
  color: #909090;
}
.game-badge--cards {
  background: rgba(208,208,208,0.05);
  border: 1px solid rgba(208,208,208,0.3);
  color: #D0D0D0;
}

/* ── Loading Shimmer for Content ───────────────────────────────── */
.loading-shimmer {
  background: linear-gradient(90deg,
    var(--bg-dark) 25%,
    rgba(220,220,220,0.06) 50%,
    var(--bg-dark) 75%
  );
  background-size: 200% 100%;
  animation: loadShimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
}

@keyframes loadShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .glass-card:hover {
    transform: none;
  }
  .sgs-sparkle, .sgs-sparkle-dot {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0s !important;
    transition-duration: 0s !important;
  }
}
/* ── Scroll Reveal Animations ─────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(32px);
  transition: opacity 0.7s cubic-bezier(0.4,0,0.2,1), transform 0.7s cubic-bezier(0.4,0,0.2,1);
}
.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

.reveal-left {
  opacity: 0;
  transform: translateX(-40px);
  transition: opacity 0.7s cubic-bezier(0.4,0,0.2,1), transform 0.7s cubic-bezier(0.4,0,0.2,1);
}
.reveal-left.revealed {
  opacity: 1;
  transform: translateX(0);
}

.reveal-right {
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.7s cubic-bezier(0.4,0,0.2,1), transform 0.7s cubic-bezier(0.4,0,0.2,1);
}
.reveal-right.revealed {
  opacity: 1;
  transform: translateX(0);
}

.reveal-scale {
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.7s cubic-bezier(0.4,0,0.2,1), transform 0.7s cubic-bezier(0.4,0,0.2,1);
}
.reveal-scale.revealed {
  opacity: 1;
  transform: scale(1);
}

/* ── Card Spotlight (cursor-following glow) ───────────────────── */
.card-spotlight {
  --spot-x: 50%;
  --spot-y: 50%;
  position: relative;
  overflow: hidden;
}
.card-spotlight::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  background: radial-gradient(
    350px circle at var(--spot-x) var(--spot-y),
    rgba(0,168,120,0.08) 0%,
    transparent 70%
  );
  z-index: 1;
}
.card-spotlight:hover::after {
  opacity: 1;
}

/* ── Tilt Card ────────────────────────────────────────────────── */
.tilt-card {
  transition: transform 0.15s ease-out, box-shadow 0.3s;
  will-change: transform;
}

/* ── Counter Animation ────────────────────────────────────────── */
[data-count] {
  transition: color 0.3s;
}
[data-count].counter-done {
  color: var(--accent, #00A878);
}

/* Visual Engine v3.0 */
