/*
 * Public marketing sidebar — the same card component as the blog article
 * sidebar ("On this page" / "Latest articles"), lifted out of the inline
 * <style> in blog/blog_detail.html so more than one page can use it.
 *
 * Class names and metrics are kept IDENTICAL to the blog's so the two
 * sidebars are visually the same component, and so blog_detail.html can
 * later drop its ~165 inline lines and just link this file. The only
 * difference is scope: the blog's rules are all prefixed `.article-detail`,
 * these are not.
 *
 * Two bugs in the original are fixed here rather than copied:
 *   - `.toc-card` used var(--tb-card-bg), which is only defined on elements
 *     carrying Bootstrap's `.card` class. These cards do not, so it resolved
 *     to nothing. Uses --tb-card-bg-custom (defined globally: #fff / #212529).
 *   - Muted text used var(--bs-secondary-color); this build compiles
 *     Bootstrap with the `tb-` prefix so that variable does not exist.
 *
 * Linked after bootstrap/app/custom via `{% block css %}{{ block.super }}`,
 * so no specificity tricks are needed.
 */

/* Sticky breaks if any ancestor has overflow other than visible. */
.section.events-discover {
    overflow: visible;
}

.sidebar-col {
    display: flex;
    flex-direction: column;
}

/* Sticky only once the sidebar is actually beside the content. Below lg it
 * stacks under the grid, where sticking would just make it hover oddly. */
@media (min-width: 992px) {
    .sidebar-wrap {
        position: sticky;
        top: 6rem; /* clears the fixed-top navbar */
        flex-shrink: 0;
    }
}

/* ---------------------------------------------------------------- card ---- */

.sidebar-card {
    background: var(--tb-card-bg-custom, #fff);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 0.5rem;
    overflow: hidden;
}

.sidebar-card + .sidebar-card {
    margin-top: 1rem;
}

[data-layout-mode="dark"] .sidebar-card {
    border-color: rgba(255, 255, 255, 0.08);
}

.sidebar-card .card-header {
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    color: var(--tb-body-color);
    font-size: 0.9375rem;
    font-weight: 600;
    padding: 0.75rem 1rem;
}

[data-layout-mode="dark"] .sidebar-card .card-header {
    background: rgba(255, 255, 255, 0.04);
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

/* ----------------------------------------------------------------- rows --- */
/* Same geometry as the blog's "Latest articles" rows. */

.latest-item {
    align-items: flex-start;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    color: inherit;
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    transition: background 0.15s ease;
}

.latest-item:last-child {
    border-bottom: 0;
}

.latest-item:hover {
    background: rgba(0, 0, 0, 0.03);
    color: inherit;
}

[data-layout-mode="dark"] .latest-item {
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

[data-layout-mode="dark"] .latest-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.latest-item .latest-thumb {
    background: #f1f3f5;
    border-radius: 0.375rem;
    flex-shrink: 0;
    height: 56px;
    overflow: hidden;
    position: relative;
    width: 72px;
}

[data-layout-mode="dark"] .latest-item .latest-thumb {
    background: #2a2f34;
}

.latest-item .latest-thumb img {
    height: 100%;
    object-fit: cover;
    width: 100%;
}

.latest-item .latest-info {
    min-width: 0;
}

.latest-item .latest-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.35;
    overflow: hidden;
}

.latest-item .latest-date {
    color: #878a99;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

[data-layout-mode="dark"] .latest-item .latest-date {
    color: #9599ad;
}

/* ------------------------------------------------------------ live tint --- */
/* The blog marks its active TOC row with a green left border and a green
 * wash; the live rows here borrow exactly that treatment so the two
 * sidebars read as one design. */

.latest-item.is-live {
    border-left: 3px solid #198754;
    background: rgba(25, 135, 84, 0.1);
}

[data-layout-mode="dark"] .latest-item.is-live {
    border-left-color: #45cb85;
    background: rgba(25, 135, 84, 0.18);
}

.latest-item.is-live:hover {
    background: rgba(25, 135, 84, 0.16);
}

[data-layout-mode="dark"] .latest-item.is-live:hover {
    background: rgba(25, 135, 84, 0.24);
}

.latest-item.is-live .latest-date {
    color: #198754;
    font-weight: 500;
}

[data-layout-mode="dark"] .latest-item.is-live .latest-date {
    color: #45cb85;
}

.latest-date.is-ended {
    color: #878a99 !important;
    font-weight: 400 !important;
}

.latest-date.is-ended .live-left {
    display: none;
}

/* Small "on air" dot in the card header, matching the green accent. */
.live-dot {
    background: #45cb85;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    height: 8px;
    position: relative;
    width: 8px;
}

.live-dot::after {
    animation: live-pulse 2s ease-out infinite;
    border: 2px solid #45cb85;
    border-radius: 50%;
    content: "";
    inset: -3px;
    position: absolute;
}

@keyframes live-pulse {
    0% {
        opacity: 0.7;
        transform: scale(0.6);
    }
    70%,
    100% {
        opacity: 0;
        transform: scale(1.9);
    }
}

.live-count {
    background: rgba(25, 135, 84, 0.14);
    border-radius: 999px;
    color: #45cb85;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    padding: 0.25rem 0.5rem;
}

.live-progress {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 2px;
    height: 3px;
    margin-top: 0.35rem;
    overflow: hidden;
    width: 100%;
}

[data-layout-mode="dark"] .live-progress {
    background: rgba(255, 255, 255, 0.1);
}

.live-progress-bar {
    background: #198754;
    border-radius: 2px;
    display: block;
    height: 100%;
    transition: width 0.3s ease;
}

[data-layout-mode="dark"] .live-progress-bar {
    background: #45cb85;
}


/* -------------------------------------------------------------- empty ----- */

.sidebar-empty {
    color: #878a99;
    font-size: 0.8125rem;
    padding: 1.5rem 1rem;
    text-align: center;
}

[data-layout-mode="dark"] .sidebar-empty {
    color: #9599ad;
}

.sidebar-empty i {
    font-size: 1.5rem;
    opacity: 0.5;
}

.sidebar-card-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    color: #878a99;
    font-size: 0.75rem;
    padding: 0.5rem 1rem;
    text-align: center;
}

[data-layout-mode="dark"] .sidebar-card-footer {
    border-top-color: rgba(255, 255, 255, 0.06);
    color: #9599ad;
}

/* A pulsing dot is precisely the motion this preference exists to stop. */
@media (prefers-reduced-motion: reduce) {
    .live-dot::after {
        animation: none;
        opacity: 0.35;
        transform: scale(1);
    }

    .latest-item {
        transition: none;
    }
}
