/* HAW relaunch fixes, loaded after t3up and the site's brand stylesheet.
   Explicit dark mode and operating-system dark mode use the same palette. */
html:is([color-mode="dark"], [color-mode="system-dark"]) {
    color-scheme: dark;
    --haw-dark-bg: #151515;
    --haw-dark-panel: #222222;
    --haw-dark-text: #f5f5f5;
    --haw-dark-link: #b8dcff;
    --bs-body-bg: var(--haw-dark-bg);
    --bs-body-color: var(--haw-dark-text);
    --bs-emphasis-color: #ffffff;
    --bs-secondary-color: #d0d0d0;
    --bs-tertiary-color: #c0c0c0;
    --bs-secondary-bg: var(--haw-dark-panel);
    --bs-tertiary-bg: #2b2b2b;
    --bs-border-color: #777777;
}

html:is([color-mode="dark"], [color-mode="system-dark"]) body {
    background: var(--haw-dark-bg) !important;
    color: var(--haw-dark-text);
}

html:is([color-mode="dark"], [color-mode="system-dark"]) #content {
    color: var(--haw-dark-text);
}

/* This specificity also wins against brand rules such as
   .content h2:first-of-type; headings must remain readable on dark panels. */
html:is([color-mode="dark"], [color-mode="system-dark"]) #content :is(h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4) {
    color: #ffffff !important;
}

html:is([color-mode="dark"], [color-mode="system-dark"]) #content :is(.frame-white, .frame-grey, .frame-colored, .news .article) {
    background-color: var(--haw-dark-panel) !important;
    color: var(--haw-dark-text);
}

/* t3up gives the inner accordion its own white background; darkening only
   the outer .frame-white leaves white headings/links on a white panel.
   Explicit colours also cover the bundled Bootstrap 5.0 compiled rules,
   while the variables support components using Bootstrap's newer variables. */
html:is([color-mode="dark"], [color-mode="system-dark"]) #content :is(.frame-accordion.frame-white .t3up_accordion, .accordion-item, .accordion-button, .card, .card-header, .card-footer, .bg-white, .bg-light) {
    background-color: var(--haw-dark-panel) !important;
    color: var(--haw-dark-text);
}

html:is([color-mode="dark"], [color-mode="system-dark"]) #content .accordion {
    --bs-accordion-color: var(--haw-dark-text);
    --bs-accordion-bg: var(--haw-dark-panel);
    --bs-accordion-btn-color: var(--haw-dark-text);
    --bs-accordion-btn-bg: var(--haw-dark-panel);
    --bs-accordion-active-color: #ffffff;
    --bs-accordion-active-bg: var(--haw-dark-panel);
    --bs-accordion-border-color: var(--bs-border-color);
}

html:is([color-mode="dark"], [color-mode="system-dark"]) #content .card {
    --bs-card-color: var(--haw-dark-text);
    --bs-card-bg: var(--haw-dark-panel);
    --bs-card-cap-color: var(--haw-dark-text);
    --bs-card-cap-bg: var(--haw-dark-panel);
    --bs-card-border-color: var(--bs-border-color);
}

html:is([color-mode="dark"], [color-mode="system-dark"]) #content :is(.card, .accordion, .bg-white, .bg-light):is(.text-body, .text-dark, .text-black),
html:is([color-mode="dark"], [color-mode="system-dark"]) #content :is(.card, .accordion, .bg-white, .bg-light) :is(.text-body, .text-dark, .text-black) {
    color: var(--haw-dark-text) !important;
}

html:is([color-mode="dark"], [color-mode="system-dark"]) #content :is(.card, .accordion, .bg-white, .bg-light):is(.text-muted, .text-secondary),
html:is([color-mode="dark"], [color-mode="system-dark"]) #content :is(.card, .accordion, .bg-white, .bg-light) :is(.text-muted, .text-secondary) {
    color: var(--bs-secondary-color) !important;
}

html:is([color-mode="dark"], [color-mode="system-dark"]) #content a:not(.btn) {
    color: var(--haw-dark-link) !important;
}

html:is([color-mode="dark"], [color-mode="system-dark"]) #content a:not(.btn):is(:hover, :focus) {
    color: #ffffff !important;
    text-decoration: underline;
}

html:is([color-mode="dark"], [color-mode="system-dark"]) #content .subnavigation li {
    background-color: var(--haw-dark-panel) !important;
    color: var(--haw-dark-text);
}

html:is([color-mode="dark"], [color-mode="system-dark"]) #header,
html:is([color-mode="dark"], [color-mode="system-dark"]) #header :is(.top, .tab-pane, .mainNavigtion .box, .mainNavigtion ul) {
    background-color: var(--haw-dark-bg) !important;
    color: var(--haw-dark-text);
}

html:is([color-mode="dark"], [color-mode="system-dark"]) #header :is(a, .symbol, .symbol-outline, .sym, .funcItemTitle, .nextlevel),
html:is([color-mode="dark"], [color-mode="system-dark"]) #header .tab-pane :is(b, h2, h3, h4, label) {
    color: var(--haw-dark-text) !important;
}

/* Keep the existing multicoloured logo readable without inverting its colours. */
html:is([color-mode="dark"], [color-mode="system-dark"]) #header :is(.logo, .mobillogo) img {
    background: #ffffff;
    border-radius: 0.2rem;
    padding: 0.25rem;
    box-sizing: border-box;
}

html:is([color-mode="dark"], [color-mode="system-dark"]) #header .nav_burger::before {
    border-color: var(--haw-dark-text);
}

html:is([color-mode="dark"], [color-mode="system-dark"]) #header .nav_burger::after,
html:is([color-mode="dark"], [color-mode="system-dark"]) #header .nav_burger.act::before {
    background-color: var(--haw-dark-text);
}

html:is([color-mode="dark"], [color-mode="system-dark"]) #footer,
html:is([color-mode="dark"], [color-mode="system-dark"]) #footer :is(.footer1, .footer2, .footer3) {
    background-color: var(--haw-dark-bg) !important;
    color: var(--haw-dark-text);
}

html:is([color-mode="dark"], [color-mode="system-dark"]) #footer :is(p, h2, h3, h4, li, span) {
    color: var(--haw-dark-text) !important;
}

html:is([color-mode="dark"], [color-mode="system-dark"]) #footer a {
    color: var(--haw-dark-link) !important;
}

/* Jump links are visible when reached by keyboard. They remain real links. */
#jumpto {
    list-style: none;
    margin: 0;
    padding: 0;
}

#jumpto a {
    position: fixed;
    z-index: 2000;
    top: 0;
    left: 1rem;
    padding: 0.75rem 1rem;
    transform: translateY(-150%);
    color: #151515 !important;
    background: #ffffff !important;
    text-decoration: underline;
}

#jumpto a:focus {
    transform: translateY(0);
    outline: 3px solid #004b92;
    outline-offset: 2px;
}

#content {
    scroll-margin-top: 8rem;
}
