:root {
  --top-margin: 20px;
  --bottom-bar: 40px;
   --bottom-margin: 20px;
}

html,body {
  height: 100%;
  margin: 0;
  background: rgba(0,0,0,255);
}

#map-container {
  position: relative;
  width: 92vw;
  height: auto; /* overridden by JS */
  margin: var(--top-margin) auto 0; /* remove bottom margin so JS controls spacing */
  border: 1px solid white;
  overflow: hidden;
  background: #0d0d0d;
  touch-action: none;
  visibility: hidden; /* hide until ready */
}
#svg-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

#svg-wrapper svg {
  width: auto;       /* natural width */
  height: auto;      /* natural height */
  max-width: 90%;    /* optional */
  max-height: 90%;   /* optional */
}


#p5-wrapper {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
/* Toolbar */
#toolbar {
  position: fixed;
  bottom: env(safe-area-inset-bottom, 0px);
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  padding: 10px;
  display: flex;
  justify-content: center;
  gap: 8px;
  z-index: 1000;
}

/* Toolbar sections */
.toolbar-left,
.toolbar-center,
.toolbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end; /* make content hug right edge */
  gap: 10px;
  flex: 0; /* prevent stretching */
  padding-bottom:15px;
}

/* Toolbar buttons */
#toolbar button {
 min-width: 30px;
  height: 30px;
  border: 1px solid #fff;
  cursor: pointer;
  background: rgb(0, 0, 0);
  color: #fff;
 ;
}

#zoom-in {
  font-size: 16px;
  font-weight: bold;
}

#zoom-out {
  font-size: 16px;
  font-weight: bold;
}

#toggle-container {
  display: flex;
  gap: 6px;
}

.toggle-btn {
  width: auto;
  min-width: 0;
  padding: 0 10px;
  font-size: 14px;
  white-space: nowrap;
border: 1px solid #fff;
  
  cursor: pointer;
}

/* active / inactive states */
.toggle-btn.active {
  /*background-color: rgba(255,255,255,0.8) !important;
  color: black !important;*/
  font-weight: 600;
  text-decoration:underline;
}


#popUp {
  position: fixed;
  top: 50px;
  right: 30px;
  min-width: max-content;
  /*height: 600px;*/
  max-width: 90vw;
  max-height: 100vh;
  overflow-y: auto;

  background: #111;
  color: #fff;
  padding: 12px 14px;
  border-radius: 2px;
  font-family: sans-serif;
  font-size: 12px;
  line-height: 1.3;

  display: none; /* shown by JS */
  z-index: 9999;
}

#popUp h2 {
  margin: 0 0 6px 0;
  font-size: 20px;
}

#popUp p {
  margin: 4px 0 0 0px;
}

.popup-header {
  display: flex;
  flex-direction: column; /* stack main header and below section */
  gap: 6px; /* space between main header and belowHeader */
  margin-bottom: 10px;
}


.popup-header-shape {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
}

.popup-top-row {
  display: flex;
  align-items: center; /* shape centers with name + population */
  gap: 6px;
}

.popup-name-pop {
  display: flex;
  flex-direction: column;
}

.popup-title {
  font-size: 20px;
  font-weight: bold;
}

.popup-sub {
  font-size: 16px;
  line-height: 1.2;
}

.mig-info {
  font-weight: lighter;
  font-size: 14px;
  line-height: 1.2;
  margin-left: calc(24px + 6px); /* aligns under text, not shape */
}

.migration-list {
  max-height: 300px;
  overflow-y: auto;
  padding: 4px;
}

.migration-row {
  display: flex;
  align-items: center; /* shape matches text height */
  gap: 15px;
}

.shape-wrapper {
  width: 15px;  /* fixed width for the shape */
  display: flex;
  align-items: center;
  justify-content: center;
}


.shape-wrapper {
  width: 15px;  /* fixed width for the shape */
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom : 5px;
}


.migration-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.2;
  margin-bottom : 5px;
}

.migration-dest {
  font-weight: 400;
  font-size: 15px;
}

.migration-value {
  font-size: 14px;
  color: #aaa;
  
}

#popInfo  {
position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  width: 700px;
  max-width: 80%;
  max-height: 80%;        /* ← 80% of map-container */
  overflow-y: auto;

  z-index: 10;

  background: #000;
  color: #fff;
  padding: 20px 20px;
  border: 1px solid #fff;
gap: 20px;
  font-family: sans-serif;
  font-size: clamp(13px, 1.6vw, 16px);
  line-height: 1.5;
  text-align: center;
  display: none;
  z-index: 9999;
}
.popContact .contact-image {
  display: block;           /* so margin auto works */
  margin: 10px auto 10px auto; /* center horizontally + bottom margin */
  height: clamp(15px, 20vw, 50px); /* responsive height */
  width: auto;              /* maintain aspect ratio */
}
.popCompass {
  display: block; 
  height: clamp(20px, 20vw, 40px);
  margin:20px 0px;
  width: auto; 
}

.compass-image{
  max-height: 40px;
  margin-bottom:10px;
}
.popup-note {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 20px;
  margin-bottom: 30px;
}

#originCountry {
  display: inline-block;
  align-items: center;
  gap: 10px;
  margin: 15px 10px;
}



#popInfo a {
  color: #9fd3ff;
  text-decoration: underline;
}

#popInfo a:hover {
  color: #ffffff;
}

#popInfo .info-icons img {
  width: 22px;
  height: 22px;
  cursor: pointer;
}

#popInfo .info-icons a {
  text-decoration: none; /* removes underline */
}

#info-btn.active {
  font-weight: 600;
  opacity: 1;
  background-color: rgba(255,255,255,0.8);
  border-color: rgba(255,255,255,1);
  color: rgb(0,0,0);
}

#info-btn.active + #popInfo,
#popInfo.active {
  display: block;
}
