/* Legacy Team Profile (scoped additions) */

.legacy-team-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.legacy-team-name {
  margin: 0;
}

.legacy-team-logo img {
  display: block;
  max-width: 160px;
  max-height: 120px;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* Optional: tighten the meta line spacing a bit for teams */
.legacy-team-meta {
  margin-top: 8px;
}

/* ------------------------------ */
/* Team Roster table (full width) */
/* ------------------------------ */

/* Ensure the section/card aren't constraining width */
.legacy-team-profile-wrap .legacy-profile-section,
.legacy-team-profile-wrap .legacy-profile-card {
  width: 100%;
  max-width: none;
}

/* Target ONLY your roster table */
.legacy-team-profile-wrap table.legacy-team-roster {
  width: 100% !important;
  max-width: none;
  table-layout: auto;
}

/* If the theme is applying a narrower width specifically inside entry-content */
.legacy-team-profile-wrap .entry-content table.legacy-team-roster {
  width: 100% !important;
  max-width: none;
}

/* Default center */
.legacy-team-profile-wrap table.legacy-team-roster th,
.legacy-team-profile-wrap table.legacy-team-roster td {
  text-align: center;
}

/* But keep Player column left aligned (1st column) */
.legacy-team-profile-wrap table.legacy-team-roster th:first-child,
.legacy-team-profile-wrap table.legacy-team-roster td:first-child {
  text-align: left;
}

/* Roster table header text color */
.legacy-team-profile-wrap table.legacy-team-roster thead th {
  color: #007bff;
}

/* =========================
   Created line (Created: <date>)
   ========================= */

.legacy-team-profile-wrap .legacy-team-meta .lp-meta-label {
  color: #007bff; /* blue label */
}

.legacy-team-profile-wrap .legacy-team-meta .lp-meta-value {
  color: #ffffff; /* white date */
}

/* =========================
   Career stat blocks (Matches/W/L/T/Win%)
   Assumes your existing markup:
   .legacy-profile-header-stats
   .legacy-profile-stats
   .lp-stat, .lp-stat-num, .lp-stat-label
   and per-stat classes: .lp-stat-matches, .lp-stat-wins, etc.
   ========================= */

/* Layout grid for the stat squares */
.legacy-team-profile-wrap .legacy-profile-header-stats {
  margin-top: 14px;
}

.legacy-team-profile-wrap .legacy-profile-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
}

/* Square card look */
.legacy-team-profile-wrap .lp-stat {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 12px 10px;
  text-align: center;
}

/* Title under each stat (Matches, Wins, etc.) */
.legacy-team-profile-wrap .lp-stat-label {
  color: #007bff; /* same blue as headers */
  font-size: 0.9rem;
  margin-top: 6px;
  font-weight: 700;
}

/* Big number styling */
.legacy-team-profile-wrap .lp-stat-num {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
}

