/**
 * Leaderboard Premium Styles
 *
 * Sky Sports-inspired premium table styling with sticky header,
 * row animations, top 3 highlighting, and responsive breakpoints.
 *
 * @package OnyxData_Child
 * @since 1.5.0
 */

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

:root {
  /* Leaderboard-specific tokens (extend existing --ddna-* system) */
  --lb-header-bg: #ffffff;
  --lb-header-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --lb-row-border: #e5e5e5;
  --lb-hover-bg: rgba(255, 187, 9, 0.08);
  --lb-row-gap: 0;

  /* Medal colours - Sky Sports inspired */
  --lb-gold: #FFD700;
  --lb-gold-bg: rgba(255, 215, 0, 0.15);
  --lb-silver: #C0C0C0;
  --lb-silver-bg: rgba(192, 192, 192, 0.15);
  --lb-bronze: #CD7F32;
  --lb-bronze-bg: rgba(205, 127, 50, 0.15);

  /* Cell dimensions */
  --lb-cell-padding: 16px 20px;
  --lb-avatar-size: 48px;
  --lb-avatar-size-sm: 40px;
}

/* ==========================================================================
   Wrapper Styles
   ========================================================================== */

.leaderboard-premium-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  background: #ffffff;
  border-radius: var(--ddna-card-radius, 12px);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  padding: 24px;
}

/* ==========================================================================
   Controls Bar
   ========================================================================== */

.leaderboard-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.leaderboard-search {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
  position: relative;
}

