/* =========================================================
   DARK THEME AUDIT v131 — 16 Aug 2026
   Scope: site-wide dark-mode consistency with particular
   attention to Research and Publications pages.
   Light mode is intentionally untouched.
   ========================================================= */

html[data-theme="dark"]{
  color-scheme:dark;
}

/* ---------- Global shell ---------- */
html[data-theme="dark"] body,
html[data-theme="dark"] main{
  background:var(--bg)!important;
  color:var(--text)!important;
}
html[data-theme="dark"] .site-header{
  background:color-mix(in srgb,var(--bg) 92%,transparent)!important;
  border-color:var(--line)!important;
}
html[data-theme="dark"] .site-header nav,
html[data-theme="dark"] .site-header nav.open{
  border-color:var(--line)!important;
}
@media(max-width:1050px){
  html[data-theme="dark"] .site-header nav,
  html[data-theme="dark"] .site-header nav.open{
    background:var(--surface)!important;
  }
}
html[data-theme="dark"] .site-footer{
  background:color-mix(in srgb,var(--surface) 78%,var(--bg))!important;
  color:var(--muted)!important;
  border-color:var(--line)!important;
}
html[data-theme="dark"] .theme,
html[data-theme="dark"] .menu,
html[data-theme="dark"] .back-to-top{
  background:var(--neutral-button,var(--surface))!important;
  border-color:var(--line)!important;
  color:var(--primary2)!important;
}

/* ---------- Common cards / detail surfaces ---------- */
html[data-theme="dark"] .blog-card,
html[data-theme="dark"] .card,
html[data-theme="dark"] .project-card,
html[data-theme="dark"] .detail-card,
html[data-theme="dark"] .detail-shell,
html[data-theme="dark"] .media-note,
html[data-theme="dark"] .contact-card,
html[data-theme="dark"] .profile-card,
html[data-theme="dark"] .credential-card,
html[data-theme="dark"] .credential-record,
html[data-theme="dark"] .education-degree-card,
html[data-theme="dark"] .tc-record,
html[data-theme="dark"] .tc-summary-card{
  background:var(--surface)!important;
  border-color:var(--line)!important;
  color:var(--text)!important;
}
html[data-theme="dark"] .blog-thumb,
html[data-theme="dark"] .project-image,
html[data-theme="dark"] .detail-media,
html[data-theme="dark"] .gallery-card img{
  background:var(--surface2)!important;
}

/* =========================================================
   RESEARCH + PUBLICATIONS STORY PAGES
   ========================================================= */
html[data-theme="dark"] body.story-page .spatial-story{
  background:var(--bg)!important;
}
html[data-theme="dark"] body.story-page .story-intro{
  border-color:var(--line)!important;
}
html[data-theme="dark"] body.story-page .story-intro h1,
html[data-theme="dark"] body.story-page .story-intro h2,
html[data-theme="dark"] body.story-page .story-chapter h3,
html[data-theme="dark"] body.story-page .story-map-title,
html[data-theme="dark"] body.story-page .story-map-head h2{
  color:var(--primary2)!important;
}
html[data-theme="dark"] body.story-page .story-intro p,
html[data-theme="dark"] body.story-page .story-chapter-body>p,
html[data-theme="dark"] body.story-page .story-summary,
html[data-theme="dark"] body.story-page .story-publication-authors,
html[data-theme="dark"] body.story-page .story-location,
html[data-theme="dark"] body.story-page .story-map-head p,
html[data-theme="dark"] body.story-page .story-map-caption p{
  color:var(--muted)!important;
}
html[data-theme="dark"] body.story-page .story-map-shell,
html[data-theme="dark"] body.story-page .story-chapter,
html[data-theme="dark"] body.story-page .story-map-caption{
  background:var(--surface)!important;
  border-color:var(--line)!important;
  color:var(--text)!important;
}
html[data-theme="dark"] body.story-page .story-chapter.is-active{
  background:color-mix(in srgb,var(--surface) 91%,var(--surface2))!important;
  border-color:color-mix(in srgb,var(--primary) 36%,var(--line))!important;
  box-shadow:0 14px 34px rgba(0,0,0,.22)!important;
}
html[data-theme="dark"] body.story-page .story-map-head,
html[data-theme="dark"] body.story-page .story-step,
html[data-theme="dark"] body.story-page .story-chapter .tags span{
  background:var(--surface2)!important;
  border-color:var(--line)!important;
}
html[data-theme="dark"] body.story-page .story-chapter-media{
  background:color-mix(in srgb,var(--surface2) 88%,var(--bg))!important;
  border-color:var(--line)!important;
}
html[data-theme="dark"] body.story-page .story-chapter-kicker,
html[data-theme="dark"] body.story-page .story-step,
html[data-theme="dark"] body.story-page .story-map-caption span{
  color:var(--primary)!important;
}
html[data-theme="dark"] body.story-page .story-publication-venue{
  color:var(--primary2)!important;
}
html[data-theme="dark"] body.story-page .story-more,
html[data-theme="dark"] body.story-page .story-map-reset{
  background:var(--neutral-button,var(--surface))!important;
  border-color:var(--line)!important;
  color:var(--primary2)!important;
}
html[data-theme="dark"] body.story-page .story-more:hover,
html[data-theme="dark"] body.story-page .story-map-reset:hover{
  background:var(--neutral-button-hover,var(--surface2))!important;
  border-color:color-mix(in srgb,var(--accent) 55%,var(--line))!important;
}
html[data-theme="dark"] body[data-story-page="research"] .story-chapter.is-active .story-more,
html[data-theme="dark"] body[data-story-page="publications"] .story-chapter.is-active .story-more{
  background:#182932!important;
  color:#fff!important;
  border-color:var(--accent)!important;
}

