/* The building inspector's five tabs, and what goes with them: the connect
   banner over the plan and the results under the search box.

   index.html links this sheet with the page's others. Tokens only: nothing
   here names a colour. */

/* ---------- The tabs: five in 320 px ---------- */

.bld-inspector .tabs__tab {
  padding: 0 4px;
  font-size: var(--t-sm);
}

.bld-inspector .tabs__panel:focus-visible {
  outline-offset: var(--focus-offset);
}

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

.bi-part {
  padding-top: var(--s-3);
  border-top: var(--border);
}

.bi-part > * + * {
  margin-top: var(--s-3);
}

.bi-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.bi-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
  align-items: end;
}

.bi-side {
  display: grid;
  gap: var(--s-1);
}

.bi-small {
  min-height: 32px;
  padding: 0 var(--s-2);
  font-size: var(--t-sm);
}

.bld-inspector .btn:disabled,
.bld-inspector .btn[aria-disabled="true"] {
  border-color: var(--line);
  background: var(--paper);
  color: var(--ink-2);
  cursor: not-allowed;
  box-shadow: none;
}

.bld-inspector .field__input:disabled {
  background: var(--paper);
  color: var(--ink-2);
}

/* ---------- A select, a checkbox, a slider, a colour ---------- */

.bi-select {
  width: 100%;
  max-width: 100%;
  height: 36px;
  padding: 0 var(--s-2);
  border: var(--border-width) solid var(--line-strong);
  border-radius: var(--r-1);
  background: var(--card);
}

.bi-check {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: var(--s-2);
  row-gap: var(--s-1);
  align-items: center;
}

.bi-check__box {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
}

.bi-check__label {
  font-weight: var(--w-semibold);
}

.bi-check__hint,
.bi-check .field__refusal {
  grid-column: 2;
  margin: 0;
}

.bi-range {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: var(--s-3);
  row-gap: var(--s-1);
  align-items: center;
}

.bi-range .field__label {
  grid-column: 1 / -1;
}

.bi-range__input {
  width: 100%;
  min-height: 28px;
  accent-color: var(--accent);
}

.bi-range__value {
  min-width: 3.5ch;
  text-align: right;
  font-variant-numeric: var(--numeric);
}

.bi-colour {
  width: 64px;
  height: 36px;
  padding: 2px;
  border: var(--border-width) solid var(--line-strong);
  border-radius: var(--r-1);
  background: var(--card);
}

.bi-notice {
  display: grid;
  gap: var(--s-2);
  padding: var(--s-3);
  border: var(--border);
  border-left: 4px solid var(--line-strong);
  background: var(--paper);
}

.bi-notice--problem {
  border-left-color: var(--problem);
}

.bi-notice p {
  margin: 0;
}

.bi-preview {
  margin: 0;
  padding: var(--s-2) var(--s-3);
  border-left: 4px solid var(--line-strong);
  background: var(--paper);
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
}

.bi-preview[data-loss="true"] {
  border-left-color: var(--problem);
}

/* ---------- Lists: teachers, doors, connections, names, areas, exits ---------- */

.bi-people,
.bi-rows,
.bi-findings {
  margin: 0;
  padding: 0;
  list-style: none;
}

.bi-person,
.bi-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-1) 0;
  border-bottom: var(--border);
}

.bi-person:first-child,
.bi-row:first-child {
  border-top: var(--border);
}

.bi-person__name,
.bi-row__text {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.bi-person__main {
  color: var(--ink-2);
  font-size: var(--t-sm);
}

.bi-person .chip__remove {
  border: var(--border-width) solid var(--line-strong);
  border-radius: var(--r-1);
  flex: none;
}

.bi-row--stack {
  display: grid;
  gap: var(--s-2);
  padding: var(--s-3) 0;
}

.bi-row--stack p {
  margin: 0;
}

.bi-row__where {
  font-weight: var(--w-semibold);
}

.bi-row__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

/* ---------- The room list ---------- */

.bi-scroll {
  overflow-x: auto;
}

.bi-scroll .table {
  min-width: 30rem;
}

.bi-scroll .table td {
  padding: var(--s-1);
  vertical-align: top;
}

.bi-scroll .table td.table__num .field__input {
  width: 4.5rem;
  text-align: right;
}

.bi-cell__label {
  display: none;
}

/* The Rooms tab in a panel narrower than its five columns (287 px at 1280,
   DESIGN 16.4): each room stacks into a card, Room and Seats side by side,
   then Teacher, Subject and Features each on a line of its own, every cell
   naming itself. Nothing is cut and nothing hides past a sideways scroll. The
   headings stay as one wrapping row of sort buttons. */

#rooms-table {
  container-type: inline-size;
}

