/* ===================== OPTIMIZED TREE & CHIP SYSTEM ===================== */

/* Core keyframes */
@keyframes textGlitch {
  0%, 100% { transform: translateX(0); clip-path: inset(0); }
  10% { transform: translateX(-2px); clip-path: inset(0 0 40% 0); }
  20% { transform: translateX(1px); clip-path: inset(40% 0 0 0); }
  30% { transform: translateX(-1px); clip-path: inset(20% 0 20% 0); }
}

@keyframes scanLine {
  from { opacity: 0.5; left: -100%; }
  to { opacity: 0; left: 100%; }
}

/* ===================== TREE NODES ===================== */

.tree-node-item {
  position: relative;
  overflow: hidden;
  transition: color 0.3s ease;
  border-bottom: 1px solid transparent;
}

.tree-node-item::before {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 1px;
  background-color: var(--color-nier-text-dark);
  transition: width 0.3s ease;
}

.tree-node-item .scan-line {
  position: absolute;
  inset: 0 0 auto -100%;
  width: 100%;
  height: 1px;
  background-color: var(--color-nier-text-dark);
  opacity: 0;
  z-index: 3;
  pointer-events: none;
}

/* Tree node hover effects */
.tree-node-item:hover {
  color: var(--color-nier-text-dark);
  border-bottom-color: var(--color-nier-text-dark);
}

.tree-node-item:hover::before {
  width: 100%;
}

.tree-node-item:hover span:last-of-type {
  animation: textGlitch 0.6s ease;
}

.tree-node-item:hover .scan-line {
  animation: scanLine 0.3s ease forwards;
}

.tree-node-item:active {
  transform: scale(0.98);
}

/* ===================== CHIP SYSTEM ===================== */

.chip-container {
  position: relative;
}

.chip-parent {
  position: relative;
  padding: 16px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  overflow: hidden;
  transition: transform 0.2s ease;
}

/* Parent chip gradients */
.tools-parent { background: linear-gradient(135deg, #a67c63, #8b6b52); }
.frontend-parent { background: linear-gradient(135deg, #b8916f, #a67c63); }
.backend-parent { background: linear-gradient(135deg, #c9b896, #b8916f); }
.database-parent { background: linear-gradient(135deg, #e6d7b8, #d4c4a0); }

.locked-parent {
  background: linear-gradient(135deg, #606060, #4a4a4a);
  border: none;
  cursor: not-allowed;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chip-locked-category {
  opacity: 0.7;
  flex: 1;
  min-height: 0;
}

.chip-cells-column {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.locked-content {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
}

.lock-icon {
  width: 40px;
  height: 40px;
  color: #b0b0b0;
  stroke-width: 1.5;
  opacity: 0.8;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* Chip cells */
.chip-cell {
  position: relative;
  width: 100%;
  height: 16px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: rgba(0, 0, 0, 0.1);
  cursor: pointer;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}

.chip-cell::before {
  content: '';
  position: absolute;
  inset: 1px 1px auto 1px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
}

/* Active states */
.chip-cell.cell-hovered,
.chip-cell.cell-selected {
  transform: scale(1.05) !important;
}

.chip-container.chip-hovered .chip-parent,
.chip-container.chip-selected .chip-parent {
  transform: scale(1.02) !important;
}

/* Prevent direct chip interactions */
.chip-cell:hover,
.chip-cell:focus,
.chip-cell:active {
  background: rgba(0, 0, 0, 0.1) !important;
  border: 1px solid rgba(0, 0, 0, 0.2) !important;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2) !important;
  transform: none !important;
}

.chip-cell:hover::before,
.chip-cell:focus::before,
.chip-cell:active::before,
.chip-cell.cell-hovered::before,
.chip-cell.cell-selected::before {
  background: rgba(255, 255, 255, 0.1) !important;
  height: 4px !important;
}

/* ===================== RESPONSIVE DESIGN ===================== */

@media (max-width: 768px) {
  .chip-cell {
    height: 12px;
  }

  .chip-cells-column {
    gap: 2px;
  }

  .chip-parent {
    padding: 12px;
  }
}

/* Touch devices */
@media (hover: none) {
  .tree-node-item:active::before {
    width: 100%;
  }

  .tree-node-item:active .scan-line {
    animation: scanLine 0.3s ease forwards;
  }

  .tree-node-item:active {
    color: var(--color-nier-text-dark);
  }
}
