/* =============================================================================
   RANKED PAGE STYLES
   ============================================================================= */
@import url('ranked-leaderboard.css');

/* ===== ROOT & LAYOUT ===== */
.ranked-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  padding-top: calc(70px + env(safe-area-inset-top, 0px) + 32px);
  padding-bottom: 100px;
}

/* ===== TWO-COLUMN LAYOUT ===== */
.ranked-main-content {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 24px;
}

.ranked-left-col {
  flex: 1;
  min-width: 0;
  position: sticky;
  top: calc(70px + env(safe-area-inset-top, 0px) + 32px);
}

.ranked-right-col {
  flex: 1;
  min-width: 0;
}

/* Mobile tab bar — hidden on desktop */
.mobile-ranked-tabs {
  display: none;
}

/* ===== LOADING STATE ===== */
.ranked-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: rgba(255, 255, 255, 0.5);
}
.ranked-loading p { margin-top: 16px; font-size: 14px; }

/* ===== NOT LOGGED IN ===== */
.ranked-not-logged-in {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
  gap: 12px;
}
.ranked-empty-icon { color: rgba(255, 255, 255, 0.2); margin-bottom: 8px; }
.ranked-not-logged-in h2 { color: #fff; margin: 0; font-size: 20px; }
.ranked-not-logged-in p { margin: 0; font-size: 14px; max-width: 360px; }
.ranked-login-btn {
  margin-top: 12px;
  padding: 10px 24px;
  background: #00D3BD;
  color: #0a1628;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.ranked-login-btn:hover { opacity: 0.85; }

/* ===== GLASS CARD HELPER ===== */
.glass-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.ranked-section-title {
  font-size: 15px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  margin: 0 0 16px 0;
}

.ranked-empty-text {
  color: rgba(255, 255, 255, 0.4);
  font-size: 13px;
  margin: 0;
}

/* ===== RANK OVERVIEW CARD — liquid glass ===== */
.rank-overview-card {
  background: var(--bg-base, #0a1628);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 20px 28px 28px;
  margin-bottom: 40px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 24px;
  position: relative;
  overflow: visible;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 4px 24px rgba(0, 0, 0, 0.3),
    0 1px 3px rgba(0, 0, 0, 0.15);
}

.rank-overview-glow {
  display: none;
}

/* Keep content above the glow layer */
.rank-overview-main,
.rank-overview-stats {
  position: relative;
  z-index: 1;
}

/* ===== INTEGRATED TABS — pill row on bottom edge of card ===== */
.rank-card-tabs {
  display: flex;
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  gap: 12px;
  z-index: 2;
}

.rank-card-tab {
  padding: 8px 22px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  background: #0a1628;
  color: rgba(255, 255, 255, 0.45);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.rank-card-tab.active {
  background: #1a2a40;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

.rank-card-tab.has-live::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e74c3c;
  margin-right: 5px;
  vertical-align: middle;
  position: relative;
  top: -2px;
  animation: rank-tab-live-pulse 1.5s ease-in-out infinite;
}

@keyframes rank-tab-live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Hide Live tab when no live content */
body.mobile-no-live .rank-card-tab[data-tab="live"] {
  display: none;
}

/* ===== HORIZONTAL MAIN ROW (circle + info) ===== */
.rank-overview-main {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-shrink: 0;
}

.rank-overview-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
}

/* ===== USERNAME ROW ===== */
.rank-username-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rank-username-display {
  font-size: 20px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.rank-username-display.rank-username-placeholder {
  color: rgba(255, 255, 255, 0.3);
  font-style: italic;
}

.rank-username-edit-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.35);
  font-size: 12px;
  padding: 2px 4px;
  cursor: pointer;
  transition: color 0.15s;
  flex-shrink: 0;
}
.rank-username-edit-btn:hover { color: rgba(255, 255, 255, 0.8); }

.rank-username-input {
  display: none;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 2px 8px;
  outline: none;
  width: 180px;
  font-family: inherit;
}
.rank-username-input:focus {
  border-color: rgba(255, 255, 255, 0.3);
}
.rank-username-input.active {
  display: inline-block;
}

/* ===== CIRCULAR PROGRESS RING ===== */
.rank-circle-wrap {
  position: relative;
  width: 110px;
  height: 110px;
  flex-shrink: 0;
}

.rank-progress-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.rank-progress-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 8;
}

.rank-progress-fill {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}

.rank-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rank-badge svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.rank-badge img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ===== GOAT — hide ring, enlarge badge ===== */
.rank-circle-wrap.is-goat {
  width: 74px;
  height: 74px;
}

.rank-circle-wrap.is-goat .rank-progress-ring {
  display: none;
}

.rank-circle-wrap.is-goat .rank-badge {
  width: 90px;
  height: 90px;
}

.rank-tier-label {
  display: block;
  font-size: 20px;
  font-weight: 700;
}

.rank-rr-label {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.5);
}

/* Circle + label column wrapper */
.rank-circle-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

/* Desktop: show label in info block, hide below circle */
.rank-rr-label-mobile { display: none; }
.rank-rr-label-desktop { display: block; }

