/* Timeline Container */
.timeline-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
}

/* Side Navigation */
.timeline-nav {
  position: -webkit-sticky;
  position: sticky;
  top: 100px;
  flex-shrink: 0;
  width: 160px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding-right: 0.5rem;
  display: none;
  z-index: 100;
  background: inherit;
}

/* Ensure parent sections don't break sticky */
#resume {
  overflow: visible !important;
}

#resume .container {
  overflow: visible !important;
}

.timeline-nav::-webkit-scrollbar {
  width: 3px;
}

.timeline-nav::-webkit-scrollbar-thumb {
  background: var(--bs-primary);
  border-radius: 2px;
}

.timeline-nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.timeline-nav-item {
  margin-bottom: 0.25rem;
}

.timeline-nav-link {
  display: block;
  padding: 0.4rem 0.6rem;
  font-size: 0.75rem;
  color: #888;
  text-decoration: none;
  border-left: 2px solid #e0e0e0;
  transition: all 0.25s ease;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-nav-link:hover {
  color: var(--bs-primary);
  border-left-color: var(--bs-primary);
  background: rgba(var(--bs-primary-rgb), 0.05);
}

.timeline-nav-link.active {
  color: var(--bs-primary);
  border-left-color: var(--bs-primary);
  border-left-width: 3px;
  font-weight: 600;
  background: rgba(var(--bs-primary-rgb), 0.08);
  white-space: normal;
}


/* Show nav on larger screens */
@media (min-width: 1100px) {
  .timeline-nav {
    display: block;
  }
}

/* Timeline Styles */
.timeline {
  position: relative;
  padding-left: 40px;
  width: 100%;
  flex: 1;
}

/* Timeline entry */
.timeline-entry {
  position: relative;
  padding-bottom: 2rem;
}

.timeline-entry:last-child {
  padding-bottom: 0;
}

/* Line segment - each entry draws line to next (except last) */
.timeline-entry::after {
  content: '';
  position: absolute;
  left: -33px;
  top: 24px;
  bottom: -8px;
  width: 2px;
  background: var(--bs-primary);
}

.timeline-entry:last-child::after {
  display: none;
}

/* Timeline dot */
.timeline-entry::before {
  content: '';
  position: absolute;
  left: -40px;
  top: 8px;
  width: 16px;
  height: 16px;
  background: #fff;
  border: 3px solid var(--bs-primary);
  border-radius: 50%;
  z-index: 1;
}

/* Current/Present job - filled dot with pulse */
.timeline-entry.current::before {
  background: var(--bs-primary);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(var(--bs-primary-rgb), 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(var(--bs-primary-rgb), 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(var(--bs-primary-rgb), 0);
  }
}

/* Timeline content box */
.timeline-content {
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 0.5rem;
  padding: clamp(0.75rem, 2vw, 1rem);
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
  transition: all 0.3s ease;
  width: 100%;
  scroll-margin-top: 80px;
  cursor: pointer;
}

.timeline-content:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: var(--bs-primary);
}

/* Expanded state */
.timeline-entry.active .timeline-content {
  padding: clamp(1rem, 3vw, 1.75rem);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  border-color: var(--bs-primary);
}

/* Header with date and title */
.timeline-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.timeline-date {
  font-size: clamp(0.75rem, 1.5vw, 0.9rem);
  font-weight: 500;
  color: var(--bs-primary);
  background: rgba(var(--bs-primary-rgb), 0.1);
  padding: 0.25rem 0.75rem;
  border-radius: 2rem;
  white-space: nowrap;
}

.timeline-title {
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 600;
  margin: 0;
  flex: 1;
  min-width: 200px;
}

.timeline-company {
  color: #64748b;
  font-weight: 500;
  margin-bottom: 0.75rem;
  font-size: clamp(0.9rem, 1.5vw, 1.1rem);
}

/* Grouped timeline card (multiple roles at same company) */
.timeline-content-grouped .timeline-company {
  font-style: italic;
  margin-bottom: 1rem;
}

.timeline-role {
  border-left: 3px solid var(--bs-primary);
  padding-left: 1rem;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.timeline-role:last-child {
  margin-bottom: 0;
}

.timeline-role-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.timeline-role-title {
  font-weight: 600;
  font-size: clamp(0.95rem, 1.5vw, 1.1rem);
  color: #333;
}

.timeline-role-date {
  font-size: 0.8rem;
  color: var(--bs-primary);
  background: rgba(var(--bs-primary-rgb), 0.1);
  padding: 0.15rem 0.5rem;
  border-radius: 1rem;
  white-space: nowrap;
}

.timeline-role-details {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.4s ease-out, opacity 0.3s ease, margin 0.3s ease;
  margin-top: 0;
}

.timeline-role-details > ul {
  overflow: hidden;
  margin: 0;
  padding-left: 1.25rem;
  font-size: clamp(0.85rem, 1.25vw, 0.95rem);
}

.timeline-role-details li {
  margin-bottom: 0.3rem;
  line-height: 1.5;
}

.timeline-role.expanded .timeline-role-details {
  grid-template-rows: 1fr;
  opacity: 1;
  margin-top: 0.75rem;
}

.timeline-role:hover {
  border-left-color: var(--bs-primary);
  background: rgba(var(--bs-primary-rgb), 0.02);
}

.timeline-role.expanded {
  background: rgba(var(--bs-primary-rgb), 0.03);
  padding: 1rem;
  padding-left: 1rem;
  border-radius: 0.25rem;
}

/* Grouped card always shows details section */
.timeline-content-grouped .timeline-details {
  display: none;
}

/* Mobile adjustments for roles */
@media (max-width: 575px) {
  .timeline-role-header {
    flex-direction: column;
  }

  .timeline-role-date {
    order: -1;
    margin-bottom: 0.25rem;
    align-self: flex-start;
  }
}

/* Bullet points - collapsed by default */
.timeline-details {
  font-size: clamp(0.85rem, 1.25vw, 1rem);
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.4s ease-out, opacity 0.3s ease, margin 0.3s ease;
  opacity: 0;
  margin-top: 0;
}

.timeline-details > ul {
  overflow: hidden;
}

/* Expanded when active */
.timeline-entry.active .timeline-details {
  grid-template-rows: 1fr;
  opacity: 1;
  margin-top: 0.75rem;
}

.timeline-details ul {
  margin-bottom: 0;
  padding-left: 1.25rem;
}

.timeline-details li {
  margin-bottom: 0.35rem;
  line-height: 1.6;
}

/* Company margin adjustment for collapsed state */
.timeline-company {
  margin-bottom: 0;
  transition: margin 0.3s ease;
}

.timeline-entry.active .timeline-company {
  margin-bottom: 0.5rem;
}

/* Tablet adjustments */
@media (max-width: 991px) {
  .timeline {
    padding-left: 35px;
  }

  .timeline-entry::after {
    left: -29px;
  }

  .timeline-entry::before {
    left: -35px;
    width: 14px;
    height: 14px;
  }
}

/* Mobile adjustments */
@media (max-width: 575px) {
  .timeline-wrapper {
    gap: 0;
  }

  .timeline {
    padding-left: 28px;
  }

  .timeline-entry::after {
    left: -23px;
    top: 18px;
    bottom: -6px;
  }

  .timeline-entry::before {
    left: -28px;
    width: 12px;
    height: 12px;
    top: 6px;
    border-width: 2px;
  }

  .timeline-entry {
    padding-bottom: 1.5rem;
  }

  .timeline-header {
    flex-direction: column;
  }

  .timeline-date {
    order: -1;
    margin-bottom: 0.25rem;
  }

  .timeline-title {
    min-width: unset;
  }
}
