/* Bayesian Gaussian — "The data assimilation problem" (Chapter 1 widget).
   Embedding stylesheet: every selector is prefixed with .da-widget so the
   widget can be dropped into a site page without touching the page's own
   styles. Custom properties are declared on the .da-widget wrapper (they
   inherit down into the widget's DOM); theme follows the browser's
   prefers-color-scheme via the data-theme attribute set by app.js.
*/
.da-widget {
  --surface-1:      #fcfcfb;   /* chart surface */
  --surface-2:      #f9f9f7;   /* page plane */
  --ink-1:          #0b0b0b;
  --ink-2:          #52514e;
  --ink-3:          #898781;   /* muted, axis labels */
  --line:           #e1e0d9;   /* hairline gridline */
  --axis:           #c3c2b7;   /* baseline / axis */
  --border:         rgba(11,11,11,0.10);
  --series-prior:   #2a78d6;   /* blue  — model forecast pdf */
  --series-obs:     #e49a00;   /* amber — observation likelihood */
  --series-post:    #e34948;   /* red   — posterior (the analysis) */
  --series-product: #7a5cd6;   /* violet, dashed — raw prior × likelihood */
  --shadow:         0 1px 2px rgba(11,11,11,0.06), 0 4px 16px rgba(11,11,11,0.05);
}

.da-widget[data-theme="dark"] {
  --surface-1:      #1a1a19;
  --surface-2:      #0d0d0d;
  --ink-1:          #ffffff;
  --ink-2:          #c3c2b7;
  --ink-3:          #898781;
  --line:           #3f3f3c;
  --axis:           #4d4d49;
  --border:         rgba(255,255,255,0.10);
  --series-prior:   #6da7ec;
  --series-obs:     #e0a61d;
  --series-post:    #e66767;
  --series-product: #9d86e0;
  --shadow:         0 1px 2px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.35);
}

.da-widget, .da-widget * { box-sizing: border-box; }

.da-widget {
  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;
}

.da-widget .viz-root {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 22px 26px;
}

/* ------------------------------------------------------------ workspace */
.da-widget .workspace {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.da-widget .plot-wrap { flex: 1 1 400px; min-width: 0; }
.da-widget .plot-wrap canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* ------------------------------------------------------------- controls */
.da-widget .controls {
  flex: 1 1 250px;
  min-width: 230px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.da-widget .ctl-group {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px 10px;
  box-shadow: var(--shadow);
}
.da-widget .ctl-group[data-color="prior"] { --ctl-accent: var(--series-prior); }
.da-widget .ctl-group[data-color="obs"]   { --ctl-accent: var(--series-obs); }
.da-widget .ctl-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--ink-1);
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.da-widget .ctl-note { font-size: 0.7rem; font-weight: 500; color: var(--ink-3); }
.da-widget .ctl-row {
  display: grid;
  grid-template-columns: 40px 1fr 48px;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  font-size: 0.75rem;
  color: var(--ink-2);
}
.da-widget .ctl-row input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--ctl-accent);
  cursor: pointer;
}
.da-widget .ctl-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink-1);
  font-weight: 600;
}
.da-widget .ctl-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.da-widget .ctl-toggle input { accent-color: var(--series-product); cursor: pointer; }

/* -------------------------------------------------------------- readout */
.da-widget .readout {
  margin: 16px 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);
}
.da-widget .readout div { margin-top: 5px; }
.da-widget .readout div:first-child { margin-top: 0; }
.da-widget .readout strong { color: var(--ink-1); font-weight: 650; }
.da-widget .readout .ro-formula {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--ink-1);
  overflow-wrap: break-word;
}
.da-widget .readout .ro-note { font-size: 0.78rem; }

/* --------------------------------------------------------------- legend */
.da-widget .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);
}
.da-widget .legend li { display: flex; align-items: center; gap: 7px; }
.da-widget .mark { display: inline-block; flex: 0 0 auto; }
.da-widget .mark.prior { height: 3px; width: 16px; background: var(--series-prior); border-radius: 2px; }
.da-widget .mark.obs   { height: 3px; width: 16px; background: var(--series-obs);   border-radius: 2px; }
.da-widget .mark.post  { height: 3px; width: 16px; background: var(--series-post);  border-radius: 2px; }
.da-widget .mark.product { height: 0; width: 16px; border-top: 2px dashed var(--series-product); }
