:root {
  --bg-base: #05050f;
  --violet: #7c3aed;
  --cyan: #06b6d4;
  --magenta: #ec4899;
  --text: #eef0ff;
  --muted: rgba(238, 240, 255, 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-base);
}

body {
  font-family: 'Space Grotesk', sans-serif;
  color: var(--text);
}

/* ---------------- Scene ---------------- */
.scene {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 30% 20%, #0e0a2a 0%, transparent 55%),
    radial-gradient(ellipse at 75% 80%, #0a1a2e 0%, transparent 55%),
    var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------------- Aurora blobs ---------------- */
.aurora {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  mix-blend-mode: screen;
  opacity: 0.55;
  will-change: transform;
  pointer-events: none;
}
.aurora-1 {
  width: 55vmax; height: 55vmax;
  top: -15vmax; left: -10vmax;
  background: radial-gradient(circle, var(--violet), transparent 70%);
  animation: drift1 32s ease-in-out infinite;
}
.aurora-2 {
  width: 50vmax; height: 50vmax;
  bottom: -18vmax; right: -12vmax;
  background: radial-gradient(circle, var(--cyan), transparent 70%);
  animation: drift2 40s ease-in-out infinite;
}
.aurora-3 {
  width: 42vmax; height: 42vmax;
  top: 30%; left: 55%;
  background: radial-gradient(circle, var(--magenta), transparent 70%);
  animation: drift3 28s ease-in-out infinite;
  opacity: 0.4;
}

@keyframes drift1 {
  0%,100% { transform: translate(0,0) scale(1); }
  33% { transform: translate(15vmax, 8vmax) scale(1.15); }
  66% { transform: translate(6vmax, 18vmax) scale(0.95); }
}
@keyframes drift2 {
  0%,100% { transform: translate(0,0) scale(1); }
  50% { transform: translate(-14vmax, -10vmax) scale(1.2); }
}
@keyframes drift3 {
  0%,100% { transform: translate(0,0) scale(1); }
  40% { transform: translate(-18vmax, 6vmax) scale(1.1); }
  70% { transform: translate(-8vmax, -12vmax) scale(0.9); }
}

/* ---------------- Center glow ---------------- */
.center-glow {
  position: absolute;
  width: 70vmax; height: 70vmax;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(124,58,237,0.18) 0%, transparent 60%);
  pointer-events: none;
}

/* ---------------- Grid ---------------- */
.grid {
  position: absolute;
  inset: -2px;
  background-image:
    linear-gradient(rgba(255,255,255,0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.045) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
  animation: gridScroll 22s linear infinite;
  pointer-events: none;
}
@keyframes gridScroll {
  from { background-position: 0 0; }
  to { background-position: 48px 48px; }
}

/* ---------------- Stars ---------------- */
#stars { position: absolute; inset: 0; pointer-events: none; }
.star {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  opacity: 0.7;
  animation-name: twinkle;
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
}
@keyframes twinkle {
  0%, 100% { opacity: 0.15; transform: scale(0.8); }
  50% { opacity: 0.95; transform: scale(1.3); }
}

/* ---------------- Waves ---------------- */
.wave {
  position: absolute;
  left: -50%;
  width: 200%;
  height: 40vh;
  bottom: 0;
  border-radius: 45%;
  mix-blend-mode: screen;
  pointer-events: none;
}
.wave-1 {
  background: radial-gradient(ellipse at center bottom, rgba(6,182,212,0.14), transparent 65%);
  animation: waveMove 26s linear infinite;
}
.wave-2 {
  background: radial-gradient(ellipse at center bottom, rgba(124,58,237,0.12), transparent 65%);
  height: 32vh;
  animation: waveMove 34s linear infinite reverse;
}
@keyframes waveMove {
  from { transform: translateX(0) rotate(0deg); }
  to { transform: translateX(12%) rotate(2deg); }
}

/* ---------------- Vignette ---------------- */
.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,0.6) 100%);
  pointer-events: none;
}

/* ---------------- Noise ---------------- */
.noise {
  position: absolute;
  inset: 0;
  opacity: 0.05;
  mix-blend-mode: overlay;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------------- Mouse light ---------------- */
.mouse-light {
  position: absolute;
  top: 0; left: 0;
  width: 420px; height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(140,120,255,0.16) 0%, transparent 65%);
  pointer-events: none;
  mix-blend-mode: screen;
  will-change: transform;
}

