/* Timetable: control bar, weekly grid, activity blocks, details dialog and legend.
 * The grid has 79 rows of 0.75rem: one per 10 minutes from 08:00 to 21:10 (grid.js places
 * the blocks by percentage inside each day cell, so overlapping blocks share the width). */

/* ---------- Control bar ---------- */

.tt-controls {
  display: grid;
  gap: var(--space-3);
}

.tt-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
}

.tt-filters .field {
  min-width: 13rem;
}

.tt-week {
  align-items: center;
}

.tt-week-label {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tt-empty {
  text-align: center;
  color: var(--color-muted);
  padding: var(--space-5);
}

/* .card sets its own display, which would override the hidden attribute. */
.tt-empty[hidden] {
  display: none;
}

/* ---------- Timetable grid ---------- */

.tt-grid {
  display: grid;
  grid-template-columns: 6.5rem repeat(7, minmax(6.5rem, 1fr));
  grid-template-rows: auto repeat(79, 0.75rem);
  min-width: 58rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  overflow: hidden;
}

.tt-corner,
.tt-head {
  padding: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 700;
  text-align: center;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.tt-time {
  padding: var(--space-1);
  font-size: 0.75rem;
  white-space: nowrap;
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
  border-top: 1px solid var(--color-border);
}

/* One day. A line marks the start of each module: one module every 10 of the 79 rows. */
.tt-day {
  position: relative;
  border-left: 1px solid var(--color-border);
  background-image: repeating-linear-gradient(
    to bottom,
    var(--color-border) 0,
    var(--color-border) 1px,
    transparent 1px,
    transparent calc(100% * 10 / 79)
  );
}

/* Exam session (D-027): hourly rows, 08:00 to 22:00. 84 rows, a line every 6 of them. */
.tt-grid--hourly {
  grid-template-rows: auto repeat(84, 0.75rem);
}

.tt-grid--hourly .tt-day {
  background-image: repeating-linear-gradient(
    to bottom,
    var(--color-border) 0,
    var(--color-border) 1px,
    transparent 1px,
    transparent calc(100% * 6 / 84)
  );
}

/* A holiday day (D-027). A one-off activity on that day is drawn over the label. */
.tt-off {
  display: block;
  padding: var(--space-2) var(--space-1);
  color: var(--color-muted);
  font-size: var(--text-sm);
  text-align: center;
}

/* ---------- Activity blocks ---------- */

.tt-block {
  position: absolute;
  box-sizing: border-box;
  display: grid;
  align-content: start;
  gap: 0;
  margin: 0;
  padding: 2px var(--space-1);
  overflow: hidden;
  border: 0;
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-sm);
  background: var(--color-info-bg);
  color: var(--color-info-text);
  font: inherit;
  font-size: 0.75rem;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}

.tt-block strong {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.8125rem;
}

.tt-block span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  opacity: 0.9;
}

.tt-block:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 1px;
}

/* Didactic activities (courses, seminars, labs) share one colour; the block text names the kind. */
.tt-block--course,
.tt-block--seminar,
.tt-block--lab {
  background: var(--color-info-bg);
  color: var(--color-info-text);
  border-left-color: var(--color-info-text);
}

/* An approved room booking: a tinted block with a full accent outline, so its right edge is not lost in the grid lines. */
.tt-block--booking {
  background: var(--color-slot-hover-bg);
  color: var(--color-text);
  border: 1px solid var(--color-accent);
  border-left-width: 4px;
}

.tt-block--other {
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
  border-left-color: var(--color-danger-text);
}

/* ---------- Details dialog ---------- */

.tt-dialog {
  width: min(28rem, calc(100% - 2rem));
  padding: var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
}

.tt-dialog::backdrop {
  background: rgb(0 0 0 / 0.4);
}

.tt-dialog dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-2) var(--space-4);
  margin: var(--space-3) 0;
}

.tt-dialog dt {
  color: var(--color-muted);
}

.tt-dialog dd {
  margin: 0;
}

/* ---------- Room description (above the timetable, room view only) ---------- */

.tt-room {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-2) var(--space-4);
  margin: 0 0 var(--space-3);
}

.tt-room[hidden] {
  display: none;
}

.tt-room dt {
  color: var(--color-muted);
}

.tt-room dd {
  margin: 0;
}

/* ---------- Legend and scroll wrapper ---------- */

.legend {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.legend__swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: var(--space-1);
  vertical-align: -1px;
}

/* Scrollable wrapper around the timetable grid, with no frame of its own. */
.tt-scroll {
  overflow-x: auto;
  background: transparent;
  border: 0;
}

/* Legend swatches: the same colour as the edge of the blocks they stand for. */
.legend__swatch--didactic {
  background: var(--color-info-text);
}
.legend__swatch--exam {
  background: var(--color-danger-text);
}
.legend__swatch--booking {
  background: var(--color-accent);
}

/* A free module of a bookable room in the room view. Clean at rest: a faint plus. On hover or focus
   it gets a soft tint and border, and the "+ Book" label. A past module is blank and cannot be clicked. */
.tt-free {
  position: absolute;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-primary);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition:
    background-color 150ms ease,
    border-color 150ms ease;
}

.tt-free__plus,
.tt-free__label {
  transition: opacity 150ms ease;
}

.tt-free__plus {
  font-size: var(--text-lg);
  color: var(--color-slot-icon);
}

.tt-free__label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  white-space: nowrap;
}

.tt-free:not(.tt-free--past):hover,
.tt-free:not(.tt-free--past):focus-visible {
  background: var(--color-slot-hover-bg);
  border-color: var(--color-slot-hover-border);
}

.tt-free:not(.tt-free--past):hover .tt-free__plus,
.tt-free:not(.tt-free--past):focus-visible .tt-free__plus {
  opacity: 0;
}

.tt-free:not(.tt-free--past):hover .tt-free__label,
.tt-free:not(.tt-free--past):focus-visible .tt-free__label {
  opacity: 1;
}

.tt-free:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 1px;
}

.tt-free--past {
  cursor: default;
  background: var(--color-border);
  opacity: 0.35;
}

.tt-hint {
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm);
}

/* Move Activity dialog (DS-unispace-timetable-move). Tokens only. */
.mv-dialog {
  width: min(100% - var(--space-5), 40rem);
}
.mv-modules {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}
.mv-module {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  min-height: 44px;
  text-align: left;
}
.mv-module small {
  color: var(--color-muted);
  font-size: var(--text-sm);
}
.mv-module[aria-pressed="true"] {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}
.mv-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: flex-end;
  margin-top: var(--space-5);
}
.mv-steps {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
@media (max-width: 639px) {
  .mv-modules {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* The step pills: the current step is filled, the others are outlined. */
.mv-steps .pill {
  background: transparent;
  color: var(--color-muted);
  box-shadow: inset 0 0 0 1px var(--color-border);
}
.mv-steps .pill--info {
  background: var(--color-info-bg);
  color: var(--color-info-text);
  box-shadow: none;
}
