/* The batch band's motion (src/batch-band.js). Positions come from the script's layout constants as
   custom properties in sheet units; one unit is --u. Two arrangements: the row, and on narrow stages a
   two-by-two grid of piles (container query). Only transform, translate and opacity move. */

.batch-stage { container: batch / inline-size; }

.batch-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .875rem; min-height: 1.875rem; }
.batch-file { font-size: 1.0625rem; font-weight: 600; overflow-wrap: anywhere; }
.batch-meta { font-size: .875rem; color: var(--muted); }
.batch-state { margin-left: auto; font-size: .9375rem; font-weight: 600; color: var(--ink); opacity: 0; transition: opacity .35s; }
.batch-state.is-on { opacity: 1; }
.batch-meta, .batch-state { display: inline-grid; }
.batch-state { justify-items: end; }
.batch-meta > *, .batch-state > * { grid-area: 1 / 1; }
.batch-size { visibility: hidden; }
.batch-bar { height: 3px; margin: .625rem 0 1.5rem; background: var(--ink-08); overflow: hidden; }
.batch-bar i { display: block; height: 100%; background: var(--ink); transform-origin: 0 50%; transform: scaleX(var(--done, 0)); transition: transform .6s cubic-bezier(.65,0,.35,1); }

.batch-scene {
  --w: var(--rw); --h: var(--rh);
  --u: calc(100cqw / var(--w));
  container: batch-scene / inline-size;
  position: relative; width: 100%; max-width: 92rem; aspect-ratio: var(--w) / var(--h);
}

/* ---------- sheets ---------- */
.batch-sheet {
  --x: var(--rx0); --y: var(--ry0);
  position: absolute; left: 0; top: 0;
  width: calc(var(--sw) * var(--u)); height: calc(var(--sh) * var(--u));
  translate: calc(var(--x) * var(--u)) calc(var(--y) * var(--u));
  background: #fff; border-radius: calc(4 * var(--u)); overflow: hidden;
  box-shadow: 0 1px 2px rgba(40,32,20,.08), 0 calc(10 * var(--u)) calc(24 * var(--u)) calc(-8 * var(--u)) rgba(40,32,20,.35);
  opacity: 0; transform: translateY(calc(14 * var(--u)));
  transition: translate .5s cubic-bezier(.65,0,.35,1), opacity .35s, transform .35s cubic-bezier(.2,.7,.2,1);
}
.batch-sheet.is-in { opacity: 1; transform: none; }
.batch-scene.is-split .batch-sheet { --x: var(--rx1); --y: var(--ry1); }
.batch-sheet > svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* Frame: green on the first finished invoice, warn on the one that asks for attention. */
.batch-sheet::after { content: ""; position: absolute; inset: 0; z-index: 4; border-radius: inherit; box-shadow: inset 0 0 0 calc(2 * var(--u)) var(--frame, var(--ink)); opacity: 0; transition: opacity .35s .3s; pointer-events: none; }
.batch-sheet.is-first::after { opacity: 1; }
.batch-sheet.is-warned { --frame: var(--warn); }
.batch-sheet.is-warned::after { opacity: 1; }

/* Found values: marked like the demo's boxes once the invoice is done. */
.batch-hl { position: absolute; background: var(--ink-14); box-shadow: 0 0 0 1px rgba(47,93,80,.55); border-radius: 1px; opacity: 0; transition: opacity .4s .5s; }
.batch-sheet.is-done .batch-hl { opacity: 1; }

