/* WUN country map + country gateway pages. */

:root {
  --map-europe: #0f6b57;
  --map-asia: #2b6cb0;
  --map-africa: #c45c26;
  --map-oceania: #8a5bb5;
  --map-north-america: #b7791f;
  --map-latin-america: #2f855a;
  /* choropleth surface tones (site palette: warm paper + sea-glass green) */
  --map-ocean: #d6e3e0;
  --map-land: #efe9da;
}

.map-panel {
  padding: 0.9rem;
}

.map-frame {
  width: 100%;
}

.world-map {
  display: block;
  width: 100%;
  height: auto;
}

.map-ocean {
  fill: var(--map-ocean);
}

/* Neutral landmass backdrop: every country that is not a WUN member. */
.map-land-base {
  fill: var(--map-land);
  stroke: rgba(16, 35, 63, 0.08);
  stroke-width: 0.55;
}

.map-members {
  isolation: isolate;
}

/* ---- Landing gateway: Countries / Universities mode switch (no JS) ---- */
.map-gateway {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.9rem;
  position: relative;
}

.map-mode {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.map-mode-btn {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 1rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.map-mode-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.map-mode:checked + .map-mode-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
}

.map-mode:focus-visible + .map-mode-btn {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.map-gateway .map-frame {
  order: 10;
  flex: 1 1 100%;
}

/* Countries layer is the default; the universities layer swaps in via CSS. */
.map-layer-universities {
  display: none;
}

#gm-universities:checked ~ .map-frame .map-layer-universities {
  display: block;
}

#gm-universities:checked ~ .map-frame .map-layer-countries {
  display: none;
}

/* University markers (layer above the landmass). */
.map-uni-link {
  cursor: pointer;
}

.map-uni circle:first-of-type {
  transition: filter 0.15s ease, transform 0.15s ease;
  transform-origin: center;
  transform-box: fill-box;
}

.map-uni-link:hover .map-uni circle:first-of-type,
.map-uni-link:focus .map-uni circle:first-of-type {
  filter: brightness(1.12) saturate(1.12);
  transform: scale(1.15);
}

.map-country-link {
  cursor: pointer;
}

.map-country {
  stroke: #fffdf8;
  stroke-width: 1.1;
  transition: filter 0.15s ease;
}

.map-country-link:hover .map-country,
.map-country-link:focus .map-country {
  filter: brightness(1.08) saturate(1.18);
  stroke: var(--ink);
  stroke-width: 1.6;
}

.map-country-code {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  fill: #fffdf8;
  paint-order: stroke;
  stroke: rgba(16, 35, 63, 0.35);
  stroke-width: 2.5px;
  stroke-linejoin: round;
  pointer-events: none;
}

/* Name/region readout revealed while hovering/focusing a member country.
   Drawn over the empty ocean at the bottom of the map (~65°S and south),
   so it is never hidden behind another country's landmass. */
.map-tip {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.map-country-link:hover .map-tip,
.map-country-link:focus .map-tip,
.map-uni-link:hover .map-tip,
.map-uni-link:focus .map-tip,
.map-marker-link:hover .map-tip,
.map-marker-link:focus .map-tip {
  opacity: 1;
}

.map-tip rect {
  fill: var(--white);
  stroke: var(--line);
}

.map-tip-text {
  font-family: var(--font-ui);
}

.map-tip-name {
  font-size: 18px;
  font-weight: 700;
  fill: var(--ink);
}

.map-tip-sep {
  font-size: 15px;
  font-weight: 700;
  fill: rgba(16, 35, 63, 0.3);
}

.map-tip-region {
  font-size: 13px;
  font-weight: 650;
  fill: var(--accent-deep);
}

/* Point-marker fallback for members without landmass geometry (Hong Kong). */
.map-marker-link {
  cursor: pointer;
}

.map-marker circle:first-of-type {
  transition: filter 0.15s ease, transform 0.15s ease;
  transform-origin: center;
  transform-box: fill-box;
}

.map-marker-link:hover .map-marker circle:first-of-type,
.map-marker-link:focus .map-marker circle:first-of-type {
  filter: brightness(1.12) saturate(1.1);
  transform: scale(1.15);
}

.map-marker-label {
  font-family: var(--font-ui);
  font-size: 8px;
  font-weight: 700;
  fill: #fffdf8;
  pointer-events: none;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin-top: 0.75rem;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  display: inline-block;
}

.country-group h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0 0 0.9rem;
}

.country-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.6rem;
}

.country-card {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.country-card:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(16, 35, 63, 0.06);
}

.country-flag {
  flex: 0 0 auto;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.78rem;
  color: #fffdf8;
  background: var(--accent);
  padding: 0.2rem 0.4rem;
  border-radius: 7px;
}

.country-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.country-card-body strong {
  font-family: var(--font-ui);
  font-weight: 650;
  font-size: 0.95rem;
}

.country-card-meta {
  font-family: var(--font-ui);
  font-size: 0.76rem;
  color: var(--ink-soft);
}

.country-card-funders {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.2rem;
}

.country-card-funders .tag {
  margin-left: 0;
  font-size: 0.66rem;
}

/* Country detail page */
.country-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 760px) {
  .country-facts {
    grid-template-columns: 1fr;
  }
}

.fact-label {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin-bottom: 0.5rem;
}

.member-list,
.funder-list {
  margin: 0;
  padding-left: 1.1rem;
  font-family: var(--font-ui);
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.member-list li,
.funder-list li {
  margin: 0.3rem 0;
}

.funder-list strong {
  color: var(--ink);
}

.funder-list a {
  margin-left: 0.4rem;
  font-size: 0.78rem;
  text-decoration: none;
}

.funder-list a:hover {
  text-decoration: underline;
}

.country-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.country-chips a {
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: var(--paper-deep);
  color: var(--accent-deep);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 650;
  text-decoration: none;
}

.country-chips a:hover {
  background: var(--accent-glow);
}

.row-closed {
  opacity: 0.55;
}
