/* ===========================================
   Page tabs — a page split into sections, each with its own URL.

   Markup comes from the page_tabs() macro in partials/_macros.html (data:
   botterino/web/page_tabs.py). Tabs are real links: the active one carries
   aria-current="page", so every tab is bookmarkable and reload-safe.
   Not the same thing as .preset-tabs (preset-tabs.css), the small segmented
   control that switches a time range inside a card.

   Narrow screens: the bar scrolls sideways instead of wrapping, and
   static/js/ui.js scrolls the current tab into view. Status chips inside a
   tab are the global .badge.stat-chip + .tone-* (badges.css, status.css).
   =========================================== */

.page-tabs {
    margin-top: 1.25rem;
}

.page-tabs-list {
    /* Tabs' offsetLeft is measured against the list (ui.js centring). */
    position: relative;
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border-light);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}

.page-tabs-list::-webkit-scrollbar { display: none; }

.page-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    height: 36px;
    padding: 0 12px;
    border-radius: 0;
    color: var(--label-2);
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    text-decoration: none;
    /* The active marker is an inset bar, so the list's bottom rule stays one line. */
    box-shadow: inset 0 -2px 0 transparent;
    transition:
        color var(--dur-fast) var(--ease-out),
        background-color var(--dur-fast) var(--ease-out),
        box-shadow var(--dur-fast) var(--ease-out);
}

/* Outranks reset.css `a:hover:not(.btn)` (the link colour). Pointer devices only: a tap
   sticks :hover on touch screens, and after an in-place switch re-centres the bar the
   stuck hover greys whichever tab slid under the finger. */
@media (hover: hover) {
    .page-tabs .page-tab:hover {
        color: var(--label-1);
        background: none;
    }
}

/* v6: the underline is the text color, not blue */
.page-tabs .page-tab[aria-current="page"] {
    color: var(--label-1);
    font-weight: 500;
    box-shadow: inset 0 -2px 0 var(--label-1);
}

/* Drawn inside the tab: the scrolling list would clip an outer ring. */
.page-tab:focus-visible {
    outline: 2px solid var(--c-secondary);
    outline-offset: -2px;
}

.page-tab .badge { flex-shrink: 0; }

/* The active tab's one-line description, under the bar. */
.page-tabs-intro {
    margin: 0.75rem 0 0;
    max-width: 75ch;
    color: var(--text-muted);
    font-size: 0.85rem;
}

@media (max-width: 640px) {
    .page-tab {
        padding: 0.6rem 0.7rem 0.65rem;
        font-size: 0.85rem;
    }
}

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

/* In-place switch (nav[data-live-nav], js/live_regions.js): while the next tab loads,
   the current panel dims and stops taking clicks; the panel that arrives fades in. The
   bar itself stays crisp — the clicked tab is current from the click. */
[data-live-region][aria-busy="true"] > :not([data-live-sync]) {
    opacity: 0.45;
    pointer-events: none;
    transition: opacity var(--dur-base) var(--ease-out);
}

[data-live-region][data-live-entered] > :not([data-live-sync]) {
    animation: page-tab-enter var(--dur-base) var(--ease-out);
}

@keyframes page-tab-enter {
    from { opacity: 0; transform: translateY(4px); }
}

@media (prefers-reduced-motion: reduce) {
    [data-live-region][data-live-entered] > :not([data-live-sync]) { animation: none; }
}
