//
// Variables
// --------------------------------------------------
$timeline-item-spacing: 1.5rem !default;
$timeline-item-padding: 1.5rem !default;
$timeline-item-border: 1px solid currentColor !default;
$timeline-item-border-radius: 0 !default;
$timeline-item-shadow: 0 1px 0 0 rgba(0, 0, 0, .15) !default;
$timeline-item-headline-color: $primary !default;
$timeline-item-headline-size: 1.5rem !default;
$timeline-item-date-size: .8rem !default;
$timeline-item-color: $body-color !default;
$timeline-item-bg: #ffffff !default;
$timeline-item-caption-bg: #f2f2f2 !default;
$timeline-item-caption-color: color-contrast($timeline-item-caption-bg) !default;

$timeline-icon-color: $body-color !default;
$timeline-icon-bg: #ffffff !default;
$timeline-icon-size: 46px !default;
$timeline-icon-space: 10px !default;
$timeline-icon-border: 3px solid currentColor !default;
$timeline-icon-border-radius: 50% !default;
$timeline-icon-border-opacity: .25 !default;

$timeline-marker-size: 16px !default;
$timeline-marker-bg: $timeline-icon-bg !default;
$timeline-marker-border: $timeline-icon-border !default;
$timeline-marker-border-radius: $timeline-icon-border-radius !default;
$timeline-marker-border-opacity: $timeline-icon-border-opacity !default;

$timeline-path-border: 2px dashed currentColor !default;
$timeline-path-opacity: .25 !default;

//
// Component
// --------------------------------------------------
.timeline {
    --timeline-item-spacing: #{$timeline-item-spacing};
    --timeline-item-padding: #{$timeline-item-padding};
    --timeline-item-border: #{$timeline-item-border};
    --timeline-item-border-radius: #{$timeline-item-border-radius};
    --timeline-item-shadow: #{$timeline-item-shadow};
    --timeline-item-headline-color: #{$timeline-item-headline-color};
    --timeline-item-headline-size: #{$timeline-item-headline-size};
    --timeline-item-date-size: #{$timeline-item-date-size};
    --timeline-item-color: #{$timeline-item-color};
    --timeline-item-bg: #{$timeline-item-bg};
    --timeline-item-caption-color: #{$timeline-item-caption-color};
    --timeline-item-caption-bg: #{$timeline-item-caption-bg};
    --timeline-icon-color: #{$timeline-icon-color};
    --timeline-icon-bg: #{$timeline-icon-bg};
    --timeline-icon-size: #{$timeline-icon-size};
    --timeline-icon-space: #{$timeline-icon-space};
    --timeline-icon-border: #{$timeline-icon-border};
    --timeline-icon-border-radius: #{$timeline-icon-border-radius};
    --timeline-icon-border-opacity: #{$timeline-icon-border-opacity};
    --timeline-marker-size: #{$timeline-marker-size};
    --timeline-marker-bg: #{$timeline-marker-bg};
    --timeline-marker-border: #{$timeline-marker-border};
    --timeline-marker-border-radius: #{$timeline-marker-border-radius};
    --timeline-marker-border-opacity: #{$timeline-marker-border-opacity};
    --timeline-path-border: #{$timeline-path-border};
    --timeline-path-opacity: #{$timeline-path-opacity};
    padding-left: var(--timeline-icon-size);
    position: relative;
    &:before {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        left: calc(var(--timeline-icon-size) / 2);
        transform: translate(-50%, 0);
        border-left: var(--timeline-path-border);
        opacity: var(--timeline-path-opacity);
    }
}
.timeline-item {
    position: relative;
    &:not(:first-child) {
        margin-top: calc(var(--timeline-item-spacing) / 2);
    }
}
.timeline-item-inner {
    overflow: hidden;
    margin-left: var(--timeline-item-spacing);
    background-color: var(--timeline-item-bg);
    border: var(--timeline-item-border);
    border-radius: var(--timeline-item-border-radius);
    box-shadow: var(--timeline-item-shadow);
    padding: var(--timeline-item-padding);
}
.timeline-item-marker,
.timeline-item-icon {
    &:after,
    &:before,
    span {
        background-clip: content-box;
        border: var(--timeline-marker-border);
        border-radius: var(--timeline-marker-border-radius);
    }
    &:after,
    span {
        border-color: transparent;
    }
    &:after,
    &:before {
        inset: 0;
        z-index: 1;
        content: '';
        position: absolute;
    }
    &:before {
        opacity: var(--timeline-marker-border-opacity);
    }
    &:after {
        background-color: var(--timeline-marker-bg);
    }
    span {
        display: block;
        height: 100%;
        width: 100%;
        z-index: 2;
        position: relative;
    }
    z-index: 3;
    position: absolute;
    top: 50%;
    left: calc(var(--timeline-icon-size) / 2 * -1);
    width: var(--timeline-marker-size);
    height: var(--timeline-marker-size);
    transform: translate(-50%, -50%);
}
.timeline-item-icon {
    left: calc(var(--timeline-icon-size) / 2 * -1);
    width: var(--timeline-icon-size);
    height: var(--timeline-icon-size);
    border-radius: var(--timeline-icon-border-radius);
    &:before {
        border: var(--timeline-icon-border);
    }
    &:after {
        background-color: var(--timeline-icon-bg);
    }
    span {
        color: var(--timeline-icon-color);
        display: block;
        padding: var(--timeline-icon-space);
    }
    svg {
        position: relative;
        display: block;
        width: 100%;
        height: auto;
    }
}
.timeline-item-image {
    margin: calc(var(--timeline-item-padding) * -1);
    margin-bottom: var(--timeline-item-padding);
    img {
        width: 100%;
        height: auto;
    }
    .caption {
        font-size: .8em;
        padding: .5rem var(--timeline-item-padding);
        color: var(--timeline-item-caption-color);
        background-color: var(--timeline-item-caption-bg);
    }
}
.timeline-item-header-headline {
    font-size: var(--timeline-item-headline-size);
    color: var(--timeline-item-headline-color);
}
.timeline-item-header:last-child,
.timeline-item-text {
    > *:last-child {
        margin-bottom: 0;
    }
}
.timeline-item-date,
.timeline-item-text {
    color: var(--timeline-item-color);
}
.timeline-item-date {
    font-size: var(--timeline-item-date-size);
    text-transform: uppercase;
}

//
// Small
// --------------------------------------------------
@include media-breakpoint-up(md) {
    .timeline {
        &:before {
            left: 50%;
        }
        padding-left: 0;
    }
    .timeline-item {
        width: 50%;
        &:not(:first-child) {
            margin-top: calc(var(--timeline-item-spacing) * -1);
        }
    }
    .timeline-item-marker {
        left: auto;
        right: 0;
        transform: translate(50%, -50%);
    }
    .timeline-item-inner {
        margin-left: 0;
        margin-right: calc(var(--timeline-item-spacing) + var(--timeline-icon-size) / 2);
    }
    .timeline-item:nth-child(even) {
        margin-left: 50%;
        .timeline-item-inner {
            margin-left: calc(var(--timeline-item-spacing) + var(--timeline-icon-size) / 2);
            margin-right: 0;
        }
        .timeline-item-marker {
            left: 0;
            right: auto;
            transform: translate(-50%, -50%);
        }
    }
}