.rank-available-rr {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
}

.rank-available-rr i {
  margin-right: 3px;
  font-size: 11px;
}

/* ===== OVERVIEW STATS — horizontal, spread across remaining space ===== */
.rank-overview-stats {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-evenly;
  flex: 1;
  min-width: 0;
}

.rank-overview-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.rank-overview-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
}

.rank-overview-stat-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.rank-reset-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.4);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}
.rank-reset-btn:hover {
  color: #F44336;
  border-color: rgba(244, 67, 54, 0.4);
}
.rank-reset-btn i { margin-right: 4px; }

/* ===== STATS CARDS ===== */
.ranked-stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.ranked-stat-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 14px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ranked-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

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

.stat-positive { color: #4CAF50; }
.stat-negative { color: #F44336; }

/* ===== CHART ===== */
.ranked-chart-card { position: relative; }

.ranked-chart-wrap {
  height: 250px;
  position: relative;
}

.ranked-chart-empty {
  text-align: center;
  padding: 40px 0;
  color: rgba(255, 255, 255, 0.4);
  font-size: 13px;
}

/* ===== RANK HISTORY ===== */
.rank-history-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: calc(100vh - 340px);
  overflow-y: auto;
  padding-right: 4px;
}

.rank-history-list::-webkit-scrollbar { width: 4px; }
.rank-history-list::-webkit-scrollbar-track { background: transparent; }
.rank-history-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

/* Text-only history rows (initial, deleted, no parlay) */
.rank-history-item {
  display: grid;
  grid-template-columns: 70px 100px 80px 1fr;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 13px;
}

.rank-history-item:last-child { border-bottom: none; }

.history-time {
  color: rgba(255, 255, 255, 0.35);
  font-size: 12px;
}

.history-event {
  color: rgba(255, 255, 255, 0.6);
}
.history-event i { margin-right: 4px; width: 14px; text-align: center; }

.history-change {
  font-weight: 600;
}

.history-tier {
  text-align: right;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}

.rr-positive { color: #4CAF50; }
.rr-negative { color: #F44336; }
.rr-neutral { color: rgba(255, 255, 255, 0.4); }

.history-promotion { background: rgba(76, 175, 80, 0.04); }
.history-demotion { background: rgba(244, 67, 54, 0.04); }

/* ===== RANK HISTORY — PARLAY CARD CONTEXT STRIP ===== */
.rank-history-context {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px 8px 0 0;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-bottom: none;
}

.rank-history-context.history-promotion {
  background: rgba(76, 175, 80, 0.06);
  border-color: rgba(76, 175, 80, 0.12);
}

.rank-history-context.history-demotion {
  background: rgba(244, 67, 54, 0.06);
  border-color: rgba(244, 67, 54, 0.12);
}

.rank-history-context .history-tier { margin-left: auto; }

/* ===== RANK HISTORY — PARLAY CARD WRAPPER ===== */
.rank-history-parlay-card {
  margin-bottom: 8px;
}

/* Hide action buttons (Reuse, Share, Remove) in ranked context */
.rank-history-parlay-card .parlay-card-actions {
  display: none !important;
}

/* Connect card to context strip visually */
.rank-history-parlay-card .parlay-card {
  border-radius: 0 0 12px 12px;
  margin-bottom: 0;
}

/* ===== HOW IT WORKS ===== */
.ranked-how-card details { cursor: default; }

.ranked-how-toggle {
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.ranked-how-toggle::-webkit-details-marker { display: none; }
.ranked-how-toggle::before {
  content: '▸ ';
  display: inline;
}
details[open] > .ranked-how-toggle::before { content: '▾ '; }

.ranked-how-content {
  padding-top: 12px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.6;
}
.ranked-how-content h4 {
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  margin: 14px 0 4px 0;
}
.ranked-how-content h4:first-child { margin-top: 0; }
.ranked-how-content ul {
  margin: 4px 0;
  padding-left: 20px;
}
.ranked-how-content li { margin-bottom: 2px; }

/* ===== TIER-SPECIFIC COLORS ===== */
.tier-novice    { --tier-color: #a07848; }
.tier-amateur   { --tier-color: #a8a8a8; }
.tier-pro       { --tier-color: #b09030; }
.tier-elite     { --tier-color: #a0a0b8; }
.tier-legend    { --tier-color: #88bce0; }
.tier-goat      { --tier-color: #1A6B5A; }

.tier-text-novice    { color: #a07848; }
.tier-text-amateur   { color: #a8a8a8; }
.tier-text-pro       { color: #b09030; }
.tier-text-elite     { color: #a0a0b8; }
.tier-text-legend    { color: #88bce0; }
.tier-text-goat {
  background: linear-gradient(135deg, #0F5349, #2E8B7A, #4DC9B0, #1A6B5A, #3AA893);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== MOBILE — single breakpoint ===== */
@media (max-width: 1000px) {
  .ranked-page {
    padding: 16px;
    padding-top: calc(60px + env(safe-area-inset-top, 0px) + 16px);
  }

  /* Layout: single column */
  .ranked-main-content {
    flex-direction: column;
    gap: 0;
  }
  .ranked-left-col {
    position: static;
  }

  /* Mobile tabs */
  .mobile-ranked-tabs {
    display: flex;
    position: sticky;
    top: calc(70px + env(safe-area-inset-top, 0px));
    z-index: 10;
    gap: 4px;
    padding: 4px;
    background: #0c1a2e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    margin-bottom: 12px;
  }

  .mobile-ranked-tab {
    flex: 1;
    padding: 10px 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: rgba(255, 255, 255, 0.45);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .mobile-ranked-tab.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
  }

  /* Tab visibility — Rank tab */
  body.ranked-tab-rank .ranked-left-col  { display: block; }
  body.ranked-tab-rank .ranked-right-col { display: none; }

  /* Tab visibility — History tab */
  body.ranked-tab-history .ranked-left-col { display: none; }
  body.ranked-tab-history .ranked-right-col { display: block; }
  body.ranked-tab-history .ranked-leaderboard,
  body.ranked-tab-history .ranked-how { display: none; }

  /* Tab visibility — Leaderboard tab */
  body.ranked-tab-leaderboard .ranked-left-col { display: none; }
  body.ranked-tab-leaderboard .ranked-right-col { display: block; }
  body.ranked-tab-leaderboard .ranked-stats,
  body.ranked-tab-leaderboard .ranked-chart-section { display: none; }

  /* Rank overview card — mobile tweaks (stays horizontal, larger) */
  .rank-overview-card { padding: 10px 20px 32px; gap: 16px; margin-bottom: 48px; border-bottom: none; }
  .rank-circle-wrap { width: 108px; height: 108px; margin-top: 20px; }
  .rank-badge { width: 60px; height: 60px; }
  .rank-circle-wrap.is-goat { width: 72px; height: 72px; }
  .rank-circle-wrap.is-goat .rank-badge { width: 88px; height: 88px; }
  .rank-overview-main {
    gap: 24px;
  }
  .rank-username-display { max-width: 200px; font-size: 28px; }
  .rank-username-edit-btn { font-size: 20px; margin-left: 5px;}
  .rank-username-input { width: 180px; font-size: 26px; }
  .rank-tier-label { font-size: 22px; }
  .rank-rr-label { font-size: 18px; }
  .rank-rr-label-mobile { display: block; margin-top: 16px; text-align: center; }
  .rank-rr-label-desktop { display: none; }
  .rank-overview-stat-value { font-size: 30px; }
  .rank-overview-stat-label { font-size: 12px; }
  .rank-card-tab { font-size: 24px; padding: 12px 36px; border-radius: 30px; }
  .rank-card-tab.has-live::before { width: 9px; height: 9px; margin-right: 8px; }
  .rank-card-tabs { bottom: -22px; gap: 18px; }

  .rank-progress-bg {
    stroke-width: 9;
  }

  .rank-progress-fill {
    stroke-width: 9;
  }

  /* Stats cards */
  .ranked-stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Chart */
  .ranked-chart-wrap { height: 200px; }

  /* History */
  .rank-history-list {
    max-height: none;
    overflow-y: visible;
    padding-right: 0;
  }

  .rank-history-item {
    grid-template-columns: 60px 80px 60px 1fr;
    font-size: 12px;
  }

  .ranked-history-card.glass-card {
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
    margin-bottom: 0;
  }

  .rank-history-parlay-card .parlay-card {
    border-radius: 0 0 12px 12px;
  }

}

/* ===== ALL-SHIELDS POPUP ===== */
#shields-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: shields-fadeIn 0.2s ease;
}

@keyframes shields-fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.shields-popup {
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 16px;
  max-width: 280px;
  width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
}

.shields-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.shields-popup-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
}

.shields-popup-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.shields-popup-close:hover { color: #fff; }

.shields-popup-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.shields-popup-tier-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.shields-popup-tier-row {
  display: flex;
  gap: 6px;
}

.shields-popup-item {
  flex: 1;
  max-width: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 4px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  transition: all 0.15s;
}

.shields-popup-item--active {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

.shields-popup-shield {
  width: 100%;
  aspect-ratio: 1;
}

.shields-popup-shield svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.shields-popup-shield img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.shields-popup-name {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
}

.shields-popup-sub {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
}

/* Shields popup — mobile overrides */
@media (max-width: 1000px) {
  .shields-popup {
    max-width: 500px;
    max-height: 90vh;
    padding: 24px;
  }
  .shields-popup-header { margin-bottom: 16px; }
  .shields-popup-header h3 { font-size: 18px; }
  .shields-popup-close { font-size: 28px; }
  .shields-popup-grid { gap: 14px; }
  .shields-popup-tier-header { font-size: 13px; margin-bottom: 4px; }
  .shields-popup-tier-row { gap: 8px; }
  .shields-popup-item { padding: 4px; max-width: calc(33.3% - 6px); }
  .shields-popup-name { font-size: 12px; }
}
