.timeline-wrapper {
  width: 100%;
  position: relative;
  --timeline-dot-size: 16px;
  --timeline-dot-color: #4FA9D1;
}

.timeline-container {
  position: relative;
  padding: 20px 0;
}

.timeline-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  background-color: #94C9E5;
  z-index: 1;
}

.timeline-item-wrapper {
  position: absolute;
  z-index: 2;
  min-height: 100px;
  width: 50%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 0;
}

/* Alternating side padding using data-side */
.timeline-item-wrapper[data-side="left"] { left: 0; padding-right: 30px; justify-content: flex-end; }
.timeline-item-wrapper[data-side="right"] { right: 0; padding-left: 30px; justify-content: flex-start; }

/* Alternating: centerline at 50%, wrappers take half width */
/* Note: timeline-line is the first child of container */
.timeline-item-wrapper[data-side="left"] .timeline-card,
.timeline-item-wrapper[data-side="left"] .timeline-card * { align-items: flex-end; text-align: right; }
.timeline-item-wrapper[data-side="right"] .timeline-card,
.timeline-item-wrapper[data-side="right"] .timeline-card * { align-items: flex-start; }

.timeline-wrapper[data-layout="alternating"] .timeline-item-wrapper:nth-child(even) .timeline-card {
  justify-self: end;
  margin-right: 30px;
  align-items: flex-end;
}

.timeline-wrapper[data-layout="alternating"] .timeline-item-wrapper:nth-child(even) .timeline-card,
.timeline-wrapper[data-layout="alternating"] .timeline-item-wrapper:nth-child(even) .timeline-card * {
  align-items: flex-end;
}

.timeline-wrapper[data-layout="alternating"] .timeline-item-wrapper:nth-child(odd):not(:first-child) .timeline-card {
  justify-self: start;
  margin-left: 30px;
  align-items: flex-start;
}

.timeline-wrapper[data-layout="alternating"] .timeline-item-wrapper:nth-child(odd):not(:first-child) .timeline-card,
.timeline-wrapper[data-layout="alternating"] .timeline-item-wrapper:nth-child(odd):not(:first-child) .timeline-card * {
  align-items: flex-start;
}

