/* --- Playground: full-width chapter breakout --- */
#rv-playground.rv-playground-full {
  width: calc(100% + 2 * var(--content-inline-padding, 1.5rem));
  max-width: none;
  margin-left: calc(-1 * var(--content-inline-padding, 1.5rem));
  margin-right: calc(-1 * var(--content-inline-padding, 1.5rem));
  box-sizing: border-box;
  --content-inline-padding: 1.5rem;
}

@media (max-width: 736px) {
  #rv-playground.rv-playground-full {
    width: calc(100% + 2rem);
    margin-left: -1rem;
    margin-right: -1rem;
  }
}

#rv-playground {
  /* Default until WASM sets from Rust `line_step_px()` (must match data::LINE_SPACE) */
  --rv-line-step: 30px;
  /* mdBook sets html { font-size: 62.5% }, so rem-based sizes are tiny — use px here */
  --rv-editor-font-size: 18px;
  /* Push code down so line 1 lines up with the timeline below variable headers */
  --rv-editor-content-offset: 48px;
  /* Match stacked editor toolbar to the visual pane header */
  --rv-playground-toolbar-min-h: 7.25rem;
}

.rv-playground {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: min(92vh, calc(100vh - 5.5rem));
  transition: opacity 0.2s ease;
}

.rv-playground-shell {
  --rv-editor-pct: 42%;
  display: grid;
  grid-template-columns: var(--rv-editor-pct) 6px minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: min(85vh, 720px);
  gap: 0;
  border: 1px solid var(--searchbar-border-color, #5c5c68);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg, #141617);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  transition: border-color 0.2s ease, box-shadow 0.25s ease;
}

.rv-playground-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.rv-pane-editor {
  border-right: 1px solid var(--searchbar-border-color, #3d3d44);
}

.rv-pane-resizer {
  cursor: col-resize;
  background: var(--searchbar-border-color, #5c5c68);
  opacity: 0.45;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}

.rv-pane-resizer:hover,
.rv-pane-resizer:focus-visible {
  opacity: 0.95;
  outline: none;
}

.rv-playground-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--searchbar-border-color, #5c5c68);
  background: var(--sidebar-bg, #1d2021);
  flex-shrink: 0;
  min-height: var(--rv-playground-toolbar-min-h);
  box-sizing: border-box;
}

.rv-visual-header {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--searchbar-border-color, #5c5c68);
  background: var(--sidebar-bg, #1d2021);
  flex-shrink: 0;
  min-height: var(--rv-playground-toolbar-min-h);
  box-sizing: border-box;
}

.rv-toolbar-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--icons, #737373);
}

.rv-playground-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  width: 100%;
}

/* Three actions: Compile | Copy on row 1, Reset full width on row 2 */
.rv-playground-btn-wide {
  grid-column: 1 / -1;
}

/* Floating hover captions for timeline SVG (inline in playground, not via helpers.js) */
#rv-playground-tooltip.rv-playground-tooltip {
  position: fixed;
  z-index: 10000;
  max-width: min(36rem, calc(100vw - 24px));
  margin: 0;
  padding: 0.5rem 0.65rem;
  font-size: 1rem;
  line-height: 1.35;
  font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  border-radius: 8px;
  box-sizing: border-box;
  background: rgba(70, 70, 70, 0.92);
  color: #fff;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  word-wrap: break-word;
}

.rv-playground-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 0.45rem;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid var(--searchbar-border-color, #5c5c68);
  border-radius: 6px;
  background: var(--bg, #141617);
  color: var(--fg, #d9d9db);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.rv-playground-btn:hover:not(:disabled) {
  background: var(--sidebar-bg, #1d2021);
  border-color: var(--icons, #737373);
}

.rv-playground-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.rv-playground-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.rv-playground-btn-primary {
  border-color: var(--icons, #8a8a8a);
  font-weight: 600;
}

.rv-playground-btn i {
  font-size: 14px;
}

/* IDE-style editor: line numbers + textarea */
.rv-editor-shell {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: 12rem;
  overflow: hidden;
  padding-top: var(--rv-editor-content-offset);
  box-sizing: border-box;
}

.rv-line-numbers {
  padding: 0.45rem 0.4rem 0.45rem 0.55rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: var(--rv-editor-font-size);
  line-height: var(--rv-line-step);
  text-align: right;
  color: var(--icons, #737373);
  background: var(--sidebar-bg, #1a1c1d);
  border-right: 1px solid var(--searchbar-border-color, #3d3d44);
  user-select: none;
  overflow: hidden;
  white-space: pre;
  min-width: 2.25rem;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.rv-playground-ta {
  width: 100%;
  min-height: 100%;
  max-height: 100%;
  border: none;
  border-radius: 0;
  padding: 0.45rem 0.75rem;
  box-sizing: border-box;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: var(--rv-editor-font-size);
  line-height: var(--rv-line-step);
  color: var(--fg, #d9d9db);
  background: var(--bg, #141617);
  resize: none;
  outline: none;
  overflow: auto;
  tab-size: 2;
}

.rv-pane-visual {
  background: var(--sidebar-bg, #1d2021);
}

/* Timeline-only panel (code lives in the editor) */
.rv-playground-svg-timeline-only {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: none;
  border-radius: 0;
  padding: 0;
  background: var(--sidebar-bg, #1d2021);
  transition: background-color 0.2s ease;
}

.rv-timeline-scroll-inner {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0.35rem 0.45rem;
  box-sizing: border-box;
}

.rv-playground-svg-timeline-only svg {
  max-width: none;
  width: auto;
  height: auto;
  display: block;
  min-width: fit-content;
  transition: opacity 0.2s ease;
}

.chapter .rv-playground-svg-timeline-only svg {
  display: block;
}

/* Compiler / rustc diagnostics */
.rv-diagnostics {
  flex-shrink: 0;
  max-height: 16rem;
  overflow: auto;
  border-top: 1px solid var(--searchbar-border-color, #5c5c68);
  background: rgba(0, 0, 0, 0.2);
  animation: rv-fade-in 0.2s ease;
}

.rv-diagnostics-header {
  padding: 0.45rem 0.75rem;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--icons, #9a9a9a);
  border-bottom: 1px solid var(--searchbar-border-color, #3d3d44);
}

.rv-diagnostics-body {
  margin: 0;
  padding: 0.65rem 0.75rem 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--fg, #e8e8ea);
}

.rv-playground-error,
.rv-inference-error {
  border-radius: 0;
  border: none;
  border-top: 1px solid #f06b6b;
  padding: 0.55rem 0.75rem;
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  color: #ffd2d2;
  background: #532727;
  white-space: pre-wrap;
}

@keyframes rv-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Hide the "Print this book" button */
#print-button,
a[title="Print this book"],
a[aria-label="Print this book"] {
  display: none !important;
}

/* Hide Rust and Ayu themes from the theme selector */
button#rust,
button#ayu {
  display: none !important;
}

/* --- mdBook chrome: smooth nav --- */
.sidebar .chapter a {
  transition: background-color 0.15s ease, color 0.15s ease, padding-left 0.15s ease;
}

.sidebar .chapter a:hover {
  padding-left: 0.35rem;
}

/* Section titles in sidebar */
.sidebar .chapter li.part-title,
.sidebar .chapter .part-title {
  transition: color 0.2s ease;
}
