/* interactives.css — styling for the blog's interactive figures.
   Namespaced under .iv so it never touches the surrounding post styles.
   Colours adapt to the page's light/dark scheme; the canvas is self-coloured
   (viridis) and deliberately never inverted. */

.iv {
  --iv-border: #ddd;
  --iv-muted: #666;
  --iv-panel-bg: #fafafa;
  --iv-btn-bg: #fff;
  --iv-btn-border: #ccc;
  --iv-accent: #1f9e89;
  margin: 1.5em 0;
}

.iv-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.iv-tag-icon {
  width: 20px;
  height: 20px;
  display: block;
  flex: none;
}

.iv-tag-text {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--iv-muted);
}

.iv-stage {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: stretch;
}

.iv-canvas-wrap {
  flex: 1 1 300px;
  min-width: 240px;
  max-width: 460px;
}

.iv-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  border: 1px solid var(--iv-border);
  cursor: crosshair;
  touch-action: manipulation;
}

.iv-panel {
  flex: 1 1 200px;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
}

.iv-llc-readout {
  background: var(--iv-panel-bg);
  border: 1px solid var(--iv-border);
  border-radius: 6px;
  padding: 10px 12px;
}

.iv-llc-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--iv-muted);
}

.iv-llc-value {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
}

.iv-llc-num {
  font-variant-numeric: tabular-nums;
}

.iv-llc-sub {
  font-size: 12px;
  color: var(--iv-muted);
}

.iv-legend-label {
  font-size: 11px;
  color: var(--iv-muted);
  margin-bottom: 4px;
}

.iv-legend-bar {
  height: 10px;
  border-radius: 3px;
  border: 1px solid var(--iv-border);
}

.iv-legend-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--iv-muted);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.iv-formula {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  text-align: center;
  padding: 6px 4px;
}

.iv-fixed {
  font-size: 12px;
  color: var(--iv-muted);
  line-height: 1.5;
}

.iv-fixed .iv-lstar {
  font-variant-numeric: tabular-nums;
}

.iv-list-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--iv-muted);
}

.iv-list {
  margin: 0;
  padding: 4px 4px 4px 28px;
  list-style: decimal;
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid var(--iv-border);
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

.iv-list li {
  padding: 1px 0;
}

.iv-list .iv-dv {
  color: var(--iv-muted);
  margin-left: 10px;
}

.iv-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
}

.iv-btn {
  flex: 1 1 auto;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid var(--iv-btn-border);
  border-radius: 6px;
  background: var(--iv-btn-bg);
  color: inherit;
  cursor: pointer;
}

.iv-btn:hover {
  border-color: var(--iv-muted);
}

.iv-btn:active {
  transform: translateY(1px);
}

.iv-hint {
  font-size: 12px;
  color: var(--iv-muted);
  margin: 8px 2px 0;
  line-height: 1.5;
}

.iv-hint em {
  font-style: normal;
  font-weight: 600;
}

/* ---- wiggle widget (linear regression / degenerate net) ---------------- */
.iv-chart-wrap {
  flex: 1 1 320px;
  min-width: 240px;
  max-width: 520px;
}

.iv-chart {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  border: 1px solid var(--iv-border);
}

.iv-wiggle-panel {
  flex: 1 1 220px;
}

.iv-sliders {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.iv-slider-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
}

.iv-slider-name {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-style: italic;
}

.iv-slider-val {
  font-variant-numeric: tabular-nums;
  color: var(--iv-muted);
}

.iv-slider {
  width: 100%;
  margin: 0;
  accent-color: var(--iv-accent);
  touch-action: none; /* let the thumb drag horizontally without scrolling */
}

.iv-inset-label,
.iv-ribbon-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--iv-muted);
  margin-bottom: 4px;
}

.iv-inset {
  display: block;
  width: 100%;
  max-width: 180px;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  border: 1px solid var(--iv-border);
}

.iv-ribbon-wrap {
  margin-top: 18px;
}

.iv-ribbon {
  display: block;
  width: 100%;
  height: 120px;
  border-radius: 6px;
  border: 1px solid var(--iv-border);
  background: var(--iv-panel-bg);
}

/* ---- ice-freeze widget (phase transition) ------------------------------ */
.iv-ice-stage {
  align-items: flex-start;
}

.iv-ice-box {
  flex: 1 1 260px;
  min-width: 220px;
  max-width: 320px;
}

.iv-ice-mol {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  border: 1px solid var(--iv-border);
  background: var(--iv-panel-bg);
}

.iv-ice-right {
  flex: 1 1 320px;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.iv-ice-plot {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  border-radius: 6px;
  border: 1px solid var(--iv-border);
  background: var(--iv-panel-bg);
}

.iv-ice-readout {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  align-items: flex-start;
}

.iv-ice-phase {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
}

.iv-ice-phase-sub {
  font-size: 11px;
  color: var(--iv-muted);
  margin-top: 2px;
}

.iv-ice-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
}

.iv-ice-stat {
  display: flex;
  flex-direction: column;
}

.iv-ice-stat-k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--iv-muted);
}

.iv-ice-stat-v {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.iv-ice-stat-s {
  font-size: 11px;
  color: var(--iv-muted);
}

.iv-ice-bar-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--iv-muted);
  margin-bottom: 4px;
}

.iv-ice-bar-track {
  height: 10px;
  border-radius: 5px;
  background: var(--iv-panel-bg);
  border: 1px solid var(--iv-border);
  overflow: hidden;
}

.iv-ice-bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 5px 0 0 5px;
  transition: width 0.12s ease, background 0.12s ease;
}

.iv-ice-ctrl {
  margin-top: 18px;
}

.iv-ice-ctrl-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  margin-bottom: 4px;
}

.iv-ice-ends {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--iv-muted);
  margin-top: 4px;
}

@media (prefers-color-scheme: dark) {
  .iv {
    --iv-border: #444;
    --iv-muted: #aaa;
    --iv-panel-bg: #161616;
    --iv-btn-bg: #1c1c1c;
    --iv-btn-border: #555;
    --iv-accent: #2bb89f;
  }

  /* The icon is black-on-white; invert so it blends with the dark page. */
  .iv-tag-icon {
    filter: invert(1);
  }
}
