/* workbench.css, the front page: the tab strip over Play and the notebook frames, drawn in the tokens of palette.css,
 * with the terminal in terminal.css's --mudgym-* tokens, shared with the live widgets. */
:root {
  /* The two sizes most of the page is set in, chrome and reading. The headings and a few small labels set their own. */
  --type-ui: .85rem;
  --type-body: 1rem;
  color-scheme: light;
  color: var(--notebook-body);
  background: var(--notebook-background);
  font-family: var(--notebook-sans);
}
* { box-sizing: border-box; }
/* Smoothed as marimo smooths the notebooks, so text has one weight in every tab. */
body { margin: 0; font-size: var(--type-ui); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
button, input { font: inherit; }
[hidden] { display: none !important; }
/* The light surface's focus ring, the run card's: 2px of the accent, 2px out. terminal.css draws the dark one. */
:is(a, button):focus-visible { outline: 2px solid var(--notebook-accent); outline-offset: 2px; }

/* ── The bar ─────────────────────────────────────────────────────────────── */
.workbench {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
}
.workbench-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  min-height: 3rem;
  border-bottom: 1px solid var(--notebook-rule);
  background: var(--notebook-background);
}
.workbench-home {
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  padding: .45rem .9rem;
  border-right: 1px solid var(--notebook-rule);
  color: var(--notebook-ink);
  text-decoration: none;
}
.workbench-home:hover { background: var(--notebook-tint); }
/* Inside its edge, since it fills the bar from top to bottom. */
.workbench-home:focus-visible { outline-offset: -2px; }
.brand-logo { flex: none; width: 1.3rem; height: 1.3rem; }
.brand-name {
  font: 750 var(--type-ui) var(--notebook-mono);
  letter-spacing: .12em;
  text-transform: uppercase;
}
/* A diagnostic stamp, so it recedes beside the brand. */
.build-id {
  color: var(--notebook-muted);
  font: .72rem var(--notebook-mono);
  white-space: nowrap;
}

.notebook-tabs {
  display: flex;
  gap: .2rem;
  min-width: 0;
  padding: .36rem .55rem;
  overflow-x: auto;
  scrollbar-width: thin;
}
.notebook-tab {
  position: relative;
  flex: none;
  padding: .4rem .64rem;
  border: 1px solid transparent;
  border-radius: var(--notebook-radius);
  color: var(--notebook-body);
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}
.notebook-tab:hover { color: var(--notebook-secondary); background: var(--notebook-tint); }
.notebook-tab[aria-current="page"] {
  border-color: color-mix(in srgb, var(--notebook-accent) 22%, transparent);
  color: var(--notebook-accent);
  background: color-mix(in srgb, var(--notebook-accent) 14%, var(--notebook-background));
}
/* Sets a group of tabs apart. pages.json says where. */
.tab-divider {
  flex: none;
  margin: .3rem .35rem;
  border-left: 1px solid var(--notebook-rule);
}
/* Elapsed time while an opened tab is starting, after the tab's name. It holds the width of its widest count, so the
   strip beside it keeps still as the seconds go up, and it goes when the notebook is ready. */
.tab-time {
  display: inline-block;
  min-width: 2.3em;
  margin-left: .38rem;
  color: var(--notebook-muted);
  font-family: var(--notebook-mono);
  font-weight: 600;
}
.tab-time[data-state="failed"] { color: var(--notebook-danger); }
.tab-time[data-state="stalled"] { color: var(--notebook-accent); }
.notebook-tab[aria-current="page"] .tab-time { color: inherit; opacity: .8; }
/* A dot marks a tab whose notebook is loaded, once its timing has gone. */
.notebook-tab[data-visited="true"]:not(:has(.tab-time))::after {
  content: "";
  position: absolute;
  top: .25rem;
  right: .25rem;
  width: .3rem;
  height: .3rem;
  border-radius: 50%;
  background: var(--notebook-accent);
  box-shadow: 0 0 0 2px var(--notebook-background);
}

