/*
 * Nykysuomi dark-mode overrides.
 * Loaded after the parent theme's dark-mode stylesheet. The parent controls
 * system detection, the manual toggle and persisted preference.
 */
:is(html.aeon-dark-mode-active, body.dark-mode) {
    color-scheme: dark;
    --nyk-night: #0b1d2a;
    --nyk-night-raised: #102735;
    --nyk-night-soft: #163548;
    --nyk-night-deep: #071724;
    --nyk-night-line: #29495d;
    --nyk-night-text: #edf5fa;
    --nyk-night-muted: #a9bdca;
    --nyk-night-link: #70bce5;
}

:is(html.aeon-dark-mode-active, body.dark-mode) body,
body.dark-mode {
    color: var(--nyk-night-text) !important;
    background: var(--nyk-night) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) .nyk-brand__wordmark {
    color: var(--nyk-night-text);
}

:is(html.aeon-dark-mode-active, body.dark-mode) .nyk-brand__tagline {
    color: var(--nyk-sky);
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .main-header,
    .sticky-header,
    .off-canvas-menu,
    .footer-main,
    .site-main,
    .site-content,
    #primary,
    #secondary,
    .content-area,
    .widget-area,
    .widget,
    article,
    .post,
    .page,
    .news-item,
    .archive-post,
    .search-post,
    .single-post-content,
    .entry-content,
    .comments-area,
    .comment-body,
    .author-box,
    .related-posts,
    .modal-content
) {
    color: var(--nyk-night-text);
    background-color: var(--nyk-night-raised) !important;
    border-color: var(--nyk-night-line) !important;
}

