/* r9 (John, Q5 A): file attachments in the task panel, and the file count in the table. HIG: light weights, hairlines,
   44px touch targets, nothing wider than the screen on phones (r4.1). */

/* the list: thumbnail (or file icon), name and one quiet meta line, Download and Delete */
.files { list-style: none; margin: 0; padding: 0; display: grid; min-width: 0; }
.files .file { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 0; border-bottom: 1px solid var(--hairline); min-width: 0; }
.files .file:last-child { border-bottom: 0; }
.file-thumb { flex: none; width: 40px; height: 40px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--soft); color: var(--text-2); overflow: hidden; box-shadow: inset 0 0 0 1px var(--hairline); }
.file-thumb svg { width: 20px; height: 20px; }
.file-thumb.img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-main { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
.file-name { font: 400 15px/20px var(--font-ui); color: var(--text); text-decoration: none; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
/* long names shorten in the middle (Kirby): the head ellipsizes, the tail (the type) always shows */
.file-name:has(> .fn-head) { display: flex; min-width: 0; }
.file-name > .fn-head { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: pre; }
.file-name > .fn-tail { flex: none; white-space: pre; }
/* P4-j: once measured (fitName in app.js) the head holds exactly what fits and '…' follows it with no gap; the rest
   of the name stays in the element, visually hidden */
.file-name:has(> .fn-cut) { position: relative; }
.file-name.fitted > .fn-head { flex: none; overflow: visible; text-overflow: clip; }
.file-name.fitted.cut > .fn-head::after { content: '\2026'; }
.file-name > .fn-cut { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: pre; }
a.file-name:hover { text-decoration: underline; text-underline-offset: 2px; }
.file-meta { font: 400 13px/18px var(--font-ui); color: var(--text-2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0;
  display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.file-meta.m-text { display: block; }
.file-meta.m-text > span { white-space: nowrap; }
.file-err { font: 400 13px/18px var(--font-ui); color: var(--danger); overflow-wrap: anywhere; }
.file-acts { flex: none; display: flex; align-items: center; gap: 12px; }
.file-acts > .icon-btn { flex: none; color: var(--text-2); }
.file-acts > .icon-btn svg { width: 18px; height: 18px; }
.files .file > .btn.sm { flex: none; height: 32px; min-height: 32px; font: 500 15px/1 var(--font-ui); padding: 0 12px; position: relative; }
.files .file > .btn.sm::after { content: ''; position: absolute; left: 0; right: 0; top: -6px; bottom: -6px; }

/* upload progress: a thin bar and the percent */
.up-bar { position: relative; flex: 1 1 auto; max-width: 220px; height: 4px; border-radius: 2px; background: var(--hairline); overflow: hidden; }
.up-bar > span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--primary); border-radius: 2px; transition: width .12s linear; }
.up-pct { flex: none; min-width: 3.2em; text-align: right; }
.file.failed .file-thumb { color: var(--danger); }

/* Add file (the r7 32px secondary button, 44px tap area) and the drop hint */
.file-add { display: flex; align-items: center; gap: 12px; min-width: 0; flex-wrap: wrap; }
.file-add .btn.sm { position: relative; height: 32px; min-height: 32px; padding: 0 12px; font: 500 15px/1 var(--font-ui); display: inline-flex; align-items: center; gap: 6px; }
.file-add .btn.sm::after { content: ''; position: absolute; left: 0; right: 0; top: -6px; bottom: -6px; }
.file-add .btn.sm svg { width: 16px; height: 16px; }
.file-add .small { color: var(--text-3); }

/* dragging files over the open panel: a quiet outline and a label, nothing moves */
/* (the panel is already position: fixed, so the label sits inside it) */
.detail.drop-on::after { content: 'Drop files to attach'; position: absolute; inset: 8px; z-index: 30; display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--text-3); border-radius: 12px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  font: 500 17px/22px var(--font-ui); color: var(--text); pointer-events: none; }

/* the table: a paperclip and the number of files, beside the checklist count */
.chip.att { flex: none; display: inline-flex; align-items: center; gap: 3px; background: transparent; border: 0; box-shadow: none; color: var(--text-2);
  font-variant-numeric: tabular-nums; padding: 0 4px; font-weight: 400; }
.chip.att svg { width: 13px; height: 13px; stroke-width: 1.8; }
main.grid .pt-inner .task .title-line > .chip.att { flex: none; margin-left: 4px; }

@media (max-width: 600px) {
  .files .file { gap: 10px; }
  .file-acts { gap: 10px; }
  .file-acts > .icon-btn { width: 44px; height: 44px; }
  .file-add .small { display: none; }
}

/* Duplicate's copies still being made (John, Q4): a quiet moving bar */
.up-bar.indeterminate > span { width: 30%; animation: r9-copying 1.2s ease-in-out infinite; }
@keyframes r9-copying { 0% { left: -30%; } 100% { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .up-bar.indeterminate > span { animation: none; width: 100%; opacity: .4; } }

/* Kirby, 360px and below: Download and Delete side by side with no gap (each still 44 x 44), and the meta line
   wraps onto a second line instead of ending in an ellipsis, so the uploader's name is never cut off */
@media (max-width: 360px) {
  .file-acts { gap: 0; }
  .file-meta.m-text { white-space: normal; text-overflow: clip; overflow: visible; }
  .file-meta.m-text > .m-who { white-space: normal; overflow-wrap: anywhere; }
}

/* r9.1 hotfix: the in-app image viewer (images used to open in a new tab, which has no way back in the iPhone
   home-screen app). Always closable: the X is fixed inside the safe area (notch, Dynamic Island), 44px, white on a dark
   translucent circle so it reads over any image. Light weights; nothing wider than the screen. */
.iv { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; background: rgba(0, 0, 0, calc(.94 * var(--iv-fade, 1)));
  overscroll-behavior: contain; touch-action: pinch-zoom; overflow: hidden; outline: none; }
.iv-stage { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center;
  padding: calc(56px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); }
.iv-img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: default; transition: transform .18s ease; }
.iv.dragging .iv-img { transition: none; }
.iv-close { position: fixed; z-index: 201; top: calc(8px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right));
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .55); color: #fff; box-shadow: 0 0 0 1px rgba(255, 255, 255, .28); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.iv-close svg { width: 22px; height: 22px; stroke: #fff; stroke-width: 2; }
.iv-close:hover { background: rgba(0, 0, 0, .7); }
.iv-close:focus-visible, .iv-dl:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.iv-cap { flex: none; display: flex; align-items: center; gap: 12px; min-width: 0; color: #fff;
  padding: 4px max(16px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.iv-name { flex: 1 1 auto; min-width: 0; font: 400 15px/20px var(--font-ui); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; opacity: .9; }
.iv-dl { flex: none; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; color: #fff; border-radius: 50%; }
.iv-dl svg { width: 20px; height: 20px; stroke: #fff; }
html.iv-open, html.iv-open body { overflow: hidden; }
