/* =========================================================
   /files/timeline-styles.css (FULL)
   Newspaper-style timeline with center line + filters + mobile fixes
   ========================================================= */

/* Wrapper */
.timeline-wrapper {
    width: 100%;
    padding: 20px;
    overflow-x: hidden;
}

/* Safety: prevent horizontal scroll from long content/images */
.timeline-wrapper * {
    box-sizing: border-box;
}

.timeline,
.tl-row,
.tl-card {
    max-width: 100%;
}

.tl-card {
    width: 100%;
    min-width: 0;
    overflow: visible;
}

/* Safety: constrain media only (do NOT apply max-width to everything) */
.tl-card img,
.tl-card svg,
.tl-card video,
.tl-card iframe {
    max-width: 100%;
    height: auto;
}

.tl-card-title {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.tl-card-title .copy-anchor-btn {
    margin-left: auto;
    /* pushes to far right */
    flex: 0 0 auto;
}

.tl-card-title-text {
    min-width: 0;
}

/* =========================================================
   Controls (search + selects + chips + articles-only pill)
   ========================================================= */

.timeline-controls {
    margin: 18px 0 26px;
    padding: 12px;
    border: 1px solid color-mix(in srgb, var(--text-color) 14%, transparent);
    border-radius: 12px;
    background: color-mix(in srgb, var(--bg-color) 88%, transparent);
    display: grid;
    gap: 12px;
    font-family: "Work Sans Regular", sans-serif;
}

.tl-row-controls {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
}

.tl-search input {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid color-mix(in srgb, var(--text-color) 14%, transparent);
    background: color-mix(in srgb, var(--bg-color) 80%, transparent);
    color: var(--text-color);
    outline: none;
    font-family: "Work Sans Regular", sans-serif;
}

.tl-search input::placeholder {
    color: color-mix(in srgb, var(--text-color) 60%, transparent);
}

.tl-selects {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.tl-selects select {
    width: 100%;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid color-mix(in srgb, var(--text-color) 14%, transparent);
    background: color-mix(in srgb, var(--bg-color) 80%, transparent);
    color: var(--text-color);
    outline: none;
    font-family: "Work Sans Regular", sans-serif;
}

.tl-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    padding: 8px 10px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--text-color) 14%, transparent);
    background: color-mix(in srgb, var(--bg-color) 82%, transparent);
    color: var(--text-color);
    cursor: pointer;
    line-height: 1;
    user-select: none;
    font-family: "Work Sans Regular", sans-serif;
}

/* Chip hover: bg stays your --bg-color, but gains contrast tint */
.chip{
  transition:
    background var(--trans-speed) var(--trans-ease),
    border-color var(--trans-speed) var(--trans-ease),
    color var(--trans-speed) var(--trans-ease),
    transform var(--trans-speed) var(--trans-ease);
}

/* On hover/focus, slightly mix in text color for contrast */
.chip:hover,
.chip:focus-visible{
  background: color-mix(in srgb, var(--bg-color) 40%, var(--text-color) 28%);
  border-color: color-mix(in srgb, var(--text-color) 28%, transparent);
  transform: translateY(-1px);
}

.chip:active{
  transform: translateY(0);
}

/* If chip is selected, keep the accent look (slightly stronger on hover) */
.chip[aria-pressed="true"]:hover,
.chip[aria-pressed="true"]:focus-visible{
  background: color-mix(in srgb, var(--accent-color) 22%, var(--bg-color) 78%);
  border-color: color-mix(in srgb, var(--accent-color) 70%, transparent);
}

/* Selected chip */
.chip[aria-pressed="true"] {
    border-color: color-mix(in srgb, var(--accent-color) 70%, transparent);
    background: color-mix(in srgb, var(--accent-color) 18%, transparent);
}

.tl-hint {
    margin: 0;
    color: color-mix(in srgb, var(--text-color) 70%, transparent);
}


/* =========================================================
   Articles-only pill toggle
   ========================================================= */

.tl-pill-toggle {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    position: relative;
}

.tl-pill-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tl-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--text-color) 14%, transparent);
    background: color-mix(in srgb, var(--bg-color) 82%, transparent);
    color: var(--text-color);
    line-height: 1;
    user-select: none;
    white-space: nowrap;
}

.tl-pill i {
    font-size: 0.95rem;
}

.tl-pill-text {
    font-size: 0.95rem;
}

.tl-pill-toggle input:checked+.tl-pill {
    border-color: color-mix(in srgb, var(--accent-color) 70%, transparent);
    background: color-mix(in srgb, var(--accent-color) 18%, transparent);
}

/* =========================================================
   Timeline layout
   ========================================================= */