/* Per-stat number colors */
.legacy-team-profile-wrap .lp-stat-matches .lp-stat-num { color: #ffffff; }
.legacy-team-profile-wrap .lp-stat-ties    .lp-stat-num { color: #ffffff; }

/* Soft gold + red */
.legacy-team-profile-wrap .lp-stat-wins   .lp-stat-num { color: #dd9933; } /* soft gold */
.legacy-team-profile-wrap .lp-stat-losses .lp-stat-num { color: #ff4444; } /* red */

/* Win % number color is controlled by your PHP class:
   $win_pct_class => lp-stat-winpct-good / lp-stat-winpct-bad
   You asked: gold if over 50%, green if under 50%.
*/
.legacy-team-profile-wrap .lp-stat-winpct-good .lp-stat-num { color: #dd9933; } /* gold */
.legacy-team-profile-wrap .lp-stat-winpct-bad  .lp-stat-num { color: #5de000; } /* green */

/* Make the record block size to its contents (mirror player profile look) */
.legacy-team-profile-wrap .legacy-profile-header-stats {
  width: auto;
}

/* Key: inline-flex makes the container shrink to content instead of filling the row */
.legacy-team-profile-wrap .legacy-profile-stats {
  display: inline-flex !important;
  width: auto !important;
  max-width: 100%;
  justify-content: flex-start;
  align-items: stretch;
  flex-wrap: wrap;  /* keep wrapping on smaller screens */
  gap: 12px;
}

/* Prevent any “stretch all cards equally” rules from taking over */
.legacy-team-profile-wrap .lp-stat {
  flex: 0 0 auto;
}

/* Subtle divider lines above + below the Created line (match player profile) */
.legacy-team-profile-wrap .legacy-profile-header-meta.legacy-team-meta {
  border-top: 2px solid rgba(0,0,0,.12);
  border-bottom: 2px solid rgba(0,0,0,.12);
  padding: 8px 0;
  margin: 10px 0 12px;
}

/* Team logo: fixed 250x250 box */
.legacy-team-profile-wrap .legacy-team-logo {
  width: 250px;
  height: 250px;
  flex: 0 0 250px;          /* prevents flex from shrinking it */
  display: flex;
  align-items: center;
  justify-content: center;
}

.legacy-team-profile-wrap .legacy-team-logo img {
  width: 250px;
  height: 250px;
  max-width: none;
  max-height: none;
  object-fit: contain;      /* keep full logo visible */
  display: block;
}

/* =========================================================
   Layout Fixes for Team Profile 
   (Mirrors the fix in Player Profile)
   ========================================================= */

/* Remove any top padding specific to the Team template wrapper */
.page-template-page-legacy-team-profile .legacy-profile-wrap {
  padding-top: 0;
}

/* Kill default H1 top margin (~2rem) that pushes content down */
.page-template-page-legacy-team-profile .legacy-page-title {
  margin-top: 0;
}

/* Team title (H1) in soft gold */
.page-template-page-legacy-team-profile .legacy-team-name,
.page-template-page-legacy-team-profile .legacy-profile-username.legacy-team-name {
  color: #dd9933; /* soft gold */
}

/* Team Profile: Best rank line */
.page-template-page-legacy-team-profile .lp-summary-label{
  color: #007bff; /* blue label */
}

/* Value color for 1st (soft gold) */
.page-template-page-legacy-team-profile .lp-summary-value.lp-rank-1{
  color: #dd9933; /* soft gold */
}

/* Optional: keep other ranks consistent if you want */
.page-template-page-legacy-team-profile .lp-summary-value.lp-rank-2{ color:#c0c0c0; } /* silver-ish */
.page-template-page-legacy-team-profile .lp-summary-value.lp-rank-3{ color:#cd7f32; } /* bronze-ish */
.page-template-page-legacy-team-profile .lp-summary-value.lp-rank-default{ color:#ffffff; }

/* --- Team Profile: Best Rank section spacing + hierarchy --- */

/* Small space under the "Best rank seen in competition" row */
.page-template-page-legacy-team-profile .legacy-profile-summary .lp-summary-row{
  margin-bottom: 10px; /* tweak: 6–14px depending on taste */
}

/* Wrap for the context list */
.page-template-page-legacy-team-profile .lp-best-rank-context{
  margin-top: 2px; /* tiny separation from the row */
}

/* Game line: normal (not indented) */
.page-template-page-legacy-team-profile .lp-best-rank-game{
  margin: 6px 0 2px 0;
  font-weight: 600; /* optional: makes the game label read like a header */
}

/* Ladders under a game: indented + tighter spacing */
.page-template-page-legacy-team-profile .lp-best-rank-ladder{
  margin: 2px 0;
  padding-left: 18px; /* the indent */
}

/* Optional: make ladder links slightly "subordinate" without changing your link colors */
.page-template-page-legacy-team-profile .lp-best-rank-ladder a{
  font-weight: 400;
}

/* small breathing room between best-rank block and ladders table */
.legacy-team-profile-wrap .lp-summary-spacer {
  margin-top: 10px;
}

/* h4 heading style (keeps consistent hierarchy) */
.legacy-team-profile-wrap .legacy-subheading {
  margin: 10px 0 8px;
}

/* make the ladders table behave like roster table */
.legacy-team-profile-wrap table.legacy-team-ladders-played {
  width: 100%;
}

/* =========================
   Ladders Played table colors
   Columns:
   1 Game | 2 Ladder | 3 Matches | 4 W | 5 L | 6 T | 7 Win % | 8 First | 9 Last
   ========================= */

.legacy-team-profile-wrap table.legacy-team-ladders-played thead th {
  color: #007bff; /* your blue */
}

/* Default body text (dates, game/ladder text, etc.) */
.legacy-team-profile-wrap table.legacy-team-ladders-played tbody td {
  color: #ffffff;
}

/* Matches (col 3) */
.legacy-team-profile-wrap table.legacy-team-ladders-played tbody td:nth-child(3) {
  color: #ffffff;
}

/* Wins (col 4) */
.legacy-team-profile-wrap table.legacy-team-ladders-played tbody td:nth-child(4) {
  color: #dd9933; /* soft gold */
}

/* Losses (col 5) */
.legacy-team-profile-wrap table.legacy-team-ladders-played tbody td:nth-child(5) {
  color: #ff4444; /* player-profile red */
}

/* Ties (col 6) */
.legacy-team-profile-wrap table.legacy-team-ladders-played tbody td:nth-child(6) {
  color: #ffffff;
}

/* Win % (col 7) — mirror player: gold if >= 50, green if < 50 */
.legacy-team-profile-wrap table.legacy-team-ladders-played tbody td:nth-child(7) {
  color: #dd9933; /* default to gold */
}
.legacy-team-profile-wrap table.legacy-team-ladders-played tbody tr.lp-winpct-bad td:nth-child(7) {
  color: #5de000; /* green */
}

/* Dates (cols 8 & 9) */
.legacy-team-profile-wrap table.legacy-team-ladders-played tbody td:nth-child(8),
.legacy-team-profile-wrap table.legacy-team-ladders-played tbody td:nth-child(9) {
  color: #ffffff;
}

/* Make ALL table body data bold */
.legacy-team-profile-wrap table tbody td,
.legacy-team-profile-wrap .legacy-profile-table tbody td,
.legacy-team-profile-wrap .legacy-team-roster tbody td,
.legacy-team-profile-wrap .legacy-team-ladders-played tbody td {
  font-weight: 700;
}

/* =========================================================
   Team Profile – Ladders Played table:
   Make Game, Ladder, First, Last body cells regular weight
   (keep Matches/W/L/T/Win% bold)
   ========================================================= */

.legacy-team-profile-wrap table.legacy-team-ladders-played tbody td:nth-child(1),
.legacy-team-profile-wrap table.legacy-team-ladders-played tbody td:nth-child(2),
.legacy-team-profile-wrap table.legacy-team-ladders-played tbody td:nth-child(8),
.legacy-team-profile-wrap table.legacy-team-ladders-played tbody td:nth-child(9) {
  font-weight: 400 !important;
}

/* If Game/Ladder cells contain links, keep them regular weight too */
.legacy-team-profile-wrap table.legacy-team-ladders-played tbody td:nth-child(1) a,
.legacy-team-profile-wrap table.legacy-team-ladders-played tbody td:nth-child(2) a,
.legacy-team-profile-wrap table.legacy-team-ladders-played tbody td:nth-child(8) a,
.legacy-team-profile-wrap table.legacy-team-ladders-played tbody td:nth-child(9) a {
  font-weight: 400 !important;
}

/* =========================================================
   Team Roster table:
   Keep <th> bold, make ALL <td> regular weight
   ========================================================= */

.legacy-team-profile-wrap table.legacy-team-roster tbody td {
  font-weight: 400 !important;
}

/* If roster cells include links, keep them regular too */
.legacy-team-profile-wrap table.legacy-team-roster tbody td a {
  font-weight: 400 !important;
}

/* Career Summary (first section H2) */
.legacy-team-profile-wrap .legacy-profile-section:first-of-type > h2 {
  color: #ffffff !important;
}

/* =========================================================
   Mobile (<=800px): mirror Player Profile "tables -> cards"
   Requires td[data-label="..."] in template output
   ========================================================= */
@media (max-width: 800px) {

  .legacy-team-profile-wrap .legacy-profile-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow: hidden; /* not auto */
  }

  .legacy-team-profile-wrap .legacy-profile-table {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
  }

  .legacy-team-profile-wrap .legacy-profile-table thead {
    display: none;
  }

  /* Card */
  .legacy-team-profile-wrap .legacy-profile-table tbody tr {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;

    border: 1px solid rgba(255,255,255,.15);
    border-radius: 10px;
    padding: .75rem;
    margin: .75rem 0;
    background: rgba(0,0,0,.15);

    overflow: hidden; /* fixes "open-ended on the right" look */
  }

  /* Each cell becomes: label | value */
  .legacy-team-profile-wrap .legacy-profile-table tbody td {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: .75rem;

    padding: .35rem 0;
    border: 0 !important;

    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;

    align-items: start;
    white-space: normal !important;
    overflow-wrap: anywhere;
    word-break: break-word;

    text-align: left !important; /* cards should read left */
  }

  /* Beat theme nowrap */
  .legacy-team-profile-wrap .legacy-profile-table tbody td * {
    white-space: normal !important;
  }

  /* IMPORTANT: force ladder links to wrap like player page */
  .legacy-team-profile-wrap .legacy-profile-table tbody td a.legacy-ladder-link,
  .legacy-team-profile-wrap .legacy-profile-table tbody td a.legacy-game-link,
  .legacy-team-profile-wrap .legacy-profile-table tbody td a.legacy-player-link {
    display: block !important;
    width: 100%;
    max-width: 100%;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    line-height: 1.3;
  }

  /* Label */
  .legacy-team-profile-wrap .legacy-profile-table tbody td::before {
    content: attr(data-label);
    color: #007bff;
    font-weight: 600;

    min-width: 0;
    overflow-wrap: anywhere;
  }

  /* Value side must be allowed to shrink/wrap */
  .legacy-team-profile-wrap .legacy-profile-table tbody td > * {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}

/* =========================================================
   Sticky title transform (Team Name becomes "H4-like" when pinned)
   Mirrors Player Profile behavior
   ========================================================= */
.legacy-team-profile-wrap .legacy-profile-username.is-pinned {
  background-color: #333;
  color: #dd9933;
  padding: 12px 15px;
  margin: 0;

  font-size: 1.1rem;
  font-weight: 700;

  width: 100%;
  box-sizing: border-box;
  z-index: 1000;
}

/* Sticky section headers (Ladders Played / Player Roster) */
.legacy-team-profile-wrap .legacy-profile-section h4.is-pinned {
  background-color: #333;
  color: #dd9933;
  padding: 12px 15px;
  margin: 0;

  font-size: 1.1rem;
  font-weight: 700;

  width: 100%;
  box-sizing: border-box;
}

/* Ghost spacer for pinned H4s (prevents jump) */
.legacy-team-profile-wrap .gwl-h4-ghost {
  display: none;
  width: 100%;
  margin: 0;
  padding: 0;
}

/* =========================================================
   Sticky cloned table header text color + structure
   ========================================================= */
.gwl-sticky-clone-table {
  border-collapse: collapse !important;
  border-spacing: 0 !important;
  border: none !important;
}

.gwl-sticky-clone-table th,
.gwl-sticky-clone-table td {
  color: #007bff !important;
  box-sizing: border-box;
}

/* =========================================================
   Sticky table header (clone): match original TH weight + alignment
   ========================================================= */

/* Make sticky clone headers bold like the normal table headers */
.gwl-sticky-clone-table thead th {
  font-weight: 700 !important;
}

/* Center ALL sticky clone cells by default */
.gwl-sticky-clone-table th,
.gwl-sticky-clone-table td {
  text-align: center !important;
}

/* First column in the sticky clone stays left-aligned */
.gwl-sticky-clone-table th:first-child,
.gwl-sticky-clone-table td:first-child {
  text-align: left !important;
}

/* =========================================================
   Desktop table alignment: center all columns except first
   (applies to BOTH Player + Team tables)
   ========================================================= */

/* Player Profile tables */
.legacy-player-profile-wrap .legacy-profile-table th,
.legacy-player-profile-wrap .legacy-profile-table td {
  text-align: center;
}
.legacy-player-profile-wrap .legacy-profile-table th:first-child,
.legacy-player-profile-wrap .legacy-profile-table td:first-child {
  text-align: left;
}

/* Team Profile tables */
.legacy-team-profile-wrap .legacy-profile-table th,
.legacy-team-profile-wrap .legacy-profile-table td {
  text-align: center;
}
.legacy-team-profile-wrap .legacy-profile-table th:first-child,
.legacy-team-profile-wrap .legacy-profile-table td:first-child {
  text-align: left;
}

/* =========================================================
   Center text inside sticky title bars (Player + Team)
   ========================================================= */

/* Main sticky title (player/team name) */
.legacy-profile-username.is-pinned {
  text-align: center !important;
}

/* Sticky section headings (ex: "Name: Ladders Played") */
.legacy-profile-section h4.is-pinned {
  text-align: center !important;
}

/* =========================================================
   Team Profile: Ladders Played ONLY (normal table)
   Keep the "Ladder" column (2nd column) left-aligned
   ========================================================= */
.legacy-team-profile-wrap table.legacy-team-ladders-played thead th:nth-child(2),
.legacy-team-profile-wrap table.legacy-team-ladders-played tbody td:nth-child(2) {
  text-align: left !important;
}

.legacy-team-profile-wrap table.legacy-team-ladders-played tbody td:nth-child(2) .legacy-ladder-link {
  display: inline-block;
  text-align: left !important;
}

/* =========================================================
   Sticky clone: Ladders Played ONLY
   IMPORTANT: ONLY apply when the clone is the 9-column ladders table
   (Game, Ladder, Matches, W, L, T, Win%, First, Last)
   ========================================================= */
.gwl-sticky-clone-table thead th:nth-child(2):nth-last-child(8),
.gwl-sticky-clone-table td:nth-child(2):nth-last-child(8) {
  text-align: left !important;
}

/* Team Profile: "GWL Overall Record" label above stat blocks */
.lp-overall-record-title{
  margin: 0 0 8px 0;
  text-align: left;     /* or left */
  color: #dd9933;         /* soft gold */
  font-weight: 400;       /* match your preference */
  font-size: 1.05rem;
  line-height: 1.2;
}

/* Mirror Player Profile container padding on Team Profile */
.page-template-page-legacy-team-profile .legacy-profile-wrap {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0 1.25rem 1.25rem 1.25rem;
}
