/*
 * Stem-rendering stylesheet: the ff-* (Fault Finding), ec-* (Error
 * Checking), na-* (Numerical Analysis) and nc-* (Numerical Comprehension)
 * classes that authored item stems and statements rely on. Moved here
 * verbatim from candidate.css so both runners render an item identically:
 * candidate.css @imports this file for every native candidate page, and
 * Evenhand loads it directly from its stable, unhashed URL
 * https://itesthub.com/static/css/stems.css (docs/evenhand-api.md).
 *
 * Keep this file free of page chrome (layout, buttons, footer, hub cards):
 * anything here is applied inside the stimulus frame of BOTH runners. Never
 * change what an item looks like for dark mode here -- the stimulus must
 * stay on a light surface for psychometric validity (CLAUDE.md).
 *
 * When you edit this file, bump the ?v= on the @import in candidate.css so
 * cached copies are refreshed.
 */

/* Fault Finding: input -> switch -> output circuit diagram. On/off
   state and switch identity are always given as text as well as shape/
   colour (WCAG 1.4.1 -- never colour/shape alone). */
.ff-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 1rem 0 1.5rem;
  padding: 1.5rem;
  background: #f7f9fb;
  border: 1px solid #d7dee5;
  border-radius: 0.5rem;
}

.ff-column {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
}

.ff-column-label {
  font-weight: 700;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #1c3f60;
  margin-bottom: 0.15rem;
}

.ff-dot {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.ff-dot-circle {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 2px solid #1c3f60;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex: none;
  font-size: 1.05rem;
}

.ff-dot--on .ff-dot-circle {
  background: #fff;
  color: #1c3f60;
}

.ff-dot--off .ff-dot-circle {
  background: #1c3f60;
  color: #fff;
}

.ff-dot-state {
  font-size: 1.05rem;
  font-weight: 600;
  color: #43536b;
  min-width: 2.6rem;
}

.ff-flow {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: center;
}

.ff-arrow {
  color: #1c3f60;
  font-size: 1.3rem;
}

.ff-switch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 4.75rem;
}

.ff-switch-label {
  font-weight: 700;
  color: #1c3f60;
  font-size: 1.1rem;
}

.ff-switch-icon {
  width: 4rem;
  height: 4rem;
  stroke: #1c3f60;
  fill: none;
  stroke-width: 6;
}

/* Fault Finding / Error Checking: response options stacked vertically, one
   per line, left-aligned. Each .form-check must NOT be individually centred
   (e.g. `margin: 0 auto`) -- centring rows independently by their own width
   gives every row a different left edge whenever option text length varies
   (obvious on Error Checking's mix of short/long options), which reads as
   misaligned rather than as a real left-aligned list. */
.ff-response-options {
  text-align: left;
}

.ff-response-options .form-check {
  display: flex;
  align-items: center;
  text-align: left;
  margin: 0 0 0.5rem;
  width: fit-content;
}

.ff-switch-name {
  font-size: 0.95rem;
  /* #43536b measured at 4.45:1 on the diagram's background -- fails
     4.5:1 by a hair (caught by axe-core). #1c3f60 passes, already
     used and verified elsewhere in this component. Kept through the
     candidate-test-revert (this file went back to base.html) because
     CLAUDE.md's standing rule is that no change to this template may
     introduce a WCAG 2.2 AA violation -- a mechanical revert would
     otherwise have silently reintroduced this one. */
  color: #1c3f60;
  text-align: center;
}

.ff-key {
  max-width: 800px;
  width: 100%;
  margin: 1rem auto 0;
  text-align: center;
}

.ff-key table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.05rem;
  text-align: left;
}

.ff-key th,
.ff-key td {
  border: 1px solid #d7dee5;
  padding: 0.4rem 0.6rem;
  text-align: left;
  vertical-align: middle;
}

.ff-key th {
  background: #eef1f4;
}

