/* Last edited: 2026-11-13 12:30 UTC (Claude, website chat) */
/* =========================================================
   EC9D5 interactive page: /teaching/ec9d5/uncertainty.html
   Page structure, title, lead, sections, panels, callouts and
   the reveal animation come from site.css. This file only
   styles the model cards, controls, charts and table.
   ========================================================= */

.uncertainty-body {
  /* Chart colours, used by the SVG and the chart key. */
  --chart-risk: #b4366f;
  --chart-mean: #2f5fd0;
  --chart-current: var(--accent);
  --chart-ghost: #a1a1aa;
  --chart-ink: var(--ink);
}

.eyebrow {
  margin-bottom: 0.55rem;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* --- Sections 1 and 2: model cards and equations -------- */

/* Model cards sit one below the other. */
.model-stack {
  display: grid;
  gap: 1rem;
}

/* Side-by-side pairs: the two Euler equations and the two charts. */
.equation-case-grid,
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.model-card,
.chart-card {
  min-width: 0;
  padding: 1.35rem;
  background: var(--paper-soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}

.model-card h3,
.chart-head h3 {
  margin-bottom: 0.75rem;
  color: var(--accent-strong);
  font-family: var(--display);
  font-size: 1.08rem;
  line-height: 1.4;
}

.model-card p,
.chart-copy p,
.normalisation-note {
  color: var(--ink-soft);
  font-size: 0.93rem;
  line-height: 1.65;
}

/* Site rule: running text is justified. */
.uncertainty-body .model-card p,
.uncertainty-body .chart-copy p,
.uncertainty-body .normalisation-note,
.uncertainty-body .chart-note,
.uncertainty-body .gamma-roles dd,
.uncertainty-body .equation-case p,
.uncertainty-body .model-card li,
.uncertainty-body .certainty-side .section-introduction {
  text-align: justify;
  hyphens: auto;
}

.model-card p + p {
  margin-top: 0.75rem;
}

.model-card-label {
  display: inline-block;
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

/* Long equations scroll sideways instead of overflowing. */
.equation-block {
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  color: var(--ink);
}

/* Card with the formula on the left and a small interactive graph on the right. */
.model-card.has-figure {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 1.5rem;
}

.model-card-text {
  min-width: 0;
}

.model-card-figure {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
  margin: 0;
  padding: 1rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
}

.model-card-figure .chart {
  margin-top: 0;
}

.model-card-figure .chart-note {
  min-height: 0;
  margin-top: 0;
}

/* The three roles of γ. */
.gamma-roles {
  display: grid;
  gap: 0.9rem;
  margin: 0 0 1rem;
}

.gamma-roles > div {
  padding-left: 0.85rem;
  border-left: 3px solid var(--accent-border-strong);
}

.gamma-roles dt {
  margin-bottom: 0.2rem;
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 600;
}

.gamma-roles dd {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.93rem;
  line-height: 1.65;
}

/* Text between equations inside a card. */
.model-card .equation-block + p,
.model-card p + .equation-block {
  margin-top: 0.6rem;
}

/* Interactive block that follows the model cards in section 1. */
.model-stack + .subsection-title {
  margin-top: 2.5rem;
}

.normalisation-note {
  margin: 1.25rem 0;
}

/* The Euler equation that applies is highlighted, the other greyed out. */
.equation-case {
  min-width: 0;
  padding: 1rem;
  background: var(--sheet);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  transition: opacity 0.22s ease, background-color 0.22s ease,
              border-color 0.22s ease, filter 0.22s ease;
}

.equation-case.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-border-strong);
}

.equation-case.is-muted {
  opacity: 0.4;
  background: var(--paper-soft);
  border-color: var(--line);
  filter: grayscale(0.9);
}

.equation-case-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
  color: var(--accent-strong);
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 700;
}

.equation-status {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  text-align: right;
}

/* Callout holding display maths: normal weight, room for the equation. */
.callout.key-result,
.callout.takeaway {
  margin-top: 1.25rem;
  font-weight: 400;
}

.callout.takeaway {
  display: block;
}

.callout.key-result > div {
  min-width: 0;
  overflow-x: auto;
}

/* --- Section 3: controls, summary values, charts --------- */

.control-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
  padding: 1.25rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
}

.control {
  display: grid;
  gap: 0.7rem;
  min-width: 0;
}

.control-heading,
.control-scale {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.control-heading {
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 600;
}

.control-heading output {
  min-width: 3.4rem;
  padding: 0.25rem 0.45rem;
  color: var(--on-accent);
  background: var(--accent);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.78rem;
  text-align: center;
}

.control input[type='range'] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.control input[type='range']:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.control-scale {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
}

/* Sliders sit right above the charts; the live values right below. */
.control-panel + .chart-card,
.control-panel + .chart-key {
  margin-top: 1rem;
}

/* Section 2: controls on the left of the chart card (desktop). */
.certainty-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.78fr) minmax(0, 1fr);
  align-items: start;
  gap: 1.25rem;
}

.certainty-side {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.certainty-side .section-introduction {
  margin: 0;
}

.control-panel.is-stacked {
  grid-template-columns: 1fr;
  align-content: start;
}

.certainty-layout > .certainty-side {
  position: sticky;
  top: 1rem;
}

.certainty-layout > .chart-card {
  grid-row: auto;
  margin-top: 0;
}

.insight-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.insight-strip > div {
  padding: 0.85rem 1rem;
  background: var(--sheet);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-small);
}

