/* The chart pane: one card per matplotlib figure, newest at the top, each
   with matplotlib's window toolbar above it and its status line below.
   js/figures.js builds them.

   The host is #charts, which style.css already gives a scroll and 12px of
   padding. js/figures.js adds .fg-host to it, and .fg-open while one figure
   is filling the pane. Link this after css/style.css. */

.fg-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.fg {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 6px;
  outline: none;
}
.fg:focus-visible { border-color: var(--accent); }

/* ----- the caption and the toolbar ----- */

.fg-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.fg-title {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 600;
}

.fg-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.fg-sep {
  width: 1px;
  height: 18px;
  margin: 0 5px;
  background: var(--edge);
}

.fg-tool {
  display: grid;
  place-items: center;
  width: 28px;
  height: 26px;
  padding: 0;
  color: var(--dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
}
.fg-tool:hover:not(:disabled) {
  color: var(--text);
  background: var(--button);
  border-color: var(--button-edge);
}
.fg-tool:disabled { opacity: 0.35; cursor: default; }
.fg-tool.fg-on {
  color: var(--accent);
  background: var(--select);
  border-color: var(--primary-edge);
}

/* matplotlib's own icons, drawn in the theme's color: each SVG is used as a
   mask, so the button's text color is what shows through. */
.fg-icon {
  display: block;
  width: 17px;
  height: 17px;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.fg-expand { margin-left: auto; flex: 0 0 auto; }

/* ----- the figure ----- */

/* matplotlib draws for paper: a white face, black text. The figure keeps its
   own colors in both themes and sits on the card as a sheet, which is what
   it is. Its size comes from js/figures.js, which has it drawn at exactly the
   pixels it is shown at. */
.fg-plate {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-width: 0;
  overflow: hidden;
}

.fg-canvas {
  display: block;
  max-width: 100%;
  border-radius: 3px;
  box-shadow: 0 0 0 1px var(--edge);
  touch-action: pan-y;
}

.fg-plate[data-mode="pan"] .fg-canvas,
.fg-plate[data-mode="zoom"] .fg-canvas { touch-action: none; }
.fg-plate[data-mode="pan"] .fg-canvas { cursor: move; }
.fg-plate[data-mode="zoom"] .fg-canvas { cursor: crosshair; }
.fg.fg-busy .fg-canvas { cursor: progress; }

/* A plotly chart: plotly.js sizes it and brings its own modebar, which shows
   on hover as it does in the browser tab fig.show() opens in IDLE. */
.fg-plotly {
  max-width: 100%;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--edge);
}

/* plotly.js's tips, at the chart pane's top right rather than the window's
   (js/figures.js placeNotes sets the two properties). plotly.js styles them
   with a rule of its own injected at run time; this one is more specific. */
body > .plotly-notifier {
  top: var(--fg-note-top, 50px);
  right: var(--fg-note-right, 20px);
}

/* The zoom rectangle, drawn the way the window draws it: a dashed line that
   shows on white and on a dark image alike. */
.fg-rubber {
  position: absolute;
  pointer-events: none;
  border: 1px dashed #000000;
  outline: 1px dashed #ffffff;
  outline-offset: -2px;
  background: rgba(90, 169, 255, 0.08);
}
.fg-rubber.fg-out { background: rgba(240, 138, 122, 0.08); }

/* ----- the status line ----- */

.fg-foot {
  display: flex;
  gap: 12px;
  min-height: 16px;
  font-size: 12px;
  line-height: 16px;
  color: var(--dim);
}

.fg-coords {
  flex: 0 0 auto;
  font-family: var(--mono, ui-monospace, Consolas, monospace);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.fg-msg {
  margin-left: auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fg-msg.fg-said { color: var(--busy); }

/* ----- one figure, filling the pane ----- */

/* Expanding hides the other cards rather than floating this one over them.
   The pane is a scroller, and an absolutely positioned child of a scroller
   anchors to the top of the content, so a figure expanded after scrolling
   down would open off screen. Hiding the rest has no such corner. */
.fg-host.fg-open {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.fg-host.fg-open .fg-list {
  flex: 1 1 auto;
  min-height: 0;
}
.fg-host.fg-open .fg { display: none; }
.fg-host.fg-open .fg.fg-shown {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}
.fg-host.fg-open .fg.fg-shown .fg-plate {
  flex: 1 1 auto;
  min-height: 0;
  align-items: center;
}

@media (max-width: 768px) {
  .fg-list { gap: 10px; }
  .fg { padding: 6px; }
  .fg-head { flex-wrap: wrap; row-gap: 4px; }
  .fg-msg { display: none; }
}