.timeline-section {
    margin: 28px 0 34px;
}

.timeline-section h2 {
    margin-bottom: 34px;
}

.timeline {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    /* ensures space between rows */
}

/* 3-column timeline row (desktop) */
.tl-row {
    display: grid;
    grid-template-columns: 1fr 86px 1fr;
    gap: 12px;
    position: relative;

    /* line position variable (desktop default center) */
    --tl-line-left: 50%;
}

/* Center line (pseudo element) */
.tl-row::before {
    content: "";
    position: absolute;
    top: -14px;
    bottom: -14px;
    width: 2px;
    left: var(--tl-line-left);
    transform: translateX(-50%);
    background: var(--text-color);
}

/* Hard lock: keep card + node + empty on the same grid row */
.tl-row>.tl-card,
.tl-row>.tl-node-wrap,
.tl-row>.tl-empty {
    grid-row: 1;
}

/* Node always in center column */
.tl-row .tl-node-wrap {
    grid-column: 2 / 3;
}

/* Left rows */
.tl-row[data-side="left"] .tl-card {
    grid-column: 1 / 2;
}

.tl-row[data-side="left"] .tl-empty {
    grid-column: 3 / 4;
}

/* Right rows */
.tl-row[data-side="right"] .tl-empty {
    grid-column: 1 / 2;
}

.tl-row[data-side="right"] .tl-card {
    grid-column: 3 / 4;
}

/* =========================================================
   Node (center circle) — centered + 2-line clamp + smart shrink
   ========================================================= */

.tl-node-wrap {
    display: flex;
    justify-content: center;
    align-self: start;
    padding-top: 10px;
}

.tl-node {
    width: 62px;
    height: 62px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    text-decoration: none;
    color: var(--text-color);
    background: var(--bg-color);
    border: 2px solid var(--text-color);
    position: relative;
    padding: 5px;
    transition: filter var(--trans-speed) var(--trans-ease),
        background var(--trans-speed) var(--trans-ease),
        transform var(--trans-speed) var(--trans-ease);
}

.tl-node:hover,
.tl-node:focus-visible {
    color: var(--accent-color);
    border-color: var(--accent-color);
    transform: scale(1.05);
}

.tl-node .t {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    /* max 2 lines */
    overflow: hidden;

    width: 100%;
    max-width: 100%;
    text-align: center;
    font-size: 0.7rem;
    line-height: 1.05;
    letter-spacing: -0.01em;

    text-wrap: balance;
    word-break: break-word;
}

/* Auto shrink for long labels */
.tl-node[data-len="long"] .t {
    font-size: 0.64rem;
    letter-spacing: -0.02em;
}

/* Tooltip */
.tl-node:hover::after,
.tl-node:focus-visible::after {
    content: attr(data-tip);
    position: absolute;
    top: -42px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    border-radius: 10px;
    white-space: nowrap;
    font-size: 0.82rem;
    color: var(--text-color);
    background: color-mix(in srgb, var(--bg-color) 90%, transparent);
    border: 1px solid color-mix(in srgb, var(--text-color) 14%, transparent);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
}

/* =========================================================
   Cards
   ========================================================= */

.tl-card {
    border: 1px solid color-mix(in srgb, var(--text-color) 14%, transparent);
    background: var(--bg-color);
    filter: contrast(0.95);
    border-radius: 16px;
    padding: 14px;
    align-self: start;
}

.tl-card h3 {
    margin: 0 0 6px;
    font-size: 1.08rem;
}

.tl-card .meta {
    margin: 0 0 10px;
    color: color-mix(in srgb, var(--text-color) 70%, transparent);
    font-size: 0.93rem;
    line-height: 1.35;
}

.tl-card p {
    margin: 0 0 10px;
    line-height: 1.5;
}

/* Type pill inside meta */
.pill {
    display: inline-flex;
    font-size: 0.78rem;
    padding: 5px 9px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--text-color) 14%, transparent);
    color: color-mix(in srgb, var(--text-color) 78%, transparent);
}

/* Highlight when jumping */
.tl-card.flash {
    outline: 2px solid color-mix(in srgb, var(--accent-color) 70%, transparent);
    outline-offset: 2px;
}

/* =========================================================
   Related reads (1 per row)
   ========================================================= */

.tl-related {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid color-mix(in srgb, var(--text-color) 14%, transparent);
}

.tl-related-head {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
    color: color-mix(in srgb, var(--text-color) 88%, transparent);
}

.rel-grid {
    display: grid;
    grid-template-columns: 1fr;
    /* one per row */
    gap: 10px;
}

