/* The Safety section's own stylesheet (DESIGN 5.5).

   index.html links it (data-sheet="safety"). The section mounts the plan map
   (ui/surface/plan-map.js), whose rules are ui/movement/movement.css's map
   rules and ui/app.css's block for the plan map's sections; what is the
   evacuation view's and the door cards' alone goes here. */

/* ---------- The exits' colours (SV2-72c) ----------

   One colour an exit, in the key's order, --exit-1 to --exit-8; past eight
   they repeat, and the number on each room says which exit (the key says
   so). A categorical set that keeps clear of the severities: no colour's
   hue is within 40 degrees of --problem's or --warning's in either theme
   (the grey has no hue), so the first exit no longer reads as an alarm.
   Each is at least 3:1 on --corridor, --grid and --stairs of its theme,
   since a route lies on corridors and stairs and a frame and a badge on a
   room over the floor, and every pair is at least 0.13 apart in OKLab
   (ui/surface/overlays/evacuation.js EXIT_APART), and as far from --accent
   (--focus) and --ink, since a route lies beside the cursor's ring and the
   rooms' text; no exit is the grey a token that cannot be read falls back to
   (exitColours, #808080). test/ui/exit-colours.test.mjs
   reads this file and tokens.css and holds all of it, and the two dark
   blocks equal, as tokens.css's own test does for its blocks. The theme
   selectors are tokens.css's, so the values are on the page's root and a
   map read before its section is on the page gets them too. */

:root,
[data-theme="light"],
[data-theme="auto"] {
  --exit-1: #255ebc;    /* blue */
  --exit-2: #005700;    /* green */
  --exit-3: #661f75;    /* purple */
  --exit-4: #1b8dae;    /* teal */
  --exit-5: #876fe4;    /* violet */
  --exit-6: #768b09;    /* olive */
  --exit-7: #48423f;    /* grey */
  --exit-8: #c34e97;    /* pink */
}

[data-theme="dark"] {
  --exit-1: #90a5e7;    /* blue */
  --exit-2: #37a643;    /* green */
  --exit-3: #e7bafc;    /* purple */
  --exit-4: #60edfc;    /* teal */
  --exit-5: #846ce0;    /* violet */
  --exit-6: #b7d341;    /* olive */
  --exit-7: #8c8c8c;    /* grey */
  --exit-8: #f07ec2;    /* pink */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]),
  [data-theme="auto"] {
    --exit-1: #90a5e7;    /* blue */
    --exit-2: #37a643;    /* green */
    --exit-3: #e7bafc;    /* purple */
    --exit-4: #60edfc;    /* teal */
    --exit-5: #846ce0;    /* violet */
    --exit-6: #b7d341;    /* olive */
    --exit-7: #8c8c8c;    /* grey */
    --exit-8: #f07ec2;    /* pink */
  }
}

/* ---------- The key, docked under the map ---------- */

.sfy-key {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s-1) var(--s-3);
  padding: var(--s-2) var(--s-4);
  background: var(--card);
  border-top: var(--border);
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
  font-variant-numeric: tabular-nums;
}

.sfy-key__title {
  font-weight: var(--w-semibold);
}

.sfy-key__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1) var(--s-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.sfy-key__list[hidden],
.sfy-key__marks[hidden],
.sfy-key__note[hidden] {
  display: none;
}

.sfy-key__item {
  display: inline-flex;
  align-items: baseline;
  gap: var(--s-1);
  min-width: 0;
}

.sfy-key__marks {
  margin: 0;
}

/* the colours repeat past ten; zoom in for the numbers: a line of its own */
.sfy-key__note {
  flex-basis: 100%;
  margin: 0;
  color: var(--ink-2);
}

/* an exit's number on its colour: the badge drawn on a room, in words too */
.sfy-swatch {
  display: inline-block;
  flex: none;
  min-width: 1.5em;
  padding: 0 0.3em;
  border-radius: var(--r-1);
  /* the colour and the number's ink are set where it is made, the ink by
     labelOn() (ui/colour.js) so the number reads at 4.5:1 on any exit colour */
  font-weight: var(--w-semibold);
  text-align: center;
}

.sfy-swatch--small {
  min-width: 1.3em;
  font-size: var(--t-xs);
  line-height: var(--lh-sm);
}

/* ---------- The empty screen ---------- */

.sfy-empty[hidden] {
  display: none;
}

.sfy-empty {
  padding: var(--s-6) var(--s-5) max(var(--s-6), var(--toast-room, 4.75rem));
}

/* ---------- The inspector ---------- */

.sfy-panel__lead {
  margin: var(--s-2) 0 0;
  color: var(--ink-2);
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
}

.sfy-exits,
.sfy-rooms,
.sfy-missing,
.sfy-rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sfy-exit {
  margin-top: var(--s-4);
  padding-top: var(--s-3);
  border-top: var(--border);
}

.sfy-exit__name {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  margin: 0;
  font-size: var(--t-md);
  line-height: var(--lh-md);
  font-weight: var(--w-semibold);
}

.sfy-exit__where,
.sfy-exit__assembly,
.sfy-missing__why,
.sfy-missing__none {
  margin: var(--s-1) 0 0;
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
}

.sfy-exit__assembly--none {
  color: var(--ink-2);
}

.sfy-rooms {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  margin-top: var(--s-2);
}

/* a room's name: shows its way out on the map */
.sfy-room {
  min-height: 28px;
  padding: 0 var(--s-2);
  border: var(--border-width) solid var(--line-strong);
  border-radius: var(--r-1);
  background: var(--card);
  color: var(--ink);
  font-size: var(--t-sm);
}

.sfy-room:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.sfy-room[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: var(--w-semibold);
}

.sfy-missing__row {
  margin-top: var(--s-3);
}

.sfy-cards__print {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--s-2);
  margin-top: var(--s-3);
}

