/*
 * web/landing/shells/TimelineDesk.css - audio on one time axis (web/landing/shells/TimelineDesk.js
 * documents the markup). A section imports it at the top of its sheet:
 *   @import url('/web/landing/shells/TimelineDesk.css');
 *
 * Generic only: the source line, the transcript field with its counter, the lanes on one
 * axis with the playhead across them, the scrubber and its inspector, the download tray.
 * Mono for every number and every wire name, sans for the controls. Tokens are
 * web/landing.css's.
 *
 * Narrow (the DemoFrame's container under 480 px, or the desk's own when it is not in a
 * frame): the dense lanes give way to the waveform, the scrubber and the inspector.
 */

/* ── The input side: the source and the transcript ─────────────────────── */

.timeline-desk-source {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.timeline-desk-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.timeline-desk-choices button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.timeline-desk-choices button[hidden] { display: none; }
.timeline-desk-choices button:disabled { opacity: .55; cursor: default; }
.timeline-desk-choices button:not(:disabled):hover { border-color: var(--muted); }

/* The chosen source reads as selected: a lit dot, as the frame's switches have. */
.timeline-desk-choices button::before {
  content: "";
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--muted);
}

.timeline-desk-choices button[aria-pressed="true"] { border-color: var(--accent); }
.timeline-desk-choices button[aria-pressed="true"]::before { background: var(--accent); box-shadow: none; }

.timeline-desk-name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  margin: 0;
  min-width: 0;
  font-size: 13px;
}

.timeline-desk-name [data-desk-name] {
  min-width: 0;
  overflow-wrap: anywhere;
}

.timeline-desk-name [data-desk-duration],
.timeline-desk-name [data-desk-cap] {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.timeline-desk-name [data-desk-cap] { color: var(--muted); margin-left: -6px; }

.timeline-desk-note {
  margin: 0;
  font-size: 13px;
  color: var(--danger);
}

.timeline-desk-note[hidden] { display: none; }

.timeline-desk-transcript {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  min-width: 0;
}

.timeline-desk-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.timeline-desk-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.timeline-desk-count[data-full] { color: var(--danger); }

.timeline-desk-transcript textarea {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 74px;
  resize: vertical;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ink);
  color: var(--text);
  font: 14px/1.5 var(--sans);
}

.timeline-desk-transcript textarea:disabled { opacity: .7; }
.timeline-desk-transcript textarea::placeholder { color: var(--muted); }

/* ── The timeline ──────────────────────────────────────────────────────── */