.workbench-actions { display: flex; align-items: center; gap: .6rem; padding: 0 .65rem; }
/* A fixed width, so a new message never moves the tab strip beside it. Below the width where the strip and the line
   both fit, the line is left to assistive technology, which still hears a start announced. */
.workbench-status { width: 17rem; color: var(--notebook-muted); line-height: 1.25; }
@media (max-width: 83rem) {
  .workbench-status {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
/* The site's own button, on Retry and Unload. run_control.css and notebook-page.css draw it again where this sheet does
   not reach. */
.workbench-button {
  padding: .38rem .62rem;
  border: 1px solid var(--notebook-rule);
  border-radius: var(--notebook-radius);
  color: var(--notebook-secondary);
  background: var(--notebook-background);
  white-space: nowrap;
  cursor: pointer;
}
.workbench-button:hover:not(:disabled) { border-color: var(--notebook-accent); background: var(--notebook-tint); }
.workbench-button:disabled { cursor: default; opacity: .45; }
/* MudGym's repository at the end of the bar, its mark and name in the mono face of the build stamp and the body colour
   of the tab names, so they read clearly. It opens in a new browser tab, as every link off the site does, since
   leaving this one would end the examples running in it. */
.workbench-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .5rem;
  border-radius: var(--notebook-radius);
  color: var(--notebook-body);
  font: .78rem var(--notebook-mono);
  text-decoration: none;
  white-space: nowrap;
}
.workbench-link:hover { color: var(--notebook-secondary); background: var(--notebook-tint); }
.workbench-link svg { display: block; flex: none; width: 1.15rem; height: 1.15rem; fill: currentColor; }

/* ── The notebook frames ────────────────────────────────────────────────── */
.notebook-stage { position: relative; }
.notebook-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* Not display: none, under which a frame lays out at nothing and its widgets lose their size and scroll. */
.notebook-frame[data-showing="false"] { visibility: hidden; }

/* The reading on the page, Play's introduction and guide and an unloaded tab's placeholder, and its one heading. */
.notebook-placeholder,
.play-intro p,
.play-walkthrough { font-size: var(--type-body); line-height: 1.6; }
.notebook-placeholder h2,
.play-intro h1,
.play-walkthrough h2 {
  color: var(--notebook-ink);
  font-size: clamp(1.3rem, 4vw, 1.5rem);
  letter-spacing: -.02em;
}
/* What an unloaded tab shows in place of its frame. */
.notebook-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: start;
  gap: .5rem;
  width: min(44rem, 100%);
  margin: 0 auto;
  padding: 2rem 1.25rem;
}
.notebook-placeholder h2 { margin: 0; padding-bottom: .5rem; border-bottom: 4px solid var(--notebook-heading-rule); }
.notebook-placeholder p { margin: 0; }
.placeholder-note { color: var(--notebook-muted); }
.load-button {
  justify-self: start;
  margin-top: .5rem;
  padding: .45rem .9rem;
  border: 1px solid transparent;
  border-radius: var(--notebook-radius);
  color: var(--notebook-background);
  background: var(--notebook-primary);
  font-weight: 650;
  cursor: pointer;
}
.load-button:hover { background: var(--notebook-secondary); }

/* ── Play ───────────────────────────────────────────────────────────────── */
.play {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}
/* The introduction runs the full width of the game and the guide below it. */
.play-intro {
  width: min(80.5rem, 100%);
  margin: 0 auto;
  padding: 1.5rem 1.25rem .9rem;
}
.play-intro h1 { margin: 0 0 .5rem; font-weight: 780; }
.play-intro p { margin: 0 0 .6rem; text-wrap: pretty; }
/* A link in the introduction or the guide, as links read on every notebook page. */
.play-intro a,
.play-walkthrough a {
  color: var(--notebook-secondary);
  text-decoration-color: var(--notebook-accent);
  text-underline-offset: .2em;
}
.play-starters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem .5rem;
  min-height: 1.9rem;
  color: var(--notebook-muted);
  font-size: var(--type-body);
}
/* Set like inline code, so a click reads as "type this" rather than as a control. The mono face runs large beside the
   sans, hence .92em. */
