/* Scroll Progress Indicator */
.scroll-progress {
  --progress-height: 60vh;
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  left: 0;
  z-index: 1;
  background: var(--baseColorOpacity30);
  padding: var(--spacing);
  border-radius: 0 var(--spacing) var(--spacing) 0;
  border: 1px solid var(--baseColor);
  border-width: 1px 1px 1px 0;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  backdrop-filter: blur(1px);
}

.scroll-progress.visible.scrolling {
  opacity: 1; /* Full opacity when actively scrolling */
  transition: opacity 250ms 0 ease; /* Faster fade-in when scrolling starts */
}

.scroll-progress__track {
  width: 4px;
  height: var(--progress-height);
  background: rgba(var(--fadeBrandColor-rgb, 0, 0, 0), 0.2);
  border-radius: 2px;
  position: relative;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.scroll-progress__thumb {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  background: var(--darkColor);
  border-radius: 2px;
  transition: height 0.1s ease-out;
  min-height: 8px;
}

.scroll-progress__markers {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.scroll-progress__marker {
  position: absolute;
  left: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--baseColor);
  border: 2px solid var(--bodyColor);
  transform: translateY(-50%);
  transition: all 0.2s ease;
}

.scroll-progress__marker--milestone {
  background: var(--fadeAccentColor);
  border-color: var(--accentColor);
}

.scroll-progress__marker--active {
  background: var(--accentColor);
  border-color: var(--accentColor);
  transform: translateY(-50%) scale(1.3);
  box-shadow: 0 0 0 2px var(--baseColor);
}

@media screen and (max-width: 768px) {
  .scroll-progress {
    display: none;
  }
}

.timeline {
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute;
  top: 0;
  width: 50%;
  display: block;
  height: 100%;
  border-right: 1px solid var(--fadeBaseColor);
}
.history-listout {
  position: relative;
  padding-top: 8rem;
  padding-bottom: 12rem;
  padding-left: 0 !important;
  margin-top: max(5rem, 5vh);
  margin-bottom: max(2rem, 5vh);
}
.history-listout::before {
  position: absolute;
  content: "Today";
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  background: var(--baseColor);
  padding: 0.5rem 1rem;
  border: 1px solid var(--fadeBaseColor);
  border-radius: var(--text-size-1);
  font-size: var(--text-size-1);
  color: var(--fadeBaseColor);
  z-index: 1;
  transition: all 0.3s ease;
}

/* Active state for "Today" label - styled like active year markers */
.history-listout.active-today::before {
  background: var(--darkColor);
  color: var(--baseColor);
  border-color: var(--darkColor);
  transform: translateX(-50%) scale(1.1);
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
/* Note: .history-listout::after background image is set inline in the template */
.history-listout::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 100px;
  background-size: cover;
  display: block;
}
.history-item {
  list-style: none;
  position: relative;
}
.history-item[data-show-year]::after,
.history-item:first-child::before {
  content: attr(data-year);
  position: absolute;
  bottom: -3.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--baseColor);
  padding: 0.5rem 1rem;
  border: 1px solid var(--fadeBaseColor);
  border-radius: var(--text-size-1);
  font-size: var(--text-size-1);
  color: var(--fadeBaseColor);
  z-index: 1;
  transition: all 0.3s ease;
}

/* CSS Scroll-driven Animation (modern browsers) */
@supports (animation-timeline: scroll()) {
  .history-item[data-show-year] {
    animation: highlight-year linear;
    animation-timeline: scroll();
    animation-range: entry 20% exit 20%;
  }

  @keyframes highlight-year {
    0%, 100% {
      --year-bg: var(--baseColor);
      --year-color: var(--fadeBaseColor);
      --year-border: var(--fadeBaseColor);
      --year-scale: 1;
      --year-shadow: 0 0 0 rgba(0,0,0,0);
    }
    50% {
      --year-bg: var(--fadeBaseColor);
      --year-color: var(--baseColor);
      --year-border: var(--fadeBaseColor);
      --year-scale: 1.1;
      --year-shadow: 0 4px 15px rgba(0,0,0,0.2);
    }
  }

  .history-item[data-show-year]::after {
    background: var(--year-bg, var(--baseColor));
    color: var(--year-color, var(--darkColor));
    border-color: var(--year-border, var(--fadeBaseColor));
    transform: translateX(-50%) scale(var(--year-scale, 1));
    box-shadow: var(--year-shadow, 0 0 0 rgba(0,0,0,0));
  }
}

