:host {
    display: block;
    --rail-gap: var(--cover-gap, 16px);
}

.rail {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 0 0;
    border: 1px solid transparent;
    border-radius: 16px;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

// Optional active accent — used by recently-added when a section matches the
// currently-scoped content type. Mirrors the prior `.section--active` look.
.rail--active {
    padding: 12px 14px 0;
    border-color: var(--app-selection-border);
    background: linear-gradient(
        145deg,
        var(--app-selection-surface),
        color-mix(in srgb, var(--app-selection-color) 6%, transparent)
    );
    box-shadow:
        inset 0 0 0 1px var(--app-selection-border),
        0 14px 24px -22px var(--app-selection-glow);

    .rail__label {
        color: var(--app-selection-color);
    }
}

// ── Header ─────────────────────────────────────────────────────────────────
.rail__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 2px;
    min-height: 24px;
}

.rail__title {
    margin: 0;
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.012em;
    color: var(--app-heading-color, #1a1d23);
}

.rail__see-all {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 4px 8px 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0.005em;
    color: var(--app-muted-color, #8891a4);
    text-decoration: none;
    transition:
        color 0.15s ease,
        background-color 0.15s ease;

    mat-icon {
        font-size: 16px;
        width: 16px;
        height: 16px;
        transition: transform 0.15s ease;
    }

    &:hover {
        color: var(--app-selection-color, #2f7bff);
        background: color-mix(
            in srgb,
            var(--app-selection-color, #2f7bff) 12%,
            transparent
        );

        mat-icon {
            transform: translateX(2px);
        }
    }

    &:focus-visible {
        outline: 2px solid var(--app-selection-color, #2f7bff);
        outline-offset: 2px;
    }
}

// ── Viewport ───────────────────────────────────────────────────────────────
.rail__viewport {
    position: relative;
    min-width: 0;

    // Edge gradients hint at horizontal scroll without interaction.
    &::before,
    &::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        width: 32px;
        pointer-events: none;
        z-index: 1;
        opacity: 0;
        transition: opacity 0.2s ease;
    }

    &::before {
        left: 0;
        background: linear-gradient(
            to right,
            var(--app-content-bg, #161a22) 0%,
            transparent 100%
        );
    }

    &::after {
        right: 0;
        background: linear-gradient(
            to left,
            var(--app-content-bg, #161a22) 0%,
            transparent 100%
        );
    }

    &:has(.rail__chev--left.rail__chev--visible)::before {
        opacity: 0.9;
    }

    &:has(.rail__chev--right.rail__chev--visible)::after {
        opacity: 0.9;
    }

    &:hover .rail__chev--visible {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}

.rail__track {
    display: flex;
    align-items: flex-start;
    gap: var(--rail-gap);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-padding-inline-start: 4px;
    scrollbar-width: none;
    padding: 4px 0 16px;
    margin: -4px 0 0;

    &::-webkit-scrollbar {
        display: none;
    }
    // Callers style their own projected cards (width, scroll-snap-align,
    // flex: 0 0 auto) — projected content stays in the parent's view
    // encapsulation and can't be reached from here without `::ng-deep`.
}

// ── Chevron — streaming-app circle (matches dashboard rail) ────────────────
.rail__chev {
    position: absolute;
    top: 50%;
    transform: translateY(-50%) scale(0.96);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 0.18s ease,
        background-color 0.18s ease,
        transform 0.18s ease,
        box-shadow 0.18s ease;
    z-index: 2;
    box-shadow:
        0 4px 14px -4px rgba(0, 0, 0, 0.55),
        0 0 0 0 rgba(255, 255, 255, 0);

    mat-icon {
        font-size: 24px;
        width: 24px;
        height: 24px;
        line-height: 24px;
        filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
    }

    &--visible {
        opacity: 0.5;
        pointer-events: auto;
    }

    &:hover {
        background: rgba(0, 0, 0, 0.88);
        transform: translateY(-50%) scale(1.08);
        box-shadow:
            0 8px 22px -6px rgba(0, 0, 0, 0.65),
            0 0 0 4px rgba(255, 255, 255, 0.06);
    }

    &:active {
        transform: translateY(-50%) scale(0.96);
    }

    &:focus-visible {
        outline: 2px solid var(--app-selection-color, #78adff);
        outline-offset: 3px;
    }

    &--left {
        left: 6px;
    }

    &--right {
        right: 6px;
    }
}

@media (hover: none) {
    .rail__chev {
        display: none;
    }

    .rail__viewport::before,
    .rail__viewport::after {
        display: none;
    }
}
