/*
 * django-timetable — structural styles for the programme, detail page and
 * "now & next" widget. Sites theme it by setting these custom properties:
 *   --tt-accent  --tt-surface  --tt-border  --tt-muted  --tt-text
 *   --tt-slot-h (height of one grid slot)  --tt-col-min (min column width)
 * Every item also gets --tt-cat (its category colour) inline.
 */

.tt-programme,
.tt-detail,
.tt-now-next {
  --_accent: var(--tt-accent, #0d6efd);
  --_surface: var(--tt-surface, #fff);
  --_border: var(--tt-border, #dee2e6);
  --_muted: var(--tt-muted, #6c757d);
  --_text: var(--tt-text, #212529);
  --_slot-h: var(--tt-slot-h, 1.6rem);
  --_col-min: var(--tt-col-min, 9.5rem);
  color: var(--_text);
}

/* ---- Toolbar ---------------------------------------------------------- */

.tt-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

.tt-search {
  flex: 1 1 14rem;
  min-width: 0;
}

.tt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex-basis: 100%;
}

.tt-chip {
  border: 2px solid var(--tt-cat);
  background: var(--_surface);
  color: var(--_text);
  border-radius: 999px;
  padding: 0.15rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
}

.tt-chip[aria-pressed="true"] {
  background: var(--tt-cat);
}

.tt-view-toggle .btn[aria-pressed="true"] {
  background: var(--_accent);
  border-color: var(--_accent);
  color: #fff;
}

.tt-no-results {
  color: var(--_muted);
  padding: 1rem 0;
}

/* ---- View switching: list on phones by default, JS picks grid on wide screens */

[data-tt-view="list"] .tt-grid-view,
[data-tt-view="grid"] .tt-list-view {
  display: none;
}

[data-tt-searching] .tt-grid-view .tt-block:not(.is-match) {
  opacity: 0.25;
}

[hidden] {
  display: none !important;
}

/* ---- Grid ------------------------------------------------------------- */

.tt-day {
  margin-bottom: 2rem;
}

.tt-grid-view {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--_border);
  border-radius: 0.5rem;
  background: var(--_surface);
}

.tt-grid {
  display: grid;
  grid-template-columns: 3.5rem repeat(var(--tt-cols), minmax(var(--_col-min), 1fr));
  grid-template-rows: auto calc(var(--_slot-h) * var(--tt-slots));
  min-width: min-content;
}

.tt-grid__corner,
.tt-grid__times {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--_surface);
}

.tt-grid__head {
  padding: 0.5rem;
  font-weight: 700;
  border-bottom: 1px solid var(--_border);
  border-left: 1px solid var(--_border);
  line-height: 1.2;
}

.tt-grid__head small {
  display: block;
  font-weight: 400;
  color: var(--_muted);
}

.tt-grid__times {
  position: sticky;
  height: 100%;
}

.tt-grid__time {
  position: absolute;
  top: calc(var(--_slot-h) * var(--tt-row));
  right: 0.4rem;
  transform: translateY(-0.1rem);
  font-size: 0.75rem;
  color: var(--_muted);
}

.tt-grid__time.is-hour {
  font-weight: 700;
  color: var(--_text);
}

.tt-grid__col {
  position: relative;
  border-left: 1px solid var(--_border);
  /* hour lines every 4 slots (15 min slots) */
  background-image: repeating-linear-gradient(
    to bottom,
    var(--_border) 0 1px,
    transparent 1px calc(var(--_slot-h) * 2)
  );
}

.tt-block {
  position: absolute;
  top: calc(var(--_slot-h) * var(--tt-row));
  height: calc(var(--_slot-h) * var(--tt-span) - 2px);
  left: calc(var(--tt-left) + 2px);
  width: calc(var(--tt-width) - 4px);
  margin-top: 1px;
  overflow: hidden;
  padding: 0.2rem 0.4rem;
  border-radius: 0.35rem;
  border-left: 4px solid var(--tt-cat);
  background: color-mix(in srgb, var(--tt-cat) 22%, var(--_surface));
  color: var(--_text);
  text-decoration: none;
  font-size: 0.8rem;
  line-height: 1.2;
  transition: opacity 0.15s;
}

.tt-block:hover,
.tt-block:focus-visible {
  z-index: 3;
  height: auto;
  min-height: calc(var(--_slot-h) * var(--tt-span) - 2px);
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.2);
}

.tt-block__time {
  display: block;
  font-size: 0.7rem;
  color: var(--_muted);
}

.tt-block__title {
  font-weight: 700;
}

/* ---- List items (list view, all-day list, widget) ---------------------- */

.tt-hour__title,
.tt-floor__title {
  font-size: 1.1rem;
  margin: 1.25rem 0 0.5rem;
}

.tt-list {
  margin: 0;
}

.tt-item {
  display: flex;
  align-items: stretch;
  gap: 0.25rem;
  margin-bottom: 0.4rem;
  border-left: 5px solid var(--tt-cat);
  border-radius: 0.4rem;
  background: var(--_surface);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}

.tt-item__link {
  display: flex;
  flex: 1;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.tt-item__time {
  flex: 0 0 auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 3rem;
}

.tt-item__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tt-item__title {
  font-weight: 700;
}

.tt-item__meta,
.tt-item__teaser {
  font-size: 0.85rem;
  color: var(--_muted);
}

.tt-map-btn {
  flex: 0 0 auto;
  border: 0;
  border-left: 1px solid var(--_border);
  background: transparent;
  padding: 0 0.85rem;
  font-size: 1.1rem;
  border-radius: 0 0.4rem 0.4rem 0;
}

.tt-map-btn:hover {
  background: color-mix(in srgb, var(--_accent) 12%, transparent);
}

/* ---- All-day list ------------------------------------------------------ */

.tt-allday {
  margin-top: 2rem;
}

.tt-locations {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 1rem;
}

.tt-location__title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.tt-allday .tt-item__time {
  display: none;
}

/* ---- Floor plan -------------------------------------------------------- */

.tt-map {
  margin: 1rem 0;
}

.tt-map__plan {
  position: relative;
  line-height: 0;
}

.tt-map__plan img {
  width: 100%;
  height: auto;
  border-radius: 0.4rem;
  border: 1px solid var(--_border);
}

.tt-map__marker {
  position: absolute;
  width: 1.4rem;
  height: 1.4rem;
  margin: -0.7rem 0 0 -0.7rem;
  border-radius: 50%;
  background: var(--_accent);
  border: 3px solid #fff;
  box-shadow: 0 0 0 0 var(--_accent);
  animation: tt-pulse 1.6s infinite;
}

@keyframes tt-pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--_accent) 70%, transparent);
  }
  100% {
    box-shadow: 0 0 0 1.2rem transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tt-map__marker {
    animation: none;
  }
}

