/**
 * Horizontal Timeline Styles
 * 
 */

/* ==========================================================================
   Base Styles
   ========================================================================== */

.elematic-htl-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.elematic-htl-container {
    overflow-x: auto;
    overflow-y: visible;
    flex: 1;
    padding: 20px 0;
    scroll-snap-type: x mandatory;
}

.elematic-htl-hide-scrollbar .elematic-htl-container {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.elematic-htl-hide-scrollbar .elematic-htl-container::-webkit-scrollbar {
    display: none;
}

.elematic-htl-track {
    position: relative;
    display: inline-flex;
    min-width: 100%;
}

/* Timeline Line */
.elematic-htl-line-wrapper {
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 1;
    width: 100%;
}

.elematic-htl-line {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 100%;
    background-color: #e0e0e0;
    width: 100%;
}

.elematic-htl-line-progress {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background-color: #6c5ce7;
    transition: width 0.3s ease;
}

/* Items Container */
.elematic-htl-items {
    display: flex;
    position: relative;
    z-index: 2;
    width: 100%;
}

/* Single Item */
.elematic-htl-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 280px;
    padding: 0 15px;
    position: relative;
    scroll-snap-align: start;
}

/* Marker/Icon */
.elematic-htl-marker {
    position: relative;
    z-index: 3;
    flex-shrink: 0;
}

.elematic-htl-icon {
    width: 50px;
    height: 50px;
    background-color: #6c5ce7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.elematic-htl-icon i {
    font-size: 18px;
    color: #ffffff;
    line-height: 1;
}

.elematic-htl-icon svg {
    width: 18px;
    height: 18px;
    fill: #ffffff;
}

.elematic-htl-item:hover .elematic-htl-icon {
    transform: scale(1.1);
}

/* Avatar Image */
.elematic-htl-avatar-img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #e91e8c;
    transition: all 0.3s ease;
}

