/* Calnic Online badges system (scoped, conflict-safe) */

.co-badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.co-badge-list--profile {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.co-badge-list--compact {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.co-badge {
  --co-b-base: #7a5828;
  --co-b-dark: #3a2a10;
  --co-b-accent: #d4a84a;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 6px 10px 6px 8px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--co-b-accent) 62%, #2a1a08 38%);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0) 38%),
    linear-gradient(155deg, color-mix(in srgb, var(--co-b-base) 87%, #0b0b0b 13%), color-mix(in srgb, var(--co-b-dark) 84%, #060606 16%));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    inset 0 -1px 0 rgba(0, 0, 0, 0.28),
    0 7px 20px rgba(0, 0, 0, 0.35);
  color: #fff6de;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  width: auto;
  box-sizing: border-box;
}

.co-badge:hover {
  transform: translateY(-2px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 10px 24px rgba(0, 0, 0, 0.42);
  filter: saturate(1.05);
}

.co-badge-medal {
  width: 23px;
  height: 23px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: color-mix(in srgb, var(--co-b-accent) 86%, #fff 14%);
  border: 1px solid color-mix(in srgb, var(--co-b-accent) 60%, #000 40%);
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--co-b-accent) 26%, #fff 74%), color-mix(in srgb, var(--co-b-dark) 75%, #0a0a0a 25%));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 2px 7px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}

.co-badge-icon {
  width: 13px;
  height: 13px;
  display: block;
}

.co-badge-icon-img {
  width: 13px;
  height: 13px;
  display: block;
  object-fit: contain;
}

.co-badge-icon path,
.co-badge-icon circle,
.co-badge-icon rect {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.co-badge-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.co-badge-title {
  font-family: 'Playfair Display', serif;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
  color: #fff4d2;
  letter-spacing: 0.2px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.co-badge-desc {
  font-family: 'EB Garamond', serif;
  font-size: 10px;
  line-height: 1.2;
  color: color-mix(in srgb, #fff 70%, var(--co-b-accent) 30%);
  opacity: 0.93;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.co-badge--primary {
  outline: 1px solid color-mix(in srgb, var(--co-b-accent) 48%, #1c1c1c 52%);
  outline-offset: 1px;
}

.co-badge--compact {
  min-height: 28px;
  padding: 3px 7px 3px 6px;
  border-radius: 9px;
  gap: 5px;
  width: 100%;
}

.co-badge--profile {
  flex: 0 0 240px;
  width: 240px;
  min-height: 58px;
  padding-top: 9px;
  max-width: 100%;
}

.co-badge--svg.co-badge--profile,
.co-badge--svg.co-badge--compact {
  width: auto;
  flex: 0 0 auto;
  min-height: 0;
}

.co-badge--profile .co-badge-medal {
  width: 25px;
  height: 25px;
  font-size: 12px;
}

.co-badge--profile .co-badge-icon-img {
  width: 14px;
  height: 14px;
}

.co-badge--profile .co-badge-title {
  font-size: 12px;
}

.co-badge--profile .co-badge-desc {
  font-size: 10px;
}

.co-badge--profile::before {
  content: '✦';
  position: absolute;
  top: 1px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  line-height: 1;
  color: color-mix(in srgb, var(--co-b-accent) 85%, #f7edd2 15%);
  opacity: 0.95;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.55);
}

.co-badge--profile::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 9px;
  border: 1px solid color-mix(in srgb, var(--co-b-accent) 45%, #281a08 55%);
  pointer-events: none;
  opacity: 0.85;
}

.co-badge--compact .co-badge-medal {
  width: 16px;
  height: 16px;
  font-size: 9px;
}

.co-badge--compact .co-badge-icon-img {
  width: 10px;
  height: 10px;
}

.co-badge--compact .co-badge-title {
  font-size: 10px;
  line-height: 1.1;
}

.co-badge--compact .co-badge-desc {
  display: none;
}

.co-badge-empty {
  font-size: 13px;
  color: #7a5828;
  font-style: italic;
}

.co-badge-tooltip {
  position: fixed;
  z-index: 9999;
  max-width: min(320px, 85vw);
  background: linear-gradient(180deg, #171106, #0e0a03);
  border: 1px solid #6c5124;
  border-radius: 8px;
  color: #f7e7c0;
  padding: 7px 10px;
  font-family: 'EB Garamond', serif;
  font-size: 13px;
  line-height: 1.25;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

/* Full SVG badge rendering (uses provided artwork files) */
.co-badge--svg {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  min-height: 0;
  width: auto;
}

.co-badge--svg::before,
.co-badge--svg::after {
  display: none !important;
}

.co-badge--svg:hover {
  transform: translateY(-1px);
  box-shadow: none;
  filter: brightness(1.03);
}

.co-badge-art {
  display: block;
  width: 100%;
  height: auto;
}

.co-badge-art--profile {
  width: 190px;
  max-width: 100%;
}

.co-badge-art--compact {
  width: 130px;
  max-width: 100%;
}

.co-badge--svg.co-badge--primary {
  outline: none !important;
  outline-offset: 0 !important;
}

/* Profile page section */
.co-profile-badges {
  margin-top: 2px;
}

/* Family cards integration */
.co-card-badge-slot {
  margin-top: 8px;
}

.fc .co-card-badge-slot .co-badge-list {
  gap: 6px;
}

.fc .co-card-badge-slot .co-badge {
  max-width: 100%;
}

.fc .co-card-badge-slot .co-badge--svg {
  width: auto;
}

.fc .co-card-badge-slot .co-badge-art--compact {
  width: 120px;
}

/* Admin section */
.ab-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.ab-box {
  background: var(--s2);
  border: 1px solid var(--b1);
  border-radius: 2px;
  padding: 14px;
}

.ab-title {
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold-m);
  margin-bottom: 10px;
}

.ab-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--b1);
}

.ab-row:last-child {
  border-bottom: none;
}

.ab-row-badge {
  min-width: 0;
}

.ab-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ab-primary-tag {
  font-size: 11px;
  color: #f1c96a;
  border: 1px solid #6f5220;
  background: #1b1407;
  border-radius: 2px;
  padding: 3px 8px;
  white-space: nowrap;
}

.ab-empty {
  color: var(--gold-m);
  font-style: italic;
  font-size: 13px;
}

.ab-status {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

.ab-status.ok { color: #86c978; }
.ab-status.warn { color: #e0b66a; }
.ab-status.err { color: #d97a7a; }

/* Admin badges selects: keep dropdown readable in dark theme */
#sec-badges select.fs {
  color-scheme: dark;
}

#sec-badges select.fs option {
  background: #0d1018;
  color: #f3e7c8;
}

#sec-badges select.fs option:checked {
  background: #2a1b08;
  color: #ffd987;
}

#sec-badges select.fs option:disabled {
  color: #8f7a4b;
}

@media (max-width: 900px) {
  .ab-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .co-badge-list--profile {
    display: grid;
    grid-template-columns: 1fr;
  }
  .co-badge--profile {
    width: 100%;
    min-width: 0;
    flex: 0 0 auto;
  }
  .co-badge-list--compact {
    grid-template-columns: 1fr;
  }
}
