/* ============================================================
   WDHC Athlete Portal · Non-Overview tab design system
   Shared dark/card-list tokens for History, Train, Progress,
   Achievements, Challenges, Leaderboard, Gym, Settings, Calculator.
   Overview (#section-overview) is intentionally NOT in scope.
   Cache: ?v=20260913loghist1
   ============================================================ */

:root {
  --portal-tab-bg: var(--bg-secondary, #0a0a0a);
  --portal-tab-card: var(--bg-card, #111111);
  --portal-tab-card-hover: var(--bg-card-hover, #161616);
  --portal-tab-border: var(--border-subtle, #1a1a1a);
  --portal-tab-border-strong: rgba(212, 175, 55, 0.22);
  --portal-tab-gold: var(--gold, #d4af37);
  --portal-tab-gold-bright: #FFE566;
  --portal-tab-text: var(--text-primary, #ffffff);
  --portal-tab-muted: #c8c8c8;
  --portal-tab-dim: #9a9a9a;
  --portal-tab-radius: 14px;
  --portal-tab-row-radius: 12px;
}

/* Scope: all non-overview portal tabs */
#section-history,
#section-training-log,
#section-progress,
#section-achievements,
#section-monthly-challenges,
#section-leaderboard,
#section-your-gym,
#section-settings,
#section-calculator {
  --portal-in-tabs: 1;
  padding-top: 0;
  margin-top: 0;
  min-height: 0;
}

/* ---- Compact page headers ---- */
#section-history > .section-header-row,
#section-training-log > .section-header-row,
#section-progress > .section-header-row,
#section-achievements > .section-header-row,
#section-monthly-challenges > .section-header-row,
#section-leaderboard > .section-header-row,
#section-your-gym > .section-header-row,
#section-settings > .section-header-row,
#section-calculator > .section-header-row,
#section-history .portal-page-header,
#section-training-log .portal-page-header,
#section-progress .portal-page-header,
#section-achievements .portal-page-header,
#section-monthly-challenges .portal-page-header,
#section-leaderboard .portal-page-header,
#section-your-gym .portal-page-header,
#section-settings .portal-page-header,
#section-calculator .portal-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
  margin: 0 0 14px;
  padding: 0;
  min-height: 0;
}

#section-history .section-title,
#section-training-log .section-title,
#section-progress .section-title,
#section-achievements .section-title,
#section-monthly-challenges .section-title,
#section-leaderboard .section-title,
#section-your-gym .section-title,
#section-settings .section-title,
#section-calculator .section-title {
  margin: 0;
  padding: 0;
  font-size: clamp(1.2rem, 2.2vw, 1.45rem);
  line-height: 1.2;
  letter-spacing: 0.03em;
  color: var(--portal-tab-text);
  text-transform: none;
}

#section-history .section-subtitle,
#section-training-log .section-subtitle,
#section-progress .section-subtitle,
#section-achievements .section-subtitle,
#section-monthly-challenges .section-subtitle,
#section-leaderboard .section-subtitle,
#section-your-gym .section-subtitle,
#section-settings .section-subtitle,
#section-calculator .section-subtitle {
  margin: 4px 0 0;
  max-width: 52ch;
  font-size: 0.92rem;
  line-height: 1.4;
  color: var(--portal-tab-muted) !important;
}

#section-history .section-actions,
#section-training-log .section-actions,
#section-progress .chart-controls,
#section-achievements .achievement-filters-wrap,
#section-leaderboard .portal-lb-controls,
#section-your-gym > .section-header-row > a,
#section-monthly-challenges > .section-header-row > a {
  margin-left: auto;
  flex-shrink: 0;
}

/* Kill blank black hero voids under top bar */
#section-history::before,
#section-training-log::before,
#section-progress::before,
#section-achievements::before,
#section-monthly-challenges::before,
#section-leaderboard::before,
#section-your-gym::before,
#section-settings::before,
#section-calculator::before {
  content: none !important;
  display: none !important;
}

#section-history > *:first-child,
#section-training-log > *:first-child,
#section-progress > *:first-child,
#section-achievements > *:first-child,
#section-monthly-challenges > *:first-child,
#section-leaderboard > *:first-child,
#section-your-gym > *:first-child,
#section-settings > *:first-child,
#section-calculator > *:first-child {
  margin-top: 0;
}

/* Shared dark card shell */
#section-history .card,
#section-training-log .card,
#section-progress .card,
#section-achievements .card,
#section-monthly-challenges .card,
#section-leaderboard .card,
#section-your-gym .card,
#section-settings .card,
#section-calculator .card,
#section-progress .chart-container.card,
#section-leaderboard .portal-lb-card {
  background: var(--portal-tab-card);
  border: 1px solid var(--portal-tab-border);
  border-radius: var(--portal-tab-radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}

