/* inspect.js: Measure's readouts and hint bar, label pins and their card. The points and lines are
   drawn in overlay.js's canvas; these sit over it in the viewport and move with the warp. */
.sv-inspect {
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
}

.sv-viewport.is-picking video {
  cursor: crosshair !important;
}

/* A measurement's value, centred on its line (or beside its angle); hover or tap: ΔX ΔY ΔZ. */
#viewer .sv-measure {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: rgb(23 23 26 / 0.88);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
  font: 600 12px/16px var(--sv-font);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  translate: -50% -50%;
  pointer-events: auto;
  will-change: transform;
}

/* base.css's light hover would put white text on near-white. */
#viewer .sv-measure:hover:not(:disabled) {
  background: rgb(23 23 26 / 0.88);
}

.sv-measure.is-hidden {
  opacity: 0.6;
}

.sv-measure__delta {
  display: none;
  font-weight: 500;
  font-size: 11px;
  opacity: 0.85;
}

.sv-measure:hover .sv-measure__delta:not(:empty),
.sv-measure.is-open .sv-measure__delta:not(:empty) {
  display: block;
}

/* A pin: its point is drawn in the canvas; the title sits above it, the card below. */
.sv-pin {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  will-change: transform;
}

#viewer .sv-pin__chip {
  position: absolute;
  bottom: 9px;
  left: 0;
  max-width: 180px;
  min-height: 26px;
  overflow: hidden;
  padding: 4px 10px;
  border: 1px solid var(--sv-border);
  border-left: 3px solid #2f6bff;
  border-radius: 6px;
  color: var(--sv-ink);
  background: var(--sv-surface);
  box-shadow: var(--sv-shadow);
  font: 600 12px/16px var(--sv-font);
  text-overflow: ellipsis;
  white-space: nowrap;
  translate: -50% 0;
  pointer-events: auto;
}

.sv-pin.is-hidden .sv-pin__chip {
  opacity: 0.5;
}

.sv-pin.is-open {
  z-index: 1;
}

/* Fingers: a 44 px target around the chip. */
@media (any-pointer: coarse) {
  #viewer .sv-pin__chip::after,
  #viewer .sv-measure::after {
    content: "";
    position: absolute;
    inset: -9px -4px;
  }

  #viewer .sv-pin__chip {
    overflow: visible;
  }
}

/* Touch first: the chip itself at least 32 px tall. */
@media (pointer: coarse) {
  #viewer .sv-measure {
    min-height: 32px;
    padding: 8px 12px;
  }
}

.sv-label-card {
  position: absolute;
  top: 10px;
  left: 0;
  width: min(260px, 80vw);
  padding: 10px 12px;
  border: 1px solid var(--sv-border);
  border-radius: 10px;
  color: var(--sv-ink);
  background: var(--sv-surface);
  box-shadow: var(--sv-shadow);
  font: 13px/18px var(--sv-font);
  translate: -50% 0;
  pointer-events: auto;
}

.sv-label-card h3 {
  margin: 0 0 4px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.sv-label-card p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sv-label-card p.is-empty {
  color: var(--sv-faint);
}

.sv-label-card form {
  display: grid;
  gap: 6px;
}

#viewer .sv-label-card :is(input, textarea) {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid var(--sv-border);
  border-radius: 6px;
  font: inherit;
  resize: vertical;
}

.sv-label-card__row {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

#viewer .sv-label-card__row button {
  min-height: 32px;
  padding: 0 10px;
}

#viewer .sv-label-card__delete {
  margin-right: auto;
  color: var(--sv-danger);
}

#viewer .sv-label-card__save {
  border-color: var(--sv-accent);
  color: #fff;
  background: var(--sv-accent);
}

#viewer .sv-label-card__save:hover:not(:disabled) {
  background: #1f3bb8;
}

@media (pointer: coarse) {
  #viewer .sv-label-card :is(input, .sv-label-card__row button) {
    min-height: 44px;
  }
}

/* The tool's hint and chips: above the toolbar, centred in what the drawer and card leave. */
.sv-measure-bar {
  position: absolute;
  z-index: 2;
  bottom: var(--sv-above-dock);
  left: calc(var(--sv-l, 0px) + (100% - var(--sv-l, 0px) - var(--sv-r, 0px)) / 2);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - var(--sv-l, 0px) - var(--sv-r, 0px) - 32px);
  padding: 4px 4px 4px 12px;
  border-radius: 999px;
  color: #fff;
  background: rgb(23 23 26 / 0.88);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
  font: 500 12px/16px var(--sv-font);
  translate: -50% 0;
}

.sv-measure-bar__hint {
  min-width: 0;
  padding-right: 8px;
}

.sv-measure-bar__chip {
  flex: none;
}

#viewer .sv-measure-bar__chip {
  min-height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: rgb(255 255 255 / 0.16);
  font: 600 12px/16px var(--sv-font);
}

#viewer .sv-measure-bar__chip:hover:not(:disabled),
#viewer .sv-measure-bar__chip[aria-pressed="true"] {
  background: rgb(255 255 255 / 0.3);
}

@media (any-pointer: coarse) {
  #viewer .sv-measure-bar__chip {
    min-height: 44px;
  }
}

/* Phones: a full-width bar just above the toolbar, the hint on at most two lines at the left and
   the chips on the right (one row of 44 px targets: little of the model's lower part covered). */
@media (max-width: 760px), (max-width: 1023px) and (max-height: 520px) and (min-aspect-ratio: 301/200) {
  .sv-measure-bar {
    right: max(8px, env(safe-area-inset-right));
    bottom: calc(var(--sv-above-dock) - 4px);
    left: max(8px, env(safe-area-inset-left));
    max-width: none;
    padding: 4px 4px 4px 12px;
    border-radius: 14px;
    translate: none;
  }

  .sv-measure-bar__hint {
    display: -webkit-box;
    flex: 1;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }
}
