/* Anatomy Bench, run 01. The specimen carries the colour; the bench around it
   stays neutral. Serif for what is named, sans for what is measured. */

:root {
  --ground: #e9e7e2;
  --ground-edge: #d3d0c8;
  --ink: #1c1b19;
  --ink-2: #5d5a54;
  --ink-3: #8b877f;
  --sheet: rgba(250, 249, 246, 0.88);
  --sheet-solid: #faf9f6;
  --line: rgba(28, 27, 25, 0.13);
  --press: rgba(28, 27, 25, 0.07);
  --accent: #0d8793;
  --ghost: #55585e;
  --right: #2f8552;
  --wrong: #b8463d;
  --said: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --measured: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --rail: 316px;
  --gap: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #1b1c1e;
    --ground-edge: #0e0f10;
    --ink: #ebe8e2;
    --ink-2: #aba79f;
    --ink-3: #7d7a74;
    --sheet: rgba(30, 31, 33, 0.86);
    --sheet-solid: #1e1f21;
    --line: rgba(235, 232, 226, 0.14);
    --press: rgba(235, 232, 226, 0.08);
    --accent: #45bfca;
    --ghost: #c9ccd2;
    --right: #5cba82;
    --wrong: #e0766c;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  overflow: hidden;
  background: radial-gradient(ellipse at 58% 46%, var(--ground) 0%, var(--ground) 38%, var(--ground-edge) 100%);
  color: var(--ink);
  font: 13px/1.45 var(--measured);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.said { font-family: var(--said); }
.measure { color: var(--ink-2); font-size: 11.5px; letter-spacing: 0.01em; font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline: none; }
#view.turning { cursor: grabbing; }
#view.over { cursor: pointer; }

/* ---- the rail -------------------------------------------------------- */

#rail {
  position: fixed; top: var(--gap); left: var(--gap); bottom: var(--gap); width: var(--rail);
  display: flex; flex-direction: column;
  background: var(--sheet); backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid var(--line); border-radius: 10px;
}
.mast { padding: 16px 18px 10px; display: grid; grid-template-columns: 1fr auto; align-items: baseline; }
.mast h1 { margin: 0; font: 600 21px/1.1 var(--said); letter-spacing: -0.01em; }
.mast .measure { margin: 5px 0 0; grid-column: 1 / -1; }
#rail-toggle { display: none; }
#rail-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }

.search { position: relative; margin: 4px 14px 10px; display: block; }
.search input {
  width: 100%; height: 34px; padding: 0 30px 0 11px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--press); outline-offset: 0;
}
.search input::placeholder { color: var(--ink-3); }
.search kbd {
  position: absolute; right: 8px; top: 8px; width: 18px; height: 18px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 4px; font: 11px var(--measured); color: var(--ink-3); pointer-events: none;
}
.search input:focus + kbd, .search input:not(:placeholder-shown) + kbd { display: none; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 14px; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; padding: 7px 0 8px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }

.panel { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 8px 10px; overscroll-behavior: contain; }
.panel h2 { font: 600 11px var(--measured); letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-3); margin: 10px 10px 6px; }
.panel p { margin: 6px 10px; color: var(--ink-2); }

.credit { padding: 9px 18px 12px; border-top: 1px solid var(--line); display: grid; gap: 3px; font-size: 11px; }
.plain { background: none; border: 0; padding: 0; color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; justify-self: start; }
.plain:hover { color: var(--ink); }

/* ---- layers ---------------------------------------------------------- */

