/* ===================================================== */
/* Root Scope */
/* ===================================================== */

.wp-block-custom-timeline,
.editor-styles-wrapper .wp-block-custom-timeline {
  --line-bg: var(--wp--preset--color--grey-700);
}

/* ===================================================== */
/* Timeline Wrapper */
/* ===================================================== */

.wp-block-custom-timeline .timeline-wrapper,
.editor-styles-wrapper .wp-block-custom-timeline .timeline-wrapper {
  position: relative;
}

/* ===================================================== */
/* Timeline List */
/* ===================================================== */

.wp-block-custom-timeline .timeline,
.editor-styles-wrapper .wp-block-custom-timeline .timeline {
  list-style: none;
  padding-left: 24px;
  margin: 0;
  position: relative;
}

.wp-block-custom-timeline .timeline > * + *,
.editor-styles-wrapper .wp-block-custom-timeline .block-editor-block-list__layout > .timeline-item + .timeline-item {
  margin-top: var(--timeline-gap);
}

/* ===================================================== */
/* Timeline Line (Base) */
/* ===================================================== */

.wp-block-custom-timeline .timeline-line,
.editor-styles-wrapper .wp-block-custom-timeline .timeline-line {
  position: absolute;
  left: 11px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--line-bg);
}

.wp-block-custom-timeline .timeline-line::after,
.editor-styles-wrapper .wp-block-custom-timeline .timeline-line::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: var(--wp--preset--color--primary, currentColor);
  transform-origin: top;
  transform: scaleY(var(--progress, 0));
}

/* ===================================================== */
/* Timeline Item */
/* ===================================================== */

.wp-block-custom-timeline .timeline-item,
.editor-styles-wrapper .wp-block-custom-timeline .timeline-item {
  position: relative;
  padding-left: 16px;
}

/* Dot */
.wp-block-custom-timeline .timeline-item::before,
.editor-styles-wrapper .wp-block-custom-timeline .timeline-item::before {
  content: "";
  position: absolute;
  left: -24px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 3px solid var(--line-bg);
  background: var(--color-body);
  z-index: 2;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}

.wp-block-custom-timeline .timeline-item.is-active::before,
.editor-styles-wrapper .wp-block-custom-timeline .timeline-item.is-active::before {
  background: var(--wp--preset--color--primary, currentColor);
  border-color: var(--wp--preset--color--primary, currentColor);
}

/* ===================================================== */
/* Center Layout */
/* ===================================================== */

@media (min-width: 768px) {
  .wp-block-custom-timeline .timeline-wrapper[data-align="center"] .timeline,
  .editor-styles-wrapper .wp-block-custom-timeline .timeline-wrapper[data-align="center"] .timeline {
    padding-left: 0;
  }

  .wp-block-custom-timeline .timeline-wrapper[data-align="center"] .timeline-item,
  .editor-styles-wrapper .wp-block-custom-timeline .timeline-wrapper[data-align="center"] .timeline-item {
    width: 50%;
    text-align: right;
    padding-right: 24px;
    padding-left: 0;
  }

  .wp-block-custom-timeline .timeline-wrapper[data-align="center"] .timeline-item::before,
  .editor-styles-wrapper .wp-block-custom-timeline .timeline-wrapper[data-align="center"] .timeline-item::before {
    left: auto;
    right: -12px;
  }

  .wp-block-custom-timeline .timeline-wrapper[data-align="center"] .timeline-item:nth-child(2n),
  .editor-styles-wrapper .wp-block-custom-timeline .timeline-wrapper[data-align="center"] .timeline-item:nth-child(2n) {
    margin-left: 50%;
    text-align: left;
    padding-left: 24px;
    padding-right: 0;
  }

  .wp-block-custom-timeline .timeline-wrapper[data-align="center"] .timeline-item:nth-child(2n)::before,
  .editor-styles-wrapper .wp-block-custom-timeline .timeline-wrapper[data-align="center"] .timeline-item:nth-child(2n)::before {
    left: -12px;
    right: auto;
  }

  .wp-block-custom-timeline .timeline-wrapper[data-align="center"] .timeline-line,
  .editor-styles-wrapper .wp-block-custom-timeline .timeline-wrapper[data-align="center"] .timeline-line {
    left: 50%;
    transform: translateX(-50%);
  }
}

/* ===================================================== */
/* Content Styling */
/* ===================================================== */

.wp-block-custom-timeline .timeline-item > *:first-child {
  margin-top: 0;
}

.wp-block-custom-timeline .timeline-item > *:last-child {
  margin-bottom: 0;
}

/* ===================================================== */
/* Editor Static Line */
/* ===================================================== */

.editor-styles-wrapper .wp-block-custom-timeline .timeline-line::after {
  transform: scaleY(1);
}

.editor-styles-wrapper .wp-block-custom-timeline .timeline-item::before {
  background: var(--wp--preset--color--primary, currentColor);
  border-color: var(--wp--preset--color--primary, currentColor);
}
