/* =================================
   J.A.R.V.I.S HUD ROOT
   (중앙 정렬의 핵심)
================================= */
.hud-root {
  position: relative;
  width: 100%;
  height: 100vh;

  display: flex;
  justify-content: center;
  align-items: center;
}

/* =====================
   STATE SYSTEM
===================== */
input[type='radio'] {
  display: none;
}

:root {
  --core-color: #5b6cff;
  --glow-color: color-mix(in srgb, var(--core-color) 60%, transparent);

  --ring-speed: 6s;
  --core-scale: 1;
  --core-opacity: 1;
  --bg-tint: none;
  --orbit-radius: 245px;

  --ball-hover-bg: rgba(116, 118, 212, 0.15);
  --ball-hover-glow: rgba(116, 118, 212, 0.45);
}

/* =====================
   MODE VARIABLES
===================== */
#mode-standby:checked ~ .orbit-wrapper {
  --ball-hover-bg: #e0e7ff;
  --ball-hover-glow: rgba(37, 99, 235, 0.35);
}

#mode-analysis:checked ~ .orbit-wrapper {
  --ball-hover-bg: #cffafe;
  --ball-hover-glow: rgba(56, 189, 248, 0.45);
}

#mode-alert:checked ~ .orbit-wrapper {
  --ball-hover-bg: #fee2e2;
  --ball-hover-glow: rgba(239, 68, 68, 0.55);
}

#mode-sleep:checked ~ .orbit-wrapper {
  --ball-hover-bg: #e5e7eb;
  --ball-hover-glow: rgba(148, 163, 184, 0.3);
}

/* ANALYSIS */
#mode-analysis:checked ~ * {
  --ring-speed: 2.5s;
  --glow-color: rgba(103, 232, 249, 0.9);
}

/* ALERT */
#mode-alert:checked ~ * {
  --core-color: #dc2626;
  --glow-color: rgba(239, 68, 68, 0.9);
  --ring-speed: 1.5s;
  --bg-tint: radial-gradient(circle at center, #3b0a0a, #020617 60%);
}

/* SLEEP */
#mode-sleep:checked ~ * {
  --core-scale: 0.85;
  --core-opacity: 0.4;
  --ring-speed: 10s;
}

/* =====================
   HUD STATUS
===================== */
.hud-status {
  position: absolute;
  top: 16px;
  left: 16px;

  font-family: 'Courier New', monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  opacity: 0.65;
  line-height: 1.6;
  text-align: left;
}

.hud-status label {
  cursor: pointer;
  opacity: 0.6;
}

.hud-status label:hover {
  opacity: 1;
  text-decoration: underline;
}

/* =====================
   ORBIT WRAPPER
===================== */
.orbit-wrapper {
  position: relative;
  width: 520px;
  height: 520px;
}

/* =====================
   J.A.R.V.I.S CORE
===================== */
#menu-toggle {
  display: none;
}

.menu-btn {
  width: 160px;
  height: 160px;
  border-radius: 50%;

  background: radial-gradient(
    circle at center,
    rgba(255, 255, 255, 0.22) 0%,
    var(--core-color) 38%,
    rgba(0, 0, 0, 0.6) 78%
  );

  font-weight: bold;

  display: flex;
  justify-content: center;
  align-items: center;

  cursor: pointer;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(var(--core-scale));
  opacity: var(--core-opacity);
  z-index: 10;

  box-shadow:
    0 0 18px var(--glow-color),
    0 0 55px var(--glow-color),
    inset 0 0 20px rgba(255, 255, 255, 0.12);
}

/* CORE IDLE PULSE */
.orbit-wrapper .menu-btn:not(:hover) {
  animation: core-idle-pulse 4s infinite ease-in-out;
}

@keyframes core-idle-pulse {
  0% {
    box-shadow:
      0 0 22px var(--glow-color),
      0 0 45px var(--glow-color);
    transform: translate(-50%, -50%) scale(0.98);
  }
  50% {
    box-shadow:
      0 0 48px var(--glow-color),
      0 0 110px var(--glow-color);
    transform: translate(-50%, -50%) scale(1.05);
  }
  100% {
    box-shadow:
      0 0 22px var(--glow-color),
      0 0 45px var(--glow-color);
    transform: translate(-50%, -50%) scale(0.98);
  }
}

/* 코어 링 */

.menu-btn::before {
  border: 1px solid var(--glow-color);
  opacity: 0.7;
}

.menu-btn::after {
  content: '';
  position: absolute;
  inset: -40px;
  border-radius: 50%;
  border: 1px solid var(--glow-color);
  animation: core-spin var(--ring-speed) linear infinite;
  border-style: dashed;
  opacity: 0.25;
}

@keyframes core-spin {
  to {
    transform: rotate(360deg);
  }
}

/* =====================
   STAGE
===================== */
.stage {
  position: relative;
  width: 100%;
  height: 100%;
}