.elematic-htl-item:hover .elematic-htl-avatar-img {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

/* Content */
.elematic-htl-content {
    max-width: 260px;
    position: relative;
}

.elematic-htl-date {
    font-size: 14px;
    color: #636e72;
    margin-bottom: 10px;
}

.elematic-htl-title {
    font-size: 18px;
    font-weight: 600;
    color: #2d3436;
    margin: 0 0 8px 0;
    line-height: 1.4;
    transition: color 0.3s ease;
}

.elematic-htl-content a {
    text-decoration: none;
}

.elematic-htl-content a:hover .elematic-htl-title {
    color: #6c5ce7;
}

.elematic-htl-desc {
    font-size: 14px;
    color: #636e72;
    margin: 0;
    line-height: 1.6;
}

/* Card with Image */
.elematic-htl-card-image {
    height: 160px;
    overflow: hidden;
    margin: -20px -20px 15px -20px;
    border-radius: 8px 8px 0 0;
}

.elematic-htl-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ==========================================================================
   Style 1 - Basic Content Below with Image
   ========================================================================== */
.elematic-htl-style-1 .elematic-htl-container {
    padding-top: 40px;
    padding-bottom: 20px;
}

.elematic-htl-style-1 .elematic-htl-line-wrapper {
    top: 25px;
}

.elematic-htl-style-1 .elematic-htl-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.elematic-htl-style-1 .elematic-htl-marker {
    order: 1;
}

.elematic-htl-style-1 .elematic-htl-content {
    order: 2;
    margin-top: 20px;
    padding: 20px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.elematic-htl-style-1 .elematic-htl-card-image {
    margin: -20px -20px 15px -20px;
}

.elematic-htl-style-1 .elematic-htl-card-body {
    /* padding inherited from content */
}

/* ==========================================================================
   Style 2 - Avatar Highlighted (Line Through Avatar Center)
   ========================================================================== */
.elematic-htl-style-2 .elematic-htl-container {
    padding: 30px 0;
}

.elematic-htl-style-2 .elematic-htl-track {
    position: relative;
}

.elematic-htl-style-2 .elematic-htl-line-wrapper {
    top: calc(44px + 15px + 40px); /* date height (44px for 2 lines) + margin(15px) + half-avatar(40px) = 99px */
}

.elematic-htl-style-2 .elematic-htl-line {
    background-color: #d0d0d0;
}

.elematic-htl-style-2 .elematic-htl-item {
    flex-direction: column;
    text-align: center;
    position: relative;
    align-items: center;
}

.elematic-htl-style-2 .elematic-htl-date {
    order: 1;
    margin-bottom: 15px;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.4;
    color: #636e72;
    min-height: 44px; /* Ensure consistent height for 2-line dates */
    display: flex;
    align-items: center;
    justify-content: center;
}

.elematic-htl-style-2 .elematic-htl-marker {
    order: 2;
    position: relative;
    z-index: 3;
}

.elematic-htl-style-2 .elematic-htl-avatar-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #e91e8c;
    position: relative;
    z-index: 2;
    background: #ffffff;
    box-sizing: border-box;
}

.elematic-htl-style-2 .elematic-htl-icon {
    width: 80px;
    height: 80px;
    position: relative;
    z-index: 2;
    background: linear-gradient(135deg, #e91e8c 0%, #6c5ce7 100%);
}

.elematic-htl-style-2 .elematic-htl-icon i {
    font-size: 32px;
    color: #ffffff;
}

.elematic-htl-style-2 .elematic-htl-content {
    order: 3;
    margin-top: 15px;
    padding: 0;
    background: transparent;
    box-shadow: none;
    text-align: center;
    max-width: none;
}

.elematic-htl-style-2 .elematic-htl-title {
    font-size: 16px;
    font-weight: 400;
    color: #2d3436;
    margin-bottom: 0;
}

.elematic-htl-style-2 .elematic-htl-highlight {
    color: #e91e8c;
    font-weight: 700;
}

/* ==========================================================================
   Style 3 - Content Above with Image
   ========================================================================== */
.elematic-htl-style-3 .elematic-htl-container {
    padding-top: 20px;
    padding-bottom: 40px;
}

.elematic-htl-style-3 .elematic-htl-line-wrapper {
    bottom: 25px;
    top: auto;
}

.elematic-htl-style-3 .elematic-htl-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}

.elematic-htl-style-3 .elematic-htl-marker {
    order: 2;
}

.elematic-htl-style-3 .elematic-htl-content {
    order: 1;
    margin-top: 0;
    margin-bottom: 20px;
    padding: 20px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.elematic-htl-style-3 .elematic-htl-card-image {
    margin: -20px -20px 15px -20px;
}

/* ==========================================================================
   Style 4 - Card with Pointer + Icon on Line
   ========================================================================== */
.elematic-htl-style-4 .elematic-htl-container {
    padding-top: 20px;
    padding-bottom: 80px;
}

.elematic-htl-style-4 .elematic-htl-line-wrapper {
    bottom: 25px;
    top: auto;
}

.elematic-htl-style-4 .elematic-htl-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.elematic-htl-style-4 .elematic-htl-content {
    order: 1;
    margin-bottom: 15px;
    padding: 0;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    overflow: visible;
    position: relative;
}

.elematic-htl-style-4 .elematic-htl-card-body {
    padding: 20px;
}

.elematic-htl-style-4 .elematic-htl-card-image {
    margin: 0;
    border-radius: 8px 8px 0 0;
}

/* Pointer Arrow */
.elematic-htl-style-4 .elematic-htl-content::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid #ffffff;
}

.elematic-htl-style-4 .elematic-htl-marker {
    order: 2;
}

.elematic-htl-style-4 .elematic-htl-icon {
    width: 40px;
    height: 40px;
}

.elematic-htl-style-4 .elematic-htl-icon i {
    font-size: 16px;
}



/* ==========================================================================
   Navigation
   ========================================================================== */
.elematic-htl-nav {
    width: 40px;
    height: 40px;
    border: 1px solid #e8e8e8;
    background-color: transparent;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #b2b2b2;
    flex-shrink: 0;
    z-index: 5;
}

.elematic-htl-nav:hover {
    color: #6c5ce7;
    border-color: #6c5ce7;
}

.elematic-htl-nav:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.elematic-htl-nav i {
    font-size: 14px;
    line-height: 1;
}

/* ==========================================================================
   Scrollbar Styling
   ========================================================================== */
.elematic-htl-container::-webkit-scrollbar {
    height: 6px;
}

.elematic-htl-container::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 3px;
}

