/* CloudDrive Skeleton Loaders v0.2.8
   Apple/Huawei style shimmer skeletons replacing .spinner */

:root {
  --skeleton-base: rgba(128,128,140,.12);
  --skeleton-shine: rgba(128,128,140,.20);
}

/* Pulse animation */
@keyframes skeleton-pulse {
  0%, 100% { opacity: .45; }
  50% { opacity: .85; }
}

/* Shimmer animation */
@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* --- Base skeleton --- */
.skeleton {
  background: var(--skeleton-base);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--skeleton-shine) 40%,
    transparent 70%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.8s ease-in-out infinite;
}

/* --- Skeleton variants --- */
.skeleton-text {
  height: 14px;
  border-radius: 7px;
  margin-bottom: 8px;
}

.skeleton-text.short  { width: 60%; }
.skeleton-text.medium { width: 80%; }
.skeleton-text.long   { width: 95%; }

.skeleton-title {
  height: 20px;
  border-radius: 10px;
  width: 70%;
  margin-bottom: 10px;
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
}

.skeleton-thumb {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
}

.skeleton-card {
  background: var(--cd-surface);
  border: 1px solid var(--cd-line);
  border-radius: 14px;
  padding: 16px;
  display: grid;
  gap: 10px;
}

.skeleton-chip {
  height: 28px;
  width: 72px;
  border-radius: 999px;
}

/* --- File card skeletons --- */
.skeleton-file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--cd-surface);
  border: 1px solid var(--cd-line);
  border-radius: 12px;
}

.skeleton-file-row .skeleton-avatar { width: 36px; height: 36px; border-radius: 8px; }

.skeleton-file-row .skeleton-meta {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 6px;
}

.skeleton-file-card {
  background: var(--cd-surface);
  border: 1px solid var(--cd-line);
  border-radius: 14px;
  overflow: hidden;
}

.skeleton-file-card .skeleton-thumb { aspect-ratio: 4/3; border-radius: 0; }

.skeleton-file-card .skeleton-body {
  padding: 12px;
  display: grid;
  gap: 6px;
}

/* --- Preview skeleton --- */
.skeleton-preview {
  display: grid;
  place-items: center;
  height: 100%;
  width: 100%;
}

.skeleton-preview .skeleton-frame {
  width: min(640px, 80vw);
  height: min(480px, 60vh);
  border-radius: 16px;
}

/* --- Grid skeleton container --- */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.skeleton-list {
  display: grid;
  gap: 8px;
}

/* --- Dark mode --- */
[data-theme="dark"] .skeleton {
  --skeleton-base: rgba(255,255,255,.06);
  --skeleton-shine: rgba(255,255,255,.10);
}

/* --- Spinner replacement --- */
.spinner-modern {
  width: 32px;
  height: 32px;
  border: 3px solid var(--cd-line);
  border-top-color: var(--cd-blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Loading overlay --- */
.loading-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--pv-bg, rgba(0,0,0,.94));
  z-index: 2;
}

/* --- Staggered entrance for skeletons --- */
@keyframes skeleton-enter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.skeleton-enter {
  animation: skeleton-enter .35s cubic-bezier(.34,1.56,.64,1) both;
}

/* Delayed children */
.skeleton-enter:nth-child(1) { animation-delay: .00s; }
.skeleton-enter:nth-child(2) { animation-delay: .04s; }
.skeleton-enter:nth-child(3) { animation-delay: .08s; }
.skeleton-enter:nth-child(4) { animation-delay: .12s; }
.skeleton-enter:nth-child(5) { animation-delay: .16s; }
.skeleton-enter:nth-child(6) { animation-delay: .20s; }
.skeleton-enter:nth-child(7) { animation-delay: .24s; }
.skeleton-enter:nth-child(8) { animation-delay: .28s; }
