/* Question figures drawn by lp-figure.js (graphs, geometry, tables). Loaded with lp-math.js
   on pages that show question text (front matter lpMath: true). */

.lp-fig {
  --lp-fig-ink: rgb(31 41 55);
  --lp-fig-grid: rgb(31 41 55 / 0.16);
  --lp-fig-fill: rgb(46 125 50 / 0.45);
  --lp-fig-shade: rgb(31 41 55 / 0.14);
  --lp-fig-bg: #fff;
  display: block;
  margin: 0.75rem 0;
  color: var(--lp-fig-ink);
  white-space: normal;
  line-height: 1.3;
}

.dark .lp-fig {
  --lp-fig-ink: rgb(229 231 235);
  --lp-fig-grid: rgb(229 231 235 / 0.16);
  --lp-fig-fill: rgb(129 199 132 / 0.45);
  --lp-fig-shade: rgb(229 231 235 / 0.16);
  --lp-fig-bg: rgb(31 41 55);
}

.lp-fig-title {
  margin: 0 0 0.35rem;
  font-weight: 600;
  font-size: 0.92em;
  text-align: center;
}

.lp-fig-box {
  position: relative;
  width: 100%;
  margin: 0 auto;
  container-type: inline-size;
  /* Figures are drawn left to right in every language. */
  direction: ltr;
}

/* Only the figure's own drawing: KaTeX draws radicals with SVG inside the labels. */
.lp-fig-box > svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lp-fig-grid { stroke: var(--lp-fig-grid); stroke-width: 1; }
.lp-fig-axis { stroke: currentColor; stroke-width: 1.4; }
.lp-fig-line { stroke: currentColor; stroke-width: 2; fill: none; }
.lp-fig-mark { stroke: currentColor; stroke-width: 1.4; fill: none; }
.lp-fig-median { stroke-width: 2.6; }
.lp-fig-dot { fill: currentColor; stroke: none; }
.lp-fig-dot-open { fill: var(--lp-fig-bg); stroke: currentColor; stroke-width: 1.8; }
.lp-fig-bar { fill: var(--lp-fig-fill); stroke: currentColor; stroke-width: 1.2; }
.lp-fig-box-rect { fill: var(--lp-fig-fill); stroke: currentColor; stroke-width: 1.6; }
.lp-fig-shade { fill: var(--lp-fig-shade); stroke: none; }

.lp-fig-lbl {
  position: absolute;
  white-space: nowrap;
  /* Scales with the figure, but never below a readable size. */
  font-size: clamp(10px, 2.5cqw, 14px);
  line-height: 1.15;
  pointer-events: none;
}

.lp-fig-num { font-variant-numeric: tabular-nums; }
.lp-fig-num-bg { background: var(--lp-fig-bg); padding: 0 1px; border-radius: 2px; }
.lp-fig--plot .lp-fig-num-bg { background: transparent; }
.lp-fig-var { font-family: "Times New Roman", Times, serif; font-size: clamp(12px, 3cqw, 16px); }
.lp-fig-axis-title { font-weight: 600; }
.lp-fig-ytitle { transform: translate(-50%, -50%) rotate(-90deg); }
/* Chinese, Japanese, Korean: a vertical title reads top to bottom with upright characters. */
.lp-fig-ytitle:lang(zh), .lp-fig-ytitle:lang(yue), .lp-fig-ytitle:lang(ja), .lp-fig-ytitle:lang(ko) {
  transform: translate(-50%, -50%);
  writing-mode: vertical-rl;
  text-orientation: mixed;
}
.lp-fig-cat { white-space: normal; text-align: center; }
.lp-fig-pt, .lp-fig-tag { font-size: clamp(11px, 3.1cqw, 15px); }
.lp-fig-lbl .katex { font-size: 1.05em; }
/* Labels are short: never the scrolling box (and scrollbar) .lp-math gets in running text. */
.lp-fig-lbl .lp-math { overflow: visible; max-width: none; padding-bottom: 0; }

.lp-fig-note {
  margin: 0.4rem 0 0;
  font-size: 0.85em;
  text-align: center;
  opacity: 0.85;
}

/* Watermark: "learnPALM" repeated on a diagonal behind the figure, meant to be barely visible. */
.lp-fig {
  --lp-fig-wm: 0.045;
}
.dark .lp-fig { --lp-fig-wm: 0.05; }
.lp-fig-wm {
  fill: currentColor;
  fill-opacity: var(--lp-fig-wm);
  stroke: none;
  /* Same face as the header wordmark (.lp-logo-text): Orbitron 500, self-hosted in fonts.css. */
  font: 500 14px "Orbitron", sans-serif;
  letter-spacing: 0.02em;
  user-select: none;
}
.lp-fig-wm-line {
  stroke: currentColor;
  stroke-opacity: var(--lp-fig-wm);
  stroke-width: 1.3;
}

/* Tables */
.lp-fig-table-box {
  position: relative;
  display: inline-block;
  max-width: 100%;
  vertical-align: top;
}
.lp-fig-wm-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}
.lp-fig-table-box .lp-fig-table { position: relative; }
.lp-fig--table { text-align: center; }
.lp-fig-table-wrap { max-width: 100%; overflow-x: auto; }
.lp-fig-table {
  margin: 0 auto;
  border-collapse: collapse;
  font-size: 0.95em;
  font-variant-numeric: tabular-nums;
}
.lp-fig-table th,
.lp-fig-table td {
  border: 1px solid rgb(31 41 55 / 0.35);
  padding: 0.35em 0.8em;
  text-align: center;
  vertical-align: middle;
}
.lp-fig-table th { font-weight: 600; background: rgb(31 41 55 / 0.05); }
.dark .lp-fig-table th,
.dark .lp-fig-table td { border-color: rgb(229 231 235 / 0.35); }
.dark .lp-fig-table th { background: rgb(229 231 235 / 0.07); }

/* Inside an answer choice: smaller, left aligned. */
.pn-choice-text .lp-fig,
.choice-text .lp-fig { margin: 0.25rem 0; }
.pn-choice-text .lp-fig--table,
.choice-text .lp-fig--table { text-align: start; }
.pn-choice-text .lp-fig-table,
.choice-text .lp-fig-table { margin: 0; font-size: 0.9em; }

/* No figure data yet: the description, in a box, instead of "[Graph: …]". */
.lp-fig--text {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.6rem 0.8rem;
  border: 1px dashed rgb(31 41 55 / 0.35);
  border-radius: 0.5rem;
  font-size: 0.93em;
  font-style: italic;
}
.dark .lp-fig--text { border-color: rgb(229 231 235 / 0.35); }
.lp-fig-text-icon {
  flex: none;
  width: 1.1em;
  height: 1.1em;
  margin-top: 0.15em;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  background:
    linear-gradient(currentColor, currentColor) 25% 75% / 1.5px 45% no-repeat,
    linear-gradient(currentColor, currentColor) 55% 75% / 1.5px 65% no-repeat,
    linear-gradient(currentColor, currentColor) 82% 75% / 1.5px 30% no-repeat;
  opacity: 0.7;
}