.layer { display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: center; padding: 7px 10px; border-radius: 7px; }
.layer:hover { background: var(--press); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18); }
.layer .name { background: none; border: 0; padding: 0; text-align: left; display: grid; }
.layer .name b { font: 600 14.5px/1.2 var(--said); }
.layer .name span { color: var(--ink-3); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer[data-mode="off"] .name b, .layer[data-mode="off"] .dot { opacity: 0.45; }
.tri { display: inline-grid; grid-auto-flow: column; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.tri button { background: none; border: 0; padding: 3px 7px; font-size: 11px; color: var(--ink-2); min-height: 24px; }
.tri button + button { border-left: 1px solid var(--line); }
.tri button[aria-pressed="true"] { background: var(--ink); color: var(--sheet-solid); }

/* ---- rows: results, tree, members ------------------------------------ */

.row {
  width: 100%; display: grid; grid-template-columns: 12px 1fr auto; gap: 9px; align-items: baseline;
  background: none; border: 0; border-radius: 6px; padding: 5px 10px; text-align: left;
}
.row:hover, .row.at { background: var(--press); }
.row .n { font: 14px/1.25 var(--said); }
.row .m { color: var(--ink-3); font-size: 11px; white-space: nowrap; }
.row .dot { align-self: center; width: 8px; height: 8px; }
.row .dot.set { border-radius: 2px; background: none; box-shadow: inset 0 0 0 1.5px var(--ink-3); }
mark { background: none; color: inherit; font-weight: 700; }

.tree-pick { margin: 4px 10px 8px; }
.tree-pick select, #bar select { height: 28px; border-radius: 6px; border: 1px solid var(--line); background: var(--press); padding: 0 6px; }
.node { margin: 0; padding: 0; list-style: none; }
.node .node { margin-left: 13px; border-left: 1px solid var(--line); }
.node li > div { display: grid; grid-template-columns: 18px 1fr; align-items: baseline; }
.twist { background: none; border: 0; padding: 0; width: 18px; height: 22px; color: var(--ink-3); font-size: 10px; }
.twist[aria-expanded="true"] { transform: rotate(90deg); }
.node .row { grid-template-columns: 1fr auto; padding: 3px 8px; }

/* ---- the inspector --------------------------------------------------- */

#inspector {
  position: fixed; top: var(--gap); right: var(--gap); width: 300px; max-height: calc(100% - 96px); overflow-y: auto;
  background: var(--sheet); backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px 14px;
}
#inspector .kind { display: flex; gap: 7px; align-items: center; color: var(--ink-2); font-size: 11.5px; }
#inspector h2 { margin: 7px 22px 2px 0; font: 600 22px/1.15 var(--said); letter-spacing: -0.01em; text-wrap: balance; }
#inspector .fma { color: var(--ink-3); font-size: 11.5px; user-select: all; }
#inspector .close { position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; border-radius: 6px; border: 0; background: none; color: var(--ink-2); font-size: 16px; line-height: 1; }
#inspector .close:hover { background: var(--press); }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 4px; padding: 10px 0; border-block: 1px solid var(--line); }
.facts div { display: grid; gap: 1px; }
.facts dt, .facts .k { color: var(--ink-3); font-size: 10.5px; letter-spacing: 0.05em; text-transform: uppercase; }
.facts .v { font-size: 13.5px; font-variant-numeric: tabular-nums; }
.lineage { margin: 12px 0 0; }
.lineage h3 { margin: 0 0 3px; font: 600 10.5px var(--measured); letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-3); }
.lineage ol { margin: 0; padding: 0; list-style: none; font: 14px/1.4 var(--said); }
.lineage li { display: inline; }
.lineage li + li::before { content: " \203A  "; color: var(--ink-3); }
.lineage button { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.lineage button:hover { text-decoration-color: var(--ink); }
.acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.acts button, #bar button, dialog button, .quiz button.go, .choice {
  border: 1px solid var(--line); background: var(--press); border-radius: 6px; padding: 5px 10px; min-height: 28px;
}
.acts button:hover, #bar button:hover:not(:disabled), .choice:hover:not(:disabled) { border-color: var(--ink-3); }
.acts kbd { color: var(--ink-3); font: 10.5px var(--measured); margin-left: 4px; }
button:disabled { opacity: 0.4; cursor: default; }
.members { margin: 10px -10px 0; max-height: 38vh; overflow-y: auto; }

/* ---- the bar --------------------------------------------------------- */

#bar {
  position: fixed; bottom: var(--gap); left: calc(var(--rail) + var(--gap) * 2); right: var(--gap);
  display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: center; pointer-events: none;
}
#bar .set {
  pointer-events: auto; display: flex; gap: 4px; align-items: center; padding: 4px;
  background: var(--sheet); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line); border-radius: 9px;
}
#bar button { border-color: transparent; background: none; padding: 4px 9px; }
#bar button:hover:not(:disabled) { background: var(--press); border-color: transparent; }
#bar input[type="range"] { width: 130px; accent-color: var(--ink); }

#tip {
  position: fixed; z-index: 5; pointer-events: none; transform: translate(14px, 16px);
  background: var(--ink); color: var(--sheet-solid); padding: 4px 9px; border-radius: 6px;
  font: 14px/1.3 var(--said); max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

