/* Studio's step 4, the batch (components/batch_step.cljs,
   docs/design-system.md, The batch): a framed table of the carousels; each
   idea and template cell is a button that opens its list in a popover
   under it. */

.batch-step__note {
  margin: 0 0 var(--space-3);
  font-size: var(--text-note);
  color: var(--color-text-muted);
}

/* "To promote a product, add it on the Product page." under the table. */
.batch-step__note--under {
  margin: var(--space-3) 0 0;
}

/* The warning under the table: status text, never a status fill. */
.batch-step__warning {
  margin: var(--space-3) 0 0;
  font-size: var(--text-note);
  color: var(--color-warning);
}

/* White on the white card: the table takes the soft line. The tooltips of
   the Promote column reach out of it, so it does not clip. */
.batch-table {
  overflow: visible;
  border: var(--border-width) solid var(--color-border-subtle);
}

/* The columns keep their widths whatever a cell shows: a chosen hook
   never moves the Template column. */
.batch-table .table__table {
  table-layout: fixed;
}

.batch-table .table__head:nth-child(2) {
  width: 32%;
}

.batch-table .table__head:nth-child(3) {
  width: 20%;
}

.batch-table .table__head,
.batch-table .table__cell {
  padding: var(--space-2) var(--space-3);
  white-space: normal;
  vertical-align: middle;
}

/* The widths include the cell padding (border-box): the number column
   fits "10", the draw again column fits its toolbar button. */
.batch-table .table__head:first-child,
.batch-table .table__cell:first-child {
  width: 48px;
}

/* Draw again acts on the whole row: its column stands apart from the
   cells behind a soft line, the button centered with 4px to the column's
   edges. */
.batch-table .table__head:last-child,
.batch-table .table__cell:last-child {
  width: calc(var(--control-height) + 2 * var(--space-1));
  padding-inline: var(--space-1);
  text-align: center;
  border-left: var(--border-width) solid var(--color-border-subtle);
}

/* The Promote column, with a product: its head "Promote" over the
   product's name with the info icon closing the line, both at the left
   like the other heads, the checkbox at the left under them. The
   checkbox's label shows only in the stacked row of a phone. */
.batch-table--promote .table__head:nth-child(5),
.batch-table--promote .table__cell:nth-child(5) {
  width: 128px;
}

.batch-table--promote .table__head:nth-child(5) {
  white-space: normal;
}

.batch-step__promote-head {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  max-width: 100%;
}

.batch-step__promote-product {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  max-width: 100%;
}

.batch-step__promote-info {
  display: inline-flex;
  cursor: help;
}

.batch-step__promote-info:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
  border-radius: 50%;
}

.batch-step__promote-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-step__promote-label {
  display: none;
}

/* A cell: plain at rest, the control fill and the chevron under the
   cursor, the ink border while its list is open. It reaches 8px past the
   column on both sides so its text stays on the line of the header. */
.batch-cell {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  box-sizing: content-box;
  width: 100%;
  min-height: 44px;
  margin: 0 calc(-1 * var(--space-2));
  padding: var(--space-1) var(--space-2);
  font: inherit;
  text-align: left;
  color: var(--color-text);
  background: transparent;
  border: var(--border-width) solid transparent;
  border-radius: var(--border-radius);
  transition: background var(--duration-fast) var(--ease-default),
              border-color var(--duration-fast) var(--ease-default);
}

button.batch-cell {
  cursor: pointer;
}

button.batch-cell:hover {
  background: var(--color-bg-control);
}

button.batch-cell:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

.batch-cell--open {
  border-color: var(--color-text);
}

.batch-cell__text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.batch-cell__main {
  font-size: var(--text-body);
  line-height: var(--leading-snug);
}

.batch-cell--muted .batch-cell__main,
.batch-cell__sub {
  color: var(--color-text-muted);
}

.batch-cell__sub {
  font-size: var(--text-note);
}

/* While the pair's hooks are written: "Generating hooks…" pulsing with
   the frames of the hook list (css/ui/hook_list.css). */
