/* Dark-theme overlay for the Sandcastle (SHFB) reference documentation.

   Used in two ways:
     1. linked directly on /web-pdf-viewer/documentation/reference/*, where the
        generated topic HTML is rendered inline in the site layout;
     2. injected by /assets/js/tw-iframe-dark.js into the <iframe> documents of
        /pdf-print-net/reference and /twainscanning-net/reference (the injector
        also stamps data-theme="dark" on the frame's <html> so these selectors
        match there too).

   Everything is scoped to .tw-sandcastle - the wrapper around the generated
   markup on the inline page, and the frame <body> in the iframe case. Without
   it the generic selectors below (a:visited, td, h2, ...) would repaint the
   surrounding site chrome on the inline page.

   Colours are literal: inside an iframe document the :root custom properties
   from master.css are not available.

   Two Sandcastle generations are covered: the older "OH_*" branding (PdfPrint,
   TwainScanning) and the newer lowercase branding (Web PDF Viewer), plus the
   TOC frame styled by TOC.css. */

/* Native scrollbars inside the frame documents follow this. */
[data-theme="dark"] {
    color-scheme: dark;
}

/* ===== Page canvas ===== */

[data-theme="dark"] .tw-sandcastle,
[data-theme="dark"] .tw-sandcastle .OH_outerDiv,
[data-theme="dark"] .tw-sandcastle .TopicContent {
    background-color: #0f1219;
    color: #e2e8f0;
}

[data-theme="dark"] .tw-sandcastle .OH_outerContent,
[data-theme="dark"] .tw-sandcastle .topicContent {
    border-left-color: #2a3444;
}

[data-theme="dark"] .tw-sandcastle .OH_footer,
[data-theme="dark"] .tw-sandcastle .pageFooter {
    border-top-color: #2a3444;
}

[data-theme="dark"] .tw-sandcastle .pageHeader {
    background-color: #1a2332;
    color: #cbd5e1;
}

/* ===== Headings and links ===== */

[data-theme="dark"] .tw-sandcastle h1,
[data-theme="dark"] .tw-sandcastle h2,
[data-theme="dark"] .tw-sandcastle h3,
[data-theme="dark"] .tw-sandcastle h4,
[data-theme="dark"] .tw-sandcastle h5,
[data-theme="dark"] .tw-sandcastle h6,
[data-theme="dark"] .tw-sandcastle .subHeading,
[data-theme="dark"] .tw-sandcastle .OH_tdTitleColumn,
[data-theme="dark"] .tw-sandcastle .OH_regiontitle,
[data-theme="dark"] .tw-sandcastle h1.ps_glossaryTitle,
[data-theme="dark"] .tw-sandcastle h2.ps_glossaryDivHeading {
    color: #93c5fd;
}

[data-theme="dark"] .tw-sandcastle .OH_regiontitle {
    background-color: transparent;
}

[data-theme="dark"] .tw-sandcastle .OH_tdRunningTitleColumn,
[data-theme="dark"] .tw-sandcastle div.preliminary,
[data-theme="dark"] .tw-sandcastle h3.glossaryGroupHeading,
[data-theme="dark"] .tw-sandcastle h3.ps_glossaryGroupHeading {
    color: #94a3b8;
}

[data-theme="dark"] .tw-sandcastle a,
[data-theme="dark"] .tw-sandcastle a:link {
    color: #60a5fa;
}

[data-theme="dark"] .tw-sandcastle a:visited {
    color: #c084fc;
}

[data-theme="dark"] .tw-sandcastle a:hover,
[data-theme="dark"] .tw-sandcastle a:active {
    color: #93c5fd;
}

[data-theme="dark"] .tw-sandcastle div.caption,
[data-theme="dark"] .tw-sandcastle span.selflink {
    color: #93c5fd;
}

/* ===== Tables ===== */

[data-theme="dark"] .tw-sandcastle div.OH_outerContent table,
[data-theme="dark"] .tw-sandcastle div.OH_outerContent table th,
[data-theme="dark"] .tw-sandcastle div.OH_outerContent table td,
[data-theme="dark"] .tw-sandcastle div.OH_outerContent div#mainSection table th,
[data-theme="dark"] .tw-sandcastle div.OH_outerContent div#mainSection table td,
[data-theme="dark"] .tw-sandcastle .members td,
[data-theme="dark"] .tw-sandcastle td,
[data-theme="dark"] .tw-sandcastle th {
    border-color: #2a3444;
}

[data-theme="dark"] .tw-sandcastle div.OH_outerContent table th,
[data-theme="dark"] .tw-sandcastle div.OH_outerContent div#mainSection table th,
[data-theme="dark"] .tw-sandcastle .members th,
[data-theme="dark"] .tw-sandcastle th {
    background-color: #253548;
    color: #e2e8f0;
}

[data-theme="dark"] .tw-sandcastle div.OH_outerContent table td,
[data-theme="dark"] .tw-sandcastle div.OH_outerContent div#mainSection table td,
[data-theme="dark"] .tw-sandcastle td {
    color: #e2e8f0;
}

/* ===== Collapsible sections ===== */

[data-theme="dark"] .tw-sandcastle .OH_CollapsibleArea_Hr {
    color: #2a3444;
    border-bottom-color: #2a3444;
}

/* ===== Code snippets - older branding ===== */

