.ims-timeline {
    --ims-timeline-label-width: 170px;
    --ims-timeline-card-gap: 28px;
    --ims-timeline-card-width: 100%;
    --ims-timeline-row-gap: 30px;
    --ims-timeline-line-width: 2px;
    --ims-timeline-line-color: var(--e-global-color-primary);
    --ims-timeline-dot-size: 10px;
    --ims-timeline-dot-color: var(--e-global-color-primary);
    --ims-timeline-dot-ring-color: rgba(175, 120, 225, 0.45);
    --ims-timeline-dot-animation-duration: 3.2s;
    --ims-timeline-connector-color: var(--e-global-color-primary);
    --ims-timeline-connector-width: 1px;
    --ims-timeline-axis-y: 30px;
    --ims-timeline-top-extension: 28px;
    --ims-timeline-hover-lift: 3px;
    --ims-timeline-year-gap: 28px;

    position: relative;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    row-gap: var(--ims-timeline-row-gap);
    overflow: hidden;
    padding-top: 10px;
}

.ims-timeline__item {
    position: relative;
    display: grid;
    grid-template-columns: var(--ims-timeline-label-width) minmax(0, 1fr);
    column-gap: var(--ims-timeline-card-gap);
    align-items: start;
}

/*
 * Vertikale Linie abschnittsweise zeichnen:
 * Sie beginnt exakt am ersten Punkt, endet exakt am letzten Punkt
 * und kann dadurch niemals über die Höhe des Widgets hinausragen.
 */
.ims-timeline__item:not(:last-child)::before {
    content: "";
    position: absolute;
    z-index: 1;
    top: var(--ims-timeline-axis-y);
    left: var(--ims-timeline-label-width);
    width: var(--ims-timeline-line-width);
    height: calc(100% + var(--ims-timeline-row-gap));
    transform: translateX(-50%);
    pointer-events: none;
    background: var(--ims-timeline-line-color);
}

/*
 * Kurze Fortsetzung oberhalb des ersten Punkts.
 * Durch overflow:hidden am Widget kann die Linie nie außerhalb des Widgets laufen.
 */
.ims-timeline__item:first-child::after {
    content: "";
    position: absolute;
    z-index: 1;
    top: calc(var(--ims-timeline-axis-y) - var(--ims-timeline-top-extension));
    left: var(--ims-timeline-label-width);
    width: var(--ims-timeline-line-width);
    height: var(--ims-timeline-top-extension);
    transform: translateX(-50%);
    pointer-events: none;
    background: var(--ims-timeline-line-color);
}

.ims-timeline__period {
    padding-top: 20px;
    padding-right: 18px;
    color: var(--e-global-color-primary);
    font-weight: 500;
    font-size: 24px;
    text-align: left;
}

/* Achse, Punkt und waagerechter Connector sind unabhängig von der Karte. */
.ims-timeline__axis {
    position: absolute;
    top: var(--ims-timeline-axis-y);
    left: var(--ims-timeline-label-width);
    z-index: 3;
    width: var(--ims-timeline-card-gap);
    height: 0;
    pointer-events: none;
}

.ims-timeline__dot {
    position: absolute;
    z-index: 2;
    top: 0;
    left: 0;
    width: var(--ims-timeline-dot-size);
    height: var(--ims-timeline-dot-size);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: var(--ims-timeline-dot-color);
    box-shadow: 0 0 0 4px var(--ims-timeline-dot-ring-color);
}

/* Optionale, bewusst dezente Punkt-Animationen. */
.ims-timeline--dot-pulse .ims-timeline__dot {
    animation: ims-timeline-dot-pulse var(--ims-timeline-dot-animation-duration) ease-in-out infinite;
}

.ims-timeline--dot-fade .ims-timeline__dot {
    animation: ims-timeline-dot-fade var(--ims-timeline-dot-animation-duration) ease-in-out infinite;
}

@keyframes ims-timeline-dot-pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        filter: brightness(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.16);
        filter: brightness(1.12);
    }
}

