/*
 * chess-days-timeline.css — the programme overview strip at the top of
 * #schedule on /chess-days/ (markup: _includes/partials/chess-strands.njk,
 * data: _data/chessStrandsData.json). Linked inline from the page body.
 *
 * The schedule below is day-first, which splits each strand across the days
 * it touches. This is the time-first view of the same programme: the nine
 * days run across the top and each strand gets one bar over the days it
 * actually occupies. No JavaScript — placement is pure CSS grid, driven by
 * an inline grid-column on each bar.
 *
 * Below 768px the grid collapses: the track becomes a block, each bar goes
 * full width and the date label (.cd-tl-when) appears beside the strand name.
 *
 * Reuses the site design tokens (--heading-color, --accent-color,
 * --surface-color, --contrast-color, --heading-font, --header-height).
 */

.cd-tl {
  max-width: 1100px;
  margin: 0 auto 42px;
}

/* --- Head: the nine day columns ------------------------------------------ */
/* The label column is sized for the longest strand name PLUS the registration
   badge — too narrow and that one row wraps to two lines and stands taller
   than its neighbours, which breaks the strip's horizontal read. */
.cd-tl-head,
.cd-tl-row {
  display: grid;
  grid-template-columns: 225px 1fr;
  align-items: center;
  gap: 16px;
}
.cd-tl-head {
  padding-bottom: 8px;
}
.cd-tl-track {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 6px;
  align-items: center;
}
.cd-tl-day {
  text-align: center;
  font-family: var(--heading-font);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.15;
  color: var(--heading-color);
  padding: 6px 0;
  border-radius: 10px;
}
.cd-tl-day b {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  opacity: 0.55;
}
.cd-tl-day.is-weekend {
  background: color-mix(in srgb, var(--accent-color), transparent 90%);
  color: var(--accent-color);
}

/* --- Rows ----------------------------------------------------------------- */
/* The row is a plain container: the strand name and each bar are their own
   links (a multi-segment strand points at more than one day), so the tint
   stays on the row while the focus ring belongs to whichever link has focus. */
.cd-tl-row {
  padding: 7px 0;
  border-radius: 10px;
  color: inherit;
  transition: background 0.2s ease;
}
.cd-tl-row + .cd-tl-row {
  border-top: 1px solid color-mix(in srgb, var(--heading-color), transparent 92%);
}
.cd-tl-row:hover {
  background: color-mix(in srgb, var(--accent-color), transparent 95%);
}
.cd-tl-label,
.cd-tl-bar {
  text-decoration: none;
}
.cd-tl-label:focus-visible,
.cd-tl-bar:focus-visible {
  outline: none;
  border-radius: 10px;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-color), transparent 55%);
}
.cd-tl-label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--heading-color);
}
.cd-tl-label i {
  flex: 0 0 auto;
  width: 18px;
  text-align: center;
  color: var(--accent-color);
}
.cd-tl-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* The bar. min-width:0 matters: a grid item defaults to min-width:auto and
   would overflow its day column, making a one-day strand look like it spans
   several. Long text is clipped instead — the full wording is the link's
   title, and the schedule below always carries it in full. */
.cd-tl-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: color-mix(in srgb, var(--accent-color), transparent 86%);
  color: color-mix(in srgb, var(--accent-color), black 18%);
}
.cd-tl-bar.is-main {
  height: 40px;
  font-size: 13px;
  background: var(--accent-color);
  color: var(--contrast-color, #fff);
}
.cd-tl-bar:hover {
  background: color-mix(in srgb, var(--accent-color), transparent 76%);
}
.cd-tl-bar.is-main:hover {
  background: color-mix(in srgb, var(--accent-color), black 10%);
}

/* Registration badge on the strand that takes entries — main.js hides it
   (data-participate-only-open) once the window closes. */
.cd-tl-badge {
  flex: 0 0 auto;
  margin-left: 7px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--accent-color);
  color: var(--contrast-color, #fff);
}

/* Full date label — desktop keeps it for assistive tech only, the phone
   layout below promotes it to visible text. */
.cd-tl-when {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Narrow desktops: a one-day bar is ~45px there, which an asterisk alone can
   push past the column. Buy the few pixels back from the bar's own padding
   rather than from the text — a clipped time reads as a wrong time. */
@media (min-width: 768px) and (max-width: 991.98px) {
  .cd-tl-bar {
    padding: 0 4px;
  }
}

/* Anchor targets: the day tiles are the timeline's jump destinations, so keep
   them clear of the fixed header. */
.schedule-flat .schedule-day {
  scroll-margin-top: calc(var(--header-height, 120px) + 14px);
}

/* --- Phones: the grid collapses to a list -------------------------------- */
@media (max-width: 767.98px) {
  .cd-tl {
    margin-bottom: 32px;
  }
  .cd-tl-head {
    display: none;
  }
  .cd-tl-row {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 12px 0;
  }
  .cd-tl-track {
    display: block;
  }
  .cd-tl-bar {
    height: 30px;
    justify-content: flex-start;
    font-size: 12px;
    padding: 0 12px;
  }
  /* A multi-segment strand (bars[]) stacks its bars here — the grid gap that
     separates them on desktop is gone once the track is a block. */
  .cd-tl-bar + .cd-tl-bar {
    margin-top: 6px;
  }
  .cd-tl-when {
    position: static;
    width: auto;
    height: auto;
    margin: 0 0 0 auto;
    clip-path: none;
    font-family: var(--heading-font);
    font-size: 12px;
    font-weight: 800;
    color: var(--accent-color);
  }
}
