/* News hub (/news, contract news-hub-v1 W2-W5). Colours come only from site.css's own tokens
   (--panel, --panel-2, --border-color, --muted, --body-color, --accent, --warning, --focus-ring),
   which are defined for both themes, plus --news-hub-accent below, a contrast fix for light mode;
   Bootstrap's --bs-* colour variables are not defined on this site and would silently drop a
   declaration. */

.news-hub {
    /* Accent text for chips, the selected tab and hovered headlines. The site's light accent
       (#2962ff) measures 4.04:1 on --panel-2, under WCAG AA for this small text, so light mode uses a
       darker blue: 5.5:1 on --panel-2 and 6.6:1 on --panel. Dark mode keeps --accent (6.9:1). */
    --news-hub-accent: var(--accent);
    display: grid;
    gap: .85rem;
    max-width: 1100px;
    margin: 0 auto;
    min-width: 0;
}
[data-bs-theme="light"] .news-hub {
    --news-hub-accent: #1d4ed8;
}
.news-hub [hidden] {
    display: none !important;
}
.news-hub-muted {
    color: var(--muted);
}
.news-hub-header h1,
.news-hub-header p {
    overflow-wrap: anywhere;
}
.news-hub-note {
    color: var(--muted);
    display: flex;
    gap: .4rem;
    align-items: baseline;
}

/* Section tabs: one row that scrolls sideways when it does not fit (a phone), never the page. */
.news-hub-tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: .35rem;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    padding: .15rem .1rem .45rem;
    border-bottom: 1px solid var(--border-color);
    min-width: 0;
    max-width: 100%;
}
.news-hub-tab {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    white-space: nowrap;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--panel);
    color: var(--body-color);
    font-size: .85rem;
    line-height: 1.2;
    padding: .38rem .8rem;
    cursor: pointer;
}
.news-hub-tab:hover {
    border-color: var(--news-hub-accent);
}
.news-hub-tab:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}
.news-hub-tab.active,
.news-hub-tab[aria-selected="true"] {
    border-color: var(--news-hub-accent);
    background: var(--panel-2);
    color: var(--news-hub-accent);
    font-weight: 600;
}
.news-hub-tab .bi {
    font-size: .75rem;
    color: var(--muted);
}

.news-hub-panel {
    display: grid;
    gap: .7rem;
    min-width: 0;
}

/* Tools: the symbol filter and the local headline search, side by side from tablet width. */
.news-hub-tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: .6rem;
    padding: .65rem .75rem;
    border: 1px solid var(--border-color);
    border-radius: .55rem;
    background: var(--panel);
}
@media (min-width: 768px) {
    .news-hub-tools {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        align-items: end;
    }
}
.news-hub-symbol .form-control {
    text-transform: uppercase;
}
.news-hub-symbol .form-control::placeholder {
    text-transform: none;
}
.news-hub-error-text {
    color: var(--warning);
}

.news-hub-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem 1rem;
    color: var(--muted);
}
.news-hub-stale {
    margin: 0;
    padding: .45rem .65rem;
    border: 1px solid var(--warning);
    border-left-width: 3px;
    border-radius: .45rem;
    color: var(--body-color);
    background: var(--panel);
}
.news-hub-stale .bi {
    color: var(--warning);
}
.news-hub-filter {
    color: var(--muted);
}

/* States */
.news-hub-state {
    padding: .9rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: .55rem;
    background: var(--panel);
    color: var(--body-color);
}
.news-hub-state-loading {
    display: flex;
    gap: .5rem;
    align-items: center;
    color: var(--muted);
}
.news-hub-state-error {
    border-left: 3px solid var(--warning);
}
.news-hub-state-sign-in {
    border-left: 3px solid var(--news-hub-accent);
}
.news-hub-state-title {
    font-weight: 600;
}

/* Cards */
.news-hub-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: .55rem;
    min-width: 0;
}
.news-hub-list:empty {
    display: none;
}
.news-hub-item {
    min-width: 0;
    padding: .75rem .9rem;
    border: 1px solid var(--border-color);
    border-radius: .55rem;
    background: var(--panel);
}
.news-hub-item article {
    display: grid;
    gap: .35rem;
    min-width: 0;
}
.news-hub-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
}
.news-hub-headline {
    color: var(--body-color);
    text-decoration: none;
}
.news-hub-headline:hover,
.news-hub-headline:focus-visible {
    color: var(--news-hub-accent);
    text-decoration: underline;
}
.news-hub-headline:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
    border-radius: .2rem;
}
.news-hub-summary {
    margin: 0;
    color: var(--muted);
    font-size: .9rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}
.news-hub-byline-row,
.news-hub-tickers {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: .15rem .45rem;
    align-items: baseline;
    color: var(--muted);
    font-size: .8rem;
    overflow-wrap: anywhere;
}
.news-hub-source {
    color: var(--body-color);
    font-weight: 600;
}
.news-hub-dot {
    color: var(--muted);
}
.news-hub-label {
    font-weight: 600;
}
.news-hub-chips {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
}
.news-hub-chip {
    display: inline-block;
    padding: .12rem .5rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--panel-2);
    color: var(--news-hub-accent);
    font-size: .76rem;
    font-weight: 600;
    text-decoration: none;
    letter-spacing: .01em;
}
.news-hub-chip:hover,
.news-hub-chip:focus-visible {
    border-color: var(--news-hub-accent);
    text-decoration: underline;
}
.news-hub-chip:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.news-hub-fresh {
    display: flex;
    justify-content: center;
}
.news-hub-fresh[hidden] {
    display: none;
}

.news-hub-more {
    display: grid;
    justify-items: center;
    gap: .4rem;
    padding: .25rem 0 .5rem;
}
.news-hub-more [data-news-more-error] {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    justify-content: center;
}

/* Phone: a denser card and full-width controls; nothing may push the page sideways. Every control a
   finger presses is at least 44px tall (WCAG 2.5.5): the tabs, the entity chips, the symbol field
   and its buttons, the search field, Load more and the retry buttons. */
@media (max-width: 575.98px) {
    .news-hub {
        gap: .7rem;
    }
    .news-hub-item {
        padding: .65rem .7rem;
    }
    .news-hub-title {
        font-size: .95rem;
    }
    .news-hub-tab {
        min-height: 44px;
        font-size: .8rem;
        padding: .5rem .85rem;
    }
    .news-hub-chips {
        gap: .4rem;
    }
    .news-hub-chip {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
        padding: .55rem .85rem;
        font-size: .8rem;
    }
    .news-hub-symbol .form-control,
    .news-hub-symbol .btn,
    .news-hub-search .form-control,
    .news-hub-more .btn,
    .news-hub-fresh .btn,
    .news-hub-state .btn {
        min-height: 44px;
    }
    .news-hub-more .btn,
    .news-hub-fresh .btn {
        width: 100%;
    }
}

@media print {
    .news-hub-tabs,
    .news-hub-tools,
    .news-hub-fresh,
    .news-hub-more,
    .news-hub-state-loading {
        display: none !important;
    }
    .news-hub-item {
        break-inside: avoid;
        border-color: #999;
    }
}