[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTab,
[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabLeft,
[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabRight,
[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabFirst {
    background-color: #1a2332;
}

[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabDisabled,
[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabLeftDisabled,
[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabRightDisabled,
[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabDisabledNotFirst {
    background-color: #141b27;
}

[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabActive,
[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabLeftActive,
[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabRightActive,
[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabActiveNotFirst,
[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabSolo,
[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabActive a,
[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabActiveNotFirst a {
    background-color: #1e2a3a;
    color: #e2e8f0;
}

[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTab,
[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabFirst,
[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabActive,
[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabActiveNotFirst,
[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabDisabled,
[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabDisabledNotFirst,
[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabSolo,
[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabLeft,
[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerTabRight {
    border-color: #2a3444;
}

[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetContainerCodeCollection {
    border-color: #2a3444;
    background-color: #141b27;
}

[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetToolBar {
    border-top-color: #2a3444;
}

[data-theme="dark"] .tw-sandcastle .OH_CodeSnippetToolBarText {
    background-color: transparent;
}

/* ===== Code snippets - newer branding ===== */

[data-theme="dark"] .tw-sandcastle .codeSnippetContainerTab {
    color: #cbd5e1;
}

[data-theme="dark"] .tw-sandcastle .codeSnippetContainerTabActive,
[data-theme="dark"] .tw-sandcastle .codeSnippetContainerTabPhantom,
[data-theme="dark"] .tw-sandcastle .codeSnippetContainerTabSingle {
    background: #1e2a3a;
    color: #e2e8f0;
    border-top-color: #3d4f63;
    border-right-color: #3d4f63;
    border-left-color: #3d4f63;
}

[data-theme="dark"] .tw-sandcastle .codeSnippetContainerTab a,
[data-theme="dark"] .tw-sandcastle .codeSnippetContainerTabActive a,
[data-theme="dark"] .tw-sandcastle .codeSnippetContainerTabSingle a {
    color: #e2e8f0;
}

[data-theme="dark"] .tw-sandcastle .codeSnippetContainerCodeContainer,
[data-theme="dark"] .tw-sandcastle .codeSnippetContainerCode {
    background-color: #141b27;
    border-color: #2a3444;
}

[data-theme="dark"] .tw-sandcastle .codeSnippetToolBarText a,
[data-theme="dark"] .tw-sandcastle .codeSnippetToolBarText a:link {
    color: #60a5fa;
    background-color: transparent;
}

/* ===== Syntax colouring ===== */

[data-theme="dark"] .tw-sandcastle span.code,
[data-theme="dark"] .tw-sandcastle span.command {
    color: #93c5fd;
    background-color: #1a2332;
}

[data-theme="dark"] .tw-sandcastle span.keyword,
[data-theme="dark"] .tw-sandcastle .codeSnippetContainerCode .keyword {
    color: #7dd3fc;
}

[data-theme="dark"] .tw-sandcastle span.literal,
[data-theme="dark"] .tw-sandcastle span.literalValue {
    color: #fca5a5;
}

[data-theme="dark"] .tw-sandcastle span.comment {
    color: #86efac;
}

[data-theme="dark"] .tw-sandcastle span.introStyle {
    color: #94a3b8;
}

[data-theme="dark"] .tw-sandcastle .missing {
    color: #fca5a5;
}

[data-theme="dark"] .tw-sandcastle div.clsTooltip {
    background-color: #1e2a3a;
    border-color: #3d4f63;
    color: #e2e8f0;
}

/* ===== Lightweight website TOC (newer branding) ===== */

[data-theme="dark"] .tw-sandcastle div#leftNav {
    border-right-color: #2a3444;
}

[data-theme="dark"] .tw-sandcastle div#tocNav > div.current > a,
[data-theme="dark"] .tw-sandcastle div#tocNav > div.current > a:link,
[data-theme="dark"] .tw-sandcastle div#tocNav > div.current > a:visited {
    color: #e2e8f0;
}

[data-theme="dark"] .tw-sandcastle form#SearchForm,
[data-theme="dark"] .tw-sandcastle form#SearchForm input {
    background-color: #1e2a3a;
    color: #cbd5e1;
}

/* The magnifier is a dark glyph - invert it over a transparent background so
   only the glyph flips, not the button surface. */
[data-theme="dark"] .tw-sandcastle form#SearchForm button {
    background-color: transparent;
    filter: invert(1) brightness(1.4);
}

/* ===== TOC frame (TOC.css, older website output) ===== */

[data-theme="dark"] .tw-sandcastle .Tree {
    background-color: #0f1219;
    color: #e2e8f0;
}

[data-theme="dark"] .tw-sandcastle a.SelectedNode,
[data-theme="dark"] .tw-sandcastle a.UnselectedNode {
    color: #cbd5e1;
}

[data-theme="dark"] .tw-sandcastle a.SelectedNode {
    background-color: #253548;
    border-color: #3d4f63;
}

[data-theme="dark"] .tw-sandcastle a.UnselectedNode:hover,
[data-theme="dark"] .tw-sandcastle a.SelectedNode:hover {
    background-color: #253548;
    border-color: #3d4f63;
    color: #ffffff;
}

[data-theme="dark"] .tw-sandcastle .TOCSizer {
    background-color: #1a2332;
}

[data-theme="dark"] .tw-sandcastle .SearchOpts,
[data-theme="dark"] .tw-sandcastle .NavOpts,
[data-theme="dark"] .tw-sandcastle .IndexOpts {
    background-color: #1a2332;
    color: #e2e8f0;
}

[data-theme="dark"] .tw-sandcastle .SearchOpts input[type="text"],
[data-theme="dark"] .tw-sandcastle .SearchOpts input[type="button"] {
    background-color: #1e2a3a;
    border: 1px solid #3d4f63;
    color: #cbd5e1;
}

/* Tree expander and toolbar icons are dark-on-transparent GIFs - lift them so
   they stay visible on the dark tree background. */
[data-theme="dark"] .tw-sandcastle img.TreeNodeImg,
[data-theme="dark"] .tw-sandcastle img.TOCLink,
[data-theme="dark"] .tw-sandcastle .Tree img {
    filter: invert(1) brightness(1.2);
}