.ff-key-icon {
  width: 1.8rem;
  height: 1.8rem;
  vertical-align: middle;
  margin-right: 0.4rem;
  stroke: #1c3f60;
  fill: none;
  stroke-width: 6;
}

/* Phones (Rob, 7 Nov 2026): at full size the switches wrap onto a second
   line, leaving Switch C alone and arrows hanging at row ends. Below 576px
   the same diagram is drawn smaller so Input, A, B, C and Output stay on
   one line in their order. Only sizes and spacing change; the shapes,
   the lights, their On/Off fill and every text label are as above. */
@media (max-width: 575.98px) {
  .ff-diagram { flex-wrap: nowrap; gap: clamp(0rem, 0.5vw, 0.3rem); padding: 0.9rem 0.15rem; }
  .ff-flow { flex-wrap: nowrap; gap: clamp(0rem, 0.5vw, 0.15rem); }
  .ff-column { align-items: center; gap: 0.4rem; flex: none; }
  .ff-column-label { font-size: clamp(0.6rem, 2.4vw, 0.75rem); letter-spacing: 0; }
  .ff-dot-circle { width: clamp(1.4rem, 7.5vw, 1.9rem); height: clamp(1.4rem, 7.5vw, 1.9rem); font-size: clamp(0.75rem, 3.4vw, 0.9rem); }
  .ff-arrow { font-size: clamp(0.7rem, 3.2vw, 1rem); }
  .ff-switch { min-width: 0; flex: 0 1 auto; gap: 0.15rem; }
  .ff-switch-label { font-size: clamp(0.62rem, 2.8vw, 0.8rem); white-space: nowrap; letter-spacing: -0.01em; }
  .ff-switch-icon { width: clamp(1.5rem, 9vw, 2.6rem); height: clamp(1.5rem, 9vw, 2.6rem); }
  .ff-switch-name { font-size: clamp(0.65rem, 2.6vw, 0.75rem); }
}


/* Error Checking: consignment-details / pick-manifest comparison tables. */
.ec-table-wrap {
  max-width: 880px;
  width: 100%;
  margin: 1rem auto;
  overflow-x: auto;
}

.ec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.25rem;
}

.ec-table caption {
  font-weight: 700;
  color: #fff;
  background: #1c3f60;
  padding: 0.5rem 0.75rem;
  text-align: left;
  caption-side: top;
  border-radius: 0.375rem 0.375rem 0 0;
}

.ec-table th,
.ec-table td {
  border: 1px solid #d7dee5;
  padding: 0.5rem 0.75rem;
  text-align: left;
  white-space: nowrap;
}

.ec-table th {
  background: #eef1f4;
}

.ec-table--manifest caption {
  background: #43536b;
}

.ec-table--manifest td {
  background: #f7f9fb;
  font-weight: 600;
}

.ec-key {
  max-width: 880px;
  margin: 0.85rem auto;
  padding: 0.6rem 0.9rem;
  border: 1px solid #1c3f60;
  border-radius: 0.4rem;
  background: #eef4fa;
  font-size: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  row-gap: 0.35rem;
}

.ec-key strong {
  color: #1c3f60;
}

.ec-key-label {
  font-weight: 700;
  color: #1c3f60;
  margin-right: 0.75rem;
}

/* Each "CODE = Value" entry as its own pill-like chunk, separated by a
   visible divider rather than relying on raw whitespace in the source
   text -- multiple spaces in HTML collapse to one when rendered, so the
   entries used to run together with barely any visual gap at all. */
.ec-key-item {
  padding-right: 0.9rem;
  margin-right: 0.9rem;
  border-right: 1px solid #9cb7cf;
}

.ec-key-item:last-child {
  padding-right: 0;
  margin-right: 0;
  border-right: none;
}

@media (max-width: 767.98px) {
  .candidate-header {
    padding-block: 0.5rem;
  }

  .candidate-experience main .mt-5 {
    margin-top: 1rem !important;
  }
}

