/* ==========================================================================
   FPS Visualization — Interactive centisecond timeline
   ========================================================================== */

.fps-viz {
  margin: var(--space-lg) 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* --- Result Banner --- */
.fps-viz__result {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  margin-bottom: var(--space-md);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--accent-lime-dim);
  color: var(--accent-lime);
  border: 1px solid transparent;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity var(--transition-slow), transform var(--transition-slow), background var(--transition-base), color var(--transition-base), border-color var(--transition-base);
}

.fps-viz__result.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.fps-viz__result.is-exact {
  background: var(--accent-lime-dim);
  color: var(--accent-lime);
  border-color: rgba(101, 163, 13, 0.25);
}

.fps-viz__result.is-mismatch {
  background: rgba(239, 68, 68, 0.12);
  color: var(--error);
  border-color: rgba(239, 68, 68, 0.25);
}

.fps-viz__result-icon {
  flex-shrink: 0;
  font-size: 1.1em;
}

/* --- Timeline Container --- */
.fps-viz__timeline-wrap {
  position: relative;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 20px 16px 12px;
}

/* --- Timeline Grid --- */
.fps-viz__timeline {
  position: relative;
  height: 56px;
  min-width: 600px;
}

.fps-viz__slots {
  display: flex;
  height: 100%;
  border-radius: 4px;
  overflow: hidden;
}

.fps-viz__slot {
  flex: 1;
  border-right: 1px solid var(--border-subtle);
  position: relative;
  transition: background var(--transition-fast);
}

.fps-viz__slot:last-child {
  border-right: none;
}

.fps-viz__slot.is-filled {
  background: var(--accent-lime-dim);
}

.fps-viz__slot.is-filled-mismatch {
  background: rgba(239, 68, 68, 0.1);
}

.fps-viz__slot.is-filled-mixed {
  background: rgba(245, 158, 11, 0.1);
}

/* --- Frame Markers --- */
.fps-viz__marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  margin-left: -1.5px;
  border-radius: 2px;
  transform: scaleY(0);
  transform-origin: bottom;
  z-index: 2;
}

.fps-viz__marker.is-active {
  transform: scaleY(1);
}

.fps-viz__marker--exact {
  background: var(--accent-lime);
}

.fps-viz__marker--actual {
  background: var(--error);
}

.fps-viz__marker--ghost {
  background: var(--text-dim);
  opacity: 0.35;
  width: 2px;
  margin-left: -1px;
  border-style: dashed;
  z-index: 1;
}

.fps-viz__marker--mixed {
  background: var(--warning);
}

/* Marker labels */
.fps-viz__marker-label {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

.fps-viz__marker:hover .fps-viz__marker-label {
  opacity: 1;
}

/* --- Ruler ticks --- */
.fps-viz__ruler {
  display: flex;
  min-width: 600px;
  margin-top: 4px;
  user-select: none;
}

.fps-viz__tick {
  flex: 1;
  text-align: center;
  font-size: 0.55rem;
  color: var(--text-dim);
  position: relative;
}

.fps-viz__tick::before {
  content: '';
  display: block;
  width: 1px;
  height: 5px;
  background: var(--border-color);
  margin: 0 auto 2px;
}

.fps-viz__tick--major {
  font-weight: 600;
  color: var(--text-muted);
}

.fps-viz__tick--major::before {
  height: 8px;
  background: var(--text-dim);
}

.fps-viz__labels {
  display: flex;
  justify-content: space-between;
  min-width: 600px;
  margin-top: 2px;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* --- FPS Buttons --- */
.fps-viz__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: var(--space-md);
  justify-content: center;
}

.fps-viz__btn {
  appearance: none;
  border: 2px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  position: relative;
}

.fps-viz__btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  color: var(--text-main);
}

.fps-viz__btn:focus-visible {
  outline: 2px solid var(--accent-lime);
  outline-offset: 2px;
}

/* Pre-warning for problematic FPS */
.fps-viz__btn--warn {
  border-style: dashed;
  border-color: rgba(239, 68, 68, 0.35);
}

.fps-viz__btn--warn::after {
  content: '*';
  color: var(--error);
  margin-left: 2px;
}

/* Active states */
.fps-viz__btn.is-active-exact {
  background: var(--accent-lime-dim);
  border-color: var(--accent-lime);
  border-style: solid;
  color: var(--accent-lime);
}

.fps-viz__btn.is-active-mismatch {
  background: rgba(239, 68, 68, 0.12);
  border-color: var(--error);
  border-style: solid;
  color: var(--error);
}

.fps-viz__btn.is-active-mismatch::after {
  content: none;
}

/* --- Info Row --- */
.fps-viz__info {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  justify-content: center;
  margin-top: var(--space-sm);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.fps-viz__info-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fps-viz__info-item strong {
  color: var(--text-secondary);
}

/* --- Mode Toggle for mismatch FPS --- */
.fps-viz__mode-toggle {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: var(--space-sm);
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.fps-viz__mode-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.fps-viz__mode-btn:hover {
  color: var(--text-secondary);
}

.fps-viz__mode-btn.is-active {
  background: var(--bg-elevated);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.fps-viz__mode-btn:focus-visible {
  outline: 2px solid var(--accent-lime);
  outline-offset: 2px;
}

/* --- Legend --- */
.fps-viz__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: var(--space-sm);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.fps-viz__legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.fps-viz__legend-swatch {
  width: 12px;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}

.fps-viz__legend-swatch--exact { background: var(--accent-lime); }
.fps-viz__legend-swatch--ghost { background: var(--text-dim); opacity: 0.4; }
.fps-viz__legend-swatch--actual { background: var(--error); }
.fps-viz__legend-swatch--mixed { background: var(--warning); }

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  .fps-viz__marker,
  .fps-viz__result,
  .fps-viz__slot,
  .fps-viz__btn {
    transition: none !important;
  }
  .fps-viz__marker.is-active {
    transform: scaleY(1);
  }
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .fps-viz__timeline-wrap {
    padding: 16px 12px 10px;
  }
  .fps-viz__controls {
    gap: 6px;
  }
  .fps-viz__btn {
    padding: 6px 14px;
    font-size: 0.8rem;
  }
  .fps-viz__result {
    font-size: 0.8rem;
    padding: 8px 12px;
  }
}