/* Cooperative dark table tokens (Otis History/Log + leftover tables) */
#section-history .data-table,
#section-training-log .data-table,
#section-progress .data-table,
#section-achievements .data-table,
#section-monthly-challenges .data-table,
#section-leaderboard .data-table,
#section-your-gym .data-table,
#section-settings .data-table,
#section-calculator .data-table,
#section-history .table-wrap,
#section-training-log .table-wrap,
#section-monthly-challenges .table-wrap,
#section-leaderboard .table-wrap,
#section-your-gym .table-wrap {
  background: var(--portal-tab-card) !important;
  color: var(--portal-tab-text) !important;
  border-color: var(--portal-tab-border) !important;
}

#section-history .data-table thead,
#section-training-log .data-table thead,
#section-monthly-challenges .data-table thead,
#section-leaderboard .data-table thead,
#section-your-gym .data-table thead,
#section-history .data-table th,
#section-training-log .data-table th,
#section-monthly-challenges .data-table th,
#section-leaderboard .data-table th,
#section-your-gym .data-table th {
  background: var(--bg-tertiary, #0f0f0f) !important;
  color: var(--portal-tab-dim) !important;
  border-bottom: 1px solid var(--portal-tab-border) !important;
}

#section-history .data-table td,
#section-training-log .data-table td,
#section-monthly-challenges .data-table td,
#section-leaderboard .data-table td,
#section-your-gym .data-table td {
  background: transparent !important;
  color: var(--portal-tab-text) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
}

/* Hidden legacy tables must stay invisible (no ghost chrome) */
#section-history .data-table[hidden],
#section-training-log .data-table[hidden],
#hangHistoryTable[hidden],
#trainingLogTable[hidden],
#portalLbTable[hidden],
#yourGymTable[hidden] {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* ---- Rank list (Leaderboard + Gym + Challenges) ---- */
.portal-rank-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  max-height: 560px;
  overflow: auto;
  background: transparent;
}

.portal-rank-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px 12px;
  padding: 12px 14px;
  border-radius: var(--portal-tab-row-radius);
  background: linear-gradient(165deg, rgba(22, 22, 22, 0.98) 0%, rgba(10, 10, 10, 0.99) 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  min-height: 56px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.portal-rank-row:hover {
  border-color: rgba(212, 175, 55, 0.28);
  background: var(--portal-tab-card-hover);
}

.portal-rank-row.is-you,
.portal-rank-row.portal-lb-you {
  border-color: rgba(212, 175, 55, 0.35);
  background:
    linear-gradient(90deg, rgba(212, 175, 55, 0.16) 0, rgba(212, 175, 55, 0.16) 3px, transparent 3px),
    linear-gradient(165deg, rgba(28, 24, 12, 0.95) 0%, rgba(12, 11, 8, 0.99) 100%);
  box-shadow: inset 3px 0 0 var(--portal-tab-gold);
}

.portal-rank-row__rank {
  font-family: var(--font-heading, Oswald, sans-serif);
  font-weight: 700;
  font-size: 1.05rem;
  color: #c4a35a;
  text-align: center;
}

.portal-rank-row__main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.portal-rank-row__name {
  font-weight: 700;
  color: #fff;
  font-size: 0.98rem;
  line-height: 1.25;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.portal-rank-row__meta {
  font-size: 0.82rem;
  color: var(--portal-tab-dim);
  line-height: 1.35;
}

.portal-rank-row__stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  text-align: right;
}

.portal-rank-row__time {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--portal-tab-gold);
}

.portal-rank-row__substat {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--portal-tab-muted);
}

/* 20260913lblay2: tier badge BEFORE name (main board order) */
.portal-rank-row__name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  min-width: 0;
}
.portal-rank-row__identity {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.portal-rank-row__name .tier-badge,
.portal-rank-row__name .tier-badge--compact {
  width: auto !important;
  min-width: 72px !important;
  max-width: 110px !important;
  height: 26px !important;
  font-size: 0.68rem !important;
  padding: 2px 8px 2px 12px !important;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.portal-rank-row__meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  padding-left: 0;
}

.portal-rank-empty,
.portal-rank-loading {
  padding: 28px 16px;
  text-align: center;
  color: var(--portal-tab-dim);
  font-size: 0.95rem;
  border-radius: var(--portal-tab-row-radius);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.25);
}

.portal-lb-you-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #111;
  background: var(--portal-tab-gold);
}

#section-leaderboard .portal-lb-card {
  padding: 0;
  overflow: hidden;
}

