/* The school day: the "now" section, the class journal, one class's day and the events.
   Sizes follow the approved mockups (27px headings on a phone, 38px from 960px). */

:root {
  --heading-size: 1.588rem;
  --heading-line: 1.3333;
  --section-heading-size: 1.353rem;
}

@media (min-width: 960px) {
  :root {
    --heading-size: 2.235rem;
    --heading-line: 1.263;
    --section-heading-size: 1.765rem;
  }
}

.margin-time {
  padding-top: calc(var(--cell) * 0.85);
  font-size: 1.059rem;
  font-weight: 700;
}

@media (min-width: 960px) {
  .margin-time {
    padding-top: calc(var(--cell) * 1.2);
    font-size: 1.294rem;
  }
}

.page-heading,
.now-headline {
  margin: calc(var(--cell) / 2) 0 0;
  font-size: var(--heading-size);
  line-height: var(--heading-line);
}

.page-lead {
  margin: calc(var(--cell) / 3) 0 0;
}

.section-note {
  margin: calc(var(--cell) / 6) 0 0;
  color: var(--pencil);
  font-size: var(--size-note);
}

/* A link on a line of its own, tall enough to hit with a thumb even when it wraps. */
.link-line {
  display: inline-block;
  padding: calc((var(--touch-target) - var(--cell)) / 2) 0;
}

.day-note {
  margin: calc(var(--cell) / 2) 0 0;
  font-weight: 700;
}

.no-lessons {
  margin: calc(var(--cell) / 4) 0 0;
}

/* A teacher's red-pen note on a changed lesson. */
.change-mark {
  display: block;
  color: var(--red-pen);
  font-size: var(--size-note);
  font-weight: 700;
}

/* Class picker: a plain select and its button, square like the rest of the page. */
.class-picker {
  margin: calc(var(--cell) / 2) 0 0;
}

.class-picker label {
  display: block;
  color: var(--pencil);
  font-size: var(--size-note);
}

.class-picker-row {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--cell) / 3);
  max-width: calc(var(--cell) * 16);
  margin-top: calc(var(--cell) / 6);
}

.class-picker select {
  flex: 1 1 calc(var(--cell) * 7);
  min-width: 0;
  height: calc(var(--cell) * 2);
  padding: 0 calc(var(--cell) / 2);
  border: 1.5px solid var(--ink);
  border-radius: 0;
  background: var(--label);
  color: var(--ink);
  font: inherit;
}

.class-picker .button {
  flex: none;
  min-height: calc(var(--cell) * 2);
  padding: 0 calc(var(--cell) * 2 / 3);
}

/* Shift switch: tabs written with a ruler line under the chosen one. */
.shift-switch {
  display: flex;
  gap: var(--cell);
  margin-top: calc(var(--cell) / 6);
}

.shift-switch a {
  line-height: var(--touch-target);
}

.shift-switch a[aria-current="page"] {
  border-bottom: 3px solid var(--ink);
  font-weight: 700;
  text-decoration: none;
}

/* The class journal grid. On a phone it is glued across the margin, as a printed register
   would be: it sits above the red rule and hides it. */
.journal-table-wrap {
  position: relative;
  margin: calc(var(--cell) / 2) calc(var(--cell) / -1 + 8px) 0
    calc(var(--content-inset) * -1 + 8px);
  background-color: var(--paper);
  overflow-x: auto;
}

@media (min-width: 600px) {
  .journal-table-wrap {
    margin: calc(var(--cell) / 2) 0 0;
    background-color: transparent;
  }
}

.journal-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--label);
}

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

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

.journal-table .class-column {
  width: 48px;
}

.journal-table tbody th a {
  display: block;
  font-weight: 700;
  line-height: calc(var(--cell) * 1.5);
}

.journal-table abbr {
  text-decoration: none;
}

.journal-table .is-now {
  background-color: var(--marker);
  font-weight: 700;
}

/* A changed lesson gets a red corner, as a teacher would tick the cell. */
.journal-table .is-changed {
  background-image: linear-gradient(225deg, var(--red-pen) 7px, transparent 7px);
}

.journal-notes {
  padding-top: calc(var(--cell) / 2);
}

.journal-notes p {
  margin-bottom: calc(var(--cell) / 2);
  color: var(--pencil);
  font-size: var(--size-note);
}

.notes-heading {
  margin: 0 0 calc(var(--cell) / 4);
  font-family: var(--font-text);
  font-size: 1rem;
}

.abbreviations {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(calc(var(--cell) * 5), 1fr));
  gap: 0 var(--cell);
  margin: 0 0 calc(var(--cell) / 2);
  font-size: var(--size-note);
}

