/**
 * QLINIQA News completion: real category archive and Single News enhancements.
 * Presentation only. Reuses the existing approved News token and card system.
 */

/* Category archive -------------------------------------------------------- */
/* The category archive is a continuation of the approved News homepage.
 * These changes are presentation-only; the existing WP category loop and
 * pagination remain authoritative in category.php.
 */
.qliniqa-news-category {
    --qna-column-gap: clamp(1rem, 1.65vw, 1.5rem);
    --qna-editorial-font: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --qna-ink: #17191d;
    --qna-muted: #5c6470;
    font-family: var(--qna-editorial-font);
    color: var(--qna-ink);
}

/* Keep the common site furniture typographically consistent. */
.qliniqa-news-category .qnh-header,
.qliniqa-news-category .qnh-category-nav,
.qliniqa-news-category .qnh-footer {
    font-family: var(--qna-editorial-font);
}

.qliniqa-news-category .qnh-category-nav {
    position: sticky;
    top: 5.15rem;
    z-index: 290;
    border: 0;
    border-block-end: 1px solid var(--qnh-border);
    border-radius: 0;
    background: rgba(255, 255, 255, .97);
}

.qliniqa-news-category .qnh-category-nav__list {
    display: flex;
    width: min(calc(100% - 4rem), 78rem);
    max-width: none;
    min-height: 4.25rem;
    align-items: center;
    justify-content: flex-start;
    gap: clamp(.9rem, 1.7vw, 1.5rem);
    margin-inline: auto;
    padding: 0;
}

/* Uniform tab boxes and label baseline, including the first (Novosti) item. */
.qliniqa-news-category .qnh-category-nav__list > li {
    display: flex;
    align-items: stretch;
    margin: 0;
    padding: 0;
}

/* The original homepage applies an optical offset to its first category.
 * The archive has text-only tabs, so that offset must not carry across.
 */
.qliniqa-news-category .qnh-category-nav__list > li:first-child .qnh-category-nav__label {
    position: static;
    top: auto;
}

.qliniqa-news-category .qnh-category-nav__link {
    display: inline-flex;
    min-height: 4.25rem;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding-inline: .15rem;
    color: var(--qna-muted);
    font-family: var(--qna-editorial-font);
    font-size: .86rem;
    font-weight: 500;
    line-height: 1;
    transform: none;
}

.qliniqa-news-category .qnh-category-nav__link:hover,
.qliniqa-news-category .qnh-category-nav__link:focus-visible,
.qliniqa-news-category .qnh-category-nav__link.is-active,
.qliniqa-news-category .qnh-category-nav__link[aria-current="page"] {
    color: #054ed5;
}

.qliniqa-news-category .qnh-category-nav__link.is-active::after {
    background: #054ed5;
    opacity: 1;
}

.qna-content {
    width: min(calc(100% - 4rem), 78rem);
    min-height: 55vh;
    padding-block: 1.25rem 4rem;
}

.qna-breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem;
    align-items: center;
    color: var(--qna-muted, #5c6470);
    font-size: .77rem;
}

