/* The changelog: a line of track down the page, read like a railroad map. Each day is a station, a bar across the
   line; each version is a lamp on it, lit in its product's colour (RailroaderHub pink, RailCom Pro amber, Holiday
   Lights green), brighter while it's the one running now. Everything else stays quiet. */

[data-product="railroaderhub"] {
  --product: var(--pink);
  --product-ink: #ff74b1;
}

[data-product="railcom"] {
  --product: var(--amber);
  --product-ink: var(--amber);
}

[data-product="holiday-lights"] {
  --product: var(--green);
  --product-ink: var(--green);
}

.cl-page {
  padding: clamp(36px, 7vw, 84px) 0 24px;
}

.cl-head h1 {
  font: 800 clamp(46px, 7.4vw, 88px) / 0.95 var(--display);
  font-stretch: 82%;
  letter-spacing: -0.02em;
}

.cl-lead {
  max-width: 34em;
  margin-top: 18px;
  color: var(--haze);
  font-size: clamp(18px, 2vw, 21px);
  line-height: 1.5;
}

.cl-tally {
  margin-top: 6px;
  color: var(--dim);
  font-size: 15.5px;
}

.cl-lamp {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--product, var(--haze));
  box-shadow: 0 0 10px color-mix(in srgb, var(--product, var(--haze)) 70%, transparent);
}

/* ------------------------------------------------------------ running now */

.cl-now {
  margin-top: clamp(26px, 4vw, 40px);
}

.cl-now-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
}

.cl-now-item {
  min-width: 0;
  padding: 20px 24px 22px;
}

.cl-now-item + .cl-now-item {
  border-left: 1px solid var(--line);
}

.cl-now-name {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--haze);
  font-size: 15px;
  font-weight: 650;
}

.cl-now-name a {
  color: inherit;
  text-decoration: none;
}

.cl-now-name a:hover {
  color: var(--moon);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.cl-now-version {
  margin-top: 8px;
  font: 780 clamp(32px, 3.4vw, 42px) / 1 var(--display);
  font-stretch: 84%;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.cl-now-line {
  margin-top: 8px;
  color: var(--dim);
  font-size: 14.5px;
  line-height: 1.4;
}

.cl-now-line + .cl-now-line {
  margin-top: 2px;
}

/* ------------------------------------------------------------ which updates */

.cl-bar {
  position: sticky;
  top: var(--nav-h);
  z-index: 30;
  margin-top: clamp(28px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  background: rgba(20, 12, 46, 0.88);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
}

.cl-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 12px 0;
}

.cl-tabs {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(246, 241, 255, 0.03);
}

.cl-tabs button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--haze);
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
}

.cl-tabs button:hover {
  color: var(--moon);
}

.cl-tabs button[aria-checked="true"] {
  background: rgba(246, 241, 255, 0.94);
  color: var(--night);
}

.cl-tabs button:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.cl-tabs .cl-lamp {
  width: 8px;
  height: 8px;
}

.cl-search {
  position: relative;
  flex: 1 1 240px;
  max-width: 360px;
  margin-left: auto;
}

.cl-search svg {
  position: absolute;
  top: 50%;
  left: 15px;
  width: 18px;
  height: 18px;
  color: var(--dim);
  transform: translateY(-50%);
  pointer-events: none;
}

.cl-search .input {
  min-height: 44px;
  padding-left: 42px;
  border-radius: 999px;
}

/* ------------------------------------------------------------ the line */

.cl-body {
  padding-top: 18px;
}

.cl-status {
  color: var(--dim);
  font-size: 14.5px;
}

.cl-line {
  --track-x: 30px;
  --indent: 78px;
  --rail: rgba(196, 176, 255, 0.4);
  --tie: rgba(196, 176, 255, 0.13);
  position: relative;
  padding: 4px 0 40px var(--indent);
}

/* Two rails on their ties, fading in at the top and out at the bottom. */
.cl-line::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--track-x) - 12px);
  width: 24px;
  background:
    linear-gradient(90deg, transparent 4px, var(--rail) 4px 6px, transparent 6px 18px, var(--rail) 18px 20px, transparent 20px),
    repeating-linear-gradient(180deg, var(--tie) 0 4px, transparent 4px 13px);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 36px, #000 calc(100% - 96px), transparent);
  mask-image: linear-gradient(180deg, transparent, #000 36px, #000 calc(100% - 96px), transparent);
  pointer-events: none;
}

.cl-day {
  margin-top: 64px;
}

.cl-day:first-child {
  margin-top: 30px;
}

.cl-day-title {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 16px;
  font: 760 clamp(24px, 2.7vw, 31px) / 1.15 var(--display);
  font-stretch: 86%;
}

/* The station: a bar across the track. */
.cl-day-title::before {
  content: "";
  position: absolute;
  top: calc(0.575em - 4px);
  left: calc(var(--track-x) - var(--indent) - 20px);
  width: 40px;
  height: 8px;
  border-radius: 4px;
  background: var(--moon);
  box-shadow: 0 0 0 5px var(--night);
}

