/* Training matrix, Phase 2 requirement 1.
   Deliberately not reusing the .matrix-* prefix: that belongs to the risk matrix on
   the incident form, which is a different component with different rules.

   Sized so ENV's 35 courses and 53 people fit the page without sideways scrolling.
   Two things buy that: the course name is set on its side in the header, so a long
   name costs height instead of width, and the position sits under the person's name
   rather than in a column of its own. Status is carried by colour AND by the glyph
   in the cell, because colour alone is unreadable to anyone with a colour vision
   deficiency and unusable in print. */
.training-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

/* FB-0055, Emma Roland: "freeze the first row with course names so when you scroll it's
   easier to identify the right course". The name column was already fixed; the header
   was not, and a cell with neither label visible says nothing.

   The panel scrolls in both directions rather than the page, so the header sticks to
   the top of the table itself and never fights the app's own top bar. */
.matrix-sticky {
  max-height: 70vh;
  overflow-y: auto;
}

.matrix-sticky .training-matrix thead th {
  position: sticky;
  top: 0;
  z-index: 5;
}

/* The corner cell sits above both, or the first column slides under the header. */
.matrix-sticky .training-matrix thead .training-person {
  z-index: 6;
}

.training-matrix {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8rem;
  width: 100%;
  table-layout: fixed;
}

.training-matrix th,
.training-matrix td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 0.4rem 0.5rem;
  text-align: left;
  white-space: nowrap;
}

.training-matrix thead th {
  background: var(--ground);
  color: var(--ink-soft);
  vertical-align: bottom;
}

.training-matrix .training-person {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 13.5rem;
  background: var(--panel);
  font-weight: 600;
  color: var(--ink);
}

.training-matrix thead .training-person {
  z-index: 4;
  background: var(--ground);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* The row header is a person's name, not a column label, so it opts out of the
   global uppercase treatment that every other `th` in the app carries. */
.training-matrix tbody .training-person {
  font-size: 0.82rem;
  letter-spacing: 0;
  text-transform: none;
}

.training-role {
  display: block;
  font-weight: 400;
  font-size: 0.68rem;
  color: var(--ink-faint, var(--ink-soft));
  letter-spacing: 0;
  text-transform: none;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* One glyph per cell and the colour behind it. */
.training-cell {
  text-align: center;
  padding: 0.3rem 0.1rem;
}

.training-cell.is-ok { background: var(--ok-bg); }
.training-cell.is-warn { background: var(--amber-bg); }
.training-cell.is-bad { background: var(--red-bg); }
.training-cell.is-info { background: var(--info-bg); }

.training-mark {
  display: inline-block;
  min-width: 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.1rem;
}

.training-cell.is-ok .training-mark { color: var(--ok); }
.training-cell.is-warn .training-mark { color: var(--amber); }
.training-cell.is-bad .training-mark { color: var(--red); }
.training-cell.is-info .training-mark { color: var(--info); }

/* The full course name, set on its side. Height is capped so one very long name
   cannot push the header off the screen; the whole name stays in the title. */
.training-matrix thead .training-course {
  padding: 0.4rem 0.1rem;
  height: 12.5rem;
  text-align: center;
}

.training-course span {
  display: inline-block;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  max-height: 11.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
}

.training-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1.1rem;
  margin: 0 0 0.7rem;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.training-key {
  display: inline-block;
  min-width: 1.15rem;
  height: 1.15rem;
  line-height: 1.15rem;
  text-align: center;
  border-radius: 3px;
  margin-right: 0.15rem;
  vertical-align: -0.25rem;
  font-weight: 700;
  font-size: 0.75rem;
}

.training-key.is-ok { background: var(--ok-bg); border: 1px solid var(--ok); color: var(--ok); }
.training-key.is-warn { background: var(--amber-bg); border: 1px solid var(--amber); color: var(--amber); }
.training-key.is-bad { background: var(--red-bg); border: 1px solid var(--red); color: var(--red); }
.training-key.is-info { background: var(--info-bg); border: 1px solid var(--info); color: var(--info); }

@media (max-width: 900px) {
  .training-matrix { font-size: 0.74rem; }
  .training-matrix .training-person { width: 10rem; }
}

/* Training admin screens: the small pieces the person, catalogue, position and
   course-people pages lean on. Written after seeing them render as bare text, which
   made "Provide First Aid Required Earlier certificate" read as one course name. */
.training-status {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.training-status.is-ok { background: var(--ok-bg); color: var(--ok); }
.training-status.is-warn { background: var(--amber-bg); color: var(--amber); }
.training-status.is-bad { background: var(--red-bg); color: var(--red); }
.training-status.is-info { background: var(--info-bg); color: var(--info); }

/* A label about the row, not part of the name beside it, so it needs to look like
   one. Without this the words simply ran on. */
.tag-required,
td .tag {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--ground);
  color: var(--ink-soft);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: 0.05rem;
}

.tag-required {
  border-color: #cdd9e0;
  background: var(--info-bg);
  color: var(--info);
}

/* An earlier certificate somebody has since renewed. Kept on the page because the
   history is the point of a register, dimmed because it is not the current answer. */
tr.is-superseded td,
tr.is-superseded th {
  color: var(--ink-faint, var(--ink-soft));
  background: var(--ground);
}

.row-actions {
  text-align: right;
  white-space: nowrap;
}

.row-actions form {
  display: inline;
}

.btn-quiet {
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 600;
}

.btn-quiet:hover {
  color: var(--ink);
  border-color: var(--ink-soft);
}

.training-record {
  margin-bottom: 2rem;
}

.training-record h2 {
  font-size: 1.05rem;
  margin: 0 0 0.6rem;
}

/* Course detail and certificate links. */
.training-file {
  display: block;
  font-size: 0.76rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 14rem;
}

.course-description {
  max-width: 70ch;
  margin: 0 0 1rem;
  color: var(--ink-soft);
}

.course-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.9rem 1.5rem;
  margin: 0;
}

.course-facts div {
  border-top: 1px solid var(--line);
  padding-top: 0.5rem;
}

.course-facts dt {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint, var(--ink-soft));
}

.course-facts dd {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.course-positions {
  margin: 0;
  padding-left: 1.1rem;
  columns: 2;
}

/* A description needs the width of the panel, not one cell of the form grid. */
.filter-panel label.wide {
  grid-column: 1 / -1;
}

.filter-panel textarea {
  width: 100%;
  min-height: 4.5rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.88rem;
  resize: vertical;
}

/* A tick box is not a field with a label above it. `.filter-panel label` stacks its
   contents in a column and stretches them to the column width, which turned the two
   checkboxes on the course form into large blue squares. Row direction, and the input
   keeps its own size. */
.filter-panel label.check {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  align-self: center;
}

.filter-panel label.check input[type="checkbox"],
.filter-panel label.check input[type="radio"] {
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
  margin: 0;
}

/* The rotated header is a link now. It keeps the header's colour so the row of
   course names does not turn into a wall of blue, and shows it is a link on hover. */
.training-course a {
  color: inherit;
  text-decoration: none;
  display: inline-block;
}

.training-course a:hover,
.training-course a:focus-visible {
  color: var(--brand-700);
  text-decoration: underline;
}

/* The chosen likelihood or consequence, explained under its picker. ENV's own words
   from HSE-TEM-004, which used to be reachable only through a tooltip and a
   collapsed drawer: neither works on the phone people report from. */
.risk-note {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--ink-soft);
}

.risk-note[hidden] { display: none; }

