/* Forecast Calibration: what is particular to this page, over /shared/base.css (tokens, frame,
   controls, dialog, problems, out-of-date results and the narrow layout). */

:root {
  --yes: #1d6b36;
  --yes-soft: #e7f4eb;
  --no: #6a4a00;
  --no-soft: #fbf1dc;
}
:root[data-theme="dark"] {
  --yes: #86d99b;
  --yes-soft: #17301f;
  --no: #f0c674;
  --no-soft: #33290f;
}

/* ---------- Tables ---------- */

/* Long prediction lists scroll inside their frame; every column fits its width. In one
   column the frame is shorter, so the page still scrolls past it to the results below. */
.table-wrap { max-height: 65vh; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
@media (max-width: 999px) {
  .table-wrap { max-height: 45vh; }
}

table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.3rem 0.4rem; text-align: left; vertical-align: top; }
thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
tbody tr + tr > * { border-top: 1px solid var(--border); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Fixed layout: the header sets the column widths and the prediction column takes the rest. */
.predictions { table-layout: fixed; }
.predictions .index { width: 2.6rem; text-align: right; color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.predictions tr.has-issue .index { color: var(--alert); font-weight: 700; }
.predictions tr.has-issue .index::before { content: "⚠ "; }
.predictions textarea {
  width: 100%;
  resize: none;
  overflow: hidden; /* sized to its content by app.js, so nothing is hidden */
  field-sizing: content;
  display: block;
  line-height: 1.35;
}
.predictions .probability-col { width: 6.8rem; }
.predictions .probability { width: 100%; text-align: right; font-variant-numeric: tabular-nums; }
.predictions .outcome-col { width: 6.4rem; }
.predictions .outcome { width: 100%; }
.outcome[data-state="1"] { background: var(--yes-soft); color: var(--yes); border-color: var(--yes); }
.outcome[data-state="0"] { background: var(--no-soft); color: var(--no); border-color: var(--no); }
.outcome[data-state=""] { border-style: dashed; color: var(--muted); }
.outcome option { background: var(--surface); color: var(--text); }
.predictions .remove-col { width: 3rem; }
.predictions .remove { padding: 0.2rem 0.55rem; font-size: 1.05rem; line-height: 1.2; }

/* On a phone each row takes two lines: the prediction across the full width, then
   probability, outcome and remove beneath it. */
@media (max-width: 560px) {
  .predictions, .predictions thead, .predictions tbody { display: block; }
  .predictions thead { position: sticky; top: 0; z-index: 1; background: var(--surface-2); border-bottom: 1px solid var(--border); }
  .predictions thead th { position: static; border: 0; background: none; }
  .predictions tr {
    display: grid;
    grid-template-columns: 2.2rem minmax(0, 1fr) minmax(0, 1fr) 2.4rem;
    grid-template-areas: "index text text text" "index probability outcome remove";
    gap: 0.3rem 0.4rem;
    padding: 0.4rem;
  }
  .predictions th, .predictions td { display: block; width: auto; padding: 0; }
  .predictions .index { grid-area: index; width: auto; }
  .predictions .text-col { grid-area: text; }
  .predictions .probability-col { grid-area: probability; width: auto; }
  .predictions .outcome-col { grid-area: outcome; width: auto; }
  .predictions .remove-col { grid-area: remove; width: auto; }
  .predictions tbody tr + tr > * { border-top: 0; }
  .predictions tbody tr + tr { border-top: 1px solid var(--border); }
}

.bins { font-size: 0.92rem; border: 1px solid var(--border); }
@media (max-width: 480px) {
  .bins { font-size: 0.84rem; }
  .bins th, .bins td { padding: 0.3rem 0.25rem; }
}
@media (max-width: 360px) {
  .bins { font-size: 0.76rem; }
  .bins th, .bins td { padding: 0.25rem 0.15rem; }
}
.position.inside { color: var(--muted); }
.position.above, .position.below { color: var(--alert); font-weight: 700; }

/* ---------- Results ---------- */

.plot { margin: 0; }
.plot svg { display: block; width: 100%; height: auto; }

.scores { display: grid; gap: 0.6rem; margin: 0; }
.scores > div {
  display: grid;
  grid-template-columns: minmax(0, 13rem) minmax(0, 1fr);
  gap: 0.2rem 1rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.scores dt { font-weight: 600; }
.scores dd { margin: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.score-value { font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-p { font-weight: 600; }
.score-detail { color: var(--muted); font-size: 0.9rem; }
@media (max-width: 560px) {
  .scores > div { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- CSV/TSV dialog ---------- */

.dialog-body textarea {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
  white-space: pre-wrap;
}
