/* ═══════════════════════════════════════════════════
   TGRA TERMINAL LOADER
   Hacker/Console Style Boot Screen
   ═══════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════
   LOADER VARIABLES
   ═══════════════════════════════════════════════════ */
:root {
  --loader-bg: #0a0a0f;
  --terminal-bg: #0d1117;
  --terminal-border: #30363d;
  --terminal-green: #00ff88;
  --terminal-blue: #58a6ff;
  --terminal-purple: #bc8cff;
  --terminal-red: #ff7b72;
  --terminal-yellow: #ffd93d;
  --terminal-text: #c9d1d9;
  --terminal-dim: #484f58;
  --glow-green: rgba(0, 255, 136, 0.5);
  --glow-blue: rgba(88, 166, 255, 0.5);
  --font-mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
}

/* ═══════════════════════════════════════════════════
   MAIN LOADER
   ═══════════════════════════════════════════════════ */
.tgra-loader {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--loader-bg);
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════
   ANIMATED BACKGROUND
   ═══════════════════════════════════════════════════ */
.loader-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.bg-gradient {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(0, 255, 136, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(88, 166, 255, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(188, 140, 255, 0.03) 0%, transparent 70%);
  animation: bgPulse 8s ease-in-out infinite;
}

@keyframes bgPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 255, 136, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 136, 0.025) 1px, transparent 1px);
  background-size: 40px 40px;
  animation: gridScroll 25s linear infinite;
}

@keyframes gridScroll {
  0% { transform: translate(0, 0); }
  100% { transform: translate(40px, 40px); }
}

.bg-scanline {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 4px
  );
  pointer-events: none;
  animation: scanlineShift 6s linear infinite;
}

@keyframes scanlineShift {
  0% { transform: translateY(0); }
  100% { transform: translateY(4px); }
}

/* Floating Code Particles */
.bg-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.bg-particle {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--terminal-green);
  opacity: 0.12;
  animation: codeFloat 18s linear infinite;
  user-select: none;
}

@keyframes codeFloat {
  0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
  10% { opacity: 0.12; }
  90% { opacity: 0.12; }
  100% { transform: translateY(-100vh) rotate(360deg); opacity: 0; }
}

/* ═══════════════════════════════════════════════════
   TERMINAL WINDOW
   ═══════════════════════════════════════════════════ */
.loader-terminal {
  position: relative;
  z-index: 10;
  width: 90%;
  max-width: 700px;
  background: var(--terminal-bg);
  border-radius: 14px;
  overflow: hidden;
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.5),
    0 0 0 1px var(--terminal-border),
    0 0 80px rgba(0, 255, 136, 0.06);
  animation: terminalHover 5s ease-in-out infinite;
}

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

/* Terminal Header */
.terminal-header {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.025);
  border-bottom: 1px solid var(--terminal-border);
}

.terminal-dots {
  display: flex;
  gap: 8px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.dot:hover {
  transform: scale(1.3);
}

.dot.red {
  background: #ff5f57;
  box-shadow: 0 0 12px rgba(255, 95, 87, 0.5);
}

.dot.yellow {
  background: #ffbd2e;
  box-shadow: 0 0 12px rgba(255, 189, 46, 0.5);
}

.dot.green {
  background: #28c840;
  box-shadow: 0 0 12px rgba(40, 200, 64, 0.5);
}

.terminal-title {
  flex: 1;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--terminal-dim);
  letter-spacing: 0.5px;
}

.terminal-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--terminal-green);
  animation: statusGlow 1.5s ease-in-out infinite;
}

@keyframes statusGlow {
  0%, 100% { opacity: 1; box-shadow: 0 0 12px var(--glow-green); }
  50% { opacity: 0.4; box-shadow: 0 0 4px var(--glow-green); }
}

.status-text {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--terminal-green);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Terminal Body */
.terminal-body {
  padding: 24px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  min-height: 300px;
}

/* ASCII Logo */
.ascii-logo {
  margin-bottom: 20px;
  opacity: 0;
}

.ascii-logo pre {
  font-family: var(--font-mono);
  font-size: clamp(6px, 1.8vw, 12px);
  line-height: 1.2;
  color: var(--terminal-green);
  text-shadow: 0 0 25px var(--glow-green);
  margin: 0;
  white-space: pre;
  text-align: center;
}

/* Terminal Lines */
.terminal-lines {
  margin-bottom: 16px;
}

