/* Extra layout rules. Load this after styles.css. */

/* ---------- Home page ---------- */
body.page-home .intro {
  max-width: 720px;
  margin: 20px auto 0;
  padding: 28px 32px;
  text-align: left;
  font-size: 15px;
  line-height: 1.7;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
body.page-home .intro p { margin: 0 0 1em; }
body.page-home .intro p:last-child { margin-bottom: 0; }
body.page-home .intro a { color: var(--accent); font-weight: 600; text-decoration: none; }
body.page-home .intro a:hover { text-decoration: underline; }

/* ---------- Pages with centred content ---------- */

body.centered .controls {
  justify-content: center;
}

body.centered .controls > div {
  text-align: center;
}

body.centered h2,
body.centered h3,
body.centered #status {
  text-align: center;
}


/* ---------- Search box ---------- */

/*
 * sortableTable() creates a div containing:
 *
 *   input
 *   .wrap
 *
 * Centre the contents of that container.
 */
body.centered #root > div {
  text-align: center;
}


/* Keep the search box inline so text-align can centre it. */
body.centered #root > div > input {
  display: inline-block;
  margin-bottom: 10px;
}


/* ---------- Consistent table width ---------- */

body.centered table {
  width: 1250px;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- Fixed, per-page column widths ---------- */

/* Fixed layout: widths come from the header row, not from cell content.
   Since every table on a page gets the same percentages, columns line up. */
body.centered table {
  table-layout: fixed;
}

/* Cells are nowrap (styles.css), so clip anything too long. */
body.centered th,
body.centered td {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 3-column tables (Most and Best / Least and Worst): sprite | Pokemon | value */
body.page-pokemon th:first-child:nth-last-child(3)           { width: 22%; }
body.page-pokemon th:first-child:nth-last-child(3) + th      { width: 48%; }
body.page-pokemon th:first-child:nth-last-child(3) + th + th { width: 30%; }

/* Gen 9 Stats: Rank 6%, Sprite 6%, Pokemon 14.2%, remaining ten columns equal */
body.page-stats th:nth-child(1) { width: 6%; }
body.page-stats th:nth-child(2) { width: 6%; }
body.page-stats th:nth-child(3) { width: 19.2%; }
body.page-stats th:nth-child(n+4) { width: 6.88%; }

/* Slimmer side padding so headers (plus the sort arrow) fit in narrower columns */
body.page-stats th,
body.page-stats td {
  padding-left: 10px;
  padding-right: 10px;
}

/* Individual Records: Player/Season/Opponent | Pseudonym/Wins | Wins/Record | Net */
body.page-individual th:nth-child(1) { width: 30%; }
body.page-individual th:nth-child(2) { width: 30%; }
body.page-individual th:nth-child(3) { width: 20%; }
body.page-individual th:nth-child(4) { width: 20%; }

/* Pairing Records */
body.page-pairing th:nth-child(1) { width: 50%; }
body.page-pairing th:nth-child(n+2) { width: 16.66%; }

/* Pokemon Records (7 columns): 2nd column 30%, the other six share 70% */
body.page-pokemon th { width: 11.6667%; }
body.page-pokemon th:nth-child(2) { width: 30%; }
body.page-pokemon #root > div {
  max-width: 1250px;            /* same overall width as the other pages */
  margin-left: auto;
  margin-right: auto;
}

body.page-pokemon #root > div > div {
  flex: 1 1 calc(50% - 16px);   /* half the row, minus half the 32px gap */
  min-width: 0;                 /* lets the group shrink instead of forcing a wrap */
}

body.page-pokemon .wrap,
body.page-pokemon table {
  width: 100%;
  max-width: 100%;
}


/* Table wrapper used by sortableTable() and Pokemon Records */

body.centered .wrap {
  width: 1250px;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}


/* Keep generated groups centred */

body.centered #root > div {
  justify-content: center;
}


/* ---------- Non-sortable tables ---------- */

table.nosort th {
  cursor: default;
}

table.nosort th:hover {
  filter: none;
}

/* Hall of Fame: wider columns where names pile up, and let cells wrap */
body.page-hof th:nth-child(1) { width: 11%; }   /* Season */
body.page-hof th:nth-child(2),
body.page-hof th:nth-child(3),
body.page-hof th:nth-child(4),
body.page-hof th:nth-child(5) { width: 13%; }   /* Champions and runners-up */
body.page-hof th:nth-child(6) { width: 17%; }   /* Pokemon MVP */
body.page-hof th:nth-child(7) { width: 20%; }   /* Hercule Poirot */

body.page-hof td {
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Hover-over notes on tables */
body.centered .page-note {
  max-width: 720px;
  margin: 12px auto 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Season Sheets page ---------- */
body.page-sheets table {
  width: 640px;
  table-layout: fixed;
}

body.page-sheets th:nth-child(1) { width: 28%; }
body.page-sheets th:nth-child(2),
body.page-sheets th:nth-child(3) { width: 36%; }

body.page-sheets td.season { font-weight: 700; }
