:host(:not(:is([hydrated], .hydrated))) {
  @apply not-hydrated;
}


mds-button,
mds-file-preview,
mds-progress,
mds-tab,
mds-tab-item,
mds-text {
  &:not(:is([hydrated], .hydrated)) {
    @apply not-hydrated;
  }
}


/**
 * @prop --mds-input-upload-drag-area-background-color-on-drag: Set the background color of the drag area when a file is dragged over it.
 * @prop --mds-input-upload-drag-area-background-color: Sets the background-color of the drag area.
 * @prop --mds-input-upload-drag-area-border-on-drag: Set the border of the drag area when a file is dragged over it.
 * @prop --mds-input-upload-drag-area-border: Sets the border of the drag area.
 * @prop --mds-input-upload-min-cols: Public. Set the minimum number of columns for the file list.
 */

/* ❌ Not supported
@property --mds-input-upload-drag-area-border-on-drag {
  inherits: false;
  initial-value: 3px dashed rgb(var(--magma-border-strong));
  syntax: "<border>";
}

@property --mds-input-upload-drag-area-border {
  inherits: false;
  initial-value: 3px dashed rgb(var(--magma-border-default));
  syntax: "<border>";
}
*/

:host {
  --mds-input-upload-drag-area-background-color-on-drag: rgb(var(--magma-wash-soft, var(--tone-neutral-10, 237 237 237)));

  /* a field stands a step off its surface: overlay on a page, the step below inside an overlay
     surface, which passes it as --magma-field-fill (#1193) */
  --mds-input-upload-drag-area-background-color: rgb(var(--magma-field-fill, var(--magma-surface-overlay, var(--surface-neutral-overlay, 255 255 255))));
  --mds-input-upload-drag-area-border-on-drag: --spacing(75) dashed rgb(var(--magma-border-strong, var(--border-neutral-strong, 140 140 140)));
  --mds-input-upload-drag-area-border: --spacing(75) dashed rgb(var(--magma-border-default, var(--border-neutral-default, 183 183 183)));
  --mds-input-upload-min-cols: 3;

  @apply grid-cols-full;

  container-type: inline-size;
  display: grid;
  gap: --spacing(400);
}

.drag-area {
  align-items: center;
  background-color: var(--mds-input-upload-drag-area-background-color, rgb(var(--magma-surface-overlay, var(--surface-neutral-overlay, 255 255 255))));
  border: var(--mds-input-upload-drag-area-border);
  border-radius: var(--magma-radius-2xl, var(--radius-squircle-2xl, 40px));
  corner-shape: var(--magma-corner-shape, squircle);
  display: flex;
  flex-direction: column;
  gap: --spacing(400);
  justify-content: center;
  padding: --spacing(600);

  /*
    actually there is no way to custom background-image url
    paramter which not allows to pass custom properties inside
    --stroke-color: rgb(var(--magma-border-default));
    --stroke-dashoffset: 8;
    --stroke-line-width: 8;
    --stroke-width: 5;
    --stroke-line-distance: --spacing(400);
    --stroke-dasharray-line: var(--stroke-line-width) '%2c' var(--stroke-line-distance);
    --border-radius: var(--radius-2xl);
    --url: "url(data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' rx='" var(--border-radius) "' ry='" var(--border-radius) "' stroke='" var(--stroke-color) "' stroke-width='" var(--stroke-width) "' stroke-dasharray='8%2c 16' stroke-dashoffset='0' stroke-linecap='square'/%3e%3c/svg%3e)";
    background-image: url("data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' rx="16" ry='16' stroke='red' stroke-width='5' stroke-dasharray='8%2c 16' stroke-dashoffset='0' stroke-linecap='square'/%3e%3c/svg%3e");
 */
  transition-duration: var(--duration-300, 300ms);
  transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
  transition-timing-function: var(--ease-out-sine, cubic-bezier(0.39, 0.575, 0.565, 1));
  -webkit-user-select: none;
          user-select: none;
}

