/* ============================================================
   MOON · 赛博智脑界面
   视觉底子：IB/moon_yinyang.html（暗色底＋青色 HUD＋粒子阴阳盘）
   这是有意区别于草屋宋韵主站的另一个世界，故独立样式、独立配色。
   ============================================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --moon-bg: #02060f;
  --moon-cyan: #00f3ff;
  --moon-cyan-dim: rgba(0, 243, 255, 0.35);
  --moon-text: rgba(255, 255, 255, 0.85);
  --moon-panel: rgba(2, 8, 18, 0.65);
  --moon-line: rgba(0, 243, 255, 0.3);
  --mono: 'Courier New', Courier, monospace;
}

html, body {
  height: 100%;
}

body {
  background-color: var(--moon-bg);
  overflow: hidden;
  font-family: var(--mono);
  color: var(--moon-cyan);
}

/* ---------------- 背景层 ---------------- */

#rig-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
}

.grid-bg {
  position: fixed;
  inset: 0;
  background-size: 50px 50px;
  background-image:
    linear-gradient(to right, rgba(0, 243, 255, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 243, 255, 0.03) 1px, transparent 1px);
  z-index: 0;
}

.scan-line {
  position: fixed;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--moon-cyan);
  box-shadow: 0 0 15px var(--moon-cyan);
  opacity: 0.3;
  animation: scan 4s linear infinite;
  z-index: 3;
}

@keyframes scan {
  0%   { top: 0; }
  100% { top: 100%; }
}

/* ---------------- HUD 容器 ---------------- */

.hud {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

/* ---------------- 面板（含科幻边角） ---------------- */

.panel {
  position: absolute;
  width: 300px;
  padding: 20px;
  display: flex;          /* 左右两栏等高（top/bottom 同值），内部纵向排布 */
  flex-direction: column;
  background: var(--moon-panel);
  border: 1px solid var(--moon-line);
  box-shadow: 0 0 20px rgba(0, 243, 255, 0.1);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: auto;
}

.panel::before,
.panel::after {
  content: '';
  position: absolute;
  width: 15px;
  height: 15px;
  border: 2px solid var(--moon-cyan);
}

.panel::before {
  top: -2px;
  left: -2px;
  border-right: none;
  border-bottom: none;
}

.panel::after {
  bottom: -2px;
  right: -2px;
  border-left: none;
  border-top: none;
}

/* 两栏同顶同底＝等长；左栏内容自然高，TRANSCRIPT 吸收余量，
   右栏退出按钮 margin-top:auto 沉底 */
.hud-left  { top: 40px; left: 40px; bottom: 40px; }
.hud-right { top: 40px; right: 40px; bottom: 40px; }

.panel h2 {
  font-size: 14px;
  letter-spacing: 2px;
  margin-bottom: 15px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--moon-cyan-dim);
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(0, 243, 255, 0.5);
}

.panel h2.mt { margin-top: 30px; }

/* TRANSCRIPT 标题行：h2 底线占满，禁声按钮低视觉权重贴在右端 */
.transcript-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 15px;
}
.transcript-head.mt { margin-top: 30px; }
.transcript-head h2 { flex: 1; margin: 0; }

.mute-btn {
  flex: none;
  background: transparent;
  border: 1px solid var(--moon-line);
  color: var(--moon-text);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  padding: 3px 9px;
  margin-bottom: 5px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.mute-btn:hover {
  color: var(--moon-cyan);
  border-color: var(--moon-cyan-dim);
}
.mute-btn.is-muted {
  color: var(--moon-cyan);
  border-color: var(--moon-cyan-dim);
  background: rgba(0, 243, 255, 0.1);
}

/* ============ 语音交互头像：fox-head 浮出，听＝慢波，说＝连波 ============ */
.voice-avatar {
  position: fixed;
  left: 50%;
  top: 47%;
  width: 320px;
  height: 320px;
  margin: -160px 0 0 -160px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  z-index: 6;
  transition: opacity 0.35s ease;
}
.voice-avatar.is-listening,
.voice-avatar.is-speaking {
  opacity: 1;
}
.voice-avatar img {
  width: 286px;
  height: 286px;
  border-radius: 44%;
  border: 1px solid rgba(0, 243, 255, 0.35);
}

.va-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 286px;
  height: 286px;
  margin: -143px 0 0 -143px;
  border: 1px solid rgba(0, 243, 255, 0.5);
  border-radius: 50%;
  opacity: 0;
}

