/**
 * Timeline Block Styles
 */

.timeline-block {
  --timeline-accent: var(--wp--preset--color--contrast, #dc2626);
  --timeline-bg: var(--wp--preset--color--white, #ffffff);
  --timeline-spacing: var(--wp--preset--spacing--50, 2rem);
  --timeline-spacing-large: var(--wp--preset--spacing--60, 3rem);
  
  background: var(--timeline-bg);
  padding: var(--timeline-spacing) 0;

  @media (min-width: 1024px) {
    padding: var(--timeline-spacing-large);
  }
}

.timeline-block__items {
  display: flex;
  flex-flow: row wrap;
  position: relative;
  padding-bottom: var(--timeline-spacing-large);

  &::after {
    content: "" !important;
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 2px;
    background: var(--timeline-accent);

    @media (min-width: 1024px) {
      left: calc(50% - 1px);
    }
  }

  @media (min-width: 1024px) {
    &::before {
      left: calc(50% - 0.625rem);
    }
  }
}

.timeline-block__item {
  flex: 1 0 100%;
  max-width: 100%;
  margin-bottom: var(--timeline-spacing);
  opacity: 0;
  transition: opacity 0.8s ease-out, transform 0.8s ease-out;
  transform: translateY(50px);

  @media (max-width: 1023px) {
    & > * {
      padding-left: 2.5rem !important;
      padding-right: 0 !important;
    }
  }

  &.item-visible {
    opacity: 1;
    transform: translateY(0);

    & .timeline-block__item__wrap::before {
      transform: scale(1);
    }

    & .timeline-block__item__wrap::after {
      width: 100%;
    }
  }

  /* Stagger animation delays for sequential items */
  &:nth-child(1) { transition-delay: 0ms; }
  &:nth-child(2) { transition-delay: 100ms; }
  &:nth-child(3) { transition-delay: 200ms; }
  &:nth-child(4) { transition-delay: 300ms; }
  &:nth-child(5) { transition-delay: 400ms; }
  &:nth-child(6) { transition-delay: 500ms; }
  &:nth-child(7) { transition-delay: 600ms; }
  &:nth-child(8) { transition-delay: 700ms; }
  &:nth-child(9) { transition-delay: 800ms; }
  &:nth-child(10) { transition-delay: 900ms; }
  &:nth-child(11) { transition-delay: 1000ms; }
  &:nth-child(12) { transition-delay: 1100ms; }
  &:nth-child(13) { transition-delay: 1200ms; }
  &:nth-child(14) { transition-delay: 1300ms; }
  &:nth-child(15) { transition-delay: 1400ms; }
  &:nth-child(16) { transition-delay: 1500ms; }

  & button {
    width: 100%;
    text-align: left;
    position: relative;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;

    @media (min-width: 1024px) {
      font-size: 1.15rem !important;
    }

    & .icon {
      height: 1.25rem;
      width: 1.25rem;
    }
  }

  &:nth-child(even) {
    & > * {
      margin-right: 0;
      margin-left: auto;
    }

    & .timeline-block__item__wrap {
      padding-right: 0 !important;
    }

    & .timeline-block__item__wrap::before {
      right: auto;
      left: -0.5rem;
    }
  }

  &:nth-child(odd) {
    & > * {
      margin-right: auto;
      margin-left: 0;
      padding-left: 0;
    }

    @media (min-width: 1024px) {
      & .timeline-block__item__wrap {
        padding-left: 0 !important;
      }

      & .timeline-block__item__wrap::after {
        right: 0;
        left: auto;
      }
    }

    & .timeline-block__item__wrap::before {
      right: auto;
      left: -0.5rem;

      @media (min-width: 1024px) {
        left: auto;
        right: -0.5rem;
      }
    }
  }
}

.timeline-block__item__wrap {
  padding: var(--wp--preset--spacing--50, 2rem) !important;
  padding-top: 0.5rem;
  margin: 0 auto;
  margin-bottom: var(--timeline-spacing);
  position: relative;

  @media (max-width: 1023px) {
    padding-right: 0 !important;
  }

  & .wp-block-heading {
    color: var(--timeline-accent);
    margin-bottom: var(--wp--preset--spacing--20, 0.5rem);
  }

  @media (min-width: 1024px) {
    max-width: 50%;
  }

  &::after {
    content: "";
    z-index: -1;
    position: absolute;
    bottom: 0;
    left: 0;
    border-bottom: 2px solid var(--timeline-accent);
    transition: 300ms 1s all;
    width: 0;
  }

  &::before {
    content: "";
    z-index: -1;
    position: absolute;
    bottom: -0.5rem;
    left: -0.5rem;
    width: 1rem;
    height: 1rem;
    background: var(--timeline-accent);
    border-radius: 50%;
    transition: 500ms 1.25s all;
    transform: scale(0);
  }

  & details {
    border-radius: 0;

    & summary {
      list-style: none;
      cursor: pointer;
      position: relative;
      padding: 0;
      padding-right: 2rem !important;
      font-weight: 700;
      font-size: var(--wp--preset--font-size--h-6, 1.25rem);

      &::-webkit-details-marker {
        display: none;
      }

      &::after {
        content: "";
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%) rotate(0deg);
        width: 0.75rem;
        height: 0.75rem;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11.06 6.59'%3E%3Cpolygon fill='%23dc2626' points='5.53 6.59 0 1.06 1.06 0 5.53 4.47 10 0 11.06 1.06 5.53 6.59'/%3E%3C/svg%3E");
        background-position: 50% 50%;
        background-size: contain;
        background-repeat: no-repeat;
        transition: transform 0.3s ease;
      }
    }

    & *:not(summary) {
      padding: 0 !important;
    }

    &[open] summary::after {
      transform: translateY(-50%) rotate(180deg);
      content: "" !important;
    }
  }
}