/*
 * Mestizaje — the sonar switchboard. Builds on /css/iscream.css.
 */

.masthead__art[src$='dogz.gif'] {
  width: 144px; /* 2x the source */
}

.mix-status {
  margin: 0 0 12px;
  font-size: 0.8em;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}

.mix-status[data-state='error'] {
  color: var(--warn);
}

/* ------------------------------------------------------------------ stage */

.stage {
  position: relative;
  width: min(100%, 640px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  touch-action: none; /* dragging a dot must not scroll the page */
  user-select: none;
  -webkit-user-select: none;
}

.stage__sonar {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  opacity: 0.6; /* the sonar sits back; the dots (DOM, full white) sit on top */
}

.stage__dots {
  position: absolute;
  inset: 0;
}

/* -------------------------------------------------------------------- dots */

.dot {
  position: absolute;
  width: 44px; /* touch target; the visible dot is the ::before */
  height: 44px;
  margin: -22px 0 0 -22px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;
  transition: left 0.35s steps(6), top 0.35s steps(6), opacity 0.5s;
  -webkit-tap-highlight-color: transparent;
}

.dot::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  background: var(--fg);
  box-shadow: 0 0 0 2px var(--bg);
}

.dot--in::before {
  width: 15px;
  height: 15px;
  margin: -7.5px 0 0 -7.5px;
}

/* Connecting: the dot blinks in whole steps, like the rest of the art. */
.dot[data-state='connecting']::before,
.dot[data-state='reconnecting']::before {
  animation: blink 0.8s steps(2, jump-none) infinite;
}

.dot[data-state='error']::before {
  background: var(--bg);
  outline: 2px solid var(--warn);
}

@keyframes blink {
  50% { opacity: 0.2; }
}

.dot--drag {
  cursor: grabbing;
  transition: opacity 0.5s; /* follow the finger, no easing */
  z-index: 2;
}

.dot--gone {
  opacity: 0;
}

.dot__label {
  position: absolute;
  left: 34px;
  top: 50%;
  transform: translateY(-50%);
  max-width: 11em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
  font-size: 0.72em;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--fg);
  background: var(--bg);
  padding: 1px 4px;
  pointer-events: none;
}

.dot--left .dot__label {
  left: auto;
  right: 34px;
}

.dot:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: -8px;
}

/* Phones: side labels would run off the screen, so they go under the dot. */
@media (max-width: 600px) {
  .dot__label,
  .dot--left .dot__label {
    left: 50%;
    right: auto;
    top: 36px;
    transform: translateX(-50%);
    max-width: 9em;
    font-size: 0.66em;
  }

  .dot--edge-l .dot__label {
    left: 10px;
    transform: none;
  }

  .dot--edge-r .dot__label {
    left: auto;
    right: 10px;
    transform: none;
  }
}

/* ------------------------------------------------------------------- veil */

.veil {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 46%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 2px solid var(--fg);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  z-index: 3;
}

.veil:hover {
  box-shadow: 0 0 15px var(--glow);
}

.veil img {
  width: 120px;
  height: auto;
}

/* The disc before audio starts: a dim, dithered sonar under the button. */
.stage:has(.veil:not([hidden])) .stage__dots {
  opacity: 0.5;
  pointer-events: none;
}

/* -------------------------------------------------------------- mix list */

.mix-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.8em;
  color: var(--fg-dim);
}

.mix-list li {
  padding: 3px 0;
  border-bottom: 1px dashed var(--hairline);
}

/* ------------------------------------------------------------- recording */

.rec {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.rec__info {
  margin: 0;
  font-family: var(--mono);
}

.rec__button:disabled {
  opacity: 0.5;
  cursor: default;
}

.rec__button.is-rec {
  animation: blink 1.2s steps(2, jump-none) infinite;
}

.rec__out {
  margin: 12px 0;
  padding-left: 1.2em;
  font-family: var(--mono);
  font-size: 0.85em;
}

@media (prefers-reduced-motion: reduce) {
  .dot,
  .rec__button.is-rec,
  .dot::before {
    animation: none !important;
    transition: none;
  }
}