/* 聆听：一环缓慢呼吸 */
.is-listening .va-ring-1 { animation: va-breathe 2.6s ease-out infinite; }

/* MOON 回复：三环连续向外扩散 */
.is-speaking .va-ring-1 { animation:va-wave 1.8s ease-out infinite; }
.is-speaking .va-ring-2 { animation:va-wave 1.8s ease-out 0.6s infinite; }
.is-speaking .va-ring-3 { animation:va-wave 1.8s ease-out 1.2s infinite; }
.is-speaking img { animation: va-glow 1.4s ease-in-out infinite; }

@keyframes va-breathe {
  0%   { transform: scale(1);    opacity: 0.55; }
  70%  { transform: scale(1.16); opacity: 0.12; }
  100% { transform: scale(1.16); opacity: 0; }
}
@keyframes va-wave {
  0%   { transform: scale(1);    opacity: 0.7; }
  100% { transform: scale(1.42); opacity: 0; }
}
@keyframes va-glow {
  0%, 100% { filter: drop-shadow(0 0 10px rgba(0, 243, 255, 0.35)); }
  50%      { filter: drop-shadow(0 0 22px rgba(0, 243, 255, 0.75)); }
}

@media (prefers-reduced-motion: reduce) {
  .is-listening .va-ring-1 { animation: none; opacity: 0.4; transform: scale(1.05); }
  .is-speaking .va-ring-1,
  .is-speaking .va-ring-2,
  .is-speaking .va-ring-3,
  .is-speaking img { animation: none; }
  .is-speaking .va-ring-1 { opacity: 0.5; transform: scale(1.08); }
}

.data-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  margin-bottom: 10px;
  color: var(--moon-text);
}

.data-value {
  color: var(--moon-cyan);
  font-weight: bold;
}

/* ---------------- session uptime 流动进度条 ----------------
   细槽样式不变；亮区由 brain-boot.js 驱动，自左向右流动着充满
   （8 秒，与欢迎播报等长），充满即代表加载与播报完成。 */

.progress-bar {
  width: 100%;
  height: 6px;
  margin: 15px 0;
  position: relative;
  overflow: hidden;
  background: rgba(0, 243, 255, 0.1);
}

.progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 100%;
  background: var(--moon-cyan);
  box-shadow: 0 0 10px var(--moon-cyan);
}

/* SYSTEM LOG：限定高度可滚；滑轨隐藏，鼠标靠近才显出，青色与整体协调 */
.sys-log {
  max-height: 130px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.sys-log:hover { scrollbar-color: rgba(0, 243, 255, 0.35) transparent; }

.sys-log::-webkit-scrollbar { width: 6px; }
.sys-log::-webkit-scrollbar-track { background: transparent; }
.sys-log::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 3px;
}
.sys-log:hover::-webkit-scrollbar-thumb { background: rgba(0, 243, 255, 0.28); }
.sys-log::-webkit-scrollbar-thumb:hover { background: rgba(0, 243, 255, 0.5); }

