/*
 * Figure actions (Copy, Save, Edit), the status bubble and the in-page editor.
 *
 * Moved unchanged from chatOAME Static Diagrams' chatoame-diagrams.css (lines
 * 593-729) when the figure actions moved into Math Visuals (removal plan
 * B1/K1). Enqueued by ChatOAME_MV_Plugin::enqueue() with figure-actions.js.
 * Keep the EN/FR label toggle: the server writes every label in both
 * languages and this sheet shows the one matching <html lang>.
 */

/* --------------------------------------------------------------------------
 * Figure actions: Copy, Save, Edit.
 *
 * Written by the server into the <figure> they belong to (Math Visuals'
 * figure_actions()), so AI Engine's React renderer draws them with the reply
 * and the association is unambiguous when a reply carries more than one. They
 * carry chatoame-no-export, so an export clone drops them rather than printing
 * three dead buttons under the image.
 * ----------------------------------------------------------------------- */
.chatoame-figure-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 2px;
  align-items: center;
}

.chatoame-figure-action {
  font: inherit;
  font-size: 0.85em;
  line-height: 1.2;
  padding: 6px 12px;
  border: 1px solid #c7d0d8;
  border-radius: 999px;
  background: #fff;
  color: #24333d;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.chatoame-figure-action:hover { background: #eef3f7; border-color: #9fb0bd; }
.chatoame-figure-action:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.chatoame-figure-action[disabled] { opacity: 0.55; cursor: default; }

/* Each label is written in English and in French. Show the one for the
 * interface language, which Locale Core keeps on <html lang>, so switching
 * language needs no script to touch the buttons. */
.chatoame-figure-action > [lang^="fr" i] { display: none; }
html[lang^="fr" i] .chatoame-figure-action > [lang^="en" i] { display: none; }
html[lang^="fr" i] .chatoame-figure-action > [lang^="fr" i] { display: inline; }

/* The confirmation after Copy, Save or Edit ("Copied"). It lives in <body>,
 * not in the reply, and figure-actions.js holds it against the button that
 * was pressed. Empty, it draws nothing but stays a live region. */
.chatoame-figure-action-status {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2147483000;
  transform: translate(-50%, -100%);
  width: max-content;
  max-width: min(320px, calc(100vw - 16px));
  padding: 6px 10px;
  border-radius: 6px;
  background: #172033;
  color: #fff;
  font: 600 0.8rem/1.3 system-ui, sans-serif;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(15, 23, 32, 0.25);
}

.chatoame-figure-action-status--below { transform: translate(-50%, 0); }
.chatoame-figure-action-status:empty { padding: 0; box-shadow: none; }

@media print {
  .chatoame-figure-actions,
  .chatoame-figure-action-status { display: none !important; }
}

/* The editor opens over the page rather than navigating away, so the reply the
 * diagram belongs to is still there when the teacher saves or cancels. */
.chatoame-figure-editor {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(15, 23, 32, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.chatoame-figure-editor__shell {
  background: #fff;
  border-radius: 12px;
  width: min(1200px, 100%);
  height: min(820px, 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 18px 48px rgba(15, 23, 32, 0.35);
}

.chatoame-figure-editor__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8ee;
}

.chatoame-figure-editor__title { font-size: 1rem; margin: 0; font-weight: 700; }
.chatoame-figure-editor__status { margin: 0; flex: 1 1 auto; font-size: 0.85rem; color: #465966; }

.chatoame-figure-editor__apply,
.chatoame-figure-editor__copy,
.chatoame-figure-editor__cancel {
  font: inherit;
  font-size: 0.9rem;
  padding: 7px 16px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid #c7d0d8;
  background: #fff;
}

.chatoame-figure-editor__apply {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  font-weight: 600;
}

.chatoame-figure-editor__apply[disabled],
.chatoame-figure-editor__copy[disabled] { opacity: 0.6; cursor: default; }
.chatoame-figure-editor__canvas { flex: 1 1 auto; min-height: 0; }

@media (prefers-color-scheme: dark) {
  .chatoame-figure-action { background: #1b2732; color: #e8eef4; border-color: #3a4a58; }
  .chatoame-figure-action:hover { background: #24333f; border-color: #55697a; }
  .chatoame-figure-editor__shell { background: #14202b; color: #e8eef4; }
  .chatoame-figure-editor__bar { border-bottom-color: #2b3a48; }
  .chatoame-figure-editor__status { color: #a9bccb; }
  .chatoame-figure-editor__copy,
  .chatoame-figure-editor__cancel { background: #1b2732; color: #e8eef4; border-color: #3a4a58; }
}

/* --------------------------------------------------------------------------
 * Figure carriers still written by stages that outlive Static Diagrams.
 *
 * Math Visuals used to enqueue the whole of chatoame-diagrams.css on every
 * page. These rules from it (lines 397-453) style markup that surviving code
 * still writes: the 990 finalizer's (and Math Visuals') figure carrier, which
 * is emitted hidden when every figure was placed inline. Copied unchanged,
 * without the retired companion-chip selector and without the retired
 * .chatoame-visual-fulfillment-notice rules (R11).
 * ----------------------------------------------------------------------- */
.chatoame-static-visual-fulfillment {
  --co-representations-line: var(--co-tanzanite-200, #c6cde2);
  --co-representations-rule: var(--co-tanzanite-600, #303e70);
  --co-representations-field: var(--co-tanzanite-700, #23305e);
  --co-representations-wash: var(--co-tanzanite-50, #eef1f9);
  --co-representations-grad: var(--co-grad-tanzanite, linear-gradient(135deg, #303e70, #18224c));

  position: relative;
  clear: both;
  margin: 1rem 0 1.25rem;
  padding: .9rem;
  border: 1px solid var(--co-representations-line);
  border-left: 6px solid var(--co-representations-rule);
  border-radius: .75rem;
  background-color: var(--co-representations-wash);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  break-inside: avoid;
}
/* The carrier is emitted hidden when every figure was placed inline, and it
   still carries the payload for the exporters. A themed empty card must not
   appear in that case. */
.chatoame-static-visual-fulfillment[hidden] {
  display: none !important;
}
.chatoame-static-visual-fulfillment__title {
  margin: -.9rem -.9rem .65rem;
  padding: .5rem .9rem .46rem;
  border-radius: 0;
  background-color: var(--co-representations-field);
  background-image: var(--co-representations-grad);
  color: #fff !important;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
}
.chatoame-static-visual-fulfillment__figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: .8rem;
  align-items: start;
}
.chatoame-static-visual-fulfillment figure,
.chatoame-static-visual-fulfillment svg {
  max-width: 100%;
  height: auto;
}
@media print {
  .chatoame-static-visual-fulfillment { border-color: #777; background: #fff; box-shadow: none; }
  .chatoame-static-visual-fulfillment__title { background: transparent; background-image: none; color: #000 !important; border-bottom: 1px solid #777; }
}
