/* File upload — a labelled dropzone wrapping a visually-hidden file input,
   plus a list of uploaded files. Markup: .govbb-file-upload holds a
   .govbb-file-upload__dropzone <label> (with __info text, the hidden __input,
   and an __action column) and an optional __list of __item rows. */

/* Size containment keeps the copy's 16rem wrap floor and the nowrap file
   names out of the component's min-content, so a narrow column shrinks it. */
.govbb-file-upload {
  display: flex;
  flex-direction: column;
  gap: var(--govbb-space-xs);
  width: 100%;
  contain: inline-size;
}

/* Copy and action share a row while the copy keeps 16rem; below that the
   action wraps beneath it. */
.govbb-file-upload__dropzone {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--govbb-space-m);
  width: 100%;
  padding: var(--govbb-space-xm) var(--govbb-space-s);
  color: var(--govbb-color-muted);
  border: 1px dashed var(--govbb-color-neutral);
  border-radius: var(--govbb-radius);
  cursor: pointer;
  transition: box-shadow 0.2s;
}

.govbb-file-upload__dropzone:has([aria-invalid='true']) {
  border-color: var(--govbb-color-error);
}

.govbb-file-upload__dropzone:has(:disabled) {
  opacity: var(--govbb-opacity-disabled);
  cursor: not-allowed;
}

/* The dropzone shows the keyboard focus ring when the hidden input has
   focus — the upstream package lacks this (WCAG 2.4.7); shared rule in
   focus.css. */

.govbb-file-upload__info {
  display: flex;
  flex: 1 1 16rem;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--govbb-space-xxs);
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: start;
}

.govbb-file-upload__title {
  font-size: var(--govbb-font-size-body);
  line-height: var(--govbb-line-height-base);
  font-weight: 700;
}

.govbb-file-upload__subtitle {
  font-size: var(--govbb-font-size-body-sm);
  line-height: var(--govbb-line-height-base);
}

.govbb-file-upload__action {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--govbb-space-xxs);
  min-width: 0;
}

.govbb-file-upload__max-size {
  font-size: var(--govbb-font-size-body-sm);
  line-height: var(--govbb-line-height-base);
  color: var(--govbb-color-muted);
  overflow-wrap: anywhere;
}

/* The hidden <input> carries .govbb-visually-hidden (the utility) for hiding;
   this class stays on it only as the :has() hook for the focus ring above. */

.govbb-file-upload__list {
  display: flex;
  flex-direction: column;
  gap: var(--govbb-space-xxs);
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Name and Remove share a row while the name keeps 8rem; below that Remove
   drops beneath it. */
.govbb-file-upload__item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--govbb-space-s);
  width: 100%;
  padding: var(--govbb-space-s);
  background: var(--govbb-color-highlight);
  border-radius: var(--govbb-radius);
}

.govbb-file-upload__name {
  flex: 1 1 8rem;
  min-width: 0;
  overflow: hidden;
  font-size: var(--govbb-font-size-body);
  line-height: var(--govbb-line-height-base);
  color: var(--govbb-color-ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Below the tablet breakpoint (800px) the info + button no longer fit side by
   side, so the dropzone stacks and centres on mobile. */
@media (--mobile) {
  .govbb-file-upload__dropzone {
    flex-direction: column;
    gap: var(--govbb-space-m);
    text-align: center;
  }

  .govbb-file-upload__info {
    flex-basis: auto;
    align-items: center;
  }

  .govbb-file-upload__action {
    align-items: center;
  }
}