@keyframes ims-timeline-dot-fade {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.48; }
}

@media (prefers-reduced-motion: reduce) {
    .ims-timeline--dot-pulse .ims-timeline__dot,
    .ims-timeline--dot-fade .ims-timeline__dot {
        animation: none !important;
    }
}

.ims-timeline.has-connector .ims-timeline__axis::after {
    content: "";
    position: absolute;
    z-index: 1;
    top: calc(var(--ims-timeline-connector-width) / -2);
    left: 0;
    width: var(--ims-timeline-card-gap);
    height: var(--ims-timeline-connector-width);
    background: var(--ims-timeline-connector-color);
    pointer-events: none;
}

.ims-timeline.no-connector .ims-timeline__axis::after {
    display: none;
}

/* =========================================================
 * LINIEN- & PUNKTSTILE
 * ======================================================= */

/* Glow (Standard): weiche Lichtkante und dezenter Punkt-Glow. */
.ims-timeline--glow .ims-timeline__item:not(:last-child)::before,
.ims-timeline--glow .ims-timeline__item:first-child::after {
    background: var(--ims-timeline-line-color);
    box-shadow: 0 0 10px color-mix(in srgb, var(--ims-timeline-line-color) 48%, transparent);
}

.ims-timeline--glow .ims-timeline__dot {
    box-shadow:
        0 0 0 4px var(--ims-timeline-dot-ring-color),
        0 0 12px color-mix(in srgb, var(--ims-timeline-dot-color) 50%, transparent);
}

/* Soft Fade: die vertikale Linie läuft permanent weich in geringere Deckkraft aus. */
.ims-timeline--fade .ims-timeline__item:not(:last-child)::before {
    background: linear-gradient(
        to bottom,
        color-mix(in srgb, var(--ims-timeline-line-color) 92%, transparent) 0%,
        color-mix(in srgb, var(--ims-timeline-line-color) 68%, transparent) 68%,
        color-mix(in srgb, var(--ims-timeline-line-color) 18%, transparent) 100%
    );
}

.ims-timeline--fade .ims-timeline__item:first-child::after {
    background: linear-gradient(
        to bottom,
        transparent 0%,
        color-mix(in srgb, var(--ims-timeline-line-color) 38%, transparent) 38%,
        color-mix(in srgb, var(--ims-timeline-line-color) 92%, transparent) 100%
    );
}

.ims-timeline--fade .ims-timeline__dot {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ims-timeline-dot-ring-color) 78%, transparent);
}

.ims-timeline--fade.has-connector .ims-timeline__axis::after {
    background: linear-gradient(
        to right,
        var(--ims-timeline-connector-color),
        color-mix(in srgb, var(--ims-timeline-connector-color) 34%, transparent)
    );
}

/* Klar / Solid: ruhige, präzise Linie ohne Glow. */
.ims-timeline--solid .ims-timeline__item:not(:last-child)::before,
.ims-timeline--solid .ims-timeline__item:first-child::after {
    background: var(--ims-timeline-line-color);
    box-shadow: none;
}

.ims-timeline--solid .ims-timeline__dot {
    box-shadow: 0 0 0 2px var(--ims-timeline-dot-ring-color);
}

/* Fein gestrichelt: kleinere, ruhigere Striche. */
.ims-timeline--dashed .ims-timeline__item:not(:last-child)::before,
.ims-timeline--dashed .ims-timeline__item:first-child::after {
    background: repeating-linear-gradient(
        to bottom,
        var(--ims-timeline-line-color) 0 7px,
        transparent 7px 13px
    );
}

.ims-timeline--dashed .ims-timeline__dot {
    background: var(--ims-timeline-dot-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ims-timeline-dot-ring-color) 80%, transparent);
}

