/* Widget chrome. Deliberately small: the theme owns typography, this owns
   only the parts a themed Sphinx site has no opinion about. */

.eb-widget {
  --eb-widget-border: rgba(127, 127, 127, 0.35);
  margin: 1.5rem 0;
  padding: 0.75rem 0.9rem 0.9rem;
  border: 1px solid var(--eb-widget-border);
  border-left-width: 3px;
  border-radius: 4px;
}

.eb-widget > :first-child {
  margin-top: 0;
}

.eb-widget > :last-child {
  margin-bottom: 0;
}

/* The editor sits inside a div.highlight so the theme's own code-block
   background and colour apply, and then takes them by inheriting rather
   than naming any theme variable. A sample that is editable should look
   like the sample that was not. */
.eb-widget-editor-wrap {
  margin: 0;
}

.eb-widget-editor {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  padding: 0.6rem 0.7rem;
  border: 0;
  background: transparent;
  color: inherit;
  resize: vertical;
  tab-size: 4;
}

/* The caret is the only affordance saying this box takes typing, so it has
   to be visible against the code background rather than assumed. */
.eb-widget-editor:focus {
  outline: 2px solid currentColor;
  outline-offset: -2px;
}

/* The output is filled on hydrate, so an empty one means the engine
   answered with nothing rather than that nobody has asked yet. */
.eb-widget-output:empty {
  display: none;
}

/* A live island says so, quietly, because the difference between a code
   block and an editable one is otherwise invisible until you click. */
.eb-widget[data-eb-state="live"]::before {
  content: "editable, runs as you type";
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  opacity: 0.6;
}

.eb-widget-output {
  margin: 0.6rem 0 0;
  padding: 0.6rem 0.7rem;
  overflow-x: auto;
  font-size: 0.85rem;
  border: 1px dashed var(--eb-widget-border);
  border-radius: 3px;
}

.eb-widget-note {
  margin: 0.6rem 0 0;
  font-size: 0.85rem;
  font-style: italic;
  opacity: 0.75;
}

/* Wide content scrolls inside its own box rather than the page. */
.eb-widget pre {
  overflow-x: auto;
}

/* --- a sample that is meant to fail ---------------------------------------
 *
 * Teaching material that shows broken input has to say so where the input
 * is, not in the paragraph above it: a reader who copies the block did not
 * read the paragraph. The label is text in the markup, so it survives a
 * reader stylesheet, a screen reader and the printer, and the colour is the
 * second signal rather than the only one.
 */
article.yue .eb-widget--fails {
  border-left: 3px solid #bf3989;
}

article.yue .eb-widget-fails {
  margin: 0 0 0.5rem;
  font-family: var(--eb-sans);
  font-size: 0.84rem;
  color: var(--eb-fg-muted);
}

article.yue .eb-widget-fails__tag {
  display: inline-block;
  margin-right: 0.5rem;
  padding: 0.05rem 0.4rem;
  border: 1px solid #bf3989;
  border-radius: 2px;
  font-family: var(--eb-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #bf3989;
}

/* Page-level playground. Docked, not modal: the chapter stays readable
   while the reader tries a thing the sample did not think of. */
.eb-repl {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  max-height: 46vh;
  display: flex;
  flex-direction: column;
  border-top: 2px solid rgba(127, 127, 127, 0.45);
  background: var(--eb-bg, Canvas);
  color: inherit;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.12);
}

.eb-repl[hidden] {
  display: none;
}

.eb-repl-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  border-bottom: 1px solid rgba(127, 127, 127, 0.25);
}

.eb-repl-title {
  opacity: 0.7;
  letter-spacing: 0.02em;
}

.eb-repl-widget {
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
}

.eb-repl-close {
  margin-left: auto;
  font: inherit;
  font-size: 0.8rem;
}

.eb-repl-editor,
.eb-repl-output {
  margin: 0;
  padding: 0.55rem 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.45;
  border: 0;
  background: transparent;
  color: inherit;
}

.eb-repl-editor {
  min-height: 7rem;
  resize: vertical;
  width: 100%;
  box-sizing: border-box;
}

.eb-repl-editor:focus {
  outline: 2px solid currentColor;
  outline-offset: -2px;
}

.eb-repl-output {
  overflow: auto;
  max-height: 18vh;
  border-top: 1px dashed rgba(127, 127, 127, 0.3);
  white-space: pre-wrap;
}

body.eb-repl-open {
  padding-bottom: 46vh;
}
