/* Dove Milestones v1.8.4 — Alternating timeline with hover zoom */

/* =====================================================
   DESKTOP — horizontal scrollable timeline
   ===================================================== */
.dms-timeline {
    position: relative;
    display: grid;
    grid-template-columns: repeat(var(--dms-cols, 6), 1fr);
    grid-template-rows: 1fr 2px 1fr;
    gap: 0 16px;
    overflow: visible;
    box-sizing: border-box;
    /* Break out of any container to use full viewport, centered.
       Use max(100vw - scrollbar, 100%) to avoid horizontal overflow
       on browsers with visible scrollbars. */
    width: calc(100vw - var(--scrollbar-w, 0px));
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    padding: 40px 40px;
}

/* Horizontal timeline line via pseudo-element */
.dms-timeline::before {
    content: '';
    grid-column: 1 / -1;
    grid-row: 2;
    background: var(--dms-line-color, #8B7536);
    z-index: 1;
}

/* Individual card */
.dms-card {
    display: flex;
    flex-direction: column;
    position: relative;
    transition: transform 0.3s ease, z-index 0s;
}

/* Top card: body above the line, year at the line */
.dms-card--top {
    grid-row: 1 / 3;
    align-self: end;
    justify-content: flex-end;
}

/* Bottom card: year at the line, body below */
.dms-card--bottom {
    grid-row: 2 / 4;
    align-self: start;
    justify-content: flex-start;
}

/* Extra gap between timeline line and bottom row year */
.dms-card--bottom .dms-card__year {
    padding-top: 14px;
}

/* Gap between connector and image in bottom cards — matches top-half spacing */
.dms-card--bottom .dms-card__body .dms-card__img:first-child {
    margin-top: 14px;
}

/* Cards are clickable — subtle hover highlight on desktop */
@media (hover: hover) and (min-width: 1101px) {
    .dms-card:hover {
        cursor: pointer;
    }

    .dms-card:hover .dms-card__body {
        box-shadow: 0 4px 16px rgba(0,0,0,0.12);
        border-radius: 6px;
    }
}

/* Tap-to-zoom modal overlay for touch devices */
.dms-modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
}

.dms-modal-overlay.is-active {
    display: flex;
}

.dms-modal-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    max-width: 520px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 16px 48px rgba(0,0,0,0.25);
    animation: dmsModalIn 0.25s ease;
    align-self: center;
    flex-shrink: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