/* Fein gepunktet: kurze Lichtpunkte statt grober Segmente. */
.ims-timeline--dotted .ims-timeline__item:not(:last-child)::before,
.ims-timeline--dotted .ims-timeline__item:first-child::after {
    background: repeating-linear-gradient(
        to bottom,
        var(--ims-timeline-line-color) 0 2px,
        transparent 2px 7px
    );
}

.ims-timeline--dotted .ims-timeline__dot {
    background: transparent;
    border: 2px solid var(--ims-timeline-dot-color);
    box-shadow: 0 0 0 2px var(--ims-timeline-dot-ring-color);
}

/* Doppellinie: zwei schlanke parallele Linien mit Doppelring am Punkt. */
.ims-timeline--double {
    --ims-timeline-double-gap: 4px;
}

.ims-timeline--double .ims-timeline__item:not(:last-child)::before,
.ims-timeline--double .ims-timeline__item:first-child::after {
    width: calc((var(--ims-timeline-line-width) * 2) + var(--ims-timeline-double-gap));
    background: linear-gradient(
        to right,
        var(--ims-timeline-line-color) 0 var(--ims-timeline-line-width),
        transparent var(--ims-timeline-line-width) calc(var(--ims-timeline-line-width) + var(--ims-timeline-double-gap)),
        var(--ims-timeline-line-color) calc(var(--ims-timeline-line-width) + var(--ims-timeline-double-gap)) 100%
    );
}

.ims-timeline--double .ims-timeline__dot {
    background: var(--ims-timeline-dot-color);
    box-shadow:
        0 0 0 2px var(--ims-timeline-dot-ring-color),
        0 0 0 5px color-mix(in srgb, var(--ims-timeline-dot-ring-color) 45%, transparent);
}

/* Segmentiert: markantere, aber gleichmäßige Abschnitte. */
.ims-timeline--segmented .ims-timeline__item:not(:last-child)::before,
.ims-timeline--segmented .ims-timeline__item:first-child::after {
    background: repeating-linear-gradient(
        to bottom,
        var(--ims-timeline-line-color) 0 12px,
        transparent 12px 20px
    );
}

.ims-timeline--segmented .ims-timeline__dot {
    background: transparent;
    border: 2px solid var(--ims-timeline-dot-color);
    box-shadow: 0 0 0 3px var(--ims-timeline-dot-ring-color);
}

/* Connector übernimmt bei den strukturierten Varianten denselben Charakter. */
.ims-timeline--dashed.has-connector .ims-timeline__axis::after {
    background: repeating-linear-gradient(
        to right,
        var(--ims-timeline-connector-color) 0 7px,
        transparent 7px 13px
    );
}

.ims-timeline--dotted.has-connector .ims-timeline__axis::after {
    background: repeating-linear-gradient(
        to right,
        var(--ims-timeline-connector-color) 0 2px,
        transparent 2px 7px
    );
}

.ims-timeline--segmented.has-connector .ims-timeline__axis::after {
    background: repeating-linear-gradient(
        to right,
        var(--ims-timeline-connector-color) 0 12px,
        transparent 12px 20px
    );
}

.ims-timeline-card {
    grid-column: 2;
    justify-self: start;
    width: min(var(--ims-timeline-card-width), 100%);
    max-width: 100%;
    position: relative;
    z-index: 2;
    min-width: 0;
    min-height: 100%;
    display: block;
    padding: 22px 26px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(67, 57, 70, 0.96), rgba(38, 31, 42, 0.96));
    border: 1px solid rgba(175, 120, 225, 0.20);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.16);
    color: inherit;
    text-decoration: none;
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.ims-timeline-card:hover,
.ims-timeline-card:focus {
    color: inherit;
    text-decoration: none;
}

/* Nur die Karte bewegt sich. Achse, Punkt und Connector bleiben statisch. */
@media (hover: hover) {
    .ims-timeline-card:hover {
        transform: translateY(calc(-1 * var(--ims-timeline-hover-lift)));
        border-color: rgba(175, 120, 225, 0.48);
        box-shadow: 0 16px 38px rgba(0, 0, 0, 0.22), 0 0 22px rgba(175, 120, 225, 0.08);
    }
}

