@font-face {
  font-family: "Source Code Pro";
  src: url("SourceCodePro-VariableFont_wght.ttf") format("truetype-variations");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --border: #e2ddd6;
  --text: #1a1714;
  --muted: #6b6560;
  --time-bg: #f2efe9;
  --kind-bg: #f7f5f1;

  --c-lcca:  #d4e8c2;
  --c-ttua:  #c2d9ed;
  --c-ct:    #f7e4c2;
  --c-iypp:  #e2c2ed;
  --c-cbpv:  #f7c2c2;
  --c-sht:   #c2ede8;
  --c-cal:   #ede8c2;
  --c-icr:   #f7d4c2;
  --c-admin: #ececec;
  --c-social:#cccccc;

  --radius: 4px;
}

/* ── Table wrapper ── */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 820px;
  background: var(--surface);
}

/* ── Header rows ── */
thead tr.days-row th {
  background: var(--text);
  color: #faf9f7;
  font-weight: 400;
  font-size: 0.82rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0.55rem 0.75rem;
  text-align: center;
}

thead tr.kind-row th {
  background: var(--kind-bg);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-top: 2px solid var(--border);
}
thead tr.kind-row th.time-th {
  background: var(--time-bg);
  border-right: 2px solid var(--border);
}
/* Thicker dividers between days in kind row */
thead tr.kind-row th.day-first { border-left: 2px solid #c8c0b4; }

/* ── Body cells ── */
td {
  border: 1px solid var(--border);
  padding: 5px 6px;
  vertical-align: top;
  font-size: 0.8rem;
}

td.time {
  background: var(--time-bg);
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  text-align: right;
  padding-right: 0.75rem;
  vertical-align: middle;
  border-right: 2px solid #c8c0b4;
}

/* Day separator — left border of first column in each day */
td.day-first { border-left: 2px solid #c8c0b4; }
thead tr.kind-row th.day-first { border-left: 2px solid #c8c0b4; }

/* Admin rows */
td.admin {
  background: var(--c-admin);
  color: var(--muted);
  font-size: 0.75rem;
  font-style: italic;
  text-align: center;
  vertical-align: middle;
}

/* Session pill */
.session {
  border-radius: var(--radius);
  font-family: 'Source Code Pro', monospace;
  font-weight: 700;
  font-size: 0.75rem;
  text-align: center;
  padding: 4px 6px;
  display: block;
}

/* Social events use serif, not monospace */
.session.social {
  font-family: 'Lora', serif;
  font-weight: 400;
  font-size: 0.75rem;
  background: var(--c-social);
}

.split { display: flex; flex-direction: column; gap: 3px; }

/* Course colours */
.bg-lcca { background: var(--c-lcca); }
.bg-ttua { background: var(--c-ttua); }
.bg-ct   { background: var(--c-ct);   }
.bg-iypp { background: var(--c-iypp); }
.bg-cbpv { background: var(--c-cbpv); }
.bg-sht  { background: var(--c-sht);  }
.bg-cal  { background: var(--c-cal);  }
.bg-icr  { background: var(--c-icr);  }

/* ── Course toggles ── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin-bottom: 2.5rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.filter-group-label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding-left: 2px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  border: 1.5px solid rgba(0,0,0,0.15);
  cursor: pointer;
  font-family: "Lora", serif;
  font-size: 0.8rem;
  user-select: none;
  transition: opacity 0.15s, border-color 0.15s;
  background: var(--surface);
}

.toggle:hover { border-color: rgba(0,0,0,0.3); }

.toggle .swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.12);
}

.toggle .code {
  font-family: 'Source Code Pro', monospace;
  font-weight: 700;
  font-size: 0.75rem;
}

.code {
  font-family: 'Source Code Pro', monospace;
  font-weight: 700;
}

/* Deselected state */
.toggle[aria-pressed="false"] {
  opacity: 0.45;
}

/* IYPP is always-on — no pointer, slightly different look */
.toggle.always-on {
  cursor: default;
  border-style: solid;
  opacity: 1;
}
.toggle.always-on::after {
  content: '✦';
  font-size: 0.55rem;
  color: var(--muted);
  margin-left: 1px;
}

/* Hide sessions in the timetable when their course is toggled off */
body.hide-lcca table:not(.room-table) .bg-lcca,
body.hide-ttua table:not(.room-table) .bg-ttua,
body.hide-ct   table:not(.room-table) .bg-ct,
body.hide-cbpv table:not(.room-table) .bg-cbpv,
body.hide-sht  table:not(.room-table) .bg-sht,
body.hide-cal  table:not(.room-table) .bg-cal,
body.hide-icr  table:not(.room-table) .bg-icr { display: none; }

/* Hide room-allocation rows when their course is toggled off */
body.hide-lcca tr[data-course="lcca"],
body.hide-ttua tr[data-course="ttua"],
body.hide-ct   tr[data-course="ct"],
body.hide-cbpv tr[data-course="cbpv"],
body.hide-sht  tr[data-course="sht"],
body.hide-cal  tr[data-course="cal"],
body.hide-icr  tr[data-course="icr"] { display: none; }

/* Highlight when a course changes room */
.room-change {
  font-weight: 700;
}

/* Room allocation tables */
.room-table td, .room-table th {
  text-align: center;
  vertical-align: middle;
}
.room-table td.course-cell {
  text-align: left;
  white-space: nowrap;
  background: var(--time-bg);
  font-size: 0.75rem;
  color: var(--muted);
}
.room-table td.course-tag {
  background: var(--surface);
  border-right: 2px solid #c8c0b4;
}
.room-table .session {
  display: inline-block;
  vertical-align: middle;
  width: 3.2rem;
  box-sizing: border-box;
}

.note {
  margin-top: 1.5rem;
  line-height: 1.6;
}
.note strong {
  font-family: "Arial", sans-serif;
  font-style: bold;
}

@media (max-width: 700px) {
  header { padding: 1.5rem 1rem; }
  main { padding: 1.5rem 0.75rem 3rem; }
}
