/* math_input: the MathLive editor's fonts and the math panel.

   A host restyles the panel by overriding these custom properties (defaults below):
     --math-input-surface      panel and key background
     --math-input-line         borders
     --math-input-radius       corner radius
     --math-input-shadow       panel shadow
     --math-input-muted        label, hint and key text
     --math-input-ink          strong text, hovered key
     --math-input-accent       focus outline, hovered key border
     --math-input-accent-tint  math-field background
     --math-input-danger       load error
     --math-input-mono         monospace font for the hint's keys */

/* MathLive's KaTeX fonts. MathLive would load them itself from fixed file names under
   MathfieldElement.fontsDirectory, but Propshaft serves only digested names, so they are
   declared here (Propshaft rewrites each url() to its digested path) and --ML__static-fonts
   tells MathLive they are already declared. Families, weights and styles match MathLive's
   own list (mathlive.js, 0.110.0). */
@font-face { font-family: "KaTeX_Main"; src: url("/assets/mathlive/KaTeX_Main-Regular-a5f3c801.woff2") format("woff2"); font-style: normal; font-weight: normal; }
@font-face { font-family: "KaTeX_Main"; src: url("/assets/mathlive/KaTeX_Main-BoldItalic-5edc6a9d.woff2") format("woff2"); font-style: italic; font-weight: bold; }
@font-face { font-family: "KaTeX_Main"; src: url("/assets/mathlive/KaTeX_Main-Bold-da93c799.woff2") format("woff2"); font-style: normal; font-weight: bold; }
@font-face { font-family: "KaTeX_Main"; src: url("/assets/mathlive/KaTeX_Main-Italic-8617c11c.woff2") format("woff2"); font-style: italic; font-weight: normal; }
@font-face { font-family: "KaTeX_Math"; src: url("/assets/mathlive/KaTeX_Math-Italic-c0c4e419.woff2") format("woff2"); font-style: italic; font-weight: normal; }
@font-face { font-family: "KaTeX_Math"; src: url("/assets/mathlive/KaTeX_Math-BoldItalic-48fc0d5d.woff2") format("woff2"); font-style: italic; font-weight: bold; }
@font-face { font-family: "KaTeX_AMS"; src: url("/assets/mathlive/KaTeX_AMS-Regular-8c0f01ff.woff2") format("woff2"); font-style: normal; font-weight: normal; }
@font-face { font-family: "KaTeX_Caligraphic"; src: url("/assets/mathlive/KaTeX_Caligraphic-Regular-18fe031a.woff2") format("woff2"); font-style: normal; font-weight: normal; }
@font-face { font-family: "KaTeX_Caligraphic"; src: url("/assets/mathlive/KaTeX_Caligraphic-Bold-b624feb2.woff2") format("woff2"); font-style: normal; font-weight: bold; }
@font-face { font-family: "KaTeX_Fraktur"; src: url("/assets/mathlive/KaTeX_Fraktur-Regular-8e609a3c.woff2") format("woff2"); font-style: normal; font-weight: normal; }
@font-face { font-family: "KaTeX_Fraktur"; src: url("/assets/mathlive/KaTeX_Fraktur-Bold-96606008.woff2") format("woff2"); font-style: normal; font-weight: bold; }
@font-face { font-family: "KaTeX_SansSerif"; src: url("/assets/mathlive/KaTeX_SansSerif-Regular-e8fb1d35.woff2") format("woff2"); font-style: normal; font-weight: normal; }
@font-face { font-family: "KaTeX_SansSerif"; src: url("/assets/mathlive/KaTeX_SansSerif-Bold-649ed3b2.woff2") format("woff2"); font-style: normal; font-weight: bold; }
@font-face { font-family: "KaTeX_SansSerif"; src: url("/assets/mathlive/KaTeX_SansSerif-Italic-3d603156.woff2") format("woff2"); font-style: italic; font-weight: normal; }
@font-face { font-family: "KaTeX_Script"; src: url("/assets/mathlive/KaTeX_Script-Regular-69f2e250.woff2") format("woff2"); font-style: normal; font-weight: normal; }
@font-face { font-family: "KaTeX_Typewriter"; src: url("/assets/mathlive/KaTeX_Typewriter-Regular-015b437a.woff2") format("woff2"); font-style: normal; font-weight: normal; }
@font-face { font-family: "KaTeX_Size1"; src: url("/assets/mathlive/KaTeX_Size1-Regular-46ece434.woff2") format("woff2"); font-style: normal; font-weight: normal; }
@font-face { font-family: "KaTeX_Size2"; src: url("/assets/mathlive/KaTeX_Size2-Regular-34bfe380.woff2") format("woff2"); font-style: normal; font-weight: normal; }
@font-face { font-family: "KaTeX_Size3"; src: url("/assets/mathlive/KaTeX_Size3-Regular-7fd4fd88.woff2") format("woff2"); font-style: normal; font-weight: normal; }
@font-face { font-family: "KaTeX_Size4"; src: url("/assets/mathlive/KaTeX_Size4-Regular-eefb151c.woff2") format("woff2"); font-style: normal; font-weight: normal; }

