/* Class Map -- interactive room assignments.
   Light, print-friendly, no external assets. */

:root {
  --ink: #17212e;
  --muted: #5f6c7b;
  --faint: #8794a3;
  --line: #d3dae1;
  --paper: #eef1f5;
  --card: #ffffff;
  --wall: #26313f;
  --slab: #ffffff;
  --room: #fbfcfd;
  --room-line: #9aa7b4;
  --zone: #e7ebf0;
  /* Circulation and doors keep the source drawing's colour coding: blue for
     the corridor network, yellow for the two foyers, green for the ways
     out. */
  --corridor: #dbe8f4;
  --foyer: #fbf1cf;
  --foyer-line: #d9b93f;
  --exit: #1d7a4c;
  --accent: #1f6f8b;
  --warn: #b23c17;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(23, 33, 46, .06), 0 6px 20px rgba(23, 33, 46, .06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

.muted, .hint { color: var(--muted); font-size: 12.5px; }
.hint { margin: 0 0 10px; }
.palette .muted { margin: 0; }

/* --------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.topbar h1 { font-size: 19px; }
.topbar p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.topbar__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  padding: 7px 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
.btn:hover { border-color: var(--faint); background: #f7f9fb; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: #1a5f78; }
.btn--warn { color: var(--warn); border-color: #e6c4b7; }

/* ----------------------------------------------------------------- tabs */

.tabs {
  display: flex;
  gap: 8px;
  padding: 12px 20px 0;
  flex-wrap: wrap;
}

.tab {
  font: inherit;
  text-align: left;
  cursor: pointer;
  padding: 9px 14px;
  min-width: 148px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  display: grid;
  gap: 1px;
}
.tab strong { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.tab span { font-size: 15px; font-weight: 600; }
.tab em { font-style: normal; font-size: 12px; color: var(--faint); }
.tab:hover { border-color: var(--faint); }
.tab[aria-selected="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.tab[aria-selected="true"] strong { color: var(--accent); }
.tab--compare { min-width: 120px; }

/* ------------------------------------------------------ travel toggles */

.travel {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 20px 0;
}
.travel__label { font-size: 12.5px; color: var(--muted); }

.toggle {
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  padding: 5px 11px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
}
.toggle:hover { border-color: var(--faint); }
.toggle[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  background: #eef6f9;
}

.warn {
  margin: 12px 20px 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: #fdf1ec;
  border: 1px solid #f0cdbe;
  color: var(--warn);
  font-size: 13px;
  font-weight: 550;
}

/* --------------------------------------------------------------- layout */

.layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 250px;
  gap: 16px;
  padding: 16px 20px 32px;
  align-items: start;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.panel h2 {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 8px;
}
.panel__block + .panel__block { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }

.palette { display: flex; flex-direction: column; gap: 6px; min-height: 46px; }
.palette:empty::after { content: ''; }

#palette-drop.is-drop {
  outline: 2px dashed var(--accent);
  outline-offset: 4px;
  border-radius: 8px;
}

.legend { display: flex; flex-wrap: wrap; gap: 6px; }
.legend__item {
  font-size: 11.5px;
  font-weight: 550;
  padding: 3px 8px 3px 20px;
  border-radius: 20px;
  background: #f2f5f8;
  color: var(--muted);
  position: relative;
}
.legend__item::before {
  content: '';
  position: absolute;
  left: 7px; top: 50%;
  width: 8px; height: 8px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--org);
}

/* -------------------------------------------------------------- layouts */

.layouts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

/* A whole arrangement under a name, so two can be compared by clicking
   between them rather than exporting and reading a file back. */
.layout-pill {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  overflow: hidden;
}
.layout-pill:hover { border-color: var(--faint); }
.layout-pill:has(.layout-pill__pick[aria-pressed="true"]) {
  border-color: var(--accent);
  background: #eef6f9;
}

.layout-pill__pick {
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  padding: 5px 11px;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.layout-pill__pick[aria-pressed="true"] { color: var(--accent); }

.layout-pill__drop {
  font: inherit;
  font-size: 14px;
  line-height: 1;
  padding: 0 8px 0 0;
  border: 0;
  background: none;
  color: var(--faint);
  cursor: pointer;
}
.layout-pill__drop:hover { color: var(--warn); }

.btn--wide { width: 100%; }

/* --------------------------------------------------------------- roster */

.roster__seg {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent);
  margin: 14px 0 6px;
}
/* On the whole block the headings are organisations, so they take that
   organisation's colour rather than the generic accent. */
.roster__seg[style*="--org"] { color: var(--org); }
.roster__seg:first-child { margin-top: 0; }

.roster__list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 12.5px;
}

