/* bn-attach.css — the shared attachment component (client, 2026-10-27).
   A vanilla port of shadcn/ui's Attachment: every upload on the site shows
   the same card. Horizontal for files, vertical for images (in a group),
   with uploading / done / error states. Driven by assets/js/bn-attach.js.
   Tokens come from styles.css :root; fallbacks keep it usable anywhere. */

.att-group {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
}
.att-group:empty { display: none; }
.att-list { display: flex; flex-direction: column; gap: 8px; }
.att-list:empty { display: none; }

.att {
  position: relative; display: flex; align-items: center; gap: 10px;
  min-width: 0; box-sizing: border-box;
  padding: 8px; background: #fff;
  border: 1px solid var(--line, #e5e7eb); border-radius: 12px;
  font-family: var(--inter, Inter, system-ui, sans-serif);
  transition: border-color .15s, background-color .15s, opacity .2s, transform .2s;
  animation: att-in .2s ease;
}
@keyframes att-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.att.is-leaving { opacity: 0; transform: scale(.96); }

/* media */
.att__media {
  position: relative; flex: none; width: 40px; height: 40px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: var(--grey-100, #ededed); color: var(--grey-800, #404040);
}
.att__media svg { width: 18px; height: 18px; }
.att__media img, .att__media video { width: 100%; height: 100%; object-fit: cover; display: block; }

/* content */
.att__content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.att__title {
  margin: 0; font-size: 13px; font-weight: 500; line-height: 1.35; color: var(--ink, #111);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.att__desc {
  margin: 0; font-size: 12px; line-height: 1.35; color: var(--grey-500, #8a8a8a);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.att__bar { height: 3px; margin-top: 4px; border-radius: 99px; background: var(--grey-100, #ededed); overflow: hidden; }
.att__bar span {
  display: block; height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, var(--g1, #ff4b2b), var(--g2, #ff416c));
  transition: width .2s ease;
}
.att:not([data-state="uploading"]) .att__bar { display: none; }

/* actions */
.att__actions { flex: none; display: flex; gap: 2px; }
.att__action {
  width: 28px; height: 28px; border: 0; border-radius: 8px; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--grey-800, #404040);
  transition: background-color .15s, color .15s;
}
.att__action:hover { background: var(--grey-100, #ededed); color: var(--ink, #111); }
.att__action:focus-visible { outline: 2px solid var(--g2, #ff416c); outline-offset: 1px; }
.att__action svg { width: 16px; height: 16px; }

/* spinner */
.att__spin {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,.12); border-top-color: var(--g2, #ff416c);
  animation: att-spin .7s linear infinite;
}
@keyframes att-spin { to { transform: rotate(360deg); } }

/* states */
.att[data-state="error"] { border-color: #fecaca; background: #fff8f8; }
.att[data-state="error"] .att__desc { color: #c0392b; }
.att[data-state="error"] .att__media { color: #c0392b; background: #fee2e2; }

/* vertical (images) */
.att--v {
  flex: none; width: 132px; flex-direction: column; align-items: stretch; gap: 0;
  padding: 0; overflow: hidden; scroll-snap-align: start;
}
.att--v .att__media { width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: 0; }
.att--v .att__media svg { width: 22px; height: 22px; }
.att--v .att__content { padding: 8px 10px 9px; }
.att--v .att__actions { position: absolute; top: 6px; right: 6px; }
.att--v .att__action {
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(17,17,17,.6); color: #fff;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.att--v .att__action:hover { background: rgba(17,17,17,.8); color: #fff; }
.att--v .att__action svg { width: 14px; height: 14px; }
/* An image uploading keeps its preview, dimmed, with the spinner over it. */
.att--v[data-state="uploading"] .att__media img,
.att--v[data-state="uploading"] .att__media video { opacity: .45; }
.att--v .att__media .att__spin { position: absolute; }
.att--v[data-state="uploading"] .att__media::after { content: none; }

/* full-width vertical (a single video/photo slot) */
.att--wide { width: 100%; }
.att--wide .att__media { aspect-ratio: 16 / 9; }
.att--wide video { background: #000; }

@media (prefers-reduced-motion: reduce) {
  .att, .att__spin { animation: none; }
  .att__bar span { transition: none; }
}
