/* The Voice dock: voice to notes (voice.js).

   A flow of three steps — 1 Take, 2 Shape, 3 Add to song — laid out by the
   room the dock gives it (container queries, not the window: the side
   panels and the on-screen piano decide the dock's size):
   - wide, or short (a phone on its side, the desktop's default dock): the
     three steps side by side, each scrolling on its own;
   - medium: Take on the left, Shape beside it, Add to song under Shape;
   - narrow (a phone): one column, in order.
   The panel scrolls whenever its content is taller than the dock (a
   container query styles only what is inside the container). */

.voice {
  height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  container-type: size;
  container-name: voice;
}
.voice-flow {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 240px;
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "take shape add";
  height: 100%;
  min-height: 0;
}
.voice-take {
  grid-area: take;
}
.voice-shape {
  grid-area: shape;
}
.voice-add {
  grid-area: add;
}

/* ---------------------------------------------------------------- steps */

.voice-step {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  padding: 12px 12px 14px;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  transition: opacity 0.2s;
}
.voice-step:last-child {
  border-right: none;
}
.voice-take {
  background: linear-gradient(180deg, #17141b, #0f0d12);
}
.voice-step.waiting {
  opacity: 0.55;
}
.voice-step-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
}
.voice-step-num {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 700 11px/1 var(--sans);
  color: #231804;
  background: var(--metal);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}
.voice-step.waiting .voice-step-num {
  background: var(--ob-4);
  color: var(--muted);
  box-shadow: none;
}
.voice-step-titles {
  flex: 1;
  min-width: 120px;
}
.voice-step-title {
  font: italic 600 17px/1.1 var(--serif);
  color: var(--gold-hi);
}
.voice-step-sub {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
}
.voice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ---------------------------------------------------------------- 1 take */

.voice-take .seg {
  align-self: stretch;
}
.voice-take .seg .btn {
  flex: 1;
}
.voice-rec {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px;
}
.btn.voice-recbtn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  color: var(--rose);
}
.btn.voice-recbtn .glyph {
  width: 22px;
  height: 22px;
}
.btn.voice-recbtn.armed {
  color: #fff;
  background: radial-gradient(circle at 50% 40%, #e2717f, #8e2336);
  border-color: rgba(255, 170, 180, 0.7);
  box-shadow: 0 0 22px rgba(224, 112, 126, 0.6);
  animation: pulse 1.2s ease-in-out infinite;
}
.voice-time {
  font: 600 20px/1 var(--serif);
  font-style: italic;
  color: var(--champagne);
}

/* ---------------------------------------------------------------- fields */

.voice-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.voice-label {
  font: 600 9.5px/1 var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.voice-field .select {
  max-width: 100%;
}

/* ---------------------------------------------------------------- 2 shape */

.voice-shape {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 220px auto auto;
  grid-template-areas: "head" "view" "crop" "set";
  align-content: start;
  container-type: inline-size;
  container-name: shape;
}
.voice-shape > .voice-step-head {
  grid-area: head;
}
.voice-view {
  grid-area: view;
  min-height: 0;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #0f0d12, #09080b);
  box-shadow: inset 0 1px 6px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.voice-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.voice-canvas.drums {
  cursor: pointer;
}
.voice-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  text-align: center;
  color: var(--muted);
}
.voice-empty .glyph {
  width: 34px;
  height: 34px;
  color: var(--gold);
  opacity: 0.7;
}
.voice-empty-title {
  font: italic 600 22px/1.1 var(--serif);
  color: var(--champagne);
}
.voice-empty-doc {
  max-width: 440px;
  font: 14px/1.35 var(--serif);
}
/* The crop: the whole take between two handles, dragged in from either end. */
.voice-crop {
  grid-area: crop;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.voice-crop.off {
  opacity: 0.45;
}
.voice-crop-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-height: 24px;
}
.voice-crop-span {
  flex: 1;
  font: 500 10.5px/1.2 var(--mono);
  color: var(--champagne);
}
.voice-crop-strip {
  position: relative;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #0f0d12, #09080b);
  overflow: hidden;
  cursor: ew-resize;
  touch-action: none;
}
.voice-settings {
  grid-area: set;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 10px;
  min-width: 0;
  min-height: 0;
}
.voice-group {
  flex: 1 1 220px;
  padding: 9px 10px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.16);
}
.voice-group-title {
  font: italic 600 14px/1 var(--serif);
  color: var(--gold);
  margin: 0 0 9px 2px;
  letter-spacing: 0.04em;
}
.voice-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 12px;
}
.voice-row .param {
  width: 62px;
}
.voice-row .param .knob {
  --size: 32px;
}

/* A wide Shape step: the preview beside the settings, both filling it. */
@container shape (min-width: 560px) {
  .voice-shape {
    grid-template-columns: minmax(0, 1fr) 270px;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "head head"
      "view set"
      "crop set";
    align-content: stretch;
  }
  .voice-settings {
    flex-direction: column;
    flex-wrap: nowrap;
    overflow-y: auto;
  }
  .voice-group {
    flex: none;
  }
}

/* ---------------------------------------------------------------- 3 add */

.voice-summary {
  font: 500 11px/1.3 var(--mono);
  color: var(--champagne);
}
.voice-target {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}
.voice-target .voice-field {
  flex: 1 1 140px;
}
.btn.voice-addbtn {
  height: 36px;
}

/* ---------------------------------------------------------------- medium */

@container voice (max-width: 999px) and (min-height: 430px) {
  .voice-flow {
    grid-template-columns: 220px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas:
      "take shape"
      "take add";
  }
  .voice-shape {
    border-right: none;
  }
  .voice-add {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    border-top: 1px solid var(--line);
    overflow: visible;
  }
  .voice-add > .voice-step-head {
    flex: 1 1 100%;
  }
  .voice-add .voice-summary {
    flex: 1 1 160px;
    align-self: center;
  }
  .voice-add .voice-target {
    flex: 2 1 260px;
  }
}

/* ---------------------------------------------------------------- narrow, short */

@container voice (max-width: 999px) and (min-width: 640px) and (max-height: 429px) {
  .voice-flow {
    grid-template-columns: 190px minmax(0, 1fr) 200px;
  }
  .voice-shape {
    grid-template-rows: auto 150px auto auto;
  }
}

@container voice (max-width: 639px) {
  .voice-flow {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    grid-template-areas: "take" "shape" "add";
    height: auto;
  }
  .voice-step {
    overflow: visible;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .voice-take {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .voice-take > * {
    flex: 1 1 100%;
  }
  .voice-take .voice-field {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .voice-take .voice-field .voice-label {
    width: 72px;
    flex: none;
  }
  .voice-take .voice-field .select {
    flex: 1;
    min-width: 0;
  }
  .voice-add {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    border-top: none;
  }
  .voice-add > .voice-step-head,
  .voice-add .voice-summary,
  .voice-add .voice-target {
    flex: none;
  }
}