.timeline-desk {
  --desk-label-w: 76px;
  --desk-gap: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.timeline-desk-lanes {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0 2px;
  touch-action: pan-y;
  cursor: crosshair;
  user-select: none;
}

.timeline-desk-axis {
  position: relative;
  height: 16px;
  margin-left: calc(var(--desk-label-w) + var(--desk-gap));
  border-bottom: 1px solid var(--line);
}

.timeline-desk-tick {
  position: absolute;
  bottom: 2px;
  transform: translateX(-1px);
  padding-left: 4px;
  border-left: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
  color: var(--muted);
  white-space: nowrap;
}

.timeline-desk-lane {
  display: flex;
  align-items: stretch;
  gap: var(--desk-gap);
  min-width: 0;
}

.timeline-desk-lane-label {
  flex: none;
  width: var(--desk-label-w);
  align-self: center;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.25;
  letter-spacing: .04em;
  color: var(--muted);
}

.timeline-desk-track {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 30px;
  border-radius: 6px;
  background: var(--ink);
  overflow: hidden;
}

/* The waveform: dim, and lit up to what has been fed. */
.timeline-desk-lane[data-kind="wave"] .timeline-desk-track { height: 56px; }

.timeline-desk-wave {
  position: absolute;
  inset: 0;
  color: color-mix(in srgb, var(--muted) 55%, transparent);
  overflow: hidden;
}

.timeline-desk-wave-lit {
  right: auto;
  width: 0;
  color: var(--accent);
}

.timeline-desk-wave canvas {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
}

/* A lane of blocks: one per cue, word or caption. */
.timeline-desk-block {
  position: absolute;
  top: 3px;
  bottom: 3px;
  min-width: 1px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  border-left: 1px solid var(--ink);
  background: color-mix(in srgb, var(--accent) 22%, var(--panel-2));
}

.timeline-desk-block i {
  font: normal 10px/1 var(--mono);
  padding-bottom: 3px;
  color: var(--text);
  white-space: nowrap;
}

/* A 'shapes' lane: each mouth cue a bar as tall as the mouth is open. */
.timeline-desk-lane[data-kind="shapes"] .timeline-desk-track { height: 46px; }

.timeline-desk-lane[data-kind="shapes"] .timeline-desk-block {
  top: auto;
  bottom: 0;
  height: calc(14px + (100% - 16px) * var(--open, .3));
  border-radius: 3px 3px 0 0;
  background: color-mix(in srgb, var(--accent) calc(25% + 60% * var(--open, .3)), var(--panel-2));
}

.timeline-desk-lane[data-kind="shapes"] .timeline-desk-block i { color: var(--accent-ink); font-weight: 600; }
.timeline-desk-lane[data-kind="shapes"] .timeline-desk-block[data-value="X"] i { color: var(--muted); }

/* A lane of events as they land: a span (a slice and its cues) in the lower part, a tick
   (an open) across the lane with its label above the spans. */
.timeline-desk-lane[data-kind="events"] .timeline-desk-track { height: 38px; }

.timeline-desk-event {
  position: absolute;
  top: 15px;
  bottom: 3px;
  display: flex;
  align-items: center;
  min-width: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.timeline-desk-event[data-tick] {
  top: 2px;
  width: 2px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: var(--text);
}

.timeline-desk-event i {
  padding: 0 5px;
  font: normal 10px/1 var(--mono);
  color: var(--text);
  white-space: nowrap;
}

.timeline-desk-event[data-tick] i {
  position: absolute;
  left: 4px;
  top: 0;
  line-height: 11px;
  font-size: 9.5px;
  padding: 0;
  color: var(--muted);
}

/* Something that just landed: a short glow, never a movement. */
.timeline-desk-block[data-new],
.timeline-desk-event[data-new] { animation: timeline-desk-land .6s ease-out; }

@keyframes timeline-desk-land {
  from { box-shadow: 0 0 0 2px var(--accent); }
  to { box-shadow: 0 0 0 0 transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .timeline-desk-block[data-new],
  .timeline-desk-event[data-new] { animation: none; }
}

/* The playhead: one line across every track, placed by --desk-t (0 to 1). */
.timeline-desk-playhead {
  position: absolute;
  top: 20px;
  bottom: 0;
  left: calc(var(--desk-label-w) + var(--desk-gap) + var(--desk-t, 0) * (100% - var(--desk-label-w) - var(--desk-gap)));
  width: 2px;
  margin-left: -1px;
  background: var(--text);
  pointer-events: none;
  opacity: .35;
}

.timeline-desk[data-transport="playing"] .timeline-desk-playhead { opacity: 1; background: var(--accent); }
.timeline-desk[data-transport="held"] .timeline-desk-playhead { opacity: 1; background: repeating-linear-gradient(var(--accent) 0 4px, transparent 4px 7px); }
.timeline-desk[data-transport="paused"] .timeline-desk-playhead { opacity: .8; }

/* ── The scrubber and its inspector ────────────────────────────────────── */

.timeline-desk-scrub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  min-width: 0;
}

.timeline-desk-scrub input[type="range"] {
  flex: 1 1 200px;
  min-width: 0;
  margin: 0;
  accent-color: var(--accent);
}

.timeline-desk-inspector {
  flex: none;
  min-width: 15ch;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* ── Downloads ─────────────────────────────────────────────────────────── */

.timeline-desk-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.timeline-desk-downloads[hidden] { display: none; }

.timeline-desk-download {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  min-height: 34px;
  padding: 7px 13px;
  border: 1px dashed var(--muted);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.timeline-desk-download:hover { border-style: solid; border-color: var(--accent); }

.timeline-desk-download-name {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

/* ── Narrow: the scrubber and the inspector instead of dense lanes ─────── */

@container demo-frame (max-width: 479px) {
  .timeline-desk { --desk-label-w: 0px; --desk-gap: 0px; }
  .timeline-desk-lane[data-dense],
  .timeline-desk-lane-label { display: none; }
  .timeline-desk-axis { display: none; }
  .timeline-desk-playhead { top: 4px; }
  .timeline-desk-inspector { flex-basis: 100%; }
}
