/* ==========================================================================
   Custom theme (light/dark) + page overrides + interactive background
   ========================================================================== */

/* --- Light theme (default) --- */
:root,
[data-theme="light"] {
  --bg: #ffffff;
  --bg-secondary: #f8f9fa;
  --text: #2d3748;
  --text-muted: #5a6a7a;
  --border-color: #e8e8e8;
  --border-hover: #d0d0d0;
  --card-bg: #fafafa;
  --link: #52adc8;
  --link-hover: #3a8fa8;
  --masthead-bg: #ffffff;
  --sidebar-bg: transparent;
  --bg-blob-1: #e8f4f8;
  --bg-blob-2: #f0e8f8;
  --bg-blob-3: #f8f4e8;
}

/* --- Dark theme (black bg, white text) --- */
[data-theme="dark"] {
  --bg: #000000;
  --bg-secondary: #1a1a1a;
  --text: #ffffff;
  --text-muted: #b0b0b0;
  --border-color: #333333;
  --border-hover: #444444;
  --card-bg: #1a1a1a;
  --link: #7dd3fc;
  --link-hover: #bae6fd;
  --masthead-bg: #000000;
  --sidebar-bg: transparent;
  --bg-blob-1: #0d1f26;
  --bg-blob-2: #1a1a26;
  --bg-blob-3: #1f1a0d;
}

/* --- Interactive background --- */
.interactive-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}
.interactive-bg canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.site-content {
  position: relative;
  z-index: 0;
  min-height: 100vh;
  background: rgba(255, 255, 255, 0.88);
  transition: background 0.3s ease;
}
[data-theme="dark"] .site-content {
  background: rgba(0, 0, 0, 0.95);
}

[data-theme="dark"] body {
  background-color: var(--bg);
  color: var(--text);
}

/* Dark theme: force top nav to black with white text (high specificity to override theme) */
html[data-theme="dark"] .masthead,
html[data-theme="dark"] .masthead__inner-wrap,
html[data-theme="dark"] .masthead .masthead__inner-wrap,
html[data-theme="dark"] .greedy-nav {
  background: #000000 !important;
  background-color: #000000 !important;
  border-bottom-color: var(--border-color);
}

html[data-theme="dark"] .masthead a,
html[data-theme="dark"] .greedy-nav .visible-links a,
html[data-theme="dark"] .greedy-nav a {
  color: #ffffff !important;
}

html[data-theme="dark"] .masthead a:hover,
html[data-theme="dark"] .greedy-nav .visible-links a:hover,
html[data-theme="dark"] .greedy-nav a:hover {
  color: var(--link) !important;
}

html[data-theme="dark"] .greedy-nav button {
  background-color: #1a1a1a !important;
  color: #ffffff;
}

html[data-theme="dark"] .theme-toggle-wrap,
html[data-theme="dark"] .theme-icon {
  color: #ffffff;
}

[data-theme="dark"] .page__content a,
[data-theme="dark"] .archive a,
[data-theme="dark"] .author__urls a {
  color: var(--link);
}

[data-theme="dark"] .page__content a:hover,
[data-theme="dark"] .archive a:hover {
  color: var(--link-hover);
}

[data-theme="dark"] .author__avatar img {
  border-color: var(--border-color);
}

[data-theme="dark"] .sidebar,
[data-theme="dark"] .author__content {
  color: var(--text);
}

[data-theme="dark"] .author__urls {
  background: var(--bg-secondary);
  border-color: var(--border-color);
}

