/* ── Desktop / Bootstrap col context ───────────────────────────────────────
   The timeline lives inside .col-md-8 > .col-md-12 on the project page.
   At Bootstrap's largest container (1300px + 40px padding each side = 1220px
   usable), col-md-8 gives ~810px. We size variables to fit that column.
   ─────────────────────────────────────────────────────────────────────────── */
.tl-scroll {
  width: 100%;
  overflow-x: auto; /* hard clip — prevents bleed past Bootstrap column */
}

.tl {
  --fitW: min(100%, 840px);
  --labelW: 160px;
  --yearW: calc((var(--fitW) - var(--labelW)) / var(--years));
  --rowH: 70px;
  --blue: #0e8dc9;
  --grid: #d0d0d0;
  --dash: #7a7a7a;
  --sub: #666;

  display: block;       /* block so width: 100% works correctly */
  width: var(--fitW);
  max-width: 100%;
  margin-inline: auto;
  box-sizing: border-box;
  font-family: Arial, sans-serif;
  color: #000;
  background: #fff;
}

.tl * {
  box-sizing: border-box;
}

/* ── Mobile (below Bootstrap md = 768px): enable horizontal scroll ──────── */
@media (max-width: 767.98px) {
  .tl-scroll {
    overflow-x: scroll;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
  }

  .tl {
    --yearW: 100px!important;
    --labelW: 220px!important;
    display: inline-block; /* shrink-wrap to content width so scroll works */
    width: max-content;
    min-width: 760px;      /* minimum "full timeline" width before scrolling */
    /* max-width: none; */
    /* overflow-x: scroll; */
  }

  .tl-row {
    overflow: hidden;
  }

  .tl-track {
    overflow: hidden;
  }
}

.tl-header {
  display: inline-grid;
  grid-template-columns: var(--labelW) calc(var(--years) * var(--yearW));
  align-items: center;
  border-bottom: 3px solid var(--blue);
  padding-bottom: 8px;
}

.tl-title {
  font-weight: 700;
  font-size: 22px;
  color: #005a96;
  padding: 0 12px 0 20px;
  line-height: 1.1;
  white-space: nowrap;
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 10;    
}

.tl-years {
  position: relative;
  height: 28px;
}

.tl-year {
  position: absolute;
  top: 0;
  left: calc(var(--i) * var(--yearW));
  font-size: 14px;
  padding-left: 6px;
  white-space: nowrap;
  transform: translateX(-50%); /* nudge left so year is more centered in grid column */
}

.tl-row {
  position: relative;
  display: inline-grid;
  grid-template-columns: var(--labelW) calc(var(--years) * var(--yearW));
  min-height: var(--rowH);
}

.tl-label {
  position: relative;
  z-index: 2;
  padding: 12px 8px 8px 10px;
  border-right: 1px solid #3a3a3a;
  background: transparent;
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 10;
  width: var(--labelW);
  max-width: var(--labelW);
}

.tl-label-main {
  font-size: 14px;
  line-height: 1.15;
  white-space: pre-line;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
}

.tl-label-dates {
  margin-top: 4px;
  font-size: 12px;
  color: var(--sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tl-track {
  position: relative;
  z-index: 2;
  width: calc(var(--years) * var(--yearW));
  min-height: var(--rowH);
  background-image:
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc(var(--yearW) - 1px),
      var(--grid) calc(var(--yearW) - 1px),
      var(--grid) var(--yearW)
    );
}

.tl-track::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    background-image: repeating-linear-gradient(to right, transparent 0 4px, var(--dash) 4px 8px);
    height: 1px;
    transform: translateY(-50%);
}

.tl-baseline-row {
  position: absolute;
  top: 50%;
  height: 1px;
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 1;
  background-image: repeating-linear-gradient(
    to right,
    transparent 0 4px,
    var(--dash) 4px 8px
  );
}

.tl-bar {
  position: absolute;
  top: 50%;
  height: 8px;
  transform: translateY(-50%);
  background: var(--blue);
  border-radius: 4px;
  z-index: 3;
}

.tl-dot {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--blue);
  z-index: 4;
}

.tl-footer {
  display: grid;
  grid-template-columns: var(--labelW) calc(var(--years) * var(--yearW));
  margin-top: 6px;
  padding-bottom: 4px;
}

.tl-disclaimer {
  grid-column: 2 / 3;
  text-align: right;
  font-size: 12px;
  color: var(--sub);
  font-style: italic;
  padding-right: 6px;
  white-space: nowrap;
}
