/**
 * High Velocity Labs - Timeline Photo Mosaic Background
 * Ultra-high-performance 60fps GPU-accelerated ambient photo collage.
 * Zero backdrop-filters, clean hardware transforms, smooth transitions.
 * Strict HVL Standard: < 400 lines.
 */

.branch-mosaic-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2; /* Sits behind branch-nodes-layer (z-index: 10) */
  overflow: hidden;
  user-select: none;
  contain: layout paint;
}

/* Entry & Exit Keyframes (0.68s) */
@keyframes mosaicFadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes mosaicFadeOut {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* Individual Mosaic Photo Card */
.mosaic-card {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 3;
  contain: layout style;
  animation: mosaicFadeIn 0.68s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  transition: opacity 0.68s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Leaving Card: smooth 0.68s fade out */
.mosaic-card.mosaic-leaving {
  animation: mosaicFadeOut 0.68s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
  pointer-events: none !important;
  z-index: 2 !important;
}

/* Card Inner Frame (Clean, upright rectangle - zero rotation, no backdrop-filter for 60fps) */
.mosaic-card-inner {
  position: relative;
  border-radius: 7px;
  overflow: hidden;
  background: #111827;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  opacity: 0.90;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.20s ease;
}

/* Photo Thumbnail - Fast GPU Greyscale */
.mosaic-card-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  filter: grayscale(100%);
  transition: filter 0.25s ease;
}

/* Tiny Era Label (e.g., 'Feb 99', 'Sep 06') */
.mosaic-card-tag {
  position: absolute;
  bottom: 2px;
  left: 3px;
  right: 3px;
  background: rgba(0, 0, 0, 0.82);
  color: rgba(255, 255, 255, 0.92);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 1px 3px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  pointer-events: none;
  line-height: 1.2;
}

/* --- Hover State: Full Color, Grows a Bit, Shines --- */
.mosaic-card:hover {
  z-index: 8 !important; /* Strictly below foreground event bubbles at z-index: 10+ */
}

.mosaic-card:hover .mosaic-card-inner {
  transform: scale(1.15);
  opacity: 1;
  border-color: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.60), 0 0 0 1.5px var(--gold-light, #e0aa3e);
}

.mosaic-card:hover .mosaic-card-img {
  filter: grayscale(0%);
}

.mosaic-card:hover .mosaic-card-tag {
  background: rgba(164, 32, 56, 0.92);
  color: #fff;
  font-weight: 700;
}

/* --- Layout Modes --- */

/* 1. Backdrop / Floating Mode (Default - Balanced Top & Bottom) */
.branch-mosaic-layer.mode-backdrop .mosaic-card-inner {
  width: 76px;
  height: 58px;
}

/* 2. Bottom Ribbon Mode */
.branch-mosaic-layer.mode-bottom .mosaic-card-inner {
  width: 76px;
  height: 58px;
}

/* 3. Top Ribbon Mode */
.branch-mosaic-layer.mode-top .mosaic-card-inner {
  width: 76px;
  height: 58px;
}

/* During motion/drag: disable pointer events and transitions for maximum frame rate */
.branch-viewport.is-moving .mosaic-card {
  pointer-events: none !important;
  transition: none !important;
}

.branch-viewport.is-moving .mosaic-card-inner {
  transition: none !important;
}

/* Responsive Scaling for Mobile Screens */
@media (max-width: 640px) {
  .branch-mosaic-layer .mosaic-card-inner {
    width: 60px;
    height: 48px;
  }
}