.abbreviations div {
  display: flex;
  gap: calc(var(--cell) / 3);
}

.abbreviations dt {
  min-width: calc(var(--cell) * 1.5);
  font-weight: 700;
}

.abbreviations dd {
  margin: 0;
}

.mark-legend {
  margin: 0;
  padding: 0;
  color: var(--pencil);
  font-size: var(--size-note);
  list-style: none;
}

.mark-legend li {
  display: flex;
  align-items: center;
  gap: calc(var(--cell) / 3);
}

.mark-sample {
  display: inline-block;
  min-width: var(--cell);
  height: calc(var(--cell) * 0.75);
  border: 1px solid var(--table-line);
  background-color: var(--label);
  color: var(--ink);
  font-size: var(--size-small);
  line-height: calc(var(--cell) * 0.75);
  text-align: center;
}

.mark-sample.is-changed {
  background-image: linear-gradient(225deg, var(--red-pen) 7px, transparent 7px);
}

/* Monday to Saturday of one class's week. */
.week-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  max-width: calc(var(--cell) * 20);
  margin-top: calc(var(--cell) * 2 / 3);
  border: 1px solid var(--table-line);
  background: var(--label);
}

.week-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 52px;
  border-right: 1px solid var(--table-line);
  font-size: var(--size-small);
  line-height: 1.385;
  text-decoration: none;
}

.week-day:last-child {
  border-right: 0;
}

.week-day-number {
  font-size: 0.941rem;
  font-weight: 700;
}

.week-day.is-today {
  background-color: var(--marker);
}

.week-day[aria-current="page"] {
  box-shadow: inset 0 -3px 0 var(--ink);
  font-weight: 700;
}

/* One class's lessons: start times in the margin, done ones ticked in red. */
.lesson-list {
  margin: calc(var(--cell) / 2) 0 0;
  padding: 0;
  list-style: none;
}

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

.lesson-time {
  font-size: var(--size-note);
}

.lesson-body {
  display: flex;
  max-width: calc(var(--cell) * 26);
  justify-content: space-between;
  gap: calc(var(--cell) / 3);
  padding: calc(var(--cell) / 2) calc(var(--cell) * 2 / 3) calc(var(--cell) / 2) 0;
}

.lesson-subject,
.lesson-place,
.lesson-ends {
  display: block;
}

.lesson-subject {
  font-weight: 700;
}

.lesson-place,
.lesson-ends {
  font-size: var(--size-note);
}

.lesson-row.is-done .lesson-time,
.lesson-row.is-done .lesson-body {
  color: var(--pencil);
}

.lesson-row.is-now .lesson-time {
  font-size: 0.941rem;
  font-weight: 700;
}

.lesson-row.is-now .lesson-body {
  margin-left: calc(var(--cell) / -3);
  padding-left: calc(var(--cell) / 3);
  background-color: var(--marker);
}

.lesson-row.is-now .lesson-subject {
  font-family: var(--font-hand);
  font-size: 1.176rem;
  line-height: 1.4;
}

.lesson-row.is-now .lesson-place {
  font-size: 1rem;
}

/* Red pen on the marker yellow is 4.46:1, under AA: the note turns ink, underlined in red. */
.lesson-row.is-now .change-mark {
  color: var(--ink);
  text-decoration: underline 2px var(--red-pen);
  text-underline-offset: 3px;
}

.tick {
  flex: 0 0 var(--cell);
}