.sfy-cards__print [hidden] {
  display: none;
}

.sfy-cards__hint {
  margin: 0;
  color: var(--ink-2);
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
}

.sfy-floor {
  margin: var(--s-3) 0 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.sfy-floor__name {
  padding: 0;
  font-weight: var(--w-semibold);
}

.sfy-row {
  padding: var(--s-2) 0;
  border-bottom: var(--border);
}

.sfy-row__head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.sfy-row__box {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.sfy-row__name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: var(--w-medium);
  overflow-wrap: anywhere;
}

.sfy-row__show {
  flex: none;
  font-size: var(--t-sm);
}

.sfy-row__way {
  margin: var(--s-1) 0 0 calc(18px + var(--s-2));
  color: var(--ink-2);
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
  overflow-wrap: anywhere;
}

.sfy-row__way[data-way="none"] {
  color: var(--problem);
}

/* The Everyone / Step-free switch at the top of the inspector (DESIGN 13.6) */
.sfy-view {
  margin-bottom: var(--s-3);
  padding-bottom: var(--s-3);
  border-bottom: var(--border);
}

.sfy-view__label {
  display: block;
  margin-bottom: var(--s-1);
  color: var(--ink-2);
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
}

.sfy-view .seg__option {
  display: flex;
}

.sfy-view__line {
  margin: var(--s-2) 0 0;
  color: var(--ink-2);
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
}

/* the Step-free lists and the report: rows with no tick before them */
.sfy-way .sfy-row__way,
.sfy-report .sfy-row__way,
.sfy-refuge__use {
  margin-left: 0;
}

.sfy-way[data-way="none"] .sfy-row__way {
  color: var(--problem);
}

.sfy-ways,
.sfy-floor-report,
.sfy-day {
  margin-top: var(--s-3);
}

.sfy-row__floor {
  color: var(--ink-2);
  font-weight: var(--w-regular);
}

.sfy-refuges {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sfy-refuge {
  padding: var(--s-2) 0;
  border-bottom: var(--border);
}

.sfy-refuge__name {
  margin: 0;
  font-size: var(--t-md);
  line-height: var(--lh-md);
  font-weight: var(--w-semibold);
}

.sfy-refuge__use {
  margin-top: var(--s-1);
  margin-bottom: 0;
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
}

.sfy-unmarked {
  margin: var(--s-2) 0;
  padding: var(--s-2) var(--s-3);
  border: var(--border);
  border-left: 4px solid var(--warning);
  border-radius: var(--r-1);
  background: var(--card);
}

.sfy-unmarked .sfy-panel__lead {
  margin: 0 0 var(--s-2);
}

.sfy-cards__step {
  margin-top: var(--s-3);
}

.sfy-cards__step-label {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: var(--w-medium);
}

.sfy-cards__step-box {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

/* Under 640 px, or on a coarse pointer, every control here takes a finger
   (DESIGN 5.3, Targets): 44 px in its smaller dimension. */
@media (max-width: 640px), (pointer: coarse) {
  .sfy-room,
  .sfy-inspector .btn,
  .sfy-view .seg__label {
    min-height: 44px;
  }

  .sfy-cards__step-label {
    min-height: 44px;
  }

  .sfy-cards__step-box {
    width: 24px;
    height: 24px;
  }

  .sfy-row__head {
    min-height: 44px;
  }

  .sfy-row__box {
    width: 24px;
    height: 24px;
  }

  .sfy-row__name {
    display: flex;
    align-items: center;
    align-self: stretch;
  }

  .sfy-row__show {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
  }

  .sfy-row__way {
    margin-left: calc(24px + var(--s-2));
  }
}

/* ---------- The load warning, the trial band and the What if tab (SV2-109; DESIGN 14) ---------- */

/* five tabs: they scroll sideways when the window is narrow, each keeping its name whole */
.sfy-inspector .tabs__list {
  overflow-x: auto;
  scrollbar-width: thin;
}

.sfy-inspector .tabs__tab {
  flex: 1 0 auto;
  padding: 0 var(--s-3);
}

/* from 1024 px the inspector is wide enough for no scrolling: a tighter padding, and the row wraps
   to a second line rather than cut a name, so every tab lies wholly inside its row */
@media (min-width: 1024px) {
  .sfy-inspector .tabs__list {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .sfy-inspector .tabs__tab {
    flex: 1 1 auto;
    padding: 0 var(--s-2);
  }
}

.sfy-load {
  margin-top: var(--s-3);
}

/* a warning in words first ("Warning", "Far more than the others"), the colour second */
.sfy-warn {
  margin: 0;
  padding: var(--s-2) var(--s-3);
  border: 2px solid var(--warning);
  border-radius: var(--r-1);
  background: var(--card);
}

.sfy-warn p,
.sfy-note {
  margin: var(--s-1) 0 0;
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
}

.sfy-warn__head {
  margin-top: 0;
  color: var(--warning);
}

.sfy-warn__head::before {
  content: "\26A0\FE0E\00A0";
}

.sfy-warn__rule,
.sfy-note {
  color: var(--ink-2);
}

.sfy-heavy {
  color: var(--warning);
  font-weight: var(--w-semibold);
}

.sfy-heavy--blocked {
  color: var(--problem);
}

.sfy-exit__was {
  color: var(--ink-2);
}

/* the trial band: above the map, on every tab, never over it */
.sfy-band {
  display: flex;
  align-items: center;
  gap: var(--s-2) var(--s-3);
  flex-wrap: wrap;
  margin-top: var(--s-2);
  padding: var(--s-1) var(--s-3);
  border: 2px solid var(--problem);
  border-radius: var(--r-1);
  background: var(--card);
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
}

.sfy-band[hidden] {
  display: none;
}

.sfy-band__text {
  flex: 1 1 12rem;
  min-width: 0;
  margin: 0;
  font-weight: var(--w-semibold);
  overflow-wrap: anywhere;
}

.sfy-band__short {
  display: none;
}

.sfy-band__clear {
  flex: none;
  min-height: 44px;
  min-width: 44px;
}

/* a phone: one line, "Trial · 2 blocked · Clear"; the sentence is the screen's first line */
@media (max-width: 640px) {
  .sfy-band {
    flex-wrap: nowrap;
  }

  .sfy-band__long {
    display: none;
  }

  .sfy-band__short {
    display: inline;
  }
}

.sfy-ticks {
  margin: var(--s-3) 0 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.sfy-ticks__legend {
  padding: 0;
  font-weight: var(--w-semibold);
}

.sfy-ticks__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sfy-tick {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  border-bottom: var(--border);
}

.sfy-tick__box {
  flex: none;
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--accent);
}

.sfy-tick__label {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-self: stretch;
  gap: 0 var(--s-1);
  min-width: 0;
  overflow-wrap: anywhere;
}

.sfy-tick__words {
  min-width: 0;
}

.sfy-whatif__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-3);
}

.sfy-whatif__actions .btn {
  min-height: 44px;
}

.sfy-chips {
  margin: var(--s-2) 0 0;
  padding: 0;
  list-style: none;
}

.sfy-chips[hidden] {
  display: none;
}

.sfy-chip {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
}

.sfy-chip__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

.sfy-results {
  margin-top: var(--s-4);
}

.sfy-results__sentence {
  margin: 0;
  font-size: var(--t-lg);
  line-height: var(--lh-lg);
}

.sfy-results__none {
  margin: 0;
  color: var(--ink-2);
  font-size: var(--t-sm);
}

.sfy-whatif .sfy-row__way {
  margin-left: 0;
}

.sfy-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-sm);
  font-variant-numeric: tabular-nums;
}