.cl-day-count {
  color: var(--dim);
  font: 600 14.5px / 1.2 var(--text);
  white-space: nowrap;
}

.cl-day-note {
  margin-top: 4px;
  color: var(--dim);
  font-size: 15px;
}

.cl-day-list {
  display: grid;
  gap: 34px;
  margin-top: 24px;
}

.cl-entry {
  position: relative;
  isolation: isolate;
  scroll-margin-top: calc(var(--nav-h) + 96px);
}

.cl-entry > .cl-lamp {
  position: absolute;
  top: 28px;
  left: calc(var(--track-x) - var(--indent) - 8px);
  width: 16px;
  height: 16px;
  box-shadow: 0 0 0 5px var(--night), 0 0 18px 2px color-mix(in srgb, var(--product) 55%, transparent);
}

/* The version running now: lit, with a ring round it like a signal lamp. */
.cl-entry[data-live] > .cl-lamp {
  box-shadow: 0 0 0 5px var(--night), 0 0 0 8px color-mix(in srgb, var(--product) 45%, transparent), 0 0 26px 6px color-mix(in srgb, var(--product) 60%, transparent);
}

/* A link to this version brought you here. */
.cl-entry[data-linked]::after,
.cl-entry:target::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -14px -18px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: rgba(246, 241, 255, 0.04);
}

.cl-entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 14px;
}

.cl-entry h3 a {
  display: grid;
  color: inherit;
  text-decoration: none;
}

.cl-product {
  color: var(--product-ink);
  font: 700 14.5px / 1.35 var(--text);
}

.cl-version {
  font: 780 clamp(28px, 3vw, 34px) / 1.08 var(--display);
  font-stretch: 84%;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.cl-entry h3 a:hover .cl-version {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.cl-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.cl-tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--haze);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.cl-tag-live {
  border-color: color-mix(in srgb, var(--product) 55%, transparent);
  background: color-mix(in srgb, var(--product) 12%, transparent);
  color: var(--product-ink);
}

.cl-notes {
  max-width: 70ch;
  margin-top: 12px;
  color: var(--haze);
  line-height: 1.6;
}

.cl-notes p + p {
  margin-top: 10px;
}

.cl-notes b {
  color: var(--moon);
  font-weight: 720;
}

.cl-notes mark,
.cl-version mark {
  padding: 0 2px;
  border-radius: 3px;
  background: rgba(255, 195, 92, 0.3);
  color: var(--moon);
}

/* One product at a time: its name on every version would only repeat the filter (screen readers still hear it). */
.cl-line[data-one] .cl-product {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.cl-line[data-one] .cl-entry > .cl-lamp {
  top: 9px;
}

/* Wide screens: the versions in a column of their own, like the times in a timetable, the notes beside them. */
@media (min-width: 1000px) {
  .cl-entry {
    display: grid;
    grid-template-columns: 200px minmax(0, 70ch);
    column-gap: 44px;
    max-width: calc(244px + 70ch);
  }

  .cl-entry-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .cl-tags {
    margin-bottom: 0;
  }

  .cl-notes {
    margin-top: 0;
    padding-top: 2px;
  }
}

.cl-empty {
  margin-top: 40px;
}

.cl-empty p {
  color: var(--haze);
  font-size: 18px;
}

.cl-empty .button {
  margin-top: 16px;
}

/* ------------------------------------------------------------ narrow screens */

@media (max-width: 860px) {
  .cl-now-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .cl-now-item + .cl-now-item {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .cl-now-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 2px 16px;
    padding: 16px 20px;
  }

  .cl-now-version {
    grid-row: 1 / span 3;
    grid-column: 2;
    margin-top: 0;
    font-size: 32px;
  }

  .cl-now-line {
    grid-column: 1;
    margin-top: 2px;
  }
}

@media (max-width: 900px) {
  .cl-search {
    flex-basis: 100%;
    max-width: none;
    margin-left: 0;
  }
}

@media (max-width: 760px) {
  .cl-bar {
    position: static;
  }

  .cl-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    border-radius: 24px;
  }

  .cl-line {
    --track-x: 13px;
    --indent: 44px;
  }

  .cl-day-title::before {
    width: 30px;
    left: calc(var(--track-x) - var(--indent) - 15px);
  }

  .cl-entry {
    scroll-margin-top: calc(var(--nav-h) + 16px);
  }

  .cl-entry > .cl-lamp {
    top: 27px;
    width: 14px;
    height: 14px;
    left: calc(var(--track-x) - var(--indent) - 7px);
  }

  .cl-line[data-one] .cl-entry > .cl-lamp {
    top: 9px;
  }

  .cl-entry[data-linked]::after,
  .cl-entry:target::after {
    inset: -10px -10px -12px -12px;
  }
}
