/* Every child rule is scoped under .ds-photo-upload (0-2-0) because the control sits
   INSIDE WPForms, whose full stylesheet sets width/height:auto on
   "div.wpforms-container-full *" (0-1-1). Unscoped, the 52px thumbnail box lost and an
   uploaded photo rendered at its own size (Boring Guy staging, 2026-09-28). */
/* ===========================================
   photo-upload.css: compact photo attach for quote forms.
   2.0.0 layout from Mykyta's Guyatt quote-form states (Figma 9:5637): an outlined
   "Add photos" button with the hint beside it, small square thumbnails with a remove
   control, a quiet empty slot for the next one, and a running count. Token-driven so
   it reads as part of each site. Marker class `ds-photo-upload` (smoke-site §8b).
   =========================================== */

.ds-photo-upload {
  margin: var(--ds-space-md) 0;
  font-family: var(--ds-body-font);
  display: grid;
  gap: var(--ds-space-sm);
}

.ds-photo-upload .ds-photo-upload__label {
  display: block;
  font-size: var(--ds-fs-sm);
  font-weight: var(--ds-fw-semibold);
  color: var(--ds-dark);
  line-height: var(--ds-lh-tight);
}
/* The button text and hint already say what the control is; the label stays as the
   input's accessible name. */
.ds-photo-upload .ds-photo-upload__label--sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Button + hint on one row; the hint drops under the button on a narrow form. */
.ds-photo-upload .ds-photo-upload__row {
  display: flex;
  align-items: center;
  gap: var(--ds-space-md);
}

/* The button: outlined, compact, one line. Never a full-width drop zone. */
.ds-photo-upload .ds-photo-upload__drop {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-xs);
  min-height: var(--ds-tap-target, 44px);
  padding: 0 var(--ds-space-md);
  border: 1.5px solid var(--ds-dark);
  border-radius: var(--ds-radius-sm);
  background: var(--ds-white);
  color: var(--ds-dark);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--ds-transition-base), border-color var(--ds-transition-base), color var(--ds-transition-base);
}
.ds-photo-upload .ds-photo-upload__drop:hover { background: var(--ds-bg-elevated); }
.ds-photo-upload .ds-photo-upload__drop:focus-within { outline: 2px solid var(--ds-accent); outline-offset: 2px; }
.ds-photo-upload.is-dragover .ds-photo-upload__drop { border-color: var(--ds-accent); background: var(--ds-primary-10); }

/* At the cap the button goes quiet: still visible, no longer inviting a tap. */
.ds-photo-upload.is-full .ds-photo-upload__drop {
  border-color: var(--ds-border);
  color: var(--ds-body-light);
  cursor: default;
  background: var(--ds-white);
}

.ds-photo-upload .ds-photo-upload__icon { flex: none; display: inline-flex; color: currentColor; }
.ds-photo-upload .ds-photo-upload__icon svg { width: 20px; height: 20px; }

.ds-photo-upload .ds-photo-upload__button-text {
  font-size: var(--ds-fs-base);
  font-weight: var(--ds-fw-semibold);
  color: inherit;
}

/* Visually hidden, still focusable and clickable through the wrapping label. The
   !important is deliberate (the standard visually-hidden pattern): WPForms styles file
   inputs at a higher specificity, and a hidden input that gets its width back pushes
   the page sideways. It is anchored to the button, which is positioned. */
.ds-photo-upload .ds-photo-upload__drop { position: relative; }
.ds-photo-upload .ds-photo-upload__input {
  position: absolute !important; top: 0 !important; left: 0 !important;
  width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important;
  overflow: hidden !important; clip: rect(0 0 0 0) !important; white-space: nowrap !important;
  border: 0 !important; opacity: 0 !important;
}

.ds-photo-upload .ds-photo-upload__hint {
  margin: 0;
  font-size: var(--ds-fs-sm);
  line-height: 1.43;
  color: var(--ds-body-light);
}

/* ── Thumbnails: small fixed squares, never the photo's own size ── */

.ds-photo-upload .ds-photo-upload__previews {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0;
  padding: 8px 0 0;
  list-style: none;
}
.ds-photo-upload .ds-photo-upload__previews:empty { display: none; }

.ds-photo-upload .ds-photo-upload__item {
  position: relative;
  flex: none;
  width: 52px;
  height: 52px;
  background: var(--ds-black-8);
}
.ds-photo-upload .ds-photo-upload__item--slot { background: var(--ds-black-8); opacity: .6; }

.ds-photo-upload .ds-photo-upload__thumb {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  display: block;
  /* EXIF orientation honoured on preview (image_exif_orientation_gotcha). */
  image-orientation: from-image;
}

/* Upload progress veil: fades out when the item gets .is-done. */
.ds-photo-upload .ds-photo-upload__item:not(.ds-photo-upload__item--slot)::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--ds-white-40);
  opacity: 1;
  transition: opacity var(--ds-transition-base);
  pointer-events: none;
}
.ds-photo-upload .ds-photo-upload__item.is-done::after,
.ds-photo-upload .ds-photo-upload__item.is-error::after { opacity: 0; }
.ds-photo-upload .ds-photo-upload__item.is-error { outline: 2px solid var(--ds-error); outline-offset: -2px; }

/* Remove: a small dark disc sitting on the thumbnail's top-right corner. */
.ds-photo-upload .ds-photo-upload__remove {
  position: absolute;
  top: -8px;
  right: -8px;
  z-index: 1;
  width: 24px;
  height: 24px;
  /* Site tap-target rules (min 44px on every button) would blow this up into a block
     that covers the thumbnail; the disc is 24px, the WCAG 2.2 minimum target. */
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 2px solid var(--ds-white);
  border-radius: var(--ds-radius-full);
  background: var(--ds-dark);
  color: var(--ds-white);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.ds-photo-upload .ds-photo-upload__remove:hover { background: var(--ds-black, #000); }

.ds-photo-upload .ds-photo-upload__status {
  margin: 0;
  font-size: var(--ds-fs-sm);
  line-height: 1.43;
  color: var(--ds-body-light);
}
.ds-photo-upload .ds-photo-upload__status:empty { display: none; }
.ds-photo-upload .ds-photo-upload__status.is-error { color: var(--ds-error); }

@media (max-width: 480px) {
  .ds-photo-upload .ds-photo-upload__row { flex-direction: column; align-items: flex-start; gap: var(--ds-space-xs); }
}

/* ── Companion URL field (plain WPForms Lite text field, builder CSS class
      `ds-photo-urls`): carries the uploaded URLs into the entry + lead email,
      never shown to the visitor. ── */

.wpforms-field.ds-photo-urls,
.ds-photo-urls-wrap {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  border: 0 !important;
}
