/**
 * DragonCompanion — Team Card Styles
 *
 * Polished two-column dark team cards with:
 * - Faction-colored top border and dragon/faction icons
 * - Aligned 6-member primary roster with compact formation badges
 * - Visibly smaller reserve portraits
 * - Compact optional formation grid (3×3) disclosure
 * - Wyrmspells and suggested artifacts disclosures with local game artwork
 * - Active character profile highlighting
 * - Deep linking and responsive breakpoints
 */

.team-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 18px;
  align-items: start;
}

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

/* Base Team Card */
.team-card {
  position: relative;
  background: var(--panel, #121b24);
  border: 1px solid var(--border, #273440);
  border-top: 3px solid var(--faction-color, #546e7a);
  border-radius: var(--radius, 14px);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.team-card:hover {
  border-color: color-mix(in srgb, var(--faction-color, #546e7a) 40%, var(--border, #273440));
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35), 0 0 0 1px color-mix(in srgb, var(--faction-color, #546e7a) 25%, transparent);
}

.team-card:target {
  outline: 2px solid var(--faction-color, #ff7588);
  outline-offset: 3px;
}
.team-details-link {
  align-self: flex-start;
}

.team-page {
  max-width: 1000px;
  margin-inline: auto;
}

.team-detail {
  padding: clamp(16px, 3vw, 32px);
  gap: 24px;
}

.team-detail .team-title {
  font-size: clamp(1.7rem, 3vw, 2.5rem);
}

.team-detail .team-member-name,
.team-detail .team-reserve-name,
.team-detail .team-system-link {
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
}

.team-detail .team-reserve-member {
  width: 80px;
}

.team-detail .team-system-desc {
  font-size: 0.88rem;
  line-height: 1.6;
}

.team-detail .team-section-label,
.team-detail .team-disclosure-summary,
.team-detail .team-subdisclosure-summary {
  font-size: 0.9rem;
}

.team-detail .team-formation-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: none;
  width: min(100%, 280px);
}

.team-detail .formation-slot {
  aspect-ratio: 1;
}

.team-detail .formation-column-label {
  font-size: 0.75rem;
}


/* Card Header */
.team-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.team-header-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 240px;
}

.team-faction-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--faction-color, #546e7a) 15%, #0e151d);
  border: 1px solid color-mix(in srgb, var(--faction-color, #546e7a) 35%, #273440);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.team-faction-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}

.team-dragon-icon {
  color: var(--faction-color, var(--gold, #f7c977));
}

.team-header-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.team-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text, #edf1f4);
  line-height: 1.3;
  margin: 0;
}

.team-title a {
  color: inherit;
  text-decoration: none;
}

.team-title a:hover {
  color: var(--accent, #ff7588);
  text-decoration: underline;
}

.team-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}


/* Section Labels */
.team-section-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted, #a8b5c3);
  margin-bottom: 8px;
}

.team-member-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text, #edf1f4);
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 10px;
}

/* Primary Roster (6 slots) */
.team-primary-roster {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 540px) {
  .team-primary-roster {
    gap: 6px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.team-member {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 0;
}

.team-member-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  text-decoration: none;
  color: inherit;
}

.team-member-avatar {
  position: relative;
  width: 100%;
  max-width: 80px;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: #0c131a;
  border: 2px solid color-mix(in srgb, var(--faction-color) 65%, var(--border));
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.team-member-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}

.team-member:hover .team-member-avatar img {
  transform: scale(1.05);
}

.team-avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #162432, #0d1620);
  color: var(--gold, #f7c977);
  font-size: 0.85rem;
  font-weight: 700;
}

.team-avatar-fallback.small {
  font-size: 0.75rem;
}

.team-slot-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(9, 14, 20, 0.88);
  backdrop-filter: blur(4px);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text, #edf1f4);
  padding: 1px 2px;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  line-height: 1.3;
}

.team-member-name {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text, #edf1f4);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  text-align: center;
  line-height: 1.25;
}

.team-member:hover .team-member-name {
  color: var(--accent, #ff7588);
}

/* Active Profile Highlighting */
.team-member.is-current .team-member-avatar,
.team-reserve-member.is-current .team-reserve-avatar {
  border: 2px solid var(--accent, #ff7588);
  box-shadow: 0 0 12px rgba(255, 117, 136, 0.5);
}

.team-member.is-current .team-member-name,
.team-reserve-member.is-current .team-reserve-name {
  color: var(--accent, #ff7588);
  font-weight: 700;
}

/* Formation Disclosure (3x3 grid) */
.team-formation-disclosure {
  border-radius: 8px;
}

.team-subdisclosure-summary {
  font-size: 0.74rem;
  color: var(--muted, #a8b5c3);
  cursor: pointer;
  user-select: none;
  padding: 2px 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.team-subdisclosure-summary:hover {
  color: var(--text, #edf1f4);
}

.team-formation-grid {
  display: grid;
  grid-template-columns: repeat(3, 38px);
  grid-template-rows: auto repeat(3, 46px);
  gap: 6px;
  margin: 8px auto 4px auto;
  justify-content: center;
  background: rgba(0, 0, 0, 0.28);
  padding: 10px;
  border-radius: 8px;
  border: 1px dashed var(--border, #273440);
  width: fit-content;
}

.formation-column-label {
  min-width: 0;
  color: var(--muted, #a8b5c3);
  font-size: 0.62rem;
  line-height: 1.3;
  text-align: center;
  overflow-wrap: anywhere;
}

.formation-slot {
  position: relative;
  min-height: 0;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  overflow: hidden;
}

.formation-slot.empty {
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.2);
}

.formation-slot.occupied {
  border: 1px solid var(--border, #273440);
  background: #0c131a;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
}

.formation-slot.occupied img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.formation-slot.occupied.is-current {
  border: 2px solid var(--accent, #ff7588);
}

.formation-slot-initials {
  color: var(--gold, #f7c977);
  font-size: 0.72rem;
  font-weight: 700;
}

.formation-order {
  position: absolute;
  bottom: 1px;
  right: 1px;
  padding: 1px 4px;
  border-radius: 4px;
  background: #10151e;
  color: #fff;
}

/* Reserves (Bench) */
.team-reserves-section {
  display: flex;
  flex-direction: column;
}

.team-reserves-roster {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.team-reserve-member {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 42px;
  min-width: 0;
}

.team-reserve-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  text-decoration: none;
  color: inherit;
}

.team-reserve-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: #0c131a;
  border: 1px solid color-mix(in srgb, var(--faction-color) 50%, var(--border));
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.team-reserve-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.team-reserve-name {
  font-size: 0.65rem;
  color: var(--muted, #a8b5c3);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  text-align: center;
  line-height: 1.2;
}

.team-reserve-member:hover .team-reserve-name {
  color: var(--accent, #ff7588);
}

/* Native Disclosures (Wyrmspells, Artifacts) */
.team-disclosure {
  border: 1px solid var(--border, #273440);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.16);
  overflow: hidden;
}

.team-disclosure-summary {
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text, #edf1f4);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}

.team-disclosure-summary:hover {
  background: rgba(255, 255, 255, 0.04);
}

.team-disclosure-summary::-webkit-details-marker {
  display: none;
}

.team-disclosure-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.team-disclosure-arrow {
  font-size: 0.72rem;
  color: var(--muted, #a8b5c3);
  transition: transform 0.2s ease;
}

.team-disclosure[open] .team-disclosure-arrow {
  transform: rotate(180deg);
}

.team-disclosure-note {
  font-size: 0.72rem;
  color: var(--muted, #a8b5c3);
  padding: 8px 12px 0 12px;
  margin: 0;
  background: rgba(0, 0, 0, 0.1);
  border-top: 1px solid var(--border, #273440);
  line-height: 1.4;
}

.team-disclosure-note + .team-system-grid {
  border-top: none;
  padding-top: 8px;
}

/* System Cards inside Disclosures */
.team-system-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border, #273440);
  background: rgba(0, 0, 0, 0.1);
}

@media (max-width: 600px) {
  .team-system-grid {
    grid-template-columns: 1fr;
  }
}

.team-system-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  min-width: 0;
}

.team-system-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: #0c131a;
  border: 1px solid var(--border, #273440);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.team-artifact-icon {
  width: 56px;
  height: 56px;
}

.team-system-icon-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.team-system-fallback {
  color: var(--muted, #a8b5c3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.team-system-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
  flex: 1;
}

.team-system-slot {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gold, #f7c977);
}

.team-system-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text, #edf1f4);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-system-link:hover {
  color: var(--accent, #ff7588);
  text-decoration: underline;
}

.team-system-desc {
  font-size: 0.74rem;
  color: var(--muted, #a8b5c3);
  line-height: 1.35;
  margin: 0;
}



/* Attribution Line */
.team-source-attribution {
  font-size: 0.85rem;
  color: var(--muted, #a8b5c3);
  margin: 6px 0 16px 0;
  line-height: 1.5;
}

.team-source-attribution a {
  color: var(--accent, #ff7588);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.team-source-attribution a:hover {
  color: var(--accent-hover, #ff8da1);
}