/* Leaflet UI: avoid bright white control/pop-up islands in dark mode. */
html[data-theme="dark"] body.story-page .leaflet-bar,
html[data-theme="dark"] body.story-page .leaflet-control-layers,
html[data-theme="dark"] body.story-page .leaflet-popup-content-wrapper,
html[data-theme="dark"] body.story-page .leaflet-popup-tip{
  background:var(--surface)!important;
  color:var(--text)!important;
  border-color:var(--line)!important;
}
html[data-theme="dark"] body.story-page .leaflet-bar a,
html[data-theme="dark"] body.story-page .leaflet-bar a:hover{
  background:var(--surface)!important;
  color:var(--primary2)!important;
  border-color:var(--line)!important;
}
html[data-theme="dark"] body.story-page .leaflet-control-attribution{
  background:color-mix(in srgb,var(--surface) 90%,transparent)!important;
  color:var(--muted)!important;
}
html[data-theme="dark"] body.story-page .leaflet-control-attribution a{
  color:var(--primary)!important;
}

/* =========================================================
   ALL INDIVIDUAL RESEARCH DETAIL PAGES
   Fix fixed cream/white/navy values inherited from styles.css.
   ========================================================= */
html[data-theme="dark"] .academic-research-page{
  background:var(--bg)!important;
  color:var(--text)!important;
}
html[data-theme="dark"] .academic-research-page .research-detail-intro,
html[data-theme="dark"] .academic-research-page .academic-paper-hero{
  background:linear-gradient(180deg,
    color-mix(in srgb,var(--surface2) 72%,var(--bg)),
    var(--bg))!important;
  border-color:var(--line)!important;
}
html[data-theme="dark"] .academic-research-page .research-detail-intro h1,
html[data-theme="dark"] .academic-research-page .academic-paper-heading h1,
html[data-theme="dark"] .academic-research-page .research-detail-disclosure-content h2,
html[data-theme="dark"] .academic-research-page .academic-section h2,
html[data-theme="dark"] .academic-research-page .academic-section h3{
  color:var(--primary2)!important;
}
html[data-theme="dark"] .academic-research-page .academic-breadcrumbs,
html[data-theme="dark"] .academic-research-page .research-detail-summary,
html[data-theme="dark"] .academic-research-page .research-detail-reading-note,
html[data-theme="dark"] .academic-research-page .research-detail-visual-caption,
html[data-theme="dark"] .academic-research-page .academic-affiliation,
html[data-theme="dark"] .academic-research-page .academic-cover-figure figcaption,
html[data-theme="dark"] .academic-research-page .academic-figure figcaption,
html[data-theme="dark"] .academic-research-page .academic-section>p,
html[data-theme="dark"] .academic-research-page .academic-section li,
html[data-theme="dark"] .academic-research-page .academic-abstract>p:last-child,
html[data-theme="dark"] .academic-research-page .academic-objectives p,
html[data-theme="dark"] .academic-research-page .academic-authorship-box dd,
html[data-theme="dark"] .academic-research-page .academic-authorship-box>p,
html[data-theme="dark"] .academic-research-page .academic-sidebar-card p,
html[data-theme="dark"] .academic-research-page .academic-sidebar-dl dd,
html[data-theme="dark"] .academic-research-page .research-detail-disclosure-content p,
html[data-theme="dark"] .academic-research-page .research-detail-disclosure-content li{
  color:var(--muted)!important;
}
html[data-theme="dark"] .academic-research-page .academic-breadcrumbs a,
html[data-theme="dark"] .academic-research-page .research-detail-label,
html[data-theme="dark"] .academic-research-page .research-detail-keylines dt,
html[data-theme="dark"] .academic-research-page .research-detail-disclosure summary::after{
  color:var(--primary)!important;
}
html[data-theme="dark"] .academic-research-page .academic-record-label,
html[data-theme="dark"] .academic-research-page .academic-section-label,
html[data-theme="dark"] .academic-research-page .academic-objectives span,
html[data-theme="dark"] .academic-research-page .academic-authorship-box dt,
html[data-theme="dark"] .academic-research-page .academic-sidebar-dl dt{
  color:var(--accent)!important;
}
html[data-theme="dark"] .academic-research-page .research-detail-keylines dd,
html[data-theme="dark"] .academic-research-page .academic-author-line,
html[data-theme="dark"] .academic-research-page .academic-table td:first-child,
html[data-theme="dark"] .academic-research-page .research-detail-disclosure-content strong{
  color:var(--text)!important;
}

