/*
 * Dark theme for the Antora UI.
 * Active when <html data-theme="dark">, set by the inline script in partials/head-styles.hbs
 * (stored choice from the header toggle, otherwise the OS preference).
 * site.css stays untouched; every rule here is prefixed with html[data-theme=dark] so it also
 * beats the later-loaded search.css of the Lunr extension.
 */

html[data-theme=dark] {
  color-scheme: dark;
  --bg: #15181e;
  --bg-raised: #1b1f27;
  --bg-sunken: #11141a;
  --bg-muted: #222733;
  --bg-navbar: #0d0f13;
  --border: #2b313c;
  --border-strong: #3a4250;
  --text: #cdd3dc;
  --text-strong: #eef1f6;
  --text-muted: #949eac;
  --text-faint: #6c7686;
  --link: #79b8ff;
  --link-hover: #a8d1ff;
  --brand: #b968bb; /* favicon purple #8b358d, lifted for dark backgrounds */
  --code-bg: #1d222b;
  --code-text: #d7dde6;
}

/* ---- base ---- */
html[data-theme=dark] body { background: var(--bg); color: var(--text); }
html[data-theme=dark] { scrollbar-color: var(--border-strong) var(--bg-sunken); }
html[data-theme=dark] body * { scrollbar-color: var(--border-strong) transparent; }
html[data-theme=dark]::-webkit-scrollbar { background-color: var(--bg-sunken); }
html[data-theme=dark] ::-webkit-scrollbar-thumb { background-color: var(--border-strong); }
html[data-theme=dark] ::-webkit-scrollbar-thumb:hover { background-color: var(--text-faint); }
html[data-theme=dark] ::selection { background: rgba(185, 104, 187, .35); }

/* ---- navbar ---- */
html[data-theme=dark] .navbar { background: var(--bg-navbar); box-shadow: 0 1px 0 var(--border); }
html[data-theme=dark] .navbar-item,
html[data-theme=dark] .navbar-link { color: var(--text); }
html[data-theme=dark] .navbar-brand .navbar-item,
html[data-theme=dark] .navbar-end .navbar-link,
html[data-theme=dark] .navbar-end > .navbar-item { color: var(--text-strong); }
html[data-theme=dark] .navbar-menu,
html[data-theme=dark] .navbar-dropdown { background: var(--bg-raised); border-color: var(--border); }
html[data-theme=dark] .navbar-menu .navbar-link:hover,
html[data-theme=dark] .navbar-menu a.navbar-item:hover,
html[data-theme=dark] .navbar-dropdown a.navbar-item:hover { background: var(--bg-muted); }
html[data-theme=dark] .navbar-divider { background-color: var(--border); }
html[data-theme=dark] .navbar .button { background: var(--bg-raised); border-color: var(--border); color: var(--text); }
html[data-theme=dark] #search-input { background: var(--bg-raised); color: var(--text-strong); border-color: var(--border-strong); }
html[data-theme=dark] #search-input::placeholder { color: var(--text-faint); }
html[data-theme=dark] #search-input:disabled { background-color: var(--bg-muted); }
html[data-theme=dark] #search-field .filter {
  background: var(--bg-raised) linear-gradient(180deg, var(--border-strong) 0, var(--border-strong)) no-repeat 0 / 1px 50%;
  border-color: var(--border-strong);
  color: var(--text-muted);
}

