/* Interactive Chapter 11 elasticity figures (see widget.js). Same look as the
   heterogeneous-belief widget earlier in the chapter. */

.akel-widget,
.akel-widget * {
  box-sizing: border-box;
}

.akel-widget {
  --akel-s0: #008300;
  --akel-s1: #e34948;
  --akel-s2: #2a78d6;
  --akel-s3: #eb6834;
  --akel-s4: #6250d6;
  --akel-s5: #1baf7a;
  --akel-s6: #eda100;
  --akel-s7: #e87ba4;
  --akel-grid: rgba(0, 0, 0, 0.08);
  --akel-zero: rgba(0, 0, 0, 0.28);
  --akel-axis: #66645f;
  --akel-text: #444441;
  margin: 0 auto 0.75rem;
  color: #1a1a18;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-align: left;
}

.akel-widget[hidden] {
  display: none;
}

.akel-panel {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  background: #ffffff;
  padding: 1.25rem;
}

.akel-widget.is-single .akel-panel {
  max-width: 640px;
}

.akel-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

/* narrower card: give the check boxes room to stay on one line */
.akel-widget.is-single .akel-controls {
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
}

/* below two sliders, the check boxes take the full row */
.akel-control.is-wide {
  grid-column: 1 / -1;
}

/* opts.stackControls: one control per row. A lone slider beside a long check-box
   list crowds both -- the list wraps to three rows while the slider stretches. */
.akel-widget.is-stacked .akel-controls,
.akel-widget.is-stacked.is-single .akel-controls {
  grid-template-columns: minmax(0, 1fr);
}

.akel-control {
  border-radius: 8px;
  background: #f4f3f0;
  padding: 0.75rem;
}

.akel-label {
  margin-bottom: 0.4rem;
  color: #66645f;
  font-size: 0.78rem;
  line-height: 1.2;
}

.akel-slider input[type="range"] {
  display: block;
  width: 100%;
  height: 4px;
  margin: 0.45rem 0;
  border-radius: 999px;
  outline-offset: 4px;
  background: #d3d1c7;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.akel-slider input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #534ab7;
  box-shadow: 0 0 0 1px rgba(83, 74, 183, 0.4);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.akel-slider input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #534ab7;
  cursor: pointer;
}

.akel-ticks {
  display: flex;
  justify-content: space-between;
  padding: 0 4px;
  color: #66645f;
  font-size: 0.75rem;
}

.akel-ticks span.is-active {
  color: #1a1a18;
  font-weight: 600;
}

.akel-lines {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
}

.akel-line {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  color: #1a1a18;
  font-size: 0.88rem;
  cursor: pointer;
  user-select: none;
}

.akel-line input {
  margin: 0;
  accent-color: #534ab7;
  cursor: pointer;
}

.akel-line.is-off {
  opacity: 0.45;
}

.akel-key {
  display: inline-block;
  width: 20px;
  border-top: 2.5px solid var(--akel-s0);
}

.akel-key-1 {
  border-top: 2.5px dashed var(--akel-s1);
}

.akel-key-2 {
  border-top-color: var(--akel-s2);
}

.akel-key-3 {
  border-top: 2.5px dashed var(--akel-s3);
}

.akel-key-4 {
  border-top: 2.5px dashed var(--akel-s4);
}

.akel-key-5 {
  border-top: 2.5px dotted var(--akel-s5);
}

.akel-key-6 {
  border-top: 2.5px dashed var(--akel-s6);
}

.akel-key-7 {
  border-top: 2.5px dashed var(--akel-s7);
}

.akel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.akel-widget.is-single .akel-grid {
  grid-template-columns: 1fr;
}

.akel-plot {
  min-width: 0;
  border-radius: 8px;
  background: #f4f3f0;
  padding: 0.6rem 0.6rem 0.5rem;
}

.akel-plot-title {
  margin: 0 0 0.4rem 0.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
}

.akel-chart {
  position: relative;
  width: 100%;
  height: 270px;
}

.akel-widget.is-single .akel-chart {
  height: 320px;
}

.akel-note {
  margin: 0.65rem 0 0;
  color: #74716a;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.82rem;
  font-style: italic;
  line-height: 1.4;
  text-align: center;
}

/* on screen the widget replaces the figure's static image; print/PDF keeps the image */
@media screen {
  figure.akel-live > a.image-reference,
  figure.akel-live > img {
    display: none;
  }
}

@media print {
  .akel-widget {
    display: none !important;
  }
}

@media (max-width: 640px) {
  .akel-panel {
    padding: 1rem;
  }

  .akel-controls,
  .akel-widget.is-single .akel-controls,
  .akel-grid {
    grid-template-columns: 1fr;
  }

  .akel-chart,
  .akel-widget.is-single .akel-chart {
    height: 230px;
  }
}

html[data-theme="dark"] .akel-widget {
  --akel-s0: #1f9a3a;
  --akel-s1: #e66767;
  --akel-s2: #3987e5;
  --akel-s3: #d95926;
  --akel-s4: #9085e9;
  --akel-s5: #199e70;
  --akel-s6: #c98500;
  --akel-s7: #d55181;
  --akel-grid: rgba(255, 255, 255, 0.08);
  --akel-zero: rgba(255, 255, 255, 0.28);
  --akel-axis: #b0ada5;
  --akel-text: #d7d4cb;
  color: #e8e6e0;
}

html[data-theme="dark"] .akel-panel {
  border-color: rgba(255, 255, 255, 0.12);
  background: #242422;
}

html[data-theme="dark"] .akel-control,
html[data-theme="dark"] .akel-plot {
  background: #2e2e2b;
}

html[data-theme="dark"] .akel-label,
html[data-theme="dark"] .akel-ticks,
html[data-theme="dark"] .akel-note {
  color: #b0ada5;
}

html[data-theme="dark"] .akel-line,
html[data-theme="dark"] .akel-ticks span.is-active {
  color: #e8e6e0;
}

html[data-theme="dark"] .akel-slider input[type="range"] {
  background: #444441;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme]) .akel-widget {
    --akel-s0: #1f9a3a;
    --akel-s1: #e66767;
    --akel-s2: #3987e5;
    --akel-s3: #d95926;
    --akel-s4: #9085e9;
    --akel-s5: #199e70;
    --akel-s6: #c98500;
    --akel-s7: #d55181;
    --akel-grid: rgba(255, 255, 255, 0.08);
    --akel-zero: rgba(255, 255, 255, 0.28);
    --akel-axis: #b0ada5;
    --akel-text: #d7d4cb;
    color: #e8e6e0;
  }

  html:not([data-theme]) .akel-panel {
    border-color: rgba(255, 255, 255, 0.12);
    background: #242422;
  }

  html:not([data-theme]) .akel-control,
  html:not([data-theme]) .akel-plot {
    background: #2e2e2b;
  }

  html:not([data-theme]) .akel-label,
  html:not([data-theme]) .akel-ticks,
  html:not([data-theme]) .akel-note {
    color: #b0ada5;
  }

  html:not([data-theme]) .akel-line,
  html:not([data-theme]) .akel-ticks span.is-active {
    color: #e8e6e0;
  }

  html:not([data-theme]) .akel-slider input[type="range"] {
    background: #444441;
  }
}
