/* Interactions: hold to delete, import animation (folder), drop veil documents. */

/* ---------- Hold to delete ---------- */
.btn[data-hold] { position: relative; isolation: isolate; overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.btn[data-hold]:active { opacity: 1; }
.hold-fill {
  position: absolute; inset: 0; z-index: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: inherit; padding: inherit;
  border-radius: inherit;
  background: color-mix(in srgb, var(--red) 16%, var(--surface));
  color: var(--red);
  clip-path: inset(0 100% 0 0);
  transition: clip-path 380ms var(--ease-out);
  pointer-events: none;
}
.btn[data-hold].is-holding { transform: scale(0.96); opacity: 1; }
.btn[data-hold].is-holding .hold-fill { clip-path: inset(0 0 0 0); transition: clip-path var(--hold-ms, 1000ms) linear; }
.btn[data-hold].is-held .hold-fill { clip-path: inset(0 0 0 0); transition: none; }
.btn[data-hold]:is(.is-holding, .is-held) { opacity: 1 !important; }
/* Round icon buttons: the fill grows from the centre and a red ring goes round. */
@property --hold-p { syntax: "<number>"; inherits: false; initial-value: 0; }
.btn-icon[data-hold]:hover { color: var(--red); background: var(--fill-2); }
.btn-icon[data-hold] .hold-fill { background: color-mix(in srgb, var(--red) 20%, var(--surface)); clip-path: circle(0% at 50% 50%); }
.btn-icon[data-hold].is-holding .hold-fill { clip-path: circle(72% at 50% 50%); }
.btn-icon[data-hold].is-held .hold-fill { clip-path: circle(72% at 50% 50%); }
.btn-icon[data-hold]::after {
  content: ""; position: absolute; inset: 0; z-index: 2; border-radius: 50%; pointer-events: none;
  background: conic-gradient(var(--red) calc(var(--hold-p) * 1turn), transparent 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px));
  transition: --hold-p 320ms var(--ease-out);
}
.btn-icon[data-hold].is-holding::after { --hold-p: 1; transition: --hold-p var(--hold-ms, 1000ms) linear; }
.btn-icon[data-hold].is-held::after { --hold-p: 1; transition: none; }
.reduce-motion .btn-icon[data-hold].is-holding::after { transition-duration: var(--hold-ms, 1000ms) !important; }