[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3,
[data-theme="dark"] .page__title,
[data-theme="dark"] .author__name {
  color: var(--text);
}

[data-theme="dark"] .page__content h2 {
  border-bottom-color: var(--border-color);
}

[data-theme="dark"] .publication-item {
  border-left-color: var(--border-color);
}

[data-theme="dark"] .archive,
[data-theme="dark"] .page__content {
  color: var(--text);
}

[data-theme="dark"] .hidden-links {
  background: var(--bg-secondary);
  border-color: var(--border-color);
}
[data-theme="dark"] .hidden-links a {
  color: var(--text);
}
[data-theme="dark"] .navicon {
  background: var(--text);
}
[data-theme="dark"] .navicon::before,
[data-theme="dark"] .navicon::after {
  background: var(--text);
}

[data-theme="dark"] .page__footer {
  color: var(--text);
}
[data-theme="dark"] .page__footer a {
  color: var(--link);
}
[data-theme="dark"] .page__footer a:hover {
  color: var(--link-hover);
}

/* Theme toggle at right end of masthead: sun – switch – moon (keep on one line) */
.masthead__menu {
  display: flex;
  align-items: center;
  width: 100%;
  flex-wrap: nowrap;
}
.theme-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  padding-left: 1rem;
  flex-shrink: 0;
  white-space: nowrap;
}
.theme-icon {
  display: inline-flex;
  color: var(--text-muted, #666);
  line-height: 1;
}
[data-theme="dark"] .theme-icon {
  color: var(--text-muted);
}
.theme-icon--sun { opacity: 0.9; }
.theme-icon--moon { opacity: 0.7; }
.theme-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}
.theme-switch__input {
  opacity: 0;
  width: 0;
  height: 0;
}
.theme-switch__slider {
  position: absolute;
  inset: 0;
  background: var(--border-hover, #c0c0c0);
  border-radius: 24px;
  transition: background 0.25s ease;
}
.theme-switch__slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.25s ease;
}
.theme-switch__input:checked + .theme-switch__slider {
  background: var(--link, #52adc8);
}
.theme-switch__input:checked + .theme-switch__slider::before {
  transform: translateX(20px);
}
.theme-switch__input:focus-visible + .theme-switch__slider {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}
[data-theme="dark"] .theme-switch__slider {
  background: var(--border-color);
}
[data-theme="dark"] .theme-switch__input:checked + .theme-switch__slider {
  background: var(--link);
}
[data-theme="dark"] .theme-switch__slider::before {
  background: var(--bg-secondary);
}
@media (max-width: 1023px) {
  .theme-toggle-wrap {
    padding-left: 0.5rem;
  }
}
/* Keep theme toggle visible and to the left of hamburger on small screens */
.greedy-nav {
  flex: 1 1 auto;
  min-width: 0;
}

/* --- Home page: organization logos --- */
.org-logos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1.5rem 2rem;
  margin: 1.5em 0;
  max-width: 720px;
}
.org-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5em;
}
.org-logo img {
  width: 80px;
  height: 80px;
  object-fit: contain;
}
.org-logo span {
  font-size: 0.85em;
  color: var(--text-muted, #555);
  line-height: 1.3;
}
@media (min-width: 600px) {
  .org-logos {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
  .org-logo img {
    width: 100px;
    height: 100px;
  }
}

/* Visitor map – smaller, no overlap */
.visitor-map {
  margin-top: 2em;
  margin-bottom: 2em;
  text-align: center;
  max-width: 320px;
  max-height: 220px;
  margin-left: auto;
  margin-right: auto;
  overflow: hidden;
}
.visitor-map > div,
.visitor-map iframe {
  max-width: 100%;
  max-height: 220px;
  margin: 0 auto;
  transform-origin: top left;
}

/* Footer: minimal – no panel, just copyright text */
.page__footer {
  z-index: 2;
  background: transparent !important;
  background-color: transparent !important;
  border: none !important;
  margin-top: 2em;
  padding: 0.5em 1em 1em;
  min-height: 0;
}
.page__footer footer {
  padding: 0;
  margin-top: 0;
}
.page__footer-copyright {
  margin-left: 0;
  font-size: 0.8rem;
  opacity: 0.85;
}
.page__footer-follow {
  display: none;
}

/* Main content and sidebars */
#main {
  padding-bottom: 2em;
}
.sidebar {
  z-index: 15;
}

/* Recent Updates: plain text at bottom of home page content (no panel) */
.recent-updates {
  margin-top: 2rem;
}
.recent-updates__title {
  margin: 1em 0 0.5em;
  font-size: 1em;
  font-weight: 600;
}
.recent-updates__list {
  margin: 0 0 1em;
  padding-left: 1.5em;
  list-style-type: disc;
}
.recent-updates__item {
  margin-bottom: 0.35em;
  line-height: 1.4;
}
.recent-updates__item a {
  text-decoration: underline;
}
.recent-updates__meta {
  font-size: 0.9em;
  color: var(--text-muted, #666);
  margin-left: 0.25em;
}

[data-theme="dark"] .recent-updates__meta {
  color: var(--text-muted);
}

/* Footer: clear left sidebar on desktop */
@media (min-width: 1024px) {
  .page__footer {
    margin-left: 260px;
    width: calc(100% - 260px);
  }
  .page__footer footer {
    margin-left: 0;
  }
}
