/* =========================================================================
   RESEARCH NETWORK — the collaboration/conference map on the home page.

   Moved out of site.css when the section gained a detail panel, filters and
   connection arcs. Everything is scoped to .rnet, and every colour comes from
   a site.css token: the map is deliberately almost invisible so the research
   relationships are what the eye lands on.
   ========================================================================= */

.rnet {
  --rnet-land: #eceff2;
  --rnet-arc: #c9ced6;
  --rnet-arc-live: var(--accent);
  --rnet-halo: rgba(181, 18, 23, 0.19);

  padding-block: 2.75rem 2rem;
  border-top: 1px solid var(--border);
}

/* --- Header ------------------------------------------------------------- */

.rnet__head {
  max-width: 46rem;
  margin-bottom: 1.5rem;
}

.rnet__title {
  margin: 0.625rem 0 0;
  font-size: clamp(1.5rem, 1.95vw, 1.8125rem);
  font-weight: 700;
  letter-spacing: -0.026em;
  line-height: 1.14;
}

.rnet__sub {
  margin: 0.4rem 0 0;
  max-width: 54ch;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--muted);
}

/* Text tabs, not pills: an underline carries the active state. */
.rnet__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-top: 1.25rem;
}

.rnet__filter {
  padding: 0 0 0.375rem;
  border: 0;
  border-bottom: 1.5px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--speed) var(--ease), border-color var(--speed) var(--ease);
}

.rnet__filter:hover {
  color: var(--text);
}

.rnet__filter[aria-pressed="true"] {
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.rnet__filter:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* --- Layout ------------------------------------------------------------- */

.rnet__layout {
  display: grid;
  grid-template-columns: minmax(0, 70fr) minmax(0, 30fr);
  gap: 2.5rem;
  align-items: start;
}

/* --- Map ---------------------------------------------------------------- */

.rnet__map {
  position: relative;
  width: 100%;
}

.rnet__base,
.rnet__overlay {
  display: block;
  width: 100%;
  aspect-ratio: 1000 / 438;
}

.rnet__overlay {
  position: absolute;
  inset: 0;
  overflow: visible;
}

/* --- Arcs ---------------------------------------------------------------
   One path per real collaboration, drawn home -> collaborator. A conference
   never gets one: presenting somewhere is not a collaboration. */

.rnet__arc {
  fill: none;
  stroke: var(--rnet-arc);
  /* Stroke widths are viewBox units; at desktop this lands near 1px. */
  stroke-width: 0.9;
  stroke-linecap: round;
  opacity: 0.45;
  transition: opacity var(--speed) var(--ease), stroke var(--speed) var(--ease),
    stroke-width var(--speed) var(--ease);
}

/* Collaborators filter: the arcs come forward a little. */
.rnet__map.is-filter-collaboration .rnet__arc {
  opacity: 0.75;
  stroke-width: 1.1;
}

/* Conferences filter: collaboration is not what is being shown. */
.rnet__map.is-filter-conference .rnet__arc {
  opacity: 0;
}

/* One selected collaborator: its arc only. */
.rnet__map.has-selection .rnet__arc {
  opacity: 0.16;
}

.rnet__map.has-selection .rnet__arc.is-live {
  stroke: var(--rnet-arc-live);
  stroke-width: 1.3;
  opacity: 0.9;
}

/* --- Markers ------------------------------------------------------------ */

.rnet__marker {
  cursor: pointer;
  transition: opacity var(--speed) var(--ease);
}

/* Invisible, generous hit area for touch and coarse pointers. */
.rnet__hit {
  fill: transparent;
}

.rnet__dot {
  fill: var(--accent);
  transition: transform var(--speed) var(--ease);
  transform-box: fill-box;
  transform-origin: center;
}

/* Conference: a small dot inside a pale halo. */
.rnet__halo {
  fill: var(--rnet-halo);
  opacity: 0;
  transition: opacity var(--speed) var(--ease);
}

.rnet__marker--conference .rnet__halo {
  opacity: 1;
}

/* Home: the same red disc, ringed in near-black so it reads as the base. */
.rnet__ring {
  fill: none;
  stroke: var(--text);
  stroke-width: 0.9;
  opacity: 0;
  transition: opacity var(--speed) var(--ease);
}

.rnet__marker--home .rnet__ring {
  opacity: 0.85;
}

/* Selection ring, for collaborators and conferences alike. */
.rnet__sel {
  fill: none;
  stroke: var(--accent);
  stroke-width: 0.9;
  opacity: 0;
  transition: opacity var(--speed) var(--ease);
}

.rnet__marker.is-selected .rnet__sel {
  opacity: 1;
}

.rnet__marker.is-selected .rnet__dot {
  transform: scale(1.15);
}

@media (hover: hover) {
  .rnet__marker:hover .rnet__dot {
    transform: scale(1.15);
  }
}

.rnet__marker:focus {
  outline: none;
}

.rnet__marker:focus-visible .rnet__sel {
  opacity: 1;
  stroke: var(--text);
  stroke-width: 1.2;
}

/* Filtered-out markers stay in the DOM (and in the tab order they lose via
   tabindex) but recede visually. */
.rnet__marker.is-muted {
  opacity: 0.12;
  pointer-events: none;
}

/* --- Hover tooltip -------------------------------------------------------
   Deliberately tiny: a name and a type, never a publication list. */

.rnet__tip {
  position: absolute;
  z-index: 3;
  max-width: 14rem;
  padding: 0.4375rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg);
  box-shadow: 0 6px 18px rgba(16, 16, 16, 0.09);
  pointer-events: none;
}