:root {
  --ML__static-fonts: true;

  --math-input-surface: #fff;
  --math-input-line: #e4e6e1;
  --math-input-radius: 7px;
  --math-input-shadow: 0 1px 2px rgba(28, 35, 33, .04), 0 6px 20px rgba(28, 35, 33, .05);
  --math-input-muted: #6b726e;
  --math-input-ink: #1c2321;
  --math-input-accent: #0e7c66;
  --math-input-accent-tint: #e7f2ee;
  --math-input-danger: #b44a3a;
  --math-input-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", "D2Coding", monospace;
}

/* The panel is positioned by the math-panel controller from the active field's bounding rect
   rather than moved in the DOM: relocating the node would fire disconnectedCallback on
   <math-field> and re-run Stimulus connect on every open. */
.math-panel {
  position: fixed; z-index: 60;
  background: var(--math-input-surface); border: 1px solid var(--math-input-line);
  border-radius: var(--math-input-radius); box-shadow: var(--math-input-shadow);
  padding: 8px 10px 10px;
  /* Backstop for content taller than the viewport allows (e.g. a \begin{cases} block that
     outgrows both the space below and above the field): scroll inside rather than run off. */
  max-height: 60vh; overflow-y: auto;
}
/* border-box here, not left to the host's reset: the controller sets the panel's width to the
   field's, and the math-field is width: 100% with padding — content-box would overflow both. */
.math-panel, .math-panel * { box-sizing: border-box; }
.math-panel[hidden] { display: none; }
.math-panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.math-panel-label { font-size: 12px; font-weight: 600; color: var(--math-input-muted); }
.math-panel-hint { margin: 0; font-size: 11.5px; color: var(--math-input-muted); }
.math-panel-hint b { font-family: var(--math-input-mono); font-weight: 600; color: var(--math-input-ink); }
.math-panel math-field {
  display: block; width: 100%; margin-top: 6px; padding: 7px 9px; font-size: 19px;
  border: 1px solid var(--math-input-line); border-radius: var(--math-input-radius);
  background: var(--math-input-accent-tint);
}
.math-panel math-field:focus { outline: 2px solid var(--math-input-accent); outline-offset: 1px; }
.math-panel-error { margin: 7px 0 0; font-size: 12px; color: var(--math-input-danger); }
.math-panel-key {
  border: 1px solid var(--math-input-line); background: var(--math-input-surface);
  border-radius: var(--math-input-radius);
  padding: 1px 7px; font-size: 13px; line-height: 1.5; cursor: pointer; color: var(--math-input-muted);
}
.math-panel-key:hover { color: var(--math-input-ink); border-color: var(--math-input-accent); }