.tick path {
  fill: none;
  stroke: var(--red-pen);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.day-end .lesson-time,
.day-end-text {
  color: var(--pencil);
}

.day-end-text {
  margin: calc(var(--cell) / 2) 0 0;
}

/* Sections on the page start with a ruled line across the text, never across the margin. */
.section-head .ruled-body {
  margin-top: var(--cell);
  padding-top: var(--cell);
  border-top: 1px solid var(--ink);
}

.section-heading {
  margin: 0;
  font-size: var(--section-heading-size);
  line-height: 1.39;
}

/* Events: the date in the margin, a day off written in red pen. */
.event-row .ruled-body {
  padding: calc(var(--cell) / 2) 0;
}

.event-date {
  padding-top: calc(var(--cell) / 2 + 2px);
}

@media (min-width: 960px) {
  .event-date {
    font-size: 0.941rem;
  }
}

.event-title {
  margin: 0;
  font-family: var(--font-text);
  font-size: 1rem;
  line-height: inherit;
}

.event-meta,
.event-summary {
  margin: 0;
  font-size: var(--size-note);
}

.event-meta {
  color: var(--pencil);
}

/* Audience and place are stored as mid-sentence text; the line starts with a capital. */
.event-meta::first-letter {
  text-transform: uppercase;
}

.event-summary {
  margin-top: calc(var(--cell) / 6);
}

.events-page .section-head .ruled-body {
  margin-top: calc(var(--cell) / 2);
}

/* The "now" section: the clock in the margin, what is happening on the page. */
.now-main .margin-time {
  padding-top: calc(var(--cell) * 0.85);
}

.now-details p {
  margin: calc(var(--cell) / 2) 0 0;
}

.now-details .link-line {
  margin-top: calc(var(--cell) / -6);
}

.lesson-progress {
  max-width: calc(var(--cell) * 20);
  margin-top: calc(var(--cell) / 2);
}

/* The progress bar is a ruler drawn in ink with the marker filling the time gone by. */
.lesson-progress progress {
  display: block;
  width: 100%;
  height: 12px;
  border: 1.5px solid var(--ink);
  background-color: var(--label);
  -webkit-appearance: none;
  appearance: none;
}

.lesson-progress progress::-webkit-progress-bar {
  background-color: var(--label);
}

.lesson-progress progress::-webkit-progress-value {
  background-color: var(--marker);
}

.lesson-progress progress::-moz-progress-bar {
  background-color: var(--marker);
}

.now-details .progress-times {
  display: flex;
  justify-content: space-between;
  margin: 0;
  color: var(--pencil);
  font-size: var(--size-small);
  line-height: 1.5385;
}

/* The marker stroke behind what is happening now. It fills in once when the page opens;
   base.css turns the animation off under prefers-reduced-motion. */
@keyframes marker-stroke {
  from {
    background-size: 0 100%;
  }

  to {
    background-size: 100% 100%;
  }
}

.marker {
  padding: 2px 6px;
  background-image: linear-gradient(var(--marker), var(--marker));
  background-repeat: no-repeat;
  background-size: 100% 100%;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  animation: marker-stroke 0.6s ease-out;
}

.now .class-picker {
  margin-top: calc(var(--cell) * 2 / 3);
}

/* What every class of the shift is doing now: a white card on the paper. */
.class-now-list {
  margin: calc(var(--cell) / 2) 0 0;
  padding: 0;
  border: 1px solid var(--grid);
  background: var(--label);
  list-style: none;
}

.class-now-list li {
  display: flex;
  gap: calc(var(--cell) / 2);
  max-width: none;
  padding: calc(var(--cell) / 2);
  border-bottom: 1px solid var(--grid);
}

.class-now-list li:last-child {
  border-bottom: 0;
}

.class-now-label {
  flex: 0 0 calc(var(--touch-target) + 4px);
  font-family: var(--font-hand);
  font-size: 1.059rem;
  font-weight: 700;
  text-decoration: none;
}

.class-now-subject,
.class-now-place {
  display: block;
}

.class-now-subject {
  font-weight: 700;
}

.class-now-place {
  color: var(--pencil);
  font-size: var(--size-note);
}

.now-classes .link-line {
  margin-top: calc(var(--cell) / 6);
}

.now-next-times {
  padding-top: calc(var(--cell) / 3);
  line-height: 1.4;
}

.now-next-text {
  margin: 0;
  padding: calc(var(--cell) / 3) 0 var(--cell);
  color: var(--pencil);
}

/* The journal grid beside the headline appears only where it fits. */
.now-grid {
  display: none;
}

@media (min-width: 960px) {
  .now-columns {
    display: flex;
    flex-wrap: wrap;
    gap: var(--cell) calc(var(--cell) * 2);
    padding-bottom: calc(var(--cell) * 1.5);
  }

  .now-summary {
    flex: 1 1 320px;
    min-width: 0;
  }

  .now-grid {
    display: block;
    flex: 2 1 560px;
    min-width: 0;
    overflow-x: auto;
  }

  .now-grid:empty {
    display: none;
  }

  .now-classes,
  .now-next {
    display: none;
  }
}

.now-table th,
.now-table td {
  height: var(--touch-target);
  padding: 0 6px;
  font-size: var(--size-note);
}

.now-table caption {
  font-size: var(--size-note);
}

.now-table .is-focus {
  width: 38%;
  text-align: left;
}

.now-table thead .is-focus {
  font-weight: 700;
}

/* A note in pencil under the sample-data band: the page shows a chosen moment. */
.demo-time {
  max-width: none;
  margin: 0;
  padding: calc(var(--cell) / 6) calc(var(--cell) * 2 / 3);
  border-top: 1px dashed var(--table-line);
  background: var(--ribbon);
  color: var(--pencil);
  font-size: var(--size-small);
  line-height: 1.5385;
}

.demo-time a {
  color: var(--ink);
}