.terminal-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
  opacity: 0;
}

.terminal-line .prompt {
  color: var(--terminal-green);
  font-weight: bold;
  text-shadow: 0 0 10px var(--glow-green);
  flex-shrink: 0;
}

.terminal-line .text {
  color: var(--terminal-text);
}

.terminal-line .text.success { color: var(--terminal-green); }
.terminal-line .text.warning { color: var(--terminal-yellow); }
.terminal-line .text.error { color: var(--terminal-red); }
.terminal-line .text.info { color: var(--terminal-blue); }
.terminal-line .text.purple { color: var(--terminal-purple); }

/* Progress Bar */
.terminal-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0;
  opacity: 0;
}

.progress-label {
  color: var(--terminal-green);
  font-weight: bold;
  text-shadow: 0 0 10px var(--glow-green);
  white-space: nowrap;
}

.progress-bar-wrapper {
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 300px;
}

.progress-bracket {
  color: var(--terminal-dim);
  font-size: 16px;
}

.progress-bar-track {
  flex: 1;
  height: 16px;
  position: relative;
  overflow: hidden;
}

.progress-bar-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.progress-bar-fill::before {
  content: '████████████████████████████████████████';
  color: var(--terminal-green);
  text-shadow: 0 0 12px var(--glow-green);
  white-space: nowrap;
  font-size: 14px;
  letter-spacing: -1px;
}

.progress-percent {
  color: var(--terminal-yellow);
  font-weight: bold;
  min-width: 45px;
  text-align: right;
}

/* Cursor Line */
.terminal-cursor-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  opacity: 0;
}

.terminal-cursor-line .prompt {
  color: var(--terminal-green);
  font-weight: bold;
  text-shadow: 0 0 10px var(--glow-green);
}

.cursor {
  color: var(--terminal-green);
  animation: cursorBlink 1s step-end infinite;
  text-shadow: 0 0 10px var(--glow-green);
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ═══════════════════════════════════════════════════
   MUSIC MODAL
   ═══════════════════════════════════════════════════ */
.terminal-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 40px;
  background: var(--loader-bg);
  opacity: 0;
  visibility: hidden;
}

.terminal-modal.active {
  visibility: visible;
}

/* TGRA Logo */
.tgra-logo {
  display: flex;
  align-items: center;
  gap: 20px;
  font-family: var(--font-mono);
  font-size: clamp(48px, 12vw, 80px);
  font-weight: 700;
  opacity: 0;
  transform: translateY(-30px);
}

.logo-left,
.logo-right {
  color: var(--terminal-green);
  text-shadow:
    0 0 20px var(--glow-green),
    0 0 40px var(--glow-green),
    0 0 80px rgba(0, 255, 136, 0.3);
  transition: text-shadow 0.3s ease;
}

.logo-left:hover,
.logo-right:hover {
  text-shadow:
    0 0 30px var(--glow-green),
    0 0 60px var(--glow-green),
    0 0 100px rgba(0, 255, 136, 0.5);
}

.logo-divider {
  color: var(--terminal-purple);
  font-weight: 200;
  animation: dividerBlink 1s ease-in-out infinite;
  text-shadow: 0 0 20px rgba(188, 140, 255, 0.5);
}

@keyframes dividerBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

/* Music Terminal */
.music-terminal {
  width: 90%;
  max-width: 550px;
  background: var(--terminal-bg);
  border-radius: 14px;
  overflow: hidden;
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.5),
    0 0 0 1px var(--terminal-border),
    0 0 80px rgba(0, 255, 136, 0.06);
  opacity: 0;
  transform: translateY(30px) scale(0.95);
}

.music-terminal .terminal-body {
  min-height: auto;
  padding: 20px 24px;
}

.music-terminal .terminal-line {
  margin-bottom: 12px;
}

.terminal-input-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  opacity: 0;
}

.terminal-input-line .prompt {
  color: var(--terminal-green);
  font-weight: bold;
  text-shadow: 0 0 10px var(--glow-green);
}

.input-wrapper {
  display: flex;
  align-items: center;
  gap: 5px;
}

.input-text {
  color: var(--terminal-dim);
}

/* Terminal Buttons */
.terminal-btn {
  background: transparent;
  border: 1px solid var(--terminal-green);
  color: var(--terminal-green);
  padding: 6px 18px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-shadow: 0 0 10px var(--glow-green);
  position: relative;
  overflow: hidden;
}

