/* ================================================================
   RESEARCH ATLAS: interactive globe of study regions (js/research-atlas.js)
   Home page "Research Atlas" section. Plain CSS (no new Tailwind
   classes needed); colours follow the teal & gold theme.
   ================================================================ */

/* Layout */
.atlas {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
  align-items: center;
}
.atlas > * { min-width: 0; }   /* the canvas must not widen the column on phones */
@media (min-width: 1024px) {
  .atlas {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    gap: 3.5rem;
  }
}

.atlas-globe-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.atlas-stage {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1;
}
.atlas-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: pan-y;
  cursor: grab;
}
.atlas-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1rem;
  min-height: 2rem;
}
.atlas-hint {
  display: none;
  color: #94a3b8;
  font-size: 0.8rem;
}
.atlas--ready .atlas-hint { display: block; }

.atlas-tour-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.8rem;
  border: 1px solid rgba(232, 179, 90, 0.45);
  border-radius: 999px;
  background: rgba(232, 179, 90, 0.08);
  color: #f3cf8a;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.atlas-tour-btn::before {
  content: '';
  width: 0.55rem;
  height: 0.6rem;
  border-left: 2px solid currentColor;
  border-right: 2px solid currentColor;
  box-sizing: border-box;
}
.atlas-tour-btn.is-paused::before {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0.3rem 0 0.3rem 0.5rem;
  border-color: transparent transparent transparent currentColor;
}
.atlas-tour-btn:hover { background: rgba(232, 179, 90, 0.16); border-color: #e8b35a; }
.atlas-tour-btn[hidden] { display: none; }

/* Region tabs */
.atlas-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
@media (min-width: 640px) {
  .atlas-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.atlas-tabs[hidden] { display: none; }

.atlas-tab {
  --tab-color: #2dd4bf;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid rgba(51, 65, 85, 0.7);
  border-radius: 0.75rem;
  background: rgba(19, 31, 53, 0.7);
  color: #cbd5e1;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.atlas-tab[data-region='sahel'] { --tab-color: #e8b35a; }
.atlas-tab-dot {
  flex-shrink: 0;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: var(--tab-color);
  opacity: 0.55;
}
.atlas-tab:hover { border-color: var(--tab-color); color: #fff; }
.atlas-tab.is-active {
  border-color: var(--tab-color);
  background: color-mix(in srgb, var(--tab-color) 14%, #131f35);
  color: #fff;
  box-shadow: 0 0 0 1px var(--tab-color) inset;
}
.atlas-tab.is-active .atlas-tab-dot {
  opacity: 1;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tab-color) 30%, transparent);
}
.atlas-tab:focus-visible,
.atlas-tour-btn:focus-visible,
.atlas-panel:focus-visible {
  outline: 2px solid #f3cf8a;
  outline-offset: 2px;
}

/* Region panels: all shown, stacked, without JS; one at a time with JS.
   On desktop (where the tour plays by itself) they share one grid cell, so the
   block keeps the height of the tallest panel and nothing jumps as the tour
   moves on. On phones the panel takes its own height: it only changes when
   the visitor taps a tab. */
.atlas-panels { display: grid; gap: 1rem; }
.atlas--ready .atlas-panel.is-hidden { display: none; }
@media (min-width: 1024px) {
  .atlas--ready .atlas-panel { grid-area: 1 / 1; }
  /* Fade only between regions, not while the script sets up the first one */
  .atlas--animate .atlas-panel { transition: opacity 0.35s ease, visibility 0.35s; }
  .atlas--ready .atlas-panel.is-hidden { display: block; opacity: 0; visibility: hidden; }
}

.atlas-panel {
  --panel-color: #2dd4bf;
  position: relative;
  padding: 1.5rem;
  border: 1px solid rgba(51, 65, 85, 0.55);
  border-radius: 1rem;
  background: linear-gradient(160deg, rgba(24, 38, 64, 0.95), rgba(19, 31, 53, 0.85));
  overflow: hidden;
}
.atlas-panel[data-region='sahel'] { --panel-color: #e8b35a; }
.atlas-panel::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--panel-color);
}
@media (prefers-reduced-motion: reduce) {
  .atlas--animate .atlas-panel { transition: none; }
}

.atlas-kicker {
  color: var(--panel-color);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.atlas-title {
  margin-top: 0.3rem;
  color: #fff;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}
.atlas-text {
  margin-top: 0.75rem;
  color: #cbd5e1;
  font-size: 0.95rem;
  line-height: 1.65;
}
.atlas-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1rem;
  padding: 0;
  list-style: none;
}
.atlas-chips li {
  padding: 0.2rem 0.65rem;
  border: 1px solid color-mix(in srgb, var(--panel-color) 40%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel-color) 9%, transparent);
  color: color-mix(in srgb, var(--panel-color) 70%, #fff);
  font-size: 0.75rem;
  font-weight: 500;
}
.atlas-papers-label {
  margin-top: 1.25rem;
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.atlas-papers {
  margin-top: 0.5rem;
  padding: 0;
  list-style: none;
  border-top: 1px solid rgba(51, 65, 85, 0.5);
}
.atlas-papers li { border-bottom: 1px solid rgba(51, 65, 85, 0.5); }
.atlas-papers a,
.atlas-papers .atlas-paper {
  display: block;
  padding: 0.6rem 1.4rem 0.6rem 0;
  position: relative;
  color: #e2e8f0;
  font-size: 0.875rem;
  line-height: 1.45;
  text-decoration: none;
}
.atlas-papers a::after {
  content: '↗';
  position: absolute;
  top: 0.6rem;
  right: 0.1rem;
  color: var(--panel-color);
  font-size: 0.8rem;
}
.atlas-papers a:hover { color: #fff; }
.atlas-papers a:hover .atlas-paper-title { text-decoration: underline; text-decoration-color: var(--panel-color); text-underline-offset: 3px; }
.atlas-paper-meta {
  display: block;
  margin-top: 0.15rem;
  color: #94a3b8;
  font-size: 0.75rem;
}

/* Themes strip under the atlas */
.atlas-themes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 3rem;
  padding: 0;
  list-style: none;
}
.atlas-themes li {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.95rem 0.45rem 0.55rem;
  border: 1px solid rgba(51, 65, 85, 0.6);
  border-radius: 999px;
  background: rgba(19, 31, 53, 0.7);
  color: #e2e8f0;
  font-size: 0.85rem;
  font-weight: 500;
}
.atlas-themes svg {
  width: 1.1rem;
  height: 1.1rem;
  color: #5eead4;
}
.atlas-themes-label {
  margin-top: 3rem;
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}
.atlas-themes-label + .atlas-themes { margin-top: 0.85rem; }

/* Without JS there is no globe to draw: show only the region panels */
.atlas:not(.atlas--ready) .atlas-globe-col { display: none; }

/* Data credit under the globe */
.atlas-credit {
  display: none;
  color: #64748b;
  font-size: 0.7rem;
}
.atlas--ready .atlas-credit { display: block; }
.atlas-credit a { color: #94a3b8; text-decoration: underline; text-underline-offset: 2px; }
.atlas-credit a:hover { color: #f3cf8a; }

/* Tour progress: a thin bar filling inside the active tab, over a faint track */
.atlas-tab { position: relative; overflow: hidden; }
.atlas-tab::before,
.atlas-tab::after {
  content: '';
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.28rem;
  height: 2px;
  border-radius: 2px;
  opacity: 0;
}
.atlas-tab::before { background: rgba(255, 255, 255, 0.14); }
.atlas-tab::after {
  background: color-mix(in srgb, var(--tab-color) 55%, #fff);
  transform-origin: left center;
  transform: scaleX(0);
}
.atlas--touring .atlas-tab.is-active::before { opacity: 1; }
.atlas--touring .atlas-tab.is-active::after {
  opacity: 1;
  transform: scaleX(var(--atlas-progress, 0));
}
