/* ============================================================
   scene: terminal — 黑客终端 · CRT 复古
   黑底 #0a0f0a / 绿字 #00ff66(主) #00cc52(辅) / JetBrains Mono
   ============================================================ */

.scene-terminal {
  --tg: #00ff66;
  --tg2: #00cc52;
  --tg-dim: rgba(0, 204, 82, 0.62);
  --tg-faint: rgba(0, 255, 102, 0.16);
  --bg: #0a0f0a;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--tg);
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  -webkit-font-smoothing: antialiased;
}

/* ---- CRT 容器（内部定位上下文） ---- */
.scene-terminal__crt {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(130% 120% at 50% 38%, #0e160e 0%, var(--bg) 58%, #050805 100%);
}

/* ---- 背景巨字水印 ---- */
.scene-terminal__bg-title {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Noto Sans SC', sans-serif;
  font-weight: 900;
  font-size: clamp(3rem, 15vw, 12rem);
  letter-spacing: 0.12em;
  white-space: nowrap;
  color: rgba(0, 255, 102, 0.045);
  text-shadow: none;
  pointer-events: none;
  user-select: none;
}

/* ---- 顶部窗口栏 ---- */
.scene-terminal__bar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 38px;
  padding: 0 clamp(12px, 3vw, 22px);
  border-bottom: 1px solid rgba(0, 255, 102, 0.22);
  background: rgba(0, 20, 8, 0.55);
  font-size: clamp(0.62rem, 2vw, 0.75rem);
  color: var(--tg2);
  text-shadow: 0 0 6px rgba(0, 204, 82, 0.5);
}
.scene-terminal__dots {
  display: inline-flex;
  gap: 6px;
  flex: 0 0 auto;
}
.scene-terminal__dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid var(--tg2);
  background: transparent;
}
.scene-terminal__dots i:first-child {
  background: var(--tg2);
  box-shadow: 0 0 8px rgba(0, 204, 82, 0.8);
}
.scene-terminal__bar-title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  letter-spacing: 0.06em;
}
.scene-terminal__bar-status {
  margin-left: auto;
  flex: 0 0 auto;
  color: var(--tg);
  animation: scene-terminal-pwr 2.4s steps(2) infinite;
}

/* ---- 屏幕（滚动区） ---- */
.scene-terminal__screen {
  position: absolute;
  inset: 38px 0 0 0;
  z-index: 2;
  overflow-y: auto;
  overflow-x: hidden;
  padding: clamp(14px, 3vw, 30px) clamp(14px, 3.5vw, 34px) 56px;
  font-size: clamp(0.72rem, 2.6vw, 0.95rem);
  line-height: 1.62;
  letter-spacing: 0.02em;
  text-shadow:
    0 0 6px rgba(0, 255, 102, 0.55),
    0 0 20px rgba(0, 255, 102, 0.16);
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 255, 102, 0.35) transparent;
  animation: scene-terminal-flicker 7s linear infinite;
}
.scene-terminal__screen::-webkit-scrollbar { width: 6px; }
.scene-terminal__screen::-webkit-scrollbar-thumb { background: rgba(0, 255, 102, 0.3); }
.scene-terminal__screen::-webkit-scrollbar-track { background: transparent; }

/* ---- 文本行 ---- */
.scene-terminal__line {
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 1em;
}
.scene-terminal__line--dim { color: var(--tg-dim); text-shadow: none; }
.scene-terminal__line--bright {
  color: var(--tg);
  font-weight: 700;
  text-shadow: 0 0 8px rgba(0, 255, 102, 0.85), 0 0 26px rgba(0, 255, 102, 0.3);
}
.scene-terminal__line--err { color: var(--tg2); font-weight: 700; }
.scene-terminal__line--cmd { margin-top: 0.35em; }
.scene-terminal__promptInline {
  color: var(--tg2);
  font-weight: 700;
  text-shadow: 0 0 6px rgba(0, 204, 82, 0.6);
}

/* ---- 输入行 ---- */
.scene-terminal__inputline {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  margin-top: 0.35em;
  word-break: break-all;
}
.scene-terminal__inputline[hidden] { display: none; }
.scene-terminal__prompt {
  flex: 0 0 auto;
  margin-right: 0.6em;
  color: var(--tg2);
  font-weight: 700;
  text-shadow: 0 0 6px rgba(0, 204, 82, 0.6);
}
.scene-terminal__typed {
  white-space: pre-wrap;
  word-break: break-all;
}
.scene-terminal__cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.08em;
  margin-left: 2px;
  vertical-align: -0.16em;
  background: var(--tg);
  box-shadow: 0 0 8px rgba(0, 255, 102, 0.9), 0 0 22px rgba(0, 255, 102, 0.4);
  animation: scene-terminal-blink 1.06s steps(1) infinite;
}

/* ---- 隐藏输入框（移动端唤起键盘用） ---- */
.scene-terminal__ghost {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 4;
  width: 100%;
  height: 44px;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  opacity: 0.01;
  font-size: 16px; /* 防 iOS 聚焦自动缩放 */
}

/* ---- CRT 质感叠加层 ---- */
.scene-terminal__scanlines {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.32) 0px,
    rgba(0, 0, 0, 0.32) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: multiply;
}
.scene-terminal__beam {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 5;
  height: 130px;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(0, 255, 102, 0.05) 45%,
    rgba(0, 255, 102, 0.09) 55%,
    transparent 100%
  );
  animation: scene-terminal-beam 7.5s linear infinite;
}
.scene-terminal__vignette {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(0, 0, 0, 0.5) 100%);
  box-shadow: inset 0 0 18vmin rgba(0, 0, 0, 0.85);
}

/* ---- 底部提示 ---- */
.scene-terminal__hint {
  position: absolute;
  right: 14px;
  bottom: 10px;
  z-index: 7;
  pointer-events: none;
  font-size: clamp(0.58rem, 1.8vw, 0.68rem);
  color: var(--tg-dim);
  letter-spacing: 0.08em;
  text-shadow: 0 0 6px rgba(0, 204, 82, 0.4);
}

/* ---- 动画 ---- */
@keyframes scene-terminal-blink {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}
@keyframes scene-terminal-beam {
  0%   { transform: translateY(-140px); }
  100% { transform: translateY(110vh); }
}
@keyframes scene-terminal-flicker {
  0%, 100% { opacity: 1; }
  91%      { opacity: 1; }
  92%      { opacity: 0.965; }
  93%      { opacity: 1; }
  95%      { opacity: 0.985; }
  96%      { opacity: 1; }
}
@keyframes scene-terminal-pwr {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

/* ---- 移动端微调 ---- */
@media (max-width: 480px) {
  .scene-terminal__bar-status { display: none; }
  .scene-terminal__screen { padding-bottom: 64px; }
}

/* ---- 减少动态偏好 ---- */
@media (prefers-reduced-motion: reduce) {
  .scene-terminal__screen,
  .scene-terminal__beam,
  .scene-terminal__bar-status,
  .scene-terminal__cursor {
    animation: none;
  }
}
