/* ============================================================
   Pixelsort Batch — layered on top of y2k.css
   Same hard borders, chrome and Verdana as the single-image
   wrapper, so the two tools read as a matched pair. The one new
   idea: the grid is dressed as a contact sheet, because the
   subject genuinely is a matrix.
   ============================================================ */

.bench {
  position: relative;
  z-index: 2;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.panel--setup  { grid-column: 1; transform: rotate(-.45deg); }
.panel--config { grid-column: 2; }
.panel--launch { grid-column: 3; transform: rotate(.35deg); }
.panel--grid   { grid-column: 1 / -1; background: var(--panel-2); }

.dropzone--compact { padding: 18px 14px; }
.dropzone--compact .dropzone__disc { width: 48px; height: 48px; margin-bottom: 10px; }
.dropzone--compact .dropzone__lead { font-size: 15px; }

/* ---------- Mode picker ---------- */

.modes { display: grid; gap: 8px; margin-bottom: 18px; }

.mode {
  display: block;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  font-family: var(--face);
  background: #fff;
  border: var(--hard);
  box-shadow: var(--pop-sm);
  cursor: pointer;
  transition: background-color .12s, transform .1s, box-shadow .1s;
}
.mode:hover { background: var(--panel-2); }
.mode.is-on {
  background: linear-gradient(180deg, #ff6bb0 0%, var(--magenta) 100%);
  color: #fff;
}
.mode:active { transform: translate(3px, 3px); box-shadow: none; }

.mode__name {
  display: block;
  font-family: var(--disp);
  font-size: 15px;
  font-weight: bold;
  letter-spacing: .12em;
}
.mode__desc { display: block; font-size: 10.5px; line-height: 1.5; opacity: .85; }
.mode.is-on .mode__desc { opacity: .95; }

.param--tight { margin-bottom: 12px; }
.param[hidden] { display: none; }

/* ---------- Axis preview ---------- */

.axispreview {
  margin: 16px 0 0;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.75;
  background: var(--ink);
  color: var(--lime);
  border: var(--hard);
  overflow-x: auto;
}
.axispreview b { color: var(--cyan); font-weight: bold; }
.axispreview em { color: #ffd23d; font-style: normal; }

/* ---------- Constants disclosure ---------- */

.constants { margin-top: 16px; border: 2px dashed var(--ink); background: var(--panel-2); }
.constants > summary {
  padding: 8px 11px;
  font-family: var(--disp);
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: .06em;
  cursor: pointer;
}
.constants[open] > summary { border-bottom: 2px dashed var(--ink); }
.constants__body { padding: 14px 12px 6px; }

/* ---------- Pre-flight ---------- */

.preflight {
  padding: 13px 14px;
  background: #fff;
  border: var(--hard);
  box-shadow: var(--pop-sm);
  margin-bottom: 14px;
}
.preflight__line { margin: 0 0 4px; font-family: var(--disp); font-size: 15px; font-weight: bold; }
.preflight__line b { color: #c0176b; }
.preflight__sub { margin: 0; font-size: 10.5px; color: #40546b; line-height: 1.6; }

.runbar { margin-top: 14px; display: grid; gap: 8px; }
.runbar__track { height: 20px; background: #fff; border: var(--hard); overflow: hidden; }
.runbar__track span {
  display: block; height: 100%; width: 0;
  background: repeating-linear-gradient(90deg, var(--magenta) 0 8px, var(--violet) 8px 16px);
  transition: width .3s linear;
}
.runbar__text {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: bold;
  letter-spacing: .06em;
}

.btn--cancel {
  padding: 9px;
  font-size: 13px;
  letter-spacing: .14em;
  background: linear-gradient(180deg, #ffe14d 0%, #f0b400 100%);
  box-shadow: var(--pop-sm);
}
.btn--cancel:hover { background: linear-gradient(180deg, #fff08a 0%, #ffcc00 100%); }

.done { margin-top: 14px; display: grid; gap: 8px; justify-items: start; }
.done__note { font-size: 10.5px; color: #40546b; }

/* ---------- The grid ---------- */

.constbar {
  margin: 0 0 8px;
  padding: 8px 11px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: bold;
  background: var(--lime);
  border: var(--hard);
  overflow-x: auto;
  white-space: nowrap;
}

.disclose {
  margin: 0 0 12px;
  padding: 8px 11px;
  font-size: 11px;
  line-height: 1.6;
  background: #ffe14d;
  border: 2px dashed var(--ink);
}

.gridwrap {
  display: grid;
  grid-template-columns: max-content repeat(var(--n, 4), minmax(0, 1fr));
  gap: 6px;
}
.gridwrap.is-sweep { grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); }

/* Contact-sheet header chrome */
.axishead {
  display: grid;
  place-content: center;
  padding: 7px 9px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  letter-spacing: .04em;
  background: linear-gradient(180deg, var(--chrome-hi) 0%, var(--chrome) 46%, var(--chrome-lo) 100%);
  border: var(--hard);
}
.axishead--row { writing-mode: horizontal-tb; max-width: 120px; word-break: break-word; }
.axishead--corner {
  background: var(--ink);
  color: var(--cyan);
  font-size: 9.5px;
  line-height: 1.4;
  padding: 6px 8px;
}
.axishead--corner b { display: block; color: #fff; font-size: 10px; }

.cell {
  position: relative;
  /* Set from the source's own dimensions in buildGrid(). Locking cells to a
     fixed ratio would crop every render, and you cannot compare sorts by
     looking at crops of them. */
  aspect-ratio: var(--ar, 4 / 3);
  display: grid;
  place-items: center;
  padding: 0;
  background:
    repeating-conic-gradient(#e7eef4 0% 25%, #f7fafc 0% 50%) 50% / 14px 14px;
  border: var(--hard);
  cursor: default;
  overflow: hidden;
}
.cell.is-done { cursor: pointer; }
.cell.is-done:hover, .cell.is-done:focus-visible { border-color: var(--magenta); outline: none; }
.cell.is-done:hover .cell__zoom { opacity: 1; }

.cell img { width: 100%; height: 100%; object-fit: cover; display: block; }

.cell__state {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #6d8095;
  text-align: center;
  line-height: 1.7;
}
.cell__state b { display: block; color: var(--ink); font-size: 13px; }

.cell.is-running .cell__state { color: var(--ink); }
.cell.is-error { border-color: #c0176b; background: #ffe0ec; }
.cell.is-error .cell__state { color: #c0176b; }

.cell__badge {
  position: absolute;
  top: 0; left: 0;
  padding: 2px 6px;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: bold;
  background: var(--ink);
  color: var(--lime);
  z-index: 2;
}
.cell__sweep {
  position: absolute;
  bottom: 0; right: 0;
  padding: 3px 7px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: bold;
  background: var(--magenta);
  color: #fff;
  border-top: 2px solid var(--ink);
  border-left: 2px solid var(--ink);
  z-index: 2;
}
.cell__zoom {
  position: absolute;
  inset: auto 0 0 0;
  padding: 4px 7px;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: bold;
  background: rgba(10, 16, 32, .82);
  color: var(--cyan);
  opacity: 0;
  transition: opacity .15s;
  z-index: 1;
}

.spin {
  width: 26px; height: 26px;
  border: 3px solid var(--chrome-lo);
  border-top-color: var(--magenta);
  border-radius: 50%;
  animation: bspin .8s linear infinite;
  margin: 0 auto 6px;
}
@keyframes bspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2.6s; } }

/* ---------- Lightbox ---------- */

.lightbox { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; }
.lightbox[hidden] { display: none; }
.lightbox__backdrop { position: absolute; inset: 0; background: rgba(10, 16, 32, .82); }

.lightbox__panel {
  position: relative;
  width: min(1200px, 100%);
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: var(--hard);
  box-shadow: 8px 8px 0 var(--ink);
}

.lightbox__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: linear-gradient(180deg, #4a5f7a 0%, var(--ink) 100%);
  border-bottom: var(--hard);
}
.lightbox__title {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: bold;
  letter-spacing: .08em;
  color: var(--cyan);
}

.lightbox__stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 10px;
  background: repeating-conic-gradient(#e7eef4 0% 25%, #f7fafc 0% 50%) 50% / 18px 18px;
}
.lightbox__stage img { max-width: 100%; max-height: 68vh; border: 2px solid var(--ink); }

.lightbox__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  background: #0d1524;
  border-top: var(--hard);
}
.lightbox__foot code {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--lime);
  word-break: break-all;
  flex: 1 1 320px;
}
.lightbox__actions { display: flex; gap: 8px; }
.btn--sm { padding: 6px 11px; font-size: 11px; letter-spacing: .06em; }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .bench { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .panel--setup  { grid-column: 1; }
  .panel--config { grid-column: 2; grid-row: 1 / span 2; }
  .panel--launch { grid-column: 1; transform: rotate(0); }
}

@media (max-width: 760px) {
  /* Mobile is explicitly out of scope. This is the free fallback: the matrix
     collapses to one column and the row headers stop making sense, so they are
     hidden and each cell carries its own badge instead. */
  .bench { grid-template-columns: 1fr; }
  .panel--setup, .panel--config, .panel--launch, .panel--grid { grid-column: 1; transform: none; }
  .panel--config { grid-row: auto; }
  .gridwrap, .gridwrap.is-sweep { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .axishead { display: none; }
  .cell__badge { position: static; display: block; }
}