.insight-label {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.insight-strip strong {
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 0.95rem;
}

.chart-key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 0 0 1rem;
  padding: 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
  list-style: none;
}

.chart-key li {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.key-swatch {
  width: 1.4rem;
  border-top: 2px dashed currentColor;
}

.key-swatch.is-risk { color: var(--chart-risk); }
.key-swatch.is-mean { color: var(--chart-mean); }
.key-swatch.is-current { color: var(--chart-current); }

.key-swatch.is-ghost {
  width: 0.7rem;
  height: 0.7rem;
  border: 1.5px solid var(--chart-ghost);
  border-radius: 50%;
}

/* Title, chart, explanation, live note. Side by side, the two cards
   share these rows, so the charts line up. */
.chart-card {
  display: grid;
  grid-row: span 4;
  grid-template-rows: subgrid;
  row-gap: 0;
  align-content: start;
  background: var(--sheet);
}

.chart-card.is-single {
  grid-template-rows: none;
}

.chart-head h3 {
  margin-bottom: 0;
}

.chart-copy {
  margin-top: 1rem;
}

/* Live Euler equation above the certainty chart. */
.chart-equation {
  margin-top: 0.5rem;
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 0.84rem;
  white-space: pre-wrap;
}

.step-number {
  display: inline-flex;
  margin-bottom: 0.55rem;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chart {
  /* Text in the SVG scales down with the chart; this enlarges it on phones.
     uncertainty.js reads it to space the labels. */
  --chart-text-scale: 1;
  margin-top: 1rem;
  overflow: hidden;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-note {
  min-height: 3.2rem;
  margin-top: 0.85rem;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

/* SVG parts drawn by uncertainty.js. */
.chart-axis {
  stroke: var(--ink-soft);
  stroke-width: 1.2;
}

.chart-curve {
  fill: none;
  stroke: var(--chart-ink);
  stroke-width: 2.4;
}

.chart-curve.is-reference {
  stroke: var(--chart-ghost);
  stroke-width: 1.4;
  stroke-dasharray: 5 4;
}

.chart-chord {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.4;
  stroke-dasharray: 6 5;
}

.chart-guide {
  fill: none;
  stroke-width: 1.3;
  stroke-dasharray: 5 5;
}

.chart-guide.is-risk { stroke: var(--chart-risk); }
.chart-guide.is-mean { stroke: var(--chart-mean); }
.chart-guide.is-current { stroke: var(--chart-current); }
.chart-guide.is-ghost { stroke: var(--chart-ghost); stroke-dasharray: none; }

.chart-point { fill: var(--chart-ink); }
.chart-point.is-current { fill: var(--chart-current); }

.chart-point.is-ghost {
  fill: var(--sheet);
  stroke: var(--chart-ghost);
  stroke-width: 1.5;
}

.chart-arrowhead { fill: var(--chart-ghost); }

.chart-label {
  fill: var(--ink-soft);
  font-family: var(--mono);
  font-size: calc(13px * var(--chart-text-scale));
}

.chart-label.is-risk { fill: var(--chart-risk); }
.chart-label.is-mean { fill: var(--chart-mean); }
.chart-label.is-current { fill: var(--chart-current); }

.chart-label-small {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: calc(11.5px * var(--chart-text-scale));
}

.chart-axis-label {
  fill: var(--ink);
  font-family: var(--display);
  font-size: calc(14px * var(--chart-text-scale));
  font-style: italic;
}

/* --- Section 4: comparison table ------------------------- */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}

.comparison-table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  background: var(--sheet);
  font-size: 0.88rem;
}

.comparison-table th,
.comparison-table td {
  padding: 0.78rem 0.9rem;
  text-align: right;
  border-bottom: 1px solid var(--line);
}

.comparison-table th:first-child,
.comparison-table td:first-child {
  text-align: left;
}

.comparison-table th {
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-family: var(--display);
  font-weight: 700;
}

.comparison-table td:not(:first-child) {
  font-family: var(--mono);
  font-size: 0.84rem;
}

.comparison-table tbody tr:nth-child(even) {
  background: var(--paper-soft);
}

.comparison-table tbody tr:last-child td {
  border-bottom: none;
}

.comparison-table tr.is-highlight td {
  color: var(--accent-strong);
  font-weight: 600;
}

.value-positive {
  color: #386641;
  font-weight: 600;
}

.value-negative {
  color: var(--error);
  font-weight: 600;
}

/* --- Responsive ------------------------------------------ */

@media (max-width: 900px) {
  .model-card.has-figure,
  .chart-grid,
  .certainty-layout {
    grid-template-columns: 1fr;
  }

  .certainty-layout > .certainty-side {
    position: static;
  }
}

@media (max-width: 768px) {
  .control-panel,
  .equation-case-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .model-card,
  .chart-card {
    padding: 1rem;
  }

  .equation-case-heading {
    display: grid;
    gap: 0.25rem;
  }

  .equation-status {
    text-align: left;
  }

  .chart {
    --chart-text-scale: 1.7;
  }

  .insight-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .equation-case {
    transition: none;
  }
}
