/* Chord Lens — the stems section: a still of the Stems Mixer, and its claims.

   The mixer is drawn, not captured: HTML and CSS for the chrome, and one SVG
   per lane whose waveform src/stems.ts generates from a seeded description.
   Nothing plays; it is parked at 00:36. The section answers to its own
   width, so the tiers below are container queries, in panel.css's shape. */

#stems { overflow-x: clip; }

.stems { container-type: inline-size; }

.stems__kicker { color: var(--text-dim); }

.stems .section__head h2 em {
  font-style: normal;
  background: linear-gradient(100deg, var(--accent-hot), #ff7a5c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---- Stage: the mixer, and the claims beside it ------------------------- */

.stems__stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 2rem;
  align-items: stretch;
}

.stems__glow {
  position: absolute;
  inset: -12% 8% -18% -6%;
  background: radial-gradient(closest-side, rgb(255 42 69 / 0.15), transparent);
  pointer-events: none;
}

.stems__panel {
  position: relative;
  overflow: hidden;
  border-radius: 15px;
  outline: 1px solid var(--panel-edge);
  outline-offset: -1px;
  background: var(--panel-glass);
  box-shadow: 0 30px 72px rgb(0 0 0 / 0.65);
  font-size: 11.5px;
  line-height: 1.2;
}

/* Each stem's hue, for its chip, lane ground, waveform and fader. */
.stems__lane--vocals, .stems__pill--vocals { --lane: var(--stem-vocals); --vol: 72%; }
.stems__lane--drums, .stems__pill--drums { --lane: var(--stem-drums); --vol: 70%; }
.stems__lane--bass, .stems__pill--bass { --lane: var(--stem-bass); --vol: 73%; }
.stems__lane--piano, .stems__pill--piano { --lane: var(--stem-piano); --vol: 68%; }
.stems__lane--guitar, .stems__pill--guitar { --lane: var(--stem-guitar); --vol: 71%; }
.stems__lane--other, .stems__pill--other { --lane: var(--stem-other); --vol: 70%; }
.stems__lane--metronome { --lane: var(--stem-click); --vol: 72%; }

.stems__icon {
  flex: none;
  width: 12px;
  height: 12px;
  fill: none;
  stroke: var(--lane, currentColor);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- Header -------------------------------------------------------------- */

.stems__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 10px 14px;
  border-bottom: 1px solid #1b1d26;
}

.stems__title { color: #f4f6fa; font-size: 13px; font-weight: 700; letter-spacing: -0.2px; }
.stems__spacer { flex: 1; }

.stems__chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border-radius: 7px;
  outline: 1px solid #23252f;
  outline-offset: -1px;
  background: #14151c;
  white-space: nowrap;
}

.stems__k, .stems__m { color: #8a8a93; font-size: 11px; }
.stems__k { font-weight: 500; }
.stems__step b { color: #e9e9ec; font-weight: 700; }

.stems__section, .stems__hide { outline-color: #2c3040; color: #e9e9ec; font-weight: 600; }
.stems__section { gap: 26px; padding-inline: 10px; }
.stems__hide { padding-inline: 11px; }
.stems__caret { width: 9px; height: 9px; fill: none; stroke: #8a8a93; stroke-width: 2.5; stroke-linecap: round; }

.stems__avatar {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e0453f;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
}

/* ---- Body: extract, presets, the lanes, the transport --------------------- */

.stems__body { display: grid; gap: 11px; padding: 14px 16px 16px; }

.stems__extract, .stems__presets { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.stems__label {
  margin-inline-end: 4px;
  color: #6b7385;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.stems__pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 20px;
  outline: 1px solid #23252f;
  outline-offset: -1px;
  background: #14151c;
  color: #c6cbd6;
  font-weight: 500;
}

.stems__pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--lane); }
.stems__pill--all { padding-inline: 13px; outline: 0; background: #f4f6fa; color: #0b0c11; font-weight: 600; }

.stems__audio {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 5px 7px 5px 11px;
  border-radius: 20px;
  outline: 1px solid #1f6b4c;
  outline-offset: -1px;
  background: #0f2a20;
  color: #3ddc97;
  font-weight: 600;
}

.stems__audio i { position: relative; width: 26px; height: 15px; border-radius: 8px; background: #22c98a; }

.stems__audio i::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
}

.stems__btn {
  padding: 6px 12px;
  border-radius: 7px;
  outline: 1px solid #262935;
  outline-offset: -1px;
  background: #14151c;
  color: #c6cbd6;
  font-weight: 600;
}

/* ---- Timeline: ruler, lanes, loop strip, playhead ------------------------- */

/* Only the rail is fixed: the label card and the M/S column. The waveform
   takes the rest, and the playhead is placed along it by --at. */
.stems__timeline {
  --label: 196px;
  --rail: calc(var(--label) + 26px + 16px);
  --at: calc(36 / 275);
  position: relative;
  display: grid;
  gap: 4px;
}

.stems__ruler, .stems__lane {
  display: grid;
  grid-template-columns: var(--label) 26px minmax(0, 1fr);
  gap: 8px;
}

.stems__ruler { height: 15px; margin-bottom: 1px; }

/* Fifteen-second labels need a track wider than the shell gives; they show
   only where there is room, and the half minutes carry the ruler meanwhile. */
.stems__marks .is-quarter { visibility: hidden; }

@container (min-width: 1300px) {
  .stems__marks .is-quarter { visibility: visible; }
}
.stems__rail-gap { grid-column: 1 / 3; }

/* Eighteen fifteen-second tracks and the last five seconds: every label
   lands on its own time without a measured offset. */
.stems__marks {
  display: grid;
  grid-template-columns: repeat(18, 15fr) 5fr;
  color: #596070;
  font-size: 9.5px;
  font-weight: 500;
  white-space: nowrap;
}

.stems__lane { height: 50px; }

.stems__card {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  align-content: center;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  overflow: hidden;
  border-radius: 6px;
  outline: 1px solid #1d1f29;
  outline-offset: -1px;
  background: #101117;
}

.stems__name { overflow: hidden; color: var(--lane); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.stems__lane--metronome .stems__name, .stems__lane--metronome .stems__card .stems__icon { color: #c6cbd6; stroke: #c6cbd6; }

/* The fader: a track, the fill to --vol, and the knob at its end. */
.stems__vol {
  position: relative;
  grid-column: 1 / -1;
  height: 10px;
  background:
    linear-gradient(var(--lane) 0 0) 0 50% / var(--vol) 3px no-repeat,
    linear-gradient(#2a2c36 0 0) 0 50% / 100% 3px no-repeat;
}

.stems__vol::after {
  content: "";
  position: absolute;
  top: 0;
  left: calc(var(--vol) - 5px);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d8dbe2;
}

.stems__ms { display: grid; grid-template-rows: 1fr 1fr; gap: 4px; }

.stems__ms > span {
  display: grid;
  place-items: center;
  border-radius: 5px;
  outline: 1px solid #262935;
  outline-offset: -1px;
  background: #14151c;
  color: #8a8a93;
  font-size: 9.5px;
  font-weight: 700;
}

/* The one lit button in the panel: the metronome is on. */
.stems__ms > .is-on { outline-color: #ff2a45; background: #3a0e18; color: #ff6b80; }

.stems__wave {
  position: relative;
  overflow: hidden;
  border-radius: 5px;
  background: color-mix(in srgb, var(--lane) 15%, var(--ink-900));
}

.stems__wave svg { display: block; width: 100%; max-width: none; height: 50px; }

.stems__bars { fill: var(--lane); }

.stems__silence {
  fill: none;
  stroke: var(--lane);
  stroke-width: 1.2;
  stroke-dasharray: 2 4;
  opacity: 0.38;
  vector-effect: non-scaling-stroke;
}

.stems__lane--metronome .stems__wave { background: #111219; }
.stems__ticks { fill: var(--stem-click); opacity: 0.55; }

.stems__rates { position: absolute; top: 14px; left: 8px; display: flex; gap: 4px; }

.stems__rates > span {
  padding: 3px 6px;
  border-radius: 4px;
  outline: 1px solid #22242e;
  outline-offset: -1px;
  background: #16171f;
  color: #7c8496;
  font-size: 9.5px;
  font-weight: 600;
}

.stems__rates > .is-on { outline-color: #3d404e; background: #2b2d38; color: #e4e7ee; }

.stems__bpm {
  position: absolute;
  top: 11px;
  right: 10px;
  color: #6e7789;
  font-size: 9px;
  font-weight: 600;
  line-height: 1.15;
  text-align: right;
}

/* Loop A-B: the whole song in miniature, the looped bars in amber. */
.stems__lane--loop { height: 44px; }
.stems__lane--loop .stems__card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; outline: 0; background: none; }
.stems__loop-title { color: #9aa3b5; font-size: 10px; font-weight: 700; letter-spacing: 1.1px; text-transform: uppercase; white-space: nowrap; }
.stems__loop-state { color: #5e6576; font-size: 10px; white-space: nowrap; }
.stems__lane--loop .stems__ms { grid-template-rows: 26px; align-content: center; }
.stems__lane--loop .stems__icon { width: 13px; height: 13px; stroke: #8a8a93; }
.stems__lane--loop .stems__wave { background: #0e0f14; }
.stems__lane--loop .stems__wave svg { height: 44px; }
.stems__region { fill: rgb(255 166 43 / 0.1); }
.stems__mix { fill: #3a3d4a; }
.stems__mix-loop { fill: var(--stem-drums); }

.stems__overview-marks {
  position: absolute;
  inset: auto 0 2px 7px;
  display: grid;
  grid-template-columns: repeat(4, 60fr) 35fr;
  color: #4a505f;
  font-size: 8.5px;
  font-weight: 500;
}

/* One line across every lane to the metronome, stopping short of the loop
   strip, with its dot on the ruler. */
.stems__playhead {
  position: absolute;
  top: 5px;
  bottom: 48px;
  left: calc(var(--rail) + (100% - var(--rail)) * var(--at));
  width: 1.6px;
  translate: -50% 0;
  background: var(--accent-hot);
  pointer-events: none;
}

.stems__playhead::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  translate: -50% 0;
  background: var(--accent-hot);
}

/* ---- Transport ------------------------------------------------------------ */

.stems__transport { display: flex; align-items: center; gap: 14px; padding-top: 6px; }

.stems__stop, .stems__pause { display: grid; place-items: center; border-radius: 50%; }
.stems__stop { width: 30px; height: 30px; outline: 1px solid #2a2d3a; outline-offset: -1px; background: #14151c; }
.stems__stop i { width: 9px; height: 9px; border-radius: 1.5px; background: #c6cbd6; }
.stems__pause { grid-auto-flow: column; justify-content: center; gap: 4px; width: 42px; height: 42px; background: #f4f6fa; }
.stems__pause i { width: 4px; height: 15px; border-radius: 1.5px; background: #0b0c11; }
.stems__now { color: #f4f6fa; font-size: 15px; font-weight: 700; letter-spacing: 0.3px; }
.stems__total { margin-inline-start: -6px; color: #5e6576; font-size: 13.5px; letter-spacing: 0.3px; }

/* ---- Claims ----------------------------------------------------------------- */

.stems__claims {
  position: relative;
  display: grid;
  align-content: space-between;
  gap: 26px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stems__claim { display: grid; gap: 12px; padding-top: 18px; border-top: 1px solid var(--line); }

.stems__claim-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--accent-hot);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stems__claim h3 { font-size: 1rem; font-weight: 600; letter-spacing: -0.2px; }
.stems__claim p { color: var(--text-faint); font-size: 0.84rem; line-height: 1.55; }

/* ---- The section at its own width -------------------------------------------- */

/* Narrower: the claims move under the mixer, side by side while they fit. */
@container (max-width: 959px) {
  .stems__stage { grid-template-columns: minmax(0, 1fr); }
  .stems__claims { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); align-content: start; gap: 1.5rem; }
}

/* The label card drops its fader. */
@container (max-width: 719px) {
  .stems__vol { display: none; }
}

/* The card is its coloured icon alone; the ruler keeps the minutes. The
   waveform never goes: it is the whole point of the picture. */
@container (max-width: 559px) {
  .stems__timeline { --label: 44px; }
  .stems__card { grid-template-columns: 12px; justify-content: center; padding-inline: 0; }
  .stems__name, .stems__lane--loop .stems__card > span { display: none; }
  .stems__marks .is-half { visibility: hidden; }
}
