/* Fablab RUC equipment finder */
:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #667085;
  --line: #d9dee5;
  --accent: #0b6bcb;
  --hit: #e8590c;
  --alt: #f2b84b;
  --note-bg: #fff4e5;
  --note-line: #e8590c;
  --error: #c92a2a;
  --ok: #2b8a3e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c; --card: #1b2129; --text: #e6e9ee; --muted: #98a2b3; --line: #2f3742;
    --accent: #5aa9f0; --note-bg: #332312;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px 16px 48px; }
a { color: var(--accent); }
h1 { margin: 8px 0 4px; font-size: 1.8rem; }
h2 { font-size: 1.2rem; margin: 24px 0 8px; }
h3 { font-size: 1rem; margin: 0 0 8px; }
.muted { color: var(--muted); font-weight: normal; }
.error { color: var(--error); font-weight: 600; }
.sr-only, .hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Question form */
.ask { display: flex; gap: 8px; margin: 16px 0; }
.ask input[type=text] {
  flex: 1; min-width: 0; font-size: 1.15rem; padding: 12px 14px;
  border: 2px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text);
}
.ask input[type=text]:focus { outline: none; border-color: var(--accent); }
button {
  font: inherit; font-weight: 600; padding: 10px 18px; border: 0; border-radius: 10px;
  background: var(--accent); color: #fff; cursor: pointer;
}
button:hover { filter: brightness(1.1); }
button:disabled { opacity: .7; cursor: wait; filter: none; }
.spinner {
  display: inline-block; width: 1em; height: 1em; margin-right: 8px; vertical-align: -2px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.busy-note { color: var(--muted); }
.examples ul { padding-left: 20px; color: var(--muted); }

/* Shelf diagram */
.shelf { margin: 16px 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.shelf figcaption { font-weight: 600; margin-bottom: 6px; }
.shelf-scroll { overflow-x: auto; }
.shelf svg { display: block; }  /* fixed scale; wide shelves scroll sideways on small screens */
.shelf .door .leaf { fill: #a8dcf7; stroke: #3a8fc4; stroke-width: 1.5; }
.shelf .door .knob { fill: #2b6f99; }
.shelf .lbl { font-size: 12px; fill: var(--muted); font-weight: 600; }
.shelf .nobox { fill: none; stroke: var(--line); stroke-dasharray: 3 3; }
.shelf .box rect { fill: var(--bg); stroke: var(--line); }
.shelf .box text { font-size: 9px; fill: var(--muted); }
.shelf .box.empty rect { fill: none; }
.shelf .box.empty text { opacity: .4; }
.shelf .hit rect { fill: var(--c, var(--hit)); stroke: #000; stroke-width: 1.5; }
.shelf .hit .code { font-size: 14px; font-weight: 700; fill: var(--ct, #fff); }
.shelf .hit.alt rect { fill: var(--cp, var(--alt)); stroke: #555; }
.shelf .hit.alt .code { fill: #000; }
.shelf .hit .badge { fill: #1c2430; stroke: #fff; stroke-width: 1.5; }
.shelf .hit .badge-n { font-size: 10px; font-weight: 700; fill: #fff; }
@media (prefers-reduced-motion: no-preference) {
  .shelf .hit:not(.alt) rect { animation: pulse 1.4s ease-in-out 3; }
  @keyframes pulse { 50% { opacity: .45; } }
}

/* Answer */
.answer .summary { font-size: 1.1rem; margin: 12px 0; }
.boxes { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.boxes li { display: flex; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.boxes .num {
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: 6px; background: var(--c, var(--hit)); color: var(--ct, #fff);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.boxes li { border-left: 8px solid var(--c, var(--hit)); }
.boxes li.alt .num { background: var(--cp, var(--alt)); color: #000; }
.boxes li.alt { border-left-color: var(--cp, var(--alt)); }

/* Rainbow colours for numbered boxes: --c bright, --cp pastel (alternatives), --ct text on bright */
.c0 { --c: #e53935; --cp: #ffcdd2; --ct: #fff; }  /* red */
.c1 { --c: #fb8c00; --cp: #ffe0b2; --ct: #000; }  /* orange */
.c2 { --c: #fdd835; --cp: #fff9c4; --ct: #000; }  /* yellow */
.c3 { --c: #8bc34a; --cp: #dcedc8; --ct: #000; }  /* lime */
.c4 { --c: #2e9e44; --cp: #c8e6c9; --ct: #fff; }  /* green */
.c5 { --c: #00bcd4; --cp: #b2ebf2; --ct: #000; }  /* cyan */
.c6 { --c: #1e88e5; --cp: #bbdefb; --ct: #fff; }  /* blue */
.c7 { --c: #3949ab; --cp: #c5cae9; --ct: #fff; }  /* indigo */
.c8 { --c: #8e24aa; --cp: #e1bee7; --ct: #fff; }  /* violet */
.c9 { --c: #e91e8c; --cp: #f8bbd0; --ct: #fff; }  /* pink */
.boxhead .pos { font-size: 1.15rem; margin-right: 6px; }
.boxhead .room { color: var(--muted); margin-right: 6px; }
.boxhead .name { font-weight: 600; }
.contents, .why { color: var(--muted); }
.note { background: var(--note-bg); border-left: 4px solid var(--note-line); padding: 4px 8px; margin: 4px 0; font-weight: 600; }
.safety li { color: var(--error); }
.steps li { margin-bottom: 6px; }
.offtopic { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.disclaimer { color: var(--muted); font-size: .85rem; margin-top: 24px; }

/* Admin and log */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin: 16px 0; overflow-x: auto; }
.card.ok { border-color: var(--ok); }
.login input { font: inherit; padding: 8px; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 16px 0; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; color: var(--muted); font-size: .9rem; }
.tile .big { display: block; font-size: 1.6rem; font-weight: 700; color: var(--text); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0 12px; }
.grid2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 24px; }
.stat meter { width: 120px; }
.inline { margin-bottom: 8px; }
.inline select { font: inherit; }
.logitem { border-bottom: 1px solid var(--line); padding: 6px 0; }
.logitem summary { cursor: pointer; }
.logbody { padding: 4px 0 4px 16px; }
.tag { display: inline-block; font-size: .75rem; padding: 0 6px; border-radius: 4px; background: var(--bg); border: 1px solid var(--line); margin-right: 4px; }

@media (max-width: 600px) {
  .ask { flex-direction: column; }
  body { font-size: 16px; }
}

/* Room names link to the campus map */
.maplink { font-weight: 600; }
.maplink::after { content: " ↗"; font-size: .8em; }

/* Front page footer link */
.bottom { margin-top: 40px; padding-top: 12px; border-top: 1px solid var(--line); }

/* All boxes page */
.allboxes .wrap { max-width: none; }
.room-block { margin: 24px 0 40px; }
.room-block h2 { font-size: 1.4rem; }
.room-block h3 { margin: 16px 0 8px; }
.shelf-table-scroll { overflow: auto; max-height: 90vh; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.shelf-table { border-collapse: separate; border-spacing: 4px; width: auto; font-size: .85rem; }
.shelf-table th { text-align: center; color: var(--muted); font-weight: 700; border: 0; padding: 2px 4px;
  position: sticky; top: 0; background: var(--card); z-index: 2; }
.shelf-table th.rowh { position: sticky; left: 0; z-index: 1; }
.shelf-table td { border: 0; padding: 0; }
.shelf-table .cell {
  position: relative; width: 120px; min-width: 120px; height: 58px; vertical-align: top;
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; background: var(--bg); cursor: default;
}
.shelf-table .cell .pos { display: block; font-weight: 700; }
.shelf-table .cell .label { display: block; line-height: 1.2; overflow-wrap: anywhere; }
.shelf-table .cell.empty .label, .shelf-table .nobox .pos { color: var(--muted); }
.shelf-table .nobox { border: 1px dashed var(--line); border-radius: 6px; background: none; width: 120px; min-width: 120px; padding: 4px 6px; vertical-align: top; }
.shelf-table .cell:hover, .shelf-table .cell:focus { outline: 2px solid var(--accent); z-index: 5; }
.shelf-table .pop {
  display: none; position: absolute; top: 100%; left: 0; z-index: 10; width: 260px; margin-top: 4px;
  background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.18); padding: 8px 10px; font-size: .9rem;
}
.shelf-table .cell.up .pop { top: auto; bottom: 100%; margin: 0 0 4px; }
.shelf-table .cell.left .pop { left: auto; right: 0; }
.shelf-table .cell:hover .pop, .shelf-table .cell:focus .pop { display: block; }
.shelf-table .pop-name { font-weight: 700; margin: 4px 0; }
.shelf-table .door-cell { position: relative; width: 244px; min-width: 244px; padding: 0; }  /* each leaf as wide as a box */
.shelf-table .door-leaves { position: absolute; inset: 0; display: flex; gap: 2px; }
.shelf-table .door-leaves span { flex: 1; background: #a8dcf7; border: 1.5px solid #3a8fc4; border-radius: 3px; }
.shelf-table th.door-h { font-weight: 600; }

/* "Show me more" under an answer */
form.more { margin: 16px 0; }
.linkbutton { background: none; color: var(--accent); padding: 0; font-weight: 600; text-decoration: underline; }
.linkbutton:hover { filter: none; opacity: .8; }
