/* Hurpedia Tidslinje v1.0.0 */

.hp-tl-root {
    --hptl-primary: #3377bb;
    --hptl-primary-dark: #2a5f93;
    --hptl-primary-soft: #eef5fc;
    --hptl-accent: #0d9551;
    --hptl-accent-soft: #e8f5ee;
    --hptl-amber: #f59e0b;
    --hptl-amber-soft: #fef3c7;
    --hptl-purple: #7c3aed;
    --hptl-purple-soft: #ede9fe;
    --hptl-warning: #dc2626;
    --hptl-warning-soft: #fee2e2;
    --hptl-bg: #faf9f7;
    --hptl-card: #ffffff;
    --hptl-text: #1f2937;
    --hptl-muted: #6b7280;
    --hptl-border: #e5e7eb;

    /* Kategori-färger */
    --hptl-c-grundande: #0d9551;
    --hptl-c-fordrag: #3377bb;
    --hptl-c-utvidgning: #f59e0b;
    --hptl-c-brexit: #dc2626;
    --hptl-c-reform: #7c3aed;
    --hptl-c-riksdag: #3377bb;
    --hptl-c-rosträtt: #0d9551;
    --hptl-c-nutid: #6b7280;

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--hptl-text);
    background: var(--hptl-bg);
    border: 1px solid var(--hptl-border);
    border-radius: 12px;
    padding: 20px;
    margin: 24px 0;
    box-sizing: border-box;
    max-width: 100%;
    overflow-x: hidden;
}

.hp-tl-root *,
.hp-tl-root *::before,
.hp-tl-root *::after { box-sizing: border-box; }

.hp-tl-root .hp-tl-loading {
    padding: 40px 20px;
    text-align: center;
    color: var(--hptl-muted);
    font-style: italic;
}

/* Header */
.hp-tl-root .hptl-header {
    margin: 0 0 16px;
    padding: 0 0 14px;
    border-bottom: 1px solid var(--hptl-border);
    text-align: center;
}

.hp-tl-root .hptl-title {
    margin: 0 0 4px;
    font-size: 1.2rem;
    font-weight: 700;
}

.hp-tl-root .hptl-subtitle {
    margin: 0;
    font-size: 0.88rem;
    color: var(--hptl-muted);
}

/* Filter (kategorier) */
.hp-tl-root .hptl-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-bottom: 20px;
}

.hp-tl-root .hptl-filter-btn {
    padding: 6px 14px;
    background: #fff;
    border: 1px solid var(--hptl-border);
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--hptl-muted);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.hp-tl-root .hptl-filter-btn:hover {
    background: var(--hptl-primary-soft);
    color: var(--hptl-primary-dark);
}

.hp-tl-root .hptl-filter-btn.hptl-active {
    background: var(--hptl-primary);
    color: #fff;
    border-color: var(--hptl-primary);
}

.hp-tl-root .hptl-filter-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex: 0 0 10px;
}

/* Tidslinjen */
.hp-tl-root .hptl-timeline {
    position: relative;
    padding: 8px 0 8px 70px;
}

.hp-tl-root .hptl-line {
    position: absolute;
    left: 56px;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--hptl-primary) 0%, var(--hptl-amber) 50%, var(--hptl-muted) 100%);
    border-radius: 2px;
}

.hp-tl-root .hptl-event {
    position: relative;
    padding: 0 0 20px 24px;
    transition: opacity 0.3s, transform 0.3s;
}

.hp-tl-root .hptl-event.hptl-hidden {
    opacity: 0;
    transform: translateY(-10px);
    height: 0;
    overflow: hidden;
    padding: 0;
    margin: 0;
}

.hp-tl-root .hptl-event:last-child {
    padding-bottom: 0;
}

/* Årsmarkör */
.hp-tl-root .hptl-year {
    position: absolute;
    left: -70px;
    top: 0;
    width: 56px;
    text-align: right;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--hptl-primary-dark);
    font-variant-numeric: tabular-nums;
    line-height: 1.4;
    padding-top: 6px;
}

/* Cirkelpunkt på linjen */
.hp-tl-root .hptl-dot {
    position: absolute;
    left: -16px;
    top: 8px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--hptl-primary);
    border: 3px solid var(--hptl-bg);
    z-index: 2;
}

.hp-tl-root .hptl-event[data-kat="grundande"] .hptl-dot { background: var(--hptl-c-grundande); }
.hp-tl-root .hptl-event[data-kat="fordrag"] .hptl-dot { background: var(--hptl-c-fordrag); }
.hp-tl-root .hptl-event[data-kat="utvidgning"] .hptl-dot { background: var(--hptl-c-utvidgning); }
.hp-tl-root .hptl-event[data-kat="brexit"] .hptl-dot { background: var(--hptl-c-brexit); }
.hp-tl-root .hptl-event[data-kat="reform"] .hptl-dot { background: var(--hptl-c-reform); }
.hp-tl-root .hptl-event[data-kat="riksdag"] .hptl-dot { background: var(--hptl-c-riksdag); }
.hp-tl-root .hptl-event[data-kat="rosträtt"] .hptl-dot { background: var(--hptl-c-rosträtt); }
.hp-tl-root .hptl-event[data-kat="nutid"] .hptl-dot { background: var(--hptl-c-nutid); }

