/* Styles for the feeds page (feeds.html): the tab bar (Seeking Alpha-style
 * pills + dynamic topic tabs), tab panels, loaders, and the load-more control.
 * Loaded via feeds.html's extra_css block. */

body {
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
}

.feeds-layout {
    display: flex;
    min-height: 100vh;
}

/* min-width:0 so the feed column can actually use the flex space (a flex item
   defaults to min-width:auto and would otherwise be sized by its content). The
   right padding is the only gutter between the feed and the window edge. */
.feeds-main-content {
    flex: 1;
    min-width: 0;
    padding: 1rem 1.5rem 1.5rem 1rem;
}

/* Constrain the feed to a readable left-anchored column (Seeking Alpha style).
   Both the tab bar and the news list live inside .feeds-content, so they stay
   aligned to the same column. The cap is generous so the feed uses most of the
   available width on wide screens (only a small right gutter is left); the
   .feeds-main-content padding below supplies that gutter. */
.feeds-content {
    max-width: 1400px;
}

/* Tabs area: the wrapping pill bar + the Show more/less toggle, aligned to the
   feed column. */
.feeds-tabs-wrap {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

/* Tabs styling (Seeking Alpha-style pills). Pills WRAP to multiple rows. By
   default the bar is collapsed to a single row (max-height clips the overflow);
   the .feeds-tabs--expanded modifier (toggled by "Show more") lifts the cap to
   reveal every tab. --row-h is the measured single-row height, set by JS so the
   clip is exact regardless of font/zoom. */
.feeds-tabs {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
    max-height: var(--row-h, 2.2rem);    /* one row collapsed */
    transition: max-height 0.2s ease;
}
.feeds-tabs--expanded {
    max-height: 80vh;                    /* effectively uncapped, still bounded */
    overflow: auto;
}

.feeds-tab {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.9rem;
    background: #f3f4f6;
    border: 1px solid transparent;
    border-radius: 999px;         /* pill */
    font-size: 0.8rem;
    font-weight: 500;
    color: #4b5563;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

/* Show more / less toggle pill (right of the tab bar, Seeking Alpha style). */
.feeds-tabs-toggle {
    flex: 0 0 auto;
    padding: 0.4rem 0.7rem;
    background: none;
    border: none;
    font-size: 0.8rem;
    font-weight: 600;
    color: #2563eb;
    cursor: pointer;
    white-space: nowrap;
}
.feeds-tabs-toggle:hover { text-decoration: underline; }
.feeds-tabs-toggle[hidden] { display: none; }

.feeds-tab:hover {
    background: #e5e7eb;
    color: #1f2937;
}

.feeds-tab.active {
    background: #1f2937;          /* dark active pill, like the reference */
    color: #fff;
}

/* My News: the personalized feed, highlighted in the brand color so it stands
   out from the shared feeds even when another tab is selected. When active it
   takes the same dark pill as the other tabs. */
.feeds-tab-mine {
    background: #eef0ff;
    border-color: #c7cdfa;
    color: #4f5bd5;
    font-weight: 600;
}
.feeds-tab-mine:hover {
    background: #e0e4ff;
    color: #3f4ac0;
}
.feeds-tab-mine.active {
    border-color: transparent;
}
.feeds-tab-icon {
    font-size: 0.85em;
    line-height: 1;
}

/* 🔥 marker on hot topic tabs; the emoji keeps its own color when active. */
.feeds-tab-fire {
    font-size: 0.85em;
    line-height: 1;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Smaller news/analysis headline on the feeds page (the global .news-title is
   1.2rem, sized for the ticker pages). Scoped to .feeds-main-content so only the
   feeds list shrinks. */
.feeds-main-content .news-title {
    font-size: 1rem;
}

.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 1rem 0;
    color: #666;
}

.loading-indicator .loading-spinner {
    margin-right: 0.5rem;
}

@media (max-width: 768px) {
    .feeds-layout {
        flex-direction: column;
    }

    .feeds-main-content {
        padding: 1rem;
        margin-left: 0;
    }

    .feeds-tab {
        padding: 0.35rem 0.8rem;
        font-size: 0.75rem;
    }
}

.load-more-pagination {
    text-align: center;
    margin: 1.5rem 0 1rem;
}

.load-more-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 2rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.25);
}

