/* ============================================================
   DOKUMENTER — Fluid Grid + Card Animations
   Replaces fixed-breakpoint grid with auto-fill fluid layout,
   adds entrance/exit animations, improved hover, and a11y focus.
   ============================================================ */


/* ── 1. Fluid Grid ──────────────────────────────────────────
   auto-fill + minmax replaces the old repeat(3, 1fr) and
   the @media 1100px / 767px column overrides.
   Cards reflow naturally from 1-col on small screens to
   as many columns as fit on wide ones.
   ────────────────────────────────────────────────────────── */

.doc-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* Keep the tighter gap on small screens */
@media (max-width: 767px) {
  .doc-grid {
    gap: 12px;
  }
}


/* ── 2. Card Entrance Animation ─────────────────────────────
   Staggered fade-in: each card slides up 12px and fades in.
   40ms delay per card, up to 12 cards.
   Skeleton cards are excluded so they stay immediately visible.
   ────────────────────────────────────────────────────────── */

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

.doc-card {
  animation: docCardFadeIn 300ms ease-out both;
}

/* Stagger delays — 40ms intervals, cards 1-12 */
.doc-card:nth-child(1)  { animation-delay:   0ms; }
.doc-card:nth-child(2)  { animation-delay:  40ms; }
.doc-card:nth-child(3)  { animation-delay:  80ms; }
.doc-card:nth-child(4)  { animation-delay: 120ms; }
.doc-card:nth-child(5)  { animation-delay: 160ms; }
.doc-card:nth-child(6)  { animation-delay: 200ms; }
.doc-card:nth-child(7)  { animation-delay: 240ms; }
.doc-card:nth-child(8)  { animation-delay: 280ms; }
.doc-card:nth-child(9)  { animation-delay: 320ms; }
.doc-card:nth-child(10) { animation-delay: 360ms; }
.doc-card:nth-child(11) { animation-delay: 400ms; }
.doc-card:nth-child(12) { animation-delay: 440ms; }

/* Skeleton cards must not animate — they show instantly */
.doc-card.skeleton-card {
  animation: none;
  opacity: 1;
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  .doc-card {
    animation: none;
    opacity: 1;
  }
  .doc-card.deleting {
    animation: none;
    opacity: 0;
  }
}


/* ── 3. Card Delete (Exit) Animation ────────────────────────
   Card slides right and shrinks slightly before removal.
   JS adds .deleting, waits 200ms, then removes the DOM node.
   ────────────────────────────────────────────────────────── */

@keyframes docCardExit {
  to {
    opacity: 0;
    transform: translateX(16px) scale(0.97);
  }
}

.doc-card.deleting {
  animation: docCardExit 200ms ease-out forwards;
  pointer-events: none;
}


/* ── 4. Improved Hover ──────────────────────────────────────
   Adds a subtle border-color shift on hover alongside the
   existing translateY(-2px) lift and shadow change.
   A 1px transparent border is added to the base state so the
   border-color transition doesn't cause layout shift.
   ────────────────────────────────────────────────────────── */

.doc-card {
  border: 0.5px solid transparent;
  transition:
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.doc-card:hover {
  border-color: rgba(31, 31, 30, 0.08);
}


/* ── 5. Focus-Visible Ring (keyboard a11y) ──────────────────
   High-contrast focus indicator for Tab navigation.
   .focused class mirrors the ring for programmatic focus.
   ────────────────────────────────────────────────────────── */

.doc-card:focus-visible {
  outline: 2px solid rgba(31, 31, 30, 0.3);
  outline-offset: -2px;
}

.doc-card.focused {
  box-shadow: 0 0 0 2px rgba(31, 31, 30, 0.3);
}


/* ── 3.5 Skeleton → Content Cross-Fade ─────────────────── */

.doc-grid {
  transition: opacity 0.3s ease;
}

.doc-grid:not(.doc-grid--loaded) .doc-card:not(.skeleton-card) {
  opacity: 0;
}

.doc-grid.doc-grid--loaded .doc-card:not(.skeleton-card) {
  opacity: 1;
}

/* ── 4.4 Animated View Transitions (Grid ↔ List) ──────── */

.doc-grid {
  transition: opacity 0.2s ease;
}

.doc-grid.doc-grid--list .doc-card {
  animation: none;
}