@container (max-width: 30rem) {
  #rooms-table .table,
  #rooms-table thead,
  #rooms-table tbody,
  #rooms-table th,
  #rooms-table td {
    display: block;
  }

  #rooms-table .table {
    min-width: 0;
  }

  #rooms-table thead tr {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-1) var(--s-3);
    padding-bottom: var(--s-2);
  }

  #rooms-table th {
    padding: var(--s-1) 0;
    text-align: left;
  }

  #rooms-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--s-1) var(--s-2);
    padding: var(--s-2) 0;
    border-top: var(--border);
  }

  #rooms-table tbody td {
    min-width: 0;
    padding: 0;
    border-top: 0;
    text-align: left;
  }

  /* Room, Teacher, Subject, Seats, Features: Seats goes up beside Room,
     as wide as three digits, and the room's number or name has the rest */
  #rooms-table tbody td:nth-child(2),
  #rooms-table tbody td:nth-child(3),
  #rooms-table tbody td:nth-child(5) {
    grid-column: 1 / -1;
  }

  #rooms-table tbody td:nth-child(4) {
    grid-row: 1;
    grid-column: 2;
  }

  #rooms-table .bi-cell {
    display: grid;
    grid-template-columns: 4rem minmax(0, 1fr);
    align-items: center;
    gap: var(--s-2);
  }

  #rooms-table tbody td:nth-child(4) .bi-cell {
    grid-template-columns: auto 4rem;
  }

  #rooms-table .bi-cell__label {
    display: block;
    color: var(--ink-2);
    font-size: var(--t-xs);
    font-weight: var(--w-semibold);
  }

  #rooms-table .bi-cell > :last-child,
  #rooms-table td.table__num .field__input,
  #rooms-table .bi-select,
  #rooms-table .bi-features-cell {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  #rooms-table td.table__num .field__input {
    text-align: left;
  }

  #rooms-table .bi-features-cell {
    justify-content: flex-start;
  }
}

/* ---------- The checks ---------- */

.bi-finding {
  display: grid;
  gap: var(--s-2);
  justify-items: start;
  padding: var(--s-3) 0 var(--s-3) var(--s-3);
  border-bottom: var(--border);
  border-left: 4px solid var(--line-strong);
}

.bi-finding:first-child {
  border-top: var(--border);
}

.bi-finding--problem {
  border-left-color: var(--problem);
}

.bi-finding--warning {
  border-left-color: var(--warning);
}

.bi-finding--note {
  border-left-color: var(--note);
}

.bi-finding__text {
  margin: 0;
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
  overflow-wrap: anywhere;
}

.bi-finding--problem .bi-finding__severity {
  color: var(--problem);
}

.bi-finding--warning .bi-finding__severity {
  color: var(--warning);
}

.bi-finding--note .bi-finding__severity {
  color: var(--note);
}

/* ---------- Connect mode: the banner across the top of the plan ---------- */

.bld-connect {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-4);
  background: var(--accent);
  color: var(--accent-ink);
  /* a long list of stops scrolls inside the banner and never covers the whole plan */
  max-height: 60%;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-sizing: border-box;
}

.bld-connect__text {
  flex: 1 1 16rem;
  margin: 0;
  font-weight: var(--w-semibold);
}

.bld-plan[data-connecting="true"] {
  cursor: pointer !important;
}

.bld-plan[data-tracing="true"] {
  cursor: move !important;
}

/* ---------- Search: the results under the box ---------- */

.bld-search__list {
  left: auto;
  right: 0;
  width: min(26rem, calc(100vw - var(--s-5)));
}

.bld-search__name {
  font-weight: var(--w-semibold);
}

/* ---------- Step-free marks (DESIGN 13.2, 13.3) ---------- */

.bi-lead {
  margin: 0;
  overflow-wrap: anywhere;
}

.bi-link {
  color: var(--accent);
}

/* a door's row: its place, its tick and its Remove; 44 px tall to tap */
.bi-row--door {
  flex-wrap: wrap;
  min-height: 44px;
}

.bi-row--door .bi-check,
.bi-row--stack .bi-check {
  min-height: 44px;
  align-content: center;
}