.tt-map__caption {
  margin-top: 0.4rem;
  font-weight: 700;
  text-align: center;
}

.tt-map-dialog {
  width: min(42rem, calc(100vw - 2rem));
  padding: 1rem;
  border: 0;
  border-radius: 0.75rem;
  background: var(--_surface);
}

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

.tt-map-dialog__close {
  display: flex;
  justify-content: flex-end;
}

/* ---- Detail ------------------------------------------------------------ */

.tt-detail {
  padding: 1rem 0 2rem;
}

.tt-detail__back {
  display: inline-block;
  margin-bottom: 1rem;
}

.tt-badge {
  display: inline-block;
  padding: 0.1rem 0.7rem;
  border-radius: 999px;
  background: var(--tt-cat);
  font-size: 0.85rem;
  font-weight: 700;
}

.tt-detail__performer {
  color: var(--_muted);
  font-size: 1.1rem;
}

.tt-detail__image {
  max-width: 100%;
  border-radius: 0.5rem;
  margin: 1rem 0;
}

.tt-detail__when {
  padding: 1rem;
  border-radius: 0.5rem;
  background: var(--_surface);
  border: 1px solid var(--_border);
}

.tt-detail__slot + .tt-detail__slot {
  margin-top: 0.75rem;
}

/* ---- Widget ------------------------------------------------------------ */

.tt-now-next__heading {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0.75rem 0 0.4rem;
}
