/**
 * Phase 9 — Leaderboard flow (.rr-lb-hub).
 * Reuses rr-lb-table, rr-tab-pill, rr-podium-*, rr-data-table from Phase 1/2/15.
 */

.rr-lb-hub {
  padding-top: clamp(1.75rem, 4vw, 2.75rem);
  padding-bottom: clamp(2.5rem, 5vw, 4rem);
}

.rr-lb-hub > .container {
  max-width: var(--rr-shell-max, 72rem);
  padding-left: var(--rr-shell-pad-x, 1rem);
  padding-right: var(--rr-shell-pad-x, 1rem);
}

/* Hero */
.rr-lb-hero .container {
  position: relative;
  z-index: 1;
}

.rr-lb-hero .breadcrumb-item a {
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
}

.rr-lb-hero .breadcrumb-item a:hover {
  color: #fff;
}

.rr-lb-hero h1 {
  font-size: clamp(1.75rem, 3.5vw, 2.35rem);
  max-width: 22ch;
}

.rr-lb-hero-lead {
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.55;
  margin-bottom: 0;
}

.rr-lb-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.rr-lb-hero-meta .rr-meta-pill {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.rr-lb-hero-meta .rr-meta-pill i {
  color: var(--rr-orange);
}

.rr-lb-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.85rem;
  text-decoration: none;
  margin-bottom: 0.85rem;
}

.rr-lb-back-link:hover {
  color: #fff;
}

/* Nav pills */
.rr-lb-nav-shell {
  background: #fff;
  border: 1px solid rgba(11, 18, 32, 0.06);
  border-radius: var(--rr-radius);
  box-shadow: var(--rr-shadow-sm);
  padding: clamp(0.85rem, 2vw, 1.1rem);
  margin-bottom: 1.35rem;
  text-align: center;
}

.rr-lb-nav-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
}

.rr-lb-nav-row + .rr-lb-nav-row {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(11, 18, 32, 0.06);
}

/* Qualification rules */
.rr-lb-rules-panel {
  background: #fff;
  border: 1px solid rgba(11, 18, 32, 0.06);
  border-radius: var(--rr-radius);
  box-shadow: var(--rr-shadow-sm);
  padding: 1rem 1.15rem;
  margin-bottom: 1.35rem;
}

.rr-lb-rules-panel h2 {
  font-family: var(--rr-display);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.95rem;
  color: var(--rr-ink);
  margin: 0 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.rr-lb-rules-panel h2 .bi {
  color: var(--rr-orange);
}

.rr-lb-rules-lead {
  font-size: 0.82rem;
  color: var(--rr-muted);
  margin-bottom: 0.75rem;
  line-height: 1.45;
}

.rr-lb-rules-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.rr-lb-rules-list li {
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--rr-text);
  padding: 0.55rem 0.65rem;
  background: var(--rr-light);
  border-radius: 10px;
  border: 1px solid rgba(11, 18, 32, 0.05);
}

.rr-lb-rules-list li strong {
  color: var(--rr-orange);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  margin-right: 0.35rem;
}

/* Podium */
.rr-lb-hub .rr-podium-wrap {
  margin: 0 0 1.25rem;
  gap: 0.75rem;
}

.rr-lb-hub .rr-podium-card {
  min-width: 0;
  flex: 1 1 0;
  max-width: 220px;
  padding: 1.1rem 0.85rem;
}

.rr-podium-medal {
  font-size: 1.75rem;
  margin-bottom: 0.35rem;
  line-height: 1;
}