/* =====================
   ORBIT
===================== */
.orbit {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;

  transform-origin: center;
  --angle: calc(360deg / var(--count) * var(--i));
  transform: rotate(0deg);
}

/* OPEN */
#menu-toggle:checked ~ .stage .orbit {
  animation: orbit-out 1.2s ease-out forwards;
  animation-delay: calc(var(--i) * 0.12s);
}

/* CLOSE */
#menu-toggle:not(:checked) ~ .stage .orbit {
  animation: orbit-in 1s ease-in forwards;
  animation-delay: calc((var(--count) - var(--i) - 1) * 0.12s);
}

/* =====================
   HUD BALL (Glass Node)
===================== */
.ball {
  width: 120px;
  height: 120px;
  border-radius: 50%;

  /* 흰색 제거 → 글래스 느낌 */
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(10px);

  border: 1px solid rgba(110, 231, 255, 0.35);

  box-shadow:
    0 0 18px rgba(110, 231, 255, 0.25),
    inset 0 0 14px rgba(110, 231, 255, 0.15);

  display: flex;
  justify-content: center;
  align-items: center;

  font-weight: bold;
  color: #e0f7ff;

  transform: translateX(0) scale(0.4) translateZ(0);
  opacity: 0;
  pointer-events: none;

  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease,
    background-color 0.25s ease;
}

.ball:hover {
  transform: translateX(var(--orbit-radius)) scale(1.06);

  background: rgba(110, 231, 255, 0.14);

  box-shadow:
    0 0 28px var(--ball-hover-glow),
    inset 0 0 18px var(--ball-hover-glow);

  animation: ball-hover-pulse 1.2s ease-in-out infinite;
}
@keyframes ball-hover-pulse {
  0% {
    box-shadow: 0 22px 42px var(--ball-hover-glow);
  }
  50% {
    box-shadow: 0 30px 60px var(--ball-hover-glow);
  }
  100% {
    box-shadow: 0 22px 42px var(--ball-hover-glow);
  }
}

.ball span {
  font-size: 12px;
  letter-spacing: 0.14em;
  color: #e0f7ff;

  text-shadow: 0 0 8px rgba(100, 83, 223, 0.8);

  white-space: nowrap;
  transform: rotate(calc(-1 * var(--angle)));
}

/* =========================
   DISABLED BALL (완전 비활성)
========================= */
.ball.disabled {
  pointer-events: none !important;
}

.ball.disabled span {
  color: #aaa;
}

/* OPEN BALL */
#menu-toggle:checked ~ .stage .orbit .ball {
  animation: radius-out 1.2s ease-out forwards;
  animation-delay: calc(var(--i) * 0.12s);
  pointer-events: auto;
}

/* CLOSE BALL */
#menu-toggle:not(:checked) ~ .stage .orbit .ball {
  animation: radius-in 1s ease-in forwards;
  animation-delay: calc((var(--count) - var(--i) - 1) * 0.12s);
}

/* =====================
   ANIMATIONS
===================== */
@keyframes orbit-out {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(var(--angle));
  }
}

@keyframes orbit-in {
  from {
    transform: rotate(var(--angle));
  }
  to {
    transform: rotate(0deg);
  }
}

@keyframes radius-out {
  to {
    transform: translateX(var(--orbit-radius)) scale(1);
    opacity: 1;
  }
}

@keyframes radius-in {
  from {
    transform: translateX(var(--orbit-radius)) scale(1);
    opacity: 1;
  }
  to {
    transform: translateX(0) scale(0.4);
    opacity: 0;
  }
}
/* =====================
   AI TEXT
===================== */
.ai-text {
  position: absolute;
  top: calc(50% + 110px);
  left: 50%;
  transform: translateX(-50%);

  width: 380px;
  height: 4.5em;
  overflow: visible;

  display: flex;
  align-items: center;
  justify-content: center;

  font-family: 'Courier New', monospace;
  font-size: 18px;
  font-weight: 600;

  letter-spacing: 0.08em; /* 자비스 느낌 핵심 */
  text-align: center;

  color: #a5b4fc; /* 은은한 블루 */
  text-shadow:
    0 0 6px rgba(99, 102, 241, 0.35),
    0 0 14px rgba(99, 102, 241, 0.25);

  user-select: none;
}

/* span도 동일 정렬 */
.ai-text span {
  position: absolute;
  inset: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  opacity: 0;
  white-space: normal;
  text-align: center;
  line-height: 1.4;
}
@keyframes ai-text-fade {
  from {
    opacity: 0;
    filter: blur(2px);
  }
  to {
    opacity: 1;
    filter: blur(0);
  }
}
#mode-standby:checked ~ .orbit-wrapper .ai-text .standby {
  opacity: 1;
  color: #818cf8;
  text-shadow:
    0 0 6px rgba(129, 140, 248, 0.6),
    0 0 18px rgba(129, 140, 248, 0.35);
}