.load-more-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(102, 126, 234, 0.35);
}

.load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Shared style for the "My News" loaders — both the initial "Loading your
   personalized news…" state and the post-save "Personalizing your news…"
   state. Larger, left-aligned copy so the message reads as a prominent
   status rather than a small centered spinner. Self-contained flex layout
   (the feeds .loading-indicator has no base rule of its own). */
.personalizing-indicator {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    padding: 1.5rem 2rem;
    gap: 0.9rem;
}

/* Keep the spinner beside the text (the base .loading-spinner auto-centers
   itself with margin: 0 auto), and size it to the larger copy. */
.personalizing-indicator .loading-spinner {
    margin: 0;
    flex: 0 0 auto;
}

.personalizing-indicator span {
    font-size: 1.35rem;
    font-weight: 600;
    color: #2c3e50;
}

/* ---- Shared "Show news aggregation" toggle bar ------------------------- */
/* Sits between the tab bar and the tab content; visible only on My News / All
   News (JS toggles display for other tabs). Reuses the global .toggle-switch. */
.feeds-aggregation-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0 0.75rem;
}

.feeds-aggregation-label {
    color: #495057;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Each toggle (switch + its label) is one group, so the switch never wraps away
   from the text it labels, and groups can be shown/hidden independently. */
.feeds-toggle-group {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Extra separation between adjacent toggles so the controls read as distinct. */
.feeds-toggle-group + .feeds-toggle-group {
    margin-left: 1.25rem;
}

/* The bar wraps on narrow screens rather than pushing "Configure My Topics"
   off-screen (there are now three toggles). */
.feeds-aggregation-bar {
    flex-wrap: wrap;
    row-gap: 0.5rem;
}

/* ---- Per-article description (the "Show news description" toggle) ------- */
/* Sits under the headline, above the meta row. Text comes from velt_ai's feed
   payload (mirrored from velt_infra news.description). Clamped to a few lines so
   a long RSS summary can't turn one article into a wall of text. */
.news-description {
    color: #556;
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0.3rem 0 0.4rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (prefers-color-scheme: dark) {
    .feeds-aggregation-label { color: #aab4c5; }
    .news-description { color: #aab4c5; }
}

/* ---- AI news event cards (aggregation mode) ---------------------------- */
/* An event card reuses .news-item; these add the event-specific bits: a
   summary line, tag chips, the expandable "N articles" count, and the member
   list revealed on expand. */
.event-summary {
    color: #556;
    font-size: 0.95rem;
    line-height: 1.45;
    margin: 0.35rem 0 0.5rem;
}

.event-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.4rem;
}

.event-tag {
    background: #eef2f7;
    color: #47546b;
    border-radius: 999px;
    padding: 0.12rem 0.6rem;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

/* The "N articles" count doubles as the expand toggle. */
.event-count-btn {
    background: none;
    border: 1px solid #c9d3e0;
    color: #3b5bdb;
    border-radius: 999px;
    padding: 0.1rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.event-count-btn:hover {
    background: #3b5bdb;
    color: #fff;
}

.event-count-btn[aria-expanded="true"] {
    background: #eef2ff;
}

/* Member article list shown inside the event-members modal dialog. */
.event-members {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.event-member {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #eceff3;
}

.event-member:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.event-member-link {
    color: #1c2b46;
    font-size: 0.92rem;
    font-weight: 600;
    text-decoration: none;
}

.event-member-link:hover {
    text-decoration: underline;
}

.event-member-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.6rem;
    font-size: 0.78rem;
    color: #8792a6;
}

/* ---- Right-side event-members panel (wide screens) --------------------- */
/* feeds-body is a flex row: the feed (feeds-content) grows to fill, and the
   panel docks to the right when open. On narrow screens the panel is hidden
   (JS uses the centered modal instead). */
.feeds-body {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
}

.feeds-content {
    flex: 1 1 auto;
    min-width: 0;  /* let the feed shrink so the panel fits */
}

.feeds-side-panel {
    flex: 0 0 40%;
    max-width: 560px;
    align-self: stretch;
    background: #fff;
    border: 1px solid #e3e8ef;
    border-radius: 10px;
    /* Stick within the viewport; the body (#side-panel-body) scrolls internally
       so the feed on the left scrolls independently. overflow is VISIBLE so the
       connecting triangle (::before/::after) can sit outside the left edge. */
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.feeds-side-panel[hidden] { display: none; }

/* Connecting triangle ("beak") pointing from the panel toward the selected
   event card in the feed. Two stacked triangles: the outer (::before) is the
   border color, the inner (::after) the panel fill, so the beak reads as an
   extension of the panel with a matching outline. Vertically centered on the
   panel's own height. */
.feeds-side-panel::before,
.feeds-side-panel::after {
    content: "";
    position: absolute;
    top: 2.25rem;                 /* near the top, aligned with the header */
    width: 0;
    height: 0;
    border-style: solid;
}
.feeds-side-panel::before {
    left: -13px;
    border-width: 13px 13px 13px 0;
    border-color: transparent #e3e8ef transparent transparent;  /* panel border */
}
.feeds-side-panel::after {
    left: -11px;
    border-width: 12px 12px 12px 0;
    border-color: transparent #fff transparent transparent;     /* panel fill */
}

.feeds-side-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #eceff3;
}

.feeds-side-panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1c2b46;
    line-height: 1.3;
}

#side-panel-body {
    padding: 1rem 1.25rem;
    overflow-y: auto;
}

/* Highlight the event card whose members are open in the panel. */
.event-item.event-selected {
    background: #eef3ff;
    box-shadow: inset 3px 0 0 #3b5bdb;
    border-radius: 6px;
}

/* Narrow screens: no room to dock — hide the panel; JS uses the modal. */
@media (max-width: 1099px) {
    .feeds-side-panel { display: none !important; }
    .feeds-body { display: block; }
}

@media (prefers-color-scheme: dark) {
    .event-summary { color: #aab4c5; }
    .event-tag { background: #2a3341; color: #b7c2d4; }
    .event-count-btn { border-color: #3a465a; color: #8ea3ff; }
    .event-count-btn:hover { background: #3b5bdb; color: #fff; }
    .event-member { border-bottom-color: #2b3546; }
    .event-member-link { color: #dbe3f0; }
    .event-member-meta { color: #7c889c; }
    .feeds-side-panel { background: #1a2230; border-color: #2b3546; }
    .feeds-side-panel-header { border-bottom-color: #2b3546; }
    .feeds-side-panel-header h3 { color: #dbe3f0; }
    .event-item.event-selected { background: #202b40; box-shadow: inset 3px 0 0 #5b7bff; }
    /* Beak: outer=border, inner=panel fill (dark). */
    .feeds-side-panel::before { border-right-color: #2b3546; }
    .feeds-side-panel::after { border-right-color: #1a2230; }
}

/* Internal debug reader: a headline whose article body is stored opens in the
   popup reader (script.js refreshNewsContentAvailability). Small marker so
   internal users can tell those apart from links to the publisher. */
.news-title-link.has-stored-content::after {
    content: "READ";
    display: inline-block;
    margin-left: 0.4em;
    padding: 0 0.35em;
    font-size: 0.65em;
    font-weight: 600;
    letter-spacing: 0.04em;
    vertical-align: middle;
    border: 1px solid currentColor;
    border-radius: 3px;
    opacity: 0.6;
}
