/* The people and history pages: the teachers, one teacher, the olympiad wall, the chronicle.
   Loaded after school-day.css; built on the tokens and the ruled rows of base.css. Years stay in
   the margin, as times do on the other pages. */

/* Jump links under a page heading, like the contents line of an exercise book. */
.page-sections ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--cell);
  margin: calc(var(--cell) / 3) 0 0;
  padding: 0;
  list-style: none;
}

.page-sections a {
  display: inline-block;
  line-height: var(--touch-target);
}

/* A list whose rows carry a year in the margin: directors, teachers, a teacher's roles. */
.history-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-list li {
  max-width: none;
}

.history-text {
  margin: 0;
  padding: calc(var(--cell) / 4) 0;
}

.history-year {
  padding-top: calc(var(--cell) / 4 + 2px);
  color: var(--ink);
}

.history-meta {
  color: var(--pencil);
  font-size: var(--size-note);
}

.subject-name,
.decade-name {
  margin: calc(var(--cell) * 2 / 3) 0 calc(var(--cell) / 6);
  font-size: 1.118rem;
  line-height: var(--cell);
}

/* A decade starts with its number written large in the margin, as a pupil would date a page. */
.decade-mark {
  padding-top: calc(var(--cell) * 2 / 3);
  font-size: 1.059rem;
  font-weight: 700;
}

/* The leadership tree, drawn in ink on the grid: each level is joined to its parent by a line
   that runs along the cells, and stops at the last position of the level. */
.staff-tree,
.staff-tree ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.staff-tree {
  padding: calc(var(--cell) / 2) 0 var(--cell);
}

.staff-tree ul {
  margin-left: calc(var(--cell) * 0.75);
}

.staff-node {
  position: relative;
  max-width: none;
}

.staff-tree ul > .staff-node {
  padding: calc(var(--cell) / 2) 0 0 var(--cell);
}

.staff-tree ul > .staff-node::before,
.staff-tree ul > .staff-node::after {
  content: "";
  position: absolute;
  left: 0;
}

.staff-tree ul > .staff-node::before {
  top: 0;
  bottom: 0;
  border-left: var(--rule-width) solid var(--ink);
}

.staff-tree ul > .staff-node:last-child::before {
  bottom: auto;
  height: calc(var(--cell) * 1.25);
}

.staff-tree ul > .staff-node::after {
  top: calc(var(--cell) * 1.25);
  width: calc(var(--cell) * 0.75);
  border-top: var(--rule-width) solid var(--ink);
}

/* Each position is written on a strip of paper, so the grid does not run through its words. */
.staff-node-card {
  display: inline-grid;
  max-width: calc(var(--cell) * 24);
  margin: 0;
  padding: calc(var(--cell) / 6) calc(var(--cell) / 3);
  background: var(--paper);
}

.staff-node-title {
  color: var(--pencil);
  font-size: var(--size-note);
}

.staff-node-holder {
  font-family: var(--font-hand);
  font-size: 1.059rem;
  font-weight: 700;
}

.staff-tree > .staff-node > .staff-node-card .staff-node-holder {
  font-size: 1.353rem;
}

.staff-node-holder.is-vacant {
  color: var(--pencil);
  font-family: var(--font-text);
  font-size: var(--size-note);
  font-weight: 400;
}

/* On a phone a deeper branch folds behind this line; from 600px every branch is open. */
.staff-branch > summary {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-target);
  margin-left: calc(var(--cell) * 0.75);
  color: var(--pencil);
  font-size: var(--size-note);
  cursor: pointer;
}

@media (min-width: 600px) {
  .staff-branch > summary {
    display: none;
  }
}

/* One teacher: the portrait is a print glued in beside the heading. */
.teacher-head {
  display: grid;
  gap: calc(var(--cell) / 2) var(--cell);
}

.teacher-portrait {
  display: block;
  width: calc(var(--cell) * 6);
  height: auto;
  margin: calc(var(--cell) / 2) 0 var(--cell);
  border: 6px solid var(--label);
  outline: 1px solid var(--table-line);
  background: var(--label);
  transform: rotate(-1.5deg);
}

@media (min-width: 600px) {
  .teacher-head {
    grid-template-columns: minmax(0, 1fr) calc(var(--cell) * 8);
    align-items: start;
  }

  .teacher-portrait {
    width: calc(var(--cell) * 8);
    margin-top: var(--cell);
  }
}

html[data-a11y-theme="contrast"] .teacher-portrait {
  transform: none;
}

.class-mark {
  display: inline-block;
  min-width: calc(var(--cell) * 2);
  font-family: var(--font-hand);
  font-weight: 700;
  line-height: var(--touch-target);
}

/* The olympiad wall: the tally as a page of the class register, the filters, then each school
   year's results as index cards: white, a red rule under the name, blue lines below, the place
   circled in red as a teacher marks it. */
.tally-wrap {
  overflow-x: auto;
  padding-top: calc(var(--cell) / 2);
}

.tally {
  width: 100%;
  max-width: calc(var(--cell) * 26);
  border-collapse: collapse;
  background: var(--label);
}

.tally caption {
  padding: 0 0 calc(var(--cell) / 6);
  color: var(--pencil);
  font-size: var(--size-small);
  text-align: left;
}

.tally th,
.tally td {
  height: calc(var(--cell) * 1.5);
  padding: 0 2px;
  border: 1px solid var(--table-line);
  font-size: var(--size-small);
  font-weight: 400;
  line-height: 1.3;
  text-align: center;
}

