/* 動かして学ぶ（操作パネル・スライダー・場合分けダッシュボード）。すべてのセレクタを .mc- で始める。色は theme.css のトークン、定義は web/DESIGN.md */

/* ---------- 動かして学ぶ（操作パネル + グラフ） ---------- */
.mc-play {
  container-type: inline-size;
  margin: 1.5em 0;
}
.mc-play__inner {
  display: grid;
  gap: 1.5em;
}
@container (min-width: 40rem) {
  .mc-play__inner {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}
.mc-panel {
  padding: 1.25em;
  background: var(--mc-surface);
  border: 1px solid var(--mc-line);
  border-radius: 0.75em;
}
.mc-panel__label {
  margin: 0 0 0.5em;
  font-size: 0.8em;
  font-weight: 700;
  color: var(--mc-ink-muted);
}
.mc-panel__eq {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3em;
  margin-bottom: 1.25em;
  font-size: 1.4em;
  font-weight: 700;
  color: var(--mc-primary);
  overflow-x: auto;
}
.mc-panel__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  margin-top: 1.25em;
  padding-top: 1em;
  border-top: 1px solid var(--mc-line);
  font-size: 0.9em;
  font-weight: 700;
  color: var(--mc-ink-muted);
}
.mc-readout {
  padding: 0.15em 0.7em;
  font-family: var(--md-code-font);
  font-size: 0.9em;
  font-weight: 500;
  color: var(--mc-ink-soft);
  background: var(--mc-paper);
  border: 1px solid var(--mc-line);
  border-radius: 0.4em;
}
.mc-slider {
  margin-top: 1.25em;
}
.mc-slider__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 0.4em;
  font-size: 0.9em;
  font-weight: 600;
  color: var(--mc-ink-soft);
}
.mc-slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 1.5em;
  background: transparent;
}
.mc-slider input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--mc-line-strong);
  border-radius: 2px;
}
.mc-slider input[type="range"]::-moz-range-track {
  height: 4px;
  background: var(--mc-line-strong);
  border-radius: 2px;
}
.mc-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  background: var(--mc-primary);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.mc-slider input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--mc-primary);
  border: 0;
  border-radius: 50%;
}
/* JS で描くグラフの線（色は数学用の色） */
.mc-plot__grid { stroke: var(--mc-math-aux); stroke-width: 0.05; }
.mc-plot__axis { stroke: var(--mc-math-axis); stroke-width: 0.1; }
.mc-plot__curve { stroke: var(--mc-math-curve); stroke-width: 0.15; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.mc-plot__point { fill: var(--mc-math-warn); }

/* ---------- 操作パネルの小物（ステッパー・セレクト・チェック） ---------- */
.mc-play__side {
  display: grid;
  gap: 1em;
}
.mc-formula-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5em;
  padding: 0.75em 1em;
  background: var(--mc-surface);
  border: 1px solid var(--mc-line);
  border-radius: 0.75em;
  font-size: 0.9em;
}
.mc-formula-bar__label {
  font-weight: 700;
  color: var(--mc-ink-muted);
}
.mc-pair {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5em;
  margin-top: 0.75em;
}
.mc-pair__op {
  min-width: 3.5em;
  text-align: center;
  color: var(--mc-ink-soft);
}
.mc-stepper {
  display: inline-flex;
  align-items: stretch;
}
.mc-stepper button {
  padding: 0.2em 0.8em;
  font-weight: 700;
  color: var(--mc-ink-soft);
  background: var(--mc-surface-sunk);
  border: 1px solid var(--mc-line-strong);
  cursor: pointer;
}
.mc-stepper button:first-child {
  border-radius: 0.4em 0 0 0.4em;
}
.mc-stepper button:last-child {
  border-radius: 0 0.4em 0.4em 0;
}
.mc-stepper input {
  width: 3.5em;
  padding: 0.2em;
  font: inherit;
  font-weight: 700;
  text-align: center;
  color: var(--mc-ink);
  background: var(--mc-paper);
  border: 1px solid var(--mc-line-strong);
  border-width: 1px 0;
  -moz-appearance: textfield;
}
.mc-stepper input::-webkit-outer-spin-button,
.mc-stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.mc-select {
  width: 100%;
  padding: 0.5em;
  font: inherit;
  font-weight: 500;
  color: var(--mc-ink);
  background: var(--mc-paper);
  border: 1px solid var(--mc-line-strong);
  border-radius: 0.5em;
}
.mc-check {
  display: flex;
  align-items: center;
  gap: 0.6em;
  margin-top: 0.5em;
  font-size: 0.9em;
  font-weight: 500;
  cursor: pointer;
}
.mc-slider--ok input[type="range"]::-webkit-slider-thumb {
  background: var(--mc-math-ok);
}
.mc-slider--ok input[type="range"]::-moz-range-thumb {
  background: var(--mc-math-ok);
}
.mc-note {
  margin: 0.5em 0 0;
  font-size: 0.8em;
  text-align: center;
  color: var(--mc-ink-muted);
}
/* foreignObject 内の数式ラベル */
.mc-vec-label {
  position: absolute;
  font-size: 14px;
  line-height: 1.3;
}
.mc-vec-label--bg {
  padding: 1px 6px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 4px;
}

