/*
 * activity-timeline.css — the period strip that filters the activity list
 * (scripts/ui/activity-timeline.js).
 *
 * The component is MOUNTABLE: it can land in the Saved Routes dock, in the profile
 * panel or in a mobile sheet, so nothing here positions anything — no fixed, no
 * z-index, no dock geometry. It fills the container it is given and borrows that
 * container's glass tokens from styles/main.css.
 *
 * The two strips scroll HORIZONTALLY, on their own. `min-width: 0` on every level
 * plus `overflow-x: auto` on the strip is what keeps twelve months from widening the
 * dock and pushing the page sideways — a flex/grid child defaults to min-content
 * width, which is exactly how a long strip breaks its host's layout.
 *
 * The blur lives on the strip, once, instead of on each chip: fifteen year chips each
 * compositing their own backdrop-filter is a real cost on a phone, and the visual
 * result is the same.
 */

.activity-timeline {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    min-width: 0;
    color: #fff;
    font-family: var(--font-ui, system-ui, sans-serif);
}

.activity-timeline[hidden] {
    display: none;
}

/* ---- Strips ------------------------------------------------------------- */

.activity-timeline__strip {
    display: flex;
    align-items: stretch;
    gap: 6px;
    min-width: 0;
    padding: 5px;
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.28));
    border-radius: var(--glass-radius, 14px);
    background: var(--glass-surface, rgba(255, 255, 255, 0.06));
    backdrop-filter: blur(var(--glass-blur, 16px));
    overflow-x: auto;
    overflow-y: hidden;
    /* WHY: a horizontal fling inside the strip must not turn into the browser's
       back-navigation gesture, which is what a trackpad or an iOS edge swipe does. */
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.activity-timeline__strip::-webkit-scrollbar {
    height: 4px;
}

.activity-timeline__strip::-webkit-scrollbar-thumb {
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.28);
}

.activity-timeline__strip::-webkit-scrollbar-track {
    background: transparent;
}

/* ---- Chips -------------------------------------------------------------- */

.activity-timeline__chip {
    appearance: none;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    /* Touch-friendly: never below the 44px finger target on either axis. */
    min-width: 46px;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    scroll-snap-align: center;
    transition: background 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}

.activity-timeline__chip:hover:not(:disabled) {
    border-color: var(--glass-border-strong, rgba(255, 255, 255, 0.4));
    background: rgba(255, 255, 255, 0.16);
}

.activity-timeline__chip:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.75);
    outline-offset: 1px;
}

/* Selected. Mirrors aria-pressed so the visual and the accessible state cannot drift. */
.activity-timeline__chip[aria-pressed='true'],
.activity-timeline__chip--on {
    border-color: transparent;
    background: var(--strava-orange, #fc4c02);
    color: #fff;
}

/* The year you have drilled into: not selected itself, but the one on screen. */
.activity-timeline__chip--open:not([aria-pressed='true']) {
    border-color: var(--strava-orange, #fc4c02);
    background: rgba(255, 255, 255, 0.12);
}

/* A month that has not happened yet, or a year that cannot hold anything. */
.activity-timeline__chip:disabled {
    opacity: 0.32;
    cursor: default;
}

/* Known to hold nothing: dimmed, but still clickable — the count can be stale. */
.activity-timeline__chip--empty:not([aria-pressed='true']):not(:disabled) {
    color: rgba(255, 255, 255, 0.55);
}

.activity-timeline__all {
    font-weight: 700;
}

.activity-timeline__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.32);
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

.activity-timeline__count[hidden] {
    display: none;
}

.activity-timeline__chip[aria-pressed='true'] .activity-timeline__count {
    background: rgba(0, 0, 0, 0.28);
}

/* ---- Narrow hosts ------------------------------------------------------- */

@media (max-width: 480px) {
    .activity-timeline__chip {
        min-width: 44px;
        padding: 8px 10px;
        font-size: 11px;
    }

    .activity-timeline__strip {
        gap: 5px;
        padding: 4px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .activity-timeline__chip {
        transition: none;
    }

    .activity-timeline__strip {
        scroll-behavior: auto;
    }
}