.rnet__tip-name {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
}

.rnet__tip-kind {
  margin: 0.125rem 0 0;
  font-size: 0.6875rem;
  line-height: 1.3;
  color: var(--muted);
}

/* --- Legend ------------------------------------------------------------- */

.rnet__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.6875rem;
  color: var(--muted);
}

.rnet__legend li {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.rnet__key {
  position: relative;
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--accent);
}

.rnet__key--home::after {
  content: "";
  position: absolute;
  inset: -0.1875rem;
  border: 1px solid var(--text);
  border-radius: 50%;
}

.rnet__key--conf::after {
  content: "";
  position: absolute;
  inset: -0.25rem;
  border-radius: 50%;
  background: var(--rnet-halo);
}

/* --- Detail panel --------------------------------------------------------
   A hairline and white space rather than a card. */

.rnet__panel {
  padding-left: 1.75rem;
  border-left: 1px solid var(--border);
  min-height: 18rem;
}

.rnet__eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  line-height: 1.4;
  text-transform: uppercase;
}

.rnet__place {
  margin: 0.5rem 0 0;
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.014em;
  line-height: 1.25;
}

.rnet__where {
  margin: 0.1875rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--muted);
}

.rnet__tally {
  margin: 0.75rem 0 0;
  font-size: 0.75rem;
  color: var(--light-muted);
}

.rnet__group {
  margin-top: 1.25rem;
}

.rnet__label {
  margin: 0 0 0.4375rem;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  line-height: 1.4;
  color: var(--light-muted);
  text-transform: uppercase;
}

.rnet__list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.8125rem;
  line-height: 1.55;
}

.rnet__list li + li {
  margin-top: 0.125rem;
}

.rnet__list a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border-strong);
}

.rnet__list a:hover {
  color: var(--accent);
  border-bottom-color: currentColor;
}

/* Areas read as a single wrapped line rather than a bulleted column. */
.rnet__areas {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--muted);
}

.rnet__link {
  display: inline-block;
  margin-top: 1.25rem;
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
}

.rnet__link + .rnet__link {
  margin-left: 1rem;
}

.rnet__link:hover {
  text-decoration: underline;
}

/* Empty state. */
.rnet__hint {
  margin: 0.625rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.65;
  color: var(--muted);
}

.rnet__glyph {
  display: block;
  width: 2.25rem;
  height: 2.25rem;
  margin-bottom: 0.875rem;
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 1;
}

.rnet__panel-body {
  transition: opacity 0.18s var(--ease);
}

.rnet__panel.is-swapping .rnet__panel-body {
  opacity: 0;
}

/* --- Text fallback ------------------------------------------------------
   Hidden while the map is drawn; real content if it is not. */

