/* ========================================
   BADGES & ACHIEVEMENTS
   Matches the markup in pages/badges.html (.badge-card, .progress-item,
   .progress-bar, .all-badges-section, etc.).
   ======================================== */

/* ---------- Page header ---------- */

.panel-list { padding: 16px 20px; }

.panel-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--c-border);
}
.panel-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-weight: 800;
  color: var(--c-ink);
  letter-spacing: -0.02em;
}
.panel-subtitle {
  color: var(--c-ink-soft);
  font-weight: 600;
  font-size: var(--fs-sm);
}

/* ---------- Section headers (My badges / Almost there / All available) ---------- */

.my-badges-section,
.progress-section,
.all-badges-section {
  margin-bottom: 32px;
}
.my-badges-section > h3,
.progress-section > h3,
.all-badges-section > h3 {
  position: relative;
  margin: 0 0 16px;
  padding-left: 14px;
  font-size: var(--fs-xl);
  font-weight: 800;
  color: var(--c-ink);
}
.my-badges-section > h3::before,
.progress-section > h3::before,
.all-badges-section > h3::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 4px;
  border-radius: 2px;
  background: var(--c-indigo);
}
.progress-section > h3::before { background: var(--c-pink); }
.all-badges-section > h3::before { background: var(--c-lime-deep); }

.badge-category { margin-bottom: 24px; }
.badge-category h4 {
  margin: 0 0 12px;
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--c-ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Badge grid + cards ---------- */

.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  gap: 10px;
}

.badge-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px 10px 10px;
  border-radius: var(--radius-md);
  background: var(--c-white);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-sm);
  transition: transform var(--motion-tap), box-shadow var(--motion-tap);
}
.badge-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.badge-card.earned {
  background: linear-gradient(165deg, var(--c-white) 0%, var(--c-indigo-tint) 100%);
  border-color: color-mix(in srgb, var(--c-indigo) 30%, transparent);
}
.badge-card.earned::after {
  content: '✓';
  position: absolute;
  top: 6px; right: 6px;
  width: 16px; height: 16px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--c-lime-deep);
  color: var(--c-white);
  font-size: 10px;
  font-weight: 900;
  box-shadow: 0 1px 3px color-mix(in srgb, var(--c-lime-deep) 40%, transparent);
}

.badge-card.locked {
  background: var(--c-surface-2);
  border-color: var(--c-border);
  opacity: 0.72;
}
.badge-card.locked .badge-icon { filter: grayscale(100%) opacity(0.7); }
.badge-card.locked .badge-name { color: var(--c-ink-soft); }

.badge-icon {
  font-size: 30px;
  line-height: 1;
  margin-bottom: 6px;
  filter: drop-shadow(0 2px 4px color-mix(in srgb, var(--c-ink) 10%, transparent));
}
.badge-name {
  font-weight: 800;
  font-size: var(--fs-xs);
  color: var(--c-ink);
  margin-bottom: 2px;
  line-height: 1.2;
}
.badge-desc {
  font-size: 10.5px;
  color: var(--c-ink-soft);
  line-height: 1.35;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.badge-threshold {
  margin-top: 6px;
  font-size: 9px;
  font-weight: 700;
  color: var(--c-ink-soft);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  display: inline-block;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------- "Almost there" progress list ---------- */

.progress-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.progress-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--c-white);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--motion-tap), box-shadow var(--motion-tap);
}
.progress-item:hover {
  border-color: color-mix(in srgb, var(--c-pink) 30%, transparent);
  box-shadow: var(--shadow-md);
}
.progress-icon {
  font-size: 36px;
  line-height: 1;
  flex-shrink: 0;
}
.progress-info { flex: 1; min-width: 0; }
.progress-name {
  font-weight: 800;
  font-size: var(--fs-base);
  color: var(--c-ink);
  margin-bottom: 2px;
}
.progress-desc {
  font-size: var(--fs-xs);
  color: var(--c-ink-soft);
  margin-bottom: 10px;
  font-weight: 500;
}
.progress-bar-container {
  height: 10px;
  background: var(--c-surface-2);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 6px;
  position: relative;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--grad-accent);
  border-radius: var(--radius-full);
  transition: width 700ms cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}
.progress-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.35) 50%,
    transparent 100%
  );
  animation: progress-shine 2s ease-in-out infinite;
}
@keyframes progress-shine {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
@media (prefers-reduced-motion: reduce){
  .progress-bar::after { animation: none; }
}
.progress-text {
  font-size: var(--fs-xs);
  color: var(--c-ink-soft);
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------- Compact badge list (inline, for profile cards) ---------- */

.badges-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 8px 0;
}
.badge-mini {
  font-size: 22px;
  cursor: help;
  transition: transform var(--motion-tap);
  filter: drop-shadow(0 1px 3px color-mix(in srgb, var(--c-ink) 12%, transparent));
}
.badge-mini:hover { transform: scale(1.15); }
.badge-more {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--c-ink-soft);
  background: var(--c-indigo-tint);
  border: 1px solid color-mix(in srgb, var(--c-indigo) 22%, transparent);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
}
.badge-more:hover { background: color-mix(in srgb, var(--c-indigo) 14%, white); }

/* ---------- Responsive ---------- */

@media (max-width: 768px) {
  .badges-grid {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 8px;
  }
  .badge-icon { font-size: 26px; }
  .panel-header h2 { font-size: var(--fs-2xl); }
}

@media (max-width: 480px) {
  .panel-list { padding: 10px; }
  .badges-grid {
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 6px;
  }
  .badge-card { padding: 10px 8px 8px; }
  .badge-icon { font-size: 24px; }
  .badge-desc { -webkit-line-clamp: 2; line-clamp: 2; }
}
