/* Video Waaaves web app (assets/js/waaaves.js) */

/* ---- the two app windows: the output monitor and the control window (both draggable and resizable) ---- */
.modalContainer--waaavesApp,
.modalContainer--waaavesMonitor {
  display: none;
  max-width: none;
  min-width: 200px;
  box-shadow: 0px 0px 32px #ff6347;
  animation: morphFromInverse 180s infinite;
  touch-action: auto; /* sliders and the control panel have to scroll on phones */
}

.modalContainer--waaavesMonitor {
  top: 4%;
  left: 2%;
  width: 52%;
  height: 62vh;
}

.modalContainer--waaavesApp {
  top: 4%;
  left: 56%;
  width: 42%;
  height: 90vh;
}

.modalContainer--waaavesApp:hover,
.modalContainer--waaavesApp .waaavesApp:hover,
.modalContainer--waaavesMonitor:hover {
  cursor: default;
}

/* resize grips (jQuery UI adds these handles; its own stylesheet is not loaded here) */
.modalContainer--waaavesApp .ui-resizable-handle,
.modalContainer--waaavesMonitor .ui-resizable-handle {
  position: absolute;
  z-index: 10;
  touch-action: none;
}

.ui-resizable-n, .ui-resizable-s { left: 12px; right: 12px; height: 8px; cursor: ns-resize; }
.ui-resizable-e, .ui-resizable-w { top: 12px; bottom: 12px; width: 8px; cursor: ew-resize; }
.ui-resizable-n { top: -4px; }
.ui-resizable-s { bottom: -4px; }
.ui-resizable-e { right: -4px; }
.ui-resizable-w { left: -4px; }
.ui-resizable-ne, .ui-resizable-nw, .ui-resizable-se, .ui-resizable-sw { width: 16px; height: 16px; }
.ui-resizable-ne { top: -4px; right: -4px; cursor: nesw-resize; }
.ui-resizable-nw { top: -4px; left: -4px; cursor: nwse-resize; }
.ui-resizable-sw { bottom: -4px; left: -4px; cursor: nesw-resize; }
.ui-resizable-se {
  bottom: -4px;
  right: -4px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, var(--grip, var(--morph-start, #ff6347)) 50%);
}

.waaavesApp {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  color: #000000;
  font-size: 0.85rem;
}

.waaavesApp__canvasHost {
  flex: 1 1 auto;
  min-height: 0;
  margin: 8px;
  display: flex;
  background: #000000;
  border: 1px solid lime;
}

.waaavesApp__canvasHost canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.waaavesApp__status {
  min-height: 1.2em;
  font-weight: bold;
}

/* Monitor buttons: one row in the header; the ones that do not fit are moved to the bottom row by
   layoutMonitorBar(), which also shrinks everything with --bs (1 = full size) as the window narrows. */
.waaavesApp__bar,
.waaavesApp__barBottom {
  display: flex;
  align-items: center;
  gap: calc(6px * var(--bs, 1));
  font-size: calc(0.85rem * var(--bs, 1));
}

.waaavesApp__bar {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  padding: 4px 8px 4px 3.6rem; /* clears the round X */
  box-sizing: border-box;
  color: inherit; /* the header's inverted color */
  flex-wrap: nowrap;
}

.waaavesApp__barBottom {
  display: none;
  flex: 0 0 auto;
  flex-wrap: wrap;
  padding: 0 8px 8px;
  color: #000000;
}

.modalContainer--waaavesMonitor .waaavesApp__btn {
  flex: 0 0 auto;
  font-size: calc(0.95rem * var(--bs, 1));
  padding: calc(3px * var(--bs, 1)) calc(9px * var(--bs, 1));
  white-space: nowrap;
}

.waaavesApp__fps {
  flex: 0 0 auto;
  min-width: 4.5em;
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.waaavesApp__btn,
.waaavesApp__tab {
  font-family: "MingLiU", serif;
  font-style: italic;
  font-weight: bold;
  font-size: 0.95rem;
  padding: 3px 9px;
  border: 1px solid lime;
  background: var(--morph-start, #000000);
  color: var(--page-bg, #ffffff);
  cursor: pointer;
}

.waaavesApp__btn:hover,
.waaavesApp__tab:hover {
  box-shadow: 0px 0px 14px var(--morph-start, #ff6347);
}

.waaavesApp__tab.is-on {
  background: var(--page-bg, #ffffff);
  color: var(--morph-start, #000000);
}

/* ---- control panel ---- */
.waaavesApp__panel {
  flex: 1 1 44%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.waaavesApp__tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.waaavesApp__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid lime;
  background: rgba(255, 255, 255, 0.35);
  padding: 4px 8px 10px;
  touch-action: pan-y;
}

.wp__group {
  margin: 12px 0 4px;
  padding-bottom: 2px;
  border-bottom: 1px solid #000000;
  font-weight: bold;
  font-style: italic;
  font-family: "MingLiU", serif;
  font-size: 1rem;
}

.wp__note {
  margin: 8px 0;
  line-height: 1.35;
}

.wp__main {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
}

.wp__label {
  flex: 0 0 38%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wp__main input[type="range"],
.wp__sub input[type="range"] {
  flex: 1 1 auto;
  min-width: 0;
  accent-color: var(--page-bg, #000000);
}

.wp__select {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
}

.wp__val {
  flex: 0 0 3.8em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.wp__tilde {
  flex: 0 0 auto;
  width: 1.6em;
  border: 1px solid #000000;
  background: transparent;
  cursor: pointer;
  padding: 0;
  font-weight: bold;
}

.wp__tilde.is-on {
  background: #000000;
  color: #ffffff;
}

.wp__extra {
  margin: 0 0 4px 12px;
  padding-left: 8px;
  border-left: 2px solid #000000;
}

.wp__sub {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
}

.wp__sub > input[type="number"] {
  width: 5em;
}

.wp__sub > input[type="range"] {
  flex: 1 1 auto;
}

.waaavesApp__grabRow {
  margin: 8px 0;
  padding: 6px;
  border: 1px dashed #000000;
}

/* ---- screen grab frame: transparent inside, so the capture sees the page behind it ---- */
.waaavesGrab {
  position: fixed;
  z-index: 9000;
  box-sizing: border-box;
  pointer-events: none; /* modals can be dragged through the middle */
  outline: 2px dashed var(--morph-start, #ff6347); /* outline sits outside the box, so it is not captured */
  outline-offset: 0;
}

.waaavesGrab--ch2 {
  outline-style: dotted; /* channel 2's frame, so the two are easy to tell apart */
  outline-width: 3px;
}

.waaavesGrab__bar,
.waaavesGrab__resize {
  position: absolute;
  pointer-events: auto;
  background: var(--morph-start, #ff6347);
  color: var(--page-bg, #000000);
  font-family: "MingLiU", serif;
  font-style: italic;
  font-weight: bold;
  touch-action: none;
}

.waaavesGrab__bar {
  left: 0;
  bottom: calc(100% + 2px);
  padding: 2px 10px;
  font-size: 0.9rem;
  white-space: nowrap;
  cursor: move;
  user-select: none;
}

.waaavesGrab__size {
  margin-left: 8px;
  font-weight: normal;
}

.waaavesGrab__resize {
  left: calc(100% + 2px);
  top: calc(100% + 2px);
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
}

/* ---- phones and narrow windows: monitor on top, controls below (still draggable and resizable) ---- */
@media (max-width: 800px) {
  .modalContainer--waaavesMonitor {
    top: 1%;
    left: 1%;
    width: 98%;
    height: 38vh;
  }

  .modalContainer--waaavesApp {
    top: 41%;
    left: 1%;
    width: 98%;
    height: 58vh;
  }
}