.drag-area--on-drag-enter {
  --mds-input-upload-drag-area-background-color: var(--mds-input-upload-drag-area-background-color-on-drag, rgb(var(--magma-wash-soft, var(--tone-neutral-10, 237 237 237))));
  --mds-input-upload-drag-area-border: var(--mds-input-upload-drag-area-border-on-drag);
}

.icon {
  @apply svg;

  fill: rgb(var(--magma-text-muted, var(--text-neutral-muted, 73 73 73)));
  width: --spacing(600);
}

.action {
  border-radius: var(--magma-radius-full, var(--radius-full, 1000px));
  fill: rgb(var(--magma-text-subtle, var(--text-neutral-subtle, 99 99 99)));
  height: auto;
  padding: --spacing(150);
}

.action--cancel-upload:focus-visible,
.action--cancel-upload:hover {
  --mds-button-background: rgb(var(--magma-danger-wash-base, var(--status-error-09, 255 214 211)));

  fill: rgb(var(--magma-danger-emphasis, var(--status-error-04, 196 64 65)));
}

.action--retry-upload:focus-visible,
.action--retry-upload:hover {
  --mds-button-background: rgb(var(--magma-success-wash-base, var(--status-success-09, 191 233 205)));

  fill: rgb(var(--magma-success-emphasis, var(--status-success-04, 0 128 57)));
}

.main-action {
  @apply grid-cols-full;

  display: grid;
  gap: --spacing(200);
  pointer-events: none;
  text-align: center;
}

.main-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: --spacing(200);
  justify-content: center;
}

.main-action-icon {
  align-items: center;
  display: inline-flex;
  justify-content: center;
}

.file-list,
.main-infos {
  @apply grid-cols-full;

  display: grid;
  gap: --spacing(100);
}

.file-list {
  @apply grid-cols-fit-sm;

  --cols: var(--mds-input-upload-min-cols, 3);
  --perc-w: calc(100% / var(--cols));
  --gap: --spacing(400);
  --gap-w: calc(var(--gap) - calc(var(--gap) / var(--cols)));
  --max-w: calc(var(--perc-w) - var(--gap-w));
  --template-cols: repeat(auto-fit, minmax(--spacing(4000), var(--max-w)));

  gap: --spacing(400);
  grid-template-columns: var(--template-cols);
}

.file-list--more-items {
  --template-cols: repeat(auto-fit, minmax(--spacing(4000), 1fr));
}

.main-infos {
  min-width: 0;
  text-align: center;
  width: 100%;
}

.progress-bar {
  justify-self: center;
  max-width: --spacing(8000);
  min-width: 0;
  width: 100%;
}

.additional-infos {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: --spacing(400);
  justify-content: space-between;
}

.file-specs {
  display: flex;
  flex-grow: 1;
  flex-wrap: wrap;
  gap: --spacing(100) --spacing(400);
  justify-content: space-between;
}

.action-sort {
  display: inline-flex;
}

.file-specs.file-specs-sort {
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: center;
}

@container (max-width: 340px) {
  .file-list {
    --template-cols: 1fr;
  }

  .main-actions {
    flex-direction: column;
  }
}

/* :disabled also covers a disabled fieldset around the component, which sets no attribute */

:host([disabled]:not([disabled='false'])) .drag-area,
:host(:disabled:not([disabled='false'])) .drag-area {
  background-color: rgb(var(--magma-wash-soft, var(--tone-neutral-10, 237 237 237)));
  color: rgb(var(--magma-text-disabled, var(--text-neutral-disabled, 119 119 119)));
  cursor: not-allowed;
}

:host([disabled]:not([disabled='false'])) .icon,
:host(:disabled:not([disabled='false'])) .icon {
  fill: rgb(var(--magma-text-disabled, var(--text-neutral-disabled, 119 119 119)));
}

