/************** TIMELINE STYLES - CUSTOM STRUCTURE *****************/

/* Timeline Container */
.gw-timeline-container {
  position: relative;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Desktop Timeline - Masonry Layout */
@media (min-width: 768px) {
  .gw-timeline-container {
    padding: 40px 20px;
    position: relative; /* Required for absolute positioning of items */
    min-height: 500px; /* Will be set by JavaScript */
  }

  /* Central vertical line */
  .gw-timeline-container::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: #ddd;
    transform: translateX(-50%);
    z-index: 0;
  }

  /* Timeline Item - Will be positioned absolutely by JS */
  .timeline-item {
    position: absolute; /* Set by JavaScript */
    width: calc(50% - 50px); /* More horizontal separation from center line */
    transition: opacity 0.3s ease-out; /* Only transition opacity, not position */
    opacity: 0; /* Hidden by default, JS will fade in when positioned */
    visibility: hidden; /* Completely hidden until positioned */
    /* No margin-bottom needed as JS controls spacing */
  }
  
  /* Items that have been positioned by JS */
  .timeline-item.timeline-positioned {
    visibility: visible;
    /* Opacity is controlled by inline style from JS for smooth fade-in */
  }

  /* Timeline Content Wrapper */
  .timeline-content {
    width: 100%;
    position: relative;
  }

  /* Left side items */
  .timeline-item-left {
    left: 0;
  }

  .timeline-item-left .timeline-content {
    text-align: right;
    position: relative;
  }

  .timeline-item-left .timeline-content .timeline-card {
    margin-left: auto;
  }

  /* Connector line for left items - Behind the card */
  .timeline-item-left .timeline-content::before {
    content: "";
    position: absolute;
    top: 39.5px; /* Centered with marker */
    right: -50px; /* Extended for more horizontal space */
    width: 66px; /* Longer to reach center marker */
    height: 3px;
    background-color: #f39200;
    z-index: 0; /* Behind the card */
  }

  /* Right side items */
  .timeline-item-right {
    right: 0;
  }

  .timeline-item-right .timeline-content {
    text-align: left;
    position: relative;
  }

  /* Connector line for right items - Behind the card */
  .timeline-item-right .timeline-content::before {
    content: "";
    position: absolute;
    top: 39.5px; /* Centered with marker */
    left: -50px; /* Extended for more horizontal space */
    width: 66px; /* Longer to reach center marker */
    height: 3px;
    background-color: #f39200;
    z-index: 0; /* Behind the card */
  }

  /* Timeline Card */
  .timeline-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 2;
  }

  /* Timeline Marker (orange circle) - Above the line */
  .timeline-marker {
    position: absolute;
    top: 25px;
    width: 32px;
    height: 32px;
    background-color: #f39200;
    border-radius: 50%;
    z-index: 10; /* Higher z-index to be above everything including the line */
    border: 4px solid #fff;
    box-shadow: 0 0 0 2px #f39200;
  }

  /* Position marker for left items - at the right edge */
  .timeline-item-left .timeline-marker {
    left: auto;
    right: -66px; /* Position at center line (50px gap + 16px to center of marker) */
  }

  /* Position marker for right items - at the left edge */
  .timeline-item-right .timeline-marker {
    right: auto;
    left: -66px; /* Position at center line (50px gap + 16px to center of marker) */
  }
}

/* Mobile Timeline */
@media (max-width: 767.98px) {
  .gw-timeline-container {
    padding: 20px 15px;
  }

  /* Remove center line pseudo-element */
  .gw-timeline-container::before {
    display: none;
  }

  /* Timeline Item - Mobile Layout */
  .timeline-item {
    position: relative;
    margin-bottom: 30px;
    padding-left: 50px;
    opacity: 1; /* Items visible by default on mobile */
  }

  /* Timeline Content - Full width on mobile */
  .timeline-content {
    width: 100%;
  }

  /* Timeline Card */
  .timeline-card {
    background: #fff;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    text-align: left;
  }

  /* Mobile connector line */
  .timeline-card::after {
    content: "";
    position: absolute;
    top: 25px;
    left: -50px;
    width: 50px;
    height: 3px;
    background-color: #f39200;
    z-index: 1;
  }

  /* Timeline Marker - Mobile (on left side) */
  .timeline-marker {
    position: absolute;
    left: 0;
    top: 15px;
    width: 28px;
    height: 28px;
    background-color: #f39200;
    border-radius: 50%;
    z-index: 3;
    border: 3px solid #fff;
    box-shadow: 0 0 0 2px #f39200;
  }

  /* Vertical line connecting markers on mobile */
  .timeline-item::before {
    content: "";
    position: absolute;
    left: 13px;
    top: 0;
    bottom: -30px;
    width: 3px;
    background-color: #ddd;
    z-index: 0;
  }

  .timeline-item:last-child::before {
    display: none;
  }
}

/* Timeline Card Content Styles (common) */
.timeline-date {
  font-size: 18px;
  font-weight: 600;
  color: #4D68B0;
  margin-bottom: 15px;
}

.timeline-image {
  margin-bottom: 15px;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1; /* Square container */
  background-size: cover;
  background-position: center;
}

/* Blurred background - using the same image */
.timeline-image::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-size: cover;
  background-position: center;
  background-image: inherit;
  filter: blur(20px);
  transform: scale(1.1); /* Slightly larger to hide blur edges */
  z-index: 0;
}

.timeline-image a {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.timeline-image img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* Image fits completely inside */
  display: block;
  position: relative;
  z-index: 1;
  transition: transform 0.3s ease;
}

.timeline-image a:hover img {
  transform: scale(1.05);
}

.timeline-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 12px;
  line-height: 1.4;
}

.timeline-title a {
  color: #222;
  text-decoration: none;
  transition: color 0.3s ease;
}

.timeline-title a:hover {
  color: #4D68B0;
}

.timeline-excerpt {
  color: #666;
  line-height: 1.6;
  margin-bottom: 15px;
  font-size: 15px;
}

.timeline-read-more {
  display: inline-block;
  color: #f39200 !important;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
}

.timeline-read-more:hover {
  color: #bf7507 !important;
  text-decoration: none;
}

/* Desktop specific text alignment */
@media (min-width: 768px) {
  .timeline-item-left .timeline-date,
  .timeline-item-left .timeline-title,
  .timeline-item-left .timeline-excerpt {
    text-align: right;
  }

  /* .timeline-item-left .timeline-read-more {
    float: right;
  } */

  .timeline-item-right .timeline-date,
  .timeline-item-right .timeline-title,
  .timeline-item-right .timeline-excerpt {
    text-align: left;
  }

  /* .timeline-item-right .timeline-read-more {
    float: left;
  } */

  /* Clear float */
  .timeline-card::before {
    content: "";
    display: table;
    clear: both;
  }
}

/* Loading Sentinel Styles */
#gw-timeline-sentinel {
  padding: 40px 0;
  width: 100%;
  min-height: 80px;
  clear: both;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

#gw-timeline-sentinel .spinner-border {
  width: 3rem;
  height: 3rem;
  border-width: 0.3rem;
  color: #4D68B0;
}

/* Error message styling */
#gw-timeline-sentinel .text-danger {
  width: 100%;
  text-align: center;
  padding: 1rem;
  margin: 0;
}

/* Smooth fade-in animation for new items */
@keyframes timelineFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.timeline-item {
  animation: timelineFadeIn 0.5s ease-out;
}
