/* =========================================================================
   Bottom Deck Module Styles (赛博命令行控制台 · Cyber CLI Terminal)
   职责：
   1. 屏幕底部常驻呼出拉手 (默认收起，始终可见)
   2. 拉起后刚好触及 [STAGE_01 // CCTV SURVEILLANCE FEED] 栏下方
   3. 完美继承并具备与中心监视器有图片时 100% 相同款的特效：
      - 通透冷翠微绿滤镜层 (.scope-sheer-green-veil)
      - 极弱水平光栅微细扫描线 (.scope-scanlines-layer)
      - 屏幕透镜暗角暗框 (.scope-vignette-glass) 与取景 HUD 直角准星
   4. 命令行全文允许自由复制与文字划选 (Selection Copy Support)
   5. 个人导航超链接样式 (悬停加粗 + 底部加横杠，严格等宽制表对齐)
   ========================================================================= */

/* =========================================================================
   1. 屏幕底栏常驻命令行拉手 (Bottom Expand Tab)
   ========================================================================= */
.bottom-expand-tab {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 22px;
  padding: 0 14px 2px;
  background: rgba(6, 14, 10, 0.85);
  border: 1px solid rgba(52, 211, 153, 0.2);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  color: rgba(110, 231, 183, 0.55);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.25s ease,
              background-color 0.2s ease,
              border-color 0.2s ease,
              color 0.2s ease,
              box-shadow 0.25s ease;
  outline: none;
  user-select: none;
}

/* 默认收起状态下：常驻可见，静默融入底栏，绝不喧宾夺主 */
.bottom-expand-tab.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.bottom-expand-tab:hover {
  background: rgba(8, 22, 15, 0.95);
  border-color: rgba(52, 211, 153, 0.5);
  color: var(--emerald-bright);
  box-shadow: 0 -3px 14px rgba(0, 0, 0, 0.8), 0 0 10px rgba(16, 185, 129, 0.16);
  transform: translateX(-50%) translateY(-1.5px);
}

.cli-pill-icon {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 10px;
  color: rgba(52, 211, 153, 0.65);
  transition: color 0.2s ease;
}

.bottom-expand-tab:hover .cli-pill-icon {
  color: var(--emerald-bright);
  text-shadow: 0 0 5px var(--emerald-bright);
}

.cli-pill-title {
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.8px;
  transition: color 0.2s ease;
}

.cli-pill-arrow {
  font-size: 8px;
  opacity: 0.5;
  transform: translateY(-0.5px);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.bottom-expand-tab:hover .cli-pill-arrow {
  opacity: 1;
  transform: translateY(-1.5px);
}

/* =========================================================================
   2. 赛博命令行控制台覆盖层 (Cyber CLI Terminal Overlay)
   拉起后精确对齐 [STAGE_01 // CCTV SURVEILLANCE FEED] 顶栏下方
   ========================================================================= */
.cli-terminal-overlay {
  position: fixed;
  top: var(--cli-top, calc(var(--layout-padding, 10px) + 38px));
  bottom: var(--layout-padding, 10px);
  left: var(--layout-padding, 10px);
  right: var(--layout-padding, 10px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.25s ease;
  user-select: text;
}

/* 拉起状态：平滑升起，刚好停留在顶栏下方 */
.cli-terminal-overlay.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* =========================================================================
   3. 终端屏幕与 CRT 滤镜层 (与中心监视器有图片时 100% 保持一致)
   ========================================================================= */
.cli-screen {
  position: relative;
  width: 100%;
  height: 100%;
  background: #040906; /* 与主视窗 cctv-screen 完全同款底色 */
  border: 1px solid var(--border-bright);
  border-radius: 0 0 4px 4px;
  box-shadow: 0 12px 42px rgba(0, 0, 0, 0.95), 0 0 20px rgba(16, 185, 129, 0.15);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  user-select: text;
}

/* 终端屏幕通用高亮复制选区样式 */
.cli-screen ::selection,
.cli-screen::selection {
  background: rgba(16, 185, 129, 0.4);
  color: #ffffff;
  text-shadow: 0 0 6px var(--emerald-bright);
}

/* =========================================================================
   3. 终端屏幕视口与 CRT 滤镜层 (独立隔离于视口内，绝对不遮罩顶栏按键)
   ========================================================================= */
.cli-viewport {
  position: relative;
  flex: 1;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 终端屏幕内部 CRT 滤镜层：只覆盖视口本身，绝不上浮遮挡顶栏关闭按钮 */
.cli-viewport .scope-sheer-green-veil {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(16, 185, 129, 0.05) 0%,
    rgba(5, 35, 22, 0.16) 100%
  );
}

/* 核心优化：1px 精致显像管隔行光栅横条 */
.cli-viewport .scope-scanlines-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.32) 0px,
    rgba(0, 0, 0, 0.32) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.9;
}

