/* Shared desktop Topic/operational browse presentation (design/news.doutlab/category_page.png,
 * filter.png). It consumes the existing Feed query context; no rule here
 * changes visibility, ordering, or filter semantics -- presentation only.
 *
 * Reuses the platform-wide semantic tokens (static/css/src/news-frontend/
 * tokens.css's --dn-* aliases, scoped under .dout-news) rather than a parallel
 * palette, and the shared dark "console panel" tokens (--color-panel*, static/
 * css/src/base/tokens.css) for the filled/selected controls the approved
 * reference shows (the "Применено фильтров" button, the selected mode pill,
 * the current pagination page) -- the same dark surface already used
 * elsewhere in the product, not a one-off color invented for this page.
 *
 * Prompt 1486: the Cyrillic-safe body/mono stack and the editorial-serif role
 * (reading/headline text) are NOT redeclared here -- `.dn-topic-page` (the
 * body class `pages/news_list.html` already sets for this page) now joins the
 * same shared `common.css` token rules `.dn-editorial-home`/`.dn-home`/
 * `.dn-article` already use, so this page gets the identical, single-source
 * values instead of a page-local copy that could silently drift from them.
 * See common.css's own comment for why the serif role is a system-font stack
 * (no serif webfont is vendored in this repository) and article-detail.css's
 * comment for the Cyrillic-rendering verification of that stack.
 */

/* ---------------------------------------------------------------------
 * Search + filter controls (filter.png's three states)
 * ------------------------------------------------------------------- */

.dn-topic-filter {
    margin-bottom: 20px;
}

.dn-topic-filter__collapsed {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.dn-topic-search {
    display: flex;
    align-items: center;
    flex: 1 1 320px;
    gap: 10px;
    min-width: 0;
    height: 48px;
    border: 1px solid var(--dn-rule-subtle);
    border-radius: var(--radius-md, 8px);
    padding: 0 16px;
    background: var(--dn-surface-panel);
    color: var(--dn-text-secondary);
}

.dn-topic-search .dout-news-icon {
    flex: none;
    font-size: 17px;
}

.dn-topic-search input {
    width: 100%;
    min-width: 0;
    height: 100%;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--dn-text-primary);
    font-family: var(--dn-font-body);
    font-size: 15px;
}

.dn-topic-search input::placeholder {
    color: var(--dn-text-secondary);
}

.dn-topic-filter__action {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex: 0 1 auto;
    gap: 8px;
}

.dn-topic-filter__details {
    width: auto;
}

.dn-topic-filter__details summary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: fit-content;
    min-width: 200px;
    height: 48px;
    margin-left: auto;
    padding: 0 16px;
    border: 1px solid var(--dn-rule-subtle);
    border-radius: var(--radius-md, 8px);
    color: var(--dn-text-primary);
    background: var(--dn-surface-panel);
    font-family: var(--dn-font-body);
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    list-style: none;
    white-space: nowrap;
    transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.dn-topic-filter__details summary::-webkit-details-marker {
    display: none;
}

.dn-topic-filter__details summary .dout-news-icon {
    font-size: 15px;
}

/* Active (filters applied) is a state of its own -- independent of whether
 * the panel is currently open or closed (filter.png states 2 and 3 both show
 * the filled dark control; only state 1, genuinely no filters, is outlined). */
.dn-topic-filter__details--active summary,
.dn-topic-filter__details[open] summary {
    color: var(--color-panel-text);
    border-color: var(--color-panel);
    background: var(--color-panel);
}

.dn-topic-filter__expanded {
    display: none;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--dn-rule-subtle);
    text-align: left;
}

/* Prompt 1489: disclosure state controls the full-width sibling panel while
 * search + summary remain in one stable top row. The form retains native
 * staged radio state and submits only through Apply; no JS state is involved. */
.dn-topic-filter__collapsed:has(.dn-topic-filter__details[open])
    + .dn-topic-filter__expanded {
    display: flex;
}

.dn-topic-filter__first-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.dn-topic-filter__modes,
.dn-topic-filter__active,
.dn-topic-filter__sources {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-family: var(--dn-font-body);
    font-size: 13px;
    color: var(--dn-text-primary);
}

.dn-topic-filter__modes {
    flex: 1 1 auto;
}

.dn-topic-filter__modes > span,
.dn-topic-filter__active > span,
.dn-topic-filter__sources > span {
    margin-right: 4px;
    color: var(--dn-text-secondary);
    font-weight: 600;
}