/* ---- theme toggle (also styled for light mode) ---- */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  width: 2rem;
  height: 2rem;
  margin: 0 .25rem;
  padding: 0;
  background: none;
  border: 1px solid transparent;
  border-radius: 50%;
  color: #e1e1e1;
  transition: color .2s, border-color .2s, background-color .2s;
}
.theme-toggle:hover { color: #fff; border-color: rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .06); }
.theme-toggle:focus-visible { outline: 2px solid var(--brand, #b968bb); outline-offset: 2px; }
.theme-toggle svg { width: 1.1rem; height: 1.1rem; }
.theme-toggle .icon-sun { display: none; }
html[data-theme=dark] .theme-toggle .icon-sun { display: block; }
html[data-theme=dark] .theme-toggle .icon-moon { display: none; }
html[data-theme=dark] .theme-toggle { color: #f2c46d; }
html[data-theme=dark] .theme-toggle:hover { color: #ffd98a; }
@media print { .theme-toggle { display: none; } }

/* ---- side nav ---- */
html[data-theme=dark] .nav { background: var(--bg-raised); box-shadow: .5px 0 0 var(--border); }
html[data-theme=dark] .nav-menu { background: linear-gradient(185deg, var(--bg-raised), var(--bg-raised) 71%, #10331b); }
html[data-theme=dark] .nav-menu h3.title { color: var(--text-strong); }
html[data-theme=dark] .nav-menu a.nav-link { color: var(--text); }
html[data-theme=dark] .nav-menu .is-current-page > .nav-link,
html[data-theme=dark] .nav-menu .is-current-page > .nav-text { color: var(--text-strong); font-weight: 500; }
html[data-theme=dark] .nav-panel-menu:not(.is-active)::after { background: rgba(0, 0, 0, .6); }
html[data-theme=dark] .nav-panel-explore { background: var(--bg-raised); }
html[data-theme=dark] .nav-panel-explore .context { color: var(--text-muted); box-shadow: 0 -1px 0 var(--border); }
html[data-theme=dark] .nav-panel-explore .components { background: var(--bg-sunken); box-shadow: inset 0 1px 5px rgba(0, 0, 0, .4); }
html[data-theme=dark] .nav-panel-explore .component .version a { border-color: var(--border-strong); }

/* line icons are dark-on-transparent SVG backgrounds; invert them */
html[data-theme=dark] .nav-toggle,
html[data-theme=dark] .home-link { filter: invert(.85); }
html[data-theme=dark] .nav-item-toggle { filter: brightness(.7); }
html[data-theme=dark] .nav-panel-explore .context .version::after,
html[data-theme=dark] .page-versions .version-menu-toggle { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3E%3Cpath d='M3.67 6.59L1.455 8.615 15 23.375l13.545-14.76L26.33 6.59 15 18.76z' fill='%23949eac'/%3E%3C/svg%3E"); }

/* ---- toolbar, versions, toc ---- */
html[data-theme=dark] .toolbar { background-color: var(--bg-raised); color: var(--text-muted); box-shadow: 0 1px 0 var(--border); }
html[data-theme=dark] .toolbar .edit-this-page a { color: var(--text-faint); }
html[data-theme=dark] .breadcrumbs a { color: var(--text-muted); }
html[data-theme=dark] .page-versions .version-menu { background: var(--bg-muted); }
html[data-theme=dark] .page-versions .version { color: var(--text); }
html[data-theme=dark] .page-versions .version.is-missing { color: var(--text-faint); }
html[data-theme=dark] .toc-menu { color: var(--text-muted); }
html[data-theme=dark] .toc .toc-menu h3 { color: var(--text-strong); }
html[data-theme=dark] .toc .toc-menu a { border-left-color: var(--border); }
html[data-theme=dark] .toc .toc-menu a:hover { color: var(--link); }
html[data-theme=dark] .toc .toc-menu a.is-active { border-left-color: var(--brand); color: var(--text-strong); }
html[data-theme=dark] .sidebar.toc .toc-menu a:focus { background: var(--bg-raised); }

/* ---- article ---- */
html[data-theme=dark] .doc { color: var(--text); }
html[data-theme=dark] .doc h1,
html[data-theme=dark] .doc h2,
html[data-theme=dark] .doc h3,
html[data-theme=dark] .doc h4,
html[data-theme=dark] .doc h5,
html[data-theme=dark] .doc h6 { color: var(--text-strong); }
html[data-theme=dark] .doc h1.sect0 { background: var(--bg-muted); }
html[data-theme=dark] .doc h2:not(.discrete) { border-bottom-color: var(--border); }
html[data-theme=dark] .doc a { color: var(--link); }
html[data-theme=dark] .doc a:hover { color: var(--link-hover); }
html[data-theme=dark] .doc a.unresolved { color: #ff7b72; }
html[data-theme=dark] .doc .colist > table code,
html[data-theme=dark] .doc p code,
html[data-theme=dark] .doc thead code,
html[data-theme=dark] .doc td code,
html[data-theme=dark] .doc li code { color: var(--code-text); background: var(--code-bg); }
html[data-theme=dark] .doc hr { border-color: var(--border); }
html[data-theme=dark] .doc kbd { background: var(--bg-muted); border-color: var(--border-strong); box-shadow: 0 1px 0 var(--border-strong), inset 0 0 0 .1em var(--bg-raised); color: var(--text-strong); }

/* tables */
html[data-theme=dark] .doc table.tableblock,
html[data-theme=dark] .doc table.tableblock > * > tr > * { border-color: var(--border); }
html[data-theme=dark] .doc table.stripes-all > tbody > tr,
html[data-theme=dark] .doc table.stripes-even > tbody > tr:nth-of-type(2n),
html[data-theme=dark] .doc table.stripes-hover > tbody > tr:hover,
html[data-theme=dark] .doc table.stripes-odd > tbody > tr:nth-of-type(odd) { background: var(--bg-raised); }
html[data-theme=dark] .doc table.tableblock > tfoot { background: linear-gradient(180deg, var(--bg-muted) 0, var(--bg)); }

/* blocks */
html[data-theme=dark] .doc .admonitionblock td.content { background: var(--bg-raised); }
html[data-theme=dark] .doc .admonitionblock.note td.content { box-shadow: inset 3px 0 0 #217ee7; }
html[data-theme=dark] .doc .admonitionblock.tip td.content { box-shadow: inset 3px 0 0 #41af46; }
html[data-theme=dark] .doc .admonitionblock.warning td.content { box-shadow: inset 3px 0 0 #e18114; }
html[data-theme=dark] .doc .admonitionblock.caution td.content { box-shadow: inset 3px 0 0 #a0439c; }
html[data-theme=dark] .doc .admonitionblock.important td.content { box-shadow: inset 3px 0 0 #d32f2f; }
html[data-theme=dark] #preamble .abstract blockquote { background: var(--bg-muted); border-left-color: var(--border-strong); color: var(--text); }
html[data-theme=dark] .doc .quoteblock,
html[data-theme=dark] .doc .verseblock { background: var(--bg-raised); border-left-color: var(--brand); color: var(--text); }
html[data-theme=dark] .doc .quoteblock .attribution { color: var(--text-faint); }
html[data-theme=dark] .doc .admonitionblock .title,
html[data-theme=dark] .doc .exampleblock .title,
html[data-theme=dark] .doc .imageblock .title,
html[data-theme=dark] .doc .listingblock .title,
html[data-theme=dark] .doc .literalblock .title,
html[data-theme=dark] .doc .openblock .title,
html[data-theme=dark] .doc .tableblock caption,
html[data-theme=dark] .doc .videoblock .title,
html[data-theme=dark] .doc details.result > summary { color: var(--text-muted); }
html[data-theme=dark] .doc .exampleblock > .content,
html[data-theme=dark] .doc details.result > .content { background: var(--bg); border-color: var(--border-strong); }
html[data-theme=dark] .doc .sidebarblock { background: var(--bg-muted); }

/* source code */
html[data-theme=dark] .doc .listingblock pre:not(.highlight),
html[data-theme=dark] .doc .literalblock pre,
html[data-theme=dark] .doc pre.highlight code { background: var(--code-bg); color: var(--code-text); box-shadow: inset 0 0 0 1px var(--border); border-radius: .25rem; }
html[data-theme=dark] .doc .source-toolbox { color: var(--text-faint); }
html[data-theme=dark] .doc .source-toolbox img.copy-icon { filter: invert(65%); }
html[data-theme=dark] .doc .source-toolbox .copy-toast { background-color: var(--bg-muted); color: var(--text-strong); }
html[data-theme=dark] .doc .source-toolbox .copy-toast::after { border-left-color: var(--bg-muted); }

/* highlight.js, GitHub-dark flavoured */
html[data-theme=dark] .hljs-comment,
html[data-theme=dark] .hljs-quote { color: #8b949e; }
html[data-theme=dark] .hljs-keyword,
html[data-theme=dark] .hljs-selector-tag,
html[data-theme=dark] .hljs-subst { color: #ff7b72; }
html[data-theme=dark] .hljs-doctag,
html[data-theme=dark] .hljs-string { color: #e8b27d; }
html[data-theme=dark] .hljs-section,
html[data-theme=dark] .hljs-selector-id,
html[data-theme=dark] .hljs-title { color: #d2a8ff; }
html[data-theme=dark] .hljs-class .hljs-title,
html[data-theme=dark] .hljs-type { color: #ffa657; }
html[data-theme=dark] .hljs-attr,
html[data-theme=dark] .hljs-attribute,
html[data-theme=dark] .hljs-number,
html[data-theme=dark] .hljs-literal,
html[data-theme=dark] .hljs-variable,
html[data-theme=dark] .hljs-template-variable { color: #79c0ff; }
html[data-theme=dark] .hljs-link,
html[data-theme=dark] .hljs-regexp { color: #7ee787; }
html[data-theme=dark] .hljs-bullet,
html[data-theme=dark] .hljs-symbol { color: #f2cc60; }
html[data-theme=dark] .hljs-built_in,
html[data-theme=dark] .hljs-builtin-name { color: #79c0ff; }
html[data-theme=dark] .hljs-meta { color: #8b949e; }
/* XML/HTML: site.css uses named colors (navy, teal) that vanish on dark */
html[data-theme=dark] .hljs-tag { color: #8b949e; }
html[data-theme=dark] .hljs-name { color: #7ee787; }
html[data-theme=dark] .hljs-tag .hljs-attr { color: #79c0ff; }
html[data-theme=dark] .hljs-deletion { background: rgba(248, 81, 73, .2); color: #ffdcd7; }
html[data-theme=dark] .hljs-addition { background: rgba(46, 160, 67, .2); color: #aff5b4; }

/* diagrams (Kroki/PlantUML SVGs are drawn for white paper): show them on a soft light card */
html[data-theme=dark] .doc .imageblock img[src*="diag-"],
html[data-theme=dark] .doc .imageblock object[data*="diag-"],
html[data-theme=dark] .doc .imageblock img[src$=".svg"] {
  background: #e9ecf1;
  border-radius: .5rem;
  padding: .75rem;
  box-shadow: 0 0 0 1px var(--border);
  filter: brightness(.94);
}
/* raster images (e.g. the white-background logo): soften the edge instead of a hard white box */
html[data-theme=dark] .doc .imageblock img:not([src$=".svg"]),
html[data-theme=dark] .doc .image > img:not([src$=".svg"]) {
  border-radius: .375rem;
  filter: brightness(.92);
}

/* ---- pagination & footer ---- */
html[data-theme=dark] nav.pagination { border-top-color: var(--border); }
html[data-theme=dark] nav.pagination span::before,
html[data-theme=dark] nav.pagination a::after,
html[data-theme=dark] nav.pagination a::before { color: var(--text-faint); }
html[data-theme=dark] footer.footer { background-color: var(--bg-sunken); color: var(--text-muted); border-top: 1px solid var(--border); }
html[data-theme=dark] .footer a { color: var(--text-strong); }

/* ---- Lunr search results ---- */
html[data-theme=dark] .search-result-dropdown-menu { box-shadow: 0 8px 24px rgba(0, 0, 0, .5); }
html[data-theme=dark] .search-result-dataset { background: var(--bg-raised); border-color: var(--border-strong); }
html[data-theme=dark] .search-result-component-header { color: var(--text-strong); border-bottom-color: var(--border); }
html[data-theme=dark] .search-result-document-title { color: var(--text-strong); border-right-color: var(--border); }
html[data-theme=dark] .search-result-document-hit { color: var(--text-muted); }
html[data-theme=dark] .search-result-document-hit > a:hover { background-color: rgba(121, 184, 255, .08); }
html[data-theme=dark] .search-result-document-hit .search-result-highlight { color: var(--link-hover); background: rgba(121, 184, 255, .15); }
html[data-theme=dark] .search-result-document-hit .search-result-section-title { color: var(--text); }
