/**
 * Tables and the club records
 * One of the stylesheets of the website, loaded in a fixed order by php/include/header.php
 * (list and order: AGENTS.md, "Stylesheets").
 */

/**
 * @section Tables
 */

table {
  background-color: var(--color-ultralightgray);
  box-shadow: var(--shadow);
  margin: 0.5em 2% 1em 2%;
  width: 96%;
}
table td {
  vertical-align: text-top;
}
table thead,
table tfoot {
  background-color: var(--color-darkblue);
  box-shadow: var(--shadow);
  color: var(--color-lightgray);
}
table thead {
  border-radius: 3px 3px 0px 0px;
  font-size: 0.9em;
  font-weight: bold;
}
table thead.sticky {
  position: sticky;
  top: 0;
}
table tfoot {
  border-radius: 0px 0px 3px 3px;
  font-size: 0.7em;
}
table tfoot.sticky {
  position: sticky;
  bottom: 0;
}
table tbody tr:first-child td {
  padding-top: 6px;
}
table tbody tr:last-child td {
  padding-bottom: 9px;
}
table td {
  padding: 2px 4px;
}
table td:first-child {
  padding-left: 8px;
}
table td:last-child {
  padding-right: 8px;
}
table thead td,
table tfoot td {
  padding-top: 4px;
  padding-bottom: 4px;
}
table tbody > tr:nth-child(2n) {
  background-color: var(--color-lightgray-transparent-barely);
}
table tbody > tr:hover {
  background-color: var(--color-yellow-transparent);
  color: var(--color-darkblue);
}
table tbody > tr:hover:nth-child(2n) {
  background-color: var(--color-yellow-transparent);
}
table thead h2 {
  font-size: 1.2em;
  font-weight: bold;
  margin-top: 0;
  margin-bottom: 0;
}
table thead a small {
  opacity: 0;
  transition: opacity 0.1s linear;
}
table thead a:hover small,
table thead a:focus small {
  opacity: 1;
}
@media (hover: none) {
  table thead a small {
    opacity: 1;
  }
}

/**
 * @section Records
 */
table.records tbody sup {
  font-size: 0.6em;
}
table.records tbody sup[title] {
  cursor: help;
}
table.records tfoot sup {
  padding-left: 1.5em;
  padding-right: 0.2em;
}
table.records tfoot sup:first-child {
  padding-left: 0.2em;
}

/* Two lines per row on phones, opt-in with class "two-line" on the table (set in the source view of
   the editor). Made for the five columns of the records: Disziplin | Leistung above,
   Athlet Jg. Jahrgang | Jahr below. All columns stay visible without swiping, the sticky head
   keeps working. Wider screens and print show the normal table. */
@media screen and (max-width: 640px) {
  main table.two-line {
    font-size: 1em;
  }
  table.two-line tr {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "first first fourth"
      "second third fifth";
    column-gap: 8px;
    padding: 5px 10px;
  }
  table.two-line :is(thead, tbody, tfoot) tr > td {
    padding: 0;
  }
  table.two-line td:nth-child(1) {
    grid-area: first;
    font-weight: bold;
  }
  table.two-line td:nth-child(2) {
    grid-area: second;
  }
  table.two-line td:nth-child(3) {
    grid-area: third;
    align-self: center;
    font-size: 0.85em;
  }
  table.two-line td:nth-child(4) {
    grid-area: fourth;
    font-weight: bold;
    text-align: right;
  }
  table.two-line td:nth-child(5) {
    grid-area: fifth;
    text-align: right;
  }
  table.two-line tbody td:nth-child(3)::before {
    content: "Jg. ";
  }
  /* further members of a team (rowspan on Disziplin, Leistung, Jahr): only Athlet and Jahrgang,
     on the second line below the first member */
  table.two-line tbody tr:not(:has(> td:nth-child(3))) > td:nth-child(1) {
    grid-area: second;
    font-weight: normal;
  }
  table.two-line tbody tr:not(:has(> td:nth-child(3))) > td:nth-child(2) {
    grid-area: third;
    align-self: center;
    font-size: 0.85em;
    font-weight: normal;
    text-align: left;
  }
  table.two-line tbody tr:not(:has(> td:nth-child(3))) > td:nth-child(2)::before {
    content: "Jg. ";
  }
  table.two-line tfoot tr {
    display: block;
  }
  table.two-line tfoot tr > td {
    display: block;
    padding: 4px 10px;
  }
}

/* phones and narrow windows (the sidebar moves below the content) */
@media (max-width: 990px) {
  table.records {
    font-size: 0.8em;
    margin-right: -20px;
    margin-left: -20px;
    width: calc(100% + 40px);
  }
}
