/* Shared by the homepage, login screens and Quarto courses. */
:root {
  color-scheme: light;
  --theme-bg: #f4f7fb;
  --theme-surface: #fff;
  --theme-raised: #edf4fa;
  --theme-text: #172b3e;
  --theme-muted: #56677d;
  --theme-border: #c8dbe6;
  --theme-accent: #086a80;
  --theme-selected: #dceff4;
}

.topbar { align-items: center; flex-wrap: wrap; gap: 12px; }
.site-theme-control {
  display: inline-flex;
  flex: 0 0 auto;
  align-self: center;
  align-items: center;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--theme-border);
  border-radius: 999px;
  background: var(--theme-surface);
  color: var(--theme-text);
}
.site-theme-control button,
.ugp-card .site-theme-control button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  min-height: 34px;
  margin: 0;
  padding: 7px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--theme-muted);
  cursor: pointer;
  box-shadow: none;
  transform: none;
  filter: none;
}
.site-theme-control button:hover,
.ugp-card .site-theme-control button:hover {
  background: var(--theme-raised);
  color: var(--theme-text);
  box-shadow: none;
  transform: none;
}
.site-theme-control button[aria-pressed="true"],
.ugp-card .site-theme-control button[aria-pressed="true"] {
  background: var(--theme-selected);
  color: var(--theme-accent);
}
.site-theme-control button:focus-visible { outline: 3px solid #e8a73b; outline-offset: 2px; }
.site-theme-control svg { display: block; flex-shrink: 0; }
.site-theme-toolbar { display: flex; justify-content: flex-end; margin: 0 0 0.8rem; }
#quarto-sidebar .site-theme-toolbar { justify-content: center; }
#quarto-header .site-theme-control { margin: 0.2rem 0.4rem; }
#quarto-header .site-theme-control button { width: 30px; min-height: 30px; padding: 6px; }
.site-theme-fallback { padding: 1rem 1.25rem 0; }

@media (max-width: 991.98px) {
  .quarto-secondary-nav .container-fluid { align-items: center; gap: 0.25rem; }
  .quarto-secondary-nav .quarto-page-breadcrumbs { flex: 1 1 auto; min-width: 0; }
  .quarto-secondary-nav .breadcrumb { flex-wrap: nowrap; overflow: hidden; margin: 0; }
  .quarto-secondary-nav .breadcrumb-item { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .quarto-secondary-nav .container-fluid > a.flex-grow-1 { display: none; }
  #quarto-header :is(.quarto-btn-toggle, .quarto-search-button) { flex: 0 0 auto; width: 34px; padding: 6px; margin: 0; }
  #quarto-header .site-theme-control { height: 40px; }
  #quarto-header .site-theme-control button { height: 30px; }
}

/* Dark colours apply to screens; printed course materials retain the light palette. */
@media screen {
  html[data-site-theme="dark"] {
    color-scheme: dark;
    --theme-bg: #0d1723;
    --theme-surface: #162332;
    --theme-raised: #203246;
    --theme-text: #e3edf7;
    --theme-muted: #aabed0;
    --theme-border: #365065;
    --theme-accent: #72d8e2;
    --theme-selected: #264758;
    --bg: var(--theme-bg);
    --text: var(--theme-text);
    --muted: var(--theme-muted);
    --card: var(--theme-surface);
    --line: var(--theme-border);
    --blue: #9cc3ff;
    --blue-dark: #c3dcff;
    --blue-soft: #223a58;
    --shadow: 0 12px 32px rgba(0, 0, 0, .22);
    --tile-shadow: 0 14px 36px rgba(0, 0, 0, .22);
    --tile-shadow-hover: 0 22px 48px rgba(0, 0, 0, .32);
    --ugp-navy: var(--theme-text);
    --ugp-navy-soft: #c6dcec;
    --ugp-teal: var(--theme-accent);
    --ugp-orange: #ffbd8b;
    --ugp-page-bg: var(--theme-bg);
    --ugp-surface: var(--theme-surface);
    --ugp-soft-border: var(--theme-border);
    --ugp-sidebar-bg: #122030;
    --ugp-muted: var(--theme-muted);
    --ugp-border: var(--theme-border);
    --ugp-active-bg: var(--theme-selected);
    --labr-graphite: var(--theme-text);
    --labr-graphite-soft: #c6dcec;
    --labr-teal: var(--theme-accent);
    --labr-page-bg: var(--theme-bg);
    --labr-surface: var(--theme-surface);
    --labr-soft-border: var(--theme-border);
    --labr-sidebar-bg: #122030;
    --labr-muted: var(--theme-muted);
    --labr-active-bg: var(--theme-selected);
    --bs-body-bg: var(--theme-surface);
    --bs-body-color: var(--theme-text);
    --bs-body-color-rgb: 227, 237, 247;
    --bs-secondary-color: var(--theme-muted);
    --bs-secondary-bg: var(--theme-raised);
    --bs-tertiary-bg: var(--theme-raised);
    --bs-emphasis-color: var(--theme-text);
    --bs-border-color: var(--theme-border);
    --bs-link-color: var(--theme-accent);
    --bs-link-hover-color: #b1f2f6;
  }

  html[data-site-theme="dark"] body {
    color: var(--theme-text);
    background: radial-gradient(circle at 92% 4%, rgba(35, 117, 146, .17), transparent 32rem), var(--theme-bg);
  }
  html[data-site-theme="dark"] a { color: var(--theme-accent); text-decoration-color: currentColor; }
  html[data-site-theme="dark"] a:hover { color: #b1f2f6; }

  /* Homepage tiles and small panels. Logos keep a light canvas for legibility. */
  html[data-site-theme="dark"] :is(.card, .highlight, .program-card, .header, .gallery figure) {
    background: linear-gradient(145deg, var(--theme-surface), #192b3f);
    border-color: var(--theme-border);
  }
  html[data-site-theme="dark"] :is(.card, .highlight, .program-card, .header, .gallery figure):hover { border-color: #6284a4; }
  html[data-site-theme="dark"] :is(.lead, .intro, .gallery figcaption, .program-card .muted) { color: var(--theme-muted); }
  html[data-site-theme="dark"] :is(.card h3, .program-card h3, .gallery figcaption strong, .program-card .muted strong, .about-roles strong) { color: var(--theme-text); }
  html[data-site-theme="dark"] :is(.language-switch, .about-roles li, .about-topics span, .about-links a, .gallery figcaption) {
    background: var(--theme-raised);
    color: var(--theme-text);
    border-color: var(--theme-border);
  }
  html[data-site-theme="dark"] :is(.program-card .muted, .about-links) { border-color: var(--theme-border); }
  html[data-site-theme="dark"] .language-switch button { color: #9cc3ff; }
  html[data-site-theme="dark"] .language-switch button:is(:hover, .active) { color: #fff; background: #285caa; }
  html[data-site-theme="dark"] .btn { color: #fff; background: #285caa; }
  html[data-site-theme="dark"] .btn:hover { color: #fff; background: #356cbd; }
  html[data-site-theme="dark"] .btn.secondary { color: #9cc3ff; background: var(--theme-raised); border-color: var(--theme-border); }
  html[data-site-theme="dark"] .btn.planned { color: var(--theme-muted); background: var(--theme-raised); border-color: var(--theme-border); }
  html[data-site-theme="dark"] .about-links a:hover { background: #2b415b; }
  html[data-site-theme="dark"] :is(.genai-logo, .genai-logo-float, .postgraduate-logos) { background: #fff; border-radius: 12px; padding: 10px; }
  html[data-site-theme="dark"] .program-card img.logo { background: #f4f7fb; }
  html[data-site-theme="dark"] .controls button { color: #9cc3ff; background: var(--theme-raised); border-color: var(--theme-border); }
  html[data-site-theme="dark"] .controls button[aria-pressed="true"] { color: #fff; background: #285caa; }

  /* Course content, menus, tables and callouts. */
  html[data-site-theme="dark"] #quarto-document-content {
    background: var(--theme-surface);
    border-color: var(--theme-border);
    box-shadow: 0 18px 55px rgba(0, 0, 0, .24);
  }
  html[data-site-theme="dark"] #quarto-sidebar,
  html[data-site-theme="dark"] .quarto-secondary-nav {
    color: var(--theme-text);
    background: #122030 !important;
    border-color: var(--theme-border) !important;
  }
  html[data-site-theme="dark"] :is(#quarto-sidebar .sidebar-link, .active-page-sections a, .active-page-sections .toc-level-2 a, .breadcrumb-item, .nav-page) { color: var(--theme-muted); }
  html[data-site-theme="dark"] :is(#quarto-sidebar .sidebar-link:hover, #quarto-sidebar .sidebar-link.active, .active-page-sections a:hover, .active-page-sections a.is-active) { color: var(--theme-accent); background: var(--theme-selected); }
  html[data-site-theme="dark"] :is(#quarto-document-content h1, #quarto-document-content h4, #quarto-document-content h5, #quarto-document-content h6) { color: var(--theme-text); }
  html[data-site-theme="dark"] #quarto-document-content :is(h2, h3) { color: var(--theme-accent); }
  html[data-site-theme="dark"] #quarto-document-content :is(th, td) { border-color: var(--theme-border); color: var(--theme-text); }
  html[data-site-theme="dark"] #quarto-document-content table { --bs-table-color: var(--theme-text); --bs-table-bg: transparent; --bs-table-border-color: var(--theme-border); }
  html[data-site-theme="dark"] #quarto-document-content thead { color: var(--theme-text); background: var(--theme-raised); }
  html[data-site-theme="dark"] #quarto-document-content tbody tr:nth-child(even) { background: #1b2c3e; }
  html[data-site-theme="dark"] #quarto-document-content :is(blockquote, .callout, .callout.callout-note) { color: var(--theme-text); background: #1b303f; border-color: var(--theme-border); }
  html[data-site-theme="dark"] #quarto-document-content .callout.callout-note { border-left-color: var(--theme-accent); }
  html[data-site-theme="dark"] #quarto-document-content .callout .callout-header { color: var(--theme-text); background: var(--theme-raised); border-bottom-color: var(--theme-border); }
  html[data-site-theme="dark"] #quarto-document-content .quarto-figure { background: var(--theme-raised); border-color: var(--theme-border); }
  html[data-site-theme="dark"] #quarto-document-content .quarto-figure img { background: #fff; }
  html[data-site-theme="dark"] #quarto-document-content :is(figcaption, .quarto-title-meta-heading, .quarto-title-meta-contents, .header-section-number) { color: var(--theme-muted); }
  html[data-site-theme="dark"] :is(.labr-page-banner, .ugp-page-banner, .labr-sidebar-banner, .ugp-sidebar-banner) { background: #122030; }
  html[data-site-theme="dark"] #quarto-sidebar :is(.labr-sidebar-banner, .ugp-sidebar-banner) { background: #122030; }

  /* Syntax colours stay distinct without inverting images or mathematical figures. */
  html[data-site-theme="dark"] :is(pre, pre.sourceCode, div.sourceCode, div.sourceCode pre, div.cell-output, div.cell-output-stdout) { color: var(--theme-text); background: #101d2b; border-color: var(--theme-border); }
  html[data-site-theme="dark"] code { color: #b1dcec; background: #203246; }
  html[data-site-theme="dark"] pre code { color: var(--theme-text); background: transparent; }
  html[data-site-theme="dark"] code span { color: var(--theme-text); }
  html[data-site-theme="dark"] code :is(span.kw, span.cf, span.im, span.bu) { color: #9dbfff; }
  html[data-site-theme="dark"] code :is(span.st, span.ss, span.ch, span.vs) { color: #9de1b0; }
  html[data-site-theme="dark"] code :is(span.dv, span.bn, span.fl, span.cn) { color: #ffc58b; }
  html[data-site-theme="dark"] code :is(span.co, span.do, span.cv, span.an) { color: #a2b5c8; }
  html[data-site-theme="dark"] code :is(span.fu, span.va, span.at) { color: #83e0e7; }
  html[data-site-theme="dark"] code span.er { color: #ffb5b5; }
  html[data-site-theme="dark"] :is(.code-copy-button, .code-fold-btn, .quarto-btn-toggle, .quarto-search-button) { color: var(--theme-muted); }
  html[data-site-theme="dark"] #quarto-header :is(.quarto-btn-toggle, .quarto-search-button) { color: var(--theme-accent); background: transparent; box-shadow: none; }
  html[data-site-theme="dark"] #quarto-header :is(.breadcrumb-item, .breadcrumb-item a) { color: var(--theme-muted); }

  /* Login and session controls. */
  html[data-site-theme="dark"] :is(.ugp-card, .ugp-session) { color: var(--theme-text); background: var(--theme-surface); border-color: var(--theme-border); }
  html[data-site-theme="dark"] .ugp-card input { color: var(--theme-text); background: #101d2b; border-color: var(--theme-border); }
  html[data-site-theme="dark"] .ugp-card input::placeholder { color: var(--theme-muted); }
  html[data-site-theme="dark"] .ugp-card form button { color: #fff; background: linear-gradient(100deg, #174058, #087f8c); }
  html[data-site-theme="dark"] :is(.ugp-card .ugp-secondary, .ugp-session button) { color: var(--theme-accent); background: var(--theme-selected); }
  html[data-site-theme="dark"] .ugp-message { color: var(--theme-text); background: #1b303f; border-color: var(--theme-border); }

  /* Quarto search, tabs, tooltips and back-to-top control. */
  html[data-site-theme="dark"] :is(.aa-DetachedOverlay, .aa-DetachedContainer, .aa-DetachedFormContainer, .aa-Panel, .aa-Form, .aa-Input, .search-result-container, .search-result-text, .search-result-title, .search-result-section, .quarto-search-results, .nav-tabs .nav-link.active, .tab-content, .tippy-box, #quarto-back-to-top) { color: var(--theme-text); background: var(--theme-surface); border-color: var(--theme-border); }
  html[data-site-theme="dark"] :is(.aa-InputWrapperPrefix, .aa-InputWrapperSuffix, .aa-DetachedCancelButton, .aa-SubmitButton, .aa-ClearButton, .aa-DetachedSearchButton, .aa-DetachedSearchButtonPlaceholder, .search-result-doc) { color: var(--theme-muted); }
  html[data-site-theme="dark"] :is(.aa-SubmitButton, .aa-ClearButton, .aa-DetachedSearchButton) svg { color: var(--theme-muted); fill: currentColor; }
  html[data-site-theme="dark"] .aa-Item[aria-selected="true"] { background: var(--theme-selected); }
  html[data-site-theme="dark"] .search-result-container mark { color: #fff; background: #315568; }
  html[data-site-theme="dark"] :is(#quarto-search-results, .aa-DetachedOverlay) :is(.aa-Panel, .aa-PanelLayout, .aa-Item) { color: var(--theme-text); background: var(--theme-surface); border-color: var(--theme-border); }
  html[data-site-theme="dark"] :is(#quarto-search-results, .aa-DetachedOverlay) .aa-Item[aria-selected] .search-item,
  html[data-site-theme="dark"] :is(#quarto-search-results, .aa-DetachedOverlay) .aa-Item[aria-selected] .search-item :is(.search-result-title-container, .search-result-text-container, .search-result-section, .search-result-text, .search-result-title, .search-result-crumbs) { color: var(--theme-text); background: var(--theme-surface); border-color: var(--theme-border); }
  html[data-site-theme="dark"] :is(#quarto-search-results, .aa-DetachedOverlay) .aa-Item[aria-selected="true"] .search-item,
  html[data-site-theme="dark"] :is(#quarto-search-results, .aa-DetachedOverlay) .aa-Item[aria-selected="true"] .search-item :is(.search-result-title-container, .search-result-text-container, .search-result-section, .search-result-text, .search-result-title) { background: var(--theme-selected); }
  html[data-site-theme="dark"] :is(#quarto-search-results, .aa-DetachedOverlay) .aa-SourceHeader .search-result-header { color: var(--theme-muted); background: var(--theme-raised); }
  html[data-site-theme="dark"] :is(#quarto-search-results, .aa-DetachedOverlay) .aa-Item[aria-selected] .search-item :is(mark.search-match, .search-match.mark) { color: #fff; background: #315568; }
  html[data-site-theme="dark"] #quarto-search .aa-SubmitButton svg { fill: var(--theme-muted); }
}

@media print {
  .site-theme-control, .site-theme-toolbar { display: none !important; }
}