.cli-viewport .scope-vignette-glass {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 7;
  background: radial-gradient(
    circle at 50% 50%,
    transparent 70%,
    rgba(2, 10, 6, 0.22) 90%,
    rgba(0, 6, 3, 0.5) 100%
  );
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

/* =========================================================================
   4. 终端顶栏与控制按钮 (Terminal Header Bar)
   ========================================================================= */
.cli-header-bar {
  height: 34px;
  background: rgba(5, 12, 9, 0.95);
  border-bottom: 1px solid rgba(52, 211, 153, 0.25);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  user-select: none;
}

.cli-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cli-term-icon {
  font-weight: 800;
  color: var(--emerald-bright);
  font-size: 13px;
  text-shadow: 0 0 6px var(--emerald-glow);
}

.cli-header-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--emerald-bright);
}

.cli-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cli-status-tag {
  font-size: 9px;
  color: var(--emerald-pale);
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.28);
  padding: 1px 6px;
  border-radius: 2px;
  letter-spacing: 0.5px;
}

.cli-btn-action {
  height: 20px;
  padding: 0 8px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 2px;
  color: var(--emerald-bright);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  user-select: none;
}

.cli-btn-action:hover {
  background: rgba(16, 185, 129, 0.28);
  border-color: var(--emerald-bright);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.4);
  color: #fff;
}

.cli-btn-action.btn-danger:hover {
  background: rgba(239, 68, 68, 0.35);
  border-color: #ef4444;
  color: #fff;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

/* =========================================================================
   5. 终端流输出区与互动输入行 (Terminal Body & Copy-enabled Content)
   ========================================================================= */
.cli-body {
  min-height: 0;
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  line-height: 1.55;
  letter-spacing: 0.5px;
  cursor: text;
  user-select: text;
}

/* 终端极细赛博滚动条 */
.cli-body::-webkit-scrollbar {
  width: 6px;
}

.cli-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.4);
}

.cli-body::-webkit-scrollbar-thumb {
  background: rgba(52, 211, 153, 0.3);
  border-radius: 3px;
}

.cli-body::-webkit-scrollbar-thumb:hover {
  background: var(--emerald-bright);
}

/* 欢迎 Banner (允许选中与复制) */
.cli-welcome-banner {
  position: relative;
  flex: 0 0 auto;
  padding: 12px 20px 0;
  color: var(--emerald-bright);
  font-size: 11px;
  line-height: 1.4;
  text-shadow: 0 0 6px rgba(52, 211, 153, 0.3);
  margin-bottom: 6px;
  user-select: text;
}

@media (max-height: 600px), (max-width: 600px) {
  .cli-welcome-banner .cli-nav-table { gap:4px; }
  .cli-welcome-banner .cli-nav-line { gap:8px; }
  .cli-welcome-banner .cli-cmd-link { min-width:64px; }
  .cli-welcome-banner .cli-nav-desc { font-size:11px; }
  .cli-welcome-banner .cli-banner-divider { overflow:hidden; white-space:nowrap; }
  .cli-welcome-banner .cli-banner-hint { font-size:10px; }
}

.cli-banner-title {
  font-weight: 700;
  font-size: 12px;
  color: #ffffff;
  margin: 3px 0;
  text-shadow: 0 0 8px var(--emerald-bright);
}

.cli-banner-sub,
.cli-banner-desc,
.cli-banner-hint {
  color: var(--emerald-pale);
  opacity: 0.9;
}

.cli-banner-hint {
  color: #6ee7b7;
  font-weight: 600;
  margin: 6px 0 4px;
}

.cli-banner-keys {
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1.6;
}

/* =========================================================================
   6. 个人导航超链接样式 (Hyperlink: 鼠标悬停加粗 + 底部加横杠，严格排版对齐)
   ========================================================================= */
.cli-nav-table {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 8px 0;
  padding-left: 2px;
  user-select: text;
}

.cli-nav-line {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: var(--font-mono);
  user-select: text;
}

