/* Layout for the top bar and small screens. Loaded after w3.css and w3schools.css. */

/* ---------- top bar (all screens) ---------- */

.topnav {
  display: flex;
  align-items: stretch;
  overflow: visible;          /* the phone drop-down hangs below the bar */
  z-index: 10;
  top: 0;
}
.topnav a, .topnav form { float: none; }
.topnav form.search {
  display: flex;
  align-items: center;
  padding: 0 16px;
}
.topnav form.search input { float: none; }
.topnav form.search input[type=search] { height: 24px; }

.menu { display: flex; flex: 1; }
.menu-right { display: flex; flex-direction: row-reverse; margin-left: auto; }

.menu-toggle {
  display: none;
  margin-left: auto;
  background: none;
  border: 0;
  color: #f2f2f2;
  font-size: 24px;
  line-height: 1;
  padding: 0 16px;
  cursor: pointer;
}
.menu-toggle:hover, .topnav.open .menu-toggle { background-color: #555; }

/* keep table rows as compact as they were (pages used to render in quirks mode) */
.w3-table td, .w3-table th { line-height: 1.2; }

/* sortable column headers look clickable */
table.sortable th { cursor: pointer; }

/* home page: bulleted text on the left, picture on the right, tops aligned */
.home-body { display: flex; align-items: flex-start; gap: 48px; margin-top: 32px; padding: 0 24px; }
.home-text { flex: 3; }
.home-img { flex: 2; }
.home-img img { width: 100%; height: auto; display: block; }
.home-section { font-weight: bold; margin: 0 0 4px; }
.home-text ul { margin: 0 0 20px; padding-left: 24px; }
.home-text li { margin: 2px 0; }
.home-updated { margin-top: 28px; color: #555; }

/* images never wider than the screen */
img.a3, img.a4, img.chart { max-width: 100%; height: auto; }

/* wide maths scrolls inside its own box */
mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; max-width: 100%; }

/* ---------- phones and narrow windows ---------- */

@media (max-width: 900px) {
  .menu-toggle { display: block; }

  .topnav form.search { flex: 1; min-width: 0; padding: 0 8px; }
  .topnav form.search input[type=search] { width: 100%; min-width: 0; font-size: 16px; height: 30px; }
  .topnav form.search input[type=submit] { height: 30px; }

  .menu {
    display: none;
    position: absolute;
    top: 44px;
    left: 0;
    right: 0;
    flex-direction: column;
    background-color: #333;
    box-shadow: 0 6px 12px rgba(0, 0, 0, .3);
  }
  .topnav.open .menu { display: flex; }
  .menu-right { flex-direction: column; margin-left: 0; border-top: 1px solid #555; }
  .menu a { text-align: left; padding: 12px 20px; }

  /* quote box: less of the screen */
  .wise { font-size: 13px; padding: 0 8px; }
  .wise p { margin: 8px 0; }

  /* filter bars: wrap cleanly, controls big enough to tap, 16px stops iOS zooming in */
  form.bar { line-height: 2.8; margin: 4px 8px; }
  form.bar input, form.bar select { font-size: 16px; line-height: normal; height: 32px; padding: 2px 4px; vertical-align: middle; }

  /* wide tables scroll sideways inside their own box instead of widening the page */
  table.w3-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  table.w3-table td, table.w3-table th { padding: 6px 8px; }
  /* player column (set by site.js) stays put while the numbers scroll */
  table.w3-table .pin { position: sticky; left: 0; z-index: 1; background-color: #fff; }
  table.w3-table tr:nth-child(even) .pin { background-color: #f1f1f1; }
  table.w3-table .pin { box-shadow: 2px 0 3px -2px rgba(0, 0, 0, .35); }

  /* multi-column chart grids become one column */
  .column2, .column3 { width: 100%; float: none; padding: 5px 0; }

  /* charts and figures use the full width */
  img.chart, .a4 img, .a3 img { width: 100% !important; height: auto; }

  /* home page: no picture on phones */
  .home-img { display: none; }
  .home-body { padding: 0 16px; }

  h1 { font-size: 28px; }
}

/* ---------- paper tables, styled like LaTeX booktabs ---------- */
table.latex {
  width: auto; max-width: 100%;
  margin: 16px auto 6px;
  border-collapse: collapse;
  border-top: 2px solid #000;           /* \toprule */
  border-bottom: 2px solid #000;        /* \bottomrule */
  font-variant-numeric: tabular-nums;
  background: none;
}
table.latex th, table.latex td {
  padding: 2px 9px; line-height: 1.35;
  background: none !important; border: 0; vertical-align: top;
}
table.latex th:first-child, table.latex td:first-child { padding-left: 4px; }
table.latex th:last-child, table.latex td:last-child { padding-right: 4px; }
table.latex thead tr:last-child th { border-bottom: 1px solid #000; padding-bottom: 3px; }  /* \midrule */
table.latex tbody tr:first-child td { padding-top: 5px; }
table.latex tbody tr:last-child td { padding-bottom: 5px; }
table.latex th.grp {                    /* \multicolumn + \cmidrule(lr) */
  text-align: center;
  background: linear-gradient(#000, #000) center bottom / calc(100% - 12px) 1px no-repeat !important;
}
table.latex tr:hover { background: none; }
table.latex.components td { padding-top: 6px; padding-bottom: 6px; }  /* \addlinespace */
table.latex.components td:nth-child(2) { white-space: nowrap; }
table.latex .pin { box-shadow: none; }
table.latex.components th { text-align: left; }
table.latex.components td:first-child { white-space: nowrap; }
/* \makebox[\textwidth]: wide tables spill past the text into the margins, centred */
@media (min-width: 901px) {
  .a4:has(table.latex.wide) { overflow: visible; }
  table.latex.wide {
    --w: min(calc(100% + 4cm), calc(100vw - 48px));
    width: var(--w); max-width: none;
    margin-left: calc((100% - var(--w)) / 2);
    margin-right: 0;
  }
}