.elematic-htl-container::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 3px;
}

.elematic-htl-container::-webkit-scrollbar-thumb:hover {
    background: #b0b0b0;
}

/* ==========================================================================
   Animation
   ========================================================================== */
.elematic-htl-item {
    opacity: 0;
    animation: txHtlFadeIn 0.5s ease forwards;
}

.elematic-htl-item:nth-child(1) { animation-delay: 0.1s; }
.elematic-htl-item:nth-child(2) { animation-delay: 0.2s; }
.elematic-htl-item:nth-child(3) { animation-delay: 0.3s; }
.elematic-htl-item:nth-child(4) { animation-delay: 0.4s; }
.elematic-htl-item:nth-child(5) { animation-delay: 0.5s; }
.elematic-htl-item:nth-child(6) { animation-delay: 0.6s; }
.elematic-htl-item:nth-child(7) { animation-delay: 0.7s; }
.elematic-htl-item:nth-child(8) { animation-delay: 0.8s; }

@keyframes txHtlFadeIn {
    to {
        opacity: 1;
    }
}

/* ==========================================================================
   Touch / Scroll Enhancement
   ========================================================================== */

.elematic-htl-container {
    -webkit-overflow-scrolling: touch; /* Momentum scrolling on iOS */
    touch-action: pan-x;              /* Prioritise horizontal swipe over browser gestures */
    scroll-behavior: smooth;
}

/* ==========================================================================
   Responsive — Tablet  (768px – 1024px)
   ========================================================================== */

@media (max-width: 1024px) and (min-width: 768px) {
    .elematic-htl-item {
        min-width: 240px !important;
        padding: 0 12px;
    }

    .elematic-htl-content {
        max-width: 220px;
    }

    /* Style 4 padding reduce */
    .elematic-htl-style-4 .elematic-htl-container {
        padding-bottom: 60px;
    }
}

/* ==========================================================================
   Responsive — Mobile  (≤ 767px)
   ========================================================================== */

