/* 芯片与数据流：首页背景与开场加载 */
#container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

#chip-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  transition: opacity 1.2s ease;
}

/* 循环播放的星河短片做首页背景，视频就绪后淡入、画布淡出 */
#chip-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1.2s ease;
}

#container.has-video #chip-video { opacity: .9; }
#container.has-video #chip-canvas { opacity: 0; }

#container.has-video::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(7, 19, 33, .58) 0%, rgba(7, 19, 33, .16) 42%, rgba(7, 19, 33, .66) 100%);
}

.loader {
  position: fixed;
  inset: 0;
  top: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: none;
  background:
    radial-gradient(circle at 50% 42%, rgba(159, 212, 255, 0.08), transparent 34%),
    radial-gradient(circle at 50% 50%, #0a1d3a 0%, #061426 58%, #020814 100%);
  overflow: hidden;
  z-index: 10000;
  transition: opacity .45s ease, visibility .45s ease;
}

.loader.is-hidden {
  display: flex !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#chip-loader-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.chip-loader-caption {
  position: relative;
  z-index: 2;
  margin-top: 26vh;
  padding: 10px 18px;
  border: 1px solid rgba(255, 217, 160, 0.34);
  border-radius: 999px;
  background: rgba(4, 16, 30, 0.72);
  color: rgba(226, 243, 255, 0.86);
  font: 500 12px/1.5 "Consolas", "Microsoft YaHei", monospace;
  letter-spacing: .16em;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
}

.chip-loader-caption i {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 8px;
  border-radius: 50%;
  background: #ffd9a0;
  box-shadow: 0 0 10px #ffd9a0;
  animation: chip-dot 1.1s ease-in-out infinite;
  vertical-align: 1px;
}

.chip-loader-caption b {
  font-weight: 600;
  color: #ffd9a0;
}

.chip-loader-caption em {
  font-style: normal;
  animation: chip-ellipsis 1.4s steps(4, end) infinite;
}

.chip-loader-bar {
  position: relative;
  z-index: 2;
  width: min(260px, 56vw);
  height: 2px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(126, 214, 255, 0.12);
}

.chip-loader-bar::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 38%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, #ffd9a0 45%, #69d9f8 75%, transparent);
  animation: chip-bar 1.25s ease-in-out infinite;
}

@keyframes chip-dot {
  0%, 100% { opacity: .35; transform: scale(.7); }
  50% { opacity: 1; transform: scale(1); }
}

@keyframes chip-ellipsis {
  0% { clip-path: inset(0 100% 0 0); }
  100% { clip-path: inset(0 0 0 0); }
}

@keyframes chip-bar {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(320%); }
}

#matrix {
  text-shadow: 0 2px 28px rgba(1, 8, 16, .85), 0 0 8px rgba(1, 8, 16, .5);
}

body.theme-light .loader {
  background:
    radial-gradient(circle at 50% 42%, rgba(159, 212, 255, 0.10), transparent 34%),
    radial-gradient(circle at 50% 50%, #ffffff 0%, #f5fbfa 58%, #edf5fa 100%);
}
body.theme-light .chip-loader-caption {
  border-color: rgba(35, 140, 60, 0.32);
  background: rgba(255, 255, 255, 0.82);
  color: #52687c;
  box-shadow: 0 12px 32px rgba(21, 36, 53, 0.08);
}
body.theme-light .chip-loader-caption b { color: #238c3c; }
body.theme-light .chip-loader-caption i { background: #ffd9a0; box-shadow: 0 0 10px rgba(255, 217, 160, 0.75); }
body.theme-light .chip-loader-bar { background: rgba(21, 36, 53, 0.08); }
body.theme-light #matrix { text-shadow: 0 12px 44px rgba(55, 114, 160, 0.16); }

@media (max-width: 720px) {
  .chip-loader-caption {
    margin-top: 25vh;
    padding: 8px 14px;
    font-size: 10px;
    letter-spacing: .12em;
  }
  #matrix {
    font-size: 64px;
  }
}

@media (max-width: 400px) {
  #matrix {
    font-size: clamp(40px, 16vw, 64px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chip-loader-caption i,
  .chip-loader-caption em,
  .chip-loader-bar::after {
    animation: none;
  }
}
