/* ── Design System ────────────────────────────────────── */
:root {
  --void: #050508;
  --text-primary: #e0e0ec;
  --text-secondary: #7a7a9a;
  --text-dim: #44445a;

  --guild-core: #7c6aff;
  --guild-glow: rgba(124, 106, 255, 0.35);
  --guild-atmo: rgba(124, 106, 255, 0.12);

  --dog-core: #ff6eb4;
  --dog-glow: rgba(255, 110, 180, 0.35);
  --dog-atmo: rgba(255, 110, 180, 0.12);

  --time-core: #00d4ff;
  --time-glow: rgba(0, 212, 255, 0.35);
  --time-atmo: rgba(0, 212, 255, 0.12);

  --accent-gradient: linear-gradient(135deg, #7c6aff 0%, #00d4ff 50%, #ff6eb4 100%);
  --star-color: 220, 220, 255;
  --nebula1: rgba(124, 106, 255, 0.02);
  --nebula2: rgba(0, 212, 255, 0.012);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── Theme: Ocean ────────────────────────────────────── */
[data-theme="ocean"] {
  --void: #020c1b;
  --text-primary: #ccd6f6;
  --text-secondary: #6a8eaa;
  --text-dim: #2a4a5a;

  --guild-core: #5e9eff;
  --guild-glow: rgba(94, 158, 255, 0.35);
  --guild-atmo: rgba(94, 158, 255, 0.12);

  --dog-core: #ff7eb3;
  --dog-glow: rgba(255, 126, 179, 0.35);
  --dog-atmo: rgba(255, 126, 179, 0.12);

  --time-core: #64ffda;
  --time-glow: rgba(100, 255, 218, 0.35);
  --time-atmo: rgba(100, 255, 218, 0.12);

  --accent-gradient: linear-gradient(135deg, #5e9eff 0%, #64ffda 50%, #ff7eb3 100%);
  --star-color: 180, 210, 255;
  --nebula1: rgba(94, 158, 255, 0.025);
  --nebula2: rgba(100, 255, 218, 0.015);
}

[data-theme="ocean"] [data-app="guild"] .planet-body {
  background: radial-gradient(circle at 38% 38%, #8ab8ff, var(--guild-core) 60%, #2a5cb0);
}
[data-theme="ocean"] [data-app="dog"] .planet-body {
  background: radial-gradient(circle at 38% 38%, #ffadd0, var(--dog-core) 60%, #a03060);
}
[data-theme="ocean"] [data-app="time"] .planet-body {
  background: radial-gradient(circle at 38% 38%, #a0ffe8, var(--time-core) 60%, #00806a);
}
[data-theme="ocean"] [data-app="guild"] .planet-name { color: #8ab8ff; }
[data-theme="ocean"] [data-app="dog"] .planet-name { color: #ffadd0; }
[data-theme="ocean"] [data-app="time"] .planet-name { color: #a0ffe8; }

/* ── Theme: Forest ───────────────────────────────────── */
[data-theme="forest"] {
  --void: #0a0f08;
  --text-primary: #d4e0c8;
  --text-secondary: #7a9a6a;
  --text-dim: #3a4a30;

  --guild-core: #b0a0ff;
  --guild-glow: rgba(176, 160, 255, 0.35);
  --guild-atmo: rgba(176, 160, 255, 0.12);

  --dog-core: #ff9a76;
  --dog-glow: rgba(255, 154, 118, 0.35);
  --dog-atmo: rgba(255, 154, 118, 0.12);

  --time-core: #5adc8a;
  --time-glow: rgba(90, 220, 138, 0.35);
  --time-atmo: rgba(90, 220, 138, 0.12);

  --accent-gradient: linear-gradient(135deg, #b0a0ff 0%, #5adc8a 50%, #ff9a76 100%);
  --star-color: 200, 230, 190;
  --nebula1: rgba(90, 220, 138, 0.02);
  --nebula2: rgba(176, 160, 255, 0.012);
}

[data-theme="forest"] [data-app="guild"] .planet-body {
  background: radial-gradient(circle at 38% 38%, #c8bbff, var(--guild-core) 60%, #6050a0);
}
[data-theme="forest"] [data-app="dog"] .planet-body {
  background: radial-gradient(circle at 38% 38%, #ffbfa0, var(--dog-core) 60%, #a05030);
}
[data-theme="forest"] [data-app="time"] .planet-body {
  background: radial-gradient(circle at 38% 38%, #90f0b0, var(--time-core) 60%, #206040);
}
[data-theme="forest"] [data-app="guild"] .planet-name { color: #c8bbff; }
[data-theme="forest"] [data-app="dog"] .planet-name { color: #ffbfa0; }
[data-theme="forest"] [data-app="time"] .planet-name { color: #90f0b0; }

/* ── Reset ────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-primary);
  background: var(--void);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Canvas Background ────────────────────────────────── */
#starfield {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ── Vignette overlay ─────────────────────────────────── */
.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 30%, var(--void) 100%);
}

/* ── Scene ────────────────────────────────────────────── */
.scene {
  position: relative;
  z-index: 2;
}

/* ── Gateway (Hero) ───────────────────────────────────── */
.gateway {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  text-align: center;
  padding: 2rem 1.5rem;
  position: relative;
  will-change: opacity, transform;
}

.gateway-title {
  font-size: clamp(2.5rem, 8vw, 6rem);
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 1.5rem;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeIn 1.2s var(--ease-out) 0.3s both;
}

.title-line {
  display: block;
}

.title-accent {
  font-weight: 600;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.gateway-subtitle {
  font-size: clamp(0.95rem, 2vw, 1.15rem);
  color: var(--text-secondary);
  font-weight: 300;
  max-width: 420px;
  line-height: 1.7;
  letter-spacing: 0.01em;
  opacity: 0;
  transform: translateY(16px);
  animation: fadeIn 1.2s var(--ease-out) 0.6s both;
}

/* ── Scroll hint ──────────────────────────────────────── */
.scroll-hint {
  position: absolute;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  opacity: 0;
  transition: opacity 0.8s var(--ease);
}

.scroll-hint.visible {
  opacity: 1;
}

.scroll-hint-icon {
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: scrollDot 2.4s ease-in-out infinite;
}

@keyframes scrollDot {
  0%, 100% { transform: translateY(-8px); opacity: 0.2; }
  50% { transform: translateY(8px); opacity: 0.8; }
}

/* ── Constellation (Planets Section) ──────────────────── */
.constellation {
  position: relative;
  min-height: 100vh;
  padding: 6rem 2rem 8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8rem;
}

/* ── Planet ────────────────────────────────────────────── */
.planet {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  position: relative;
  opacity: 0;
  transform: translateY(60px) scale(0.9);
  transition:
    opacity 0.8s var(--ease-out),
    transform 0.8s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.planet.revealed {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.planet:nth-child(2).revealed { transition-delay: 0.15s; }
.planet:nth-child(3).revealed { transition-delay: 0.3s; }

/* Desktop constellation offsets */
@media (min-width: 769px) {
  .constellation {
    gap: 10rem;
    padding: 8rem 2rem 12rem;
  }

  .planet:nth-child(1) { align-self: flex-start; margin-left: 12%; }
  .planet:nth-child(2) { align-self: flex-end; margin-right: 10%; }
  .planet:nth-child(3) { align-self: flex-start; margin-left: 22%; }
}

/* ── Planet Sphere ────────────────────────────────────── */
.planet-sphere {
  position: relative;
  width: 140px;
  height: 140px;
  margin-bottom: 1.5rem;
  transition: transform 0.6s var(--ease-out);
}

.planet:hover .planet-sphere,
.planet:focus-visible .planet-sphere,
.planet.active .planet-sphere {
  transform: scale(1.08);
}

.planet-body {
  position: absolute;
  inset: 20%;
  border-radius: 50%;
  transition: box-shadow 0.5s var(--ease);
}

.planet-atmosphere {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  transition: opacity 0.5s var(--ease);
  opacity: 0.6;
}

.planet-highlight {
  position: absolute;
  top: 22%;
  left: 28%;
  width: 30%;
  height: 20%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  filter: blur(6px);
  pointer-events: none;
}

/* Planet rotation */
.planet-body {
  animation: planetRotate 30s linear infinite;
}

@keyframes planetRotate {
  to { transform: rotate(360deg); }
}

/* ── Guild planet ─────────────────────────────────────── */
[data-app="guild"] .planet-body {
  background: radial-gradient(circle at 38% 38%, #a78bfa, var(--guild-core) 60%, #4c3db0);
  box-shadow: 0 0 30px var(--guild-glow), 0 0 60px rgba(124, 106, 255, 0.1);
}
[data-app="guild"] .planet-atmosphere {
  background: radial-gradient(circle, var(--guild-atmo) 40%, transparent 70%);
}
[data-app="guild"]:hover .planet-body,
[data-app="guild"]:focus-visible .planet-body,
[data-app="guild"].active .planet-body {
  box-shadow: 0 0 40px var(--guild-glow), 0 0 80px rgba(124, 106, 255, 0.15);
}

/* ── Dog planet ───────────────────────────────────────── */
[data-app="dog"] .planet-body {
  background: radial-gradient(circle at 38% 38%, #ffa0d0, var(--dog-core) 60%, #b0406a);
  box-shadow: 0 0 30px var(--dog-glow), 0 0 60px rgba(255, 110, 180, 0.1);
}
[data-app="dog"] .planet-atmosphere {
  background: radial-gradient(circle, var(--dog-atmo) 40%, transparent 70%);
}
[data-app="dog"]:hover .planet-body,
[data-app="dog"]:focus-visible .planet-body,
[data-app="dog"].active .planet-body {
  box-shadow: 0 0 40px var(--dog-glow), 0 0 80px rgba(255, 110, 180, 0.15);
}

/* ── Time planet ──────────────────────────────────────── */
[data-app="time"] .planet-body {
  background: radial-gradient(circle at 38% 38%, #66e8ff, var(--time-core) 60%, #006a80);
  box-shadow: 0 0 30px var(--time-glow), 0 0 60px rgba(0, 212, 255, 0.1);
}
[data-app="time"] .planet-atmosphere {
  background: radial-gradient(circle, var(--time-atmo) 40%, transparent 70%);
}
[data-app="time"]:hover .planet-body,
[data-app="time"]:focus-visible .planet-body,
[data-app="time"].active .planet-body {
  box-shadow: 0 0 40px var(--time-glow), 0 0 80px rgba(0, 212, 255, 0.15);
}

/* ── Planet Label ─────────────────────────────────────── */
.planet-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  opacity: 0.4;
  transition: opacity 0.4s var(--ease);
}

.planet:hover .planet-label,
.planet:focus-visible .planet-label,
.planet.active .planet-label {
  opacity: 1;
}

.planet-name {
  font-family: "Space Mono", monospace;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-primary);
}

[data-app="guild"] .planet-name { color: #a78bfa; }
[data-app="dog"] .planet-name { color: #ffa0d0; }
[data-app="time"] .planet-name { color: #66e8ff; }

.planet-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-width: 260px;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}

.planet:hover .planet-desc,
.planet:focus-visible .planet-desc,
.planet.active .planet-desc {
  opacity: 1;
  transform: translateY(0);
}

/* ── Focus ring ───────────────────────────────────────── */
.planet:focus-visible {
  outline: none;
}

.planet:focus-visible .planet-sphere::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

/* ── Keyframes ────────────────────────────────────────── */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Responsive: Mobile ───────────────────────────────── */
@media (max-width: 768px) {
  .constellation {
    padding: 4rem 1.5rem 6rem;
    gap: 5rem;
  }

  .planet-sphere {
    width: 120px;
    height: 120px;
  }

  .planet-label {
    opacity: 0.6;
  }

  .gateway {
    padding: 2rem 1.25rem;
  }
}

/* ── Responsive: Small Mobile ─────────────────────────── */
@media (max-width: 480px) {
  .gateway-title {
    font-size: 2.2rem;
  }

  .planet-sphere {
    width: 100px;
    height: 100px;
  }

  .constellation {
    gap: 4rem;
    padding: 3rem 1rem 5rem;
  }
}

/* ── Theme Selector Button ────────────────────────────── */
.theme-toggle {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 2rem;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text-secondary);
  font-family: "Space Mono", monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition:
    border-color 0.3s var(--ease),
    color 0.3s var(--ease),
    background 0.3s var(--ease);
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: rgba(255, 255, 255, 0.25);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.theme-toggle:focus-visible {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.theme-toggle-icon {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  line-height: 1rem;
  text-align: center;
  font-style: normal;
}

/* ── Theme Toast Notification ────────────────────────── */
.theme-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  z-index: 200;
  padding: 0.6rem 1.2rem;
  border-radius: 2rem;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  font-family: "Space Mono", monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0;
  transition: transform 0.4s var(--ease-out), opacity 0.4s var(--ease-out);
  pointer-events: none;
}

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

/* ── Reduced Motion ───────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .gateway-title,
  .gateway-subtitle {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .scroll-hint-icon {
    animation: none;
  }

  .planet-body {
    animation: none;
  }

  .planet {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .planet-label,
  .planet-desc,
  .planet-sphere,
  .planet-body,
  .planet-atmosphere,
  .scroll-hint {
    transition: none;
  }

  .planet-label {
    opacity: 0.7;
  }

  .planet-desc {
    opacity: 0.7;
    transform: none;
  }

  .theme-toast {
    transition: none;
    transform: translateX(-50%) translateY(0);
  }

  .theme-toggle {
    transition: none;
  }
}