#section-leaderboard .portal-lb-meta {
  padding: 10px 14px;
  border-bottom: 1px solid var(--portal-tab-border);
  color: var(--portal-tab-muted);
  font-size: 0.8rem;
}

#section-leaderboard .portal-lb-more {
  margin: 12px 14px 14px;
}

#section-leaderboard .portal-lb-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

#section-leaderboard .portal-lb-search,
#section-leaderboard .portal-lb-select {
  background: var(--bg-input, #0d0d0d);
  border: 1px solid var(--border-default, #222);
  color: var(--portal-tab-text);
  border-radius: 10px;
  padding: 8px 12px;
}

/* ---- Progress ---- */
#section-progress .progress-insight {
  margin: 8px 0 0;
  padding: 6px 10px;
  border-left: 3px solid var(--portal-tab-gold);
  background: rgba(212, 175, 55, 0.06);
  border-radius: 0 8px 8px 0;
  color: var(--portal-tab-muted) !important;
  font-size: 0.9rem;
}

#section-progress .progress-empty {
  text-align: left;
  padding: 20px 18px;
  margin-bottom: 14px;
  background: var(--portal-tab-card);
  border: 1px solid var(--portal-tab-border);
}

#section-progress .progress-charts-grid {
  gap: 12px;
}

#section-progress .chart-container.card {
  padding: 14px 16px;
}

#section-progress .chart-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#section-progress .chart-btn {
  border-radius: 999px;
  border: 1px solid rgba(212, 175, 55, 0.28);
  background: #121212;
  color: var(--portal-tab-muted);
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
}

#section-progress .chart-btn.active {
  background: rgba(212, 175, 55, 0.16);
  color: var(--portal-tab-gold-bright);
  border-color: rgba(212, 175, 55, 0.45);
}

/* ---- Achievements ---- */
#section-achievements .section-header-row {
  margin-bottom: 12px !important;
  align-items: flex-start;
}

#section-achievements .achievements-grid {
  gap: 10px;
}

#section-achievements .achievement-card,
#section-achievements .achievements-grid > * {
  border-radius: 14px;
  border-color: rgba(212, 175, 55, 0.16);
  background: var(--portal-tab-card);
}

#section-achievements .ach-sticky-card,
#section-achievements .ach-certificates {
  margin-bottom: 12px;
  border: 1px solid var(--portal-tab-border);
  background: var(--portal-tab-card);
  border-radius: var(--portal-tab-radius);
}

#section-achievements .section-empty-state {
  padding: 22px 18px;
  border-radius: var(--portal-tab-radius);
  background: var(--portal-tab-card);
  border: 1px solid var(--portal-tab-border);
}

/* ---- Settings ---- */
#section-settings .settings-account-card,
#section-settings .settings-card,
#section-settings .email-pref-card {
  margin-top: 12px;
  padding: 16px 18px;
  background: var(--portal-tab-card);
  border: 1px solid var(--portal-tab-border);
  border-radius: var(--portal-tab-radius);
}

#section-settings .settings-account-card {
  margin-top: 0;
}

#section-settings .settings-section-label {
  color: var(--portal-tab-gold);
  letter-spacing: 0.12em;
}

/* ---- Calculator ---- */
#section-calculator .portal-gripage-wrap {
  margin-top: 0;
  padding: 16px;
  border-radius: var(--portal-tab-radius);
  background: var(--portal-tab-card);
  border: 1px solid var(--portal-tab-border);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}

#section-calculator .portal-gripage-footnote,
#section-calculator .wdhc-gripage-disclaimer {
  margin-top: 12px;
  color: var(--portal-tab-muted);
}

/* ---- Challenges ---- */
#section-monthly-challenges .portal-challenges-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#section-monthly-challenges .portal-challenge-card {
  padding: 16px;
  background: var(--portal-tab-card);
  border: 1px solid var(--portal-tab-border);
  border-radius: var(--portal-tab-radius);
}

#section-monthly-challenges .portal-challenge-card .portal-rank-list {
  padding: 0;
  max-height: 420px;
}

#section-monthly-challenges .your-gym-head {
  margin-bottom: 10px;
}

/* ---- Your Gym ---- */
/* Hard [hidden] so gym cards never paint as a black void */
#section-your-gym #yourGymEmptyCard[hidden],
#section-your-gym #yourGymJoinedCard[hidden] {
  display: none !important;
}
#section-your-gym #yourGymEmptyCard:not([hidden]) {
  display: block !important;
}
#section-your-gym #yourGymJoinedCard {
  padding: 16px;
}

#section-your-gym .portal-rank-list {
  padding: 0;
  margin-top: 8px;
}

#section-your-gym #yourGymEmptyCard .overview-empty-state {
  padding: 22px 16px !important;
}