.sfy-table th,
.sfy-table td {
  padding: var(--s-1) var(--s-2);
  border-bottom: var(--border);
  text-align: left;
  vertical-align: baseline;
}

.sfy-table thead th {
  font-weight: var(--w-semibold);
}

.sfy-table__exit {
  font-weight: var(--w-medium);
}

/* a phone: each exit is two lines, the exit and then its figures before and after */
@media (max-width: 640px) {
  .sfy-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .sfy-table,
  .sfy-table tbody {
    display: block;
  }

  .sfy-table__row {
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--s-3);
    padding: var(--s-1) 0;
    border-bottom: var(--border);
  }

  .sfy-table__row th,
  .sfy-table__row td {
    padding: var(--s-1) 0;
    border: 0;
  }

  .sfy-table__exit {
    flex: 1 0 100%;
  }

  .sfy-table td::before {
    content: attr(data-label) " ";
    color: var(--ink-2);
  }
}

/* ---------- The Prints tab (ui/safety/prints.js) ---------- */

.sfy-prints__card {
  margin-top: var(--s-4);
  padding-top: var(--s-3);
  border-top: var(--border);
}

.sfy-prints__ticks {
  min-width: 0;
}

.sfy-prints__all {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-2);
}

.sfy-prints__all .btn {
  min-height: 44px;
}

.sfy-prints__go {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-3);
  margin-top: var(--s-3);
}

.sfy-prints__preview {
  min-height: 44px;
}

.sfy-prints__preview[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
}

.sfy-prints__warn:not(:empty) {
  margin-top: var(--s-3);
}

.sfy-prints__missing {
  margin: var(--s-1) 0 0;
  padding-left: var(--s-4);
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
}

.sfy-prints .seg {
  margin-top: var(--s-3);
}