.dn-topic-filter__mode-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Mode/Source choices are radios in a real GET <form> (Prompt 1486) so
 * selecting one only changes the checked state -- the panel stays open until
 * "Apply" submits (see topic_page_region.html's comment). The <input> is
 * visually hidden but stays in the accessibility tree and keyboard tab order;
 * its own :checked state drives the same pill/text look the old <a
 * aria-current> styling used, so nothing here changes visually versus 1484
 * except that it is now a real forms control. */
.dn-topic-filter__pill {
    display: inline-flex;
    align-items: center;
    height: 34px;
    border: 1px solid var(--dn-rule-subtle);
    border-radius: 999px;
    padding: 0 15px;
    color: var(--dn-text-primary);
    background: var(--dn-surface-panel);
    font-weight: 600;
    cursor: pointer;
}

.dn-topic-filter__pill input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.dn-topic-filter__pill:has(input:checked) {
    color: var(--color-panel-text);
    border-color: var(--color-panel);
    background: var(--color-panel);
}

.dn-topic-filter__pill:has(input:focus-visible) {
    outline: 2px solid var(--dn-accent-primary);
    outline-offset: 2px;
}

.dn-topic-filter__active a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    border-radius: 999px;
    padding: 0 12px;
    color: var(--dn-text-primary);
    background: var(--dn-rule-subtle);
    text-decoration: none;
}

.dn-topic-filter__active a b {
    font-weight: 400;
    opacity: 0.7;
}

/* Source rows read as plain text, not pills (filter.png), so the selected
 * state must carry its own weight/underline contrast instead of a chip
 * background -- and item 12's own constraint (styling that survives more than
 * one simultaneously-selected Source later) is exactly why this keys off
 * :checked on a real (future-multi-selectable) form control rather than a
 * single `selected_source_id === id` comparison baked into the class. */
.dn-topic-filter__source {
    display: inline-flex;
    align-items: center;
    padding-bottom: 1px;
    color: var(--dn-text-primary);
    cursor: pointer;
}

.dn-topic-filter__source input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.dn-topic-filter__source:has(input:checked) {
    color: var(--dn-text-primary);
    font-weight: 700;
    border-bottom: 2px solid var(--dn-accent-primary);
}

.dn-topic-filter__source:not(:has(input:checked)):hover {
    color: var(--dn-text-primary);
}

.dn-topic-filter__source:has(input:focus-visible) {
    outline: 2px solid var(--dn-accent-primary);
    outline-offset: 2px;
}

.dn-topic-filter__actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
}

.dn-topic-filter__apply {
    height: 38px;
    padding: 0 20px;
    border: 0;
    border-radius: var(--radius-md, 8px);
    background: var(--color-panel);
    color: var(--color-panel-text);
    font-family: var(--dn-font-body);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}

.dn-topic-filter__apply:hover {
    opacity: 0.9;
}

.dn-topic-filter__reset {
    color: var(--dn-text-secondary);
    font-family: var(--dn-font-body);
    font-size: 12.5px;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.dn-topic-filter__reset:hover {
    color: var(--dn-text-primary);
}

/* The expanded panel has its own reset action (--panel) once open, so the
 * quiet collapsed-state reset link next to the button would otherwise show
 * twice at once -- hide only that outer copy while open. */
.dn-topic-filter__details[open] ~ .dn-topic-filter__reset:not(.dn-topic-filter__reset--panel) {
    display: none;
}

/* ---------------------------------------------------------------------
 * Results heading + article list
 * ------------------------------------------------------------------- */

.dn-topic-results-heading {
    display: flex;
    align-items: baseline;
    gap: 16px;
    margin: 0 0 2px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--dn-rule-subtle);
    color: var(--dn-text-secondary);
    font-family: var(--dn-font-body);
    font-size: 13px;
}

.dn-topic-results-heading p {
    margin: 0;
}

.dn-topic-article {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr) auto;
    gap: 16px;
    align-items: start;
    padding: 16px 0;
    border-bottom: 1px solid var(--dn-rule-subtle);
}

.dn-topic-article__image {
    display: block;
    width: 140px;
    height: 94px;
    overflow: hidden;
    border-radius: var(--radius-sm, 4px);
    background: var(--dn-rule-subtle);
}

.dn-topic-article__image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dn-topic-article__body {
    min-width: 0;
}

.dn-topic-article h2 {
    margin: 0 0 6px;
    font-family: var(--dn-font-serif);
    font-weight: 700;
    font-size: 20px;
    line-height: 1.16;
}

.dn-topic-article h2 a {
    color: var(--dn-text-primary);
    text-decoration: none;
}

.dn-topic-article h2 a:hover {
    text-decoration: underline;
}

.dn-topic-article p {
    margin: 0 0 8px;
    color: var(--dn-text-secondary);
    font-family: var(--dn-font-serif);
    font-size: 14px;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.dn-topic-article__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    color: var(--dn-text-secondary);
    font-family: var(--dn-font-body);
    font-size: 11.5px;
}

.dn-topic-article__topics {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.dn-topic-article__topic-dot {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--dn-text-secondary);
    text-decoration: none;
}

