/* ============================================================================
   指尖花开 · MediaPipe Hands × Three.js WebGL 极奢玻璃拟物交互样式表
   ============================================================================ */

:root {
  --bg-dark: #0a0c16;
  --panel-bg: rgba(15, 20, 36, 0.72);
  --panel-border: rgba(255, 255, 255, 0.12);
  --accent-pink: #ff5f9e;
  --accent-purple: #9d4edd;
  --accent-cyan: #00f5d4;
  --accent-gold: #ffd166;
  --text-main: #f8fafc;
  --text-dim: #94a3b8;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: var(--font-family);
  color: var(--text-main);
  user-select: none;
}

/* ----------------------------------------------------------------------------
   1. 画布与底层视频层级管理
   ---------------------------------------------------------------------------- */

/* 摄像头视频与手部骨骼 Canvas 容器 */
#camera-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
}

#webcam-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* 镜像翻转符合自拍直觉 */
  opacity: 0.35;
  transition: opacity 0.2s ease;
}

#landmark-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* 骨骼同步镜像 */
  z-index: 2;
  pointer-events: none;
}

/* Three.js 3D 粒子渲染层 */
#webgl-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: auto;
}

#webgl-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* ----------------------------------------------------------------------------
   2. 毛玻璃质感组件与 HUD 仪表盘
   ---------------------------------------------------------------------------- */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--panel-border);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  border-radius: 18px;
}

#hud-panel {
  position: absolute;
  top: 24px;
  left: 24px;
  z-index: 10;
  width: 340px;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

/* 隐藏滚动条但保留滚动能力 */
#hud-panel::-webkit-scrollbar {
  width: 4px;
}
#hud-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #ffffff 40%, var(--accent-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #64748b;
  box-shadow: 0 0 6px rgba(100, 116, 139, 0.5);
  transition: all 0.3s;
}

.status-dot.ready {
  background: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan);
}

.status-dot.loading {
  background: var(--accent-gold);
  box-shadow: 0 0 10px var(--accent-gold);
}

.status-dot.error {
  background: #ef4444;
  box-shadow: 0 0 10px #ef4444;
}

.status-desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ----------------------------------------------------------------------------
   3. 进度条与指标组
   ---------------------------------------------------------------------------- */
.metrics-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.metric-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.metric-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}

.metric-label span:last-child {
  font-family: monospace;
  font-size: 13px;
  color: #fff;
}

.progress-bar {
  position: relative;
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4cc9f0, #ff5f9e);
  border-radius: 6px;
  transition: width 0.06s linear;
}

.progress-fill.spread-fill {
  background: linear-gradient(90deg, #ff5f9e, #ffd166, #00f5d4);
}

.threshold-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255, 255, 255, 0.4);
  z-index: 2;
  border-right: 1px dashed rgba(255, 255, 255, 0.8);
}

/* 手势状态 Badge */
.gesture-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.3s;
}

.badge.bud {
  background: rgba(0, 245, 212, 0.15);
  border-color: rgba(0, 245, 212, 0.35);
  color: var(--accent-cyan);
  box-shadow: 0 0 12px rgba(0, 245, 212, 0.25);
}

.badge.bloom {
  background: rgba(255, 95, 158, 0.18);
  border-color: rgba(255, 95, 158, 0.4);
  color: var(--accent-pink);
  box-shadow: 0 0 14px rgba(255, 95, 158, 0.35);
}

.badge.blooming {
  background: rgba(255, 209, 102, 0.15);
  border-color: rgba(255, 209, 102, 0.35);
  color: var(--accent-gold);
}

/* ----------------------------------------------------------------------------
   4. 参数调节控件
   ---------------------------------------------------------------------------- */
.controls-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.control-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-item label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
}

.control-item label span:last-child {
  font-family: monospace;
  color: #fff;
}

.control-toggles {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
}

/* 滑块样式 */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-pink);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(255, 95, 158, 0.6);
  transition: transform 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

input[type="checkbox"] {
  accent-color: var(--accent-pink);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* ----------------------------------------------------------------------------
   5. 摄像头异常与模拟模式弹窗
   ---------------------------------------------------------------------------- */
.modal {
  position: absolute;
  inset: 0;
  z-index: 100;
  background: rgba(10, 12, 22, 0.85);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  transition: opacity 0.3s;
}

.modal.hidden {
  opacity: 0;
  pointer-events: none;
  display: none;
}

.modal-content {
  max-width: 440px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-content h2 {
  font-size: 18px;
  color: #fff;
}

.modal-content p {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-dim);
}

.error-tips {
  font-size: 12px;
  color: var(--text-dim);
  padding-left: 18px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.error-tips code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  color: #fff;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.btn {
  flex: 1;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-align: center;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-purple));
  color: #fff;
  box-shadow: 0 4px 16px rgba(255, 95, 158, 0.4);
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 95, 158, 0.6);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.hidden {
  display: none !important;
}

/* 移动端适配 */
@media (max-width: 768px) {
  #hud-panel {
    top: 12px;
    left: 12px;
    right: 12px;
    width: auto;
    padding: 16px;
  }
}
