/**
 * CollectionView CSS
 * High-performance virtualized collection view styles
 */

/* ===========================================
   Container Structure
   =========================================== */

.cv-scroll-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.cv-scroll-container::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.cv-content {
  position: relative;
  width: 100%;
}

/* ===========================================
   Elements - All Absolutely Positioned
   =========================================== */

.cv-hero,
.cv-title,
.cv-cell {
  position: absolute;
  left: 0;
  top: 0;
  box-sizing: border-box;
}

/* Hero */
.cv-hero {
  width: 100%;
}

/* Section Title */
.cv-title {
  width: 100%;
  display: flex;
  align-items: flex-end;
  padding: 16px 16px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary, #8e8e93);
  letter-spacing: 0.02em;
  background: transparent;
}

/* Cell */
.cv-cell {
  overflow: hidden;
  background: var(--cv-cell-bg, #eee);
  border-radius: var(--cv-cell-radius, 2px);
  cursor: pointer;
}

/* Hover/Touch Border Overlay */
.cv-cell::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 3px solid rgba(255, 255, 255, 0.5);
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease-out;
}

@media (hover: hover) and (pointer: fine) {
  .cv-cell:hover::after { opacity: 1; }
}

@media (hover: none) and (pointer: coarse) {
  .cv-cell:active::after { opacity: 1; transition: opacity 0.05s ease-out; }
}

.cv-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ===========================================
   Animation
   =========================================== */

.cv-cell-new {
  animation: cv-fade-in 300ms ease-out forwards;
}

@keyframes cv-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ===========================================
   Placeholder Shimmer
   =========================================== */

.cv-cell .placeholder-shimmer,
.cv-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    var(--cv-shimmer-from, #eee) 25%,
    var(--cv-shimmer-to, #f5f5f5) 50%,
    var(--cv-shimmer-from, #eee) 75%
  );
  background-size: 200% 100%;
  animation: cv-shimmer 1.5s infinite;
}

@keyframes cv-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ===========================================
   Sticky Label
   =========================================== */

.cv-sticky-label {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-radius: 16px;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.cv-sticky-label.cv-sticky-visible {
  opacity: 1;
}

/* ===========================================
   Scrubber
   =========================================== */

.cv-scrubber-container {
  position: fixed;
  /* top, right, height set by JS based on scroll container bounds */
  z-index: 100;
  pointer-events: none;
}

.cv-scrubber {
  width: 44px;
  height: 100%;
  /* Visibility controlled by thumb opacity */
}

.cv-scrubber-track {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 20px;
  width: 3px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 1.5px;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.cv-scrubber.cv-dragging .cv-scrubber-track {
  opacity: 1;
}

.cv-scrubber-thumb {
  position: absolute;
  right: 0;
  width: 44px;
  height: 44px;
  /* glass class provides background, blur, border */
  border-radius: 50%;
  cursor: pointer;
  touch-action: none;
  opacity: 0;
  pointer-events: auto; /* Always receive taps, even when hidden */
  transition: transform 0.1s ease, background 0.15s ease, opacity 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cv-scrubber-visible .cv-scrubber-thumb {
  opacity: 1;
}

/* Left-pointing arrow indicator */
.cv-scrubber-thumb::before {
  content: '';
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 7px solid rgba(255, 255, 255, 0.7);
  margin-right: 2px;
}

/* glass-interactive class provides hover/press scale feedback */

.cv-scrubber.cv-dragging .cv-scrubber-thumb {
  cursor: grabbing;
}

/* ===========================================
   CSS Custom Properties (Theming)
   =========================================== */

/*
  Available CSS custom properties:

  --color-text-secondary: #8e8e93
  --cv-cell-bg: #eee
  --cv-cell-radius: 2px
  --cv-shimmer-from: #eee
  --cv-shimmer-to: #f5f5f5
*/

/* ===========================================
   Dark Mode Example
   =========================================== */

@media (prefers-color-scheme: dark) {
  :root {
    --color-text-secondary: #8e8e93;
    --cv-cell-bg: #2a2a2a;
    --cv-shimmer-from: #2a2a2a;
    --cv-shimmer-to: #333;
  }
}