/* Button hover glow ring */
.terminal-btn::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: var(--terminal-green);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
  filter: blur(8px);
}

.terminal-btn:hover::before {
  opacity: 0.3;
}

.terminal-btn:hover {
  background: var(--terminal-green);
  color: var(--terminal-bg);
  box-shadow: 0 0 35px var(--glow-green);
  text-shadow: none;
  transform: scale(1.08);
}

.yes-btn:hover {
  background: #28c840;
  border-color: #28c840;
  box-shadow: 0 0 35px rgba(40, 200, 64, 0.6);
}

.no-btn:hover {
  background: var(--terminal-red);
  border-color: var(--terminal-red);
  color: white;
  box-shadow: 0 0 35px rgba(255, 123, 114, 0.6);
  text-shadow: none;
}

/* ═══════════════════════════════════════════════════
   MUSIC TOGGLE BUTTON
   ═══════════════════════════════════════════════════ */
.music-toggle-btn {
  position: fixed;
  top: 20px;
  right: 80px;
  width: 50px;
  height: 50px;
  border: 1px solid var(--terminal-border);
  border-radius: 50%;
  background: var(--terminal-bg);
  cursor: pointer;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.3),
    0 0 20px rgba(0, 255, 136, 0.08);
}

.music-toggle-btn.visible {
  opacity: 1;
  visibility: visible;
}

.music-toggle-btn:hover {
  transform: scale(1.12);
  border-color: var(--terminal-green);
  box-shadow:
    0 6px 30px rgba(0, 0, 0, 0.4),
    0 0 35px var(--glow-green);
}

.music-toggle-btn i {
  font-size: 18px;
  color: var(--terminal-dim);
  transition: all 0.3s ease;
}

.music-toggle-btn.playing {
  border-color: var(--terminal-green);
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.3),
    0 0 30px var(--glow-green);
}

.music-toggle-btn.playing i {
  color: var(--terminal-green);
  text-shadow: 0 0 12px var(--glow-green);
}

/* Sound Waves */
.sound-waves {
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.music-toggle-btn.playing .sound-waves {
  opacity: 1;
}

.sound-waves span {
  width: 3px;
  background: var(--terminal-green);
  border-radius: 3px;
  box-shadow: 0 0 8px var(--glow-green);
}

.sound-waves span:nth-child(1) { height: 8px;  animation: soundWave 0.6s ease-in-out infinite 0s; }
.sound-waves span:nth-child(2) { height: 12px; animation: soundWave 0.6s ease-in-out infinite 0.1s; }
.sound-waves span:nth-child(3) { height: 10px; animation: soundWave 0.6s ease-in-out infinite 0.2s; }
.sound-waves span:nth-child(4) { height: 14px; animation: soundWave 0.6s ease-in-out infinite 0.3s; }

@keyframes soundWave {
  0%, 100% { transform: scaleY(0.4); }
  50% { transform: scaleY(1); }
}

/* Light Mode */
body.light-mode .music-toggle-btn {
  background: #ffffff;
  border-color: #e0e0e0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

body.light-mode .music-toggle-btn.playing {
  border-color: #28c840;
}

body.light-mode .music-toggle-btn.playing i {
  color: #28c840;
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .loader-terminal {
    width: 95%;
  }

  .terminal-body {
    padding: 16px;
    font-size: 12px;
  }

  .ascii-logo pre {
    font-size: clamp(5px, 1.5vw, 10px);
  }

  .progress-bar-wrapper {
    max-width: 200px;
  }

  .tgra-logo { gap: 15px; }
  .music-terminal { width: 95%; }

  .music-toggle-btn {
    top: 15px;
    right: 70px;
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 480px) {
  .terminal-body {
    padding: 12px;
    font-size: 11px;
    min-height: 250px;
  }

  .ascii-logo pre { font-size: 5px; }

  .terminal-progress {
    flex-wrap: wrap;
    gap: 8px;
  }

  .progress-bar-wrapper {
    max-width: 100%;
    order: 3;
    width: 100%;
  }

  .tgra-logo {
    font-size: clamp(36px, 10vw, 60px);
    gap: 10px;
  }

  .terminal-btn {
    padding: 5px 14px;
    font-size: 12px;
  }

  .music-toggle-btn {
    right: 65px;
    width: 40px;
    height: 40px;
  }

  .music-toggle-btn i { font-size: 14px; }
}
