/* ========================================================================
   Component Viewer — Side-by-side 3D + Frequency Sweep
   ======================================================================== */

/* Header bar */
.component-header-bar {
  padding: 0.75rem 1.5rem;
  background: #111;
  border-bottom: 1px solid #222;
}

.component-title-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.component-title-row h1 {
  font-size: 1.4rem;
  margin: 0;
  color: #fff;
}

.component-subtitle {
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.2rem;
}

/* Main split layout */
.component-main {
  display: flex;
  flex: 1;
  min-height: 0;
  height: calc(100vh - 240px);
}

/* Left panel: 3D shape */
.component-3d-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #222;
  background: #0a0a0a;
}

.panel-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #555;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #1a1a1a;
}

.canvas-wrap {
  flex: 1;
  position: relative;
}

.canvas-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
.canvas-wrap canvas:active { cursor: grabbing; }

.toggle-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #111;
  border-top: 1px solid #222;
}

/* Right panel: Frequency sweep */
.component-sweep-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #0d0d0d;
}

/* Sweep image (top-down heat map) */
.sweep-image-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 1rem;
  min-height: 0;
}

.sweep-image-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border: 1px solid #222;
  border-radius: 4px;
  background: #0a0a0a;
}

.sweep-image-label {
  position: absolute;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: #888;
  background: rgba(10, 10, 10, 0.8);
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
}

/* ---- f|t Triangle Slider ---- */
.ft-slider-container {
  padding: 0.4rem 1.5rem 0.5rem;
  background: #111;
  border-top: 1px solid #222;
}

.ft-axis-labels {
  display: flex;
  justify-content: space-between;
  padding: 0 0.25rem;
  margin-bottom: 0.15rem;
}

.ft-label {
  font-size: 0.9rem;
  font-weight: 700;
  font-style: italic;
  letter-spacing: 0.02em;
}

.ft-label-f { color: #6bff6b; }
.ft-label-t { color: #6b8bff; }

.ft-triangle-track {
  position: relative;
  height: 60px;
  margin: 0.25rem 0;
}

.ft-triangle-svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.ft-dim-labels {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 100%;
  pointer-events: none;
}

.ft-dim {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  opacity: 0.5;
}

.ft-dim[data-dim="2D"] { color: #6bff6b; }
.ft-dim[data-dim="3D"] { color: #ffbb6b; }
.ft-dim[data-dim="4D"] { color: #6b8bff; }

/* Range input overlaid on triangle */
.ft-range-input {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  width: 100%;
  height: 40px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  outline: none;
  margin: 0;
  z-index: 2;
  cursor: pointer;
}

.ft-range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 4px;
  height: 60px;
  background: rgba(255, 255, 255, 0.9);
  cursor: ew-resize;
  border: none;
  border-radius: 1px;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.ft-range-input::-moz-range-thumb {
  width: 4px;
  height: 60px;
  background: rgba(255, 255, 255, 0.9);
  cursor: ew-resize;
  border: none;
  border-radius: 1px;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.ft-range-input::-moz-range-track {
  background: transparent;
  border: none;
}

/* f|t divider SVG: 3 squares + connecting line riding the triangle edges */
.ft-divider-svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
  overflow: visible;
}

.ft-edge-sq {
  filter: drop-shadow(0 0 3px rgba(58, 123, 213, 0.4));
}

.ft-center-sq {
  filter: drop-shadow(0 0 5px rgba(58, 123, 213, 0.6));
}

/* Controls row */
.ft-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.4rem;
}

.ft-play-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #444;
  background: #1a1a1a;
  color: #ccc;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.ft-play-btn:hover {
  background: #2a2a2a;
  border-color: #666;
}

.ft-play-btn.playing {
  border-color: #3a7bd5;
  background: #1a2a3a;
}

.ft-step-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 100px;
}

.ft-current-dim {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.ft-current-dim[data-dim="2D"] { color: #6bff6b; }
.ft-current-dim[data-dim="3D"] { color: #ffbb6b; }
.ft-current-dim[data-dim="4D"] { color: #6b8bff; }

.ft-step-num {
  font-size: 0.65rem;
  color: #666;
  font-variant-numeric: tabular-nums;
}

.sweep-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.65rem;
  color: #555;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

/* Sweep placeholder for shapes without data */
.sweep-placeholder {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0a0a0a;
  z-index: 3;
  border-radius: 4px;
}

.placeholder-icon {
  width: 48px;
  height: 48px;
  border: 2px dashed #333;
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

.placeholder-text {
  font-size: 0.8rem;
  color: #555;
  text-align: center;
  line-height: 1.5;
  max-width: 280px;
}

/* Dimensional transition flash */
.sweep-image-wrap.dim-transition img {
  outline: 2px solid;
  outline-offset: -2px;
  animation: dimFlash 0.6s ease-out;
}

.sweep-image-wrap.dim-transition[data-dim="3D"] img { outline-color: #ffbb6b; }
.sweep-image-wrap.dim-transition[data-dim="4D"] img { outline-color: #6b8bff; }

@keyframes dimFlash {
  0%   { outline-width: 4px; outline-offset: -4px; opacity: 1; }
  100% { outline-width: 2px; outline-offset: -2px; opacity: 1; }
}

/* Concentration sparkline */
.sweep-curve-wrap {
  padding: 0.5rem 1.5rem;
  background: #111;
  border-top: 1px solid #1a1a1a;
}

#sweepCurve {
  width: 100%;
  display: block;
  border-radius: 3px;
}

.curve-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #444;
  text-align: center;
  margin-top: 0.25rem;
}

/* Bottom info */
.component-bottom {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: #111;
  border-top: 1px solid #222;
  align-items: flex-start;
}

.fingerprint-panel {
  flex: 0 0 300px;
}

.fingerprint-panel h3,
.description-panel h3 {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #555;
  margin: 0 0 0.4rem;
}

.fp-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.3rem;
}

.fp-cell {
  display: flex;
  flex-direction: column;
  background: #1a1a1a;
  padding: 0.3rem 0.4rem;
  border-radius: 3px;
  border: 1px solid #222;
}

.fp-label {
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #555;
}

.fp-val {
  font-size: 0.85rem;
  font-weight: 600;
  color: #e0e0e0;
  font-variant-numeric: tabular-nums;
}

.description-panel {
  flex: 1;
  font-size: 0.8rem;
  color: #aaa;
  line-height: 1.5;
}

.component-nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: #666;
}

/* Responsive */
@media (max-width: 1000px) {
  .component-main { flex-direction: column; height: auto; }
  .component-3d-panel { border-right: none; border-bottom: 1px solid #222; min-height: 300px; }
  .component-sweep-panel { min-height: 350px; }
  .component-bottom { flex-direction: column; }
  .fingerprint-panel { flex: none; width: 100%; }
  .fp-grid { grid-template-columns: repeat(7, 1fr); }
}
