/* The obstacle course, on top of web/style.css (its tokens, type and credit):
   the room fills the stage, a sheet on the right (a strip at the bottom on
   phones) holds the hint, the buttons and two tabs, the physics readout and
   the robot's log; the clock hangs over the room. */

body.course { --sheet-w: 340px; }
body.course #stage { cursor: default; }
body.course #stage.grab { cursor: grab; }
body.course #stage.grabbing { cursor: grabbing; }
#overlay { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }

body.course .masthead { max-width: min(30ch, calc(100vw - var(--sheet-w) - 3 * var(--m))); }
body.course .intro { font-size: 1rem; }

.clock {
  position: fixed; top: var(--m); left: calc((100vw - var(--sheet-w)) / 2); transform: translateX(-50%); margin: 0; z-index: 2;
  font: 400 clamp(2rem, 1.4rem + 2vw, 3.2rem)/1 var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
  color: var(--ink);
}
.clock.low { color: var(--accent); }

.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--sheet-w); z-index: 3;
  background: var(--panel); border-left: 1px solid var(--rule);
  display: flex; flex-direction: column; gap: 16px; padding: calc(var(--m) + 8px) 22px var(--m);
}
.hint { margin: 0; font: 380 1.08rem/1.35 var(--f-display); color: var(--ink-2); text-wrap: pretty; min-height: 2.7em; }
.hint.bad { color: var(--heat-2); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 16px;
  border: 1px solid var(--rule-strong); border-radius: 3px; background: transparent; color: var(--ink);
  font: 500 14px/1 var(--f-text); cursor: pointer; transition: background-color 150ms var(--ease-q), border-color 150ms var(--ease-q);
}
.actions button:hover { border-color: var(--ink); }
.actions button.primary { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.actions button.primary:hover { background: #000; }
.actions button:disabled { opacity: 0.4; cursor: not-allowed; }

.panes { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.panes[hidden] { display: none; }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--rule); }
.tabs button {
  min-height: 36px; padding: 6px 14px 7px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none;
  color: var(--ink-3); font: 500 13px/1 var(--f-text); cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.log, .readout { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.log[hidden], .readout[hidden] { display: none; }
.log h2, .readout h2 { margin: 0 0 6px; }
.log ol { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; scrollbar-width: thin; }

/* the readout: live values, then each attempt's measured events (newest first) */
.readout .scope, .closest .scope { margin: 0 0 10px; font-size: 12px; line-height: 1.4; color: var(--ink-3); text-wrap: pretty; }
.readout .live { display: grid; gap: 2px; margin: 0 0 10px; padding: 8px 0; border-block: 1px solid var(--rule); font-size: 12.5px; }
.readout .live div { display: grid; grid-template-columns: 9.5em 1fr; gap: 12px; }
.readout .live dt { color: var(--ink-3); }
.readout .live dd { margin: 0; font: 400 12px/1.5 var(--f-mono); font-variant-numeric: tabular-nums; color: var(--ink); }
.readout .attempts { overflow-y: auto; flex: 1; min-height: 0; scrollbar-width: thin; }
.attempt h3 { margin: 10px 0 4px; font: 600 12px/1.3 var(--f-text); letter-spacing: 0.02em; color: var(--ink-2); }
.attempt ol { list-style: none; margin: 0; padding: 0; }
.attempt li { display: grid; grid-template-columns: 3.4em 1fr; gap: 8px; padding: 5px 0; border-top: 1px solid var(--rule); font-size: 12.5px; line-height: 1.35; }
.attempt li time { font: 400 11px/1.6 var(--f-mono); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.attempt li.first span { color: var(--heat-2); }
.attempt li em { font: 500 10.5px/1 var(--f-text); font-style: normal; letter-spacing: 0.04em; text-transform: uppercase; color: var(--heat-2); white-space: nowrap; }
.attempt li.end span { font-weight: 560; }
.attempt li.end.win span { color: var(--ink); }
.attempt li.none { display: block; color: var(--ink-3); }
.attempt li.input span { color: var(--ink-2); }
.attempt li.input em { color: var(--ink-3); }
/* every event, in time order, behind a disclosure */
.attempt details { margin: 2px 0 6px; }
.attempt summary {
  min-height: 32px; display: flex; align-items: center; gap: 6px; cursor: pointer; list-style: none;
  font: 500 12px/1.3 var(--f-text); color: var(--ink-3);
}
.attempt summary::-webkit-details-marker { display: none; }
.attempt summary::before { content: "+"; font: 400 13px/1 var(--f-mono); width: 1em; text-align: center; }
.attempt details[open] summary::before { content: "–"; }
.attempt summary:hover { color: var(--ink); }
.attempt summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.attempt details ol li { font-size: 12px; color: var(--ink-2); }
.log li { display: grid; grid-template-columns: 3.4em 1fr; gap: 8px; padding: 6px 0; border-top: 1px solid var(--rule); font-size: 13.5px; line-height: 1.35; }
.log li time { font: 400 11px/1.6 var(--f-mono); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.log li.fail { color: var(--heat-2); }
.log li.done { color: var(--ink); font-weight: 560; }
.log li.claude { color: var(--ink); }
.log li small { font: 400 11px/1.4 var(--f-mono); color: var(--ink-3); white-space: nowrap; }

/* the route planner: the choice (before a run) and its latest line (during one) */
.planner { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin: 0; padding: 0; border: 0; font-size: 13.5px; }
.planner[hidden] { display: none; }
.planner legend { float: left; margin: 0 4px 0 0; padding: 0; }
.planner label { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; cursor: pointer; }
.planner input { accent-color: var(--ink); margin: 0; }
.planner input:disabled + span { color: var(--ink-3); }
.planner .note { flex-basis: 100%; margin: 0; font-size: 12px; line-height: 1.4; color: var(--ink-3); }
.planner .note[hidden] { display: none; }
.said { margin: 0; padding: 8px 10px; border-left: 2px solid var(--ink); background: rgb(22 22 20 / 0.04); font: 380 1rem/1.35 var(--f-display); color: var(--ink); text-wrap: pretty; }
.said[hidden] { display: none; }
.said .who { font: 500 11px/1 var(--f-text); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin-right: 4px; }
.said.thinking { color: var(--ink-3); border-left-color: var(--rule-strong); }
.said.thinking #said-text { font: 400 13px/1.35 var(--f-mono); font-variant-numeric: tabular-nums; }

.result {
  position: fixed; left: calc((100vw - var(--sheet-w)) / 2); top: 50%; transform: translate(-50%, -50%); z-index: 4;
  width: min(420px, calc(100vw - 2 * var(--m))); padding: 26px 28px 28px; background: var(--panel); border: 1px solid var(--rule); border-radius: 3px;
  box-shadow: 0 18px 50px -20px rgb(22 22 20 / 0.35);
}
.result h2 { margin: 0 0 10px; font: 340 2.1rem/1.05 var(--f-display); letter-spacing: -0.02em; }
.result p { margin: 0 0 14px; color: var(--ink-2); text-wrap: pretty; }
.result { max-height: calc(100vh - 2 * var(--m)); overflow-y: auto; }
.result-attempts { list-style: none; margin: 0 0 14px; padding: 0; font-size: 13px; }
.result-attempts li { padding: 4px 0; border-top: 1px solid var(--rule); color: var(--ink-2); }
.result-attempts li.win { color: var(--ink); font-weight: 560; }
.closest { margin: 0 0 18px; }
.closest h3 { margin: 0 0 6px; }
.closest dl { display: grid; gap: 3px; margin: 0 0 8px; font-size: 13px; }
.closest dl div { display: grid; grid-template-columns: 11em 1fr; gap: 14px; }
.closest dt { color: var(--ink-3); }
.closest dd { margin: 0; font-variant-numeric: tabular-nums; }

body.course .credit { max-width: calc(100vw - var(--sheet-w) - 3 * var(--m)); }

@media (max-width: 760px) {
  body.course { --sheet-w: 0px; }
  body.course .masthead { max-width: calc(100vw - 2 * var(--m)); }
  body.course .intro { display: none; }
  body.course .home { display: inline-block; margin-top: 12px; } /* back to the bots, kept on phones */
  .clock { top: auto; bottom: calc(38vh + 12px); left: 50%; font-size: 2rem; }
  .sheet {
    top: auto; left: 0; right: 0; width: auto; height: 38vh; border-left: 0; border-top: 1px solid var(--rule);
    padding: 14px 16px 10px; gap: 10px;
  }
  .hint { font-size: 1rem; min-height: 0; }
  .actions button { flex: 1; }
  .result { left: 50%; top: 50%; max-height: calc(100vh - 32px); padding: 20px 18px 20px; }
  .result h2 { font-size: 1.7rem; }
  /* running: the readout gets the hint's room; the live values wrap as pairs */
  body.course.running .hint { display: none; }
  .readout .live { display: flex; flex-wrap: wrap; gap: 2px 14px; padding: 6px 0; font-size: 11.5px; }
  .readout .live div { display: flex; gap: 5px; }
  .readout .live dd { font-size: 11px; }
  .readout .scope { display: none; }
  .said { padding: 6px 8px; font-size: 0.92rem; }
  .closest dl div { grid-template-columns: 9em 1fr; }
  body.course .credit { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .actions button { transition: none; }
}
