/* Widget layout for 00-toolkit -- interactive SVG playgrounds paired with
   sliders/checkboxes and a live numeric readout. */

.widget {
  display: grid;
  grid-template-columns: minmax(280px, 1.3fr) minmax(220px, 1fr);
  gap: 16px;
  align-items: start;
  margin-bottom: 14px;
}
@media (max-width: 820px) {
  .widget { grid-template-columns: 1fr; }
}

.widget-visual {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
}
.widget-visual svg {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 170px;
  display: block;
  margin: 0 auto;
  touch-action: none;
}
/* A widget-visual with several stacked panes (track + two or three graphs,
   as in kinematics) needs a tighter per-pane cap than a widget with just one
   SVG, or the whole stack (and the play button beside it) runs off-screen. */
.widget-visual svg:not(:only-of-type) {
  max-height: 100px;
}
.widget-visual svg + .pane-label { margin-top: 4px; }
.widget-visual .pane-label { margin: 0 0 2px; font-size: 11.5px; }
/* Square (1:1) or portrait SVGs (vector diagrams, vertical drop tracks,
   top-down maps) need a taller box than the default line-graph cap, but
   still bounded so they never require scrolling to see the whole widget. */
.widget-visual.compact svg {
  max-width: 230px;
  max-height: 230px;
  margin: 0 auto;
}

.readout table + table { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }

.widget-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.controls {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.controls .row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}
.controls .row .row-head {
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
}
.controls .row .row-head b { color: var(--text-primary); font-weight: 600; }
.controls input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.controls label.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  cursor: pointer;
}
.controls label.checkbox input { accent-color: var(--accent); width: 15px; height: 15px; }
.controls button.action {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  border-radius: 8px;
  padding: 7px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  align-self: flex-start;
}
.controls button.action:hover { background: var(--chip); }

.readout {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13.5px;
}
.readout table { width: 100%; border-collapse: collapse; }
.readout td { padding: 3px 0; }
.readout td.k { color: var(--text-secondary); }
.readout td.v {
  text-align: right;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  color: var(--text-primary);
  font-weight: 600;
}
.readout .swatch {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: -1px;
}

.explainer {
  color: var(--text-secondary);
  max-width: 100ch;
  font-size: 14px;
  margin: 0 0 18px;
}
.explainer strong { color: var(--text-primary); }

.svg-label { font-size: 12px; fill: var(--text-secondary); }
.svg-axis { stroke: var(--gridline); stroke-width: 1; }
.svg-grid { stroke: var(--gridline); stroke-width: 0.6; }

.explainer var, .readout var, summary var {
  font-style: normal;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  color: var(--text-primary);
}

details.math-details {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-1);
  padding: 4px 14px;
  margin: 0 0 18px;
  max-width: 100ch;
}
details.math-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
  padding: 8px 0;
  list-style: none;
}
details.math-details summary::-webkit-details-marker { display: none; }
details.math-details summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s ease;
}
details.math-details[open] summary::before { transform: rotate(90deg); }
details.math-details .explainer:last-child { margin-bottom: 10px; }