.leaderboard-search input[type="search"] {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border: 1px solid var(--lb-row-border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background-color: #f9fafb;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.leaderboard-search input[type="search"]:focus {
  outline: none;
  border-color: var(--ddna-gold, #ffbb09);
  box-shadow: 0 0 0 3px var(--ddna-gold-glow, rgba(255, 187, 9, 0.2));
  background-color: #ffffff;
}

.leaderboard-search input[type="search"]::placeholder {
  color: #9ca3af;
}

.leaderboard-search::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E");
  background-size: contain;
  pointer-events: none;
}

.leaderboard-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.leaderboard-filters select {
  padding: 10px 36px 10px 12px;
  border: 1px solid var(--lb-row-border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background-color: #f9fafb;
  cursor: pointer;
  min-width: 140px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  transition: border-color 0.2s ease;
}

.leaderboard-filters select:hover {
  border-color: #9ca3af;
}

.leaderboard-filters select:focus {
  outline: none;
  border-color: var(--ddna-gold, #ffbb09);
  box-shadow: 0 0 0 3px var(--ddna-gold-glow, rgba(255, 187, 9, 0.2));
}

/* Results count */
.leaderboard-results-count {
  font-size: 14px;
  color: #6b7280;
  margin-left: auto;
}

/* ==========================================================================
   Semantic Table Base
   ========================================================================== */

/* Table itself has .leaderboard-premium class */
table.leaderboard-premium {
  display: table !important;
  width: 100%;
  border-collapse: collapse;
  font-family: inherit;
  table-layout: auto;
  border: none !important;
  background: #fff !important;
}

/* Reset any inherited table styles */
table.leaderboard-premium th,
table.leaderboard-premium td {
  border: none;
  background: transparent;
}

table.leaderboard-premium tr {
  display: table-row !important;
}

/* ==========================================================================
   Sticky Header
   ========================================================================== */

table.leaderboard-premium thead {
  position: relative;
  display: table-header-group !important;
}

table.leaderboard-premium tbody {
  display: table-row-group !important;
}

table.leaderboard-premium thead th {
  position: sticky;
  top: var(--ddna-header-height, 80px);
  background: #f8fafc !important;
  z-index: 10;
  padding: 16px 20px !important;
  text-align: left;
  font-weight: 700 !important;
  font-size: 12px !important;
  color: #1f2937 !important;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 3px solid var(--ddna-gold, #ffbb09) !important;
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
  white-space: nowrap;
  vertical-align: middle;
}

/* Shadow on scroll - applied via JS */
table.leaderboard-premium.is-scrolled thead th {
  box-shadow: var(--lb-header-shadow);
}

/* Column-specific alignments */
table.leaderboard-premium thead th:first-child {
  text-align: center;
  width: 80px;
}

/* Points column */
table.leaderboard-premium thead th[data-col="points"],
table.leaderboard-premium thead th[data-col="wins"] {
  text-align: right;
}

/* Portfolio column */
table.leaderboard-premium thead th[data-col="portfolio"] {
  text-align: center;
}

/* ==========================================================================
   Sortable Column Headers
   ========================================================================== */

table.leaderboard-premium th .sort-btn {
  background: transparent !important;
  border: none !important;
  font-family: inherit;
  font-weight: 700 !important;
  font-size: 12px !important;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #1f2937 !important;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  margin: 0;
  transition: color 0.2s ease;
  line-height: 1.4;
}

table.leaderboard-premium th .sort-btn:hover {
  color: var(--ddna-gold, #ffbb09);
}

table.leaderboard-premium th .sort-btn:focus {
  outline: 2px solid var(--ddna-gold, #ffbb09);
  outline-offset: 2px;
  border-radius: 2px;
}

table.leaderboard-premium th .sort-btn:focus:not(:focus-visible) {
  outline: none;
}

table.leaderboard-premium th .sort-btn:focus-visible {
  outline: 2px solid var(--ddna-gold, #ffbb09);
  outline-offset: 2px;
}

/* Sort direction indicators */
.sort-icon {
  font-size: 10px;
  line-height: 1;
}

th[aria-sort="ascending"] .sort-icon::after {
  content: " \25B2"; /* Up arrow */
}

th[aria-sort="descending"] .sort-icon::after {
  content: " \25BC"; /* Down arrow */
}

th[aria-sort="none"] .sort-icon::after {
  content: " \25B4\25BE"; /* Up/down arrows */
  opacity: 0.3;
}

/* ==========================================================================
   Row Styles
   ========================================================================== */

table.leaderboard-premium tbody tr {
  border-bottom: 1px solid var(--lb-row-border);
  transition: background-color 0.15s ease, transform 0.2s ease;
  will-change: transform, background-color;
}

table.leaderboard-premium tbody tr:last-child {
  border-bottom: none;
}

/* ==========================================================================
   Top 3 Highlighting - Sky Sports Inspired
   ========================================================================== */

/* Gold - 1st place */
table.leaderboard-premium tbody tr[data-rank="1"] {
  background: linear-gradient(90deg, var(--lb-gold-bg) 0%, #fff 100%) !important;
  border-left: 4px solid var(--lb-gold) !important;
}

table.leaderboard-premium tbody tr[data-rank="1"] td {
  background: transparent !important;
}

/* Silver - 2nd place */
table.leaderboard-premium tbody tr[data-rank="2"] {
  background: linear-gradient(90deg, var(--lb-silver-bg) 0%, transparent 100%);
  border-left: 4px solid var(--lb-silver);
}

/* Bronze - 3rd place */
table.leaderboard-premium tbody tr[data-rank="3"] {
  background: linear-gradient(90deg, var(--lb-bronze-bg) 0%, transparent 100%);
  border-left: 4px solid var(--lb-bronze);
}

/* Backward compatibility with existing classes */
table.leaderboard-premium tbody tr.rank-1 {
  background: linear-gradient(90deg, var(--lb-gold-bg) 0%, transparent 100%);
  border-left: 4px solid var(--lb-gold);
}

table.leaderboard-premium tbody tr.rank-2 {
  background: linear-gradient(90deg, var(--lb-silver-bg) 0%, transparent 100%);
  border-left: 4px solid var(--lb-silver);
}

table.leaderboard-premium tbody tr.rank-3 {
  background: linear-gradient(90deg, var(--lb-bronze-bg) 0%, transparent 100%);
  border-left: 4px solid var(--lb-bronze);
}

/* ==========================================================================
   Hover States
   ========================================================================== */

table.leaderboard-premium tbody tr:hover {
  background-color: var(--lb-hover-bg);
  transform: translateX(4px);
}

/* Maintain medal styling on hover for top 3 */
table.leaderboard-premium tbody tr[data-rank="1"]:hover,
table.leaderboard-premium tbody tr.rank-1:hover {
  background: linear-gradient(90deg, rgba(255, 215, 0, 0.25) 0%, var(--lb-hover-bg) 100%);
}

table.leaderboard-premium tbody tr[data-rank="2"]:hover,
table.leaderboard-premium tbody tr.rank-2:hover {
  background: linear-gradient(90deg, rgba(192, 192, 192, 0.25) 0%, var(--lb-hover-bg) 100%);
}

table.leaderboard-premium tbody tr[data-rank="3"]:hover,
table.leaderboard-premium tbody tr.rank-3:hover {
  background: linear-gradient(90deg, rgba(205, 127, 50, 0.25) 0%, var(--lb-hover-bg) 100%);
}

/* ==========================================================================
   Cell Styles
   ========================================================================== */

table.leaderboard-premium tbody td {
  padding: var(--lb-cell-padding);
  font-size: 14px;
  color: #1f2937;
  vertical-align: middle;
}

/* Rank cell */
table.leaderboard-premium tbody td:first-child {
  text-align: center;
  font-weight: 700;
  font-size: 18px;
  width: 80px;
  padding: 16px 12px !important;
}

/* Medal icons for top 3 ranks */
table.leaderboard-premium tbody tr[data-rank="1"] td:first-child,
table.leaderboard-premium tbody tr.rank-1 td:first-child {
  color: var(--lb-gold);
}

table.leaderboard-premium tbody tr[data-rank="2"] td:first-child,
table.leaderboard-premium tbody tr.rank-2 td:first-child {
  color: var(--lb-silver);
}

table.leaderboard-premium tbody tr[data-rank="3"] td:first-child,
table.leaderboard-premium tbody tr.rank-3 td:first-child {
  color: var(--lb-bronze);
}

/* Contestant cell - flex layout for avatar + flag + name + tier */
.contestant-cell {
  padding: 16px 20px !important;
}

/* The link wraps all contestant content - make it flex container */
.contestant-cell .contestant-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

/* Points/Wins cells - right-aligned, tabular numbers */
table.leaderboard-premium tbody td[data-col="points"],
table.leaderboard-premium tbody td[data-col="wins"] {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Portfolio cell */
table.leaderboard-premium tbody td[data-col="portfolio"] {
  text-align: center;
}

/* ==========================================================================
   Avatar Styling
   ========================================================================== */

.contestant-avatar {
  width: var(--lb-avatar-size);
  height: var(--lb-avatar-size);
  min-width: var(--lb-avatar-size);
  min-height: var(--lb-avatar-size);
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 3px solid #e5e7eb;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: #f9fafb;
}

/* Avatar borders for top 3 */
table.leaderboard-premium tbody tr[data-rank="1"] .contestant-avatar,
table.leaderboard-premium tbody tr.rank-1 .contestant-avatar {
  border-color: var(--lb-gold);
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

table.leaderboard-premium tbody tr[data-rank="2"] .contestant-avatar,
table.leaderboard-premium tbody tr.rank-2 .contestant-avatar {
  border-color: var(--lb-silver);
  box-shadow: 0 0 8px rgba(192, 192, 192, 0.4);
}

table.leaderboard-premium tbody tr[data-rank="3"] .contestant-avatar,
table.leaderboard-premium tbody tr.rank-3 .contestant-avatar {
  border-color: var(--lb-bronze);
  box-shadow: 0 0 8px rgba(205, 127, 50, 0.4);
}

/* Contestant details container */
.contestant-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

/* Contestant name row with tier */
.contestant-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.contestant-name {
  font-weight: 600;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contestant-name a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

.contestant-name a:hover {
  color: var(--ddna-gold, #ffbb09);
}

/* Country flag */
.contestant-flag {
  flex-shrink: 0;
}

.contestant-flag img,
.contestant-flag .flag-icon {
  width: 24px;
  height: auto;
  border-radius: 2px;
  vertical-align: middle;
}

/* ==========================================================================
   Tier Badge Styles (Extended from leaderboard-enhanced.css)
   ========================================================================== */

.tier-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.tier-badge--beginner {
  background-color: #6b7280;
  color: #ffffff;
}

.tier-badge--intermediate {
  background-color: #3b82f6;
  color: #ffffff;
}

.tier-badge--advanced {
  background-color: #f59e0b;
  color: #1f2937;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

/* ==========================================================================
   Portfolio Link Styles (Extended from leaderboard-enhanced.css)
   ========================================================================== */

.portfolio-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  background-color: transparent;
  border: 1px solid var(--ddna-gold, #ffbb09);
  color: var(--ddna-gold, #ffbb09);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.portfolio-link:hover {
  background-color: var(--ddna-gold, #ffbb09);
  color: #1f2937;
  text-decoration: none;
}

.portfolio-link:focus {
  outline: 2px solid var(--ddna-gold, #ffbb09);
  outline-offset: 2px;
}

/* Empty portfolio cell placeholder */
.portfolio-cell--empty {
  color: #9ca3af;
  font-size: 13px;
}

/* ==========================================================================
   Profile Completion Prompt
   ========================================================================== */

.profile-prompt {
  background-color: #fef3cd;
  border: 1px solid var(--ddna-gold, #ffbb09);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-prompt__icon {
  font-size: 20px;
  flex-shrink: 0;
}

.profile-prompt__text {
  flex: 1;
  font-size: 14px;
  color: #1f2937;
  margin: 0;
}

.profile-prompt__link {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  background-color: var(--ddna-gold, #ffbb09);
  color: #1f2937;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.2s ease;
  white-space: nowrap;
}

.profile-prompt__link:hover {
  background-color: #e6a808;
  color: #1f2937;
  text-decoration: none;
}

/* ==========================================================================
   Row Enter Animation (for filtering)
   ========================================================================== */

@keyframes rowEnter {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

table.leaderboard-premium tbody tr.entering {
  animation: rowEnter 0.3s ease forwards;
}

/* ==========================================================================
   Hidden Row State (for filtering - NOT display:none)
   ========================================================================== */

table.leaderboard-premium tbody tr.hidden {
  opacity: 0;
  height: 0;
  padding: 0;
  overflow: hidden;
  border: none;
  pointer-events: none;
  transition: opacity 0.2s ease, height 0.2s ease;
}

table.leaderboard-premium tbody tr.hidden td {
  padding: 0;
  border: none;
  height: 0;
  overflow: hidden;
}

/* ==========================================================================
   Pagination Styles
   ========================================================================== */

.leaderboard-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
  padding: 16px 0;
}

.leaderboard-pagination button,
.leaderboard-pagination .page-btn {
  padding: 8px 14px;
  border: 1px solid var(--lb-row-border);
  border-radius: 6px;
  background: #ffffff;
  color: #374151;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.leaderboard-pagination button:hover:not(:disabled),
.leaderboard-pagination .page-btn:hover:not(.active) {
  border-color: var(--ddna-gold, #ffbb09);
  color: var(--ddna-gold, #ffbb09);
}

.leaderboard-pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.leaderboard-pagination .page-btn.active {
  background: var(--ddna-gold, #ffbb09);
  border-color: var(--ddna-gold, #ffbb09);
  color: #1f2937;
}

.leaderboard-pagination button:focus,
.leaderboard-pagination .page-btn:focus {
  outline: 2px solid var(--ddna-gold, #ffbb09);
  outline-offset: 2px;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.leaderboard-empty {
  text-align: center;
  padding: 60px 20px;
  color: #6b7280;
}

.leaderboard-empty p {
  margin: 0 0 16px 0;
  font-size: 16px;
}

.leaderboard-empty .btn-primary {
  display: inline-flex;
  align-items: center;
  padding: 10px 20px;
  background: var(--ddna-gold, #ffbb09);
  color: #1f2937;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.leaderboard-empty .btn-primary:hover {
  background: #e6a808;
  text-decoration: none;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.leaderboard-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: #6b7280;
}

.leaderboard-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--lb-row-border);
  border-top-color: var(--ddna-gold, #ffbb09);
  border-radius: 50%;
  animation: leaderboard-spin 0.8s linear infinite;
}

@keyframes leaderboard-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

/* Medium desktop - reduce padding, smaller avatar */
@media (max-width: 992px) {
  :root {
    --lb-cell-padding: 10px 12px;
    --lb-avatar-size: 36px;
  }

  table.leaderboard-premium thead th {
    font-size: 12px;
  }

  table.leaderboard-premium tbody td {
    font-size: 13px;
  }

  .tier-badge {
    font-size: 10px;
    padding: 2px 6px;
  }

  .portfolio-link {
    font-size: 12px;
    padding: 5px 10px;
  }
}

/* Tablet - stack controls, smaller fonts */
@media (max-width: 768px) {
  :root {
    --lb-cell-padding: 8px 10px;
    --lb-avatar-size: 32px;
  }

  .leaderboard-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .leaderboard-search {
    max-width: none;
  }

  .leaderboard-filters {
    justify-content: space-between;
  }

  .leaderboard-filters select {
    flex: 1;
    min-width: 0;
  }

  .leaderboard-results-count {
    text-align: center;
    margin-left: 0;
    width: 100%;
    padding-top: 8px;
    border-top: 1px solid var(--lb-row-border);
  }

  table.leaderboard-premium thead th {
    font-size: 11px;
    padding: 8px 8px;
  }

  table.leaderboard-premium tbody td {
    font-size: 12px;
  }

  table.leaderboard-premium tbody td:first-child {
    font-size: 14px;
    width: 50px;
  }

  .contestant-cell {
    gap: 8px;
  }

  .contestant-name-row {
    gap: 4px;
  }

  .tier-badge {
    font-size: 9px;
    padding: 1px 5px;
  }

  .portfolio-link {
    font-size: 11px;
    padding: 4px 8px;
  }

  .profile-prompt {
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }
}

/* Small mobile - hide tier badges, compact layout */
@media (max-width: 576px) {
  :root {
    --lb-cell-padding: 6px 8px;
    --lb-avatar-size: 28px;
  }

  .leaderboard-premium-container {
    padding: 16px;
  }

  table.leaderboard-premium thead th {
    font-size: 10px;
    padding: 6px 6px;
    letter-spacing: 0.3px;
  }

  table.leaderboard-premium tbody td {
    font-size: 11px;
  }

  table.leaderboard-premium tbody td:first-child {
    font-size: 13px;
    width: 40px;
  }

  /* Hide tier badges on very small screens */
  .tier-badge {
    display: none;
  }

  .contestant-cell {
    gap: 6px;
  }

  .contestant-flag img,
  .contestant-flag .flag-icon {
    width: 18px;
  }

  .portfolio-link {
    font-size: 10px;
    padding: 3px 6px;
  }

  /* Truncate long names */
  .contestant-name {
    max-width: 100px;
  }
}

/* Extra small mobile - card-style consideration */
@media (max-width: 480px) {
  :root {
    --lb-avatar-size: 24px;
  }

  table.leaderboard-premium thead th {
    font-size: 9px;
    padding: 5px 4px;
  }

  /* Consider horizontal scroll for very small screens */
  .leaderboard-premium {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .leaderboard-premium table {
    min-width: 500px;
  }

  .leaderboard-filters select {
    font-size: 13px;
  }

  /* Smaller pagination */
  .leaderboard-pagination button,
  .leaderboard-pagination .page-btn {
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* Reduced motion - disable animations */
@media (prefers-reduced-motion: reduce) {
  table.leaderboard-premium tbody tr {
    transition: none;
  }

  table.leaderboard-premium tbody tr.entering {
    animation: none;
    opacity: 1;
    transform: none;
  }

  table.leaderboard-premium tbody tr.hidden {
    transition: none;
  }

  .portfolio-link,
  .profile-prompt__link,
  .leaderboard-search input,
  .leaderboard-filters select {
    transition: none;
  }

  .leaderboard-loading-spinner {
    animation: none;
    border-top-color: var(--ddna-gold, #ffbb09);
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .leaderboard-premium {
    border: 2px solid #000;
  }

  table.leaderboard-premium thead th {
    border-bottom: 3px solid #000;
  }

  table.leaderboard-premium tbody tr {
    border-bottom: 2px solid #000;
  }

  table.leaderboard-premium tbody tr[data-rank="1"],
  table.leaderboard-premium tbody tr.rank-1 {
    border-left: 6px solid var(--lb-gold);
  }

  table.leaderboard-premium tbody tr[data-rank="2"],
  table.leaderboard-premium tbody tr.rank-2 {
    border-left: 6px solid var(--lb-silver);
  }

  table.leaderboard-premium tbody tr[data-rank="3"],
  table.leaderboard-premium tbody tr.rank-3 {
    border-left: 6px solid var(--lb-bronze);
  }

  .tier-badge--beginner {
    background-color: #4b5563;
    border: 2px solid #000;
  }

  .tier-badge--intermediate {
    background-color: #2563eb;
    border: 2px solid #000;
  }

  .tier-badge--advanced {
    background-color: #d97706;
    border: 2px solid #000;
    color: #000;
  }

  .portfolio-link {
    border-width: 2px;
  }

  .leaderboard-search input[type="search"],
  .leaderboard-filters select {
    border-width: 2px;
  }
}

/* Focus visible states for keyboard navigation */
table.leaderboard-premium tbody tr:focus-within {
  outline: 2px solid var(--ddna-gold, #ffbb09);
  outline-offset: -2px;
}

/* Skip link for keyboard users */
.leaderboard-skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--ddna-gold, #ffbb09);
  color: #1f2937;
  padding: 8px 16px;
  z-index: 100;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 8px 0;
}

.leaderboard-skip-link:focus {
  top: 0;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
  .leaderboard-controls,
  .leaderboard-pagination,
  .profile-prompt {
    display: none;
  }

  .leaderboard-premium {
    box-shadow: none;
    border: 1px solid #000;
  }

  table.leaderboard-premium thead th {
    position: static;
    background: #f3f4f6;
  }

  table.leaderboard-premium tbody tr {
    page-break-inside: avoid;
  }

  table.leaderboard-premium tbody tr[data-rank="1"],
  table.leaderboard-premium tbody tr[data-rank="2"],
  table.leaderboard-premium tbody tr[data-rank="3"],
  table.leaderboard-premium tbody tr.rank-1,
  table.leaderboard-premium tbody tr.rank-2,
  table.leaderboard-premium tbody tr.rank-3 {
    background: #f3f4f6 !important;
  }

  .portfolio-link {
    border: 1px solid #000;
    color: #000;
  }
}

/* ==========================================================================
   Integration with Existing Styles
   ========================================================================== */

/* Ensure compatibility with .leaderboard-enhanced legacy class */
.leaderboard-enhanced.leaderboard-premium .player,
.leaderboard-enhanced.leaderboard-premium .leaderboard-header {
  display: contents; /* Allow table row display when inside table */
}

/* ==========================================================================
   Hero Section - Leaderboard Stats + Podium
   ========================================================================== */

.leaderboard-hero {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  color: #ffffff;
  padding: 48px 24px 56px;
  margin: -24px -24px 24px -24px; /* Bleed to edges of container */
  border-radius: var(--ddna-card-radius, 12px) var(--ddna-card-radius, 12px) 0 0;
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* Subtle pattern overlay */
.leaderboard-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: radial-gradient(circle at 20% 80%, rgba(255, 187, 9, 0.1) 0%, transparent 50%),
                    radial-gradient(circle at 80% 20%, rgba(255, 187, 9, 0.08) 0%, transparent 40%);
  pointer-events: none;
}

.leaderboard-hero__title {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 8px 0;
  position: relative;
  z-index: 1;
}

.leaderboard-hero__subtitle {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.7);
  margin: 0 0 32px 0;
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   Stats Row
   ========================================================================== */

.stats-row {
  display: flex;
  justify-content: center;
  gap: 48px;
  margin-bottom: 40px;
  position: relative;
  z-index: 1;
}

.stat-item {
  text-align: center;
}

.stat-item__number {
  display: block;
  font-size: 42px;
  font-weight: 800;
  color: var(--ddna-gold, #ffbb09);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-item__label {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

/* ==========================================================================
   Podium Section
   ========================================================================== */

.podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 32px;
  position: relative;
  z-index: 1;
}

.podium__place {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 20px 16px 16px;
  transition: transform 0.2s ease, background-color 0.2s ease;
  text-decoration: none;
  color: inherit;
}

.podium__place:hover {
  transform: translateY(-4px);
  background: rgba(255, 255, 255, 0.1);
}

/* Place-specific styling */
.podium__place--1 {
  order: 2;
  padding-bottom: 32px;
  min-width: 140px;
}

.podium__place--2 {
  order: 1;
  min-width: 120px;
}

.podium__place--3 {
  order: 3;
  min-width: 120px;
}

/* Podium avatars */
.podium__avatar-wrapper {
  position: relative;
  margin-bottom: 12px;
}

.podium__avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid transparent;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.podium__place--1 .podium__avatar {
  width: 80px;
  height: 80px;
  border-color: var(--lb-gold);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.podium__place--2 .podium__avatar {
  border-color: var(--lb-silver);
  box-shadow: 0 0 16px rgba(192, 192, 192, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.podium__place--3 .podium__avatar {
  border-color: var(--lb-bronze);
  box-shadow: 0 0 16px rgba(205, 127, 50, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Medal badge */
.podium__medal {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #1f2937;
}

.podium__place--1 .podium__medal {
  background: var(--lb-gold);
  width: 32px;
  height: 32px;
  font-size: 16px;
}

.podium__place--2 .podium__medal {
  background: var(--lb-silver);
}

.podium__place--3 .podium__medal {
  background: var(--lb-bronze);
}

.podium__name {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 4px;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.podium__points {
  font-size: 18px;
  font-weight: 700;
  color: var(--ddna-gold, #ffbb09);
}

.podium__points-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==========================================================================
   Hero CTA
   ========================================================================== */

.hero-cta {
  position: relative;
  z-index: 1;
}

.hero-cta__button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: var(--ddna-gold, #ffbb09);
  color: #1f2937;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.hero-cta__button:hover {
  background: #e6a808;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 187, 9, 0.4);
  color: #1f2937;
  text-decoration: none;
}

.hero-cta__button:focus {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.hero-cta__rank {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 12px;
}

.hero-cta__rank strong {
  color: var(--ddna-gold, #ffbb09);
  font-weight: 700;
}

/* ==========================================================================
   Badge Grid (Scoring Section)
   ========================================================================== */

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.badge-grid__item {
  background: #ffffff;
  border-radius: 12px;
  padding: 20px 16px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.badge-grid__item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.badge-grid__icon {
  width: 56px;
  height: 56px;
  object-fit: contain;
  margin-bottom: 12px;
}

.badge-grid__name {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 6px;
}

.badge-grid__points {
  font-size: 22px;
  font-weight: 800;
  color: var(--ddna-gold, #ffbb09);
}

.badge-grid__points-label {
  font-size: 11px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Badge tier dividers */
.badge-tier {
  margin-bottom: 32px;
}

.badge-tier__label {
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge-tier__label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e5e5e5;
}

/* Champion tier special styling */
.badge-tier--champion .badge-grid__item {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.08) 0%, #ffffff 100%);
  border: 1px solid rgba(255, 215, 0, 0.2);
}

/* ==========================================================================
   Certificate Cards (Premium)
   ========================================================================== */

.certificate-grid {
  display: grid;
  gap: 20px;
}

.certificate-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.certificate-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

.certificate-card__gradient-top {
  height: 6px;
}

.certificate-card--creative .certificate-card__gradient-top {
  background: linear-gradient(90deg, #6c63ff 0%, #8b5cf6 100%);
}

.certificate-card--story .certificate-card__gradient-top {
  background: linear-gradient(90deg, #f59e0b 0%, #f97316 100%);
}

.certificate-card--problem .certificate-card__gradient-top {
  background: linear-gradient(90deg, #10b981 0%, #059669 100%);
}

.certificate-card--accessibility .certificate-card__gradient-top {
  background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
}

.certificate-card__content {
  padding: 24px;
}

.certificate-card__header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.certificate-card__icon {
  width: 56px;
  height: 56px;
  object-fit: contain;
  flex-shrink: 0;
}

.certificate-card__title {
  font-size: 18px;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
}

.certificate-card__description {
  font-size: 14px;
  color: #4b5563;
  line-height: 1.6;
  margin: 0 0 16px 0;
}

.certificate-card__protip {
  background: #f9fafb;
  border-radius: 8px;
  padding: 12px 16px;
  border-left: 3px solid var(--ddna-gold, #ffbb09);
}

.certificate-card__protip-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ddna-gold, #ffbb09);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.certificate-card__protip-text {
  font-size: 13px;
  color: #374151;
  margin: 0;
}

/* ==========================================================================
   Scoring Section Premium Wrapper
   ========================================================================== */

.scoring-section-premium {
  background: #f9fafb;
  border-radius: 12px;
  padding: 32px;
  margin-bottom: 32px;
}

.scoring-section-premium__title {
  font-size: 24px;
  font-weight: 700;
  color: #1f2937;
  margin: 0 0 8px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.scoring-section-premium__subtitle {
  font-size: 14px;
  color: #6b7280;
  margin: 0 0 24px 0;
}

.scoring-section-premium__footnote {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e5e5e5;
}

/* Certificate section wrapper */
.certificate-section-premium {
  padding: 32px 0;
}

.certificate-section-premium__title {
  font-size: 24px;
  font-weight: 700;
  color: #1f2937;
  margin: 0 0 8px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.certificate-section-premium__subtitle {
  font-size: 14px;
  color: #6b7280;
  margin: 0 0 24px 0;
}

/* ==========================================================================
   Hero + Badge/Certificate Responsive Breakpoints
   ========================================================================== */

@media (max-width: 768px) {
  .leaderboard-hero {
    padding: 32px 16px 40px;
    margin: -16px -16px 20px -16px;
  }

  .leaderboard-hero__title {
    font-size: 22px;
  }

  .stats-row {
    gap: 24px;
    flex-wrap: wrap;
  }

  .stat-item__number {
    font-size: 32px;
  }

  .stat-item__label {
    font-size: 11px;
  }

  .podium {
    gap: 8px;
  }

  .podium__place {
    padding: 16px 12px 12px;
    min-width: auto;
    flex: 1;
    max-width: 110px;
  }

  .podium__place--1 {
    padding-bottom: 20px;
  }

  .podium__avatar {
    width: 52px;
    height: 52px;
  }

  .podium__place--1 .podium__avatar {
    width: 64px;
    height: 64px;
  }

  .podium__medal {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .podium__place--1 .podium__medal {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  .podium__name {
    font-size: 12px;
    max-width: 80px;
  }

  .podium__points {
    font-size: 16px;
  }

  .hero-cta__button {
    padding: 12px 24px;
    font-size: 14px;
  }

  .badge-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .badge-grid__item {
    padding: 16px 12px;
  }

  .badge-grid__icon {
    width: 44px;
    height: 44px;
  }

  .badge-grid__name {
    font-size: 12px;
  }

  .badge-grid__points {
    font-size: 18px;
  }

  .scoring-section-premium,
  .certificate-section-premium {
    padding: 20px;
  }

  .certificate-card__content {
    padding: 16px;
  }

  .certificate-card__icon {
    width: 44px;
    height: 44px;
  }

  .certificate-card__title {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .leaderboard-hero {
    padding: 24px 12px 32px;
    margin: -12px -12px 16px -12px;
  }

  .leaderboard-hero__title {
    font-size: 18px;
  }

  .leaderboard-hero__subtitle {
    font-size: 13px;
    margin-bottom: 24px;
  }

  .stats-row {
    gap: 16px;
  }

  .stat-item__number {
    font-size: 28px;
  }

  .podium__place {
    padding: 12px 8px 10px;
    max-width: 90px;
  }

  .podium__avatar {
    width: 44px;
    height: 44px;
  }

  .podium__place--1 .podium__avatar {
    width: 56px;
    height: 56px;
  }

  .podium__name {
    font-size: 11px;
    max-width: 70px;
  }

  .podium__points {
    font-size: 14px;
  }

  .badge-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .badge-grid__item {
    padding: 12px 8px;
  }

  .badge-grid__icon {
    width: 36px;
    height: 36px;
    margin-bottom: 8px;
  }

  .badge-grid__name {
    font-size: 11px;
  }

  .badge-grid__points {
    font-size: 16px;
  }

  .certificate-card__header {
    flex-direction: column;
    text-align: center;
  }

  .certificate-card__protip {
    padding: 10px 12px;
  }
}
