/* News — Narrative Intelligence Stream (brief §10.3, §10.4)
 *
 * Two jobs. The first is the tab row and the single filter surface that
 * replaced a chip row, two inline forms and a collapsible panel that all did
 * parts of the same thing in four different visual languages. The second is
 * the feed row itself, which now leads with what a market reader scans for --
 * source, time, headline, one line of context, the assets, the call -- and
 * leaves provider tags and confidence percentages to the Context Lens.
 *
 * Own namespace throughout, so nothing here can reach into the 2026 canvas
 * layer or the older news stylesheets and quietly restyle them.
 *
 * Logical properties only: the Arabic site is the same stylesheet mirrored,
 * not a second one kept in sync by hand.
 */

/* --- tokens ------------------------------------------------------------- */

.ns-tabs,
.ns-filters,
.ns-layout,
.ns-row {
    --ns-line: var(--c-line, rgba(148, 163, 184, 0.28));
    --ns-surface: var(--c-surface, #ffffff);
    --ns-text: var(--c-text, #0f172a);
    --ns-muted: var(--c-text-muted, #64748b);
    --ns-accent: var(--c-evidence, #0891b2);
    --ns-up: var(--c-up, #16a34a);
    --ns-down: var(--c-down, #dc2626);
    --ns-attention: var(--c-attention, #b45309);
}

/* --- tab row ------------------------------------------------------------ */

.ns-tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.25rem;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0 1rem;
    margin: 0.5rem 0 0;
    border-block-end: 1px solid var(--ns-line);
    -webkit-overflow-scrolling: touch;
}

.ns-tabs::-webkit-scrollbar {
    display: none;
}

.ns-tab {
    flex: 0 0 auto;
    padding: 0.6rem 0.85rem;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--ns-muted);
    text-decoration: none;
    border-block-end: 2px solid transparent;
    margin-block-end: -1px;
    white-space: nowrap;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
}

.ns-tab:hover,
.ns-tab:focus-visible {
    color: var(--ns-text);
}

.ns-tab--current {
    color: var(--ns-text);
    border-block-end-color: var(--ns-accent);
}

/* --- one filter surface ------------------------------------------------- */

.ns-filters {
    margin: 0.75rem 1rem;
    border: 1px solid var(--ns-line);
    border-radius: 8px;
    background: var(--ns-surface);
}

.ns-filters__summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 0.9rem;
    min-height: 44px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ns-text);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.ns-filters__summary::-webkit-details-marker {
    display: none;
}

.ns-filters__summary::after {
    content: "+";
    margin-inline-start: auto;
    font-weight: 400;
    color: var(--ns-muted);
}

.ns-filters[open] > .ns-filters__summary::after {
    content: "\2212";
}

.ns-filters__count {
    font-weight: 500;
    color: var(--ns-muted);
}

.ns-filters__panel {
    padding: 0 0.9rem 0.9rem;
    border-block-start: 1px solid var(--ns-line);
}

.ns-filters__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 0.75rem;
    margin-block-start: 0.85rem;
}

.ns-filters__field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.ns-filters__label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ns-muted);
}

.ns-filters__control {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-height: 40px;
    padding: 0.5rem 0.6rem;
    font-size: 0.875rem;
    color: var(--ns-text);
    background: var(--ns-surface);
    border: 1px solid var(--ns-line);
    border-radius: 6px;
}

.ns-filters__check {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    align-self: end;
    min-height: 40px;
    font-size: 0.85rem;
    color: var(--ns-text);
}

.ns-filters__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-block-start: 0.85rem;
}

.ns-filters__apply {
    min-height: 40px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ns-surface);
    background: var(--ns-accent);
    border: 1px solid var(--ns-accent);
    border-radius: 6px;
    cursor: pointer;
}

.ns-filters__reset {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    color: var(--ns-muted);
    text-decoration: underline;
}

/* Under 768px the same disclosure becomes a bottom sheet: the controls sit
 * where a thumb is, and the feed stays visible behind them rather than being
 * replaced by a filter page a reader has to navigate back out of. */
@media (max-width: 767px) {
    .ns-filters[open] {
        position: fixed;
        inset-inline: 0;
        inset-block-end: 0;
        z-index: 60;
        margin: 0;
        max-height: 78vh;
        overflow-y: auto;
        border-radius: 14px 14px 0 0;
        border-block-end: 0;
        box-shadow: 0 -8px 28px rgba(15, 23, 42, 0.22);
    }

    .ns-filters[open] > .ns-filters__summary {
        position: sticky;
        inset-block-start: 0;
        background: var(--ns-surface);
        border-block-end: 1px solid var(--ns-line);
    }

    .ns-filters[open]::before {
        content: "";
        position: fixed;
        inset: 0;
        z-index: -1;
        background: rgba(15, 23, 42, 0.45);
    }
}

/* --- feed and contextual intelligence side by side ---------------------- */

.ns-layout {
    display: block;
}

@media (min-width: 1180px) {
    .ns-layout--split {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(18rem, 22rem);
        gap: 1.25rem;
        align-items: start;
        padding-inline: 0.5rem;
    }

    .ns-layout--split > .ns-main {
        order: 1;
        min-width: 0;
    }

    .ns-layout--split > .ns-context {
        order: 2;
        position: sticky;
        inset-block-start: 1rem;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
        min-width: 0;
    }
}

