/**
 * css/hand-tracking/ht-panel.css
 *
 * PURPOSE: Floating hand-tracking control panel.
 *          Draggable, collapsible, with camera preview PiP.
 *          Uses CSS custom properties from the app's design-tokens.css.
 */

/* ── Root container ─────────────────────────────────────────────────────── */
#ht-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;

  width: 280px;
  background: var(--surface, #1a1f2e);
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: 16px;
  box-shadow:
    0 8px 32px rgba(0,0,0,0.4),
    0 2px 8px  rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.06);

  font-family: var(--font-ui, 'Inter', sans-serif);
  font-size: 13px;
  color: var(--text, #e8eaf0);
  user-select: none;

  /* Smooth open/close animation */
  transition: opacity 0.25s ease, transform 0.25s ease, width 0.3s ease;
  will-change: transform;
}

/* Panel appears from bottom-right */
#ht-panel.ht-entering {
  opacity: 0;
  transform: translateY(16px) scale(0.96);
}

/* ── Collapsed (icon-only) state ─────────────────────────────────────────── */
#ht-panel[data-collapsed="true"] {
  width: 52px;
  border-radius: 50%;
  overflow: hidden;
}

#ht-panel[data-collapsed="true"] .ht-panel-body {
  display: none;
}

#ht-panel[data-collapsed="true"] .ht-panel-header {
  padding: 14px;
  border-bottom: none;
  border-radius: 50%;
  justify-content: center;
}

#ht-panel[data-collapsed="true"] .ht-header-title,
#ht-panel[data-collapsed="true"] .ht-toggle-btn,
#ht-panel[data-collapsed="true"] .ht-collapse-btn {
  display: none;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.ht-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  cursor: grab;
}

.ht-panel-header:active { cursor: grabbing; }

/* Hand icon */
.ht-header-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-tint, rgba(99,179,237,0.15));
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
}

.ht-header-title {
  flex: 1;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.01em;
}

/* Enable / Disable toggle */
.ht-toggle-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.15);
  background: transparent;
  color: var(--text-muted, #8892a4);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s;
}

.ht-toggle-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text, #e8eaf0);
}

.ht-toggle-btn[data-active="true"] {
  background: var(--accent, #63b3ed);
  border-color: var(--accent, #63b3ed);
  color: #fff;
}

.ht-toggle-btn .ht-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.ht-toggle-btn[data-active="true"] .ht-dot {
  animation: ht-pulse 1.4s infinite;
}

@keyframes ht-pulse {
  0%, 100% { opacity: 1; transform: scale(1);   }
  50%       { opacity: 0.5; transform: scale(0.7); }
}

/* Collapse / expand button */
.ht-collapse-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted, #8892a4);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}

.ht-collapse-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text, #e8eaf0);
}

/* ── Body ─────────────────────────────────────────────────────────────── */
.ht-panel-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Camera preview section ───────────────────────────────────────────── */
.ht-camera-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ht-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted, #8892a4);
}

.ht-camera-controls {
  display: flex;
  gap: 6px;
}

.ht-icon-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: var(--text-muted, #8892a4);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}

.ht-icon-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text, #e8eaf0);
}

.ht-icon-btn[data-active="true"] {
  background: rgba(99,179,237,0.2);
  border-color: rgba(99,179,237,0.4);
  color: var(--accent, #63b3ed);
}

/* ── Status display ───────────────────────────────────────────────────── */
.ht-status-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ht-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ht-status-label {
  font-size: 11px;
  color: var(--text-muted, #8892a4);
}

.ht-status-value {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text, #e8eaf0);
  transition: all 0.25s;
}

/* Gesture-specific colors */
.ht-status-value[data-gesture="penlight"] {
  background: rgba(251,211,141,0.15);
  border-color: rgba(251,211,141,0.3);
  color: #fbd38d;
}
.ht-status-value[data-gesture="cover"] {
  background: rgba(154,230,180,0.15);
  border-color: rgba(154,230,180,0.3);
  color: #9ae6b4;
}
.ht-status-value[data-gesture="prism"] {
  background: rgba(144,205,244,0.15);
  border-color: rgba(144,205,244,0.3);
  color: #90cdf4;
}
.ht-status-value[data-gesture="move"] {
  background: rgba(197,154,255,0.15);
  border-color: rgba(197,154,255,0.3);
  color: #c59aff;
}
.ht-status-value[data-gesture="reset"] {
  background: rgba(252,129,74,0.15);
  border-color: rgba(252,129,74,0.3);
  color: #fc814a;
}

/* ── Sensitivity sliders ──────────────────────────────────────────────── */
.ht-settings-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ht-slider-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ht-slider-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted, #8892a4);
}

.ht-slider-val {
  font-variant-numeric: tabular-nums;
  color: var(--text, #e8eaf0);
}

input[type="range"].ht-range {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.1);
  outline: none;
  cursor: pointer;
  accent-color: var(--accent, #63b3ed);
}

input[type="range"].ht-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent, #63b3ed);
  box-shadow: 0 0 0 3px rgba(99,179,237,0.25);
  cursor: grab;
}

input[type="range"].ht-range::-webkit-slider-thumb:active { cursor: grabbing; }

/* ── Error / permission message ───────────────────────────────────────── */
.ht-error-msg {
  display: none;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(252,129,74,0.12);
  border: 1px solid rgba(252,129,74,0.3);
  color: #fc814a;
  font-size: 11.5px;
  line-height: 1.5;
}

.ht-error-msg[data-visible="true"] { display: block; }

/* ── Gesture legend ───────────────────────────────────────────────────── */
.ht-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding-top: 2px;
}

.ht-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted, #8892a4);
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.06);
}

.ht-legend-emoji { font-size: 13px; line-height: 1; }

/* Single-column variant for sentence-length legend items (the grab/
   release/reset instructions), instead of the default 2-up grid used for
   short single-word labels. */
.ht-legend-stacked {
  grid-template-columns: 1fr;
}

.ht-legend-stacked .ht-legend-item {
  align-items: flex-start;
  line-height: 1.35;
}

.ht-legend-stacked .ht-legend-emoji {
  flex: 0 0 auto;
  padding-top: 1px;
}
