/* KIRUPA Learn widget kit: the shared look for interactive explainers that live inside Learn articles.
   Widgets are transparent iframe documents inside an article's .exampleFrame. They borrow the article's ink
   through /codingexercises/examples/embed-theme.js (--exercise* tokens) and its corner shape through
   /animations/examples/demo-shape.js (--demoRadius*), so they follow every site style and dark mode.
   See learn/widgets/README.md. */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 14px 14px 18px;
  background-color: transparent;
  color: var(--exerciseText, #1e2933);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
}

.kit {
  display: grid;
  gap: 16px;
}

.kit [hidden] {
  display: none !important;
}

.kit-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px 20px;
  align-items: start;
}

.kit-group {
  display: grid;
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 10px 14px 14px;
  border: 1.5px solid color-mix(in srgb, currentColor 25%, transparent);
  border-radius: var(--demoRadiusSmall, 12px);
}

.kit-group[disabled] {
  opacity: 0.5;
}

.kit-group > legend {
  padding: 0 6px;
  font-weight: 800;
  font-size: 15px;
}

/* A labeled range slider with its live value. */
.kit-slider {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  align-items: baseline;
  font-size: 15px;
}

.kit-slider output {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.kit-slider input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  margin: 4px 0 0;
  accent-color: var(--exerciseAccent, #0570c0);
}

/* A row of radio buttons drawn as one segmented control. */
.kit-segmented {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.kit-segmented > legend {
  float: left;
  margin-right: 6px;
  font-weight: 800;
  font-size: 15px;
}

.kit-segmented label,
.kit-switch {
  position: relative;
}

.kit-segmented input,
.kit-switch input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.kit-segmented span {
  display: inline-block;
  padding: 7px 14px;
  border: 2px solid currentColor;
  border-radius: var(--demoRadiusControl, 8px);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}

.kit-segmented input:checked + span {
  background-color: var(--exerciseText, #1e2933);
  color: var(--exerciseControl, #ffffff);
}

.kit-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
}

.kit-switch__track {
  flex: none;
  position: relative;
  width: 42px;
  height: 24px;
  border: 2px solid currentColor;
  border-radius: 999px;
}

.kit-switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background-color: currentColor;
  transition: transform 0.15s ease;
}

.kit-switch input:checked + .kit-switch__track {
  background-color: var(--exerciseAccent, #0570c0);
  border-color: var(--exerciseAccent, #0570c0);
}

.kit-switch input:checked + .kit-switch__track::after {
  transform: translateX(18px);
  background-color: var(--exerciseControl, #ffffff);
}

.kit-segmented input:focus-visible + span,
.kit-switch input:focus-visible + .kit-switch__track,
.kit-slider input:focus-visible {
  outline: 3px solid var(--exerciseAccent, #0798ff);
  outline-offset: 2px;
}

/* Readout chips: a muted label and a bold value that changes as readers play. */
.kit-readouts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kit-chip {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 7%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 18%, transparent);
  font-size: 15px;
}

.kit-chip > span {
  color: var(--exerciseMuted, #5b6773);
}

.kit-chip b {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.kit-good {
  color: var(--exerciseGood, #236a32);
}

.kit-bad {
  color: var(--exerciseBad, #b72222);
}

/* Results tables scroll sideways on narrow screens instead of squeezing. */
.kit-table-wrap {
  overflow-x: auto;
}

.kit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.kit-table th,
.kit-table td {
  padding: 7px 10px;
  border-bottom: 1px solid color-mix(in srgb, currentColor 18%, transparent);
  text-align: right;
  white-space: nowrap;
}

.kit-table th:first-child,
.kit-table td:first-child {
  text-align: left;
}

.kit-table thead th {
  font-weight: 800;
  border-bottom: 2px solid color-mix(in srgb, currentColor 35%, transparent);
}

.kit-table tr.kit-out td {
  color: var(--exerciseMuted, #5b6773);
}

.kit-table tfoot td {
  font-weight: 800;
  border-bottom: 0;
}

@media (prefers-reduced-motion: reduce) {
  .kit-switch__track::after {
    transition: none;
  }
}