/* Fallback for browsers without scroll-driven animation support */
.history-item[data-show-year].active-year::after {
  background: var(--darkColor) !important;
  color: var(--baseColor) !important;
  border-color: var(--darkColor) !important;
  transform: translateX(-50%) scale(1.1) !important;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2) !important;
}
.history-item + .history-item {
  margin-top: 8rem;
}
.history-item__content {
  background: var(--baseColor);
  display: flex;
  flex-direction: column;
  gap: var(--spacing);
}
.history-item__flag {
  position: relative;
  margin-top: -3rem;
  padding: calc(var(--spacing) / 3);
  outline: 1px solid var(--fadeBaseColor);
  border: 2px solid var(--baseColor);
  background: var(--accentColor);
  border-radius: 3rem;
  width: var(--text-size-2);
  height: var(--text-size-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.history-item--history-milestone {
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}
.history-item--history-milestone .history-item__content {
  padding: var(--spacing) calc(var(--spacing) * 1.5);
  background: var(--fadeAccentColor);
  border: 1px solid var(--fadeBaseColor);
  border-radius: .1rem;
  max-width: min(100%, 20rem);
  margin: 0 auto;
  position: relative;
}
.history-item--history-event .history-item__content {
  padding: var(--spacing) 0;
  position: relative;
  background: var(--baseColor);
  border: 1px solid var(--fadeBaseColor);
  border-width: 1px 0;
  padding: 2rem 0;
}


.history-item__text {
  display: flex;
  flex-direction: column;
  gap: calc(var(--spacing) / 2);
  text-align: left;
}
.history-item--history-milestone .history-item__text {
  align-items: center;
  text-align: center;
}

.history-item__title {
  margin-bottom: 0;
  margin-top: -.3rem;
}
.history-item--history-milestone .history-item__title {
  font-size: var(--text-size-1);
}
.history-item--history-event .history-item__title {
  font-size: var(--text-size-2);
}
.history-item__image img {
  width: 100%;
  height: 15rem;
  object-fit: cover;
}

@media screen and (min-width: 760px) {
  .history-item__image {
    flex: none;
    padding: 0;
    position: relative;
    box-shadow: 0 0.5rem 2.5rem 0 rgba(0, 0, 0, 0.1), 0 1rem 1rem -0.75rem rgba(0, 0, 0, 0.3);
    border-radius: 0.15em;
    background: hsl(230, 100%, 99%);
    z-index: 1;
    position: relative;
    box-sizing: border-box;
  }
  .history-item__image::before {
    position: absolute;
    width: 95%;
    height: 95%;
    border-radius: 0.1rem;
    left: -.25rem;
    top: 1rem;
    background: var(--fadeBrandColor);
    transform: rotate(-5deg);
    content: "";
    z-index: -1;
  }
  .history-item--history-event img {
    height: auto;
    width: 12rem;
    height: 14rem;
    border-radius: 0.1rem;
  }
  .history-item--history-event .history-item__content {
    flex-direction: row;
    align-items: flex-start;
    gap: 2rem;
    padding: 2rem 1rem;
  }
}
@media screen and (min-width: 1024px) {
  .history-item--history-event.odd .history-item__content {
    transform: translateX(calc(-1 * var(--spacing)));
    margin-right: 10vw;
  }
  .history-item--history-event.even .history-item__content {
    transform: translateX(var(--spacing));
    flex-direction: row-reverse;
    margin-left: 10vw;
  }

  @keyframes slideInFromLeft {
    0% {
      opacity: 0;
      transform: translateX(calc(-200px - var(--spacing)));
    }
    20% {
      opacity: 1;
    }
    100% {
      opacity: 1;
      transform: translateX(calc(-1 * var(--spacing)));
    }
  }

  @keyframes slideInFromRight {
    0% {
      opacity: 0;
      transform: translateX(calc(200px + var(--spacing)));
    }
    20% {
      opacity: 1;
    }
    100% {
      opacity: 1;
      transform: translateX(var(--spacing));
    }
  }

  /* Milestone animations */
  @keyframes fadeIn {
    0% {
      transform: scale(0);
      opacity: 0;
    }
    100% {
      transform: scale(1);
      opacity: 1;
    }
  }

  /* Classes applied by JavaScript when items come into view */
  .history-item--history-event.odd .history-item__content.animate-in {
    animation: slideInFromLeft 0.5s ease-out forwards;
  }
  .history-item--history-event.even .history-item__content.animate-in {
    animation: slideInFromRight 0.5s ease-out forwards;
  }
  .history-item--history-milestone.animate-in {
    animation: fadeIn 300ms ease-out forwards;
  }

  /* Initial hidden state for elements that will be animated */
  .history-item--history-event .history-item__content,
  .history-item--history-milestone {
    opacity: 0;
  }
}
