/*
  Tier list index/discovery styles.
  Shared app theme tokens live in common.css; this file keeps the tier-list-only
  preview cards and modal behavior out of the HTML.
*/

/* Cursor pointer for clickable elements */
button, .btn, .tier-thumb, .preview-thumb, .tl-vis-chip, .cursor-pointer {
  cursor: pointer;
}

/* Focus states for accessibility */
*:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.tier-thumb:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
}

.tier-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.tier-label {
  width: 160px;
  min-width: 120px;
  max-width: 220px;
  background: var(--card);
  border: 1px solid var(--card-outline);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  color: var(--text);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.tier-label:hover {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.tier-items {
  flex: 1;
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 12px;
  background: var(--card);
  border-radius: 8px;
  border: 1px solid var(--card-outline);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.tier-items:hover {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.tier-thumb {
  width: 96px;
  height: 128px;
  flex: 0 0 auto;
  border-radius: 6px;
  object-fit: cover;
  cursor: grab;
  transition: transform 200ms ease, box-shadow 200ms ease;
}

.tier-thumb:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.tier-settings {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  transition: opacity 150ms ease;
}

.tier-settings:hover {
  opacity: 0.7;
}

.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--card-outline);
  border-radius: 8px;
  background: var(--card);
}

.preview-tier {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 6px;
  min-height: 48px;
  transition: background 150ms ease;
}

.preview-tier:hover {
  background: rgba(79, 70, 229, 0.05);
}

.preview-tier-label {
  min-width: 48px;
  padding: 4px 6px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.4;
  /* Tier labels always have a coloured background set by JS — white text is correct
     regardless of light/dark mode. The dark-mode body * override is defeated here
     by higher specificity. */
  color: #fff;
  text-align: center;
}
html.dark-mode .preview-tier-label { color: #fff !important; }

.preview-thumbs {
  display: flex;
  gap: 6px;
  align-items: center;
  overflow: hidden;
}

.preview-thumb {
  width: 28px;
  height: 38px;
  object-fit: cover;
  border-radius: 4px;
  flex: 0 0 auto;
  transition: transform 150ms ease;
}

.preview-thumb:hover {
  transform: scale(1.1);
}

.tier-color-S { background: linear-gradient(90deg, #FFD54A, #FFB300); }
.tier-color-A { background: linear-gradient(90deg, #86efac, #16a34a); }
.tier-color-B { background: linear-gradient(90deg, #93c5fd, #3b82f6); }
.tier-color-C { background: linear-gradient(90deg, #c7b3ff, #7c3aed); }
.tier-color-D { background: linear-gradient(90deg, #fbcfe8, #f472b6); }
.tier-color-F { background: linear-gradient(90deg, #e5e7eb, #9ca3af); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: fadeIn 200ms ease;
}

.modal {
  width: 92%;
  max-width: 520px;
  background: var(--card);
  color: var(--text);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(2, 6, 23, 0.4);
  padding: 18px;
  border: 1px solid var(--card-outline);
  animation: slideUp 300ms ease;
}

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

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal h3 {
  margin: 0 0 8px 0;
  font-size: 1.125rem;
  line-height: 1.3;
}

.modal .modal-body {
  margin-bottom: 12px;
  line-height: 1.6;
}

.modal .modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal input[type='text'],
.modal select,
.modal textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--card-outline);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-size: 16px;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.modal input[type='text']:focus,
.modal select:focus,
.modal textarea:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.modal .btn {
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  border: 0;
  transition: all 200ms ease;
  min-height: 44px;
  min-width: 44px;
}

.modal .btn:hover {
  transform: translateY(-1px);
}

.modal .btn:active {
  transform: translateY(0);
}

.modal .btn.primary { background: #4f46e5; color: #fff !important; box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3); }
.modal .btn.primary:hover { box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4); }
.modal .btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--card-outline); }
.modal .btn.danger { background: #dc2626; color: #fff !important; box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3); }
.modal .btn.danger:hover { box-shadow: 0 6px 16px rgba(220, 38, 38, 0.4); }

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .tier-thumb:hover,
  .preview-thumb:hover {
    transform: none;
  }
}

@media (max-width: 640px) {
  .tier-row {
    flex-direction: column;
    gap: 8px;
  }

  .tier-label,
  .tier-items {
    width: 100%;
  }

  .tier-thumb {
    width: 80px;
    height: 107px;
    min-width: 80px;
    min-height: 107px;
  }

  .preview-thumb {
    width: 32px;
    height: 44px;
    min-width: 32px;
    min-height: 44px;
  }

  button, .btn {
    min-height: 44px;
    min-width: 44px;
  }

  .tl-vis-chip {
    padding: 0.3rem 0.6rem;
    font-size: 0.7rem;
    min-height: 32px;
  }

  .tier-label {
    min-height: 44px;
  }

  .modal {
    padding: 12px;
  }

  .modal .btn {
    padding: 12px 16px;
  }
}

@media (max-width: 768px) {
  .tier-row {
    gap: 8px;
    margin-bottom: 1rem;
  }

  .tier-label {
    width: 100%;
    min-width: auto;
    max-width: none;
  }

  .tier-items {
    width: 100%;
    padding: 12px;
  }

  .preview-panel {
    max-height: 300px;
    padding: 12px;
  }

  .modal {
    width: 95%;
    max-width: none;
    padding: 16px;
  }
}