.rnet__fallback {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.rnet__map.is-degraded ~ .rnet__legend,
.rnet[data-rnet-degraded] .rnet__layout {
  display: none;
}

.rnet[data-rnet-degraded] .rnet__fallback {
  position: static;
  width: auto;
  height: auto;
  margin: 1.5rem 0 0;
  overflow: visible;
  clip: auto;
  clip-path: none;
  white-space: normal;
}

.rnet__fallback ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.75rem;
  max-width: 44rem;
}

.rnet__fallback li {
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--muted);
}

.rnet__fallback strong {
  display: block;
  color: var(--text);
}

/* =========================================================================
   Responsive
   ========================================================================= */

/* Tablet: still side by side, but the panel gets more room — the UAE cluster
   carries six names and must not be squeezed into a narrow column. */
@media (max-width: 1180px) {
  .rnet__layout {
    grid-template-columns: minmax(0, 62fr) minmax(0, 38fr);
    gap: 2rem;
  }

  .rnet__panel {
    padding-left: 1.5rem;
  }
}

/* Below 900 the two columns would both be cramped, so the panel moves under
   the map and becomes a full-width section. */
@media (max-width: 900px) {
  .rnet__layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.75rem;
  }

  .rnet__panel {
    padding-left: 0;
    padding-top: 1.5rem;
    border-left: 0;
    border-top: 1px solid var(--border);
    min-height: 0;
  }
}

/* Coarse pointers get larger markers — radii are viewBox units, so the
   small-screen map needs them bumped up to stay touch-friendly without
   looking oversized. */
@media (max-width: 860px) {
  .rnet__dot {
    r: 7.5;
  }

  .rnet__marker--conference .rnet__dot {
    r: 5.5;
  }

  .rnet__halo {
    r: 12;
  }

  .rnet__sel,
  .rnet__ring {
    r: 12;
  }

  .rnet__hit {
    r: 22;
  }

  .rnet__arc {
    stroke-width: 1.3;
  }
}

@media (max-width: 700px) {
  .rnet {
    padding-block: 2.25rem 1.75rem;
  }

  .rnet__head {
    margin-bottom: 1.25rem;
  }

  .rnet__filters {
    gap: 1rem;
  }

  /* Full-bleed map: cancelling the container gutter (rather than using 100vw,
     which counts the scrollbar gutter) keeps the page free of horizontal
     scroll.

     At phone width the whole 1000x438 world would be a 171px-tall sliver, so
     the frame is given a taller aspect and the map inside it is scaled up and
     centred. The crop keeps roughly longitudes -95 to +95, which still holds
     every marker on this map — Washington at -77 and Peradeniya at +80 — with
     room to spare. Both layers take identical geometry from --zoom, so the
     markers stay pinned to the land beneath them. */
  .rnet__map {
    width: auto;
    margin-inline: calc(var(--gutter) * -1);
    /* The frame states the height it wants; the map inside sizes itself to
       match and is cropped horizontally by whatever is left over. That keeps
       the height in the 320-390px band at every phone width instead of
       swinging with the aspect ratio. */
    height: clamp(20rem, 82vw, 24.5rem);
    aspect-ratio: auto;
    overflow: hidden;
  }

  .rnet__base,
  .rnet__overlay {
    position: absolute;
    inset: auto;
    left: 50%;
    top: 50%;
    width: auto;
    height: 100%;
    aspect-ratio: 1000 / 438;
    transform: translate(-50%, -50%);
  }

  /* The overlay must not clip the scaled markers at the frame edge. */
  .rnet__overlay {
    overflow: visible;
  }

  /* Hover tooltips are not a phone interaction; the panel carries everything. */
  .rnet__tip {
    display: none;
  }
}

/* Reduced motion: no arc reveal, no marker scaling, no panel crossfade. */
@media (prefers-reduced-motion: reduce) {
  .rnet__arc,
  .rnet__dot,
  .rnet__halo,
  .rnet__ring,
  .rnet__sel,
  .rnet__marker,
  .rnet__filter,
  .rnet__panel-body {
    transition: none;
  }

  .rnet__marker:hover .rnet__dot,
  .rnet__marker.is-selected .rnet__dot {
    transform: none;
  }

  .rnet__panel.is-swapping .rnet__panel-body {
    opacity: 1;
  }
}