@keyframes dmsModalIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.dms-modal-card .dms-modal__year {
    font-size: 32px;
    font-weight: 700;
    color: var(--dms-line-color, #8B7536);
    margin: 0;
}

.dms-modal-card .dms-modal__img {
    margin: 0;
}

.dms-modal-card .dms-modal__text {
    margin: 0;
}

.dms-modal-card .dms-modal__img img {
    width: 100%;
    height: auto;
    max-height: 320px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}

.dms-modal-card .dms-modal__text {
    font-size: 18px;
    line-height: 1.65;
    color: #333;
    font-weight: 400;
}

/* Year label — font-size is set via inline style on the element */
.dms-timeline .dms-card__year {
    font-weight: 700;
    line-height: 1.2;
    padding: 6px 0;
    text-align: left;
    white-space: nowrap;
}

/* Vertical connector from card to timeline line */
.dms-card__connector {
    width: 2px;
    height: 20px;
    background: var(--dms-line-color, #8B7536);
    margin-left: 12px;
    flex-shrink: 0;
}

/* Card body: text + image */
.dms-card__body {
    background: var(--dms-card-bg, #ffffff);
    border-radius: 6px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    transition: background 0.3s ease, box-shadow 0.3s ease, padding 0.3s ease;
}

/* Text — desktop size from CSS variable */
.dms-timeline .dms-card__text {
    font-size: var(--dms-text-fs, 13px) !important;
    font-weight: 400 !important;
    line-height: 1.5;
}

/* Spacing between image and text */
.dms-card__img {
    margin-top: 14px;
    margin-bottom: 14px;
}

.dms-card__img:first-child {
    margin-top: 0;
}

.dms-card__img:last-child {
    margin-bottom: 0;
}

.dms-card__img img {
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

/* Both orientations fill the column width; height differentiates them */
.dms-card__img--landscape img {
    width: 100%;
    height: var(--dms-img-h, 140px);
}

.dms-card__img--portrait img {
    width: 100%;
    height: calc(var(--dms-img-h, 140px) * 1.6);
}

/* =====================================================
   SCROLL ANIMATIONS
   ===================================================== */

/* Fade up */
.dms-timeline[data-animation="fade-up"] .dms-card {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.dms-timeline[data-animation="fade-up"] .dms-card.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Fade in */
.dms-timeline[data-animation="fade-in"] .dms-card {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.dms-timeline[data-animation="fade-in"] .dms-card.is-visible {
    opacity: 1;
}

/* Scale up */
.dms-timeline[data-animation="scale-up"] .dms-card {
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.dms-timeline[data-animation="scale-up"] .dms-card.is-visible {
    opacity: 1;
    transform: scale(1);
}

/* Slide from rows — top slides down, bottom slides up */
.dms-timeline[data-animation="slide-sides"] .dms-card--top {
    opacity: 0;
    transform: translateY(-40px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.dms-timeline[data-animation="slide-sides"] .dms-card--bottom {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.dms-timeline[data-animation="slide-sides"] .dms-card.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* No animation */
.dms-timeline[data-animation="none"] .dms-card {
    opacity: 1;
}

/* Ensure animated cards stay visible after animation */
@media (hover: hover) and (min-width: 1101px) {
    .dms-timeline .dms-card.is-visible {
        transition: opacity 0.6s ease, box-shadow 0.3s ease;
    }
}

/* =====================================================
   TABLET + MOBILE — vertical center-line, cards left/right
   Year on top of each card, horizontal connector to center
   ===================================================== */
@media (max-width: 1100px) {
    .dms-timeline {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
        grid-template-rows: none !important;
        gap: 24px !important;
        padding: 30px 40px !important;
        overflow-x: visible !important;
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        position: relative;
        box-sizing: border-box !important;
    }

    /* Vertical center line */
    .dms-timeline::before {
        display: block !important;
        position: absolute !important;
        left: 50%;
        top: 0;
        bottom: 0;
        width: 2px;
        height: auto !important;
        transform: translateX(-50%);
        grid-column: auto !important;
        grid-row: auto !important;
        background: var(--dms-line-color, #8B7536);
        z-index: 0;
    }

    /* Hide the HTML connector — use ::after pseudo-element instead */
    .dms-card__connector {
        display: none !important;
    }

    /* All cards: vertical stack (year on top, body below) */
    .dms-card,
    .dms-card--top,
    .dms-card--bottom {
        flex-direction: column !important;
        align-items: stretch !important;
        align-self: auto !important;
        justify-content: flex-start !important;
        grid-row: auto !important;
        gap: 6px !important;
        position: relative;
        z-index: 1;
    }

    /* No hover zoom on vertical layout */
    .dms-card:hover {
        transform: none !important;
    }

    /* ---- LEFT cards (desktop "top") ---- */
    .dms-card--top {
        width: calc(50% - 20px) !important;
        align-self: flex-start !important;
    }

    .dms-card--top .dms-card__year {
        order: -1 !important;
        text-align: left;
        white-space: nowrap;
        padding: 0 !important;
    }

    .dms-card--top .dms-card__body {
        order: 1 !important;
    }

    /* Horizontal bridge: card right edge → center line */
    .dms-card--top::after {
        content: '';
        position: absolute;
        right: -20px;
        top: 12px;
        width: 20px;
        height: 2px;
        background: var(--dms-line-color, #8B7536);
    }

    /* ---- RIGHT cards (desktop "bottom") ---- */
    .dms-card--bottom {
        width: calc(50% - 20px) !important;
        align-self: flex-end !important;
    }

    .dms-card--bottom .dms-card__year {
        order: 0 !important;
        text-align: left;
        white-space: nowrap;
        padding: 0 !important;
    }

    .dms-card--bottom .dms-card__body {
        order: 1 !important;
    }

    /* Horizontal bridge: center line → card left edge */
    .dms-card--bottom::after {
        content: '';
        position: absolute;
        left: -20px;
        top: 12px;
        width: 20px;
        height: 2px;
        background: var(--dms-line-color, #8B7536);
    }

    .dms-timeline .dms-card__year {
        font-size: var(--dms-year-fs-tab, 24px) !important;
    }

    .dms-timeline .dms-card__text {
        font-size: var(--dms-text-fs-tab, 13px) !important;
    }

    .dms-card__img img {
        height: auto !important;
        max-height: 200px !important;
        width: 100% !important;
    }
}

/* =====================================================
   MOBILE — more padding, tighter content
   ===================================================== */
@media screen and (max-width: 767px) {
    .dms-timeline,
    .dms-timeline.dms-timeline {
        padding: 20px 10px !important;
        gap: 20px !important;
        width: 100% !important;
        margin-left: 0 !important;
    }

    .dms-card--top,
    .dms-card--bottom {
        width: calc(50% - 16px) !important;
    }

    .dms-card--top::after,
    .dms-card--bottom::after {
        width: 16px !important;
    }

    .dms-card--top::after {
        right: -16px !important;
    }

    .dms-card--bottom::after {
        left: -16px !important;
    }

    .dms-timeline .dms-card__year {
        font-size: var(--dms-year-fs-mob, 20px) !important;
    }

    .dms-timeline .dms-card__text {
        font-size: var(--dms-text-fs-mob, 12px) !important;
    }

    .dms-card__img img {
        max-height: 160px !important;
    }
}
