/**
 * Immersive Saints Timeline - Horizontal Scrolling Timeline
 * Brings a rich visual history of saints through the ages
 */

/* Added aria-live region for screen reader accessibility */
.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  word-wrap: normal !important;
}

/* Fix for navigation buttons to ensure they're only visible inside the timeline section */
.saints-timeline-section {
  position: relative;
}

.saints-timeline-section .timeline-nav {
  position: absolute !important; /* Change from fixed to absolute so it's contained in the section */
  z-index: 100 !important;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.9 !important;
  display: flex !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

.saints-timeline-section .timeline-nav.prev {
  left: 15px !important;
  right: auto !important;
}

.saints-timeline-section .timeline-nav.next {
  right: 15px !important;
  left: auto !important;
}

.saints-timeline-section {
  position: relative;
  background-color: #f5f0e8;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(201, 160, 83, 0.07) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 50%, rgba(42, 63, 63, 0.05) 0%, transparent 60%);
  padding: 4rem 0 3rem;
  overflow: hidden;
  border-top: 1px solid rgba(201, 160, 83, 0.15);
  border-bottom: 1px solid rgba(201, 160, 83, 0.2);
  min-height: 700px;
}

.timeline-header {
  text-align: center;
  margin-bottom: 2rem;
  padding: 0 2rem;
}

.timeline-title {
  font-family: var(--font-primary);
  font-size: var(--font-size-xl);
  margin-bottom: 1rem;
  color: var(--primary-color);
  position: relative;
  display: inline-block;
  letter-spacing: 0.01em;
}

.timeline-title::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;
  width: 60px;
  height: 3px;
  background-color: var(--tertiary-color);
  transform: translateX(-50%);
}

.timeline-description {
  font-size: var(--er-fs-deck); /* Increased for better readability */
  color: var(--text-medium);
  max-width: 700px;
  margin: 1.5rem auto 0;
  font-weight: 300;
}

/* Timeline container */
.timeline-container {
  position: relative;
  width: 100%;
  height: 650px; /* Further increased height to prevent cut-off images */
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
  padding-bottom: 30px;
}

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

/* Timeline track */
.timeline-track {
  position: relative;
  width: max-content;
  min-width: 100%;
  height: 100%;
  display: flex;
  padding: 0 5%;
}

/* Timeline eras */
.timeline-era {
  position: relative;
  height: 100%;
  padding: 0 1rem;
  min-width: 450px; /* Increased from 400px for better spacing */
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

/* New container for era label to improve positioning */
.era-label-container {
  position: relative;
  text-align: center;
  padding-top: 15px;
  padding-bottom: 60px; /* Increased padding to move labels further from saints */
  z-index: 5;
}

.era-label {
  display: inline-block;
  font-family: var(--font-primary);
  font-size: var(--er-fs-floor); /* Increased for better readability */
  color: var(--primary-color);
  white-space: nowrap;
  background-color: var(--bg-main); /* Using theme variable instead of white */
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(201, 160, 83, 0.4);
  max-width: 90%;
}

/* Timeline center line */
.timeline-center-line {
  position: absolute;
  top: 45%;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(to right,
    transparent 0%,
    rgba(201, 160, 83, 0.4) 5%,
    rgba(201, 160, 83, 0.85) 50%,
    rgba(201, 160, 83, 0.4) 95%,
    transparent 100%
  );
  transform: translateY(-50%);
  z-index: 1;
}

/* Saint nodes */
.saint-node {
  position: absolute;
  width: 140px; /* Increased width for better spacing */
  height: 240px; /* Further increased height to prevent text overlap */
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  z-index: 4;
}

.saint-node.above {
  top: 10%; /* Reduced from 25% to bring saints higher up */
  transform: translateY(-20%);
}

.saint-node.below {
  bottom: 10%; /* Moved down further to create more space and prevent overlap */
  transform: translateY(20%);
}

.saint-avatar {
  width: 110px; /* Further increased for better visibility */
  height: 135px; /* Further increased for better visibility */
  border-radius: 5px;
  border: 3px solid var(--tertiary-color);
  background-color: var(--bg-main); /* Using theme variable */
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-normal);
  position: relative;
  margin-top: 15px; /* Added margin to ensure images aren't cut off */
}

.saint-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.saint-avatar::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(to right, transparent 0%, rgba(255, 255, 255, 0.2) 50%, transparent 100%);
  animation: shine 3s infinite;
}

.saint-node:hover .saint-avatar {
  transform: scale(1.1);
  border-color: var(--secondary-color);
}