.rr-podium-name {
  font-weight: 700;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.rr-podium-sub {
  font-size: 0.72rem;
  opacity: 0.85;
  line-height: 1.35;
}

.rr-podium-value {
  font-weight: 800;
  font-size: 1.25rem;
  margin-top: 0.5rem;
  font-family: var(--rr-display);
  letter-spacing: 0.02em;
}

.rr-podium-unit {
  font-size: 0.7rem;
  opacity: 0.85;
}

@media (max-width: 767.98px) {
  .rr-lb-hub .rr-podium-wrap {
    flex-direction: column;
    align-items: stretch;
    max-width: 20rem;
    margin-inline: auto;
  }

  .rr-lb-hub .rr-podium-card {
    max-width: none;
    width: 100%;
    transform: none !important;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    gap: 0.15rem 0.65rem;
    align-items: center;
    text-align: left;
    padding: 0.85rem 1rem;
  }

  .rr-lb-hub .rr-podium-1 {
    order: 1;
  }

  .rr-lb-hub .rr-podium-2 {
    order: 2;
  }

  .rr-lb-hub .rr-podium-3 {
    order: 3;
  }

  .rr-podium-medal {
    grid-row: 1 / span 2;
    margin: 0;
    font-size: 1.5rem;
  }

  .rr-podium-name {
    grid-column: 2;
  }

  .rr-podium-sub {
    grid-column: 2;
  }

  .rr-podium-value {
    grid-column: 3;
    grid-row: 1;
    margin: 0;
    text-align: right;
    font-size: 1.1rem;
  }

  .rr-podium-unit {
    grid-column: 3;
    grid-row: 2;
    text-align: right;
  }
}

/* Toolbar + search */
.rr-lb-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.rr-lb-search {
  position: relative;
  flex: 1 1 240px;
  max-width: 420px;
}

.rr-lb-search > i {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--rr-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.rr-lb-search .form-control {
  padding-left: 2.2rem;
  padding-right: 2.6rem;
  border-radius: 999px;
  border: 1px solid #dde3ec;
  font-size: 0.9rem;
  min-height: 2.45rem;
}

.rr-lb-search .form-control:focus {
  border-color: rgba(236, 105, 1, 0.45);
  box-shadow: 0 0 0 3px rgba(236, 105, 1, 0.12);
}

.rr-lb-clear {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 0;
  background: #e8edf3;
  color: #5b6578;
  line-height: 1;
}

.rr-lb-clear i {
  font-size: 0.75rem;
}

.rr-lb-clear:hover {
  background: #dde3ec;
  color: #0b1220;
}

.rr-lb-hint {
  font-weight: 500;
  margin-bottom: 0.65rem;
}

.rr-lb-panel {
  background: #fff;
  border: 1px solid rgba(11, 18, 32, 0.06);
  border-radius: var(--rr-radius);
  box-shadow: var(--rr-shadow-sm);
  overflow: hidden;
}

.rr-lb-panel .rr-data-table {
  margin: 0;
}

/* Table highlights */
#lbTable tbody tr.rr-lb-hit {
  background: rgba(236, 105, 1, 0.12) !important;
  outline: 2px solid rgba(236, 105, 1, 0.35);
  outline-offset: -2px;
}

#lbTable tbody tr.rr-lb-near {
  background: rgba(61, 90, 128, 0.05);
}

#lbTable tbody tr.rr-lb-gap-row td {
  border-top: 1px dashed rgba(61, 90, 128, 0.25);
  font-size: 0.78rem;
  color: var(--rr-muted);
  background: #f7f9fc;
  text-align: center;
  padding: 0.35rem 0.75rem;
}

.rr-lb-hub .rr-lb-table thead th {
  font-size: 0.72rem;
  white-space: nowrap;
  padding: 0.85rem 0.75rem;
}

.rr-lb-hub .rr-lb-table tbody td {
  padding: 0.75rem 0.75rem;
  vertical-align: middle;
}

.rr-lb-hub .my-row {
  background: rgba(236, 105, 1, 0.06) !important;
}

.rr-lb-you-badge {
  background: var(--rr-orange) !important;
  font-size: 0.65rem;
}

.rr-lb-rider-avatar {
  width: 32px;
  height: 32px;
  font-size: 0.8rem;
  background: var(--rr-orange);
}

.rr-lb-footnote {
  text-align: center;
  color: var(--rr-muted);
  font-size: 0.82rem;
  margin-top: 1rem;
  line-height: 1.45;
}

/* Mobile ranking cards */
.rr-lb-mobile-list {
  display: none;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.85rem;
}

