/* author: https://github.com/nhermab
   rewrite by: https://github.com/broodje565 */

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(88,101,242,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(88,101,242,0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: 0;
  animation: grid-flow 20s linear infinite;
}

@keyframes grid-flow {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(50px);
  }
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(88,101,242,0.08) 0%, transparent 3%),
    radial-gradient(circle at 80% 70%, rgba(139,92,246,0.06) 0%, transparent 4%),
    radial-gradient(circle at 40% 80%, rgba(6,182,212,0.05) 0%, transparent 2.5%),
    radial-gradient(circle at 60% 20%, rgba(88,101,242,0.07) 0%, transparent 3.5%);
  background-size: 200% 200%;
  pointer-events: none;
  z-index: 0;
  animation: particle-float 25s ease-in-out infinite;
}

@keyframes particle-float {
  0%, 100% {
    background-position: 0% 0%, 100% 100%, 0% 100%, 100% 0%;
  }
  33% {
    background-position: 50% 50%, 50% 50%, 50% 50%, 50% 50%;
  }
  66% {
    background-position: 100% 0%, 0% 100%, 100% 100%, 0% 0%;
  }
}

#app-root {
  position: relative;
  z-index: 1;
}

@keyframes card-entrance {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.quiz-question,
.list-item {
  animation: card-entrance 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.list-item:nth-child(1) { animation-delay: 0.05s; }
.list-item:nth-child(2) { animation-delay: 0.1s; }
.list-item:nth-child(3) { animation-delay: 0.15s; }
.list-item:nth-child(4) { animation-delay: 0.2s; }
.list-item:nth-child(5) { animation-delay: 0.25s; }
.list-item:nth-child(6) { animation-delay: 0.3s; }
.list-item:nth-child(7) { animation-delay: 0.35s; }
.list-item:nth-child(8) { animation-delay: 0.4s; }
.list-item:nth-child(9) { animation-delay: 0.45s; }
.list-item:nth-child(10) { animation-delay: 0.5s; }
.list-item:nth-child(11) { animation-delay: 0.55s; }
.list-item:nth-child(12) { animation-delay: 0.6s; }
.list-item:nth-child(13) { animation-delay: 0.65s; }
.list-item:nth-child(14) { animation-delay: 0.7s; }
.list-item:nth-child(15) { animation-delay: 0.75s; }
.list-item:nth-child(16) { animation-delay: 0.8s; }
.list-item:nth-child(17) { animation-delay: 0.85s; }
.list-item:nth-child(18) { animation-delay: 0.9s; }
.list-item:nth-child(19) { animation-delay: 0.95s; }
.list-item:nth-child(20) { animation-delay: 1s; }

@keyframes premium-glow-pulse {
  0%, 100% {
    box-shadow:
      0 0 20px rgba(88,101,242,0.2),
      0 0 40px rgba(88,101,242,0.1);
  }
  50% {
    box-shadow:
      0 0 30px rgba(88,101,242,0.35),
      0 0 60px rgba(88,101,242,0.2);
  }
}

.list-button.is-active,
.tab-button.is-active,
.practice-attachment-button.is-active {
  animation: premium-glow-pulse 3s ease-in-out infinite;
}

@keyframes neon-glow {
  0%, 100% {
    filter: drop-shadow(0 0 8px rgba(88,101,242,0.4));
  }
  50% {
    filter: drop-shadow(0 0 12px rgba(88,101,242,0.6));
  }
}

header h1 {
  animation: neon-glow 4s ease-in-out infinite;
}

@keyframes cyber-scan {
  0% {
    transform: translateY(-100%);
    opacity: 0.1;
  }
  50% {
    opacity: 0.3;
  }
  100% {
    transform: translateY(100vh);
    opacity: 0.1;
  }
}

.screen::after {
  animation: cyber-scan 8s linear infinite;
  opacity: 0.4;
}

@keyframes button-ripple {
  0% {
    transform: scale(0);
    opacity: 0.6;
  }
  100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

@keyframes holographic-shimmer {
  0% {
    background-position: -200% center;
  }
  100% {
    background-position: 200% center;
  }
}

@keyframes status-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.1);
  }
}

#global-status.is-visible::before {
  animation: shimmer 2s infinite;
}

.markdown-body > * {
  animation: fade-in 0.5s ease-out backwards;
}