/* 超链接核心样式 (非按钮，无背景无边框) */
.cli-cmd-link {
  color: var(--emerald-bright);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.8px;
  cursor: pointer;
  display: inline-block;
  min-width: 86px; /* 严格等宽对齐，保证后续破折号与描述垂直对齐 */
  text-decoration: none;
  background: transparent;
  border: none;
  padding: 1px 0;
  margin: 0;
  outline: none;
  transition: color 0.15s ease, font-weight 0.1s ease;
  user-select: text;
}

/* 鼠标悬停效果：加粗 + 下面加横杠 */
.cli-cmd-link:hover {
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1.5px;
  text-decoration-color: var(--emerald-bright);
  color: #ffffff;
  text-shadow: 0 0 8px var(--emerald-bright);
}

.cli-cmd-link:active {
  color: #a7f3d0;
}

.cli-cmd-link:focus-visible {
  outline: 1px solid var(--emerald-bright);
  outline-offset: 3px;
}

.cli-nav-desc {
  color: #a7f3d0;
  font-size: 12px;
  letter-spacing: 0.5px;
  user-select: text;
}

/* 导航卡片输出样式 (允许划选复制) */
.cli-card-box {
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-left: 3px solid var(--emerald-bright);
  background: rgba(16, 185, 129, 0.05);
  padding: 10px 14px;
  border-radius: 2px;
  margin: 4px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  line-height: 1.5;
  user-select: text;
}

.cli-card-title {
  color: var(--emerald-bright);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1px;
  user-select: text;
}

.cli-card-row {
  display: flex;
  gap: 12px;
  user-select: text;
}

.cli-card-key {
  color: var(--emerald-pale);
  min-width: 70px;
  font-weight: 600;
  user-select: text;
}

.cli-card-val {
  color: #ffffff;
  user-select: text;
}

.cli-card-hint {
  color: var(--text-dim);
  font-size: 10px;
  margin-top: 4px;
  border-top: 1px dashed rgba(52, 211, 153, 0.2);
  padding-top: 4px;
  user-select: text;
}

/* 输出记录区 (完全允许复制) */
.cli-output-log {
  display: flex;
  flex-direction: column;
  gap: 4px;
  user-select: text;
}

.cli-log-entry {
  display: flex;
  flex-direction: column;
  gap: 2px;
  user-select: text;
}

.cli-log-cmd {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #ffffff;
  font-weight: 600;
  user-select: text;
}

.cli-log-cmd .cli-prompt-char {
  color: var(--emerald-bright);
}

.cli-log-response {
  color: var(--emerald-pale);
  white-space: pre-wrap;
  word-break: break-all;
  padding-left: 12px;
  border-left: 2px solid rgba(52, 211, 153, 0.25);
  margin: 2px 0 6px;
  user-select: text;
}

.cli-log-response.error {
  color: #f87171;
  border-left-color: #ef4444;
}

.cli-log-response.success {
  color: #6ee7b7;
}

/* 当前活动输入行 */
.cli-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  position: relative;
}

.cli-prompt-user {
  color: #34d399;
  font-weight: 700;
  user-select: text;
}

.cli-prompt-symbol {
  color: var(--text-dim);
}

.cli-prompt-path {
  color: #60a5fa;
  font-weight: 600;
  user-select: text;
}

.cli-prompt-char {
  color: var(--emerald-bright);
  font-weight: 800;
}

.cli-input-field {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  caret-color: var(--emerald-bright);
  padding: 0;
  margin: 0;
  user-select: text;
}

.cli-cursor {
  display: none; /* Use the real caret so it follows typing, selection and arrow keys. */
  color: var(--emerald-bright);
  font-size: 12px;
  animation: blinkCursor 1s step-end infinite;
  pointer-events: none;
  margin-left: -2px;
}

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

/* =========================================================================
   7. 终端底栏状态与遥测 (Terminal Footer Bar)
   ========================================================================= */
.cli-footer-bar {
  height: 28px;
  background: rgba(4, 9, 6, 0.96);
  border-top: 1px solid rgba(52, 211, 153, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  font-size: 10px;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  user-select: none;
}

.cli-footer-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.cli-footer-left b {
  color: var(--emerald-pale);
  font-weight: 600;
}

.cli-footer-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

#cli-live-time {
  color: var(--emerald-bright);
  font-weight: 600;
  letter-spacing: 1px;
}

/* =========================================================================
   8. 命令行 Login 动态握手交互动效 (CLI Login Flow Animation)
   ========================================================================= */