/* Primary page surfaces */
html[data-theme="dark"] .academic-research-page .academic-paper-body{
  background:var(--bg)!important;
}
html[data-theme="dark"] .academic-research-page .research-detail-hero-visual,
html[data-theme="dark"] .academic-research-page .academic-cover-figure,
html[data-theme="dark"] .academic-research-page .academic-manuscript,
html[data-theme="dark"] .academic-research-page .academic-figure,
html[data-theme="dark"] .academic-research-page .academic-authorship-box,
html[data-theme="dark"] .academic-research-page .academic-sidebar-card,
html[data-theme="dark"] .academic-research-page .research-detail-disclosure,
html[data-theme="dark"] .academic-research-page .research-detail-disclosure-content,
html[data-theme="dark"] .academic-research-page .academic-table-wrap,
html[data-theme="dark"] .academic-research-page .academic-table,
html[data-theme="dark"] .academic-research-page .academic-table td{
  background:var(--surface)!important;
  border-color:var(--line)!important;
  color:var(--text)!important;
  box-shadow:none!important;
}
html[data-theme="dark"] .academic-research-page .research-detail-hero-visual img,
html[data-theme="dark"] .academic-research-page .academic-cover-figure img,
html[data-theme="dark"] .academic-research-page .academic-figure img{
  background:var(--surface2)!important;
}
html[data-theme="dark"] .academic-research-page .research-detail-keylines,
html[data-theme="dark"] .academic-research-page .academic-section,
html[data-theme="dark"] .academic-research-page .academic-authorship-box dl>div,
html[data-theme="dark"] .academic-research-page .academic-sidebar-dl>div,
html[data-theme="dark"] .academic-research-page .academic-page-nav a,
html[data-theme="dark"] .academic-research-page .research-detail-disclosure-content .academic-section{
  border-color:var(--line)!important;
}

/* Disclosure panels / objective blocks */
html[data-theme="dark"] .academic-research-page .research-detail-disclosure summary{
  background:var(--surface)!important;
  color:var(--primary2)!important;
}
html[data-theme="dark"] .academic-research-page .research-detail-disclosure[open] summary{
  background:var(--surface2)!important;
  border-color:var(--line)!important;
}
html[data-theme="dark"] .academic-research-page .academic-objectives>div,
html[data-theme="dark"] .academic-research-page .research-detail-disclosure-content .academic-objectives>div{
  background:color-mix(in srgb,var(--surface2) 68%,var(--surface))!important;
  border-color:var(--line)!important;
}

/* Tables */
html[data-theme="dark"] .academic-research-page .academic-table-wrap{
  border-top-color:color-mix(in srgb,var(--primary) 55%,var(--line))!important;
  border-bottom-color:var(--line)!important;
}
html[data-theme="dark"] .academic-research-page .academic-table th{
  background:var(--surface2)!important;
  color:var(--primary2)!important;
  border-color:var(--line)!important;
}
html[data-theme="dark"] .academic-research-page .academic-table td{
  color:var(--muted)!important;
  border-color:var(--line)!important;
}
html[data-theme="dark"] .academic-research-page .academic-table tbody tr:hover td{
  background:color-mix(in srgb,var(--surface2) 52%,var(--surface))!important;
}

/* Navigation / related manuscript box */
html[data-theme="dark"] .academic-research-page .research-detail-back-link,
html[data-theme="dark"] .academic-research-page .academic-page-nav a{
  color:var(--primary)!important;
  border-color:var(--line)!important;
}
html[data-theme="dark"] .academic-research-page .research-detail-back-link{
  border-bottom-color:var(--accent)!important;
}
html[data-theme="dark"] .academic-research-page .academic-back-button{
  background:#182932!important;
  color:#fff!important;
  border:1px solid var(--accent)!important;
}

/* Keep supplied figures/photos scientifically faithful. */
html[data-theme="dark"] .academic-research-page img,
html[data-theme="dark"] body.story-page img{
  filter:none!important;
}

/* ---------- Publication status badge ---------- */
html[data-theme="dark"] #publication-record-page .publication-record-topline span{
  background:color-mix(in srgb,var(--surface2) 82%,var(--surface))!important;
  border-color:color-mix(in srgb,var(--primary) 38%,var(--line))!important;
  color:var(--primary)!important;
}

/* ---------- Mobile: no bright overflow surfaces ---------- */
@media(max-width:780px){
  html[data-theme="dark"] .academic-research-page .academic-table-wrap{
    background:var(--surface)!important;
  }
  html[data-theme="dark"] body.story-page .story-chapter-meta{
    border-color:var(--line)!important;
  }
}

/* Teaching image stage was one remaining fixed light surface found in the site-wide audit. */
html[data-theme="dark"] .teaching-capacity-page .tc-photo-main,
html[data-theme="dark"] .teaching-capacity-page .tc-photo-pair figure{
  background:var(--surface2)!important;
  border-color:var(--line)!important;
}