/* Ordered furthest walk first. The bar is the whole measurement: it says
   "further than the one below", which is the only comparison anyone acts on,
   and stops short of implying a surveyed distance. */
.roster__row {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 7px;
  padding: 6px 8px 7px 19px;
  margin-top: 2px;
  position: relative;
  color: inherit;
}
button.roster__row { cursor: pointer; }
button.roster__row:hover { background: #f2f6f9; }
.roster__row::before {
  content: '';
  position: absolute;
  left: 8px; top: 11px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--org);
}
.roster__row.is-focused {
  background: #eef6f9;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.roster__name {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
}

/* The head count, sat against the right edge so a column of them can be
   read down and compared against the rooms they are being dropped into. */
.roster__count {
  flex: none;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: #eef1f5;
  border-radius: 20px;
  padding: 1px 7px;
  font-size: 11.5px;
}
.roster__room { display: block; color: var(--muted); }
.roster__room.is-empty { color: var(--faint); font-style: italic; }

.roster__bar {
  display: block;
  height: 3px;
  margin-top: 5px;
  border-radius: 2px;
  background: #e5eaef;
  overflow: hidden;
}
.roster__bar i { display: block; height: 100%; background: var(--org); }
.roster__bar.is-none { background: transparent; }
.roster__still { display: block; color: var(--faint); font-size: 11.5px; margin-top: 2px; }

/* ------------------------------------------------------------ the plan */

.plan-wrap { min-width: 0; }

