/* The contact form's uploader (js/uploads.js; site_web::forms, docs/uploads.md), in the
   hand-built selects' language (css/controls.css): the fields' border, radius, hover and
   accent focus ring; the accent tint for what's active. Needs tokens.css and
   components.css. No inline styles (the CSP refuses them): the script sets only custom
   properties through the CSSOM (--p, a file's progress from 0 to 1, and --fill, its
   colour from amber to green). */

.uploader-field { grid-column: 1 / -1; display: grid; gap: 8px; min-width: 0; }
.uploader { display: grid; gap: 8px; min-width: 0; }

/* ---------- The slim row, and the drop area it opens into ---------- */
.uploader-drop {
  position: relative; display: flex; align-items: center; justify-content: flex-start; gap: 12px;
  width: 100%; min-height: 50px; padding: 11px 14px; text-align: left;
  border: 1px dashed var(--control); border-radius: var(--radius); background: var(--paper);
  font-size: 15px; line-height: 1.4; color: var(--ink-2); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: min-height .26s var(--ease-out), padding .26s var(--ease-out), background-color .2s ease,
    border-color .2s ease, box-shadow .2s ease, gap .26s var(--ease-out);
}
.uploader-drop:hover { border-color: var(--slate); background: var(--wash); }
.uploader-drop:focus { outline: none; }
.uploader-drop:focus-visible {
  border-color: var(--accent); border-style: solid;
  box-shadow: 0 0 0 1px var(--accent), 0 0 0 3px rgba(70, 54, 240, .28);
}
.uploader-mark {
  flex: none; width: 22px; height: 22px; color: var(--accent);
  transition: width .26s var(--ease-out), height .26s var(--ease-out);
}
.uploader-text { min-width: 0; }
.uploader-label { font-weight: 600; color: var(--ink); }
.uploader-dash { color: var(--soft); }
.uploader-prompt { color: var(--slate); }
.uploader-browse {
  color: var(--accent); font-weight: 500; text-decoration: underline; text-underline-offset: .2em;
  text-decoration-thickness: 1px;
}
.uploader-drop:hover .uploader-browse { color: var(--accent-hover); }

/* Files dragged over the form: the row opens into a larger drop area. */
.uploader.is-dragging .uploader-drop {
  min-height: 148px; padding: 22px 18px; flex-direction: column; justify-content: center; gap: 10px;
  text-align: center; border: 2px dashed var(--accent); background: var(--accent-tint);
}
.uploader.is-dragging .uploader-mark { width: 38px; height: 38px; }
.uploader.is-over .uploader-drop { background: var(--accent-tint-2); box-shadow: 0 0 0 4px rgba(70, 54, 240, .12); }
.uploader.is-dragging .uploader-text { animation: uploader-text-in .26s var(--ease-out); }
.uploader.is-full .uploader-drop { cursor: not-allowed; }

.uploader-hint { margin: 0; }
.uploader-noscript { margin: 0; }
.uploader-status { margin: 0; }

/* ---------- One row per file ---------- */
.uploader-list { display: grid; gap: 8px; list-style: none; margin: 0; padding: 0; }
.uploader-list:empty { display: none; }
.upload {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 4px 12px;
  padding: 9px 8px 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--paper); animation: upload-in .24s var(--ease-out);
  transition: border-color .2s ease, background-color .2s ease;
}
.upload.is-leaving { animation: upload-out .18s ease-in forwards; }

/* The mark that fills from the bottom up, with its percentage. */
.upload-progress { display: inline-flex; align-items: center; gap: 8px; min-width: 76px; }
.upload-mark { flex: none; display: block; width: 30px; height: 30px; overflow: visible; color: var(--ink-2); }
.upload-fill {
  fill: var(--fill, hsl(38, 92%, 50%)); transform: scaleY(var(--p, 0)); transform-box: fill-box; transform-origin: 50% 100%;
  transition: transform .3s var(--ease-out), fill .3s ease;
}
.upload-pct {
  min-width: 4ch; font-size: 13.5px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums;
}
.upload-body { display: grid; gap: 1px; min-width: 0; }
.upload-name { font-size: 15px; font-weight: 500; color: var(--ink); overflow-wrap: anywhere; }
.upload-meta { font-size: 13px; color: var(--slate); font-variant-numeric: tabular-nums; }
.upload-check { width: 18px; height: 18px; color: var(--ok); opacity: 0; transform: scale(.5); transition: opacity .2s ease, transform .3s var(--ease-out); }
.upload[data-state="done"] .upload-check { opacity: 1; transform: none; }
.upload[data-state="done"] .upload-pct { color: var(--ok); }

.upload-remove {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px;
  color: var(--slate); background: transparent; cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.upload-remove svg { width: 11px; height: 11px; }
.upload-remove:hover { background: var(--wash-2); color: var(--ink); }
.upload-remove:focus-visible { outline: var(--focus); outline-offset: 1px; }

/* An error: the row says why (not only its colour). */
.upload[data-state="error"] { border-color: var(--bad); background: var(--bad-bg); }
.upload[data-state="error"] .upload-mark { color: var(--bad); }
.upload[data-state="error"] .upload-fill { opacity: 0; }
.upload[data-state="error"] .upload-pct { color: var(--bad); }
.upload[data-state="error"] .upload-meta { color: var(--bad); font-weight: 500; }

@media (max-width: 520px) {
  .upload { grid-template-columns: auto minmax(0, 1fr) auto; }
  .upload-progress { min-width: 0; flex-direction: column; gap: 2px; }
  .upload-pct { min-width: 0; font-size: 12px; text-align: center; }
  .upload-check { grid-column: 2; grid-row: 2; display: none; }
  .uploader-dash { display: none; }
  .uploader-label { display: block; }
}

@keyframes upload-in { from { opacity: 0; transform: translateY(-4px); } }
@keyframes upload-out { to { opacity: 0; transform: translateY(-4px); } }
@keyframes uploader-text-in { from { opacity: .4; } }

/* Reduced motion: no opening animation, no fill moving; the percentage tells the
   progress, and a finished file's mark shows full. */
@media (prefers-reduced-motion: reduce) {
  .uploader-drop, .uploader-mark, .upload, .upload-check { transition: none; animation: none; }
  .upload.is-leaving { animation: none; }
  .uploader.is-dragging .uploader-text { animation: none; }
  .upload-fill { transition: none; }
  .upload:not([data-state="done"]) .upload-fill { opacity: 0; }
}

@media (forced-colors: active) {
  .upload-fill { fill: Highlight; }
  .uploader-drop { border-color: CanvasText; }
  .upload[data-state="error"] { border-color: Mark; }
}