.ims-timeline-card__title {
    margin: 0 0 24px;
    padding: 0;
}

.ims-timeline-card__title a {
    color: inherit;
    text-decoration: none;
}

.ims-timeline-card__content {
    min-width: 0;
}

.ims-timeline-card__content > :first-child {
    margin-top: 0;
}

.ims-timeline-card__content > :last-child {
    margin-bottom: 0;
}

.ims-timeline-card__content h2,
.ims-timeline-card__content h3,
.ims-timeline-card__content h4 {
    margin: var(--ims-timeline-year-gap) 0 10px;
    padding: 0;
    color: var(--e-global-color-primary);
}

.ims-timeline-card__content > h2:first-child,
.ims-timeline-card__content > h3:first-child,
.ims-timeline-card__content > h4:first-child {
    margin-top: 0;
}

.ims-timeline-card__content ul {
    list-style: none;
    margin: 0 0 8px 10px;
    padding: 0;
}

.ims-timeline-card__content li {
    position: relative;
    margin: 0 0 8px 12px;
    padding-left: 34px;
}

.ims-timeline-card__content li:last-child {
    margin-bottom: 0;
}

.ims-timeline-card__content li::before {
    content: "✓";
    position: absolute;
    left: 0;
    top: 0;
    color: var(--e-global-color-primary);
    font-weight: 500;
    line-height: inherit;
}

/* Theme-Heading-Regeln nur innerhalb dieses Widgets neutralisieren. */
.elementor-widget-ims-timeline .ims-timeline-card__title,
.elementor-widget-ims-timeline .ims-timeline-card__content h2,
.elementor-widget-ims-timeline .ims-timeline-card__content h3,
.elementor-widget-ims-timeline .ims-timeline-card__content h4 {
    font-size: 27px;
    line-height: normal;
    font-weight: 400;
}
.elementor-widget-ims-timeline .ims-timeline-card__content h4 {
    font-size: 27px !important;
    line-height: normal;
    font-weight: 500;
    margin-top: 40px;
}

@media (max-width: 767px) {
    /*
     * Mobil immer die komplette verfügbare Breite nutzen.
     * So werden Desktop-Breiten/Ausrichtungen nicht versehentlich auf Mobil vererbt.
     */
    .elementor-widget-ims-timeline > .elementor-widget-container {
        width: 100%;
        max-width: 100%;
        display: block !important;
    }

    .elementor-widget-ims-timeline .ims-timeline {
        --ims-timeline-label-width: 18px;
        --ims-timeline-card-gap: 18px;
        --ims-timeline-card-width: 100%;
        --ims-timeline-row-gap: 24px;
        --ims-timeline-axis-y: 10px;

        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .ims-timeline__item {
        width: 100%;
        min-width: 0;
        grid-template-columns: var(--ims-timeline-label-width) minmax(0, 1fr);
    }

    .ims-timeline__period {
        grid-column: 2;
        grid-row: 1;
        min-width: 0;
        padding: 0 0 10px;
        overflow-wrap: normal;
        word-break: normal;
    }

    .ims-timeline__axis {
        top: var(--ims-timeline-axis-y);
    }

    .ims-timeline__item:not(:last-child)::before {
        top: var(--ims-timeline-axis-y);
    }

    .ims-timeline-card {
        grid-column: 2;
        grid-row: 2;
        justify-self: stretch;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0;
        box-sizing: border-box;
    }

    /* Theme-Regeln dürfen lange Wörter auf Mobil nicht mitten im Wort umbrechen. */
    .ims-timeline-card__title,
    .ims-timeline-card__content,
    .ims-timeline-card__content p,
    .ims-timeline-card__content li,
    .ims-timeline-card__content h2,
    .ims-timeline-card__content h3,
    .ims-timeline-card__content h4 {
        min-width: 0;
        overflow-wrap: normal !important;
        word-break: normal !important;
        hyphens: manual;
    }
}
