/* ============================================
   Tiers - Tier Row Styles
   ============================================ */

.tier {
  display: flex;
  margin-bottom: 6px;
  min-height: 95px;
  background: var(--bg-card);
  border-radius: 8px;
  overflow: visible;
  border: 2px solid transparent;
  transition: border-color 0.3s, background-color 0.3s;
}

[data-theme="light"] .tier {
  box-shadow: 0 2px 8px var(--shadow-color);
}

.tier:hover {
  background: rgba(255, 255, 255, 0.02);
}

[data-theme="light"] .tier:hover {
  background: rgba(0, 0, 0, 0.02);
}

.tier.drag-over {
  border: 2px solid var(--color-highlight);
  background: rgba(74, 144, 217, 0.1);
}

.tier.tap-target {
  border: 2px solid #00ff00;
  background: rgba(0, 255, 0, 0.1);
  cursor: pointer;
}

/* ============================================
   Tier Label
   ============================================ */
.tier-label {
  width: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 18px;
  color: #000;
  flex-shrink: 0;
  cursor: grab;
  position: relative;
  gap: 4px;
  user-select: none;
}

.tier-label-text {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
  word-break: break-word;
  line-height: 1.1;
}

.tier-label:active {
  cursor: grabbing;
}

/* ============================================
   Mobile: Touch Device Tier Controls
   ============================================ */
@media (hover: none) and (pointer: coarse) {
  /* Hide drag grip indicator on touch devices */
  .tier-label::after {
    display: none;
  }

  /* Always show tier controls on touch (no hover) */
  .tier-controls {
    opacity: 1;
    pointer-events: auto;
  }

  /* Disable tier dragging on touch devices (use buttons instead) */
  .tier-label {
    cursor: pointer;
  }

  /* Larger touch targets for tier control buttons */
  .tier-ctrl-btn {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }
}

/* ============================================
   Tier Drag States
   ============================================ */
.tier.tier-dragging {
  opacity: 0.4;
  border: 2px dashed var(--color-highlight);
  background: rgba(74, 144, 217, 0.05);
}

.tier.tier-drag-over {
  background: rgba(0, 212, 255, 0.1) !important;
  border: 2px solid #00d4ff !important;
  border-top-width: 4px !important;
  box-shadow: 0 0 15px rgba(0, 212, 255, 0.4), inset 0 0 15px rgba(0, 212, 255, 0.05) !important;
  animation: tierDropPulse 0.5s ease-in-out infinite alternate;
}

@keyframes tierDropPulse {
  from { opacity: 0.85; }
  to { opacity: 1; }
}

/* ============================================
   Tier Controls
   ============================================ */
/* Only show controls on hover for devices that properly support hover (not touch) */
@media (hover: hover) {
  .tier-label:hover .tier-controls {
    opacity: 1;
    pointer-events: auto;
  }
}

.tier-controls {
  position: absolute;
  top: 3px;
  right: 3px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.tier-ctrl-btn {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  color: #fff;
}

.tier-ctrl-btn:hover { background: rgba(0,0,0,0.8); }
.tier-ctrl-btn.delete-btn { background: rgba(180,50,50,0.7); }
.tier-ctrl-btn.delete-btn:hover { background: rgba(200,60,60,0.9); }

/* Move buttons - shown by default, hidden on desktop with hover */
.tier-ctrl-btn.move-btn {
  display: flex;
  background: rgba(80,80,120,0.7);
  font-size: 10px;
}
.tier-ctrl-btn.move-btn:hover { background: rgba(100,100,150,0.9); }

/* Hide move buttons on desktop (where drag & drop works) */
@media (hover: hover) and (pointer: fine) {
  .tier-ctrl-btn.move-btn {
    display: none;
  }
}

/* ============================================
   Focused Tier State
   ============================================ */
.tier.tier-focused .tier-controls {
  opacity: 1;
  pointer-events: auto;
}
.tier.tier-focused .tier-label {
  box-shadow: 0 0 0 2px #00d4ff, 0 0 10px rgba(0, 212, 255, 0.3);
}

/* ============================================
   Tier Move Animation
   ============================================ */
.tier.tier-moving {
  animation: tierHighlight 0.5s ease-out;
}

@keyframes tierHighlight {
  0% {
    background: rgba(0, 212, 255, 0.15);
  }
  100% {
    background: transparent;
  }
}

/* ============================================
   Tier Content
   ============================================ */
.tier-content {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding: 6px;
  min-height: 85px;
  transition: background-color 0.3s;
  user-select: none;
  -webkit-user-select: none;
}

/* Empty tier placeholder */
.tier-content:empty::before {
  content: "Drop heroes here";
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 73px;
  color: var(--text-muted);
  opacity: 0.4;
  font-size: 14px;
  font-style: italic;
  border: 2px dashed var(--border-color);
  border-radius: 6px;
  margin: 4px;
  pointer-events: none;
}

/* Hide placeholder in readonly/view mode */
.tier.readonly .tier-content:empty::before {
  content: "";
  border: none;
  min-height: 0;
}

/* Hide placeholder on all tiers once any hero is placed */
#tiers.has-heroes .tier-content:empty::before {
  display: none;
}

/* ============================================
   Read-only Mode (Preset Viewing)
   ============================================ */
.tier.readonly .tier-label {
  cursor: default;
}

.tier.readonly .tier-controls {
  display: none;
}
