/* Research landscape map on /research/. Markup: _includes/research-landscape.html.
   Each cluster sets --c (outline and tint) and --c-fill (work pill, carries white text).
   The research direction uses its own violet so it reads apart from past work. */

.rl--reliability { --c: #5a7fc6; --c-fill: #4468ad; }
.rl--safety      { --c: #4f9a98; --c-fill: #2f7573; }
.rl--language    { --c: #b9606e; --c-fill: #a04b5a; }
.rl--earth       { --c: #6b9a6e; --c-fill: #47784b; }
.rl--society     { --c: #c29a52; --c-fill: #85631f; }
.rl--direction   { --c: #8b6fc4; }
.rl-dir          { --c: #8b6fc4; }

.rl-scroll { overflow-x: auto; margin-inline: -0.5rem; padding: 0.5rem; }

.rl-stage {
  position: relative;
  container-type: inline-size;
  min-width: 720px;
  aspect-ratio: 1000 / 700;
}

.rl-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

.rl-region {
  fill: color-mix(in srgb, var(--c) 9%, transparent);
  stroke: color-mix(in srgb, var(--c) 60%, transparent);
  stroke-width: 1.2;
  stroke-dasharray: 5 5;
  vector-effect: non-scaling-stroke;
}

.rl-edge {
  stroke: var(--muted);
  stroke-opacity: 0.4;
  stroke-width: 1;
  stroke-dasharray: 4 4;
  vector-effect: non-scaling-stroke;
  transition: stroke-opacity 0.2s ease, stroke 0.2s ease;
}

.rl-node {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 0.45em 1.1em;
  border-radius: 999px;
  text-align: center;
  line-height: 1.25;
  white-space: nowrap;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.rl-topic {
  text-decoration: none;
  font-size: clamp(0.72rem, 1.7cqw, 1.2rem);
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--c);
}

.rl-work {
  z-index: 1;
  font-size: clamp(0.66rem, 1.4cqw, 0.98rem);
  font-weight: 600;
  color: #fff;
  background: var(--c-fill);
  border: 1.5px solid var(--c-fill);
  text-decoration: none;
}

.rl-work:hover,
.rl-work:focus-visible,
.rl-dir:hover,
.rl-dir:focus-visible {
  transform: translate(-50%, -50%) scale(1.06);
  box-shadow: var(--shadow-hover);
}

/* Research direction: dashed outline in its own colour, set apart from past work. */
.rl-dir {
  z-index: 2;
  font-size: clamp(0.68rem, 1.45cqw, 1rem);
  font-weight: 650;
  color: var(--text);
  background: var(--bg);
  border: 2px dashed var(--c);
  text-decoration: none;
}
.rl-dir:hover, .rl-dir:focus-visible { color: var(--text); }
.rl-work:hover, .rl-work:focus-visible { color: #fff; }
.rl--direction.rl-region { stroke-width: 1.6; fill: color-mix(in srgb, var(--c) 12%, transparent); }
.rl-edge--dir { stroke: #8b6fc4; stroke-opacity: 0.55; }

.rl-region-label {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: clamp(0.68rem, 1.25cqw, 0.9rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--c);
  white-space: nowrap;
}

.rl-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.6rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-xs);
  color: var(--muted);
}
.rl-legend li { display: flex; align-items: center; gap: 0.5rem; }
.rl-key { display: inline-block; width: 1.9rem; height: 0.95rem; border-radius: 999px; }
.rl-key--work { background: #4468ad; }
.rl-key--topic { background: var(--bg); border: 1.5px solid #5a7fc6; }
.rl-key--dir { background: var(--bg); border: 2px dashed #8b6fc4; }

/* While a paper is previewed, fade the rest so its links read clearly.
   Pills stay opaque so the lines behind them never show through. */
.rl-stage.is-focused .rl-topic:not(.is-active) { color: var(--muted); border-color: color-mix(in srgb, var(--c) 40%, var(--bg)); }
.rl-stage.is-focused .rl-work:not(.is-active) { background: color-mix(in srgb, var(--c-fill) 45%, var(--bg)); border-color: transparent; }
.rl-stage.is-focused .rl-edge { stroke-opacity: 0.12; }
.rl-stage.is-focused .rl-edge.is-active { stroke: var(--text); stroke-opacity: 0.75; stroke-dasharray: none; }
.rl-stage.is-focused .rl-edge--dir.is-active { stroke: #8b6fc4; stroke-opacity: 0.95; }
.rl-stage.is-focused .rl-dir:not(.is-active) { color: var(--muted); border-color: color-mix(in srgb, var(--c) 40%, var(--bg)); }

.rl-preview {
  position: absolute;
  z-index: 3;
  width: min(340px, 70%);
  padding: 1rem 1.1rem;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  pointer-events: none;
}

.rl-preview p { margin: 0; }
.rl-preview-venue { font-size: var(--fs-2xs); color: var(--muted); }
.rl-preview-title { margin-top: 0.35rem !important; font: 650 0.92rem/1.35 "Space Grotesk", sans-serif; color: var(--text); }
.rl-preview-desc { margin-top: 0.5rem !important; font-size: var(--fs-xs); line-height: 1.55; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .rl-node, .rl-edge { transition: none; }
  .rl-work:hover, .rl-work:focus-visible, .rl-dir:hover, .rl-dir:focus-visible { transform: translate(-50%, -50%); }
}

/* Research direction cards, rendered from the same data file as the map. */
.rd-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.rd-card { background: var(--bg); padding: var(--card-pad-lg); scroll-margin-top: 6rem; }
.rd-card h3 { font-size: clamp(1.15rem, 1.9vw, 1.45rem); line-height: 1.2; margin: 0 0 0.75rem; }
.rd-card p { margin: 0; color: var(--muted); line-height: 1.65; font-size: var(--fs-md); }
.rd-card .rd-builds { margin-top: 1.1rem; padding-top: 0.8rem; border-top: 1px solid var(--line); font-size: var(--fs-xs); }
.rd-builds span { color: var(--text); font-weight: 700; margin-right: 0.35rem; }
.rd-builds a { color: var(--text); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.rd-card:target { outline: 2px dashed #8b6fc4; outline-offset: -2px; }
@media (max-width: 800px) { .rd-grid { grid-template-columns: 1fr; } }

/* Current Research layout. The alternate selector supports cached explorer pages. */
/* Selected Research work, open questions and their connections. */
.research-modern:is(.research-current, :has([data-research-connections])) .research-hero { grid-template-columns: 1fr; gap: 0; }
.research-modern:is(.research-current, :has([data-research-connections])) .research-hero h1 { max-width: 24ch; }
.research-modern:is(.research-current, :has([data-research-connections])) .research-feature-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; border: 1px solid var(--line); background: var(--line); }
.research-modern:is(.research-current, :has([data-research-connections])) .research-feature {
  display: block;
  padding: var(--card-pad-lg);
  border: 0;
  scroll-margin-top: 6rem;
}
.research-modern:is(.research-current, :has([data-research-connections])) .research-feature h3 { font-size: clamp(1.4rem, 2.5vw, 2rem); line-height: 1.25; }
.research-modern:is(.research-current, :has([data-research-connections])) .research-feature-name { margin: 0; color: var(--accent); font-weight: 700; }
.research-modern:is(.research-current, :has([data-research-connections])) .research-feature-meta { display: block; line-height: 1.7; }
.research-modern:is(.research-current, :has([data-research-connections])) .research-feature-meta span { display: block; }
.research-modern:is(.research-current, :has([data-research-connections])) .research-contribution { min-height: 0; margin: 1rem 0 0; }
.research-modern:is(.research-current, :has([data-research-connections])) .research-feature dl { margin: 1.75rem 0 1.5rem; }
.research-modern:is(.research-current, :has([data-research-connections])) .research-feature dl div { grid-template-columns: 110px minmax(0, 1fr); padding: 0.85rem 0; }
.research-modern:is(.research-current, :has([data-research-connections])) .research-feature dl div:first-child { border-top: 0; padding-top: 0; }
.research-modern:is(.research-current, :has([data-research-connections])) .research-feature dt { font-size: 0.8rem; text-transform: none; letter-spacing: 0; }
.research-modern:is(.research-current, :has([data-research-connections])) .research-feature dd { font-size: 0.95rem; color: var(--muted); line-height: 1.7; }
.research-modern:is(.research-current, :has([data-research-connections])) .research-feature-actions { flex-wrap: wrap; }
.research-modern:is(.research-current, :has([data-research-connections])) .research-feature:last-child:nth-child(odd) { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2.5rem; }
.research-modern:is(.research-current, :has([data-research-connections])) .research-feature:last-child:nth-child(odd) dl { margin-top: 0; }
.research-modern:is(.research-current, :has([data-research-connections])) .research-feature dd a { color: var(--text); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
@media (max-width: 760px) {
.research-modern:is(.research-current, :has([data-research-connections])) .research-feature-grid { grid-template-columns: 1fr; }
.research-modern:is(.research-current, :has([data-research-connections])) .research-feature:last-child:nth-child(odd) { display: block; }
.research-modern:is(.research-current, :has([data-research-connections])) .research-feature:last-child:nth-child(odd) dl { margin-top: 1.75rem; }
.research-modern:is(.research-current, :has([data-research-connections])) .research-feature { grid-template-columns: 1fr; gap: 1.5rem; }
.research-modern:is(.research-current, :has([data-research-connections])) .research-feature dl div { grid-template-columns: 1fr; gap: 0.5rem; }
}