@media (max-width: 767px) {
    /* Keep the wrapper as a row so the horizontal track stays intact.
       Nav buttons are simply hidden; the user scrolls/swipes instead. */
    .elematic-htl-wrapper {
        flex-direction: row;
        align-items: center;
    }

    .elematic-htl-nav {
        display: none;
    }

    /* ── Items — one per screen ── */
    .elematic-htl-item {
        min-width: calc(100vw - 60px) !important;
        padding: 0 10px;
        scroll-snap-align: start;
    }

    /* Content box matches item width */
    .elematic-htl-content {
        max-width: calc(100vw - 80px);
    }

    /* ── Typography ── */
    .elematic-htl-title {
        font-size: 14px;
    }

    .elematic-htl-desc {
        font-size: 12px;
        line-height: 1.5;
    }

    .elematic-htl-date {
        font-size: 12px;
    }

    /* ── Card Image — proportional height ── */
    .elematic-htl-card-image {
        height: 110px;
    }

    /* ── Style 1 ── */
    .elematic-htl-style-1 .elematic-htl-content {
        padding: 14px;
    }

    .elematic-htl-style-1 .elematic-htl-card-image {
        margin: -14px -14px 12px -14px;
    }
    .elematic-htl-style-2 .elematic-htl-avatar-img,
    .elematic-htl-style-2 .elematic-htl-icon {
        width: 56px;
        height: 56px;
    }

    /* Recalculate: date area (auto height, flex-aligned) + margin 12px + half avatar 28px */
    .elematic-htl-style-2 .elematic-htl-line-wrapper {
        top: calc(var(--htl-date-height, 40px) + 12px + 28px);
    }

    .elematic-htl-style-2 .elematic-htl-date {
        font-size: 12px;
        margin-bottom: 12px;
        /* Let date grow naturally; JS will compute var(--htl-date-height) if needed */
        min-height: 36px;
    }

    .elematic-htl-style-2 .elematic-htl-title {
        font-size: 12px;
    }

    .elematic-htl-style-2 .elematic-htl-content {
        margin-top: 10px;
        max-width: none; /* Style 2 content is centered text, no card box */
    }

    .elematic-htl-style-2 .elematic-htl-icon i {
        font-size: 22px;
    }

    /* ── Style 3 ── */
    .elematic-htl-style-3 .elematic-htl-content {
        padding: 14px;
    }

    .elematic-htl-style-3 .elematic-htl-card-image {
        margin: -14px -14px 12px -14px;
    }

    .elematic-htl-style-3 .elematic-htl-container {
        padding-bottom: 30px;
    }

    /* ── Style 4 ── */
    .elematic-htl-style-4 .elematic-htl-container {
        padding-bottom: 55px; /* reduce excessive bottom gap */
    }

    .elematic-htl-style-4 .elematic-htl-card-body {
        padding: 14px;
    }

    .elematic-htl-style-4 .elematic-htl-content::after {
        bottom: -8px;
        border-left-width: 8px;
        border-right-width: 8px;
        border-top-width: 8px;
    }

    .elematic-htl-style-4 .elematic-htl-icon {
        width: 36px;
        height: 36px;
    }

    .elematic-htl-style-4 .elematic-htl-icon i {
        font-size: 14px;
    }
}

/* ==========================================================================
   Responsive — Extra Small  (≤ 480px)
   ========================================================================== */

@media (max-width: 480px) {
    .elematic-htl-item {
        min-width: calc(100vw - 50px) !important;
        padding: 0 8px;
    }

    .elematic-htl-content {
        max-width: calc(100vw - 66px);
    }

    .elematic-htl-title {
        font-size: 13px;
    }

    .elematic-htl-desc {
        font-size: 11px;
    }

    .elematic-htl-date {
        font-size: 11px;
    }

    .elematic-htl-card-image {
        height: 90px;
    }

    /* Style 1 & 3 tighter padding */
    .elematic-htl-style-1 .elematic-htl-content,
    .elematic-htl-style-3 .elematic-htl-content {
        padding: 10px;
    }

    .elematic-htl-style-1 .elematic-htl-card-image,
    .elematic-htl-style-3 .elematic-htl-card-image {
        margin: -10px -10px 10px -10px;
    }

    /* Style 2 smaller avatar */
    .elematic-htl-style-2 .elematic-htl-avatar-img,
    .elematic-htl-style-2 .elematic-htl-icon {
        width: 48px;
        height: 48px;
    }

    .elematic-htl-style-2 .elematic-htl-line-wrapper {
        top: calc(var(--htl-date-height, 36px) + 10px + 24px);
    }

    .elematic-htl-style-2 .elematic-htl-date {
        min-height: 32px;
        margin-bottom: 10px;
    }

    /* Style 4 */
    .elematic-htl-style-4 .elematic-htl-card-body {
        padding: 10px;
    }

    .elematic-htl-style-4 .elematic-htl-container {
        padding-bottom: 50px;
    }
}

/* ==========================================================================
   RTL Support
   ========================================================================== */
[dir="rtl"] .elematic-htl-wrapper {
    direction: rtl;
}

[dir="rtl"] .elematic-htl-nav-prev i::before {
    content: "\e879";
}

[dir="rtl"] .elematic-htl-nav-next i::before {
    content: "\e878";
}