/*
 * Beat batch-chapters: Briefing, a production board for a narrated series
 * (web/landing/sections/batch-chapters.html). Linked in the page head by lib/landing.ts
 * while the beat is enabled; the shells' sheets it builds on are linked by the page
 * itself, once each and before every section sheet. Every class here starts with the
 * beat id, and every rule is scoped by [data-beat].
 *
 * Layout: the copy above, the board at the page's width. On the board the job's row (the
 * endpoint, the job id, its state and timer) runs across the top, the two chapter cards
 * stand side by side under it, and the skips and the batch tray close it. Narrow (the
 * frame under 640 px): the cards stack, nothing scrolls sideways. A chapter's name is the
 * serif; states, times, ids and file names are mono; the scene's text is the sans.
 */

.use-case[data-beat="batch-chapters"] {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
}

@media (min-width: 1024px) {
  .use-case[data-beat="batch-chapters"] .use-case-copy {
    display: grid;
    grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
    grid-template-areas: "eyebrow eyebrow" "title body";
    column-gap: clamp(28px, 4vw, 56px);
    align-items: end;
  }
  .use-case[data-beat="batch-chapters"] .use-case-eyebrow { grid-area: eyebrow; }
  .use-case[data-beat="batch-chapters"] .use-case-title { grid-area: title; margin: 0; }
  .use-case[data-beat="batch-chapters"] .use-case-body { grid-area: body; padding-bottom: 6px; }
}

/* ── The board ─────────────────────────────────────────────────────────── */

[data-beat="batch-chapters"] .demo-frame-body {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "main";
}

[data-beat="batch-chapters"] .batch-chapters-board { gap: 14px; }

[data-beat="batch-chapters"] .batch-chapters-stages {
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

@container demo-frame (min-width: 640px) {
  [data-beat="batch-chapters"] .batch-chapters-stages {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }
  [data-beat="batch-chapters"] .batch-chapters-job { grid-column: 1 / -1; }
}

/* A board, not a rail: the cards carry their own edges. */
[data-beat="batch-chapters"] .batch-chapters-stages > .progress-ledger-stage::before { content: none; }

/* ── The job's row: the endpoint, the job id, its state and timer ─────── */

[data-beat="batch-chapters"] .batch-chapters-job {
  grid-template-columns: var(--ledger-mark) auto minmax(0, 1fr) auto auto;
  grid-template-areas: "mark label line state elapsed";
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--ink);
}

[data-beat="batch-chapters"] .batch-chapters-endpoint {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 400;
  white-space: nowrap;
}

[data-beat="batch-chapters"] .batch-chapters-job .progress-ledger-line { font-size: 12px; }

@container demo-frame (max-width: 479px) {
  [data-beat="batch-chapters"] .batch-chapters-job {
    grid-template-columns: var(--ledger-mark) minmax(0, 1fr) auto auto;
    grid-template-areas: "mark label state elapsed" ". line line line";
  }
}

/* ── A chapter's card ──────────────────────────────────────────────────── */

[data-beat="batch-chapters"] .batch-chapters-card {
  grid-template-columns: var(--ledger-mark) minmax(0, 1fr) auto auto;
  grid-template-areas:
    "mark label state elapsed"
    "scene scene scene scene"
    "line line line line"
    "snapshot snapshot snapshot snapshot"
    "artifacts artifacts artifacts artifacts";
  row-gap: 10px;
  align-content: start;
  padding: 14px 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  transition: border-color .15s;
}

[data-beat="batch-chapters"] .batch-chapters-card[data-state="running"] { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }

[data-beat="batch-chapters"] .batch-chapters-chapter {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 20px;
  line-height: 1.2;
}

[data-beat="batch-chapters"] .batch-chapters-card:not([data-state]) .batch-chapters-chapter { color: var(--text); }

[data-beat="batch-chapters"] .batch-chapters-scene {
  grid-area: scene;
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

[data-beat="batch-chapters"] .batch-chapters-scene-id {
  margin-right: 6px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  vertical-align: 1px;
}

[data-beat="batch-chapters"] .batch-chapters-text { color: var(--text); }

/* The clip: the circle the script names, at a size a card can hold. Its place is kept
   from the start (a dashed circle where it will land), so a card never grows or shrinks
   as the job moves: the clip and the placeholder share one cell. */
[data-beat="batch-chapters"] .batch-chapters-clipbox {
  grid-area: snapshot;
  display: grid;
  justify-self: start;
  width: min(100%, 260px);
}

[data-beat="batch-chapters"] .batch-chapters-clipbox > * { grid-area: 1 / 1; min-width: 0; }
[data-beat="batch-chapters"] .batch-chapters-clip { width: 100%; }

[data-beat="batch-chapters"] .batch-chapters-pending {
  display: block;
  padding-bottom: 54px; /* the transport's height under the clip */
}

[data-beat="batch-chapters"] .batch-chapters-pending i {
  display: block;
  aspect-ratio: 1;
  border: 1.5px dashed var(--line);
  border-radius: 50%;
  transition: border-color .15s;
}

[data-beat="batch-chapters"] .batch-chapters-card[data-state="running"] .batch-chapters-pending i { border-color: var(--accent); }
[data-beat="batch-chapters"] .batch-chapters-clip:not([hidden]) ~ .batch-chapters-pending { visibility: hidden; }

/* The clip's line and the files' row keep their height too, empty until the scene is
   done. */
[data-beat="batch-chapters"] .batch-chapters-card .progress-ledger-line { min-height: 1lh; }
[data-beat="batch-chapters"] .batch-chapters-card .progress-ledger-line[hidden] { display: block; visibility: hidden; }
[data-beat="batch-chapters"] .batch-chapters-files { min-height: 30px; }
[data-beat="batch-chapters"] .batch-chapters-files[hidden] { display: flex; visibility: hidden; }
[data-beat="batch-chapters"] .batch-chapters-canvas { background: transparent; }
[data-beat="batch-chapters"] .batch-chapters-gallery { gap: 8px; }

/* ── The foot: what was skipped, and the batch tray ────────────────────── */

[data-beat="batch-chapters"] .batch-chapters-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  min-width: 0;
}

[data-beat="batch-chapters"] .batch-chapters-foot { min-height: 34px; }

[data-beat="batch-chapters"] .batch-chapters-tray {
  display: flex;
  min-height: 34px;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 0 auto;
}

[data-beat="batch-chapters"] .batch-chapters-tray[hidden],
[data-beat="batch-chapters"] .batch-chapters-all[hidden] { display: none; }

[data-beat="batch-chapters"] .batch-chapters-all {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

[data-beat="batch-chapters"] .batch-chapters-all:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }

[data-beat="batch-chapters"] .batch-chapters-manifest {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 11px;
  border: 1px dashed var(--muted);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  text-decoration: none;
}

[data-beat="batch-chapters"] .batch-chapters-manifest:hover { border-style: solid; border-color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  [data-beat="batch-chapters"] .batch-chapters-card,
  [data-beat="batch-chapters"] .batch-chapters-pending i { transition: none; }
}