.saint-node:hover .saint-avatar img {
  transform: scale(1.1);
}

/* Added to position saints closer to center line */
.saint-connector {
  position: absolute;
  width: 2px;
  height: 40px; /* Reduced from 60px to bring saints closer to timeline */
  background-color: var(--tertiary-color);
  z-index: 2;
}

.above .saint-connector {
  top: 90px;
  bottom: auto;
  height: 60px; /* Increased to reach the timeline that's now lower */
}

.below .saint-connector {
  bottom: 90px;
  top: auto;
  height: 30px; /* Reduced to match the closer position to timeline */
}

/* Added container for saint name and years to improve layout */
.saint-name-container {
  text-align: center;
  background-color: #fff;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  margin-top: 0.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  max-width: 150px;
  border: 1px solid rgba(201, 160, 83, 0.25);
}

.saint-name {
  font-family: var(--font-primary);
  font-size: var(--er-fs-floor); /* Increased from var(--font-size-sm) */
  text-align: center;
  color: var(--primary-color);
  transition: color var(--transition-fast);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.saint-years {
  font-size: var(--er-fs-floor); /* Increased from 0.75rem */
  color: var(--text-medium);
  margin-top: 0.2rem;
}

.saint-node:hover .saint-name {
  color: var(--secondary-color);
}

/* Timeline years markers */
.year-marker {
  position: absolute;
  top: 45%; /* Adjusted to match the new center line position */
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  z-index: 2;
  width: 80px;
  text-align: center;
}

.year-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--tertiary-color);
  margin-bottom: 5px;
}

.year-label {
  font-size: var(--er-fs-floor);
  font-weight: 700;
  color: var(--primary-color);
  transform: rotate(-45deg);
  background-color: #fff;
  padding: 3px 6px;
  border-radius: 3px;
  white-space: nowrap;
  letter-spacing: 0.03em;
}

/* Timeline navigation */
.timeline-nav {
  position: absolute !important; /* Change to absolute, not fixed */
  top: 50%;
  transform: translateY(-50%);
  width: 48px; /* Increased size */
  height: 48px; /* Increased size */
  border-radius: 50%;
  background-color: rgba(201, 160, 83, 0.9);
  box-shadow: var(--shadow-md);
  display: flex !important;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 100; /* Increased z-index to ensure visibility */
  opacity: 0.9 !important;
  transition: all var(--transition-fast);
  border: 1px solid rgba(255, 255, 255, 0.5);
  pointer-events: auto !important; /* Always clickable */
  visibility: visible !important;
}

.timeline-nav:hover {
  opacity: 1;
  background-color: var(--tertiary-color);
}

.timeline-nav:hover i {
  color: var(--text-light);
}