.plan {
  position: relative;
  width: 100%;
  aspect-ratio: 1088 / 788;
  container-type: inline-size;
  /* Ground outside the building, so the slab and its walls read as a
     structure sitting on a site rather than white on white. */
  background: #e4e9ef;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.plan__svg,
.plan__overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.plan__overlay { pointer-events: none; }

.plan__note {
  margin: 10px 2px 0;
  font-size: 12.5px;
  color: var(--muted);
  max-width: 70ch;
}

.slab { fill: var(--slab); stroke: none; }
.wall { fill: none; stroke: var(--wall); stroke-width: 5; stroke-linejoin: round; }

.zone-shape { fill: var(--zone); stroke: #ced6de; stroke-width: 1.2; }

/* Corridors are one continuous run made of several overlapping pieces, so
   they carry no stroke -- an internal seam would read as a wall. */
.zone-shape--corridor { fill: var(--corridor); stroke: none; }
.zone-shape--foyer { fill: var(--foyer); stroke: var(--foyer-line); stroke-width: 2; }
.zone-shape--hatch { fill: #e2e6ea; stroke: #c8d0d8; stroke-width: 1.2; }

.room-shape {
  fill: var(--room);
  stroke: var(--room-line);
  stroke-width: 2;
  cursor: pointer;
  transition: fill .12s ease;
}
.room-shape:hover { fill: #eef6f9; }
.room-shape.is-filled { fill: #f3f8fa; stroke: #7d94a2; }
.room-shape.is-drop { fill: #dcedf3; stroke: var(--accent); stroke-width: 3.5; }
.room-shape.is-conflict { stroke: var(--warn); stroke-width: 3.5; }

/* Numbered on the drawing, but spoken for: kitchen, offices, the lounge. */
.room-shape.is-locked { fill: #e6eaee; stroke: #b6c0c9; cursor: default; }
.room-shape.is-locked:hover { fill: #e6eaee; }
.room-shape.is-review { stroke: #8f9fae; stroke-dasharray: 9 6; }

.cross { stroke: #a7b3bf; stroke-width: 2; }

/* The walk between segments. Dotted, because it is a route rather than a
   wall, and graded from the organisation leaving to the one arriving. Leg 1
   is thinner: everybody makes it, so it is background against leg 2. */
.flow {
  fill: none;
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-dasharray: 1 9;
  opacity: .9;
}
.flow--leg1 { stroke-width: 2.4; stroke-dasharray: 1 11; opacity: .55; }
.flow-head { opacity: .9; }
.flow-head--leg1 { opacity: .55; }
.flow-start { opacity: .9; }
.flow-start--leg1 { opacity: .55; }

/* Hovering a walk lifts it clear of the ones sharing its corridor, which is
   how you follow a single group end to end without picking it. */
.flow { pointer-events: stroke; cursor: help; }
.flow:hover {
  stroke-width: 5;
  stroke-dasharray: none;
  opacity: 1;
}

.decor-pew { fill: #eaeef2; }
.decor-stand { fill: none; stroke: #c3ccd5; stroke-width: 3; }

/* ----------------------------------------------------------------- exits */

.exit-sill { stroke: var(--exit); stroke-width: 7; stroke-linecap: round; }
.exit-arrow { fill: var(--exit); }
.exit-sill--minor, .exit-arrow--minor { opacity: .45; }

/* Overlay cells sit exactly over their room polygon. */
.cell {
  position: absolute;
  padding: 2px 3px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}

.cell--zone { align-items: center; justify-content: center; }
.zone-name {
  font-size: 1.05cqw;
  color: var(--faint);
  text-align: center;
  letter-spacing: .02em;
}
.zone-name--foyer { color: #8a6f14; font-weight: 600; }

/* A room that is spoken for still shows what it is; it just cannot take a
   class, so it reads back rather than forward. */
.cell--locked .room-num { color: #8a97a4; }

.cell__head {
  display: flex;
  align-items: baseline;
  gap: .4cqw;
  flex: none;
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  text-align: left;
  min-width: 0;
  cursor: text;
  pointer-events: auto;
}
.cell__head:hover .room-num { color: var(--accent); }

.room-num {
  font-size: 1.9cqw;
  font-weight: 700;
  color: #c2352b;
  line-height: 1;
}
.cell__body {
  display: flex;
  flex-direction: column;
  gap: .25cqw;
  overflow: hidden;
  min-height: 0;
}


/* ---------------------------------------------------------------- chips */

.chip {
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  color: #fff;
  background: var(--org);
  border: 0;
  border-radius: 5px;
  padding: 3px 7px;
  text-align: left;
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  display: block;
  width: 100%;
}
.chip:active { cursor: grabbing; }
.chip.is-selected { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); }

/* Inside a room the chips scale with the plan; in the sidebar they don't.
   Names wrap rather than truncate -- rooms are taller than they are wide,
   so two short lines beat "Builders...". */
.cell .chip {
  font-size: 1.05cqw;
  padding: .28cqw .5cqw;
  border-radius: .35cqw;
  line-height: 1.18;
  white-space: normal;
  /* Wrap between words, never inside one: "Deaco / ns" is worse than a
     second line. */
  overflow-wrap: normal;
}
/* Rooms 6½, 9, 14 and 15 are barely wider than a chip, so they get tighter
   padding. The chip itself stays one size everywhere, on the plan and in the
   panels alike. */
.cell--tight { padding: 1px 2px; }
.cell--tight .chip { padding-left: .2cqw; padding-right: .2cqw; }

.cell .chip__seg {
  display: inline-block;
  font-size: .82cqw;
  opacity: .75;
  margin-right: .3cqw;
  font-weight: 500;
}

.palette .chip { font-size: 13px; }

.ghost {
  position: fixed;
  top: 0; left: 0;
  z-index: 999;
  pointer-events: none;
  background: var(--org);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(23, 33, 46, .3);
}

body.is-dragging { cursor: grabbing; }
body.is-dragging .chip { pointer-events: none; }
body.is-dragging .cell__head { pointer-events: none; }

.plan.is-arming .room-shape { fill: #f2f8fa; }
.plan.is-arming .room-shape:hover { fill: #d9ebf1; }

/* ----------------------------------------------------------- responsive */

@media (max-width: 1180px) {
  .layout { grid-template-columns: 230px minmax(0, 1fr); }
  .panel--roster { grid-column: 1 / -1; }
  .panel--roster #roster { columns: 2; column-gap: 24px; }
}

@media (max-width: 800px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 12px 14px 28px; }
  .panel--roster #roster { columns: 1; }
  .tab { min-width: 0; flex: 1 1 140px; }
  .topbar { padding: 12px 14px; }

  /* A whole 1160-unit plan squeezed into a phone is unreadable, so hold it
     at a legible width and let the reader pan. The scroll lives inside the
     plan, never on the page. */
  .plan-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .plan { min-width: 720px; }
  .plan__note { position: sticky; left: 0; }
  .plan__note::before {
    content: 'Swipe the plan sideways to see the whole building. ';
    color: var(--accent);
  }
}

/* --------------------------------------------------------------- print */

@media print {
  :root { --shadow: none; }
  body { background: #fff; }
  .topbar__actions, .panel--side, .plan__note, .tabs .tab[aria-selected="false"] { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 0; gap: 12px; }
  .panel, .plan { border-color: #bbb; box-shadow: none; }
  .panel--roster #roster { columns: 3; column-gap: 18px; }
  .plan { break-inside: avoid; }
}
