/* ── Skill Description Popup ── */

/* Interactive skill name affordance */
[data-skill-name] {
  cursor: pointer;
  text-decoration-style: dotted;
  text-decoration-line: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgb(var(--muted-rgb, 148 163 184) / 0.5);
  transition:
    color 0.15s ease,
    text-decoration-color 0.15s ease;
}

[data-skill-name]:hover,
[data-skill-name]:focus-visible {
  text-decoration-color: var(--accent, #6366f1);
  color: var(--accent, #6366f1);
}

[data-skill-name]:focus-visible {
  outline: 2px solid var(--accent, #6366f1);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Backdrop (invisible, catches outside clicks) */
.skill-popup-backdrop {
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 110;
}

/* Popup container */
.skill-popup {
  position: absolute;
  z-index: 111;
  background: var(--surface-1, #fff);
  color: var(--text-1, #0f172a);
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 12px;
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.12),
    0 2px 6px rgba(0, 0, 0, 0.06);
  width: min(380px, 90vw);
  max-height: min(480px, 70vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: sp-fade-in 0.12s ease-out;
}

@keyframes sp-fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body.dark .skill-popup {
  background: var(--surface-1, #111827);
  border-color: var(--border, #334155);
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.4),
    0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Header */
.skill-popup .sp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border, #e2e8f0);
  flex-shrink: 0;
}

.skill-popup .sp-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-popup .sp-close {
  background: transparent;
  border: 0;
  color: var(--text-2, #64748b);
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 1.15rem;
  line-height: 1;
  transition:
    background 0.12s ease,
    color 0.12s ease;
}

.skill-popup .sp-close:hover {
  background: rgba(100, 116, 139, 0.12);
  color: var(--text-1, #0f172a);
}

body.dark .skill-popup .sp-close:hover {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-1, #f1f5f9);
}

/* Scrollable body */
.skill-popup .sp-body {
  padding: 0.6rem 0.8rem;
  overflow-y: auto;
  flex: 1 1 auto;
}

/* Sections */
.skill-popup .sp-section {
  margin-bottom: 0.6rem;
}

.skill-popup .sp-section:last-child {
  margin-bottom: 0;
}

.skill-popup .sp-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2, #64748b);
  margin-bottom: 0.2rem;
}

/* Description text */
.skill-popup .sp-desc {
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Meta pills (rarity, cost) */
.skill-popup .sp-meta {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.skill-popup .sp-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: var(--surface-2, #f1f5f9);
  font-size: 0.75rem;
  font-weight: 500;
}

body.dark .skill-popup .sp-meta-item {
  background: var(--surface-2, #1e293b);
}

/* Effects list */
.skill-popup .sp-effects-list {
  font-size: 0.8rem;
  margin: 0.15rem 0 0;
  padding-left: 1.1rem;
  line-height: 1.5;
}

.skill-popup .sp-effects-list li {
  margin-bottom: 0.1rem;
}

/* Support card rows */
.skill-popup .sp-cards-list {
  max-height: 160px;
  overflow-y: auto;
}

.skill-popup .sp-card-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0;
  font-size: 0.8rem;
}

.skill-popup .sp-card-thumb {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-2, #f1f5f9);
}

.skill-popup .sp-card-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-popup .sp-card-rarity {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-2, #64748b);
}

.skill-popup .sp-card-group-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-2, #64748b);
  margin: 0.3rem 0 0.1rem;
}

.skill-popup .sp-card-group-label:first-child {
  margin-top: 0;
}

/* Character rows */
.skill-popup .sp-chars-list {
  max-height: 160px;
  overflow-y: auto;
}

/* Empty state */
.skill-popup .sp-empty {
  color: var(--text-2, #9ca3af);
  font-size: 0.8rem;
  font-style: italic;
}

/* ── Scrollbar styling ── */
.skill-popup .sp-body,
.skill-popup .sp-cards-list,
.skill-popup .sp-chars-list {
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 116, 139, 0.35) transparent;
}

.skill-popup .sp-body::-webkit-scrollbar,
.skill-popup .sp-cards-list::-webkit-scrollbar,
.skill-popup .sp-chars-list::-webkit-scrollbar {
  width: 6px;
}

.skill-popup .sp-body::-webkit-scrollbar-thumb,
.skill-popup .sp-cards-list::-webkit-scrollbar-thumb,
.skill-popup .sp-chars-list::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.35);
  border-radius: 999px;
}

body.dark .skill-popup .sp-body,
body.dark .skill-popup .sp-cards-list,
body.dark .skill-popup .sp-chars-list {
  scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
}

body.dark .skill-popup .sp-body::-webkit-scrollbar-thumb,
body.dark .skill-popup .sp-cards-list::-webkit-scrollbar-thumb,
body.dark .skill-popup .sp-chars-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
}

/* ── Mobile: bottom-sheet ── */
@media (max-width: 480px) {
  .skill-popup-backdrop {
    background: rgba(0, 0, 0, 0.3);
  }

  .skill-popup {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    max-height: 60vh;
    border-radius: 14px 14px 0 0;
    border-bottom: none;
    animation: sp-slide-up 0.18s ease-out;
  }

  @keyframes sp-slide-up {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }

  .skill-popup .sp-cards-list {
    max-height: 120px;
  }
}