.timeline-nav i {
  color: var(--text-light);
  font-size: 1.4rem; /* Increased size */
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.timeline-nav.prev {
  left: 15px !important; /* Force left positioning */
  right: auto !important; /* Prevent right positioning */
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.timeline-nav.next {
  right: 15px !important; /* Force right positioning */
  left: auto !important; /* Prevent left positioning */
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

/* Ensure navigation buttons are always visible */
.timeline-nav.always-visible {
  opacity: 0.9 !important;
  pointer-events: auto !important;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.4), 0 0 5px rgba(201, 160, 83, 0.3) !important;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 15px rgba(255, 255, 240, 0.3), 0 0 5px rgba(201, 160, 83, 0.2); }
  50% { box-shadow: 0 0 20px rgba(255, 255, 240, 0.5), 0 0 10px rgba(201, 160, 83, 0.4); }
  100% { box-shadow: 0 0 15px rgba(255, 255, 240, 0.3), 0 0 5px rgba(201, 160, 83, 0.2); }
}

/* Saint detail popup */
.saint-detail-popup {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 300px;
  background-color: var(--bg-main); /* Using theme variable instead of white */
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  z-index: 20;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
  border: 1px solid rgba(201, 160, 83, 0.3);
}

.saint-detail-popup.active {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.popup-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.popup-close:hover {
  background-color: rgba(137, 83, 72, 0.1);
}

.popup-close i {
  color: var(--text-medium);
  font-size: var(--er-fs-floor);
}

.popup-header {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.popup-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--tertiary-color);
}

.popup-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.popup-title {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.popup-name {
  font-family: var(--font-primary);
  font-size: var(--font-size-md);
  margin-bottom: 0.3rem;
  color: var(--primary-color);
}

.popup-years {
  font-size: var(--er-fs-floor);
  color: var(--text-medium);
}

.popup-category {
  display: inline-block;
  background-color: var(--secondary-color);
  color: var(--text-light);
  font-size: var(--er-fs-floor);
  padding: 0.2rem 0.7rem;
  border-radius: 12px;
  margin-top: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.popup-content {
  margin-bottom: 1rem;
}

.popup-bio {
  font-size: var(--font-size-sm);
  color: var(--text-dark);
  line-height: var(--line-height-normal);
  margin-bottom: 1rem;
}

.popup-quote {
  position: relative;
  padding: 1rem;
  background-color: rgba(0, 0, 0, 0.02);
  border-radius: var(--radius-sm);
  font-style: italic;
  font-size: var(--er-fs-deck);
  margin-bottom: 1rem;
}

.popup-quote::before {
  content: """;
  position: absolute;
  top: 5px;
  left: 5px;
  font-size: 1.5rem;
  color: var(--tertiary-color);
  opacity: 0.3;
}

.popup-quote p {
  margin: 0;
  padding-left: 1rem;
}

.popup-footer {
  text-align: center;
}

.view-saint-link {
  display: inline-flex;
  align-items: center;
  color: var(--secondary-color);
  font-weight: 600;
  font-size: var(--er-fs-floor);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.view-saint-link i {
  margin-left: 0.5rem;
  transition: transform var(--transition-fast);
}

.view-saint-link:hover {
  color: var(--tertiary-color);
}

.view-saint-link:hover i {
  transform: translateX(3px);
}

/* Timeline overlay */
.timeline-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 15;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.timeline-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Era separators */
.era-separator {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 80px;
  background: linear-gradient(to bottom, transparent, var(--tertiary-color), transparent);
  z-index: 2;
  right: 0;
}

/* Animation keyframes */
@keyframes shine {
  0% { left: -100%; }
  20% { left: 100%; }
  100% { left: 100%; }
}

/* Added for quick era navigation */
.era-navigation {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
  padding: 0 2rem;
}

.era-nav-button {
  padding: 0.3rem 0.6rem;
  background-color: rgba(201, 160, 83, 0.2);
  border: 1px solid rgba(201, 160, 83, 0.3);
  border-radius: var(--radius-sm);
  font-size: var(--er-fs-floor);
  color: var(--primary-color);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.era-nav-button:hover, 
.era-nav-button.active {
  background-color: rgba(201, 160, 83, 0.5);
  color: var(--text-light);
}

/* Responsive styles */
@media (max-width: 768px) {
  .saints-timeline-section {
    padding: 3rem 0 1.5rem;
    min-height: 500px; /* Adjusted for mobile */
  }
  
  .timeline-container {
    height: 450px; /* Increased for mobile to prevent overlap */
  }
  
  .timeline-era {
    min-width: 350px; /* Adjusted for better mobile display */
  }
  
  .saint-node {
    width: 110px; /* Increased from 90px for better visibility on mobile */
    height: 180px; /* Increased to prevent text overlap on mobile */
  }
  
  .saint-avatar {
    width: 75px; /* Increased for better visibility on mobile */
    height: 95px;
  }
  
  .saint-name-container {
    max-width: 110px;
  }
  
  .saint-name {
    font-size: var(--er-fs-floor); /* Adjusted for mobile but still increased from original */
  }
  
  .saint-detail-popup {
    width: 280px;
  }
  
  .era-navigation {
    display: none; /* Hide on mobile to save space */
  }
  
  .era-label {
    font-size: var(--er-fs-floor); /* Increased from previous mobile size */
    padding: 0.3rem 0.7rem;
  }
  
  /* Ensure navigation buttons remain visible on mobile */
  .timeline-nav {
    width: 44px;
    height: 44px;
    position: fixed !important;
    z-index: 100;
  }
}

@media (max-width: 576px) {
  .timeline-container {
    height: 400px; /* Adjusted for small mobile */
  }
  
  .timeline-era {
    min-width: 300px; /* Further adjusted for small mobile */
  }
  
  .timeline-title {
    font-size: var(--font-size-lg);
  }
  
  .timeline-description {
    font-size: var(--font-size-base);
  }
  
  .saint-node {
    width: 70px;
    height: 160px; /* Adjusted for small mobile */
  }
  
  .saint-avatar {
    width: 50px;
    height: 70px;
  }
  
  .above .saint-connector,
  .below .saint-connector {
    height: 40px; /* Adjusted connectors for mobile */
  }
  
  .saint-detail-popup {
    width: 260px;
    padding: 1rem;
  }
  
  .timeline-nav {
    width: 35px;
    height: 35px;
  }
}