/**
 * Chinnegar Horizontal Timeline Styles
 * Merics-style Alternating Horizontal Timeline Component
 */

/* Container and CSS Custom Properties */
.cn-timeline-module {
    --tl-accent: #c1121f;
    --tl-accent-dark: #991b1b;
    --tl-accent-light: #fef2f2;
    --tl-accent-border: #fca5a5;
    --tl-axis-color: #cbd5e1;
    --tl-card-bg: #ffffff;
    --tl-card-border: #e2e8f0;
    --tl-text-main: #1e293b;
    --tl-text-muted: #64748b;
    
    position: relative;
    width: 100%;
    margin: 40px auto 60px;
    padding: 30px;
    background: #ffffff;
    border: 1px solid var(--tl-card-border);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
    box-sizing: border-box;
    font-family: inherit;
    direction: rtl;
    text-align: right;
    overflow: hidden;
}

/* ========================================================================= */
/* HEADER & CONTROLS                                                         */
/* ========================================================================= */
.cn-tl-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--tl-card-border);
    margin-bottom: 20px;
}

.cn-tl-title-group {
    flex: 1 1 300px;
}

.cn-tl-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--tl-accent-light);
    color: var(--tl-accent);
    border: 1px solid var(--tl-accent-border);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 8px;
}

.cn-tl-title {
    font-size: 22px;
    font-weight: 900;
    color: var(--tl-text-main);
    margin: 0 0 6px 0;
    line-height: 1.3;
}

.cn-tl-subtitle {
    font-size: 13.5px;
    color: var(--tl-text-muted);
    margin: 0;
    line-height: 1.6;
}

.cn-tl-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.cn-tl-step-info {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--tl-text-muted);
    background: #f8fafc;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.cn-tl-nav-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cn-tl-nav-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #ffffff;
    border: 1.5px solid var(--tl-card-border);
    color: var(--tl-text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.cn-tl-nav-btn:hover {
    background: var(--tl-accent);
    border-color: var(--tl-accent);
    color: #ffffff;
    transform: scale(1.06);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.cn-tl-nav-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #94a3b8;
}

/* Categories Legend Bar */
.cn-tl-legend-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 25px;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid #f1f5f9;
}

.cn-tl-legend-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--tl-text-muted);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.cn-tl-legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.cn-tl-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--tl-text-main);
}

.cn-tl-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ========================================================================= */
/* HORIZONTAL VIEWPORT & TRACK                                               */
/* ========================================================================= */
.cn-tl-viewport {
    position: relative;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 20px 10px;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    scrollbar-width: thin;
    scrollbar-color: var(--tl-accent-border) #f1f5f9;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
}

.cn-tl-viewport.is-dragging {
    cursor: grabbing;
    scroll-behavior: auto;
}

.cn-tl-viewport::-webkit-scrollbar {
    height: 6px;
}

.cn-tl-viewport::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

.cn-tl-viewport::-webkit-scrollbar-thumb {
    background: var(--tl-accent-border);
    border-radius: 10px;
}

.cn-tl-viewport::-webkit-scrollbar-thumb:hover {
    background: var(--tl-accent);
}

.cn-tl-track {
    position: relative;
    display: inline-block;
    min-width: 100%;
    height: 520px;
    padding: 0 30px;
    box-sizing: border-box;
}

/* Central Horizontal Axis Line */
.cn-tl-axis {
    position: absolute;
    top: 260px;
    left: 0;
    right: 0;
    height: 4px;
    z-index: 2;
    pointer-events: none;
}

.cn-tl-axis-line {
    width: 100%;
    height: 100%;
    background: linear-gradient(to left, #e2e8f0 0%, var(--tl-accent-border) 50%, #e2e8f0 100%);
    border-radius: 2px;
}

/* Event Slots */
.cn-tl-slots {
    display: flex;
    position: relative;
    z-index: 3;
    gap: 30px;
    height: 100%;
}

.cn-tl-slot {
    position: relative;
    width: 310px;
    flex: 0 0 310px;
    height: 100%;
    box-sizing: border-box;
    scroll-snap-align: center;
}

/* Card Wrapper */
.cn-tl-card-wrap {
    position: absolute;
    width: 100%;
    height: 200px;
    left: 0;
    right: 0;
    z-index: 5;
}

.cn-tl-slot.pos-top .cn-tl-card-wrap {
    top: 10px;
}

.cn-tl-slot.pos-bottom .cn-tl-card-wrap {
    top: 310px;
}

/* The Card */
.cn-tl-card {
    position: relative;
    height: 100%;
    background: #ffffff;
    border: 1px solid var(--tl-card-border);
    border-top: 4px solid var(--item-color, var(--tl-accent));
    border-radius: 12px;
    padding: 15px 18px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
    transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1), box-shadow 0.3s ease, border-color 0.3s ease;
}

