/* Railway Timeline Styles */
:root {
  --railway-primary: #ee3238;
  --railway-secondary: #565656;
  --railway-track: #333;
  --railway-sleeper: #8B4513;
  --railway-cabin: #fff;
  --railway-cabin-border: #004165;
  --railway-cabin-shadow: rgba(0, 0, 0, 0.15);
  --railway-wheel: #333;
  --railway-connector: #555;
  --railway-text: #333;
  --railway-year: #004165;
  --railway-smoke: rgba(220, 220, 220, 0.6);
}

.railway-timeline-container {
  position: relative;
  overflow-x: auto;
  background-color: #FDEBEB;
  padding-top: 60px;
  padding-bottom: 60px;
  min-height: 350px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--railway-cabin-border) #f1f1f1;
  overflow-y: hidden;
  isolation: isolate;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.railway-timeline-title-container {
  background-color: #FDEBEB;
  padding-top: 60px;
}

.railway-timeline-title {
  text-align: center;
  margin-bottom: 60px;
}

.railway-timeline-title h2 {
  font-size: 60px;
  font-weight: 700;
  color: var(--railway-text);
  margin-bottom: 15px;
}

.railway-timeline-title p {
  font-size: 18px;
  color: var(--railway-secondary);
  max-width: 700px;
  margin: 0 auto;

}

/* Railway Track */
.railway-track {
  position: absolute;
  height: 30px;
  bottom: 100px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  width: 180vh; 
  z-index: 1;
  background-color: #e0e0e0;
  border-radius: 0;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  pointer-events: none;
}

.railway-track::before,
.railway-track::after {
  content: "";
  position: absolute;
  height: 8px;
  background-color: var(--railway-track);
  left: 0;
  right: 0;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.railway-track::before {
  top: 0;
}

.railway-track::after {
  bottom: 0;
}

/* Railway Sleepers */
.railway-sleepers {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  padding: 0;
  z-index: 1;
  width: 300%; /* Make it much wider for a more infinite appearance */
  animation: moveSleepers 40s linear infinite;
  pointer-events: none;
}

@keyframes moveSleepers {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-66.66%);
  }
}



.railway-sleeper {
  width: 12px;
  height: 30px;
  background-color: var(--railway-sleeper);
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  margin: 0 10px;
}

/* Railway Train Container */
.railway-train-container {
  position: relative;
  width: 100%;
  min-height: 300px;
  overflow: hidden; /* Hide content that extends beyond the container */
  margin: 0 auto;
}

/* Railway Train */
.railway-train {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  position: relative;
  padding-bottom: 30px; /* Increased to accommodate the track */
  min-width: max-content;
  padding-left: 100px;
  padding-right: 20px;
  z-index: 2;
  width: auto; /* Allow the train to be as wide as needed */
}

/* Railway Cabins */
.railway-cabin {
  position: relative;
  width: 280px;
  height: 280px;
  margin-right: 40px;
  background-color: var(--railway-cabin);
  border: 3px solid var(--railway-cabin-border);
  border-radius: 10px 10px 0 0;
  box-shadow: 0 10px 20px var(--railway-cabin-shadow);
  padding: 20px;
  transition: all 0.3s ease;
  z-index: 2;
  display: flex;
  flex-direction: column;
}

.railway-cabin:hover, .railway-cabin.current-cabin {
  transform: translateY(-10px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
}

.railway-cabin.current-cabin {
  border-color: var(--railway-primary);
}

.railway-cabin::before {
  content: "";
  position: absolute;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 15px;
  background-color: var(--railway-connector);
  border-radius: 0 0 5px 5px;
}

.railway-cabin::after {
  content: "";
  position: absolute;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 15px;
  height: 15px;
  background-color: var(--railway-wheel);
  border-radius: 50%;
  box-shadow: -30px 0 0 var(--railway-wheel), 30px 0 0 var(--railway-wheel);
}

.railway-cabin-year {
  font-size: 22px;
  font-weight: 700;
  color: var(--railway-year);
  margin-bottom: 15px;
  text-align: center;
  border-bottom: 2px solid var(--railway-cabin-border);
  background-color: rgba(0, 65, 101, 0.05);
  border-radius: 5px 5px 0 0;
  padding: 10px;
  position: relative;
}

.railway-cabin-year::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 2px;
  background-color: var(--railway-primary);
}

.railway-cabin-content {
  font-size: 15px;
  line-height: 1.6;
  color: var(--railway-text);
  padding: 5px;
  background-color: rgba(255, 255, 255, 0.7);
  border-radius: 0 0 5px 5px;
  flex: 1;
  overflow-y: auto;
}

/* Engine (First Cabin) */
.railway-engine {
  position: relative;
  width: 320px;
  height: 280px;
  margin-right: 40px;
  background-color: var(--railway-cabin-border);
  border: 3px solid var(--railway-cabin-border);
  border-radius: 10px 10px 0 0;
  box-shadow: 0 10px 20px var(--railway-cabin-shadow);
  padding: 20px;
  transition: all 0.3s ease;
  z-index: 3;
  color: white;
  display: flex;
  flex-direction: column;
}

.railway-engine:hover, .railway-engine.current-cabin {
  transform: translateY(-10px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
}

.railway-engine.current-cabin {
  border-color: var(--railway-primary);
}

.railway-engine::before {
  content: "";
  position: absolute;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 15px;
  background-color: var(--railway-connector);
  border-radius: 0 0 5px 5px;
}

.railway-engine::after {
  content: "";
  position: absolute;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 15px;
  height: 15px;
  background-color: var(--railway-wheel);
  border-radius: 50%;
  box-shadow: -40px 0 0 var(--railway-wheel), 40px 0 0 var(--railway-wheel);
}

.railway-engine-front {
  position: absolute;
  left: -58px;
  top: 0;
  bottom: 0;
  width: 70px;
  background-color: #003050;
  border-radius: 10px 0 0 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 0;
  border: 3px solid var(--railway-cabin-border);
  border-right: none;
}

.railway-engine-light {
  width: 25px;
  height: 25px;
  background-color: #FFD700;
  border-radius: 50%;
  margin: 10px auto;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.9);
  position: relative;
  z-index: 4;
  animation: lightPulse 2s infinite alternate;
}