.qna-breadcrumbs a:hover { color: #054ed5; }

.qna-heading {
    margin-block: 2.2rem 2rem;
    padding-block: 0 1.25rem;
    border-block-end: 1px solid #d9e2f1;
}

.qna-heading__eyebrow {
    margin: 0 0 .4rem;
    color: #054ed5;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.qna-heading h1 {
    margin: 0;
    color: var(--qna-ink, #17191d);
    font-family: var(--qna-editorial-font, "Inter", Arial, sans-serif);
    font-size: clamp(2rem, 3.3vw, 3rem);
    font-weight: 600;
    letter-spacing: -.025em;
    line-height: 1.12;
}

.qna-heading__description { margin-block-start: .7rem; color: var(--qna-muted, #5c6470); }
.qna-heading__description p { margin: 0; }

/* Archive grid preserves the existing query order and pagination, while
 * adopting the homepage's image ratio and neutral editorial card palette.
 */
.qna-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2rem var(--qna-column-gap, 1.15rem);
}

.qna-card { min-width: 0; }
.qna-card__link { display: block; height: 100%; color: inherit; text-decoration: none; }
.qna-card__media { overflow: hidden; aspect-ratio: 16 / 9; background: var(--qnh-primary-soft); }
.qna-card__image { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .2s ease; }
.qna-card__link:hover .qna-card__image { transform: scale(1.025); }
.qna-card__placeholder { display: block; width: 100%; height: 100%; background: linear-gradient(140deg, #eaf2ff, #cddff5); }
.qna-card__body { padding-block-start: .75rem; }
.qna-card__category {
    display: block;
    color: #054ed5;
    font-family: var(--qna-editorial-font, "Inter", Arial, sans-serif);
    font-size: .625rem;
    font-weight: 700;
    letter-spacing: .045em;
    line-height: 1.2;
    text-transform: uppercase;
}
.qna-card__body h2 {
    margin: .4rem 0 0;
    color: var(--qna-ink, #17191d);
    font-family: var(--qna-editorial-font, "Inter", Arial, sans-serif);
    font-size: clamp(.875rem, 1.15vw, 1rem);
    font-weight: 600;
    letter-spacing: -.015em;
    line-height: 1.35;
    text-wrap: pretty;
}
.qna-card__link:hover .qna-card__body h2,
.qna-card__link:focus-visible .qna-card__body h2 { color: #054ed5; }
.qna-card__link:focus-visible { outline: 2px solid #054ed5; outline-offset: 3px; }
.qna-card__body time { display: block; margin-block-start: .5rem; color: var(--qna-muted, #5c6470); font-size: .75rem; }

/* Pagination remains unchanged functionally: existing numbered links,
 * previous/next links, current-page semantics, and destinations are intact.
 */
.qna-pagination { margin-block-start: 3rem; }
.qna-pagination ul {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* WordPress renders the active page as a span and the others as anchors.
 * Normalize the surrounding list items and both element types so neither
 * can shift vertically when the current page changes.
 */
.qna-pagination ul > li {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
}

.qna-pagination .page-numbers:not(ul) {
    box-sizing: border-box;
    display: inline-flex;
    min-width: 2.5rem;
    width: auto;
    height: 2.5rem;
    min-height: 2.5rem;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0 .8rem;
    border: 1px solid var(--qnh-border);
    color: #054ed5;
    font-size: .85rem;
    line-height: 1;
    text-decoration: none;
    vertical-align: middle;
    transform: none;
}
.qna-pagination .page-numbers.current { border-color: #054ed5; background: #054ed5; color: #fff; }
.qna-pagination a:hover, .qna-pagination a:focus-visible { border-color: #054ed5; background: #eef4ff; }
.qna-pagination a:focus-visible { outline: 2px solid #054ed5; outline-offset: 2px; }
.qna-empty { min-height: 12rem; color: var(--qna-muted, #5c6470); }

/* Single News table of contents ----------------------------------------- */
/* The article column remains independent of the sticky reading index. */
.qvsn-reading-layout {
    display: grid;
    grid-template-columns: minmax(14rem, 16rem) minmax(0, 54rem);
    justify-content: center;
    align-items: start;
    gap: clamp(2rem, 4vw, 4.25rem);
    width: min(calc(100% - 4rem), 78rem);
    margin-inline: auto;
}

.qvsn-reading-layout .qvsn-article { width: 100%; min-width: 0; margin: 0; }

/* Reduce the excessive blank space below the author/date strip on desktop.
 * The original styles compounded reading-layout padding, the first content
 * section's margin, and the TOC's own top padding. Keep subsequent article
 * sections, sticky positioning, and compact/mobile spacing unchanged.
 */
@media (min-width: 62.0625rem) {
    body.qnh-client-single-news .qvsn-reading-layout {
        padding-block-start: 2rem;
    }

    body.qnh-client-single-news .qvsn-reading-layout > .qvsn-article {
        padding-block-start: 0;
    }

    body.qnh-client-single-news .qvsn-reading-layout > .qvsn-article > :first-child {
        margin-block-start: 0;
    }

    body.qnh-client-single-news .qvsn-reading-layout > .qvsn-toc {
        padding-block-start: 0;
    }
}

/* Match the approved staging reading index using the existing CMS markup. */
.qvsn-toc {
    position: sticky;
    top: 7.5rem;
    align-self: start;
    max-height: calc(100vh - 9rem);
    overflow-y: auto;
    padding-block-start: 3.5rem;
    scrollbar-width: thin;
}
.qvsn-toc h2 {
    margin: 0 0 .9rem;
    color: #17191d;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
}
.qvsn-toc ol {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 0;
    border-inline-start: 1px solid #d6d9df;
    list-style: none;
}
.qvsn-toc a {
    display: block;
    padding: .5rem .65rem .5rem 1rem;
    color: #383c43;
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: -.006em;
    line-height: 1.34;
    overflow-wrap: anywhere;
    text-decoration: none;
}
.qvsn-toc a:hover, .qvsn-toc a:focus-visible { color: #054ed5; }
.qvsn-toc a:focus-visible { outline: 2px solid #054ed5; outline-offset: 2px; }
.qvsn-toc li.is-subheading { padding-inline-start: .7rem; }
.qvsn-article :is(h2, h3)[id^="qvsn-heading-"] { scroll-margin-block-start: 8rem; }

/* Current reading position (staging-approved active TOC indicator).
 * The CMS uses plain anchors rather than the demo .qvsn-toc__link class.
 * Keep the indicator on the list item so subheadings share one baseline.
 */
body.qnh-client-single-news .qvsn-toc li {
    position: relative;
}

body.qnh-client-single-news .qvsn-toc li.is-active > a,
body.qnh-client-single-news .qvsn-toc a[aria-current="location"] {
    color: #17191d;
    font-weight: 600;
}

body.qnh-client-single-news .qvsn-toc li.is-active::before {
    position: absolute;
    top: .25rem;
    bottom: .25rem;
    left: -1px;
    width: 2px;
    background: #054ed5;
    content: "";
}

/* Editorial copy uses neutral ink; blue remains for navigation and promotion. */
body.qnh-client-single-news .qvsn-author strong,
body.qnh-client-single-news .qvsn-article :is(h1, h2, h3, h4, h5, h6),
body.qnh-client-single-news .qvsn-read-more-card > strong,
body.qnh-client-single-news .qvsn-most-read__item a,
body.qnh-client-single-news .qvsn-related-card h3,
body.qnh-client-single-news .qvsn-tags strong,
body.qnh-client-single-news .qvsn-share strong {
    color: #17191d;
}
body.qnh-client-single-news .qvsn-author span,
body.qnh-client-single-news .qvsn-author-strip time,
body.qnh-client-single-news .qvsn-breadcrumbs,
body.qnh-client-single-news .qvsn-figure figcaption {
    color: #5c6470;
}
body.qnh-client-single-news .qvsn-article :is(p, li),
body.qnh-client-single-news .qvsn-legacy-text :is(strong, em, blockquote) {
    color: #17191d;
}
body.qnh-client-single-news .qvsn-article .qvsn-lead {
    color: #17191d !important;
}
/* Keep the approved blue promotional heading as an intentional exception. */
body.qnh-client-single-news .qvsn-promo h2 { color: #054ed5; }
/* Preserve white lettering on the promotional CTA and other interaction UI. */
body.qnh-client-single-news .qvsn-promo > a { color: #fff; }

/* Single News taxonomy and sharing ----------------------------------------
 * Category and tag groups sit on the same editorial metadata row. Each group
 * wraps independently when content or available space requires it. This is a
 * presentation-only adjustment: term links and social destinations are intact.
 */
body.qnh-client-single-news .qvsn-article-footer {
    align-items: center;
    column-gap: clamp(1rem, 2vw, 2rem);
    row-gap: 1rem;
}

body.qnh-client-single-news .qvsn-article-taxonomy {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    min-width: 0;
    align-items: center;
    column-gap: clamp(1.15rem, 2.3vw, 2rem);
    row-gap: .65rem;
}

body.qnh-client-single-news .qvsn-article-taxonomy .qvsn-tags {
    display: inline-flex;
    flex-wrap: wrap;
    min-width: 0;
    align-items: center;
    gap: .45rem;
}

body.qnh-client-single-news .qvsn-article-taxonomy .qvsn-tags strong {
    margin-inline-end: .2rem;
    color: #17191d;
    font-size: .8rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

body.qnh-client-single-news .qvsn-article-taxonomy .qvsn-tags a {
    min-height: 2rem;
    padding: .3rem .75rem;
    font-size: .75rem;
    line-height: 1.3;
    text-decoration: none;
}

body.qnh-client-single-news .qvsn-article-taxonomy .qvsn-tags a:hover,
body.qnh-client-single-news .qvsn-article-taxonomy .qvsn-tags a:focus-visible {
    background: #dce8ff;
}

body.qnh-client-single-news .qvsn-article-taxonomy .qvsn-tags a:focus-visible {
    outline: 2px solid #054ed5;
    outline-offset: 2px;
}

body.qnh-client-single-news .qvsn-article-footer .qvsn-share {
    flex: 0 0 auto;
    margin-inline-start: auto;
}

@media (max-width: 55rem) {
    body.qnh-client-single-news .qvsn-article-footer {
        flex-wrap: wrap;
    }

    body.qnh-client-single-news .qvsn-article-footer .qvsn-share {
        margin-inline-start: 0;
    }
}

@media (max-width: 48rem) {
    body.qnh-client-single-news .qvsn-article-footer {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Related News: four columns, two rows, progressive Load More ------------- */
.qvsn-related__grid { row-gap: 1.5rem; }
.qvsn-related__controls { display: flex; flex-direction: column; align-items: center; gap: .65rem; margin-block-start: 1.6rem; }
.qvsn-related__more { min-height: 2.85rem; padding: .65rem 1.5rem; border: 1px solid var(--qnh-blue); border-radius: 4px; background: #fff; color: var(--qnh-blue); font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; }
.qvsn-related__more:hover { background: var(--qnh-primary-soft); }
.qvsn-related__more:disabled { cursor: wait; opacity: .6; }
.qvsn-related__more[hidden] { display: none; }
.qvsn-related__status { min-height: 1.4rem; color: var(--qnh-muted); font-size: .8rem; }
.qvsn-related__status:empty { display: none; }

@media (max-width: 70rem) {
    .qna-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .qvsn-reading-layout { grid-template-columns: minmax(12rem, 14rem) minmax(0, 1fr); }
}

@media (max-width: 62rem) {
    .qliniqa-news-category .qnh-category-nav { top: 4.25rem; }
    .qliniqa-news-category .qnh-category-nav__list { width: calc(100% - 2rem); overflow-x: auto; }
    .qvsn-reading-layout { display: block; width: min(calc(100% - 3rem), 54rem); }
    /* Compact layouts keep the index in the document flow; mobile disclosure follows in shared component phase. */
    .qvsn-toc { position: static; top: auto; max-height: none; overflow-y: visible; padding: 1.5rem 0 0; }
    .qvsn-toc ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .qvsn-reading-layout .qvsn-article { padding-block-start: 2rem; }
}

@media (max-width: 48rem) {
    /* Archive and search use the same text-only mobile category tabs as News.
     * Reset the framed-button rules inherited from the older demo breakpoint.
     */
    body.qliniqa-news-category .qnh-category-nav__list {
        min-height: 4rem;
        gap: 1.25rem;
    }

    body.qliniqa-news-category .qnh-category-nav__link {
        min-height: 4rem;
        padding-inline: .125rem;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        color: var(--qna-muted);
        font-size: .875rem;
        font-weight: 500;
    }

    body.qliniqa-news-category .qnh-category-nav__link:hover,
    body.qliniqa-news-category .qnh-category-nav__link:focus-visible {
        background: transparent;
        box-shadow: none;
        color: #054ed5;
    }

    body.qliniqa-news-category .qnh-category-nav__link.is-active,
    body.qliniqa-news-category .qnh-category-nav__link[aria-current="page"] {
        border: 0;
        background: transparent;
        color: #054ed5;
    }

    body.qliniqa-news-category .qnh-category-nav__link::after {
        right: 0;
        bottom: 0;
        left: 0;
        height: .14rem;
        background: transparent;
        opacity: 0;
    }

    body.qliniqa-news-category .qnh-category-nav__link.is-active::after,
    body.qliniqa-news-category .qnh-category-nav__link[aria-current="page"]::after {
        background: #054ed5;
        opacity: 1;
    }

    .qna-content { width: calc(100% - 2rem); padding-block-end: 2.5rem; }
    .qna-heading { margin-block: 1.5rem; }
    .qna-grid { grid-template-columns: 1fr; gap: 1.25rem; }

    /* 38% -> 49.5% makes article thumbnails about 30% wider on phones.
     * The text column remains flexible and the desktop grid is unchanged.
     */
    .qna-card__link {
        display: grid;
        grid-template-columns: minmax(0, 49.5%) minmax(0, 1fr);
        gap: .8rem;
    }

    .qna-card__media { aspect-ratio: 4 / 3; }
    .qna-card__body { padding-block-start: 0; }
    .qna-card__body h2 { font-size: 1rem; }
    .qvsn-reading-layout { width: calc(100% - 2rem); }
    .qvsn-toc ol { grid-template-columns: 1fr; }
    .qvsn-reading-layout .qvsn-article { width: 100%; padding-block-end: 2rem; }
}

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

/* Accessible mobile navigation until the common site header is extracted. */
.qnc-mobile-nav { display: none; }
.qnh-client-news-home .qnh-client-category-section[id] { scroll-margin-top: 10.5rem; }
.qvsn-reading-layout--no-toc {
    grid-template-columns: minmax(0, 54rem);
    width: min(calc(100% - 3rem), 54rem);
}

@media (max-width: 62rem) {
    .qliniqa-news-category .qnh-header__inner,
    .qliniqa-single-news .qnh-header__inner {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    .qnc-mobile-nav { position: relative; display: block; margin-inline-start: auto; }
    .qnc-mobile-nav summary {
        display: flex;
        min-height: 2.5rem;
        align-items: center;
        padding: .45rem .7rem;
        border: 1px solid var(--qnh-border);
        border-radius: 4px;
        color: var(--qnh-blue);
        font-size: .84rem;
        font-weight: 700;
        cursor: pointer;
    }
    .qnc-mobile-nav nav {
        position: absolute;
        z-index: 500;
        top: calc(100% + .5rem);
        right: 0;
        display: grid;
        min-width: 12rem;
        padding: .5rem;
        border: 1px solid var(--qnh-border);
        border-radius: 4px;
        background: #fff;
        box-shadow: var(--qnh-shadow-medium);
    }
    .qnc-mobile-nav nav a {
        display: block;
        padding: .65rem .75rem;
        color: var(--qnh-blue);
        font-size: .85rem;
    }
    .qnc-mobile-nav nav a:focus-visible,
    .qnc-mobile-nav nav a:hover { background: var(--qnh-primary-soft); }
    .qvsn-reading-layout--no-toc { width: min(calc(100% - 3rem), 54rem); }
}

@media (max-width: 48rem) {
    .qnh-client-news-home .qnh-client-category-section[id] { scroll-margin-top: 9rem; }
    .qvsn-reading-layout--no-toc { width: calc(100% - 2rem); }
}

/* QLINIQA Single News — compact sticky reading index.
 * Desktop maintains its existing always-visible sidebar. On mobile the
 * current heading is visible; readers expand only via the disclosure control.
 */
.qvsn-toc__toggle { display: none; }
.qvsn-toc__panel { display: block; }

@media (max-width: 62rem) {
    body.qnh-client-single-news .qvsn-reading-layout {
        overflow: visible;
    }

    body.qnh-client-single-news .qvsn-reading-layout > .qvsn-toc {
        position: sticky;
        z-index: 295;
        top: 4.25rem;
        width: 100%;
        max-height: none;
        margin: 0;
        padding: 0;
        overflow: visible;
        background: rgb(255 255 255 / 0.98);
        box-shadow: 0 1px 0 #e2e8f1;
    }

    body.qnh-client-single-news .qvsn-toc--enhanced .qvsn-toc__toggle {
        display: grid;
        width: 100%;
        min-height: 3.25rem;
        grid-template-columns: auto minmax(0, 1fr) auto;
        align-items: center;
        gap: 0.75rem;
        padding: 0.65rem 0.6rem;
        border: 0;
        background: transparent;
        color: #17191d;
        font: inherit;
        text-align: left;
        cursor: pointer;
    }

    body.qnh-client-single-news .qvsn-toc__toggle-label {
        color: #17191d;
        font-size: 0.9rem;
        font-weight: 700;
    }

    body.qnh-client-single-news .qvsn-toc__current {
        overflow: hidden;
        color: #5c6470;
        font-size: 0.825rem;
        font-weight: 500;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body.qnh-client-single-news .qvsn-toc__arrow {
        transition: transform 180ms ease;
    }

    body.qnh-client-single-news .qvsn-toc.is-open .qvsn-toc__arrow {
        transform: rotate(180deg);
    }

    body.qnh-client-single-news .qvsn-toc__toggle:focus-visible {
        outline: 2px solid #054ed5;
        outline-offset: -2px;
    }

    body.qnh-client-single-news .qvsn-toc--enhanced .qvsn-toc__panel {
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        display: none;
        max-height: min(65svh, 28rem);
        overflow-y: auto;
        padding: 0.75rem 0.5rem 0.9rem;
        border-block-end: 1px solid #d6d9df;
        background: #fff;
        box-shadow: 0 0.6rem 1.2rem rgb(10 36 99 / 0.09);
    }

    body.qnh-client-single-news .qvsn-toc--enhanced.is-open .qvsn-toc__panel {
        display: block;
    }

    body.qnh-client-single-news .qvsn-toc__panel > h2 {
        display: none;
    }

    body.qnh-client-single-news .qvsn-toc ol {
        display: grid;
        grid-template-columns: 1fr;
    }

    body.qnh-client-single-news .qvsn-reading-layout > .qvsn-article {
        padding-block-start: 1.5rem;
    }
}

@media (max-width: 62rem) and (prefers-reduced-motion: reduce) {
    body.qnh-client-single-news .qvsn-toc__arrow { transition: none; }
}