.ns-main {
    min-width: 0;
}

.ns-context {
    min-width: 0;
}

/* The contextual column is narrow by design, and a long headline in a narrow
 * column is where text escapes its container. Applied to the subtree rather
 * than to named children: the primitives inside belong to another layer and
 * naming their classes here would couple the two stylesheets. */
.ns-context,
.ns-context * {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* The feed is a stream, not a card wall. A shared `.grid` rule elsewhere
 * gives any element with that class a three-column auto-fit template, which
 * is narrower than the headlines in it once the contextual column takes its
 * share of the width. */
.ns-feed {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* --- feed row ----------------------------------------------------------- */

.ns-row {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.9rem 0;
    border-block-end: 1px solid var(--ns-line);
    min-width: 0;
}

.ns-row__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4rem 0.55rem;
    font-size: 0.75rem;
    color: var(--ns-muted);
}

.ns-row__source {
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--ns-text);
}

.ns-row__title {
    font-size: 1rem;
    font-weight: 650;
    line-height: 1.35;
    color: var(--ns-text);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.ns-row__title:hover {
    text-decoration: underline;
}

.ns-row__context {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--ns-muted);
    overflow-wrap: anywhere;
}

.ns-row__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.ns-chip {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0.1rem 0.45rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ns-accent);
    border: 1px solid var(--ns-line);
    border-radius: 999px;
    text-decoration: none;
}

.ns-row__readings {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.6rem;
    font-size: 0.78rem;
}

.ns-read {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 600;
    color: var(--ns-muted);
}

.ns-read--bullish {
    color: var(--ns-up);
}

.ns-read--bullish::before {
    content: "\25B2 ";
}

.ns-read--bearish {
    color: var(--ns-down);
}

.ns-read--bearish::before {
    content: "\25BC ";
}

.ns-read--neutral::before {
    content: "\2013 ";
}

.ns-read__key {
    font-weight: 500;
    color: var(--ns-muted);
}

.ns-eval {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ns-muted);
}

.ns-eval--pending::before {
    content: "\29D6 ";
}

.ns-eval--evaluated::before {
    content: "\2713 ";
}

.ns-eval--excluded::before {
    content: "\2298 ";
}

.ns-eval--none::before {
    content: "\00B7 ";
}

.ns-row__lens {
    align-self: flex-start;
    min-height: 24px;
    padding: 0.1rem 0.45rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ns-accent);
    background: none;
    border: 1px solid var(--ns-line);
    border-radius: 6px;
    cursor: pointer;
}

/* --- article page (§10.4) ----------------------------------------------- */

.na-block {
    margin-block: 1.25rem;
    padding-block-end: 1.25rem;
    border-block-end: 1px solid var(--c-line, rgba(148, 163, 184, 0.28));
}

.na-block:last-child {
    border-block-end: 0;
}

.na-block__head {
    margin: 0 0 0.6rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--c-text-muted, #64748b);
}

.na-block__body {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--c-text, #0f172a);
}

.na-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.7rem;
    font-size: 0.8rem;
    color: var(--c-text-muted, #64748b);
}

.na-reading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.9rem;
}

.na-reading__value {
    font-size: 1.05rem;
    font-weight: 700;
}

.na-disagree {
    margin-block-start: 0.6rem;
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--c-text, #0f172a);
    border-inline-start: 3px solid var(--c-attention, #b45309);
    background: rgba(180, 83, 9, 0.07);
    border-radius: 0 6px 6px 0;
}

.na-conf {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
}

.na-conf__link {
    font-size: 0.78rem;
    color: var(--c-text-muted, #64748b);
    text-decoration: underline;
}

.na-provenance {
    font-size: 0.85rem;
}

.na-provenance__ids {
    margin-block-start: 0.5rem;
    font-size: 0.78rem;
}

.na-provenance__ids summary {
    cursor: pointer;
    color: var(--c-text-muted, #64748b);
    min-height: 24px;
    display: flex;
    align-items: center;
}

.na-ids {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 0.25rem 0.75rem;
    margin: 0.5rem 0 0;
    font-size: 0.75rem;
}

.na-ids dt {
    color: var(--c-text-muted, #64748b);
}

.na-ids dd {
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    overflow-wrap: anywhere;
}

.na-outcome {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
    gap: 0.75rem;
}

.na-outcome__cell {
    min-width: 0;
}

.na-outcome__label {
    display: block;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--c-text-muted, #64748b);
}

.na-outcome__value {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.na-similar {
    font-size: 0.9rem;
    line-height: 1.6;
}

.na-similar__insufficient {
    color: var(--c-text-muted, #64748b);
}

.na-siblings {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.na-siblings__item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4rem 0.6rem;
    font-size: 0.9rem;
}

.na-siblings__time {
    font-size: 0.75rem;
    color: var(--c-text-muted, #64748b);
    font-variant-numeric: tabular-nums;
}

@media (max-width: 480px) {
    .ns-tabs {
        padding-inline: 0.5rem;
    }

    .ns-filters {
        margin-inline: 0.5rem;
    }

    .ns-row__title {
        font-size: 0.95rem;
    }
}
