/* === Matrix layer: always behind UI === */
.jp-matrix-bg{
  position: fixed;
  inset: 0;
  z-index: -1;            /* behind header/content */
  pointer-events: none;
  /* default hidden (light mode) */
  display: none;
  opacity: 0;
  visibility: hidden;
}

/* Show ONLY in dark mode (html or body can carry the class) */
html.dark-mode .jp-matrix-bg,
body.dark-mode .jp-matrix-bg{
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  z-index: -1 !important;
}

/* Keep navbar un-dimmed and see-through */
html.dark-mode .site-nav,
html.dark-mode .navbar{
  background: #0d1117 !important;
  border-bottom: 1px solid #30363d;
  backdrop-filter: none !important;
}

.jp-matrix {
  background-color: #05050a;
  width: 100%;
  height: 100%;
  overflow: hidden;

  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  grid-auto-rows: 40px;
  min-width: 1920px;
  min-height: 1080px;

  font-size: 32px;
  color: rgba(0, 150, 255, 0.4);
  font-family: "Courier New", Courier, monospace;
  justify-content: center;
  align-content: center;
}

.jp-matrix > span {
  text-align: center;
  text-shadow: 0 0 5px rgba(0, 150, 255, 0.5);
  user-select: none;
  transition:
    color 0.5s,
    text-shadow 0.5s;
  line-height: 1;
}

.jp-matrix > span:nth-child(19n + 2) {
  animation: smooth-pulse 3.5s ease-in-out infinite 0.2s;
}
.jp-matrix > span:nth-child(29n + 1) {
  animation: smooth-pulse 4.1s ease-in-out infinite 0.7s;
}
.jp-matrix > span:nth-child(11n) {
  color: rgba(100, 200, 255, 0.7);
  animation: smooth-pulse 2.9s ease-in-out infinite 1.1s;
}
.jp-matrix > span:nth-child(37n + 10) {
  animation: smooth-pulse 5.3s ease-in-out infinite 1.5s;
}
.jp-matrix > span:nth-child(41n + 1) {
  animation: smooth-pulse 3.9s ease-in-out infinite 0.4s;
}
.jp-matrix > span:nth-child(17n + 9) {
  animation: smooth-pulse 2.8s ease-in-out infinite 0.9s;
}
.jp-matrix > span:nth-child(23n + 18) {
  animation: smooth-pulse 4.3s ease-in-out infinite 1.3s;
}
.jp-matrix > span:nth-child(31n + 4) {
  animation: smooth-pulse 5.6s ease-in-out infinite 0.1s;
}
.jp-matrix > span:nth-child(43n + 20) {
  animation: smooth-pulse 3.6s ease-in-out infinite 1.8s;
}
.jp-matrix > span:nth-child(13n + 6) {
  animation: smooth-pulse 3.2s ease-in-out infinite 1.2s;
}
.jp-matrix > span:nth-child(53n + 5) {
  animation: smooth-pulse 4.9s ease-in-out infinite 0.5s;
}
.jp-matrix > span:nth-child(47n + 15) {
  animation: smooth-pulse 5.9s ease-in-out infinite 1s;
}

@keyframes smooth-pulse {
  0%,
  100% {
    color: rgba(0, 150, 255, 0.4);
    text-shadow: 0 0 5px rgba(0, 150, 255, 0.5);
  }
  30% {
    color: rgba(100, 200, 255, 1);
    text-shadow:
      0 0 10px rgba(100, 200, 255, 1),
      0 0 15px rgba(100, 200, 255, 1);
  }
  50% {
    color: rgba(255, 105, 180, 1);
    text-shadow:
      0 0 10px rgba(255, 105, 180, 1),
      0 0 15px rgba(255, 105, 180, 1);
  }
  70% {
    color: #ffffff;
    text-shadow:
      0 0 10px #fff,
      0 0 15px #fff,
      0 0 20px #fff;
  }
}