/* Confirm button of a destructive dialog: soft red at rest, full red when held. */
.btn-hold { background: var(--red-soft); color: var(--red); box-shadow: none; padding: 0 1.1rem; }
.btn-hold:hover { background: color-mix(in srgb, var(--red) 16%, transparent); }
.btn-hold .hold-fill { background: var(--red); color: #fff; }

.btn[data-hold].is-nudge { animation: hold-nudge 360ms var(--ease) both; }
@keyframes hold-nudge { 20% { translate: -2px 0; } 45% { translate: 2px 0; } 70% { translate: -1px 0; } }

/* Reduced motion keeps the fill (it is the feedback), only the shake goes. */
.reduce-motion .btn[data-hold].is-holding .hold-fill { transition-duration: var(--hold-ms, 1000ms) !important; }

/* ---------- Documents and folder (import card, drop veil) ---------- */
.fx-art { position: relative; width: 10rem; height: 7.4rem; }
.fx-docs { position: absolute; inset: 0; display: grid; place-items: center; transition: opacity var(--m-300) var(--ease), transform var(--m-300) var(--ease-out); }
.fx-doc, .fx-sheet {
  border-radius: var(--r-s);
  background:
    linear-gradient(var(--sep-2) 0 0) 0.7rem 2.35rem / 2.5rem 2px no-repeat,
    linear-gradient(var(--sep-2) 0 0) 0.7rem 2.9rem / 3rem 2px no-repeat,
    linear-gradient(var(--sep-2) 0 0) 0.7rem 3.45rem / 1.9rem 2px no-repeat,
    var(--surface);
  box-shadow: 0 0 0 1px var(--sep-2), 0 12px 24px -16px color-mix(in srgb, var(--petrol) 55%, transparent);
}
.fx-doc { grid-area: 1 / 1; width: 4.5rem; height: 5.6rem; transition: transform var(--m-300) var(--ease-out); }
.fx-doc.d1 { transform: translate(-0.75rem, 0.3rem) rotate(-9deg); }
.fx-doc.d2 { transform: translate(0.75rem, 0.25rem) rotate(8deg); }
.fx-doc.d3 { display: grid; align-content: space-between; justify-items: start; padding: 0.6rem; transform: translateY(-0.1rem); }
.fx-doc.d3 .i { width: 1.05rem; height: 1.05rem; color: var(--accent-text); }
.fx-doc.d3 b { padding: 0.2em 0.5em; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: 0.625rem; font-weight: 700; letter-spacing: 0.04em; line-height: 1.2; }

.fx-folder { position: absolute; left: 50%; bottom: 0; width: 8.5rem; height: 6.5rem; margin-left: -4.25rem; perspective: 500px; opacity: 0; transform: translateY(1rem) scale(0.9); transition: opacity var(--m-300) var(--ease), transform var(--m-300) var(--ease-out); }
.fx-folder-back { position: absolute; inset: 0.75rem 0 0; border-radius: 6px 14px 14px 14px; background: color-mix(in srgb, var(--signal) 70%, var(--petrol)); }
.fx-folder-back::before { content: ""; position: absolute; left: 0; top: -0.65rem; width: 44%; height: 1rem; border-radius: 9px 9px 0 0; background: inherit; }
.fx-sheet { position: absolute; top: 0.3rem; left: 12%; right: 12%; height: 4.4rem; border-radius: 7px; }
.fx-sheet.s2 { top: 0.6rem; left: 20%; right: 7%; }
.fx-folder-front {
  position: absolute; inset: auto 0 0; height: 4.5rem;
  display: flex; align-items: flex-end; gap: 0.5rem; padding: 0.6rem 0.65rem;
  border-radius: 10px 10px 14px 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--signal) 76%, white), var(--signal) 55%, color-mix(in srgb, var(--signal) 86%, var(--petrol)));
  box-shadow: inset 0 1px 0 color-mix(in srgb, white 60%, transparent), 0 16px 30px -16px color-mix(in srgb, var(--signal) 80%, var(--petrol));
  color: var(--petrol); text-align: left; transform-origin: 50% 100%;
}
.fx-mark { width: 1.4rem; height: 1.4rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fx-mark-dot { stroke-width: 3.2; }
.fx-folder-text { display: grid; gap: 0.1rem; line-height: 1.1; }
.fx-folder-text small { font-size: 0.625rem; font-weight: 600; opacity: 0.72; }
.fx-folder-text strong { font-size: var(--t-foot); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Import card ---------- */
.import-hud { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; padding: 1.5rem; background: color-mix(in srgb, var(--bg) 72%, transparent); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fade-in 160ms ease both; }
.import-hud.is-leaving { animation: fade-out 200ms var(--ease-in) both; }
.import-card { display: grid; justify-items: center; gap: 1.1rem; width: min(22rem, 100%); padding: 2rem 1.75rem 1.6rem; border-radius: var(--r-xl); background: var(--surface-raised); box-shadow: var(--pop-shadow); text-align: center; animation: sheet-in 240ms var(--ease-out) both; }
.import-card .fx-docs { opacity: 0; transform: translateY(-1.25rem) scale(0.82); animation: fx-docs-go 520ms var(--ease-out) both; }
.import-card .fx-folder { opacity: 1; transform: none; animation: fx-folder-in 420ms var(--ease-out) 120ms both; }
.fx-title { display: inline-flex; align-items: center; gap: 0.5rem; margin: 0; font-size: var(--t-title-2); font-weight: 650; color: var(--label); }
.fx-title > span { animation: fx-word 260ms var(--ease-out) both; }
.fx-sub { margin: -0.6rem 0 0; color: var(--label-3); font-size: var(--t-callout); overflow-wrap: anywhere; }
.fx-ok { width: 1.1em; height: 1.1em; color: var(--accent-text); stroke-width: 2.2; }
.fx-spin { display: inline-block; width: 0.95em; height: 0.95em; border: 2px solid var(--accent-soft); border-top-color: var(--accent-text); border-radius: 50%; animation: fx-spin 800ms linear infinite; }

.import-card[data-stage="loading"] .fx-sheet.s1 { animation: fx-feed 1100ms cubic-bezier(0.7, 0, 0.2, 1) infinite; }
.import-card[data-stage="loading"] .fx-sheet.s2 { animation: fx-feed 1100ms cubic-bezier(0.7, 0, 0.2, 1) 550ms infinite; }
.import-card[data-stage="loading"] .fx-folder-front { animation: fx-flap 550ms cubic-bezier(0.7, 0, 0.2, 1) infinite; }
.import-card[data-stage="done"] .fx-folder { animation: fx-pop 420ms var(--ease-out); }
.import-card[data-stage="done"] .fx-mark-check { stroke-dasharray: 12; animation: fx-tick 420ms var(--ease-out) 100ms both; }

/* ---------- Drop veil: the stack fans out under the dragged file ---------- */
.drop-card .fx-art { width: 9rem; height: 6.6rem; margin-bottom: 0.4rem; }
.drop-card .fx-doc { width: 4.1rem; height: 5.1rem; }
.drop-card .fx-doc.d1 { animation: fx-fan-l 480ms var(--ease-out) 60ms both; }
.drop-card .fx-doc.d2 { animation: fx-fan-r 480ms var(--ease-out) 60ms both; }
.drop-card .fx-doc.d3 { animation: fx-lift 480ms var(--ease-out) 60ms both; }
.drop-card .fx-doc.d3 .i { width: 1rem; height: 1rem; margin: 0; }

@keyframes fx-spin { to { rotate: 1turn; } }
@keyframes fx-word { from { opacity: 0; translate: 0 4px; } }
@keyframes fx-docs-go { from { opacity: 1; transform: none; } }
@keyframes fx-folder-in { from { opacity: 0; transform: translateY(1rem) scale(0.9); } }
@keyframes fx-feed {
  0% { opacity: 0; transform: translateY(-2.75rem) rotate(-4deg); }
  22% { opacity: 1; }
  70% { opacity: 1; transform: translateY(0.5rem) rotate(0deg); }
  100% { opacity: 0; transform: translateY(1.25rem); }
}
@keyframes fx-flap { 0%, 100% { transform: rotateX(0deg); } 50% { transform: rotateX(-12deg); } }
@keyframes fx-pop { 40% { scale: 1.05; } }
@keyframes fx-tick { from { stroke-dashoffset: 12; } to { stroke-dashoffset: 0; } }
@keyframes fx-fan-l { to { transform: translate(-1.8rem, 0.35rem) rotate(-17deg); } }
@keyframes fx-fan-r { to { transform: translate(1.8rem, 0.3rem) rotate(16deg); } }
@keyframes fx-lift { to { transform: translateY(-0.6rem) scale(1.04); } }

@media (prefers-reduced-motion: reduce) {
  .btn[data-hold].is-nudge, .import-card *, .drop-card .fx-doc { animation: none !important; }
}
