/* App-local styles for Clients.
 *
 * The app is built from @ecosystem/design components; what lives here is the
 * page header with an action on it, the pipeline board, and the deal card —
 * three shapes no existing component covers.
 *
 * Per packages/design/README.md this file may consume semantic tokens but must
 * not redefine any .ds-* component, and must not reach for a primitive ramp or
 * a raw value.
 */

/* This app's accent lives in @ecosystem/design — css/app-themes.css, keyed on
   the `data-app` slug the shell puts on <body>, along with every other app's.
   That is where a per-app accent is repointed now; see the header of that file
   for why they are derived from the logos rather than chosen. */

/* --- A page heading with one action on the end ---------------------------- */

.cl-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--ds-space-4);
  flex-wrap: wrap;
}

/* --- The pipeline --------------------------------------------------------- */

/* A column per stage, and the number of stages is a workspace's own business —
   they are rows, and a workspace may have three or nine. So the track is sized
   rather than counted, and the board scrolls sideways inside itself rather
   than making the page scroll. */
.cl-board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(15rem, 1fr);
  gap: var(--ds-space-4);
  overflow-x: auto;
  padding-bottom: var(--ds-space-3);
  align-items: start;
}

.cl-column {
  background: var(--ds-surface-sunken);
  border-radius: var(--ds-radius-lg);
  padding: var(--ds-space-3);
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-3);
  min-width: 0;
}

.cl-column__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--ds-space-2);
  font-weight: 600;
  min-width: 0;
}

.cl-deal {
  background: var(--ds-surface);
  border: var(--ds-border-width) solid var(--ds-border);
  border-radius: var(--ds-radius-md);
  padding: var(--ds-space-3);
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-2);
  min-width: 0;
}

/* The stage select sits inside a card that is already narrow, so it must be
   allowed to shrink rather than forcing the column wider. */
.cl-deal .ds-input {
  min-width: 0;
  font-size: var(--ds-text-sm);
}

/* --- Dragging a deal ------------------------------------------------------ */

/* Two states, and both are feedback rather than decoration: a card you have
   picked up should look picked up, and the column you are over should say it
   will accept the drop. Without the second, a drag that lands nowhere is
   indistinguishable from a drag that worked.

   The `<select>` on each card stays as the accessible path, so nothing here is
   the only way to move a deal. */
.cl-deal {
  cursor: grab;
}

.cl-deal.is-dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.cl-column.is-over {
  outline: var(--ds-border-width) dashed var(--ds-accent);
  outline-offset: calc(var(--ds-space-1) * -1);
}

/* The header now carries the stage's own controls, so it is a row of items
   rather than a name and a count at opposite ends. */
.cl-column__head {
  align-items: center;
}

.cl-column__head .ds-truncate {
  flex: 1 1 auto;
}

/* A deal somebody followed a link to, from its own entry on a client's
   timeline. Marked rather than opened: the board already shows everything a
   detail view would, so the useful thing is to say which card was meant. */
.cl-deal.is-highlighted {
  outline: var(--ds-border-width) solid var(--ds-accent);
  outline-offset: var(--ds-space-1);
}

/* --- The summary's stat rows ----------------------------------------------
   A row of figures that wraps rather than scrolls: there are three or four of
   them, they are short, and a horizontal scroller for four numbers would be
   worse than a second line. */
.cl-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ds-space-6);
}

.cl-stats > div {
  min-width: 8rem;
}

/* --- A submission, read as the form it was ---------------------------------
   A definition list rather than a table: there are five or six answers, the
   labels are the workspace's own words and may be long, and a two-column grid
   that collapses to one on a narrow screen reads better than a table that
   scrolls. */
.cl-answers {
  display: grid;
  grid-template-columns: minmax(6rem, 12rem) 1fr;
  gap: var(--ds-space-2) var(--ds-space-4);
  margin: 0;
}

.cl-answers dd {
  margin: 0;
  white-space: pre-wrap;
}

@media (max-width: 40rem) {
  .cl-answers { grid-template-columns: 1fr; }
  .cl-answers dd { margin-bottom: var(--ds-space-2); }
}
