/**
 * High Velocity Labs - Interactive Branching Timeline Nodes, Clusters & Popovers
 * Companion stylesheet for node cards, cluster badges, hover popovers, and category tokens.
 * Strict HVL Standard: < 400 lines.
 */

/* Branch Nodes (Moments) */
.branch-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px 4px 6px;
  background: #ffffff;
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.28), 0 1px 4px rgba(0, 0, 0, 0.16), 0 0 0 1.5px rgba(255, 255, 255, 0.95);
  border: 1.5px solid var(--node-border, #d8c3a8);
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, border-color 0.25s ease;
  animation: bubblePopIn 0.68s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  z-index: 15;
  max-width: 180px;
  white-space: nowrap;
}

.branch-node.has-extra {
  cursor: pointer;
}

.branch-node.has-photos {
  border-color: rgba(164, 32, 56, 0.50);
}

.branch-node:hover {
  transform: translate(-50%, -50%) scale(1.08);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.38), 0 2px 8px rgba(164, 32, 56, 0.30), 0 0 0 2px var(--burgundy);
  border-color: var(--burgundy);
  z-index: 30;
}

.branch-node-avatar-wrap {
  position: relative;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.branch-node-icon-box {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--node-bg, rgba(164, 32, 56, 0.10));
  color: var(--node-color, var(--burgundy));
  flex-shrink: 0;
}

.branch-node-icon-box.is-photo-box {
  background: rgba(164, 32, 56, 0.14);
  color: var(--burgundy);
}

.branch-node-photo {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--burgundy);
}

.branch-photo-badge {
  position: absolute;
  bottom: -3px;
  right: -3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--burgundy);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #ffffff;
  box-shadow: 0 1px 4px rgba(70, 19, 0, 0.25);
  pointer-events: none;
}

.branch-photo-badge .jt-icon {
  width: 8px;
  height: 8px;
}

.branch-photo-title-icon {
  color: var(--burgundy);
  vertical-align: -1px;
  margin-left: 2px;
}

.branch-node-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  line-height: 1.15;
}

.branch-node-date {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--burgundy);
  font-family: var(--font-serif-body);
}

.branch-node-title {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

/* Cluster Bubble (+N) */
.branch-cluster {
  position: absolute;
  transform: translate(-50%, -50%);
  background: var(--burgundy);
  color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: var(--radius-pill);
  padding: 4px 11px;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.32), 0 2px 6px rgba(164, 32, 56, 0.35);
  cursor: pointer;
  pointer-events: auto;
  z-index: 20;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s ease, box-shadow 0.2s ease;
  animation: bubblePopIn 0.68s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}

.branch-cluster:hover {
  transform: translate(-50%, -50%) scale(1.14);
  background: var(--burgundy-dark);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(164, 32, 56, 0.40);
}

.branch-cluster .branch-photo-badge {
  position: absolute;
  bottom: -4px;
  right: -5px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  color: var(--burgundy);
  border: 1.5px solid var(--burgundy);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(70, 19, 0, 0.28);
}

.branch-cluster .branch-photo-badge .jt-icon {
  width: 8px;
  height: 8px;
}

/* Rich Floating Hover Popover (Always Bounded in Viewport) */
.branch-popover {
  position: absolute;
  z-index: 50;
  background: #ffffff;
  border: 1.5px solid var(--burgundy);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-lg);
  max-width: 290px;
  max-height: 250px;
  overflow-y: auto;
  pointer-events: auto;
  font-family: var(--font-sans);
  animation: popoverFadeIn 0.15s ease-out;
  scrollbar-width: thin;
  scrollbar-color: rgba(164, 32, 56, 0.35) transparent;
}

.branch-popover.popover-above {
  transform: translate(-50%, -100%);
  margin-top: -10px;
}

.branch-popover.popover-below {
  transform: translate(-50%, 0);
  margin-top: 10px;
}

@keyframes popoverFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.branch-popover-date {
  font-family: var(--font-serif-body);
  font-weight: 700;
  font-size: 0.80rem;
  color: var(--burgundy);
  margin-bottom: 2px;
}

.branch-popover-title {
  font-size: 0.90rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 5px;
  line-height: 1.25;
}

.branch-popover-desc {
  font-size: 0.80rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 6px;
  max-height: 120px;
  overflow-y: auto;
}

.branch-popover-hint {
  font-size: 0.70rem;
  color: var(--burgundy);
  font-weight: 600;
  border-top: 1px dashed rgba(164, 32, 56, 0.2);
  padding-top: 5px;
}

.branch-popover-hint.is-clickable {
  cursor: pointer;
  transition: color 0.15s ease, transform 0.15s ease;
}

.branch-popover-hint.is-clickable:hover {
  color: var(--burgundy-dark);
  text-decoration: underline;
}

.branch-cluster-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 8px;
  max-height: 160px;
  overflow-y: auto;
}

.branch-cluster-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 7px;
  border-radius: var(--radius-xs);
  background: rgba(164, 32, 56, 0.04);
  cursor: default;
  font-size: 0.78rem;
  color: var(--text-primary);
}

.branch-cluster-item.has-extra {
  cursor: pointer;
  transition: all 0.15s ease;
}

.branch-cluster-item.has-extra:hover {
  background: var(--burgundy-subtle);
  color: var(--burgundy);
}

.branch-cluster-item-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.branch-cluster-item-date {
  font-size: 0.70rem;
  color: var(--burgundy);
  font-weight: 700;
  flex-shrink: 0;
}

.branch-cluster-item-icon-box {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--burgundy-subtle);
  color: var(--burgundy);
  flex-shrink: 0;
}

.branch-cluster-item-icon-box .branch-photo-badge {
  position: absolute;
  bottom: -3px;
  right: -4px;
  width: 10px;
  height: 10px;
}

.branch-cluster-item-icon-box .branch-photo-badge .jt-icon {
  width: 6px;
  height: 6px;
}

.branch-cluster-badge {
  font-size: 0.65rem;
  background: var(--burgundy-subtle);
  color: var(--burgundy);
  padding: 1px 5px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  margin-left: auto;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.branch-popover-photo-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--burgundy-subtle);
  color: var(--burgundy);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  margin-left: 6px;
}

/* Category Color Mappings */
.cat-wedding {
  --node-color: var(--cat-wedding);
  --node-bg: var(--cat-wedding-bg);
  --node-border: var(--cat-wedding-border);
  --stem-color: var(--cat-wedding);
}

.cat-travel {
  --node-color: var(--cat-travel);
  --node-bg: var(--cat-travel-bg);
  --node-border: var(--cat-travel-border);
  --stem-color: var(--cat-travel);
}

.cat-family,
.cat-dating {
  --node-color: var(--cat-family);
  --node-bg: var(--cat-family-bg);
  --node-border: var(--cat-family-border);
  --stem-color: var(--cat-family);
}

.cat-fun {
  --node-color: var(--cat-fun);
  --node-bg: var(--cat-fun-bg);
  --node-border: var(--cat-fun-border);
  --stem-color: var(--cat-fun);
}

.cat-career {
  --node-color: var(--cat-career);
  --node-bg: var(--cat-career-bg);
  --node-border: var(--cat-career-border);
  --stem-color: var(--cat-career);
}

.cat-milestone {
  --node-color: var(--cat-milestone);
  --node-bg: var(--cat-milestone-bg);
  --node-border: var(--cat-milestone-border);
  --stem-color: var(--cat-milestone);
}