/* Beat the parent bundle's equally important wrapper rules and inline values. */
html.aeon-dark-mode-active body .main-section,
html.aeon-dark-mode-active body .single-main-section,
html.aeon-dark-mode-active body .container,
html.aeon-dark-mode-active body .single-container,
body.dark-mode .main-section,
body.dark-mode .single-main-section,
body.dark-mode .container,
body.dark-mode .single-container {
    background: var(--nyk-night-raised) !important;
    border-color: var(--nyk-night-line) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(.top-bar, .mobile-top-bar) {
    color: var(--nyk-night-muted);
    background: var(--nyk-night-soft) !important;
    border-color: var(--nyk-night-line) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    header.site-header,
    .off-canvas-header,
    .news-item,
    .widget,
    hr,
    table,
    th,
    td,
    fieldset,
    blockquote
) {
    border-color: var(--nyk-night-line) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    h1, h2, h3, h4, h5, h6,
    .entry-title,
    .entry-title a,
    .nav-link,
    .off-canvas-menu a,
    .footer-column h4,
    .search-btn,
    .menu-toggle,
    .sticky-search-btn,
    .nav-close,
    label,
    strong
) {
    color: var(--nyk-night-text) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    p,
    .entry-meta,
    .meta,
    .excerpt,
    .current-date,
    .mobile-date,
    .sticky-current-date,
    .weather-info,
    .mobile-weather,
    .footer-description,
    .off-canvas-menu .nav-footer,
    figcaption
) {
    color: var(--nyk-night-muted) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(a, .article-topic, .column1-category) {
    color: var(--nyk-night-link);
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(a, button):hover {
    color: #a6dcf7;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .nav-link:hover,
    .nav-link:focus-visible,
    .search-btn:hover,
    .menu-toggle:hover,
    .sticky-search-btn:hover,
    .aeon-dm-toggle:hover,
    .footer-social a
) {
    color: var(--nyk-night-text) !important;
    background: var(--nyk-night-soft) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    input:not([type="checkbox"]):not([type="radio"]),
    select,
    textarea,
    .search-field,
    .wp-block-search__input
) {
    color: var(--nyk-night-text) !important;
    background: #091722 !important;
    border-color: #3c5668 !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    input:not([type="checkbox"]):not([type="radio"]),
    textarea
)::placeholder {
    color: #8da3b2;
    opacity: 1;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    button:not(.menu-toggle):not(.nav-close):not(.aeon-dm-toggle),
    input[type="submit"],
    .button,
    .wp-element-button,
    .wp-block-button__link
) {
    color: #fff !important;
    background: var(--nyk-deep-blue) !important;
    border-color: #70bce5 !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) .newsroom-cta {
    color: #fff;
    background: #164f73 !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) .newsroom-cta :where(h2, p, a) {
    color: #fff !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) .newsroom-cta__eyebrow {
    color: #bfe4f7 !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) .newsroom-cta__button:hover {
    color: var(--nyk-ink) !important;
    background: #fff !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) .footer-bottom {
    background: #040a10 !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) .off-canvas-overlay {
    background: rgba(0, 0, 0, 0.76);
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(.dropdown-menu, .sub-menu) {
    color: var(--nyk-night-text);
    background: var(--nyk-night-soft) !important;
    border-color: var(--nyk-night-line) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .post-thumbnail-col1 img,
    .wp-post-image,
    .entry-content img
) {
    background: var(--nyk-night-soft);
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(code, pre, .wp-block-code) {
    color: #dcebf4;
    background: #06101a !important;
    border-color: var(--nyk-night-line) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(.pagination a, .page-numbers) {
    color: var(--nyk-night-text) !important;
    background: var(--nyk-night-soft) !important;
    border-color: var(--nyk-night-line) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(.pagination .current, .page-numbers.current) {
    background: var(--nyk-deep-blue) !important;
}

/* Pagination belongs to the content surface, not a separate pale-blue tile. */
:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .pagination,
    .pagination .nav-links,
    .aeon-search-pagination,
    .wp-pagenavi,
    .page-links,
    ul.page-numbers
) {
    background: transparent !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .pagination a,
    .pagination span.page-numbers,
    .aeon-search-pagination .page-numbers,
    .wp-pagenavi a,
    .wp-pagenavi span,
    .page-links a,
    .page-links > span,
    ul.page-numbers > li > a,
    ul.page-numbers > li > span
) {
    color: var(--nyk-night-text) !important;
    background: var(--nyk-night-raised) !important;
    border-color: var(--nyk-night-line) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .pagination .current,
    .pagination .page-numbers.current,
    .aeon-search-pagination .current,
    .wp-pagenavi span.current,
    .page-links > span,
    ul.page-numbers > li > .current
) {
    color: #fff !important;
    background: var(--nyk-deep-blue) !important;
    border-color: var(--nyk-deep-blue) !important;
}

/*
 * The parent theme writes light background colours directly on several page
 * wrappers. Keep the complete canvas in the Nykysuomi blue family instead of
 * allowing black/grey gutters or white islands to leak through.
 */
:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .main-section,
    .single-main-section,
    .page-content,
    .default-page,
    .archive,
    .author-profile-page
) {
    color: var(--nyk-night-text) !important;
    background: var(--nyk-night) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .container,
    .single-container,
    #newMain,
    #first_col,
    #single_first_col,
    .single-view,
    .single-post-content,
    .single-content-area,
    .content-area,
    .full-content-area,
    .second-col,
    .third-col3aeon-news,
    .third-col,
    .right-sidebar,
    .single-ext-2nd-col,
    .page-sidebar,
    .search-page,
    .search-third-col3aeon-news,
    .aeon-responsive-sidebar,
    .social-area,
    .row-social,
    .tag-list
) {
    color: var(--nyk-night-text) !important;
    background: var(--nyk-night-raised) !important;
    border-color: var(--nyk-night-line) !important;
}

/* Widget rows inherit the rail surface; avoid pale-blue tiles behind metadata
 * and ranked rows when the parent or plugin stylesheet supplies a background. */
:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .widget,
    .notiser_widget,
    .aeon-most-visit-container,
    .aeon-popular-posts,
    .nyk-curated-category-posts,
    .aeon-latest-wire
) {
    background: var(--nyk-night-raised) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .notiser_widget li,
    .notiser-news-item,
    .notiser-news-item .meta,
    .aeon-latest-wire__item,
    .aeon-latest-wire__article,
    .aeon-most-visit-item,
    .most-visit-item,
    .nyk-curated-category-posts__item
) {
    background: transparent !important;
    border-color: var(--nyk-night-line) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .nyk-drawer-group h2,
    .nyk-drawer-utility,
    .footer-links a
) {
    color: var(--nyk-night-muted) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .first_col_hr hr,
    .nyk-drawer-utility,
    .off-canvas-menu .nav-footer
) {
    border-color: var(--nyk-night-line) !important;
}

/* Parent uses an equally important, highly specific legacy gray here. */
html.aeon-dark-mode-active body .first_col_hr hr,
body.dark-mode .main-section .first_col_hr hr {
    border-color: var(--nyk-night-line) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .second-col .widget,
    .third-col3aeon-news .widget,
    .right-sidebar .widget,
    .page-sidebar .widget,
    .archive-post,
    .search-post,
    .related-single-post,
    #single-extend-area,
    .comments-area,
    .author-signature,
    .top-cont-author,
    .below-cont-author,
    .informationsruta,
    .wp-block-group,
    .wp-block-cover__inner-container
) {
    color: var(--nyk-night-text) !important;
    background: var(--nyk-night-raised) !important;
    border-color: var(--nyk-night-line) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) .single .tag-list a {
    color: var(--nyk-night-text) !important;
    background: var(--nyk-night-soft) !important;
    border-color: var(--nyk-night-line) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) .single .tag-list a:is(:hover, :focus-visible) {
    color: #fff !important;
    background: var(--nyk-deep-blue) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .ticker-area,
    .ticker
) {
    color: var(--nyk-night-text) !important;
    background: var(--nyk-night-raised) !important;
    border-color: var(--nyk-night-line) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .tabs,
    .notiser_widget,
    .aeon-most-visit-container,
    .position-2-index,
    .below-content-widget,
    .below-cont-post-conditional,
    .below_article_non_repeat,
    .above-comment-widget
) {
    color: var(--nyk-night-text) !important;
    background: var(--nyk-night-soft) !important;
    border-color: var(--nyk-night-line) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .row-social,
    .social-area,
    .tag-list
) {
    box-shadow: none !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) .share-container {
    color: var(--nyk-night-text);
    background: transparent !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) .share-button {
    min-height: 44px;
    padding: 0 14px !important;
    border: 1px solid var(--nyk-night-line) !important;
    border-radius: 999px;
    color: var(--nyk-night-text) !important;
    background: var(--nyk-night-soft) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) .share-button:hover,
:is(html.aeon-dark-mode-active, body.dark-mode) .share-button:focus-visible {
    color: #fff !important;
    background: var(--nyk-deep-blue) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) .share-dropdown {
    overflow: hidden;
    background: var(--nyk-night-soft) !important;
    border-color: var(--nyk-night-line) !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.32) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) .share-dropdown li,
:is(html.aeon-dark-mode-active, body.dark-mode) .share-dropdown a {
    color: var(--nyk-night-text) !important;
    border-color: var(--nyk-night-line) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) .share-dropdown a:hover,
:is(html.aeon-dark-mode-active, body.dark-mode) .share-dropdown a:focus-visible {
    color: #fff !important;
    background: var(--nyk-deep-blue) !important;
}

/* Keep nested feeds on the rail surface after the parent widget rules. */
.site-header .aeon-dm-toggle.aeon-dm-toggle-icon,
.off-canvas-menu .aeon-dm-toggle.aeon-dm-toggle-icon {
    position: relative !important;
    inset: auto !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
    vertical-align: middle !important;
}

.site-header .aeon-dark-mode-toggle-wrapper,
.off-canvas-menu .aeon-dark-mode-toggle-wrapper {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px;
    height: 44px;
    line-height: 1 !important;
}

.site-header .aeon-dm-toggle-icon > span,
.off-canvas-menu .aeon-dm-toggle-icon > span {
    inset: 0 !important;
    align-items: center !important;
    justify-content: center !important;
}

.site-header .aeon-dm-toggle-icon .aeon-dm-icon-sun,
.off-canvas-menu .aeon-dm-toggle-icon .aeon-dm-icon-sun {
    display: flex !important;
}

.site-header .aeon-dm-toggle-icon .aeon-dm-icon-moon,
.off-canvas-menu .aeon-dm-toggle-icon .aeon-dm-icon-moon {
    display: none !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) .site-header .aeon-dm-toggle-icon .aeon-dm-icon-sun,
:is(html.aeon-dark-mode-active, body.dark-mode) .off-canvas-menu .aeon-dm-toggle-icon .aeon-dm-icon-sun {
    display: none !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) .site-header .aeon-dm-toggle-icon .aeon-dm-icon-moon,
:is(html.aeon-dark-mode-active, body.dark-mode) .off-canvas-menu .aeon-dm-toggle-icon .aeon-dm-icon-moon {
    display: flex !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .notiser_widget,
    .aeon-most-visit-container,
    .aeon-popular-posts,
    .nyk-curated-category-posts,
    .aeon-latest-wire
) {
    background: var(--nyk-night-raised) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .notiser_widget li,
    .notiser-news-item,
    .notiser-news-item .meta,
    .aeon-latest-wire__item,
    .aeon-latest-wire__article,
    .aeon-most-visit-item,
    .most-visit-item,
    .nyk-curated-category-posts__item
) {
    background: transparent !important;
    border-color: var(--nyk-night-line) !important;
}

/* Match the light-mode label affordance without reintroducing blue tiles. */
:is(html.aeon-dark-mode-active, body.dark-mode) body :is(
    a.article-topic,
    .article-topic-link,
    .article-category,
    .column1-category
) {
    color: var(--nyk-night-text) !important;
    background: var(--nyk-night-soft) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) body .article-category a {
    color: inherit !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) body.single .single-title-area-rht .article-category {
    color: var(--nyk-night-text) !important;
    background: transparent !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) body .article-topic {
    border-left-color: var(--nyk-sky);
}

:is(html.aeon-dark-mode-active, body.dark-mode) body :is(
    a.article-topic,
    .article-topic-link,
    .article-category a
):is(:hover, :focus-visible) {
    color: #fff !important;
    background: var(--nyk-deep-blue) !important;
}

/* Archive search is a parent component with its own black/grey night palette.
 * Bring every state into Nykysuomi's blue surface hierarchy. */
:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .aeon-archive-search,
    .aeon-search-form-card,
    .aeon-search-hero,
    .aeon-search-filters,
    .aeon-search-results
) {
    color: var(--nyk-night-text) !important;
    background: var(--nyk-night-raised) !important;
    border-color: var(--nyk-night-line) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .aeon-search-title,
    .aeon-search-filters h2,
    .aeon-search-results-header h2,
    .aeon-search-result-title a,
    .aeon-search-empty h3
) {
    color: var(--nyk-night-text) !important;
    background: transparent !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .aeon-search-description,
    .aeon-search-results-header p,
    .aeon-search-result-body p,
    .aeon-search-result-meta,
    .aeon-search-empty p
) {
    color: var(--nyk-night-muted) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .aeon-search-filters-tip,
    .aeon-search-result-card,
    .aeon-search-empty
) {
    color: var(--nyk-night-text) !important;
    background: var(--nyk-night-soft) !important;
    border-color: var(--nyk-night-line) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .aeon-search-primary-field input,
    .aeon-search-field input,
    .aeon-search-field select,
    .aeon-search-presets button,
    .aeon-search-filter-toggle,
    .aeon-search-clear,
    .aeon-search-chip,
    .aeon-search-clear-all
) {
    color: var(--nyk-night-text) !important;
    background: var(--nyk-night-deep) !important;
    border-color: var(--nyk-night-line) !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) .aeon-search-highlight {
    color: #fff3c4 !important;
    background: #66520f !important;
}

:is(html.aeon-dark-mode-active, body.dark-mode) :where(
    .site-footer,
    footer.site-footer
) {
    color: var(--nyk-night-text) !important;
    background: var(--nyk-night-deep) !important;
    border-color: var(--nyk-night-line) !important;
}

/* The parent currently hardcodes archive rules in both light and dark CSS. */
:is(html.aeon-dark-mode-active, body.dark-mode) body.archive h3.debatt,
:is(html.aeon-dark-mode-active, body.dark-mode) body.archive h3.insandare {
    border-top-color: var(--nyk-sky) !important;
    border-bottom-color: var(--nyk-night-line) !important;
}

/* Keep the close glyph legible when its dark-mode hover/focus surface turns white. */
:is(html.aeon-dark-mode-active, body.dark-mode) .off-canvas-menu .nav-close:is(:hover, :focus-visible) {
    color: #617383 !important;
    background-color: #fff !important;
    border-radius: 50%;
}

:is(html.aeon-dark-mode-active, body.dark-mode) .off-canvas-menu .nav-close:is(:hover, :focus-visible) i {
    color: inherit !important;
}

@media (prefers-reduced-motion: reduce) {
    .off-canvas-menu,
    .off-canvas-overlay,
    .sticky-header,
    .off-canvas-menu .nav-close,
    .off-canvas-menu .nav-close i {
        transition: none !important;
    }
}
