/* interactions.css — Micro-interactions and motion design */

/* ─── 1. Submit button: loading → success states ─── */

.add-submit-btn {
  transition: transform 0.15s ease, background 0.15s ease;
}

.add-submit-btn:active {
  transform: scale(0.9);
}

.add-submit-btn.is-saving {
  pointer-events: none;
  animation: pulse 0.8s ease infinite;
}

.add-submit-btn.is-success {
  background: var(--primary-color);
  animation: popIn 0.35s ease;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.92); opacity: 0.7; }
}

@keyframes popIn {
  0% { transform: scale(0.8); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ─── 2. Nav tab underline: animated slide ─── */

.nav-tab {
  position: relative;
}

.nav-tab::after {
  display: none;
}

/* ─── 3. Featured toggle: scale + color animation ─── */

.resource-type-icon {
  transition: color 0.2s ease, transform 0.2s ease;
}

.resource-type-icon:active {
  transform: scale(0.85);
}

.resource-type-icon.featured {
  animation: featurePop 0.3s ease;
}

@keyframes featurePop {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* ─── 4. Resource list items: stagger entrance ─── */

.resource-item {
  animation: itemIn 0.25s ease both;
}

.resource-item:nth-child(1) { animation-delay: 0ms; }
.resource-item:nth-child(2) { animation-delay: 30ms; }
.resource-item:nth-child(3) { animation-delay: 60ms; }
.resource-item:nth-child(4) { animation-delay: 90ms; }
.resource-item:nth-child(5) { animation-delay: 120ms; }
.resource-item:nth-child(6) { animation-delay: 150ms; }
.resource-item:nth-child(7) { animation-delay: 180ms; }
.resource-item:nth-child(8) { animation-delay: 210ms; }
.resource-item:nth-child(9) { animation-delay: 240ms; }
.resource-item:nth-child(10) { animation-delay: 270ms; }

@keyframes itemIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Highlight newly created resource */
.resource-highlight {
  animation: highlightFade 2s ease forwards;
}

@keyframes highlightFade {
  0% { background: color-mix(in srgb, var(--primary-color) 15%, transparent); }
  100% { background: transparent; }
}

/* ─── 5. Input focus: subtle glow ─── */

.input:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 15%, transparent);
}

/* ─── 6. Theme toggle: rotation ─── */

.theme-toggle {
  transition: color 0.15s ease, background 0.15s ease, transform 0.3s ease;
}

.theme-toggle:active {
  transform: rotate(180deg);
}

/* ─── 7. File thumbnails: entrance ─── */

.file-thumb {
  animation: thumbIn 0.2s ease both;
}

@keyframes thumbIn {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ─── 8. Checkbox: animated check ─── */

.checkbox {
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.checkbox:checked {
  animation: checkPop 0.2s ease;
}

@keyframes checkPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ─── 9. Lightbox: image crossfade ─── */

.lightbox-img,
.lightbox-video {
  animation: lightboxIn 0.2s ease;
}

@keyframes lightboxIn {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ─── 10. Lightbox thumbnails: active state ─── */

.lightbox-thumb {
  transition: opacity 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.lightbox-thumb:active {
  transform: scale(0.9);
}

/* ─── 11. Filter chips: toggle pop ─── */

.filter-chip {
  transition: all 0.15s ease, transform 0.15s ease;
}

.filter-chip:active {
  transform: scale(0.93);
}

/* ─── 12. Tags: entrance in tag input ─── */

.tag-input-tags .tag {
  animation: tagIn 0.15s ease;
}

@keyframes tagIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ─── 13. Home shortcuts: hover lift ─── */

.home-shortcut {
  transition: all 0.15s ease, transform 0.15s ease;
}

.home-shortcut:hover {
  transform: translateY(-1px);
}

.home-shortcut:active {
  transform: translateY(0) scale(0.97);
}

/* ─── 14. Home recent items: hover slide ─── */

.home-recent-item {
  transition: background 0.15s ease, padding-left 0.15s ease;
}

.home-recent-item:hover {
  padding-left: 12px;
}

/* ─── 15. Step 2 toggle chips: appear ─── */

.step2-toggle-chip {
  transition: color 0.15s ease, transform 0.15s ease;
}

.step2-toggle-chip:active {
  transform: scale(0.93);
}

/* ─── 16. Sort direction button rotation ─── */

.sort-dir-btn svg {
  transition: transform 0.2s ease;
}

/* ─── 17. Bottom sheet content: stagger reveal ─── */

.sheet-details .step2-summary {
  animation: sheetContentIn 0.3s ease 0.1s both;
}

.sheet-details .step2-fields {
  animation: sheetContentIn 0.3s ease 0.2s both;
}

.sheet-details .step2-update-btn {
  animation: sheetContentIn 0.3s ease 0.3s both;
}

@keyframes sheetContentIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── 18. Form fields: reveal when toggled ─── */

.form-group {
  animation: fieldReveal 0.2s ease;
}

@keyframes fieldReveal {
  from {
    opacity: 0;
    max-height: 0;
  }
  to {
    opacity: 1;
    max-height: 200px;
  }
}

/* ─── 19. Bulk actions bar entrance ─── */

.bulk-actions {
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── 20. Progress ring: smooth rotation on start ─── */

.file-thumb-ring {
  transition: opacity 0.2s ease;
}

.file-thumb-ring-fill {
  transition: stroke-dashoffset 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── 21. Delete button: danger shake on hover ─── */

.action-delete:hover svg,
.markdown-entry-remove:hover svg {
  animation: microShake 0.3s ease;
}

@keyframes microShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

/* ─── 22. Empty state: gentle float ─── */

.empty-state-icon {
  animation: gentleFloat 3s ease-in-out infinite;
}

@keyframes gentleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ─── Reduced motion: respect user preference ─── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