.rel-card {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    grid-template-rows: auto auto;
    gap: 6px 10px;
    text-decoration: none;
    padding: 10px;
    border-radius: 14px;
    border: 1px solid color-mix(in srgb, var(--text-color) 14%, transparent);
    background: color-mix(in srgb, var(--bg-color) 82%, transparent);
}

.rel-card img {
    grid-row: 1 / span 2;
    width: 72px;
    height: 50px;
    object-fit: cover;
    border-radius: 10px;
}

.rel-title {
    font-family: "Work Sans Bold", sans-serif;
    line-height: 1.2;
    color: var(--text-color);
}

.rel-meta {
    font-size: 0.86rem;
    color: color-mix(in srgb, var(--text-color) 70%, transparent);
}

/* =========================================================
   Read more toggle (+ / - with FontAwesome)
   ========================================================= */

.read-more-toggle {
    text-decoration: none;
    /* no underline */
    border: 0;
    background: none;
    padding: 0;
    margin: 6px 0 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--accent-color, #BF0D0D);
    font-family: "Work Sans Bold", sans-serif;
    font-size: 0.95rem;
}

.read-more-toggle:focus {
    outline: none;
}

.read-more-icon {
    width: 18px;
    display: inline-flex;
    justify-content: center;
}

/* fallback (your main open/close is in styles.css; kept here too) */
.read-more-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.read-more-content.open {
    max-height: 1000px;
}

/* =========================================================
   Empty state
   ========================================================= */

.tl-empty-state {
    color: color-mix(in srgb, var(--text-color) 70%, transparent);
    padding: 10px 2px 0;
}

/* =========================================================
   Mobile fixes (critical)
   - 2 columns: node + card
   - line centered on node column
   - override desktop left/right placement
   ========================================================= */

@media (max-width: 768px) {
    .tl-selects {
        grid-template-columns: 1fr;
    }

    .tl-row-controls {
        grid-template-columns: 1fr;
    }

    .timeline {
        gap: 14px;
    }

    .tl-row {
        margin-bottom: 14px;
    }

    .tl-row {
        --tl-node-col: 56px;

        /* line centered on node column */
        --tl-line-left: calc(var(--tl-node-col) / 2);

        grid-template-columns: var(--tl-node-col) minmax(0, 1fr);
        gap: 12px;
    }

    .tl-node-wrap {
        width: var(--tl-node-col);
        grid-column: 1;
        justify-content: center;
        align-self: start;
        padding-top: 8px;
    }

    /* Override desktop left/right placement */
    .tl-row[data-side="left"] .tl-card,
    .tl-row[data-side="right"] .tl-card {
        grid-column: 2 !important;
    }

    .tl-row[data-side="left"] .tl-empty,
    .tl-row[data-side="right"] .tl-empty {
        display: none !important;
    }

    .tl-card {
        width: 100%;
        min-width: 0;
    }

    .tl-node {
        width: 48px;
        height: 48px;
        padding: 5px;
    }

    .tl-node .t {
        font-size: 0.68rem;
        line-height: 1.02;
    }

    .tl-node[data-len="long"] .t {
        font-size: 0.60rem;
    }
}

/* =========================================================
   Mobile HARD OVERRIDE — keep circle centered on the line
   ========================================================= */

@media (max-width: 768px) {
    .tl-row {
        --tl-node-col: 56px !important;
        grid-template-columns: var(--tl-node-col) minmax(0, 1fr) !important;
    }

    .tl-row::before {
        left: calc(var(--tl-node-col) / 2) !important;
        transform: translateX(-50%) !important;
    }

    .tl-row .tl-node-wrap {
        grid-column: 1 / 2 !important;
        width: var(--tl-node-col) !important;
        justify-content: center !important;
    }

    .tl-row .tl-node {
        margin-left: auto !important;
        margin-right: auto !important;
    }
}


/* =========================================================
   Clear filters button
   ========================================================= */

.tl-actions {
    display: flex;
    justify-content: flex-end;
}

.tl-clear {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-family: "Work Sans Regular", sans-serif;
    padding: 10px 12px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--text-color) 14%, transparent);
    background: color-mix(in srgb, var(--bg-color) 82%, transparent);
    color: var(--text-color);
    cursor: pointer;
    line-height: 1;
    transition: border-color var(--trans-speed) var(--trans-ease),
        color var(--trans-speed) var(--trans-ease),
        background var(--trans-speed) var(--trans-ease);
}

.tl-clear:hover,
.tl-clear:focus-visible {
    border-color: color-mix(in srgb, var(--accent-color) 70%, transparent);
    color: var(--accent-color);
}

.tl-clear:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--accent-color) 60%, transparent);
    outline-offset: 2px;
}