#mode-analysis:checked ~ .orbit-wrapper .ai-text .analysis {
  opacity: 1;
  color: #22d3ee;
  text-shadow:
    0 0 8px rgba(34, 211, 238, 0.75),
    0 0 20px rgba(34, 211, 238, 0.4);
}

#mode-alert:checked ~ .orbit-wrapper .ai-text .alert {
  opacity: 1;
  color: #f87171;
  text-shadow:
    0 0 8px rgba(248, 113, 113, 0.8),
    0 0 26px rgba(248, 113, 113, 0.55);
}

#mode-sleep:checked ~ .orbit-wrapper .ai-text .sleep {
  opacity: 1;
  color: #9ca3af;
  text-shadow: 0 0 4px rgba(156, 163, 175, 0.25);
}

.orbit-wrapper:has(.ball:hover) .ai-text span {
  opacity: 0 !important;
}

.orbit-wrapper:has(.ball:hover) .ai-text::after {
  content: 'Command recognized';

  position: absolute;
  inset: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.1em;

  color: #00e5a8;
  text-shadow:
    0 0 10px rgba(0, 229, 168, 0.85),
    0 0 24px rgba(0, 229, 168, 0.55);
}

/* =====================
   CORE PULSE – MODE + HOVER ONLY
===================== */

/* STANDBY */
#mode-standby:checked ~ .orbit-wrapper .menu-btn:hover {
  animation: core-pulse-standby 1.4s infinite ease-in-out;
}

@keyframes core-pulse-standby {
  0% {
    transform: translate(-50%, -50%) scale(1);

    box-shadow:
      0 0 24px rgba(116, 118, 212, 0.45),
      0 0 48px rgba(116, 118, 212, 0.25);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.06);

    box-shadow:
      0 0 40px rgba(116, 118, 212, 0.75),
      0 0 90px rgba(116, 118, 212, 0.45);
  }
  100% {
    transform: translate(-50%, -50%) scale(1);

    box-shadow:
      0 0 24px rgba(116, 118, 212, 0.45),
      0 0 48px rgba(116, 118, 212, 0.25);
  }
}

/* ANALYSIS */
#mode-analysis:checked ~ .orbit-wrapper .menu-btn:hover {
  animation: core-pulse-analysis 1.2s infinite ease-in-out;
}

@keyframes core-pulse-analysis {
  0% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow:
      0 0 26px rgba(103, 232, 249, 0.45),
      0 0 60px rgba(103, 232, 249, 0.3);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.08);
    box-shadow:
      0 0 50px rgba(103, 232, 249, 0.95),
      0 0 120px rgba(103, 232, 249, 0.65);
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow:
      0 0 26px rgba(103, 232, 249, 0.45),
      0 0 60px rgba(103, 232, 249, 0.3);
  }
}

/* ALERT */
#mode-alert:checked ~ .orbit-wrapper .menu-btn:hover {
  animation: core-pulse-alert 0.9s infinite ease-in-out;
}

@keyframes core-pulse-alert {
  0% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow:
      0 0 30px rgba(239, 68, 68, 0.45),
      0 0 60px rgba(239, 68, 68, 0.4);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.12);
    box-shadow:
      0 0 60px rgba(239, 68, 68, 1),
      0 0 140px rgba(239, 68, 68, 0.8);
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow:
      0 0 30px rgba(239, 68, 68, 0.45),
      0 0 60px rgba(239, 68, 68, 0.4);
  }
}

/* SLEEP */
#mode-sleep:checked ~ .orbit-wrapper .menu-btn:hover {
  animation: core-pulse-sleep 2.2s infinite ease-in-out;
}

@keyframes core-pulse-sleep {
  0% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 0 10px rgba(148, 163, 184, 0.25);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.03);
    box-shadow: 0 0 20px rgba(148, 163, 184, 0.45);
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 0 10px rgba(148, 163, 184, 0.25);
  }
}
/* =====================
   INDEX RESPONSIVE (MOBILE)
===================== */
@media (max-width: 768px) {
  .hud-root {
    position: relative;
    --orbit-radius: 100px;
    z-index: 100; /* HUD 위로 올림 */
    pointer-events: auto;
  }

  .orbit-wrapper {
    width: 340px; /* 520 → 340 */
    height: 340px;
  }

  .orbit-wrapper,
  .stage {
    pointer-events: none;
  }

  .menu-btn {
    pointer-events: auto;
    width: 110px;
    height: 110px;
  }
  .ball {
    width: 90px;
    height: 90px;
  }

  .ai-text {
    width: 280px;
    font-size: 14px;
    top: calc(50% + 50px);
  }

  .orbit-wrapper:has(.ball:hover) .ai-text::after {
    font-size: 14px; /* 20 → 14 */
    letter-spacing: 0.06em; /* 간격 줄이기 */
  }
}