.cn-tl-slot.pos-top .cn-tl-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
}

.cn-tl-slot.pos-bottom .cn-tl-card:hover {
    transform: translateY(6px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
}

.cn-tl-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.cn-tl-card-badge {
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
    line-height: 1.3;
}

.cn-tl-card-year {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    color: var(--tl-text-muted);
}

.cn-tl-card-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cn-tl-card-title {
    font-size: 14.5px;
    font-weight: 800;
    color: var(--tl-text-main);
    margin: 0 0 6px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cn-tl-card-desc {
    font-size: 12.5px;
    color: var(--tl-text-muted);
    line-height: 1.6;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cn-tl-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px dashed #f1f5f9;
}

.cn-tl-card-index {
    font-size: 10.5px;
    font-weight: 700;
    color: #94a3b8;
}

.cn-tl-card-icon {
    font-size: 16px;
}

/* ========================================================================= */
/* CONNECTING STEM & AXIS NODE                                               */
/* ========================================================================= */
.cn-tl-stem {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    z-index: 3;
    pointer-events: none;
}

.cn-tl-slot.pos-top .cn-tl-stem {
    top: 210px;
    height: 50px;
}

.cn-tl-slot.pos-bottom .cn-tl-stem {
    top: 260px;
    height: 50px;
}

.cn-tl-stem-line {
    width: 100%;
    height: 100%;
    opacity: 0.85;
}

/* Node (Dot & Date Label) */
.cn-tl-node {
    position: absolute;
    top: 260px;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.cn-tl-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid var(--item-color, var(--tl-accent));
    box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    cursor: pointer;
}

.cn-tl-dot-inner {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--item-color, var(--tl-accent));
}

.cn-tl-slot:hover .cn-tl-dot {
    transform: scale(1.35);
    box-shadow: 0 0 0 6px rgba(0,0,0,0.08);
}

.cn-tl-axis-date {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
    background: #ffffff;
    padding: 2px 8px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
    pointer-events: none;
}

.cn-tl-slot.pos-top .cn-tl-axis-date {
    top: 22px;
}

.cn-tl-slot.pos-bottom .cn-tl-axis-date {
    bottom: 22px;
}

/* ========================================================================= */
/* MOBILE HINT & SUMMARY BOX                                                 */
/* ========================================================================= */
.cn-tl-mobile-hint {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    color: var(--tl-text-muted);
    margin: 15px 0 0 0;
    text-align: center;
}

.cn-tl-summary-box {
    margin-top: 30px;
    padding: 22px 25px;
    background: var(--tl-accent-light, #f8fafc);
    border: 1px solid var(--tl-accent-border, #e2e8f0);
    border-radius: 12px;
}

.cn-tl-summary-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
}

.cn-tl-summary-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 18px;
}

.cn-tl-summary-header h4 {
    font-size: 16px;
    font-weight: 800;
    color: var(--tl-text-main);
    margin: 0;
}

.cn-tl-summary-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cn-tl-summary-list li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13.5px;
    color: var(--tl-text-main);
    line-height: 1.6;
}

.cn-tl-summary-list li i {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}

/* ========================================================================= */
/* RESPONSIVE DESIGN                                                         */
/* ========================================================================= */
@media (max-width: 900px) {
    .cn-timeline-module {
        padding: 20px 15px;
    }
    .cn-tl-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .cn-tl-controls {
        width: 100%;
        justify-content: space-between;
    }
    .cn-tl-mobile-hint {
        display: flex;
    }
}

@media (max-width: 600px) {
    .cn-tl-slot {
        width: 270px;
        flex: 0 0 270px;
    }
    .cn-tl-card {
        padding: 12px 14px;
    }
    .cn-tl-card-title {
        font-size: 13.5px;
    }
    .cn-tl-card-desc {
        font-size: 12px;
    }
    .cn-tl-title {
        font-size: 19px;
    }
}