@keyframes lightPulse {
  0% {
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
  }
  100% {
    box-shadow: 0 0 20px rgba(255, 215, 0, 1);
  }
}

.railway-engine-chimney {
  position: absolute;
  top: -35px;
  left: -20px;
  width: 25px;
  height: 40px;
  background-color: #222;
  border-radius: 5px 5px 0 0;
  border: 2px solid #444;
  border-bottom: none;
  transform: rotate(-5deg);
}

.railway-engine-chimney::before {
  content: "";
  position: absolute;
  top: -15px;
  left: 5px;
  width: 15px;
  height: 10px;
  background-color: var(--railway-smoke);
  border-radius: 50%;
  animation: smokeAnimation 3s infinite;
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.railway-engine-chimney::after {
  content: "";
  position: absolute;
  top: -8px;
  left: -5px;
  width: 35px;
  height: 8px;
  background-color: #333;
  border-radius: 5px 5px 0 0;
  border: 2px solid #444;
  border-bottom: none;
}

@keyframes smokeAnimation {
  0% {
    transform: translateY(0) scale(1);
    opacity: 0.8;
  }
  100% {
    transform: translateY(-20px) scale(2);
    opacity: 0;
  }
}

.railway-engine-chimney::after {
  content: "";
  position: absolute;
  top: -10px;
  left: -5px;
  right: -5px;
  height: 10px;
  background-color: var(--railway-cabin-border);
  border-radius: 5px 5px 0 0;
}

.railway-engine-title {
  font-size: 24px;
  font-weight: 700;
  color: white;
  margin-bottom: 15px;
  text-align: center;
  border-bottom: 2px solid white;
  padding-bottom: 10px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  padding: 8px;
}

.railway-engine-content {
  font-size: 15px;
  line-height: 1.5;
  color: white;
  flex: 1;
  overflow-y: auto;
}

/* Responsive Styles */
@media screen and (max-width: 768px) {
  .railway-timeline-container {
    padding: 60px 0 30px;
  }

  .railway-timeline-title h2 {
    font-size: 28px;
  }

  .railway-timeline-title p {
    font-size: 16px;
  }

  .railway-cabin,
  .railway-engine {
    width: 240px;
    padding: 15px;
    margin-right: 30px;
  }

  .railway-cabin-year,
  .railway-engine-title {
    font-size: 20px;
    margin-bottom: 10px;
    padding-bottom: 8px;
  }

  .railway-cabin-content,
  .railway-engine-content {
    font-size: 14px;
  }

  .railway-engine-front {
    left: -39px;
    width: 40px;
  }


}

@media screen and (max-width: 576px) {
  .railway-timeline-container {
    padding: 50px 0 20px;
  }

  .railway-timeline-title h2 {
    font-size: 24px;
  }

  .railway-cabin,
  .railway-engine {
    width: 220px;
    padding: 12px;
    margin-right: 25px;
  }

  .railway-cabin-year,
  .railway-engine-title {
    font-size: 18px;
  }

  .railway-cabin-content,
  .railway-engine-content {
    font-size: 13px;
  }
}

/* Animation Classes */
@keyframes trainArrival {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.train-arrival {
  animation: trainArrival 1.5s ease-out forwards;
}

@keyframes autoScroll {
  0% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(calc(-50% + 50vw));
  }
  100% {
    transform: translateX(calc(-100% + 100vw));
  }
}

/* Add a subtle bounce effect to the auto-scroll */
@keyframes trainBounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}



@keyframes cabinBounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.cabin-bounce {
  animation: cabinBounce 0.5s ease-in-out;
}

/* Scrollbar Styling for Timeline Container */
.railway-timeline-container::-webkit-scrollbar {
  height: 10px;
}

.railway-timeline-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
}

.railway-timeline-container::-webkit-scrollbar-thumb {
  background: var(--railway-cabin-border);
  border-radius: 10px;
  border: 2px solid #f1f1f1;
}

.railway-timeline-container::-webkit-scrollbar-thumb:hover {
  background: #003050;
}

/* Hide scrollbar for mobile but keep functionality */
@media (max-width: 768px) {
  .railway-timeline-container {
    scrollbar-width: none; /* Firefox */
  }

  .railway-timeline-container::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Edge */
  }



  .railway-sleeper {
    margin: 0 3px; /* Closer sleepers for mobile */
  }

  /* Adjust navigation controls for mobile */
  .railway-timeline-controls {
    bottom: -10px;
  }

  .timeline-control {
    width: 35px;
    height: 35px;
  }
}

/* Extra small devices */
@media (max-width: 576px) {


  .railway-sleeper {
    width: 8px;
    height: 20px;
    margin: 0 2px;
  }

  .railway-timeline-controls {
    bottom: -15px;
  }

  .timeline-control {
    width: 30px;
    height: 30px;
  }
}

/* Timeline Navigation Controls */
.railway-timeline-controls {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 20px;
  z-index: 10;
  animation: controlsPulse 2s ease-in-out infinite;
}

@keyframes controlsPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.timeline-control {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--railway-cabin-border);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

.timeline-control:hover {
  background-color: #003050;
  transform: scale(1.1);
}

.timeline-control:active {
  transform: scale(0.95);
}

.timeline-control i {
  font-size: 20px;
}
