/* ============================================
   INTERACTIVE DEMOS — Statistical Precision
   ============================================ */

/* Shared demo card base */
[class$="-demo"] {
  border-radius: 10px;
  padding: 28px;
  margin: 24px 0;
  position: relative;
  overflow: hidden;
}

[class$="-demo"] h4 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

[class$="-demo"] h4::before {
  content: '';
  width: 3px;
  height: 20px;
  border-radius: 2px;
  flex: none;
  background: var(--accent);
}

/* Buttons */
.demo-btn {
  padding: 7px 18px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s var(--ease);
  font-family: var(--font-sans);
}
.demo-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.demo-btn:active { transform: translateY(0); }
.demo-btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.demo-btn.primary:hover {
  background: var(--accent-light);
  border-color: var(--accent-light);
}

/* Select inputs */
.demo-select {
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: border-color .2s;
}
.demo-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Range inputs */
.demo-range {
  -webkit-appearance: none;
  width: 140px;
  height: 6px;
  border-radius: 6px;
  background: var(--border);
  outline: none;
  vertical-align: middle;
}
.demo-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.demo-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

/* Demo value display */
.demo-value {
  font-weight: 600;
  color: var(--accent);
  font-size: 15px;
  min-width: 40px;
  display: inline-block;
  text-align: center;
}

/* Control row */
.demo-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}
.demo-control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.demo-control-group label {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-secondary);
  white-space: nowrap;
}

/* Info bar */
.demo-info {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 16px;
  background: rgba(255,255,255,0.6);
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--ink-secondary);
}
.demo-info strong {
  color: var(--ink);
}

/* Matrix grid (shared) */
.matrix-grid {
  display: inline-grid;
  gap: 3px;
}
.matrix-cell {
  width: 50px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-family: var(--font-mono);
  font-weight: 500;
  border-radius: 5px;
  transition: all .25s var(--ease);
  cursor: default;
  position: relative;
}
.matrix-cell:hover {
  transform: scale(1.12);
  box-shadow: var(--shadow-lg);
  z-index: 2;
}

/* Chart container */
.chart-container {
  width: 100%;
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.chart-container svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Tooltip */
.demo-tooltip {
  position: absolute;
  background: var(--primary);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--font-mono);
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity .15s;
}
.demo-tooltip.visible { opacity: 1; }

/* Legend */
.demo-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--ink-secondary);
}
.demo-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.demo-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex: none;
}

/* Responsive */
@media (max-width: 760px) {
  [class$="-demo"] { padding: 18px; }
  .demo-controls { flex-direction: column; align-items: flex-start; gap: 10px; }
  .matrix-cell { width: 38px; height: 32px; font-size: 10px; }
  .demo-range { width: 100px; }
}

@media print {
  [class$="-demo"] { break-inside: avoid; }
  .demo-btn { display: none; }
}
