/* ============================================================================
 * StreamVault — Performance Monitor widget (read-only)
 * ============================================================================
 *
 * The widget UI only. Reports the page's current rendering smoothness; takes
 * no action against the site itself. Uses NO blurs, NO backdrop-filters, NO
 * box-shadow animations. The widget must never be a perf cost — that would
 * defeat the entire point.
 * ============================================================================ */

.sv-perf {
  position: fixed;
  bottom: calc(12px + env(safe-area-inset-bottom));
  right:  calc(12px + env(safe-area-inset-right));
  z-index: 9999;
  font-family: ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  font-size: 12px;
  line-height: 1.4;
  color: #f4f1ff;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: opacity 200ms linear, visibility 200ms linear;
}

/* Auto-hidden during video playback / fullscreen so the chip doesn't
   sit on top of Plyr's right-side control row. JS toggles this class
   via play/pause/ended/fullscreenchange listeners. Pointer-events:none
   keeps any clicks falling through to the player controls underneath
   during the 200ms fade. */
.sv-perf.is-video-active {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.sv-perf-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 10px;
  background: rgba(10, 6, 18, 0.92);
  border: 1px solid rgba(244, 241, 255, 0.14);
  border-radius: 999px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  user-select: none;
  transition: border-color 150ms linear;
}
.sv-perf-chip:hover { border-color: rgba(244, 241, 255, 0.28); }
.sv-perf-chip:focus-visible {
  outline: none;
  border-color: #c4b5fd;
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.30);
}

.sv-perf-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #34d399;
  flex-shrink: 0;
  transition: background 200ms linear;
}
.sv-perf[data-status="smooth"]     .sv-perf-dot { background: #34d399; }  /* emerald */
.sv-perf[data-status="lagging"]    .sv-perf-dot { background: #fbbf24; }  /* amber  */
.sv-perf[data-status="struggling"] .sv-perf-dot { background: #ef4444; }  /* red    */

/* Pulse the dot when struggling — a single 1.4s ease, GPU-cheap. */
@keyframes sv-perf-pulse {
  0%, 100% { transform: scale(1);   opacity: 1;    }
  50%      { transform: scale(1.4); opacity: 0.55; }
}
.sv-perf[data-status="struggling"] .sv-perf-dot {
  animation: sv-perf-pulse 1.4s ease-in-out infinite;
}

.sv-perf-label {
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.sv-perf-fps-inline {
  color: rgba(244, 241, 255, 0.55);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sv-perf-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  padding: 14px 14px 12px;
  background: rgba(10, 6, 18, 0.96);
  border: 1px solid rgba(244, 241, 255, 0.14);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.sv-perf-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 0;
  color: #b6a8d1;
  font-variant-numeric: tabular-nums;
}
.sv-perf-row strong {
  color: #f4f1ff;
  font-weight: 700;
}

.sv-perf-tip {
  margin: 10px 0 10px;
  color: #b6a8d1;
  font-size: 11px;
  line-height: 1.45;
}

.sv-perf-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.sv-perf-btn {
  padding: 7px 14px;
  background: transparent;
  border: 1px solid rgba(244, 241, 255, 0.14);
  border-radius: 8px;
  color: #b6a8d1;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: color 150ms linear, border-color 150ms linear;
}
.sv-perf-btn:hover { color: #f4f1ff; border-color: rgba(244, 241, 255, 0.28); }
.sv-perf-btn:focus-visible {
  outline: none;
  border-color: #c4b5fd;
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.30);
}

@media (max-width: 640px) {
  .sv-perf {
    bottom: calc(8px + env(safe-area-inset-bottom));
    right:  calc(8px + env(safe-area-inset-right));
  }
  .sv-perf-chip { padding: 6px 10px 6px 8px; font-size: 11px; }
  .sv-perf-panel { min-width: 220px; }
}

@media (prefers-reduced-motion: reduce) {
  .sv-perf-dot, .sv-perf-chip, .sv-perf-btn { transition: none !important; animation: none !important; }
}