.dn-topic-article__topic-dot i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--dn-accent-primary);
}

.dn-topic-article__topic-dot:hover {
    color: var(--dn-text-primary);
}

.dn-topic-article__tag {
    color: var(--dn-text-secondary);
}

.dn-topic-article__save {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-top: 2px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--dn-text-secondary);
    cursor: not-allowed;
}

.dn-topic-article__save .dout-news-icon {
    font-size: 18px;
}

.dn-topic-empty {
    padding: 40px 0;
    color: var(--dn-text-secondary);
    font-family: var(--dn-font-body);
    font-size: 15px;
}

.dn-topic-empty__title {
    margin: 0 0 6px;
    color: var(--dn-text-primary);
    font-size: 15px;
}

.dn-topic-empty__hint {
    margin: 0 0 14px;
    font-size: 13px;
}

.dn-topic-empty__reset {
    display: inline-block;
    color: var(--dn-text-primary);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.dn-topic-empty__reset:hover {
    color: var(--dn-accent-primary);
}

/* ---------------------------------------------------------------------
 * Pagination
 * ------------------------------------------------------------------- */

.dn-topic-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 32px;
    font-family: var(--dn-font-body);
}

.dn-topic-pagination__controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dn-topic-pagination__step,
.dn-topic-pagination__page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border-radius: var(--radius-sm, 4px);
    color: var(--dn-text-primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}

.dn-topic-pagination__page {
    padding: 0;
    width: 36px;
    min-width: 36px;
}

.dn-topic-pagination__page:hover {
    background: var(--dn-rule-subtle);
}

.dn-topic-pagination__page--current {
    color: var(--color-panel-text);
    background: var(--color-panel);
}

.dn-topic-pagination__ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 36px;
    color: var(--dn-text-secondary);
}

.dn-topic-pagination__step {
    gap: 6px;
    color: var(--dn-text-secondary);
    padding: 0 6px;
}

.dn-topic-pagination__step:hover {
    color: var(--dn-text-primary);
}

.dn-topic-pagination__step--next {
    color: var(--dn-text-primary);
    font-weight: 700;
}

.dn-topic-pagination__step .dout-news-icon {
    font-size: 15px;
}

.dn-topic-pagination__summary {
    margin: 0;
    color: var(--dn-text-secondary);
    font-size: 13px;
}

/* ---------------------------------------------------------------------
 * Sidebar
 * ------------------------------------------------------------------- */

.dn-topic-voice {
    padding: 0 0 22px;
    color: var(--dn-text-primary);
}

.dn-topic-voice .dout-news-icon {
    font-size: 24px;
    color: var(--dn-text-secondary);
}

.dn-topic-voice blockquote {
    margin: 16px 0 12px;
    font-family: var(--dn-font-serif);
    font-size: 19px;
    font-style: italic;
    line-height: 1.3;
}

/* Short decorative divider before the attribution line (category_page.png),
 * not the previous full-width rule under the whole block -- that rule is
 * gone; whitespace alone now separates this section from "About the topic". */
.dn-topic-voice__divider {
    display: block;
    width: 28px;
    height: 2px;
    margin: 0 0 10px;
    background: var(--dn-rule-subtle);
}

.dn-topic-voice p {
    margin: 0;
    font-family: var(--dn-font-body);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--dn-text-secondary);
}

/* Short decorative rule next to the heading (category_page.png's "О ТЕМЕ ──"/
 * "ДРУГИЕ ТЕМЫ ──"), reused for both sidebar module headings. */
.dn-topic-side-rule {
    flex: 1 1 auto;
    height: 1px;
    min-width: 16px;
    background: var(--dn-rule-subtle);
}

/* ---------------------------------------------------------------------
 * Responsive: this page is a desktop-only presentation, but keep it usable
 * down to a narrow desktop/tablet window rather than breaking outright.
 * ------------------------------------------------------------------- */

@media (max-width: 620px) {
    .dn-topic-filter__collapsed {
        flex-direction: column;
    }

    .dn-topic-filter__action {
        align-items: stretch;
        width: 100%;
    }

    .dn-topic-filter__details summary {
        justify-content: center;
        width: auto;
        min-width: 0;
        margin-left: 0;
    }

    .dn-topic-filter__first-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .dn-topic-filter__actions {
        align-self: flex-end;
    }

    .dn-topic-article {
        grid-template-columns: 104px minmax(0, 1fr);
        gap: 14px;
    }

    .dn-topic-article__image {
        width: 104px;
        height: 80px;
    }

    .dn-topic-article h2 {
        font-size: 19px;
    }

    .dn-topic-article__save {
        display: none;
    }

    .dn-topic-pagination {
        justify-content: center;
        text-align: center;
    }
}
