/* Batch image tool. Every rule is scoped to .pv-image-batch. Colours come from
   the site theme tokens (light/dark set on <html> by site.css) with neutral
   fallbacks, so theme switches restyle the tool without touching its state.
   Layout is one column of panels with row cards first; from 48rem the result
   cards share the width and from 60rem files (with the per-file inspection
   list) → settings → check/process sit in the left column and the per-file
   results, failures and downloads in the right one (TOOL_UI_DENSITY_SPEC §3.5);
   DOM order is unchanged.
   Status is always text as well as colour; [hidden] always wins. */

.pv-image-batch {
  --pvb-text: var(--text, #1b1f24);
  --pvb-muted: var(--muted, #5b6472);
  --pvb-line: var(--line, #d0d6de);
  --pvb-panel: var(--panel, #ffffff);
  --pvb-sunken: var(--pv-sunken, #f6f8fa);
  --pvb-accent: var(--accent, #1f5fbf);
  --pvb-accent-dark: var(--accent-dark, #174a96);
  --pvb-on-accent: var(--pv-on-primary, #ffffff);
  --pvb-soft: var(--pv-soft, #eaf1fb);
  --pvb-selected: var(--pv-selected, #f3f7fd);
  --pvb-field: var(--pv-field, #ffffff);
  --pvb-control: var(--pv-control, #6b7480);
  --pvb-focus: var(--pv-focus, #1b1f24);
  --pvb-halo: var(--pv-halo, #ffffff);
  --pvb-danger: var(--danger, #b3261e);
  --pvb-error-bg: var(--pv-error-bg, #fdf1f0);
  --pvb-warning: var(--warning, #9a6700);
  --pvb-warning-bg: var(--pv-warning-bg, #fff7e0);
  --pvb-warning-line: var(--pv-warning-line, #e3c47e);
  --pvb-info-bg: var(--pv-info-bg, #eef4fc);
  --pvb-info-line: var(--pv-info-line, #c6d7f0);
  --pvb-result-line: var(--pv-result-line, #9db6df);
  --pvb-disabled-bg: var(--pv-disabled-bg, #e9edf2);
  --pvb-disabled-line: var(--pv-disabled-line, #c9d0d9);
  --pvb-disabled-text: var(--pv-disabled-text, #5b6472);
  color: var(--pvb-text);
  line-height: 1.6;
  overflow-wrap: break-word;
}

.pv-image-batch [hidden] { display: none !important; }

.pv-image-batch__heading { margin: 0.25rem 0 0.75rem; font-size: 1.5rem; line-height: 1.3; letter-spacing: -0.01em; word-break: keep-all; }
.pv-image-batch__intro { max-width: 48rem; margin: 0 0 1rem; }
/* Short local/leave notice: an information box, not a warning. */
.pv-image-batch__persistence {
  margin: 0 0 1rem;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--pvb-info-line);
  border-radius: 0.5rem;
  background: var(--pvb-info-bg);
  font-size: 0.9375rem;
  font-weight: 600;
}

.pv-image-batch__panel {
  margin: 0 0 1rem;
  padding: 1rem;
  border: 1px solid var(--pvb-line);
  border-radius: 0.75rem;
  background: var(--pvb-panel);
}
.pv-image-batch__panel--results { border-color: var(--pvb-result-line); }
.pv-image-batch__subheading { margin: 0 0 0.75rem; font-size: 1.125rem; line-height: 1.35; word-break: keep-all; }

.pv-image-batch__help { margin: 0.25rem 0 0.5rem; color: var(--pvb-muted); font-size: 0.9375rem; }
.pv-image-batch__warning {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--pvb-warning-line);
  border-radius: 0.5rem;
  background: var(--pvb-warning-bg);
  font-weight: 600;
}
.pv-image-batch__selection { margin: 0.5rem 0; font-weight: 600; }

/* ---- Buttons and the file chooser (a focusable, visually hidden input + label). ---- */

.pv-image-batch__file-row,
.pv-image-batch__buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0 0 0.5rem; }

.pv-image-batch__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0.5rem 1.125rem;
  border: 1px solid var(--pvb-control);
  border-radius: 0.5rem;
  background: var(--pvb-panel);
  color: var(--pvb-text);
  font: inherit;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  word-break: keep-all;
  cursor: pointer;
  touch-action: manipulation;
}
.pv-image-batch__button:hover { border-color: var(--pvb-accent-dark); background: var(--pvb-soft); color: var(--pvb-accent-dark); }
.pv-image-batch__button--primary { border-color: var(--pvb-accent); background: var(--pvb-accent); color: var(--pvb-on-accent); }
.pv-image-batch__button--primary:hover { border-color: var(--pvb-accent-dark); background: var(--pvb-accent-dark); color: var(--pvb-on-accent); }
.pv-image-batch__button:disabled,
.pv-image-batch__button[aria-disabled="true"],
.pv-image-batch__button:disabled:hover,
.pv-image-batch__button[aria-disabled="true"]:hover,
.pv-image-batch__file-input:disabled + .pv-image-batch__file-label {
  border-color: var(--pvb-disabled-line);
  background: var(--pvb-disabled-bg);
  color: var(--pvb-disabled-text);
  cursor: not-allowed;
}

.pv-image-batch__file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.pv-image-batch__file-label { flex: 1 1 12rem; }

.pv-image-batch a:focus-visible,
.pv-image-batch button:focus-visible,
.pv-image-batch input:focus-visible,
.pv-image-batch__file-input:focus-visible + .pv-image-batch__file-label {
  outline: 3px solid var(--pvb-focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--pvb-halo);
}

/* ---- Settings. ---- */

.pv-image-batch__fieldset { margin: 0 0 0.75rem; padding: 0; border: 0; }
.pv-image-batch__legend { margin: 0 0 0.25rem; padding: 0; font-weight: 700; }
.pv-image-batch__choice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 0.5rem;
  align-items: start;
  margin: 0 0 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--pvb-line);
  border-radius: 0.5rem;
  background: var(--pvb-panel);
}
.pv-image-batch__choice:has(input:checked) { border-color: var(--pvb-accent); background: var(--pvb-selected); box-shadow: inset 0 0 0 1px var(--pvb-accent); }
.pv-image-batch__choice input[type="radio"] { width: 1.25rem; height: 1.25rem; margin: 0.2rem 0 0; accent-color: var(--pvb-accent); }
.pv-image-batch__choice label { font-weight: 600; }
.pv-image-batch__choice .pv-image-batch__help { grid-column: 2; margin: 0; }
.pv-image-batch__fieldset--inline { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pv-image-batch__fieldset--inline .pv-image-batch__legend { flex: 1 0 100%; }
.pv-image-batch__choice--inline { min-width: 8rem; align-items: center; }

.pv-image-batch__field { margin: 0 0 0.75rem; }
.pv-image-batch__label { display: block; margin: 0 0 0.25rem; font-weight: 700; }
.pv-image-batch__text {
  box-sizing: border-box;
  width: 100%;
  max-width: 14rem;
  min-height: 2.75rem;
  padding: 0.375rem 0.625rem;
  border: 1px solid var(--pvb-control);
  border-radius: 0.5rem;
  background: var(--pvb-field);
  color: var(--pvb-text);
  font: inherit;
}
.pv-image-batch__text[aria-invalid="true"] { border: 2px solid var(--pvb-danger); }
.pv-image-batch__field-error { margin: 0.25rem 0 0; color: var(--pvb-danger); font-weight: 600; }

/* ---- Status, alerts and the screen-reader-only live region. ---- */

.pv-image-batch__summary,
.pv-image-batch__status,
.pv-image-batch__notice {
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--pvb-info-line);
  border-radius: 0.5rem;
  background: var(--pvb-info-bg);
}
.pv-image-batch__summary { font-weight: 700; }
.pv-image-batch__notice { border-color: var(--pvb-warning-line); background: var(--pvb-warning-bg); font-weight: 600; }
.pv-image-batch__alert:empty { display: none; }
.pv-image-batch__alert {
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--pvb-danger);
  border-radius: 0.5rem;
  background: var(--pvb-error-bg);
  color: var(--pvb-danger);
}
.pv-image-batch__alert p { margin: 0.125rem 0; }
.pv-image-batch__alert p:first-child { font-weight: 700; }

.pv-image-batch__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---- Result rows: cards on every width; the state is text plus a side bar. ---- */

.pv-image-batch__list { display: grid; gap: 0.75rem; margin: 0 0 0.75rem; padding: 0; list-style: none; }
.pv-image-batch__row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--pvb-line);
  border-left-width: 0.375rem;
  border-radius: 0.5rem;
  background: var(--pvb-sunken);
}
.pv-image-batch__row[data-state="success"] { border-color: var(--pvb-accent); }
.pv-image-batch__row[data-state="inputFailed"],
.pv-image-batch__row[data-state="processFailed"] { border-left-color: var(--pvb-danger); }
.pv-image-batch__row[data-state="cancelled"],
.pv-image-batch__row[data-state="stopped"],
.pv-image-batch__row[data-state="inspectionCancelled"] { border-left-color: var(--pvb-warning-line); }
.pv-image-batch__row-title { margin: 0; font-size: 1rem; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
/* Left inspection list under the chooser: one card per selection number, no download control. */
.pv-image-batch__list--inspection { margin: 0.75rem 0 0; }
.pv-image-batch__list--inspection:empty { display: none; }
.pv-image-batch__row-state { margin: 0; font-weight: 700; }
.pv-image-batch__facts p,
.pv-image-batch__row-reason p { margin: 0.125rem 0; font-size: 0.9375rem; }
.pv-image-batch__facts--result p:last-child { overflow-wrap: anywhere; }
.pv-image-batch__row-reason { color: var(--pvb-danger); }
.pv-image-batch__row-reason:empty,
.pv-image-batch__facts:empty { display: none; }
.pv-image-batch__download { align-self: flex-start; margin-top: 0.25rem; }

@media (min-width: 48rem) {
  .pv-image-batch__panel { padding: 1.25rem 1.5rem; }
  .pv-image-batch__list { grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); }
  .pv-image-batch__file-label { flex: 0 0 auto; min-width: 12rem; }
}

/* Input, settings and actions | per-file results. The last left row is
   flexible so a long result list never spreads the left panels apart. */
@media (min-width: 60rem) {
  .pv-image-batch {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto 1fr;
    grid-template-areas:
      "heading heading"
      "intro intro"
      "files results"
      "settings results"
      "actions results";
    column-gap: 1.5rem;
    align-items: start;
  }
  .pv-image-batch > * { min-width: 0; }
  .pv-image-batch__heading { grid-area: heading; }
  .pv-image-batch__intro { grid-area: intro; }
  .pv-image-batch__panel--files { grid-area: files; }
  .pv-image-batch__panel--settings { grid-area: settings; }
  .pv-image-batch__panel--actions { grid-area: actions; }
  .pv-image-batch__panel--results { grid-area: results; }
}
