/* Shared dark theme (the site's dominant navy/cyan look).
   Opt in per page with {% block body_class %}site-dark{% endblock %}.
   Element rules use :where() so page stylesheets always win on specificity. */

:root {
  --sd-page: #0b0f19;
  --sd-panel: #101827;
  --sd-inset: #0b1526;
  --sd-border: rgba(0, 217, 255, 0.18);
  --sd-border-strong: rgba(0, 217, 255, 0.4);
  --sd-input-border: #294566;
  --sd-divider: rgba(148, 180, 210, 0.12);
  --sd-text: #e8eef2;
  --sd-heading: #f0f6ff;
  --sd-muted: #9cb7cc;
  --sd-dim: #7f9ab3;
  --sd-accent: #00d9ff;
  --sd-accent-hover: #00b5d4;
  --sd-accent-soft: #8ae8ff;
  --sd-on-accent: #031425;
  --sd-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

/* Sitewide defaults for text and links that a page doesn't colour itself.
   style.css still carries the old light theme's #656c6d text and #333 links, which are
   unreadable on the dark backgrounds every page now uses. Plain element selectors, loaded
   after style.css, so any page rule with a class still wins. */
body {
  color: var(--sd-muted);
}

a {
  color: var(--sd-accent-soft);
}

.site-dark {
  background: var(--sd-page);
  color: var(--sd-text);
  min-height: 100vh;
}

:where(.site-dark .site-main) h1,
:where(.site-dark .site-main) h2,
:where(.site-dark .site-main) h3,
:where(.site-dark .site-main) h4,
:where(.site-dark .site-main) h5,
:where(.site-dark .site-main) h6 {
  color: var(--sd-heading);
}

:where(.site-dark .site-main) a {
  color: var(--sd-accent-soft);
}

:where(.site-dark .site-main) a:hover,
:where(.site-dark .site-main) a:focus {
  color: #b7f3ff;
}

:where(.site-dark .site-main) input,
:where(.site-dark .site-main) select,
:where(.site-dark .site-main) textarea {
  color-scheme: dark;
  accent-color: var(--sd-accent);
}

:where(.site-dark .site-main) select option {
  background: var(--sd-inset);
  color: var(--sd-heading);
}

/* Flash messages (Bootstrap .alert markup) */
.site-dark .site-main .alert {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
}

.site-dark .site-main .alert-danger {
  background: rgba(220, 53, 69, 0.15);
  border: 1px solid rgba(220, 53, 69, 0.45);
  color: #ffc8ce;
}

.site-dark .site-main .alert-success {
  background: rgba(40, 167, 69, 0.15);
  border: 1px solid rgba(40, 167, 69, 0.45);
  color: #b9f8cb;
}

/* Chosen dropdowns */
.site-dark .site-main .chosen-container {
  width: 100% !important;
  font-size: 0.98rem;
}

.site-dark .site-main .chosen-container-single .chosen-single,
.site-dark .site-main .chosen-container-multi .chosen-choices {
  min-height: 46px;
  border-radius: 10px;
  border: 1px solid var(--sd-input-border);
  background: var(--sd-inset);
  box-shadow: none;
  color: var(--sd-heading);
}

.site-dark .site-main .chosen-container-single .chosen-single {
  display: flex;
  align-items: center;
  height: auto;
  padding: 0 0 0 12px;
  line-height: 1.4;
}

.site-dark .site-main .chosen-container-single .chosen-single span {
  flex: 1 1 auto;
  margin-right: 30px;
}

.site-dark .site-main .chosen-container-single .chosen-default {
  color: var(--sd-dim);
}

.site-dark .site-main .chosen-container-single .chosen-single div {
  width: 30px;
}

.site-dark .site-main .chosen-container-single .chosen-single div b {
  width: 18px;
  background-position: 0 13px;
  filter: invert(1) hue-rotate(180deg) brightness(1.4);
}

.site-dark .site-main .chosen-container-active .chosen-single,
.site-dark .site-main .chosen-container-active .chosen-choices,
.site-dark .site-main .chosen-container-active.chosen-with-drop .chosen-single {
  border-color: var(--sd-accent);
  background: var(--sd-inset);
  box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.18);
}

.site-dark .site-main .chosen-container-active.chosen-with-drop .chosen-single {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.site-dark .site-main .chosen-container-active.chosen-with-drop .chosen-single div b {
  background-position: -18px 13px;
}

.site-dark .site-main .chosen-container .chosen-drop {
  border: 1px solid var(--sd-accent);
  border-top: 0;
  border-radius: 0 0 10px 10px;
  background: #0d1a2d;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.45);
  z-index: 1010;
}

.site-dark .site-main .chosen-container-multi .chosen-drop {
  margin-top: 4px;
  border-top: 1px solid var(--sd-accent);
  border-radius: 10px;
}

.site-dark .site-main .chosen-container .chosen-search input[type="text"] {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--sd-input-border);
  background-color: var(--sd-inset);
  color: var(--sd-heading);
  filter: none;
}

.site-dark .site-main .chosen-container .chosen-results {
  color: #d7e4ef;
  max-height: 260px;
}

.site-dark .site-main .chosen-container .chosen-results li {
  padding: 8px 10px;
  border-radius: 6px;
  line-height: 1.3;
}

.site-dark .site-main .chosen-container .chosen-results li.highlighted {
  background: rgba(0, 217, 255, 0.2);
  background-image: none;
  color: var(--sd-heading);
}

.site-dark .site-main .chosen-container .chosen-results li.no-results {
  background: transparent;
  color: #8aa3b8;
}

.site-dark .site-main .chosen-container .chosen-results li.result-selected {
  color: var(--sd-dim);
}

.site-dark .site-main .chosen-container-multi .chosen-choices {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  height: auto;
  padding: 6px 8px;
  background-image: none;
  cursor: text;
}

.site-dark .site-main .chosen-container-multi .chosen-choices li.search-field input[type="text"] {
  height: 30px;
  margin: 0;
  padding: 0 4px;
  color: var(--sd-heading);
  font-family: inherit;
  font-size: 0.95rem;
}

.site-dark .site-main .chosen-container-multi .chosen-choices li.search-field input.default {
  color: var(--sd-dim);
}

.site-dark .site-main .chosen-container-multi .chosen-choices li.search-choice {
  margin: 0;
  padding: 5px 26px 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0, 217, 255, 0.35);
  background: rgba(0, 217, 255, 0.12);
  background-image: none;
  box-shadow: none;
  color: var(--sd-accent-soft);
  font-size: 0.82rem;
}