/* Dark and breathing only while extraction runs on this sheet. */
.batch-veil { position: absolute; inset: 0; z-index: 1; background: var(--text); opacity: 0; transition: opacity .6s ease; }
.batch-veil::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(240,181,101,.7) 1px, transparent 1.4px); background-size: calc(8 * var(--u)) calc(8 * var(--u)); opacity: 0; }
.batch-sheet.is-work .batch-veil { opacity: .78; animation: batchBreathe 1.5s ease-in-out .6s infinite; }
.batch-sheet.is-work .batch-veil::after { animation: batchDots 1.5s ease-in-out infinite; }
@keyframes batchBreathe { 0%, 100% { opacity: .8; } 50% { opacity: .55; } }
@keyframes batchDots { 0%, 100% { opacity: .15; } 50% { opacity: .9; } }
.batch-pill { position: absolute; left: calc(7 * var(--u)); top: calc(7 * var(--u)); z-index: 2; padding: calc(2 * var(--u)) calc(7 * var(--u)); border-radius: calc(10 * var(--u)); background: #F0B565; color: var(--text); font-size: max(11px, calc(9.5 * var(--u))); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; opacity: 0; transition: opacity .3s; }
.batch-sheet.is-work .batch-pill { opacity: 1; }

/* The data card: translucent, three rows; the amount on its own row, never wrapped. */
.batch-card {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  display: flex; flex-direction: column;
  padding: max(13px, calc(13 * var(--u))) calc(9 * var(--u)) calc(8 * var(--u)); /* room for the flag on the top edge */
  background: rgba(243,242,239,.86); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  border-top: calc(2 * var(--u)) solid var(--ink);
  font-size: max(11px, calc(11 * var(--u))); line-height: 1.35; color: var(--text);
  transform: translateY(101%); transition: transform .45s cubic-bezier(.32,.72,0,1) .35s;
}
.batch-card b, .batch-card i { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-card b { font-weight: 600; white-space: normal; text-overflow: clip; text-wrap: balance; } /* a long company name takes a second line rather than an ellipsis */
.batch-card i { font-style: normal; color: var(--muted); }
.batch-amount { display: block; margin-top: calc(2 * var(--u)); font-size: max(12.5px, calc(12.5 * var(--u))); font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.batch-sheet.is-done .batch-card { transform: none; }
.batch-sheet.is-warned .batch-card { border-top-color: var(--warn); }

/* Signal on a finished invoice: "extracted", or the one warning. */
.batch-flag { position: absolute; right: calc(6 * var(--u)); top: 0; z-index: 3; display: flex; align-items: center; gap: calc(4 * var(--u)); padding: calc(3 * var(--u)) calc(7 * var(--u)) calc(3 * var(--u)) calc(5 * var(--u)); border-radius: calc(10 * var(--u)); font-size: max(11px, calc(10 * var(--u))); font-weight: 700; letter-spacing: .04em; white-space: nowrap; opacity: 0; transform: translateY(-50%) scale(.8); transition: opacity .3s .7s, transform .3s .7s; }
.batch-flag svg { width: calc(11 * var(--u)); height: calc(11 * var(--u)); flex: none; }
.batch-flag.is-ok { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.batch-flag.is-warn { background: #F0B565; color: var(--text); }
.batch-sheet.is-done .batch-flag { opacity: 1; transform: translateY(-50%); }

/* ---------- cut lines and brackets ---------- */
.batch-cut {
  position: absolute; left: 0; top: 0; z-index: 20;
  width: calc(3 * var(--u)); height: calc(var(--ch) * var(--u));
  translate: calc(var(--rx) * var(--u)) calc(var(--ry) * var(--u));
  border-radius: 2px; background: #F0B565; box-shadow: 0 0 calc(14 * var(--u)) calc(3 * var(--u)) rgba(240,181,101,.55);
  opacity: 0;
}
.batch-cut.is-flash { animation: batchCut .7s cubic-bezier(.32,.72,0,1) forwards; }
@keyframes batchCut { 0% { opacity: 0; transform: scaleY(.2); } 25% { opacity: 1; transform: scaleY(1.06); } 100% { opacity: 0; transform: scaleY(1); } }

.batch-br {
  position: absolute; left: 0; top: 0;
  width: calc(var(--rbw) * var(--u)); height: calc(var(--bh) * var(--u));
  translate: calc(var(--rx) * var(--u)) calc(var(--ry) * var(--u));
  border: 1.5px solid var(--ink); border-top: 0; opacity: 0; transition: opacity .4s;
}
.batch-br.is-on { opacity: 1; }
.batch-br.is-warned { border-color: var(--warn); }
.batch-br-label { position: absolute; left: 0; top: calc(15 * var(--u)); width: calc(var(--rroom) * var(--u)); display: block; font-size: max(12px, calc(13 * var(--u))); font-weight: 600; letter-spacing: .08em; line-height: 1.3; text-transform: uppercase; color: var(--ink); white-space: nowrap; }
.batch-br-label small, .batch-br-label em { display: block; font-size: max(11px, calc(12 * var(--u))); letter-spacing: 0; text-transform: none; white-space: normal; }
.batch-br-label small { font-weight: 400; color: var(--muted); }
.batch-br-label em { font-style: normal; color: var(--warn); opacity: 0; transition: opacity .3s .7s; }
.batch-br.is-warned .batch-br-label em { opacity: 1; }

/* ---------- narrow stages: a two-by-two grid of fanned piles ----------
   The row needs a stage of 72rem (u ≈ .9) so the card's text, floored at 11px, keeps the amount on one line. */
@container batch (max-width: 72rem) {
  .batch-scene { --w: var(--gw); --h: var(--gh); max-width: 28rem; margin-inline: auto; }
  .batch-sheet { --x: var(--gx0); --y: var(--gy0); }
  .batch-scene.is-split .batch-sheet { --x: var(--gx1); --y: var(--gy1); z-index: var(--gz); }
  .batch-cut { translate: calc(var(--gx) * var(--u)) calc(var(--gy) * var(--u)); }
  .batch-br { width: calc(var(--gbw) * var(--u)); translate: calc(var(--gx) * var(--u)) calc(var(--gy) * var(--u)); }
  .batch-br-label { width: calc(var(--groom) * var(--u)); }
}

/* End state at once: reduced motion, or the script showing the result without playing it. */
.batch-stage.is-static *, .batch-stage.is-static *::after { transition: none !important; animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  .batch-stage *, .batch-stage *::after { transition: none !important; animation: none !important; }
}

/* ---------- the replay button and the stage's height ---------- */
/* The stage is drawn as soon as the script runs, so the no-script reserve (styles.css) is not needed then. */
.batch-stage:has(.batch-scene) { min-height: 0; }
/* The button keeps its place while hidden, so showing it moves nothing below it. */
.batch-replay {
  display: inline-flex; align-items: center; gap: .5rem; margin-top: 1.25rem; padding: .5rem .875rem;
  background: none; border: 1px solid var(--rule); border-radius: 0; cursor: pointer;
  font: 600 .75rem 'Barlow', sans-serif; letter-spacing: .1em; text-transform: uppercase; color: var(--ink);
  transition: opacity .4s, border-color .2s, color .2s;
}
.batch-replay::before { content: "\21BB"; font-size: 1rem; line-height: 1; letter-spacing: 0; }
.batch-replay:hover { border-color: var(--ink); color: var(--text); }
.batch-replay[hidden] { display: inline-flex; visibility: hidden; opacity: 0; }
/* With the end state shown at once there is no replay, so no reserved place either. */
.batch-stage.is-static ~ .batch-replay[hidden] { display: none; }