.tally tbody th {
  text-align: left;
}

.tally-count {
  color: var(--red-pen);
  font-family: var(--font-hand);
  font-size: 1rem;
  font-weight: 700;
}

.tally-total {
  color: var(--ink);
}

/* A school year is dated in the margin as a pupil would: on a phone the margin holds only the
   year it starts; the heading beside it says both. */
.wall-year .section-head {
  align-items: baseline;
}

.year-mark {
  font-weight: 700;
}

.year-tail {
  display: none;
}

@media (min-width: 600px) {
  .tally th,
  .tally td {
    padding: 0 calc(var(--cell) / 4);
  }

  .year-tail {
    display: inline;
  }
}

.wall-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: calc(var(--cell) / 2) calc(var(--cell) * 2 / 3);
  margin: var(--cell) 0 0;
}

.wall-filter {
  display: grid;
  gap: calc(var(--cell) / 6);
  min-width: 0;
}

.wall-filter label {
  color: var(--pencil);
  font-size: var(--size-note);
}

.wall-filter select {
  max-width: calc(var(--cell) * 11);
  height: calc(var(--cell) * 2);
  padding: 0 calc(var(--cell) / 3);
  border: 1.5px solid var(--ink);
  border-radius: 0;
  background: var(--label);
  color: var(--ink);
  font: inherit;
}

.wall-filters .button {
  min-height: calc(var(--cell) * 2);
}

/* Links to the next part of a school year and to the years beside it. */
.wall-pages .ruled-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--cell);
  margin-top: var(--cell);
}

.result-cards {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cell);
  margin: calc(var(--cell) / 2) 0 0;
  padding: 0;
  list-style: none;
}

.result-card {
  position: relative;
  width: min(100%, calc(var(--cell) * 12));
  max-width: none;
  padding: 0 calc(var(--cell) * 2) calc(var(--cell) / 2) calc(var(--cell) / 2);
  border: 1px solid var(--table-line);
  background-color: var(--label);
  /* The red rule under the second line, then a blue line every cell, as on a real index card. */
  background-image:
    linear-gradient(var(--red-pen), var(--red-pen)),
    repeating-linear-gradient(
      to bottom,
      transparent 0 calc(var(--cell) - 1px),
      var(--grid) calc(var(--cell) - 1px) var(--cell)
    );
  background-position:
    0 calc(var(--cell) * 2 - 2px),
    0 calc(var(--cell) * 2);
  background-repeat: no-repeat, repeat-y;
  background-size:
    100% 2px,
    100% 100%;
  line-height: var(--cell);
}

.result-cards > .result-card:nth-child(3n + 2) {
  transform: rotate(0.6deg);
}

.result-cards > .result-card:nth-child(3n) {
  transform: rotate(-0.5deg);
}

html[data-a11y-theme="contrast"] .result-card {
  background-image: none;
  transform: none;
}

.result-place,
.result-pupil,
.result-line {
  margin: 0;
  line-height: var(--cell);
}

.result-place {
  color: var(--red-pen);
  font-size: var(--size-note);
  font-weight: 700;
}

.result-pupil {
  font-size: 1.118rem;
}

.result-line {
  font-size: var(--size-note);
}

/* The place circled in red pen, a little askew, as a teacher writes a mark. */
.place-mark {
  position: absolute;
  top: calc(var(--cell) / 4);
  right: calc(var(--cell) / 4);
  display: grid;
  place-items: center;
  width: calc(var(--cell) * 1.5);
  height: calc(var(--cell) * 1.5);
  border: var(--rule-width) solid var(--red-pen);
  border-radius: 50% 46% 52% 48%;
  color: var(--red-pen);
  font-family: var(--font-hand);
  font-size: 1.176rem;
  font-weight: 700;
  line-height: 1;
  transform: rotate(-8deg);
}

.best-class {
  margin: 0;
}

.best-period {
  color: var(--pencil);
  font-size: var(--size-note);
}

.best-row .history-meta {
  margin: 0;
}

.best-year {
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 1080px) {
  .wall-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) calc(var(--cell) * 13);
    column-gap: calc(var(--cell) * 1.5);
    align-items: start;
  }

  /* Beside the results the history leaves the ruled grid: no margin column of its own. */
  .best-classes .ruled-row {
    display: block;
    margin-left: 0;
  }

  .best-classes .margin-note {
    padding: calc(var(--cell) / 2) 0 0;
    text-align: left;
  }
}

/* The chronicle: each year written large in the margin, what happened beside it. */
.chronicle-year {
  padding-bottom: calc(var(--cell) / 2);
}

.chronicle-year-mark {
  margin: 0;
  padding-top: calc(var(--cell) / 2);
  font-size: 1.176rem;
  line-height: var(--cell);
}

.chronicle-lines {
  margin: 0;
  padding: calc(var(--cell) / 2) 0 0;
  list-style: none;
}

.chronicle-lines li {
  margin: 0 0 calc(var(--cell) / 3);
}

.chronicle-date {
  color: var(--pencil);
  font-size: var(--size-note);
}

.chronicle-director {
  font-weight: 700;
}

/* A school year's results are places: written in the teacher's red pen. */
.chronicle-results {
  padding-left: calc(var(--cell) / 3);
  border-left: var(--rule-width) solid var(--red-pen);
}