#prompt {
  position: fixed; top: var(--gap); left: calc(var(--rail) + var(--gap) * 2); right: var(--gap); margin: 0 auto; width: fit-content; max-width: min(560px, calc(100% - var(--rail) - 60px));
  background: var(--ink); color: var(--sheet-solid); border-radius: 10px; padding: 10px 18px; text-align: center;
}
#prompt .k { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.65; }
#prompt .q { font: 600 20px/1.2 var(--said); text-wrap: balance; }
#prompt .note { font-size: 12px; opacity: 0.8; min-height: 1.45em; }

/* ---- quiz ------------------------------------------------------------ */

.quiz { padding: 2px 10px; }
.quiz fieldset { border: 0; padding: 0; margin: 8px 0 12px; }
.quiz legend { padding: 0; font: 600 11px var(--measured); letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
.quiz label { display: grid; grid-template-columns: 18px 1fr; gap: 6px; padding: 4px 0; align-items: start; }
.quiz label b { font: 600 14.5px/1.2 var(--said); display: block; }
.quiz label span { color: var(--ink-2); font-size: 11.5px; }
.quiz input { accent-color: var(--ink); margin: 2px 0 0; }
.quiz p { margin: 6px 0; }
.quiz button.go { background: var(--ink); color: var(--sheet-solid); border-color: var(--ink); padding: 7px 14px; font-weight: 600; }
.score { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px 0; border-block: 1px solid var(--line); margin: 10px 0; }
.score .v { font: 600 22px/1 var(--said); font-variant-numeric: tabular-nums; }
.choices { display: grid; gap: 6px; margin: 12px 0; }
.choice { text-align: left; font: 14.5px/1.25 var(--said); padding: 8px 11px; }
.choice.right { border-color: var(--right); color: var(--right); font-weight: 600; }
.choice.wrong { border-color: var(--wrong); color: var(--wrong); }
.missed { margin: 8px 0 0; padding: 0; list-style: none; }

/* ---- loading, about -------------------------------------------------- */

#loading { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; pointer-events: none; transition: opacity 0.5s; padding-left: var(--rail); }
#loading.done { opacity: 0; }
#loading .said { margin: 0; font-size: 19px; }
#loading .track { width: 180px; height: 2px; background: var(--line); }
#loading i { display: block; height: 100%; width: 0; background: var(--ink); transition: width 0.25s; }
#loading .measure { margin: 0; min-height: 1.4em; }

dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--sheet-solid); color: var(--ink); max-width: 520px; padding: 22px 26px 18px; }
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog h2 { margin: 0 0 8px; font: 600 22px var(--said); }
dialog p { margin: 8px 0; color: var(--ink-2); }
dialog dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 16px; margin: 12px 0; font-variant-numeric: tabular-nums; }
dialog dt { color: var(--ink-3); }
dialog dd { margin: 0; }
dialog a { color: inherit; }
dialog form { margin-top: 14px; text-align: right; }

/* ---- a phone: the rail becomes a drawer from the bottom --------------- */

@media (max-width: 780px) {
  :root { --gap: 8px; }
  #rail { top: auto; left: var(--gap); right: var(--gap); bottom: var(--gap); width: auto; max-height: 62vh; }
  #rail.shut #rail-body { display: none; }
  .mast { padding: 10px 14px; }
  .mast h1 { font-size: 17px; }
  .mast .measure { display: none; }
  #rail-toggle { display: block; }
  #bar { left: var(--gap); top: var(--gap); bottom: auto; justify-content: flex-start; flex-wrap: nowrap; gap: 8px; overflow-x: auto; pointer-events: auto; scrollbar-width: none; }
  #bar .set { flex: none; }
  #bar .set:nth-child(2) input { width: 90px; }
  #inspector { top: auto; left: var(--gap); right: var(--gap); bottom: 62px; width: auto; max-height: 34vh; }
  #rail:not(.shut) ~ #inspector { display: none; }
  #prompt { left: var(--gap); top: 96px; max-width: calc(100% - 16px); }
  #loading { padding-left: 0; }
  .tri button, .acts button, #bar button { min-height: 34px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
#loading[hidden] { display: none; }
.score div { display: grid; gap: 1px; }
.score .k { color: var(--ink-3); font-size: 10.5px; letter-spacing: 0.05em; text-transform: uppercase; }
