/* ==========================================================================
   My Easy Science - Paper Tools UI kit (Chunk 0)
   Component styles for the Paper Tools. Uses only the shared tokens from
   assets/ui.css (colours, spacing, radius, shadow, focus ring, type scale).
   No hard-coded colours, so light and dark themes both work through the
   [data-theme="dark"] token overrides in ui.css. This file only adds what
   ui.css does not already provide; shared classes (.btn, .card, .badge,
   .notice, .toast, .modal, table.data-table, .input) are reused, never
   redefined here. British spelling throughout. No em dashes.
   ========================================================================== */

/* ---------- Drop zone ---------- */
.pt-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 132px;
  padding: var(--s5) var(--s4);
  background: var(--surface);
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-card);
  color: var(--ink-2);
  text-align: center;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.pt-dropzone:hover {
  background: var(--surface-2);
  border-color: var(--primary);
}
.pt-dropzone:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.pt-dropzone--dragover {
  background: var(--surface-2);
  border-color: var(--primary);
  border-style: solid;
}
.pt-dropzone__label {
  font-weight: 650;
  font-size: var(--fs-base);
  color: var(--ink);
}
.pt-dropzone__hint {
  font-size: var(--fs-sm);
  color: var(--muted);
  margin: 0;
  max-width: 48ch;
}
.pt-dropzone__browse {
  margin-top: var(--s2);
}

/* ---------- Progress bar ---------- */
.pt-progress {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  width: 100%;
  max-width: 100%;
}
.pt-progress__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s2);
  flex-wrap: wrap;
}
.pt-progress-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
}
.pt-progress__value {
  font-size: var(--fs-sm);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pt-progress__track {
  width: 100%;
  height: var(--s2);
  background: var(--surface-2);
  border-radius: var(--radius-chip);
  overflow: hidden;
}
.pt-progress__fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: var(--radius-chip);
  transition: width var(--dur-med) var(--ease-out);
}
.pt-progress--indeterminate .pt-progress__fill {
  width: 40%;
  animation: pt-progress-slide 1.4s var(--ease-out) infinite;
}
@keyframes pt-progress-slide {
  0% { margin-left: -40%; }
  100% { margin-left: 100%; }
}
.pt-progress__status {
  font-size: var(--fs-sm);
  color: var(--muted);
  min-height: 1.5em;
  margin: 0;
}
.pt-progress__cancel {
  align-self: flex-start;
}

/* ---------- Status chips ---------- */
/* Chunk 0 states: Done, Verify, Failed, and Not detected for a missing
   value. Never use the word "No" for a missing value. */
.pt-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  min-height: 24px;
  padding: var(--s1) var(--s2);
  border: 1px solid transparent;
  border-radius: var(--radius-chip);
  font-size: var(--fs-xs);
  font-weight: 650;
  line-height: 1.3;
  white-space: nowrap;
}
.pt-chip--done {
  color: var(--ok);
  background: var(--ok-soft);
}
.pt-chip--verify {
  color: var(--warn);
  background: var(--warn-soft);
}
.pt-chip--failed {
  color: var(--err);
  background: var(--err-soft);
}
.pt-chip--info {
  color: var(--primary);
  background: var(--primary-soft);
}

/* ---------- Toast additions ---------- */
/* ui.css provides .toast-region and .toast. These additions cover a success
   tone and a dismiss button; the error tone already exists in ui.css. */
.pt-toast--ok {
  background: var(--ok);
  color: #fff;
}
.pt-toast__text {
  flex: 1;
  min-width: 0;
}
.pt-toast__close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  margin: calc(var(--s2) * -1) calc(var(--s2) * -1) calc(var(--s2) * -1) 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-control);
  background: none;
  color: inherit;
  font-size: var(--fs-lg);
  line-height: 1;
  cursor: pointer;
}
.pt-toast__close:hover {
  background: rgba(255, 255, 255, .16);
}
.pt-toast__close:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ---------- Inline editable table ---------- */
/* Built on table.data-table from ui.css. The wrapper scrolls sideways on
   narrow screens so the page itself never overflows. */
.pt-editable-table {
  overflow-x: auto;
  max-width: 100%;
}
.pt-editable-table__toolbar {
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: var(--s3);
}
.pt-editable-table table.data-table {
  min-width: 0;
}
.pt-editable-table td.pt-cell {
  cursor: pointer;
  min-height: 44px;
}
.pt-editable-table td.pt-cell:hover {
  background: var(--surface-2);
}
.pt-editable-table td.pt-cell:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.pt-editable-table td.pt-cell--editing {
  padding: var(--s1);
}
.pt-editable-table td.pt-cell--editing .input {
  min-height: 44px;
  border-color: var(--primary);
}
.pt-editable-table td.pt-cell--editing .input:focus {
  outline: none;
  box-shadow: var(--focus-ring);
}
.pt-editable-table .pt-row-remove {
  min-height: 44px;
  padding: var(--s1) var(--s2);
  white-space: nowrap;
}
.pt-editable-table__hint {
  font-size: var(--fs-sm);
  color: var(--muted);
  margin: var(--s2) 0 0;
}

/* ---------- Modal additions ---------- */
/* ui.css provides .modal-backdrop and .modal. These additions cover a
   close button and a wider option; layout and actions reuse .modal and
   .modal-actions from ui.css. */
.modal.pt-modal {
  position: relative;
}
.pt-modal--wide {
  max-width: 720px;
}
.pt-modal__close {
  position: absolute;
  top: var(--s2);
  right: var(--s2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-control);
  background: none;
  color: var(--muted);
  font-size: var(--fs-xl);
  line-height: 1;
  cursor: pointer;
}
.pt-modal__close:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.pt-modal__close:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.pt-modal__body {
  margin-top: var(--s3);
}
.pt-modal__body > :last-child {
  margin-bottom: 0;
}

/* ---------- Privacy note ---------- */
/* Small note on every tool page explaining what leaves the device.
   Green left border, like .notice--ok in ui.css. */
.pt-privacy-note {
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--ok);
  background: var(--ok-soft);
  border-radius: var(--radius-control);
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s4);
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.pt-privacy-note strong {
  color: var(--ink);
  font-weight: 650;
}

/* ---------- Narrow screens ---------- */
@media (max-width: 480px) {
  .pt-dropzone {
    padding: var(--s4) var(--s3);
    min-height: 120px;
  }
  .pt-modal__body {
    font-size: var(--fs-sm);
  }
  .pt-editable-table td.pt-cell,
  .pt-editable-table th {
    padding-left: var(--s2);
    padding-right: var(--s2);
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .pt-progress--indeterminate .pt-progress__fill {
    animation: none;
    width: 100%;
  }
}