.timeline-card {
  --timeline-pointer-color: #ffffff;
  --timeline-pointer-size: 15px;
  background-color: #ffffff;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid #e0e0e0;
  max-width: 500px;
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Ensure nested blocks don't override card styling */
.timeline-card > .brxe-block,
.timeline-card > .timeline-card-content > .brxe-block {
  background: none !important;
  padding: 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
  border: none !important;
  border-radius: 0 !important;
  max-width: none !important;
}

/* Builder wrapper shouldn't interfere with layout */
.timeline-card-content {
  display: contents;
}

/* Ensure card styles apply in builder */
body.bricks-builder .timeline-card,
body.brx-body .timeline-card {
  isolation: isolate;
}

/* Make sure controls work properly in builder preview */
body iframe .timeline-card {
  contain: layout style;
}

/* Triangle pointer via data-side */
.timeline-item-wrapper[data-side="left"] .timeline-card::after {
  content: '';
  position: absolute;
  right: calc(-1 * var(--timeline-pointer-size, 15px));
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-style: solid;
  border-width: var(--timeline-pointer-size, 15px) 0 var(--timeline-pointer-size, 15px) var(--timeline-pointer-size, 15px);
  border-color: transparent transparent transparent var(--timeline-pointer-color, #ffffff);
  filter: drop-shadow(1px 0 1px rgba(0, 0, 0, 0.1));
  z-index: 2;
}

.timeline-item-wrapper[data-side="right"] .timeline-card::after {
  content: '';
  position: absolute;
  left: calc(-1 * var(--timeline-pointer-size, 15px));
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-style: solid;
  border-width: var(--timeline-pointer-size, 15px) var(--timeline-pointer-size, 15px) var(--timeline-pointer-size, 15px) 0;
  border-color: transparent var(--timeline-pointer-color, #ffffff) transparent transparent;
  filter: drop-shadow(-1px 0 1px rgba(0, 0, 0, 0.1));
  z-index: 2;
}

.timeline-dot {
  width: var(--timeline-dot-size, 16px);
  height: var(--timeline-dot-size, 16px);
  min-width: var(--timeline-dot-size, 16px);
  min-height: var(--timeline-dot-size, 16px);
  background-color: var(--timeline-dot-color, #4FA9D1);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  flex-shrink: 0;
  box-sizing: border-box;
  display: block !important;
}

/* Dot side offsets towards centerline */
.timeline-item-wrapper[data-side="left"] .timeline-dot { left: 100%; }
.timeline-item-wrapper[data-side="right"] .timeline-dot { left: 0; }

/* Responsive Design */
@media (max-width: 768px) {
  .timeline-container { display: block; height: auto !important; }

  .timeline-line {
    left: 30px;
    transform: none;
  }

  .timeline-item-wrapper { position: relative; width: 100%; left: auto; right: auto; top: auto !important; justify-content: flex-start; padding-left: 30px; }

  .timeline-card {
    margin-right: 0 !important;
    margin-left: 20px !important;
    align-items: flex-start !important;
  }

  .timeline-card,
  .timeline-card * {
    text-align: left !important;
  }

  /* On mobile always point triangle to left (toward line) */
  .timeline-item-wrapper .timeline-card::after {
    content: '';
    position: absolute;
    left: calc(-1 * var(--timeline-pointer-size, 15px));
    top: 50%;
    transform: translateY(-50%);
    width: 0; height: 0;
    border-style: solid;
    border-width: var(--timeline-pointer-size, 15px) var(--timeline-pointer-size, 15px) var(--timeline-pointer-size, 15px) 0;
    border-color: transparent var(--timeline-pointer-color, #ffffff) transparent transparent;
  }

  .timeline-dot {
    left: 30px;
    right: auto;
    transform: translate(-50%, -50%);
  }
}

/* Layout variations - Left aligned */
.timeline-wrapper[data-layout="left"] .timeline-line {
  left: 30px;
  transform: none;
}

.timeline-wrapper[data-layout="left"] .timeline-item-wrapper {
  grid-template-columns: auto 1fr;
  grid-template-areas: "dot content" !important;
}

.timeline-wrapper[data-layout="left"] .timeline-card {
  justify-self: start !important;
  margin-left: 20px !important;
  margin-right: 0 !important;
  align-items: flex-start !important;
}

.timeline-wrapper[data-layout="left"] .timeline-card,
.timeline-wrapper[data-layout="left"] .timeline-card * {
  align-items: flex-start !important;
}

.timeline-wrapper[data-layout="left"] .timeline-dot {
  margin-left: 30px;
}

/* Hide triangle pointers for left-only layout */
.timeline-wrapper[data-layout="left"] .timeline-card::after {
  display: none;
}

/* Layout variations - Right aligned */
.timeline-wrapper[data-layout="right"] .timeline-line {
  right: 30px;
  left: auto;
  transform: none;
}

.timeline-wrapper[data-layout="right"] .timeline-item-wrapper {
  grid-template-columns: 1fr auto;
  grid-template-areas: "content dot" !important;
}

.timeline-wrapper[data-layout="right"] .timeline-card {
  justify-self: end !important;
  margin-right: 20px !important;
  margin-left: 0 !important;
  align-items: flex-end !important;
}

.timeline-wrapper[data-layout="right"] .timeline-card,
.timeline-wrapper[data-layout="right"] .timeline-card * {
  align-items: flex-end !important;
}

.timeline-wrapper[data-layout="right"] .timeline-dot {
  margin-right: 30px;
}

/* Hide triangle pointers for right-only layout */
.timeline-wrapper[data-layout="right"] .timeline-card::after {
  display: none;
}