/* ---------------- Code helper card ---------------- */
.code-helper {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 44px 40px 36px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.045);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  max-width: 90vw;
  animation: cardIn 1s cubic-bezier(0.2, 0.8, 0.2, 1) both, floatCard 7s ease-in-out infinite 1s;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(28px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes floatCard {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.code-helper h1 {
  font-family: 'Vazirmatn', sans-serif;
  direction: rtl;
  font-weight: 600;
  font-size: clamp(1.5rem, 4vw, 2.4rem);
  letter-spacing: 0.5px;
  background: linear-gradient(120deg, #fff, #c4b5fd 40%, #67e8f9 80%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.subtitle {
  font-family: 'Vazirmatn', sans-serif;
  direction: rtl;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.code-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.code-button {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 108px;
  min-height: 108px;
  padding: 18px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 1px;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1),
              box-shadow 0.25s, border-color 0.25s;
}
.code-button:hover, .code-button:focus-visible {
  transform: translateY(-6px);
  outline: none;
}
.code-button:active { transform: translateY(-2px) scale(0.98); }

.button-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px; height: 46px;
  border-radius: 14px;
  font-family: 'Space Grotesk', monospace;
  font-weight: 700;
  font-size: 1.05rem;
}

.html-button .button-icon { background: linear-gradient(135deg, #f97316, #e34c26); color: #fff; }
.html-button:hover { border-color: rgba(227,76,38,0.6); box-shadow: 0 12px 34px rgba(227,76,38,0.35); }

.css-button .button-icon { background: linear-gradient(135deg, #3b82f6, #264de4); color: #fff; }
.css-button:hover { border-color: rgba(38,77,228,0.6); box-shadow: 0 12px 34px rgba(38,77,228,0.35); }

.js-button .button-icon { background: linear-gradient(135deg, #fde047, #f0db4f); color: #1a1a1a; }
.js-button:hover { border-color: rgba(240,219,79,0.6); box-shadow: 0 12px 34px rgba(240,219,79,0.3); }

.whisper {
  margin-top: 24px;
  font-size: 0.72rem;
  color: rgba(238,240,255,0.35);
  letter-spacing: 1px;
}

/* Ripple */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  transform: scale(0);
  animation: rippleAnim 0.6s ease-out;
  pointer-events: none;
}
@keyframes rippleAnim {
  to { transform: scale(2.6); opacity: 0; }
}

/* ---------------- Snippet panel ---------------- */
.snippet-panel {
  position: absolute;
  z-index: 30;
  bottom: 24px; left: 50%;
  transform: translate(-50%, 40px);
  width: min(560px, 92vw);
  max-height: 45vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: rgba(12, 12, 26, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s cubic-bezier(0.2,0.8,0.2,1);
}
.snippet-panel.open {
  opacity: 1;
  transform: translate(-50%, 0);
}
.snippet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.snippet-title {
  font-family: 'Vazirmatn', sans-serif;
  direction: rtl;
  font-size: 0.85rem;
  color: #c4b5fd;
}
.snippet-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s;
}
.snippet-close:hover { color: #fff; }

.snippet-code {
  margin: 0;
  padding: 16px;
  overflow: auto;
  direction: ltr;
  text-align: left;
}
.snippet-code code {
  font-family: 'Space Grotesk', 'Courier New', monospace;
  font-size: 0.8rem;
  line-height: 1.55;
  color: #a5f3fc;
  white-space: pre;
}

.snippet-copy {
  font-family: 'Vazirmatn', sans-serif;
  margin: 0 16px 16px;
  padding: 11px;
  border: none;
  border-radius: 12px;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  transition: transform 0.2s, filter 0.2s;
}
.snippet-copy:hover { filter: brightness(1.12); transform: translateY(-2px); }
.snippet-copy:active { transform: translateY(0); }

/* ---------------- Toast ---------------- */
.toast {
  position: absolute;
  z-index: 40;
  top: 28px; left: 50%;
  transform: translate(-50%, -120%);
  padding: 12px 26px;
  border-radius: 999px;
  font-family: 'Vazirmatn', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  color: #05050f;
  background: linear-gradient(135deg, #67e8f9, #a5f3fc);
  box-shadow: 0 10px 30px rgba(103,232,249,0.4);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.2,0.8,0.2,1), opacity 0.4s;
}
.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

/* ---------------- Footer ---------------- */
.scene-footer {
  position: absolute;
  z-index: 20;
  bottom: 12px; left: 0; right: 0;
  text-align: center;
}
.scene-footer a {
  font-size: 0.7rem;
  color: rgba(238,240,255,0.3);
  text-decoration: none;
  letter-spacing: 0.5px;
  transition: color 0.2s;
}
.scene-footer a:hover { color: rgba(238,240,255,0.7); }

/* ---------------- Mobile tweaks ---------------- */
.is-mobile .aurora { filter: blur(60px); }
.is-mobile .mouse-light { display: none; }
.is-mobile .code-helper { padding: 34px 24px 28px; }
.is-mobile .code-buttons { gap: 12px; }
.is-mobile .code-button { min-width: 88px; min-height: 92px; padding: 14px 10px; }
.is-mobile .button-icon { width: 40px; height: 40px; font-size: 0.95rem; }

@media (max-width: 420px) {
  .code-buttons { flex-direction: column; align-items: stretch; }
  .code-button { flex-direction: row; justify-content: center; min-height: 60px; }
}

/* ---------------- Reduced motion ---------------- */
.reduced-motion .aurora,
.reduced-motion .grid,
.reduced-motion .wave,
.reduced-motion .code-helper,
.reduced-motion .star {
  animation: none !important;
}