.cli-login-flow {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 4px 0 6px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.cli-login-line {
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.5;
  color: var(--emerald-pale);
  font-family: var(--font-mono);
}

.cli-login-badge {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 56px;
  min-width: 56px;
  max-width: 56px;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.6px;
  box-sizing: border-box;
}

.cli-login-sep {
  color: rgba(52, 211, 153, 0.4);
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.cli-login-text {
  flex: 1;
  font-family: var(--font-mono);
}

.cli-login-line.is-pending .cli-login-badge {
  color: #fbbf24;
  text-shadow: 0 0 6px rgba(251, 191, 36, 0.4);
}

.cli-login-line.is-success .cli-login-badge {
  color: var(--emerald-bright);
  text-shadow: 0 0 6px var(--emerald-glow);
}

.cli-login-line.is-launching .cli-login-badge {
  color: #60a5fa;
  text-shadow: 0 0 6px rgba(96, 165, 250, 0.4);
}

.cli-login-dots {
  display: inline-block;
  animation: cli-login-pulse 1s infinite steps(4, jump-none);
  color: #fbbf24;
}

@keyframes cli-login-pulse {
  0%, 20% { opacity: 0.25; }
  50% { opacity: 0.7; }
  100% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .cli-login-dots {
    animation: none;
  }
}

/* A reply owns the terminal until its final character has arrived. */
.cli-input-row[hidden],
.cli-input-row.is-farewell-waiting {
  display: none;
}

.cli-farewell-line {
  min-height: 1.7em;
  line-height: 1.7;
  white-space: pre-wrap;
  color: #b8cec4;
  letter-spacing: 0.035em;
}

.is-farewell-pending .cli-header-right {
  visibility: hidden;
}

.farewell-active .workspace-layout {
  opacity: 0.12;
  filter: grayscale(1);
  transition: opacity 2.4s ease, filter 2.4s ease;
}

.farewell-active .cli-welcome-banner,
.farewell-active .cli-footer-bar {
  transition: opacity 2s ease;
  opacity: 0.3;
}

.is-forgetting {
  animation: forget-terminal-line 1.05s steps(8, end) var(--forget-delay, 0ms) forwards;
  pointer-events: none;
}

@keyframes forget-terminal-line {
  0% { opacity: 1; }
  35% { opacity: 0.5; clip-path: polygon(0 0, 88% 0, 88% 38%, 100% 38%, 100% 100%, 0 100%); }
  65% { opacity: 0.25; clip-path: polygon(0 0, 54% 0, 54% 65%, 79% 65%, 79% 100%, 0 100%); }
  100% { opacity: 0; clip-path: inset(0 100% 0 0); }
}

.is-farewell-pending .cli-body,
.is-farewell-pending .cli-header-bar,
.is-farewell-pending .cli-welcome-banner,
.is-farewell-pending .cli-footer-bar {
  transition: opacity 700ms ease;
}

.is-farewell-clearing .cli-body,
.is-farewell-clearing .cli-header-bar,
.is-farewell-clearing .cli-welcome-banner,
.is-farewell-clearing .cli-footer-bar {
  opacity: 0;
  pointer-events: none;
}

/* Keep the viewport and its bottom-right signature anchored during farewell. */
.is-farewell-empty .cli-header-bar,
.is-farewell-empty .cli-footer-bar {
  visibility: hidden;
  opacity: 0;
}

.is-farewell-empty .cli-welcome-banner {
  display: none;
}

.is-farewell-empty .cli-body {
  overflow-anchor: none;
  scroll-behavior: auto;
}

/* Reserve the prompt's space before goodbye starts, then fade it in. */
.is-farewell-empty .cli-input-row {
  transition: opacity 700ms ease;
}

.is-farewell-empty .cli-input-row[hidden],
.is-farewell-empty .cli-input-row.is-farewell-waiting {
  display: flex;
  visibility: hidden;
  opacity: 0;
}

.cli-farewell-goodbye {
  color: #c3d0c9;
  margin-bottom: 12px;
}

@media (prefers-reduced-motion: reduce) {
  .is-farewell-pending .cli-body,
  .is-farewell-pending .cli-header-bar,
  .is-farewell-pending .cli-welcome-banner,
  .is-farewell-pending .cli-footer-bar,
  .is-farewell-empty .cli-input-row { transition: none; }
  .farewell-active .workspace-layout,
  .farewell-active .cli-welcome-banner,
  .farewell-active .cli-footer-bar { transition: none; }
  .is-forgetting { animation: none; opacity: 0; }
}
