/* ==========================================================================
   SmallWorld Analytics — Leaderboard page styles
   Layered on top of ../../settings/shared/styles.css to share tokens
   (header, footer, fonts, brand blue). Defines the analytics suite shell
   (left sidebar + main) and the leaderboard card system.
   ========================================================================== */

/* ---------- Suite shell: sidebar + main ---------------------------------- */
.an-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 26px 1rem 56px;
  display: flex;
  gap: 28px;
  align-items: flex-start;
}

/* ---------- Left sidebar (analytics report nav) -------------------------- */
.an-sidebar {
  width: 224px;
  flex-shrink: 0;
  position: sticky;
  top: 18px;
}

.an-sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: #9DA1A5;
  padding: 0 12px;
  margin-bottom: 12px;
}

.an-nav-section { margin-bottom: 18px; }
.an-nav-section + .an-nav-section { margin-top: 4px; }

.an-nav-section-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #B4B8BC;
  padding: 0 12px;
  margin-bottom: 6px;
}

.an-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: #44464A;
  padding: 8px 12px;
  border-radius: 7px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.13s, color 0.13s;
  line-height: 1.3;
  position: relative;
}
.an-nav-item svg { width: 16px; height: 16px; flex-shrink: 0; color: #9DA1A5; transition: color 0.13s; }
.an-nav-item:hover { color: #3f84e5; background: #F1F7FF; }
.an-nav-item:hover svg { color: #3f84e5; }

.an-nav-item.active {
  color: #3f84e5;
  background: #F1F7FF;
  font-weight: 700;
}
.an-nav-item.active svg { color: #3f84e5; }
/* Active accent bar on the left edge */
.an-nav-item.active::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 3px;
  background: #3f84e5;
}

.an-nav-item .an-nav-new {
  margin-left: auto;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #fff;
  background: #3f84e5;
  padding: 2px 6px;
  border-radius: 9px;
}

.an-sidebar-foot {
  margin-top: 16px;
  padding: 12px 12px 0;
  border-top: 1px solid #e6e9ed;
  font-size: 11px;
  color: #77797B;
  line-height: 1.55;
}
.an-sidebar-foot strong { color: #222; font-weight: 700; }

/* ---------- Main column -------------------------------------------------- */
.an-main { flex: 1; min-width: 0; }

.an-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.an-page-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #3f84e5;
  margin-bottom: 8px;
}

.an-page-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #222;
  display: flex;
  align-items: center;
  gap: 12px;
}
.an-page-title .an-title-trophy {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: linear-gradient(140deg, #3f84e5, #6aa1ec);
  color: #fff;
  box-shadow: 0 4px 10px rgba(63,132,229,0.30);
}
.an-page-title .an-title-trophy svg { width: 17px; height: 17px; }

.an-page-sub {
  margin-top: 10px;
  font-size: 13px;
  color: #57595B;
  line-height: 1.6;
  max-width: 640px;
}

/* ---------- Toolbar (range + scope selectors) ---------------------------- */
.an-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.an-select-group { display: inline-flex; flex-direction: column; gap: 4px; }
.an-select-label {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.9px; color: #9DA1A5; padding-left: 2px;
}
.an-select {
  height: 34px;
  padding: 0 30px 0 12px;
  border: 1px solid #e1e5e9;
  border-radius: 7px;
  background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%2377797B' stroke-width='1.5' fill='none' stroke-linecap='round'/></svg>") no-repeat right 11px center;
  font-family: 'Montserrat', sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  color: #222;
  appearance: none;
  cursor: pointer;
}
.an-select:focus { outline: none; border-color: #3f84e5; box-shadow: 0 0 0 3px rgba(63,132,229,0.12); }

/* ---------- "Your standing" strip --------------------------------------- */
.an-standing {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: #fff;
  border: 1px solid #e8ebef;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 22px;
}
.an-standing-lead {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 22px;
  border-right: 1px solid #eef1f4;
  flex-shrink: 0;
}
.an-standing-avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 15px; letter-spacing: 0.4px;
  background: #3f84e5;
}
.an-standing-lead .who-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: #9DA1A5;
}
.an-standing-lead .who-name { font-size: 15px; font-weight: 700; color: #222; }
.an-standing-lead .who-title { font-size: 11.5px; color: #77797B; margin-top: 1px; }

.an-standing-stats {
  display: flex;
  flex: 1;
  min-width: 0;
}
.an-standing-stat {
  flex: 1;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid #eef1f4;
  min-width: 0;
}
.an-standing-stat:last-child { border-right: 0; }
.an-standing-stat .s-label {
  font-size: 10.5px; font-weight: 600; color: #77797B; line-height: 1.3;
  margin-bottom: 6px;
}
.an-standing-stat .s-rank {
  font-size: 20px; font-weight: 800; color: #222; letter-spacing: -0.5px;
  display: flex; align-items: baseline; gap: 6px;
}
.an-standing-stat .s-rank .s-suffix { font-size: 11px; font-weight: 700; color: #9DA1A5; }
.an-standing-stat .s-value { font-size: 11px; font-weight: 600; color: #3f84e5; margin-top: 3px; }

/* ---------- Board grid --------------------------------------------------- */
.an-board-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.an-board {
  background: #fff;
  border: 1px solid #e8ebef;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.an-board-head {
  padding: 16px 18px 14px;
  border-bottom: 1px solid #eef1f4;
  position: relative;
}
/* Accent rule at the very top of each board (color set inline per board). */
.an-board-head::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent, #3f84e5);
}
.an-board-head-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.an-board-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--accent, #3f84e5);
  background: color-mix(in srgb, var(--accent, #3f84e5) 12%, #fff);
  flex-shrink: 0;
}
.an-board-icon svg { width: 16px; height: 16px; }
.an-board-title {
  font-size: 14px;
  font-weight: 700;
  color: #222;
  letter-spacing: -0.2px;
  line-height: 1.25;
}
.an-board-blurb {
  font-size: 11.5px;
  color: #77797B;
  line-height: 1.45;
}
.an-board-total {
  margin-top: 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent, #3f84e5);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.an-board-total::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent, #3f84e5);
}

/* ---------- Podium (top 3) ---------------------------------------------- */
.an-podium {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 6px 0 2px;
}

.an-rank-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  position: relative;
}
.an-rank-row + .an-rank-row { border-top: 1px solid #f3f5f8; }
.an-rank-row.is-you {
  background: #F1F7FF;
}
.an-you-tag {
  display: inline-flex;
  align-items: center;
  font-size: 8px; font-weight: 800; letter-spacing: 0.7px;
  color: #3f84e5;
  background: #fff;
  border: 1px solid #cfe0f7;
  padding: 1px 5px;
  border-radius: 8px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Rank badge — medal for 1-3, plain numeral after */
.an-rank-badge {
  width: 24px; height: 24px;
  flex-shrink: 0;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
  color: #9DA1A5;
  background: #f3f5f8;
}
.an-rank-badge.medal {
  color: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.12);
  border: 1.5px solid rgba(255,255,255,0.7);
}
.an-rank-badge.gold   { background: linear-gradient(140deg, #f6c34a, #e0a31f); }
.an-rank-badge.silver { background: linear-gradient(140deg, #cfd6dd, #a8b2bd); }
.an-rank-badge.bronze { background: linear-gradient(140deg, #d99a63, #b9743c); }

.an-rank-avatar {
  width: 30px; height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 11.5px; letter-spacing: 0.3px;
  background: #3f84e5;
}
/* Top-1 avatar gets a subtle gold ring */
.an-rank-row.rank-1 .an-rank-avatar { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #f0c24f; }

.an-rank-meta { min-width: 0; flex: 1; }
.an-rank-name {
  font-size: 12.5px;
  font-weight: 700;
  color: #222;
  display: flex;
  align-items: center;
  gap: 0;
}
.an-rank-name > .name-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.an-rank-title {
  font-size: 10.5px;
  color: #9DA1A5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.an-rank-stat {
  flex-shrink: 0;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
  color: #222;
  padding-right: 2px;
}
.an-rank-stat .stat-num { font-weight: 800; }
.an-rank-stat .stat-unit { font-size: 9.5px; font-weight: 600; color: #9DA1A5; display: block; }

/* Mini progress bar under the stat for the leader-relative share */
.an-rank-bar {
  height: 4px;
  border-radius: 3px;
  background: #eef1f4;
  margin: 7px 18px 0;
  overflow: hidden;
}
.an-rank-bar > span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--accent, #3f84e5);
  opacity: 0.85;
}

.an-board-foot {
  margin-top: auto;
  padding: 12px 18px;
  border-top: 1px solid #eef1f4;
  text-align: center;
}
.an-board-foot a {
  font-size: 11.5px;
  font-weight: 700;
  color: #3f84e5;
  text-decoration: none;
}
.an-board-foot a:hover { text-decoration: underline; }

/* ---------- Responsive --------------------------------------------------- */
@media (max-width: 1080px) {
  .an-board-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .an-shell { flex-direction: column; }
  .an-sidebar { width: 100%; position: static; }
  .an-standing { flex-direction: column; }
  .an-standing-lead { border-right: 0; border-bottom: 1px solid #eef1f4; }
}