/* Innehållskortet */
.hp-tl-root .hptl-card {
    background: var(--hptl-card);
    border: 1px solid var(--hptl-border);
    border-left: 4px solid var(--hptl-primary);
    border-radius: 0 8px 8px 0;
    padding: 12px 16px;
    position: relative;
}

.hp-tl-root .hptl-event[data-kat="grundande"] .hptl-card { border-left-color: var(--hptl-c-grundande); }
.hp-tl-root .hptl-event[data-kat="fordrag"] .hptl-card { border-left-color: var(--hptl-c-fordrag); }
.hp-tl-root .hptl-event[data-kat="utvidgning"] .hptl-card { border-left-color: var(--hptl-c-utvidgning); }
.hp-tl-root .hptl-event[data-kat="brexit"] .hptl-card { border-left-color: var(--hptl-c-brexit); }
.hp-tl-root .hptl-event[data-kat="reform"] .hptl-card { border-left-color: var(--hptl-c-reform); }
.hp-tl-root .hptl-event[data-kat="riksdag"] .hptl-card { border-left-color: var(--hptl-c-riksdag); }
.hp-tl-root .hptl-event[data-kat="rosträtt"] .hptl-card { border-left-color: var(--hptl-c-rosträtt); }
.hp-tl-root .hptl-event[data-kat="nutid"] .hptl-card { border-left-color: var(--hptl-c-nutid); }

.hp-tl-root .hptl-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.hp-tl-root .hptl-card-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
    flex: 1 1 auto;
    min-width: 0;
}

.hp-tl-root .hptl-card-badge {
    flex: 0 0 auto;
    padding: 3px 9px;
    background: var(--hptl-bg);
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--hptl-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.hp-tl-root .hptl-event[data-kat="grundande"] .hptl-card-badge { background: var(--hptl-accent-soft); color: var(--hptl-c-grundande); }
.hp-tl-root .hptl-event[data-kat="fordrag"] .hptl-card-badge { background: var(--hptl-primary-soft); color: var(--hptl-c-fordrag); }
.hp-tl-root .hptl-event[data-kat="utvidgning"] .hptl-card-badge { background: var(--hptl-amber-soft); color: #a16207; }
.hp-tl-root .hptl-event[data-kat="brexit"] .hptl-card-badge { background: var(--hptl-warning-soft); color: var(--hptl-c-brexit); }
.hp-tl-root .hptl-event[data-kat="reform"] .hptl-card-badge { background: var(--hptl-purple-soft); color: var(--hptl-c-reform); }
.hp-tl-root .hptl-event[data-kat="riksdag"] .hptl-card-badge { background: var(--hptl-primary-soft); color: var(--hptl-c-riksdag); }
.hp-tl-root .hptl-event[data-kat="rosträtt"] .hptl-card-badge { background: var(--hptl-accent-soft); color: var(--hptl-c-rosträtt); }
.hp-tl-root .hptl-event[data-kat="nutid"] .hptl-card-badge { background: #f3f4f6; color: var(--hptl-muted); }

.hp-tl-root .hptl-card-text {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--hptl-text);
}

.hp-tl-root .hptl-card-antal {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 10px;
    background: var(--hptl-amber-soft);
    color: #a16207;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Sammanfattning i toppen */
.hp-tl-root .hptl-summary {
    background: var(--hptl-primary-soft);
    border: 1px solid var(--hptl-primary);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    text-align: center;
    font-size: 0.92rem;
    line-height: 1.5;
}

.hp-tl-root .hptl-summary-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-top: 8px;
}

.hp-tl-root .hptl-summary-stat {
    text-align: center;
}

.hp-tl-root .hptl-summary-stat-value {
    display: block;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--hptl-primary-dark);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.hp-tl-root .hptl-summary-stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--hptl-muted);
    margin-top: 2px;
}

/* Källa */
.hp-tl-root .hptl-source {
    margin: 16px 0 0;
    font-size: 0.78rem;
    color: var(--hptl-muted);
    text-align: center;
    font-style: italic;
}

/* Kompakt-läge */
.hp-tl-root.hptl-mode-kompakt .hptl-card-text {
    display: none;
}

.hp-tl-root.hptl-mode-kompakt .hptl-card {
    padding: 8px 14px;
}

.hp-tl-root.hptl-mode-kompakt .hptl-event {
    padding-bottom: 12px;
}

/* Mobile */
@media (max-width: 600px) {
    .hp-tl-root .hptl-timeline {
        padding-left: 56px;
    }
    .hp-tl-root .hptl-line {
        left: 44px;
    }
    .hp-tl-root .hptl-year {
        left: -56px;
        width: 44px;
        font-size: 0.85rem;
    }
    .hp-tl-root .hptl-card-title { font-size: 0.95rem; }
    .hp-tl-root .hptl-card-text { font-size: 0.85rem; }
}

@media (max-width: 480px) {
    .hp-tl-root { padding: 14px; margin: 16px 0; }
    .hp-tl-root .hptl-summary-stats { gap: 14px; }
    .hp-tl-root .hptl-summary-stat-value { font-size: 1.2rem; }
}