/* ---------- 場合分けダッシュボード（canvas・タブ・解説ボックス） ---------- */
.mc-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  touch-action: none;
  border-radius: 0.5em;
}
.mc-tabs {
  display: flex;
  padding: 0.25em;
  background: var(--mc-surface-sunk);
  border-radius: 0.75em;
}
.mc-tabs__btn {
  flex: 1;
  padding: 0.5em 0.75em;
  font: inherit;
  font-weight: 700;
  color: var(--mc-ink-muted);
  background: transparent;
  border: 0;
  border-radius: 0.5em;
  cursor: pointer;
}
.mc-tabs__btn[aria-pressed="true"] {
  color: var(--mc-ink);
  background: var(--mc-paper);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.mc-choices {
  display: grid;
  gap: 0.5em;
}
.mc-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5em 0.75em;
  font: inherit;
  font-size: 0.9em;
  font-weight: 500;
  text-align: left;
  color: var(--mc-ink-soft);
  background: transparent;
  border: 2px solid var(--mc-line);
  border-radius: 0.75em;
  cursor: pointer;
}
.mc-choice::after {
  content: "";
  width: 0.9em;
  height: 0.9em;
  border: 2px solid var(--mc-line-strong);
  border-radius: 50%;
}
.mc-choice[aria-pressed="true"] {
  background: var(--mc-surface-sunk);
  border-color: var(--mc-ink-muted);
}
.mc-choice[aria-pressed="true"]::after {
  background: var(--mc-ink-muted);
  border-color: var(--mc-ink-muted);
}
.mc-width-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5em;
  padding: 0.5em 0.75em;
  font-size: 0.85em;
  font-weight: 500;
  background: var(--mc-surface);
  border: 1px solid var(--mc-line);
  border-radius: 0.75em;
}
.mc-width-setting input {
  width: 4.5em;
  padding: 0.2em 0.4em;
  font: inherit;
  font-weight: 600;
  text-align: center;
  color: var(--mc-ink);
  background: var(--mc-paper);
  border: 1px solid var(--mc-line-strong);
  border-radius: 0.5em;
}
.mc-func {
  display: grid;
  gap: 0.5em;
  padding: 0.75em;
  text-align: center;
  background: var(--mc-surface);
  border: 1px solid var(--mc-line);
  border-radius: 0.75em;
}
.mc-func__line {
  font-size: 1.1em;
  color: var(--mc-ink);
}
.mc-func__domain {
  justify-self: center;
  padding: 0.1em 0.9em;
  color: var(--mc-ink-soft);
  background: var(--mc-paper);
  border: 1px solid var(--mc-line);
  border-radius: 999px;
}
.mc-var {
  font-style: italic;
  font-weight: 700;
}
.mc-var--a { color: var(--mc-math-neg); }
.mc-var--p { color: var(--mc-math-region); }
.mc-var--q { color: var(--mc-math-vertex); }
.mc-var--s { color: var(--mc-math-ok-deep); }
.mc-var--t { color: var(--mc-math-warn-deep); }
.mc-slider-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 1em;
}
.mc-slider--wide {
  grid-column: span 2;
}
.mc-slider.is-disabled {
  opacity: 0.5;
  pointer-events: none;
  filter: grayscale(100%);
}
.mc-slider__range {
  display: flex;
  justify-content: space-between;
  padding: 0 0.25em;
  font-size: 0.7em;
  color: var(--mc-ink-muted);
}
/* 進んだ分だけ灰色で塗るトラック（--val は JS が 0%〜100% で設定する） */
.mc-slider--fill input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  background: linear-gradient(to right, var(--mc-math-axis) var(--val, 50%), var(--mc-line) var(--val, 50%));
  border-radius: 4px;
}
.mc-slider--fill input[type="range"]::-moz-range-track {
  height: 8px;
  background: linear-gradient(to right, var(--mc-math-axis) var(--val, 50%), var(--mc-line) var(--val, 50%));
  border-radius: 4px;
}
.mc-slider--fill input[type="range"]::-webkit-slider-thumb {
  width: 24px;
  height: 24px;
  margin-top: -8px;
  border: 2px solid var(--mc-math-white);
}
.mc-slider--fill input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 2px solid var(--mc-math-white);
}
.mc-slider--a input[type="range"]::-webkit-slider-thumb { background: var(--mc-math-neg); }
.mc-slider--p input[type="range"]::-webkit-slider-thumb { background: var(--mc-math-region); }
.mc-slider--q input[type="range"]::-webkit-slider-thumb { background: var(--mc-math-vertex); }
.mc-slider--s input[type="range"]::-webkit-slider-thumb { background: var(--mc-math-ok-deep); }
.mc-slider--t input[type="range"]::-webkit-slider-thumb { background: var(--mc-math-warn-deep); }
.mc-slider--a input[type="range"]::-moz-range-thumb { background: var(--mc-math-neg); }
.mc-slider--p input[type="range"]::-moz-range-thumb { background: var(--mc-math-region); }
.mc-slider--q input[type="range"]::-moz-range-thumb { background: var(--mc-math-vertex); }
.mc-slider--s input[type="range"]::-moz-range-thumb { background: var(--mc-math-ok-deep); }
.mc-slider--t input[type="range"]::-moz-range-thumb { background: var(--mc-math-warn-deep); }
.mc-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4em 1.25em;
  margin-top: 0.75em;
  font-size: 0.75em;
  color: var(--mc-ink-muted);
}
.mc-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}
.mc-legend__swatch {
  display: inline-block;
  width: 1.2em;
  height: 0.7em;
  border-radius: 0.2em;
}
.mc-legend__swatch--domain { background: var(--mc-answer-bg); border: 1px dashed var(--mc-math-ok); }
.mc-legend__swatch--axis { height: 2px; background: var(--mc-math-region); }
.mc-legend__swatch--curve { height: 4px; background: var(--mc-math-label); }
.mc-legend__swatch--out { height: 1px; background: var(--mc-math-aux); }
.mc-legend__swatch--max,
.mc-legend__swatch--min { width: 0.8em; height: 0.8em; border-radius: 50%; }
.mc-legend__swatch--max { background: var(--mc-math-neg); }
.mc-legend__swatch--min { background: var(--mc-math-curve); }
.mc-explain {
  padding: 1em 1.25em;
  line-height: 1.7;
  color: var(--mc-ink-soft);
  background: var(--mc-surface);
  border-left: 4px solid var(--mc-line-strong);
  border-radius: 0.75em;
}
.mc-explain--max {
  background: color-mix(in srgb, var(--mc-math-neg) 8%, var(--mc-paper));
  border-left-color: var(--mc-math-neg);
}
.mc-explain--min {
  background: color-mix(in srgb, var(--mc-math-curve) 8%, var(--mc-paper));
  border-left-color: var(--mc-math-curve);
}
.mc-explain p {
  margin: 0.5em 0;
}
.mc-explain__badge {
  display: inline-block;
  margin-bottom: 0.75em;
  padding: 0.15em 0.8em;
  font-size: 0.9em;
  font-weight: 700;
  color: var(--mc-math-white);
  background: var(--mc-math-neg);
  border-radius: 0.4em;
}
.mc-explain--min .mc-explain__badge {
  background: var(--mc-math-curve);
}
.mc-explain__status {
  margin: 0.5em 0;
  font-size: 1.1em;
  font-weight: 700;
  color: var(--mc-ink);
}
.mc-explain__warn {
  margin: 0.75em 0;
  padding: 0.6em 0.9em;
  font-weight: 700;
  color: var(--mc-keypoint-ink);
  background: var(--mc-keypoint-bg);
  border: 1px solid var(--mc-keypoint-line);
  border-radius: 0.5em;
}
.mc-explain__result {
  font-size: 1.1em;
}
.mc-chip {
  display: inline-block;
  margin: 0 0.25em;
  padding: 0.05em 0.6em;
  font-style: italic;
  color: var(--mc-ink);
  background: var(--mc-paper);
  border: 1px solid var(--mc-line);
  border-radius: 0.4em;
}