.bi-row--door .bi-check__label,
.bi-row--stack .bi-check__label {
  font-weight: var(--w-regular, normal);
}

/* 44 px at every pointer (DESIGN 13.3), not only a coarse one: the door's and the exit's
   tick (its box and its words, which are the target) and the buttons of the Floor and Exits
   tabs' rows and of a stop's other stops */
.bi-row--door .bi-check__box,
.bi-row--stack .bi-check__box {
  width: 24px;
  height: 24px;
}

.bi-row--door .bi-check__label,
.bi-row--stack .bi-check__label {
  padding: var(--s-2) 0;
}

.bi-row--door .bi-small,
.bi-row--stack .bi-small,
#stop-others .bi-small {
  min-width: 44px;
  min-height: 44px;
}

.bi-buttons--marks {
  padding-top: var(--s-2);
}

/* a tick that is neither on nor off: some of the cells have a step */
.bi-check__box:indeterminate {
  outline: var(--border-width) solid var(--ink-2);
}

.bi-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--s-2);
}

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

.bi-glyph {
  flex: none;
  color: var(--ink);
}

.bi-legend__words {
  overflow-wrap: anywhere;
}

@media (pointer: coarse) {
  .bi-small {
    min-height: 44px;
  }

  .bi-check__box {
    width: 24px;
    height: 24px;
  }

  /* a tick is a finger's height, its words the target */
  .bi-check {
    min-height: 44px;
  }

  .bi-check__label {
    padding: var(--s-2) 0;
  }
}

@media print {
  .bld-connect {
    display: none;
  }
}

/* ---------- Room features: chips, the picker's list, the Rooms tab's popover ---------- */

.bi-features {
  display: grid;
  gap: var(--s-2);
}

.bi-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.bi-chip__button {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  min-height: 44px;
  max-width: 100%;
}

.bi-chip__name {
  overflow-wrap: anywhere;
  text-align: left;
}

.bi-feature-option {
  min-height: 44px;
  display: flex;
  align-items: center;
  overflow-wrap: anywhere;
}

.bi-linkbutton {
  justify-self: start;
  min-height: 44px;
  text-decoration: underline;
}

.bi-features-cell {
  min-height: 44px;
  max-width: 16rem;
  text-align: left;
  overflow-wrap: anywhere;
}

.bi-popover {
  position: fixed;
  inset: auto;
  margin: 0;
  width: min(22rem, calc(100vw - 16px));
  max-height: calc(100vh - 16px);
  overflow: auto;
  padding: var(--s-3);
  background: var(--card);
  color: var(--ink);
  border: var(--border);
  border-radius: var(--r-2);
  box-shadow: var(--shadow);
}

/* The list dialog: a scrolling body and a footer pinned at the bottom (DESIGN 16.12 item 10). */

.features-dialog[open] {
  display: flex;
  flex-direction: column;
  max-height: min(40rem, calc(100dvh - var(--s-4)));
  overflow: hidden;
}

.features-dialog .dialog__title {
  flex: none;
}

.features-dialog .dialog__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.features-dialog .dialog__buttons {
  flex: none;
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: var(--border);
}

.features-dialog__content {
  display: grid;
  gap: var(--s-3);
}

.features-dialog__content p {
  margin: 0;
}

.features-dialog__rows {
  display: grid;
  gap: var(--s-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.features-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--s-2);
  padding-bottom: var(--s-3);
  border-bottom: var(--border);
}

.features-row__name {
  flex: 1 1 12rem;
  min-width: 0;
}

.features-row__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.features-row__buttons .btn {
  min-height: 44px;
  overflow-wrap: anywhere;
}

.features-row__used {
  flex: 1 0 100%;
  color: var(--ink-2);
  font-size: var(--t-sm);
}

.features-dialog__addrow {
  display: flex;
  gap: var(--s-2);
}

.features-dialog__addrow .field__input {
  flex: 1 1 auto;
  min-width: 0;
}

.features-dialog__empty {
  display: grid;
  gap: var(--s-2);
  justify-items: start;
}

.features-dialog__undo {
  padding: var(--s-2);
  border-left: 3px solid var(--accent);
  background: var(--paper);
}

@media (max-width: 520px) {
  .features-row__name {
    flex-basis: 100%;
  }
}

.bi-features .field__input,
.features-dialog .field__input,
.bi-popover .field__input {
  min-height: 44px;
}