/*
  Numerical Analysis stem visuals (see itesthub/itembank/management/
  commands/seed_numerical_analysis.py): the source material is a set of
  chart/table screenshots. Rather than embed those as flat <img> (the
  approach the older Numerical Reasoning test uses, which fails WCAG
  1.1.1 -- the alt text can't convey a chart's actual data), each stem
  here renders a lightweight CSS/SVG visual plus a real, always-visible
  <table> of the same underlying values, so screen-reader and low-
  vision candidates get the real numbers, not a re-description of a
  picture. All colours below are checked at >= 3:1 against the white
  chart background (a non-text/graphical contrast requirement, WCAG
  1.4.11), and no data series relies on colour alone -- every bar/
  segment/cell also carries a visible number or label.
*/
.na-chart {
  margin: 0 0 1rem;
  padding: 1rem;
  border: 1px solid #d7dee5;
  border-radius: 0.375rem;
  background: #fff;
}

.na-chart-title {
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: #1c3f60;
}

.na-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin: 1rem 0 0;
  font-size: 1rem;
}

.na-chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.na-chart-swatch {
  /* 3x the original 0.85rem -- at the old size the fill patterns
     (stripes/dots/crosshatch) that tell series apart without colour
     were too small to actually distinguish from each other. */
  width: 2.55rem;
  height: 2.55rem;
  border-radius: 0.25rem;
  flex-shrink: 0;
  display: inline-block;
  border: 1px solid rgba(0, 0, 0, 0.25);
}

.na-bars {
  display: flex;
  align-items: flex-end;
  gap: 1.5rem;
  height: 17rem;
  padding-top: 2.2rem;
  border-bottom: 2px solid #495057;
}

/*
  Groups/bars share the container's width proportionally (flex: 1)
  rather than a fixed rem width -- a 5-group x 5-bar chart (e.g.
  monthly rainfall by region) previously forced a fixed ~888px total
  width that overflowed the main content column, clipping the last
  group (see .na-bars used to carry overflow-x: auto -- present but
  easy to miss, not a real fix). Flexible sizing means any number of
  groups/bars always fits the available width, on any screen size, with
  nothing to scroll to.
*/
.na-bar-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
  flex: 1;
}

.na-bar-group-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.5rem;
  height: 14.7rem;
}

.na-bar-group-label {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #1c3f60;
  text-align: center;
}

.na-bar {
  flex: 1;
  min-width: 0;
  max-width: 3.5rem;
  height: calc(var(--pct) * 1%);
  min-height: 2px;
  border-radius: 0.15rem 0.15rem 0 0;
  position: relative;
  display: flex;
  justify-content: center;
}

.na-bar-value {
  position: absolute;
  top: -1.9rem;
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  color: #1a1a1a;
  /* A label can be wider than its own (narrow, 1.4rem) bar and spill
     into a neighbouring bar's column -- a solid background guarantees
     readable contrast regardless of what colour happens to sit behind
     it, rather than depending on precise non-overlapping layout. */
  background: #fff;
  padding: 0.05rem 0.15rem;
  border-radius: 0.2rem;
  z-index: 1;
}

.na-stack {
  width: 100%;
  max-width: 5rem;
  height: 15rem;
  display: flex;
  flex-direction: column-reverse;
  border-radius: 0.15rem 0.15rem 0 0;
  overflow: hidden;
}

.na-stack-segment {
  height: calc(var(--pct) * 1%);
  min-height: 1.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  padding: 0 0.15rem;
}

.na-donut-wrap {
  display: flex;
  justify-content: center;
}

.na-donut-wrap svg {
  /* Fills the available card width up to a sensible cap, instead of a
     small fixed pixel size regardless of how wide its container is --
     the ring used to end up visually occupying only about a quarter
     of its own card. */
  width: 100%;
  max-width: 26rem;
  height: auto;
}

.na-floorplan {
  display: grid;
  width: 100%;
  margin: 0 0 1rem;
  gap: 2px;
}