.play-starter {
  padding: .12em .45em;
  border: 1px solid var(--notebook-rule);
  border-radius: var(--notebook-radius);
  color: var(--notebook-secondary);
  background: var(--notebook-tint);
  font: .92em var(--notebook-mono);
  cursor: pointer;
}
.play-starter:hover:not(:disabled) { border-color: var(--notebook-accent); color: var(--notebook-accent); }
.play-starter:disabled { cursor: default; opacity: .45; }
/* The game and the reading guide share the space below the introduction, and each scrolls on its own so the live
   prompt stays in reach. */
.play-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(20rem, 1fr);
  gap: 2rem;
  width: min(80.5rem, 100%);
  min-height: 0;
  margin: 0 auto 1.1rem;
  padding: 0 1.25rem;
}
.play-walkthrough {
  min-height: 0;
  overflow: auto;
  padding-right: .5rem;
}
.play-walkthrough h2 { margin: 0 0 .65rem; padding-top: .65rem; border-top: 3px solid var(--notebook-heading-rule); }
.play-walkthrough p { margin: .25rem 0 1rem; }
.play-walkthrough ol { margin: 1.25rem 0 0; padding-left: 1.6rem; }
.play-walkthrough li { padding-left: .3rem; }
.play-walkthrough li::marker { color: var(--notebook-accent); }
.play-walkthrough a { font-weight: 650; }
.play-walkthrough a:hover { color: var(--notebook-accent); }
.play-terminal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
}
/* Zero-padded in the bar's mono face, so the reading never shunts the button beside it. */
.terminal-tick {
  margin-left: auto;
  white-space: nowrap;
}
.terminal-restart {
  padding: .2rem .55rem;
  border: 1px solid var(--mudgym-line);
  border-radius: var(--notebook-radius);
  color: var(--mudgym-accent-lit);
  background: transparent;
  cursor: pointer;
}
.terminal-restart:hover { border-color: var(--mudgym-accent-lit); }
#play-output { min-height: 0; overflow: auto; }
#play-output .command { color: var(--mudgym-accent-lit); font-weight: 700; }
#play-output .error { color: var(--mudgym-danger); }
/* The prompt's name for assistive technology, beside the glyph that draws it. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* As the window narrows, the build stamp, then the repository's name, then the brand give their room to the tab strip:
   it is the strip that has to stay reachable, a starting tab's timer and all. Retry, while a stalled or failed tab
   shows it, takes the repository's name's room, and below 60rem, where the name has gone, the brand's and the link's. */
.workbench-bar:has(#retry-notebook:not([hidden])) .workbench-link-name { display: none; }

@media (max-width: 66rem) {
  .build-id { display: none; }
}

@media (max-width: 60rem) {
  .workbench-link-name { display: none; }
  .workbench-bar:has(#retry-notebook:not([hidden])) :is(.brand-name, .workbench-link) { display: none; }
  .play { overflow: auto; grid-template-rows: auto auto; }
  .play-stage { grid-template-columns: minmax(0, 1fr); }
  .play-terminal { height: clamp(22rem, 55dvh, 40rem); }
  .play-walkthrough { overflow: visible; padding-right: 0; }
}

@media (max-width: 54rem) {
  .workbench-home .brand-name { display: none; }
}

@media (max-width: 52rem) {
  .workbench-home { padding-inline: .7rem; }
  .workbench-actions { padding-inline: .4rem; gap: .45rem; }
  .workbench-actions .workbench-button { padding-inline: .5rem; }
  .play-intro { padding: 1.1rem 1rem .7rem; }
  .play-stage { margin-bottom: .75rem; padding: 0 .75rem; }
}