.log-line {
  font-size: 12px;
  line-height: 1.7;
  color: rgba(0, 243, 255, 0.6);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------------- 转写/对话流：并入 SYSTEM DATA 面板内，同框延续 ---------------- */

.transcript {
  display: flex;
  flex-direction: column;
  flex: 1;               /* 等高布局下吸收左栏余量；不再写死高度 */
  min-height: 120px;
}

.transcript-hint {
  margin: auto;
  font-size: 12px;
  letter-spacing: 2px;
  color: rgba(0, 243, 255, 0.4);
  text-align: center;
}

.transcript-body {
  display: none;
  flex: 1;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.75;
  letter-spacing: 0.5px;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.transcript-body:hover { scrollbar-color: rgba(0, 243, 255, 0.35) transparent; }

.transcript-body::-webkit-scrollbar { width: 6px; }
.transcript-body::-webkit-scrollbar-track { background: transparent; }
.transcript-body::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 3px;
}
.transcript-body:hover::-webkit-scrollbar-thumb { background: rgba(0, 243, 255, 0.28); }
.transcript-body::-webkit-scrollbar-thumb:hover { background: rgba(0, 243, 255, 0.5); }

.transcript.has-content .transcript-hint { display: none; }
.transcript.has-content .transcript-body { display: block; }

.t-line { margin-bottom: 12px; white-space: pre-wrap; word-break: break-word; }
.t-line .t-who {
  display: block;
  font-size: 11px;
  letter-spacing: 2px;
  color: rgba(0, 243, 255, 0.55);
  margin-bottom: 2px;
}
.t-line.user .t-text { color: rgba(255, 255, 255, 0.9); }
.t-line.moon .t-text { color: var(--moon-cyan); text-shadow: 0 0 8px rgba(0,243,255,.25); }
.t-line.interim .t-text { color: rgba(255, 255, 255, 0.5); font-style: italic; }

/* ---------------- 中心：MOON ---------------- */

.center-target {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-shadow: 0 2px 10px rgba(2, 6, 15, 0.9), 0 0 12px var(--moon-cyan);
  pointer-events: none;
}

.center-target h1 {
  font-size: 38px;
  letter-spacing: 10px;
  font-weight: bold;
}

.center-target p {
  margin-top: 10px;
  font-size: 12px;
  letter-spacing: 4px;
  color: #fff;
  opacity: 0.9;
}

/* ---------------- 右侧控制 ---------------- */

.ctrl-text {
  display: flex;
  flex-direction: column;   /* 多行输入在上、发送在下 */
  gap: 8px;
  margin-bottom: 12px;
}

#text-input {
  display: block;
  width: 100%;              /* 占满栏宽：比旧的并排输入更宽，容得下长文本 */
  min-height: 84px;         /* 约 4 行 */
  max-height: 260px;        /* 超过即在内部滚动，滑轨隐藏（见下） */
  resize: none;
  line-height: 1.6;
  background: rgba(0, 243, 255, 0.06);
  border: 1px solid var(--moon-line);
  color: var(--moon-text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 8px 10px;
  outline: none;
  overflow-y: auto;
  scrollbar-width: none;          /* Firefox：隐藏滑轨 */
  -ms-overflow-style: none;
}

#text-input::-webkit-scrollbar {  /* Chromium / Safari：隐藏滑轨 */
  width: 0;
  height: 0;
}

#text-input::placeholder { color: rgba(0, 243, 255, 0.35); }
#text-input:focus { border-color: var(--moon-cyan); box-shadow: 0 0 10px rgba(0,243,255,.15); }

#send-btn { width: 100%; }

.ctrl-row {
  display: flex;
  gap: 8px;
}

.ctrl-btn {
  flex: 1;
  background: rgba(0, 243, 255, 0.08);
  border: 1px solid var(--moon-line);
  color: var(--moon-cyan);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 1px;
  padding: 8px 6px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}

.ctrl-btn.wide { display: flex; align-items: center; justify-content: center; gap: 6px; }

.ctrl-btn:hover:not(:disabled) {
  background: rgba(0, 243, 255, 0.16);
  box-shadow: 0 0 12px rgba(0, 243, 255, 0.2);
}

.ctrl-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.ctrl-btn.is-active {
  background: rgba(0, 243, 255, 0.22);
  box-shadow: 0 0 14px rgba(0, 243, 255, 0.35);
}

.ctrl-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--moon-cyan);
  box-shadow: 0 0 8px var(--moon-cyan);
}

.exit-btn {
  display: block;
  margin-top: auto;   /* 沉到右栏底部；与左栏下沿齐平 */
  text-align: center;
  font-size: 12px;
  letter-spacing: 1px;
  color: rgba(0, 243, 255, 0.7);
  text-decoration: none;
  border: 1px solid rgba(0, 243, 255, 0.2);
  padding: 9px;
  pointer-events: auto;
  transition: background 0.2s;
}

.exit-btn:hover { background: rgba(0, 243, 255, 0.1); }

/* ---------------- 降级与窄屏（细化在收尾阶段） ---------------- */

@media (max-width: 64rem) {
  .hud-left  { top: 16px; left: 16px; bottom: 16px; width: 220px; padding: 12px; }
  .hud-right { top: 16px; right: 16px; bottom: 16px; width: 220px; padding: 12px; }
  .transcript { min-height: 80px; }
  #text-input { min-height: 64px; }
  .center-target h1 { font-size: 28px; letter-spacing: 7px; }
  .voice-avatar { width: 240px; height: 240px; top: 50%; margin: -120px 0 0 -120px; }
  .voice-avatar img { width: 214px; height: 214px; }
  .va-ring { width: 214px; height: 214px; margin: -107px 0 0 -107px; }
}

@media (prefers-reduced-motion: reduce) {
  .scan-line { animation: none; }
  .progress-fill { width: 100%; }
}