.na-floorplan-room {
  border: 2px solid #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.15rem;
  text-align: center;
  padding: 1rem;
  min-height: 6rem;
  color: #1a1a1a;
}

.na-floorplan-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.05rem;
  color: #1c3f60;
}

.na-floorplan-label--top {
  align-items: flex-end;
  padding-bottom: 0.35rem;
}

.na-floorplan-label--left {
  justify-content: flex-end;
  padding-right: 0.5rem;
  text-align: right;
}

.na-floorplan-label--right {
  justify-content: flex-start;
  padding-left: 0.5rem;
}

.na-data-table {
  table-layout: fixed;
  width: 100%;
}

.na-data-table caption {
  caption-side: top;
  font-weight: 700;
  color: #1c3f60;
  padding: 0;
  margin-bottom: 0.5rem;
}

.na-peak::after {
  content: " *";
  font-weight: 700;
}

.na-timetable {
  /* Explicit per-column widths via <colgroup> (na-timetable-stop-col /
     na-timetable-time-col, set in render_timetable()) rather than
     na-data-table's bare table-layout:fixed, which -- with no colgroup --
     would force every column including the stop-name one to equal
     width, wrapping long stop names like "London Kings Cross (Arrive)".
     Using fixed WITH an explicit colgroup gets both: a wide-enough
     stop-name column, and -- critically -- Southbound/Northbound each
     rendering as its own <table> with the same column count sized
     identically, so they visually line up. table-layout:auto (the
     previous approach) let each table's columns size independently from
     its own content, which is exactly why they didn't. */
  table-layout: fixed;
}

.na-timetable-stop-col {
  width: 12rem;
}

.na-timetable-time-col {
  width: 3.4rem;
}

.na-timetable th[scope="row"] {
  text-align: left;
}

.na-timetable td,
.na-timetable thead th[scope="col"] {
  white-space: nowrap;
  font-size: 0.85rem;
  padding-left: 0.4rem;
  padding-right: 0.4rem;
  text-align: center;
}

.na-timetable.table-bordered .na-day-boundary {
  /* Marks where one day group's columns (e.g. Saturday) end and the
     next (e.g. Sunday) begins -- thicker than the table's normal 1px
     grid so the day groupings read at a glance. */
  border-left: 3px solid #495057;
}

/* One new modifier on the shared na-floorplan-label family (not a nc-
   prefixed type -- see the block below): Numerical Comprehension's two
   floor plans have a right-hand room shorter than the building, bottom-
   aligned, whose width arrow is drawn UNDER the room instead of above it
   (there's nothing directly above a room that doesn't reach the top
   edge) -- see render_floorplan()'s right_alignment="bottom" branch in
   _numerical_comprehension_charts.py. */
.na-floorplan-label--bottom {
  align-items: flex-start;
  padding-top: 0.35rem;
}

/*
  Numerical Comprehension stem visuals -- new visual types this test needs
  beyond what Numerical Analysis already has (donut/data-table/floorplan
  are reused as-is via the na-chart/na-chart-title/na-chart-legend/
  na-data-table classes above; only the genuinely new shapes get their own
  nc- prefixed classes here, to avoid clashing with na-*).

  One deliberate difference from the block above: these visuals use the
  client's REAL colour palette (hex values from stimuli.json), not
  Numerical Analysis's colour-blind-safe grey+pattern encoding, because
  this test's own items refer to colour by name ("Odd Black numbers",
  "Red bullseye") -- see _numerical_comprehension_charts.py's module
  docstring. Colour is still never the only cue: every value/label is
  real text somewhere (a legend, a gridline tick, a table cell, or a
  visually-hidden per-cell colour name), and contrast for text over these
  fills is checked >= 4.5:1 via the same luminance-based
  _readable_text_color() helper Numerical Analysis uses.
*/

.nc-donut-subtitle {
  margin: -0.5rem 0 0.75rem;
  font-size: 0.95rem;
  color: #495057;
}