.rr-lb-mrow {
  border: 1px solid rgba(11, 18, 32, 0.08);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  background: #fff;
}

.rr-lb-mrow.my-row {
  border-color: rgba(236, 105, 1, 0.35);
  background: rgba(236, 105, 1, 0.06);
}

.rr-lb-mrow.rr-lb-hit {
  outline: 2px solid rgba(236, 105, 1, 0.35);
  background: rgba(236, 105, 1, 0.1);
}

.rr-lb-mrow.rr-lb-near {
  background: rgba(61, 90, 128, 0.04);
}

.rr-lb-mrow-top {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin-bottom: 0.45rem;
}

.rr-lb-mrow-main {
  flex: 1;
  min-width: 0;
}

.rr-lb-mrow-title {
  font-weight: 700;
  color: var(--rr-ink);
  font-size: 0.92rem;
  line-height: 1.35;
}

.rr-lb-mrow-sub {
  font-size: 0.78rem;
  color: var(--rr-muted);
  margin-top: 0.15rem;
  line-height: 1.35;
}

.rr-lb-mrow-score {
  text-align: right;
  flex-shrink: 0;
}

.rr-lb-mrow-score .val {
  font-family: var(--rr-display);
  font-weight: 800;
  color: var(--rr-orange);
  font-size: 1.15rem;
  line-height: 1.1;
}

.rr-lb-mrow-score .unit {
  font-size: 0.68rem;
  color: var(--rr-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.rr-lb-mrow-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  font-size: 0.75rem;
  color: var(--rr-text);
}

.rr-lb-mrow-meta span::after {
  content: " · ";
  color: var(--rr-muted);
}

.rr-lb-mrow-meta span:last-child::after {
  content: "";
}

.rr-lb-gap-card {
  text-align: center;
  font-size: 0.78rem;
  color: var(--rr-muted);
  padding: 0.45rem;
  background: #f7f9fc;
  border-radius: 8px;
  border: 1px dashed rgba(61, 90, 128, 0.25);
}

@media (max-width: 767.98px) {
  .rr-lb-desktop {
    display: none !important;
  }

  .rr-lb-mobile-list {
    display: flex;
  }
}

/* Daily toppers */
.rr-lb-toppers-grid .rr-topper-card {
  height: 100%;
}

.rr-lb-toppers-grid .tc-avatar {
  width: 42px;
  height: 42px;
  font-size: 0.95rem;
}

.rr-lb-toppers-icon {
  font-size: 2.2rem;
  margin-bottom: 0.35rem;
  line-height: 1;
}

.rr-lb-toppers-empty {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}

.rr-lb-empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.7;
  line-height: 1;
}

/* Team details expand */
.rr-lb-team-toggle {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--rr-orange);
  text-decoration: none;
}

.rr-lb-team-toggle:hover,
.rr-lb-team-toggle:focus {
  color: var(--rr-orange-deep);
  text-decoration: underline;
}

.rr-lb-team-toggle.is-open {
  color: var(--rr-ink);
}

.rr-lb-team-detail-row td {
  background: var(--rr-light);
  border-top: 0;
  padding: 0 0.75rem 0.85rem;
}

.rr-lb-team-detail-panel {
  background: #fff;
  border: 1px solid rgba(11, 18, 32, 0.08);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
}

.rr-lb-team-detail-panel--mobile {
  padding: 0.75rem 0.85rem;
}

.rr-lb-team-detail-title {
  font-family: var(--rr-display);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.88rem;
  color: var(--rr-ink);
  margin: 0 0 0.35rem;
}

.rr-lb-team-member-table thead th {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.rr-lb-team-member-table tbody td {
  font-size: 0.82rem;
  vertical-align: middle;
}

@media (max-width: 767.98px) {
  .rr-lb-team-member-table .rr-lb-tm-city,
  .rr-lb-team-member-table .rr-lb-tm-mid {
    display: none;
  }

  .rr-lb-team-names-preview {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rr-lb-hub .rr-podium-1 {
    transform: none !important;
  }
}
