/* Capture (D-021): the sheet's corners and several drawings at once.
   Same room as style.css: ink on the wall, white mats, 44 px targets. */

/* The single form's own fields; a batch replaces them with its list. */
.single-only { display: contents; }
form.is-batch .single-only { display: none; }

/* ---------- More photos: the camera, and the library ---------- */
.batch-add { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.batch-pick { position: relative; cursor: pointer; min-height: 2.9rem; }
.batch-pick input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.batch-pick:focus-within { outline: 2px solid var(--ink); outline-offset: 3px; }

/* ---------- The sheet of paper ---------- */
.paper-note { display: flex; align-items: center; gap: 0.5rem; margin: 0; font-size: 0.92rem; color: var(--ok); }
.paper-note .icon { width: 1.25rem; height: 1.25rem; }
.paper-tools { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.paper-tools:not(:has(> :not([hidden]))) { display: none; }
#capture-editor[data-mode="corners"] canvas { cursor: grab; }
/* Once an inline style attribute, which the Content-Security-Policy refuses (D-033). */
.capture-canvas { display: block; max-width: 100%; height: auto; touch-action: none; }
#capture-editor canvas { width: 100%; max-height: 70vh; object-fit: contain; background: var(--wall); border-radius: 6px; }
#capture-editor button[aria-pressed="true"] { border-color: var(--ink); background: var(--hover); }

/* ---------- The batch ---------- */
.batch { display: grid; gap: 1.25rem; min-width: 0; }
.batch-head h2 { margin: 0; }
.batch-head p { margin: 0.35rem 0 0; font-size: 0.95rem; }
.batch-common { display: grid; gap: 0.75rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 30rem) { .batch-common { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.batch-list { list-style: none; margin: 0; padding: 0; display: grid; }
.batch-item {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr);
  grid-template-areas: "thumb actions" "fields fields" "status status" "editor editor";
  /* No row gap: empty status and editor rows must not leave holes. */
  gap: 0 0.75rem;
  padding: 1.1rem 0;
  border-top: 1px solid var(--line);
  min-width: 0;
}
.batch-item:first-child { border-top: 0; padding-top: 0.25rem; }
.batch-thumb { grid-area: thumb; align-self: start; display: grid; place-items: center; min-height: 4.5rem; background: #fff; padding: 0.3rem; box-shadow: var(--mat-shadow); }
.batch-thumb canvas, .batch-thumb img { display: block; width: 100%; height: auto; max-height: 8rem; object-fit: contain; }
.batch-fields { grid-area: fields; display: grid; gap: 0.75rem; min-width: 0; margin-top: 0.75rem; }
.batch-row { display: grid; gap: 0.75rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 26rem) { .batch-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.batch-actions { grid-area: actions; display: flex; flex-wrap: wrap; align-content: start; gap: 0.5rem; }
.batch-actions button, .batch-actions .button { min-height: 2.75rem; padding: 0.5rem 0.85rem; font-size: 0.9rem; gap: 0.4rem; }
.batch-more[open] { padding-bottom: 0.25rem; }
.batch-more[open] > summary { margin-bottom: 0.5rem; }
.batch-more summary {
  display: flex; align-items: center; min-height: 2.75rem; cursor: pointer;
  font-size: 0.85rem; font-weight: 600; color: var(--muted); list-style-position: inside;
}
.batch-more summary:hover { color: var(--ink); }
.batch-more[open] > label + label { margin-top: 0.75rem; }

.batch-status { grid-area: status; display: flex; align-items: center; gap: 0.4rem; margin: 0.5rem 0 0; font-size: 0.9rem; color: var(--muted); }
.batch-status:not(:has(.batch-status-text:not(:empty))) { display: none; }
.batch-status-icon { display: none; }
.batch-item[data-status="done"] .batch-status-icon[data-when="done"],
.batch-item[data-status="waiting"] .batch-status-icon[data-when="waiting"],
.batch-item[data-status="error"] .batch-status-icon[data-when="error"] { display: inline-flex; }
.batch-item[data-status="done"] .batch-status { color: var(--ok); }
.batch-item[data-status="error"] .batch-status { color: var(--danger); }
.batch-item[data-status="sending"] .batch-status-text::after { content: ""; display: inline-block; width: 0.8em; height: 0.8em; margin-left: 0.4em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; vertical-align: -0.1em; animation: batch-spin 0.8s linear infinite; }
@keyframes batch-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .batch-item[data-status="sending"] .batch-status-text::after { animation: none; } }
.batch-item[data-status="done"] .batch-fields { opacity: 0.7; }

.batch-editor-slot { grid-area: editor; display: grid; gap: 0.75rem; min-width: 0; margin-top: 0.75rem; }
.batch-editor-slot:not(:has(> :not([hidden]))) { display: none; }
.batch-item.is-editing { background: var(--paper); }

/* The batch's main action is the ink pill, like the single form's Subir. */
.batch .batch-submit, .batch .batch-submit:hover { justify-self: stretch; background: var(--ink); color: var(--paper); border: 0; }
.batch .batch-submit:hover { background: color-mix(in srgb, var(--ink) 85%, var(--wall)); }
.batch .batch-submit:disabled { opacity: 0.6; cursor: progress; }
@media (min-width: 30rem) { .batch-submit { justify-self: start; } }
.batch-error { margin: 0; }
.batch-summary { display: grid; gap: 0.75rem; padding: 1rem 1.1rem; border-radius: 12px; background: var(--wall); border: 1px solid var(--line); }
.batch-summary p { margin: 0; }
.batch-summary-text { font-family: var(--serif); font-size: 1.35rem; line-height: 1.25; }
.batch-summary-links { display: flex; flex-wrap: wrap; gap: 0.5rem; }

@media (min-width: 40rem) {
  .batch-item {
    grid-template-columns: 8rem minmax(0, 1fr);
    grid-template-areas: "thumb fields" "thumb actions" "thumb status" "editor editor";
    column-gap: 1rem;
  }
  .batch-fields { margin-top: 0; }
  .batch-actions { margin-top: 0.5rem; }
  .batch-thumb canvas, .batch-thumb img { max-height: 10rem; }
}
