/* ────────────────────────────────────────────────────────────────────────────
   report-table.css — presentation for js/report-table.js.

   Colour is used only to say "outside the range you asked for", and never as
   the sole signal: an out-of-range cell is also given a left rule, so the cue
   survives greyscale printing and the commoner forms of colour blindness.

   Both Bootstrap 5.3 themes are covered through [data-bs-theme="dark"], which
   is what assets/js/theme.js sets.
   ──────────────────────────────────────────────────────────────────────────── */

.rt-wrap {
  max-height: 60vh;
  overflow: auto;
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: .375rem;
}

.rt-table {
  width: 100%;
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
  font-size: .8125rem;
  font-variant-numeric: tabular-nums;
}

.rt-table th,
.rt-table td {
  padding: .3rem .55rem;
  border-bottom: 1px solid var(--bs-border-color-translucent, rgba(0, 0, 0, .09));
  vertical-align: top;
  text-align: left;
}

.rt-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bs-tertiary-bg, #f8f9fa);
  font-weight: 600;
  white-space: nowrap;
  border-bottom-width: 2px;
}

.rt-sortable { cursor: pointer; user-select: none; }
.rt-sortable:hover { background: var(--bs-secondary-bg, #e9ecef); }
.rt-sortable::after { content: "\2195"; opacity: .25; margin-left: .35rem; font-size: .85em; }
.rt-sortable[data-sort="asc"]::after  { content: "\2191"; opacity: .9; }
.rt-sortable[data-sort="desc"]::after { content: "\2193"; opacity: .9; }

.rt-num { text-align: right; }

.rt-seq {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .95em;
  word-break: break-all;
  color: inherit;
}

/* A target heading inside the report. */
.rt-section td {
  background: var(--bs-secondary-bg, #eef1f4);
  font-weight: 600;
  position: sticky;
  top: 1.85rem;
  z-index: 1;
}

/* An explanatory "//" line from the engine: why a candidate was not used. */
.rt-note td {
  background: color-mix(in srgb, var(--bs-warning-bg-subtle, #fff3cd) 55%, transparent);
  font-style: italic;
  border-left: 3px solid var(--bs-warning-border-subtle, #ffe69c);
}
.rt-note td::before { content: "note  "; font-style: normal; opacity: .6; font-size: .9em; }

.rt-text td { opacity: .85; }

/* First row of a new set within the same target. */
.rt-newset td { border-top: 2px solid var(--bs-border-color, #dee2e6); }

/* Out-of-range cues. */
.rt-low  { background: color-mix(in srgb, #0d6efd 9%, transparent); box-shadow: inset 3px 0 0 #0d6efd55; }
.rt-high { background: color-mix(in srgb, #fd7e14 12%, transparent); box-shadow: inset 3px 0 0 #fd7e1466; }

/* The row actions stay reachable however wide the report is: a long report
   scrolls horizontally, and the buttons would otherwise be the first thing to
   disappear off the right-hand edge. */
.rt-actions {
  white-space: nowrap;
  text-align: right;
  position: sticky;
  right: 0;
  background: var(--bs-body-bg, #fff);
  box-shadow: -6px 0 6px -6px rgba(0, 0, 0, .25);
}
thead .rt-actions { background: var(--bs-tertiary-bg, #f8f9fa); z-index: 3; }
.rt-section .rt-actions, .rt-note .rt-actions { background: transparent; box-shadow: none; }

.rt-act {
  display: inline-block;
  font-size: .72rem;
  line-height: 1.1;
  padding: .15rem .4rem;
  margin-left: .2rem;
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: .25rem;
  background: transparent;
  color: var(--bs-secondary-color, #6c757d);
  text-decoration: none;
  cursor: pointer;
}
.rt-act:hover {
  background: var(--bs-secondary-bg, #e9ecef);
  color: var(--bs-body-color, #212529);
}

.rt-caption {
  font-size: .75rem;
  color: var(--bs-secondary-color, #6c757d);
  margin-top: .35rem;
}

/* Switch between the table and the untouched raw report. */
.rt-viewswitch { display: inline-flex; gap: .25rem; }
.rt-viewswitch .btn.active { font-weight: 600; }

[data-bs-theme="dark"] .rt-low  { background: color-mix(in srgb, #6ea8fe 14%, transparent); }
[data-bs-theme="dark"] .rt-high { background: color-mix(in srgb, #ffa94d 16%, transparent); }
[data-bs-theme="dark"] .rt-note td {
  background: color-mix(in srgb, #ffc107 12%, transparent);
  border-left-color: #ffc10766;
}

/* Fallback for engines without color-mix(): plain tints, applied first. */
@supports not (background: color-mix(in srgb, red 50%, transparent)) {
  .rt-low  { background: #eaf1ff; }
  .rt-high { background: #fff1e6; }
  .rt-note td { background: #fff8e1; }
}

@media print {
  .rt-wrap { max-height: none; overflow: visible; }
  .rt-actions { display: none; }
}
