.directive-jmp {
  position: relative;
  border: 1px solid var(--color-nav-border);
  border-radius: 8px;
  overflow: hidden;
  min-height: 300px;
}

.directive-jmp java-memory-playground {
  display: block;
  width: 100%;
  height: 100%;
}

/* Bottom right is the one corner the playground leaves alone: the sidebar sits
   top left, undo/save top right, the zoom controls bottom left and the step bar
   bottom centre. */
.directive-jmp .buttons {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  gap: 4px;
  z-index: 5;
}

/* The playground's canvas is always light, whatever theme the book is read in,
   so this button is coloured like the playground's own panels rather than like
   the page around it — in a dark book the book's colours would be invisible
   here. The values are the playground's `--jmp-*` tokens, which are scoped to
   the element and so cannot be referred to from outside it. */
.directive-jmp .buttons button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background-color: #f5f5f5;
  color: #3c3c3c;
  box-shadow: 0 1px 3px rgb(0 0 0 / 8%);
  cursor: pointer;
}

.directive-jmp .buttons button:hover {
  background-color: #d6d6d6;
}

.directive-jmp .buttons button .icon {
  width: 18px;
  height: 18px;
  display: block;
}

/* A toggle reads as on by being filled in, matching the playground's own. */
.directive-jmp .buttons button.active {
  background-color: #242428;
  color: #f5f5f5;
}

.directive-jmp .buttons button.active:hover {
  background-color: #3c3c3c;
}

/* The figure is sized by an inline `height` from the directive, which has to
   give way once it owns the screen. */
.directive-jmp:fullscreen {
  width: 100vw;
  height: 100dvh !important;
  border: none;
  border-radius: 0;
  background-color: #ffffff;
}

/* The playground's canvas is white whatever the book's theme, so the backdrop
   behind it is too — a dark backdrop would show as a frame around it while the
   browser animates into fullscreen. */
.directive-jmp:fullscreen::backdrop {
  background-color: #ffffff;
}