/* ---- History / Train: shared header density only (Otis owns content) ---- */
#section-history .hang-history-list,
#section-training-log .tl-session-list {
  margin-top: 0;
}

#section-history .hang-history-toolbar,
#section-training-log .tl-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Mobile */
@media (max-width: 768px) {
  #section-history > .section-header-row,
  #section-training-log > .section-header-row,
  #section-progress > .section-header-row,
  #section-achievements > .section-header-row,
  #section-monthly-challenges > .section-header-row,
  #section-leaderboard > .section-header-row,
  #section-your-gym > .section-header-row,
  #section-settings > .section-header-row,
  #section-calculator > .section-header-row {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 12px;
  }

  #section-history .section-actions,
  #section-training-log .section-actions,
  #section-progress .chart-controls,
  #section-achievements .achievement-filters-wrap,
  #section-leaderboard .portal-lb-controls,
  #section-your-gym > .section-header-row > a,
  #section-monthly-challenges > .section-header-row > a {
    margin-left: 0;
    width: 100%;
  }

  #section-leaderboard .portal-lb-search {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
  }

  .portal-rank-row {
    grid-template-columns: 36px minmax(0, 1fr);
    grid-template-areas:
      "rank main"
      "rank stats";
    gap: 4px 10px;
    padding: 12px;
  }

  .portal-rank-row__rank { grid-area: rank; align-self: start; padding-top: 2px; }
  .portal-rank-row__main { grid-area: main; min-width: 0; }
  .portal-rank-row__stats {
    grid-area: stats;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    gap: 8px;
  }
  .portal-rank-row__name {
    flex-wrap: wrap;
  }

  .portal-rank-list {
    max-height: none;
    padding: 10px;
  }

  #section-progress .progress-charts-grid {
    grid-template-columns: 1fr;
  }

  #section-calculator .portal-gripage-wrap {
    padding: 12px;
  }
}

@media (max-width: 480px) {
  #section-history .section-title,
  #section-training-log .section-title,
  #section-progress .section-title,
  #section-achievements .section-title,
  #section-monthly-challenges .section-title,
  #section-leaderboard .section-title,
  #section-your-gym .section-title,
  #section-settings .section-title,
  #section-calculator .section-title {
    font-size: 1.15rem;
  }

  .portal-rank-row__time {
    font-size: 0.98rem;
  }
}


/* ============================================================
   20260913loghist1 · HARD kill legacy spreadsheet chrome
   Root cause companion: orphan </div> after portal4 CTA removal
   ejected all non-overview sections out of <main>. HTML fixed.
   ============================================================ */
#hangHistoryTable,
#trainingLogTable,
#portalLbTable,
#yourGymTable,
#section-history > table.data-table,
#section-training-log table.data-table,
#section-leaderboard table.data-table,
#section-your-gym table.data-table {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  max-height: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  position: absolute !important;
  left: -9999px !important;
  pointer-events: none !important;
}

#section-leaderboard .table-wrap.portal-lb-table-wrap,
#section-your-gym .table-wrap:has(#yourGymTable) {
  display: none !important;
}

/* Keep sections inside main painting on dark field (no white body bleed) */
#section-history,
#section-training-log,
#section-progress,
#section-achievements,
#section-monthly-challenges,
#section-leaderboard,
#section-your-gym,
#section-settings,
#section-calculator {
  background: transparent !important;
  color: #f2f2f2;
}

/* Overview ambient pseudo must never reserve space when overview is hidden */
#section-overview[hidden]::before,
#section-overview:not(.active)::before {
  content: none !important;
  display: none !important;
  height: 0 !important;
}

/* 20260913histlog1: board-hang note line in Training Log */
#section-training-log .tl-session-delta {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: #b8b8b8;
  line-height: 1.35;
}

/* 20260915bot1: hang-type filter + monthly boards match index tables */
#section-leaderboard .portal-lb-select {
  min-width: 132px;
  max-width: 200px;
}
#section-monthly-challenges .portal-ch-boards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
#section-monthly-challenges .portal-ch-board {
  padding: 14px 16px 16px;
  border-radius: 16px;
  border: 1px solid rgba(212, 175, 55, 0.28);
  background:
    radial-gradient(ellipse 80% 80% at 100% 0%, rgba(212, 175, 55, 0.1) 0%, transparent 55%),
    linear-gradient(165deg, rgba(20, 18, 12, 0.98) 0%, rgba(10, 9, 6, 0.99) 100%);
}
#section-monthly-challenges .overview-month-top3__row.is-you .overview-month-top3__name {
  color: #D4AF37;
}
@media (max-width: 700px) {
  #section-leaderboard .portal-lb-select {
    max-width: none;
    flex: 1 1 calc(50% - 8px);
  }
}
