/* Direction-dial figures (_includes/direction-viz.html) */

.dirviz {
  display: block;
  margin: 2em 0;
  padding: 1rem;
  border: 1px solid #e3e6e8;
  border-radius: 10px;
  background: #fff;
  color: #494e52;
  font-family: "IBM Plex Sans", -apple-system, "Segoe UI", sans-serif;
  font-size: 0.875rem;
  line-height: 1.5;
}

.dirviz__top {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.dirviz__plot {
  position: relative;
}

.dirviz__canvas {
  display: block;
  width: 100%;
  border-radius: 6px;
  background: #fbfcfc;
}

.dirviz__main {
  aspect-ratio: 1 / 1;
  cursor: crosshair;
}

.dirviz__hist {
  height: 150px;
}

.dirviz__curvecanvas {
  height: 190px;
}

.dirviz__strips {
  height: 310px;
}

.dirviz__pair {
  height: 160px;
}

/* Grab target at the arrow tip. Only here does touch turn the dial instead of scrolling. */
.dirviz__handle {
  position: absolute;
  top: 0;
  left: 0;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border: 2px solid rgba(15, 118, 110, 0.85);
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.8);
  touch-action: none;
  cursor: grab;
  transition: none;
}

.dirviz__handle:hover,
.dirviz__handle.is-dragging {
  cursor: grabbing;
  background: rgba(15, 118, 110, 0.12);
}

.dirviz sub,
.dirviz sup {
  font-size: 0.72em;
  line-height: 0;
}

.dirviz__title,
.dirviz__subtitle {
  margin: 0 0 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #4a5257;
}

.dirviz__subtitle {
  margin-top: 0.7rem;
}

.dirviz__status {
  margin-left: 0.6em;
  font-weight: 400;
  color: #8a9297;
}

.dirviz__readouts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.1rem 0.75rem;
  margin-top: 0.55rem;
  font-size: 0.8125rem;
}

.dirviz__k {
  color: #6b7378;
}

.dirviz__v {
  font-family: "IBM Plex Mono", monospace;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: #2d3236;
}

.dirviz__legend {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: #6b7378;
}

.dirviz__legend--tight {
  margin: -0.15rem 0 0.3rem;
}

.dirviz__legend-item {
  display: inline-block;
  margin-right: 0.9em;
  white-space: nowrap;
}

.dirviz__key {
  display: inline-block;
  width: 18px;
  height: 0;
  margin-right: 0.35em;
  vertical-align: middle;
}

.dirviz__key + .dirviz__key {
  margin-left: -0.1em;
}

.dirviz__key--c1 { border-top: 2px solid #0f766e; }
.dirviz__key--c2 { border-top: 2px dashed #b45309; }
.dirviz__key--axis1 { border-top: 1.5px dotted rgba(15, 118, 110, 0.7); width: 12px; }
.dirviz__key--axis2 { border-top: 1.5px dotted rgba(180, 83, 9, 0.7); width: 12px; }
.dirviz__key--arrow { border-top: 2.5px solid #1f2a30; }
.dirviz__key--fmax { border-top: 1.6px solid #0f766e; width: 12px; }
.dirviz__key--fmin { border-top: 1.6px solid #b45309; width: 12px; }
.dirviz__key--old { border-top: 1.6px dashed #8a9297; }
.dirviz__key--ring { border-top: 2px solid #9fd6cf; }
.dirviz__key--sep { border-top: 1.2px dashed #6b7378; }
.dirviz__key--perp { border-top: 1px dotted #8a9297; }
.dirviz__key--mi { border-top: 2.2px solid #0f766e; }
.dirviz__key--negj { border-top: 1.6px dashed #1f2a30; }

.dirviz__key--hue {
  width: 18px;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, hsl(0, 62%, 48%), hsl(90, 62%, 48%), hsl(180, 62%, 48%), hsl(270, 62%, 48%), hsl(360, 62%, 48%));
}

.dirviz__key--cross {
  width: auto;
  height: auto;
  font-weight: 700;
  color: #1f2a30;
}

.dirviz__curve {
  margin-top: 0.9rem;
}

.dirviz__options,
.dirviz__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.75rem;
  margin-top: 0.8rem;
}

.dirviz__play,
.dirviz__btn {
  flex: none;
  margin: 0;
  border: 1px solid #c9d0d4;
  border-radius: 6px;
  background: #fff;
  color: #2d3236;
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
}

.dirviz__play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
}

.dirviz__play svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.dirviz__btn {
  height: 2.25rem;
  padding: 0 0.75rem;
  white-space: nowrap;
}

.dirviz__play:hover,
.dirviz__btn:hover {
  border-color: #0f766e;
  color: #0f766e;
}

.dirviz__toggle[aria-pressed="true"] {
  border-color: #0f766e;
  background: #eff8f6;
  color: #0f766e;
}

.dirviz__play:focus-visible,
.dirviz__btn:focus-visible,
.dirviz .dirviz__preset:focus-visible {
  outline: 2px solid #0f766e;
  outline-offset: 1px;
}

.dirviz .dirviz__theta,
.dirviz .dirviz__shift {
  flex: 1 1 8rem;
  width: auto;
  min-width: 0;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: none;
  accent-color: #0f766e;
}

.dirviz .dirviz__field {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  color: inherit;
  cursor: default;
}

.dirviz__field-name {
  font-size: 0.8125rem;
  color: #4a5257;
}

.dirviz .dirviz__preset {
  display: inline-block;
  width: auto;
  height: 2.25rem;
  margin: 0;
  padding: 0 0.5rem;
  border: 1px solid #c9d0d4;
  border-radius: 6px;
  box-shadow: none;
  background-color: #fff;
  color: #2d3236;
  font: inherit;
  font-size: 0.8125rem;
}

.dirviz__out {
  min-width: 4.2em;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  color: #2d3236;
  text-align: right;
}

.dirviz figcaption,
.dirviz > figcaption {
  margin: 0.9rem 0 0;
  font-family: inherit;
  font-size: 0.8125rem;
  color: #6b7378;
}

@media (max-width: 640px) {
  .dirviz {
    padding: 0.75rem;
  }

  .dirviz__top {
    grid-template-columns: minmax(0, 1fr);
  }

  .dirviz__controls .dirviz__btn {
    flex: 1 1 0;
  }

  .dirviz .dirviz__theta {
    flex-basis: calc(100% - 3rem);
  }
}