.markdown-body > *:nth-child(1) { animation-delay: 0.05s; }
.markdown-body > *:nth-child(2) { animation-delay: 0.1s; }
.markdown-body > *:nth-child(3) { animation-delay: 0.15s; }
.markdown-body > *:nth-child(4) { animation-delay: 0.2s; }
.markdown-body > *:nth-child(5) { animation-delay: 0.25s; }
.markdown-body > *:nth-child(6) { animation-delay: 0.3s; }
.markdown-body > *:nth-child(7) { animation-delay: 0.35s; }
.markdown-body > *:nth-child(8) { animation-delay: 0.4s; }
.markdown-body > *:nth-child(9) { animation-delay: 0.45s; }
.markdown-body > *:nth-child(10) { animation-delay: 0.5s; }
.markdown-body > *:nth-child(11) { animation-delay: 0.55s; }
.markdown-body > *:nth-child(12) { animation-delay: 0.6s; }
.markdown-body > *:nth-child(13) { animation-delay: 0.65s; }
.markdown-body > *:nth-child(14) { animation-delay: 0.7s; }
.markdown-body > *:nth-child(15) { animation-delay: 0.75s; }
.markdown-body > *:nth-child(16) { animation-delay: 0.8s; }
.markdown-body > *:nth-child(17) { animation-delay: 0.85s; }
.markdown-body > *:nth-child(18) { animation-delay: 0.9s; }
.markdown-body > *:nth-child(19) { animation-delay: 0.95s; }
.markdown-body > *:nth-child(20) { animation-delay: 1s; }
.markdown-body > *:nth-child(21) { animation-delay: 1.05s; }
.markdown-body > *:nth-child(22) { animation-delay: 1.1s; }
.markdown-body > *:nth-child(23) { animation-delay: 1.15s; }
.markdown-body > *:nth-child(24) { animation-delay: 1.2s; }
.markdown-body > *:nth-child(25) { animation-delay: 1.25s; }
.markdown-body > *:nth-child(26) { animation-delay: 1.3s; }
.markdown-body > *:nth-child(27) { animation-delay: 1.35s; }
.markdown-body > *:nth-child(28) { animation-delay: 1.4s; }
.markdown-body > *:nth-child(29) { animation-delay: 1.45s; }
.markdown-body > *:nth-child(30) { animation-delay: 1.5s; }

*:focus-visible {
  outline: 2px solid var(--color-primary-light);
  outline-offset: 3px;
  box-shadow:
    0 0 0 5px rgba(129,140,248,0.15),
    0 0 25px rgba(88,101,242,0.3);
}

.markdown-body a {
  position: relative;
}

.markdown-body a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  transition: width 0.3s ease;
  box-shadow: 0 0 10px rgba(88,101,242,0.6);
}

.markdown-body a:hover::after {
  width: 100%;
}

*::-webkit-scrollbar-thumb:active {
  background: rgba(99,102,241,0.9);
  box-shadow:
    0 0 15px rgba(88,101,242,0.6),
    inset 0 0 8px rgba(255,255,255,0.2);
}

@keyframes border-glow-rotate {
  0% {
    filter: hue-rotate(0deg);
  }
  100% {
    filter: hue-rotate(360deg);
  }
}

.practice-assignment-select {
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.practice-assignment-select:hover {
  border-color: rgba(129,140,248,0.8);
  box-shadow: 0 0 15px rgba(88,101,242,0.2);
  transform: translateY(-1px);
}

.practice-assignment-select:focus {
  border-color: var(--color-primary);
  box-shadow:
    0 0 0 3px rgba(88,101,242,0.2),
    0 0 20px rgba(88,101,242,0.3);
}

.markdown-body tr {
  transition: all 0.2s ease;
}

.markdown-body tr:hover {
  transform: translateX(4px);
}

.markdown-body blockquote {
  position: relative;
  overflow: hidden;
}

.markdown-body blockquote::before {
  content: '"';
  position: absolute;
  top: -10px;
  left: 10px;
  font-size: 4rem;
  color: rgba(88,101,242,0.15);
  font-family: Georgia, serif;
  line-height: 1;
}

.markdown-body img {
  cursor: zoom-in;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

button,
a,
input,
select,
textarea {
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.screen-header-title,
.chapter-header-title,
.practice-assignment-title {
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 0.4rem 0.8rem;
  background: #232526;
  color: var(--color-text);
  border: 1px solid #232526;
  border-radius: 8px;
  font-size: 0.85rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  box-shadow: none;
  z-index: 1000;
}

[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  body::before, body::after, .screen::after, .list-button.is-active, .tab-button.is-active, .practice-attachment-button.is-active, header h1, .markdown-body a::after, *:focus-visible, .markdown-body tr:hover, .markdown-body blockquote::before, .markdown-body img, .practice-assignment-select:hover, .practice-assignment-select:focus {
    animation: none !important;
    box-shadow: none !important;
    filter: none !important;
    background: none !important;
  }
}
