:root {
  --button-padding: 0.5rem 1rem;
  /* --scene-bg / --scene-fg / --node-invert arrive on <html> from the Panel
     colour (scene-theme plugin). Everything below follows them. */
  --bg: var(--scene-bg, #f2f2f2);
  --fg: #333;
  --fg-strong: #000;
  --fg-muted: #666;
  --fg-soft: #555;
  --surface: #fff;
  --surface-hover: #eee;
  --line: #000;
  --border-color: #333;
  --link: blue;
  --label-bg: rgba(255, 255, 255, 0.85);
  --border: 1px solid var(--border-color);
}

html[data-theme-mode="dark"] {
  --fg: #e6e6e6;
  --fg-strong: #ffffff;
  --fg-muted: #9a9a9a;
  --fg-soft: #b4b4b4;
  --surface: #1b1d21;
  --surface-hover: #2a2d33;
  --line: #f0f0f0;
  --border-color: #e6e6e6;
  --link: #8ab4ff;
  --label-bg: rgba(20, 22, 26, 0.85);
}

html {
  font-size: clamp(16px, 1.5vw, 21px);
  line-height: 1.1;
}

body {
  overflow: hidden;
  font-family: "Special Elite", "ltr-ncnd-variable", "Sandoll Typewrite", monospace, sans-serif;
  font-style: normal;
  font-weight: 300;
  font-variation-settings: "wght"500;
  background: var(--bg);
  color: var(--fg);
}

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

span[style*="font-size: 0.75em"],
span[style*="font-weight: 300"] {
  font-size: 0.75em !important;
  font-weight: 300 !important;
}

#network-graph {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.node {
  cursor: pointer;
}

.node .logo-wrap {
  transform-origin: 0 0;
  transition: transform 0.2s ease;
}

.node:hover .logo-wrap {
  transform: scale(1.1);
}

.node .logo-wrap image {
  pointer-events: auto;
  cursor: pointer;
  /* black silhouettes turn white on a dark background (Panel toggle) */
  filter: invert(var(--node-invert, 0));
}

.node .text-bg {
  fill: var(--surface);
  pointer-events: none;
}

.node text {
  font-family: "Special Elite", "ltr-ncnd-variable", "Sandoll Typewrite", monospace, sans-serif;
  fill: var(--fg);
  pointer-events: none;
  font-size: 0.75rem;
  font-weight: 600;
  font-variation-settings: "wght"600;
}

.node text tspan {
  font-size: 0.6em;
  font-weight: 300;
}

/* Links */
.link {
  stroke: var(--line);
  stroke-width: 2px;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  cursor: pointer;
  filter: url(#clay-stroke);
}

.tooltip {
  position: absolute;
  background: var(--surface);
  color: var(--fg);
  border: var(--border);
  pointer-events: none;
  z-index: 1000;
  overflow: visible;
  display: none;
}

.tooltip .tooltip-text {
  display: block;
  padding: 6px 10px;
}

.tooltip.show {
  display: block;
}

.tooltip.clickable {
  pointer-events: auto;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

.about-link {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1002;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.about-link button {
  color: var(--fg-strong);
  text-decoration: none;
  font-size: 0.875rem;
  padding: var(--button-padding);
  border: var(--border);
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
}

.about-link button:hover {
  background: var(--fg-strong);
  color: var(--surface);
}

.about-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1002;
  display: none;
  max-height: 100vh;
  overflow-y: auto;
  padding: 1rem;
  width: 25rem;
  height: 100%;
  background-color: var(--surface);
  border-left: var(--border);
}

.about-panel.is-open {
  display: block;
}

@media (max-width: 768px) {
  .about-panel {
    width: 100%;
    border: none;
  }
}

.about-panel-content {
  position: relative;
  width: 100%;
}

.about-panel-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  margin: 0 0 1rem 0;
  padding: 0;
  align-items: center;
}

.about-panel-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: normal;
}

.about-panel-header button {
  background: none;
  border: none;
  padding: var(--button-padding);
  margin: 0;
  line-height: 1;
  cursor: pointer;
  color: var(--fg);
  font-size: 2rem;
}

.about-panel-text {
  line-height: 1.8;
}

.about-panel-text p {
  margin-bottom: 1.5rem;
}

.about-panel-text p:last-child {
  margin-bottom: 0;
}

.articles-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1001;
  display: none;
  width: min(25rem, 90vw);
  max-width: 28rem;
  height: 80vh;
  max-height: 80vh;
  overflow: hidden;
  padding: 1rem;
  background: var(--surface);
  box-sizing: border-box;
  border: var(--border);
}

