/* Particle filter vs EnKF on the Gaussian hump (Ch. 6, §2) — embedding
   stylesheet.  Scoped to .da-widget; custom properties live on the wrapper.
   Three spaghetti-map panels side by side (phone: stacked), controls row
   and readout below — the same visual language as the Ch. 2/3 widgets.
*/
#pf-explorer {
  --surface-1:      #fcfcfb;
  --surface-2:      #f9f9f7;
  --ink-1:          #0b0b0b;
  --ink-2:          #52514e;
  --ink-3:          #898781;
  --border:         rgba(11,11,11,0.10);
  --series-ink:     #0b0b0b;
  --series-blue:    #2b7bba;
  --series-red:     #e34948;
  --series-pf:      #2ca02c;
  --series-amber:   #eda100;
  --accent-fill:    #ffffff;
  --shadow:         0 1px 2px rgba(11,11,11,0.06), 0 4px 16px rgba(11,11,11,0.05);
}
#pf-explorer[data-theme="dark"] {
  --surface-1:      #1a1a19;
  --surface-2:      #0d0d0d;
  --ink-1:          #ffffff;
  --ink-2:          #c3c2b7;
  --ink-3:          #898781;
  --border:         rgba(255,255,255,0.10);
  --series-ink:     #ffffff;
  --series-blue:    #6fb3e8;
  --series-red:     #e66767;
  --series-pf:      #52c94f;
  --series-amber:   #e0a61d;
  --accent-fill:    #1a1a19;
  --shadow:         0 1px 2px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.35);
}

#pf-explorer, #pf-explorer * { box-sizing: border-box; }
#pf-explorer {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--surface-2);
  color: var(--ink-1);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  border-radius: 14px;
  box-shadow: var(--shadow);
  margin: 20px 0 8px;
}
#pf-explorer .viz-root {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 22px 26px;
}

/* ---------------------------------------------------------- panel grid */
#pf-explorer .workspace { display: flex; gap: 14px; }
#pf-explorer .panels-wrap { flex: 1; min-width: 0; }
/* auto-fit with a minimum panel width: wraps down to fewer columns (to 1)
   as soon as a panel would otherwise be squeezed below that width, instead
   of jumping straight to 3-across at a fixed breakpoint */
#pf-explorer .panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
#pf-explorer .panel {
  min-width: 0;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 12px 10px;
  box-shadow: var(--shadow);
}
#pf-explorer .panel-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-2);
  margin: 0 0 8px;
  letter-spacing: 0.01em;
  text-align: center;
}
#pf-explorer canvas.map {
  display: block;
  width: 100%;
  min-width: 0;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  background: var(--surface-1);
}

/* truth-field colourbar (0..8 K, same as the Ch. 2 panel) */
#pf-explorer .colorbar { margin-top: 6px; }
#pf-explorer .colorbar canvas { display: block; width: 100%; height: 10px; border-radius: 4px; }
#pf-explorer .cb-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--ink-3);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------- controls */
/* always a single column (vertical stack), same outer width as the
   panel-grid above it (both are direct, unpadded children of .viz-root);
   each .ctl is itself a label/slider/value grid with a fixed label column,
   so every slider's track lines up with its neighbours. */
#pf-explorer .controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 14px 0 0;
  padding: 14px 18px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
#pf-explorer .ctl {
  display: grid;
  grid-template-columns: 128px 1fr 46px;
  align-items: center;
  gap: 9px;
  font-size: 0.82rem;
  color: var(--ink-2);
}
#pf-explorer .ctl label { white-space: nowrap; }
#pf-explorer .ctl em { font-style: italic; color: var(--ink-1); }
#pf-explorer .ctl input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--series-amber);
  cursor: pointer;
}
#pf-explorer .ctl input#pf-nens { accent-color: var(--series-blue); }
#pf-explorer .ctl input#pf-sigo { accent-color: var(--series-pf); }
#pf-explorer .ctl-val {
  text-align: right;
  font-weight: 650;
  color: var(--ink-1);
  font-variant-numeric: tabular-nums;
}
#pf-explorer .ctl-buttons {
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
#pf-explorer .ctl-btn {
  padding: 9px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-1);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  box-shadow: var(--shadow);
  white-space: nowrap;
}
#pf-explorer .ctl-btn[aria-pressed="false"] { color: var(--ink-3); border-color: var(--axis); }
#pf-explorer .ctl-btn:hover { border-color: var(--series-amber); color: var(--series-amber); }
@media (max-width: 420px) {
  #pf-explorer .ctl { grid-template-columns: 1fr; }
  #pf-explorer .ctl-val { text-align: left; }
  #pf-explorer .ctl-buttons { grid-template-columns: 1fr; }
}

/* -------------------------------------------------------------- readout */
#pf-explorer .readout {
  margin: 14px 0 8px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-1);
  font-size: 0.85rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow);
}
#pf-explorer .readout strong { color: var(--ink-1); font-weight: 650; }

/* --------------------------------------------------------------- legend */
#pf-explorer .legend {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  font-size: 0.78rem;
  color: var(--ink-2);
}
#pf-explorer .legend li { display: flex; align-items: center; gap: 7px; }
#pf-explorer .legend li.legend-note { color: var(--ink-3); }
#pf-explorer .mark { display: inline-block; flex: 0 0 auto; }
#pf-explorer .mark.truth { width: 18px; height: 3px; background: var(--series-ink); border-radius: 1px; }
#pf-explorer .mark.member { width: 18px; height: 2px;
  background: linear-gradient(90deg, #1f77b4, #ff7f0e, #2ca02c, #d62728, #9467bd, #17becf);
  border-radius: 1px; }
#pf-explorer .mark.sel   { width: 18px; height: 4px; background: #ff7f0e; border-radius: 1px; }
#pf-explorer .mark.prior { width: 18px; height: 2px; background: var(--series-blue); border-radius: 1px; }
#pf-explorer .mark.enkf  { width: 18px; height: 2px; background: var(--series-red); border-radius: 1px; }
#pf-explorer .mark.pf    { width: 18px; height: 2px; background: var(--series-pf); border-radius: 1px; }
#pf-explorer .mark.obs {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background: #101010;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}