.batch-cell--writing .batch-cell__main {
  animation: hooks-writing-pulse var(--duration-skeleton-pulse) var(--ease-default) infinite;
}

@media (prefers-reduced-motion: reduce) {
  .batch-cell--writing .batch-cell__main {
    animation: none;
  }
}

.batch-cell__thumb {
  flex: none;
  line-height: 0;
}

.batch-cell__chevron {
  flex: none;
  color: var(--color-text-muted);
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-default);
}

button.batch-cell:hover .batch-cell__chevron,
.batch-cell--open .batch-cell__chevron {
  opacity: 1;
}

/* The template cell's popover is wider: the templates at the left, the
   marked template's first slide and description at the right. */
.popover__panel.template-panel-popover {
  width: min(680px, calc(100vw - var(--space-8)));
}

.template-panel {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: var(--space-6);
  align-items: start;
}

/* The marked row, by a hover or the arrow keys, takes the row's hover
   border; the row's own template keeps its chosen border. */
.template-panel__row--marked .choice-row:not(.choice-row--chosen) {
  border-color: var(--color-text-muted);
}

.template-panel__detail {
  display: flex;
  gap: var(--space-5);
  align-items: flex-start;
}

/* A template's slide is often white on the white panel; a line marks its
   edge. */
.template-panel__slide {
  flex: none;
  line-height: 0;
  border-radius: var(--radius-media);
  box-shadow: 0 0 0 var(--border-width) var(--color-border);
}

.template-panel__text {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.template-panel__text p {
  margin: 0;
}

.template-panel__name {
  font-size: var(--text-body);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
}

.template-panel__count {
  font-size: var(--text-note);
  color: var(--color-text-muted);
}

.template-panel__text .template-panel__description {
  margin-top: var(--space-2);
}

.template-panel__description {
  font-size: var(--text-body);
  line-height: var(--leading-normal);
  color: var(--color-text-muted);
}

.template-panel__description--none {
  font-size: var(--text-note);
}

.template-panel__use {
  align-self: flex-start;
  margin-top: var(--space-3);
}

.batch-step__group {
  margin: var(--space-2) 0 var(--space-1);
  font-size: var(--text-label);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* Phone: the head goes and a row becomes a block, the number at the top
   left, draw again at the top right, the idea, the template, the hook and
   the Promote checkbox one under another. */
@media (max-width: 860px) {
  .batch-table thead {
    display: none;
  }

  .batch-table .table__table,
  .batch-table tbody {
    display: block;
  }

  .batch-table .table__row {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) 40px;
    grid-template-areas:
      "number idea again"
      ". template ."
      ". hook .";
    padding: var(--space-2) 0;
    border-bottom: var(--border-width) solid var(--color-border-subtle);
  }

  .batch-table .table__row:last-child {
    border-bottom: 0;
  }

  .batch-table .table__cell {
    display: block;
    width: auto;
    padding: 0 var(--space-2);
    border: 0;
  }

  .batch-table .table__cell:first-child {
    grid-area: number;
    width: auto;
    padding-top: var(--space-3);
  }

  .batch-table .table__cell:nth-child(2) {
    grid-area: idea;
  }

  .batch-table .table__cell:nth-child(3) {
    grid-area: template;
  }

  .batch-table .table__cell:nth-child(4) {
    grid-area: hook;
  }

  .batch-table .table__cell:last-child {
    grid-area: again;
    width: auto;
    padding-top: var(--space-1);
    border-left: 0;
  }

  /* With a product the Promote checkbox stands under the hook, its label
     beside it. */
  .batch-table--promote .table__row {
    grid-template-areas:
      "number idea again"
      ". template ."
      ". hook ."
      ". promote .";
  }

  .batch-table--promote .table__cell:nth-child(5) {
    grid-area: promote;
    width: auto;
    padding-top: var(--space-2);
  }

  .batch-step__promote-label {
    display: inline;
  }

  /* The template panel stacks: the list, then the marked template. */
  .template-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .batch-cell {
    box-sizing: border-box;
    min-height: 36px;
    margin: 0;
  }
}
