/* ==========================================================================
   Dropzone — drag files in, or click to choose. A <label> around a real file
   input, so choosing, keyboard, forms and `required` work without JavaScript.

   <label class="dropzone">
     <input type="file" name="files" multiple accept="image/*,.pdf">
     <i class="mi mi-cloud-upload dropzone-icon"></i>
     <span class="dropzone-title">Drop files here or <u>browse</u></span>
     <span class="dropzone-hint">PNG, JPG or PDF · up to 5 MB</span>
   </label>

   moey.js adds: drag & drop (and a hint on every dropzone while files are dragged over
   the page), paste, a file list with thumbnails and remove buttons, type / size / count
   checks (data-moey-max-size="5MB", data-moey-max-files="4"), adding up multiple picks.

   .dropzone-sm     a compact one-line zone          .dropzone-image   a single picture, previewed inside
   theme-<color> colors the icon, link and drag highlight
   ========================================================================== */

.dropzone {
  --mo-dropzone-min-height: 9.5rem;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .375rem;
  min-height: var(--mo-dropzone-min-height);
  padding: 1.5rem;
  font-size: .875rem;
  color: var(--mo-fg-2);
  text-align: center;
  cursor: pointer;
  background-color: var(--mo-control-bg, var(--mo-bg-surface));
  border: 1.5px dashed var(--mo-control-border-color);   /* a field, so it gets a border — dashed means "drop here" */
  border-radius: var(--mo-radius-card);
}
@media (prefers-reduced-motion: no-preference) {
  .dropzone { transition: background-color var(--mo-duration), border-color var(--mo-duration), scale var(--mo-duration); }
}
/* The real input: invisible but focusable, so Tab + Enter/Space opens the picker */
.dropzone > input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  opacity: 0;
}

.dropzone-icon { margin-bottom: .25rem; font-size: 2rem; color: var(--mo-theme-fg); }
.dropzone-title { font-weight: var(--mo-font-weight-semibold); color: var(--mo-fg-body); }
.dropzone-title :is(u, .dropzone-browse) { color: var(--mo-theme-fg); text-decoration: underline; text-underline-offset: .2em; }
.dropzone-hint { font-size: .8125rem; color: var(--mo-fg-3); }

.dropzone:hover { border-color: color-mix(in oklab, var(--mo-theme-fg) 55%, transparent); }
.dropzone:focus-within { border-color: var(--mo-theme-fg); outline: var(--mo-focus-ring-width) solid var(--mo-theme-focus-ring); }
/* Files are being dragged somewhere over the page: every dropzone hints it can take them */
html.is-dragging-files .dropzone { border-color: color-mix(in oklab, var(--mo-theme-fg) 55%, transparent); background-color: color-mix(in oklab, var(--mo-theme-subtle) 50%, var(--mo-control-bg, var(--mo-bg-surface))); }
/* …and over this one */
.dropzone.is-dragging {
  border-style: solid;
  border-color: var(--mo-theme-fg);
  background-color: var(--mo-theme-subtle);
  scale: 1.01;
}
.dropzone.is-dragging .dropzone-icon { animation: mo-dropzone-bob .8s ease-in-out infinite alternate; }
@keyframes mo-dropzone-bob { to { translate: 0 -4px; } }
@media (prefers-reduced-motion: reduce) { .dropzone.is-dragging { scale: none; } .dropzone.is-dragging .dropzone-icon { animation: none; } }

.dropzone:has(> input:disabled) { cursor: not-allowed; opacity: .55; }
.dropzone:has(> input:user-invalid), .dropzone.is-invalid { border-color: var(--mo-red-fg); }

/* Compact: icon and text in one row — for forms and narrow columns */
.dropzone-sm {
  --mo-dropzone-min-height: 0;
  flex-direction: row;
  justify-content: flex-start;
  gap: .75rem;
  padding: .75rem 1rem;
  text-align: start;
}
.dropzone-sm .dropzone-icon { margin: 0; font-size: 1.5rem; }
.dropzone-sm > :is(.dropzone-title, .dropzone-hint) { display: block; }
.dropzone-sm .dropzone-text { display: grid; gap: .125rem; }

/* Image: one picture, previewed inside the zone (logo, avatar, cover) */
.dropzone-image { overflow: hidden; aspect-ratio: var(--mo-dropzone-ratio, 1); min-height: 0; padding: 1rem; }
.dropzone-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.dropzone-image.has-file { border-style: solid; border-color: transparent; }
.dropzone-image.has-file > :not(.dropzone-preview, input) { position: relative; z-index: 1; opacity: 0; color: #fff; }
.dropzone-image.has-file::after {        /* a dark veil + "Change" on hover / focus */
  position: absolute;
  inset: 0;
  content: "";
  background: oklch(15% .01 258 / .5);
  opacity: 0;
  transition: opacity var(--mo-duration);
}
.dropzone-image.has-file:is(:hover, :focus-within)::after,
.dropzone-image.has-file:is(:hover, :focus-within) > :not(.dropzone-preview, input) { opacity: 1; }
.dropzone-image.has-file > .dropzone-icon, .dropzone-image.has-file .dropzone-title :is(u, .dropzone-browse) { color: #fff; }
.dropzone-image.has-file > .dropzone-hint { color: rgb(255 255 255 / .8); }

/* File list ------------------------------------------------------------------------
   moey.js renders it under the zone (or into data-moey-list="#id"). */
.dropzone-files { display: grid; gap: .5rem; padding: 0; margin: .75rem 0 0; list-style: none; }
.dropzone-files:empty { display: none; }
.dropzone-file {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem .5rem .5rem .625rem;
  font-size: .8125rem;
  background-color: color-mix(in oklab, var(--mo-fg-body) 4%, transparent);
  border-radius: var(--mo-radius-control);
}
.dropzone-file-thumb {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  overflow: hidden;
  font-size: 1.25rem;
  color: var(--mo-theme-fg);
  background: var(--mo-theme-subtle);
  border-radius: calc(var(--mo-radius-control) - 2px);
}
.dropzone-file-thumb > img { width: 100%; height: 100%; object-fit: cover; }
.dropzone-file-info { display: grid; flex: 1; gap: .125rem; min-width: 0; }
.dropzone-file-name { overflow: hidden; font-weight: var(--mo-font-weight-medium); color: var(--mo-fg-body); text-overflow: ellipsis; white-space: nowrap; }
.dropzone-file-meta { color: var(--mo-fg-3); }
.dropzone-file .progress { --mo-progress-height: .25rem; margin-top: .25rem; }
.dropzone-file:not(.is-uploading) .progress { display: none; }
.dropzone-file.is-done .dropzone-file-meta::after { content: " · Uploaded"; color: var(--mo-green-fg); }
.dropzone-file.is-error { background-color: var(--mo-red-subtle); }
.dropzone-file.is-error :is(.dropzone-file-meta, .dropzone-file-thumb) { color: var(--mo-red-fg); }
.dropzone-file.is-error .dropzone-file-thumb { background: color-mix(in oklab, var(--mo-red-fg) 12%, transparent); }
.dropzone-file > .btn-close { flex-shrink: 0; }