.nc-shift-table th[scope="rowgroup"] {
  vertical-align: middle;
  text-align: left;
}

.nc-price-table {
  border-width: 2px;
}

.nc-price-discounts p {
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

/* Roulette betting table (NC4) -- a CSS grid laid directly over the
   green table felt, rather than a <table>: the zero cell and the "2 to
   1"/outside-bet cells span multiple grid rows/columns in a way an HTML
   table would need awkward rowspan/colspan bookkeeping for. The real
   accessible alternative is the visually-hidden number-to-colour
   <table> rendered alongside it (see render_roulette_table). */
.nc-roulette {
  display: grid;
  gap: 2px;
  padding: 0.5rem;
  border-radius: 0.375rem;
}

.nc-roulette-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  min-height: 2.75rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  text-align: center;
  padding: 0.25rem;
}

.nc-roulette-zero {
  font-size: 1.1rem;
}

.nc-roulette-outside {
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.15;
}

.nc-roulette-diamond {
  margin-right: 0.2rem;
}

.nc-roulette-diamond--red {
  color: #f2a49c;
}

.nc-roulette-diamond--black {
  color: #1a1a1a;
  -webkit-text-stroke: 0.5px #dde6d0;
}

/* A subtle texture on top of the red fill -- colour is never the only
   cue telling a red cell from a black one (WCAG 1.4.1); every cell also
   carries a visually-hidden "Red"/"Black" word and a hover title. */
.nc-roulette-cell--red {
  background-image: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.14) 0 3px,
    transparent 3px 7px
  );
}

/* Grouped bar chart (NC6) -- reuses .na-bars/.na-bar sizing from the
   block above, but unlike Numerical Analysis's bars this test's source
   has no floating value label on each bar: values are read off labelled
   y-axis gridlines instead (see render_grouped_bar_chart's docstring),
   so only the gridlines/ticks are new here. */
.nc-bar-grid {
  display: flex;
  align-items: stretch;
}

.nc-bar-grid-ticks {
  position: relative;
  width: 3rem;
  height: 17rem;
  flex-shrink: 0;
  margin-right: 0.5rem;
}

.nc-bar-grid-tick {
  position: absolute;
  right: 0.25rem;
  transform: translateY(50%);
  font-size: 0.8rem;
  color: #495057;
}

.nc-bar-gridlines {
  flex: 1;
  min-width: 0;
  padding-top: 0;
  background-image: repeating-linear-gradient(
    to top,
    #d7dee5 0,
    #d7dee5 1px,
    transparent 1px,
    transparent calc(100% / var(--n-lines))
  );
}

.nc-bar {
  max-width: 4.5rem;
}

/* Line chart (NC8) -- an inline SVG plot (gridlines, two marker/dash
   styles so the series are told apart by more than colour, per-point
   hover titles) beside a real, always-visible side-note panel (e.g.
   "Cost Per Repair: ..."), which several items treat as essential data,
   not decoration. */
.nc-line-chart-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
}

.nc-line-chart-plot {
  flex: 1 1 20rem;
  min-width: 0;
}

.nc-line-chart-plot svg {
  width: 100%;
  height: auto;
}

.nc-line-side-note {
  flex: 0 1 14rem;
  font-size: 0.95rem;
  background: #f8f9fa;
  border: 1px solid #d7dee5;
  border-radius: 0.375rem;
  padding: 0.75rem 1rem;
}

/* Practice-page dartboard (Example Image) -- decorative single-use SVG,
   not reused by any scored stem, so it gets its own small wrapper rather
   than na-chart's title/legend/table furniture. */
.nc-dartboard-wrap {
  text-align: center;
}

.nc-dartboard {
  display: flex;
  justify-content: center;
}

.nc-dartboard svg {
  width: 100%;
  max-width: 24rem;
  height: auto;
}

.nc-dartboard-caption {
  max-width: 40rem;
  margin: 1rem auto 0;
  text-align: left;
}
