/* ===================================================================
   Dark-scheme overrides for the online book reader.

   The reader (pages/$library/readBookOnline2.vm) renders the chapter's
   body inside a normal Bulma page, then loads the book's OWN
   stylesheet -- readBookOnline2.java takes the FIRST <link
   rel=stylesheet> out of the chapter HTML, which is
   styles-generic-fd.css from
   web/WEB-INF/var/master/<BOOK>/book.online/OEBPS/. (The book also
   ships styles-online-fd.css and styles-book.css; the reader does not
   load those, so there is nothing here for them.)

   Those files are published output of the book toolchain and are
   replaced wholesale whenever a book is rebuilt, so editing them in
   place would quietly lose this work on the next publish. This file
   lives with the site and is linked immediately AFTER the book
   stylesheet, so it wins on source order without touching it.

   Every rule below is inside a dark-only selector: light rendering is
   untouched.

   What it fixes: styles-generic-fd.css draws its rules and its heading
   links in literal `black`, and gives table headers a #f0f0f0 fill.
   Against the dark page those go to roughly 1.2:1, and the table
   header keeps a near-white band with light text on it.
   =================================================================== */

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .sidebar,
    :root:not([data-theme="light"]) .mediaobject,
    :root:not([data-theme="light"]) table,
    :root:not([data-theme="light"]) th,
    :root:not([data-theme="light"]) #footnotes .footnote-line {
        border-color: var(--bulma-border);
    }

    :root:not([data-theme="light"]) th {
        background: var(--bulma-background);
    }

    :root:not([data-theme="light"]) .heading-link,
    :root:not([data-theme="light"]) .heading-link:link,
    :root:not([data-theme="light"]) .heading-link:visited {
        color: var(--bulma-text-strong);
    }
}

/* The same, for a reader who has explicitly chosen Dark. Kept as a
   separate block rather than merged into the selector lists above:
   these have to apply regardless of what the OS asks for. */
:root[data-theme="dark"] .sidebar,
:root[data-theme="dark"] .mediaobject,
:root[data-theme="dark"] table,
:root[data-theme="dark"] th,
:root[data-theme="dark"] #footnotes .footnote-line {
    border-color: var(--bulma-border);
}

:root[data-theme="dark"] th {
    background: var(--bulma-background);
}

:root[data-theme="dark"] .heading-link,
:root[data-theme="dark"] .heading-link:link,
:root[data-theme="dark"] .heading-link:visited {
    color: var(--bulma-text-strong);
}