.articles-panel.is-open {
  display: block;
}

@media (max-width: 768px) {
  .articles-panel {
    width: min(22rem, 92vw);
    height: 85vh;
    max-height: 85vh;
  }
}

@media (min-width: 1280px) {
  .articles-panel {
    width: 26rem;
  }
}

.articles-panel-content {
  position: relative;
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.articles-panel-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 0 0 1rem 0;
  padding: 0;
}

.articles-panel-header button {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  line-height: 1;
  cursor: pointer;
  color: var(--fg);
  display: flex;
  justify-content: flex-end;
  font-size: 2rem;
}

.articles-panel-body {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
}

#articles-panel-title {
  margin: 0;
  padding: 0;
  line-height: 1.4;
  text-align: left;
}

#articles-panel-title a {
  display: inline;
}

.articles-panel-links {
  margin-top: 0.25rem;
  display: flex;
  flex-direction: row;
  gap: 0.75rem;
  align-items: center;
}

.articles-panel-image {
  margin: 0.25rem 0 0.5rem;
}

.articles-panel-image img {
  max-width: 5rem;
  max-height: 5rem;
  width: auto;
  height: auto;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.articles-panel-btn {
  display: inline-block;
  padding: var(--button-padding);
  font-size: 0.875rem;
  border: 1px solid currentColor;
  border-radius: 2px;
  text-decoration: none;
  color: var(--link);
}

.articles-panel-btn:hover {
  background: var(--fg-strong);
  color: var(--surface);
}

.articles-panel-description,
.articles-panel-projects {
  margin: 0;
  padding: 0;
  text-align: left;
}

.articles-panel-projects {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

.articles-panel-project-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-bottom: 1rem;
}

.articles-panel-project-desc {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--fg-soft);
  text-align: left;
}

.articles-panel-text {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--fg);
  text-align: left;
}

.articles-panel-text:last-child {
  margin-bottom: 0;
}

.articles-panel ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.articles-panel li {
  background: var(--surface);
  margin-bottom: 0.5rem;
}

.articles-panel li:last-child {
  margin-bottom: 0;
}

.font-loading {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "ltr-ncnd-variable", "Sandoll Typewrite", sans-serif;
  color: var(--fg);
}

.font-loading.done {
  pointer-events: none;
}

.font-loading-pct {
  font-variant-numeric: tabular-nums;
}

.project-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  pointer-events: none;
}

.project-footer__version {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.project-footer__copyright {
  opacity: 0.85;
}

/* ── Decorative Markers ── */
#map-markers-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}

.map-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
  user-select: none;
  transition: filter 0.2s ease;
}

.map-marker svg {
  filter: drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.15));
}
html[data-theme-mode="dark"] .map-marker svg {
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.25));
}

.map-marker__label {
  font-size: 0.6rem;
  color: var(--fg);
  background: var(--label-bg);
  padding: 1px 5px;
  border-radius: 2px;
  white-space: nowrap;
  line-height: 1.3;
  font-weight: 600;
}

.map-marker--editable {
  pointer-events: auto;
  cursor: grab;
}

.map-marker--editable:hover {
  filter: brightness(1.15) drop-shadow(0 0 6px rgba(0, 120, 255, 0.4));
}

.map-marker--dragging {
  cursor: grabbing;
  z-index: 100;
  filter: brightness(1.2) drop-shadow(0 0 8px rgba(0, 120, 255, 0.6));
}

.map-marker svg {
  width: 24px;
  height: 24px;
}

.map-markers--editing {
  pointer-events: auto;
}

#marker-edit-toggle {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 1003;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  background: var(--surface);
  border: var(--border);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.75rem;
  color: var(--fg);
  transition: background 0.15s, color 0.15s;
}

#marker-edit-toggle:hover {
  background: var(--surface-hover);
}

#marker-edit-toggle.active {
  background: var(--fg-strong);
  color: var(--surface);
}

@media (max-width: 768px) {
  #marker-edit-toggle {
    bottom: 0.75rem;
    right: 0.75rem;
    font-size: 0.65rem;
    padding: 0.35rem 0.6rem;
  }
  .map-marker svg {
    width: 20px;
    height: 20px;
  }
  .map-marker__label {
    font-size: 0.5rem;
  }
}

/* the image inside the node panel follows the same inversion as the node itself */
#articles-panel-image img {
  filter: invert(var(--node-invert, 0));
}
