#mapLegend{
	position: absolute;
	z-index: 1003;
	bottom:1rem;
	right:1rem;
	padding: 0.5rem;
	background-color: #fcfbf5cc;
  backdrop-filter: blur(2px);
	border: 2px solid lightgrey;
	display: none;
  max-height: 40rem;
  /* overflow: hidden; */
  transition: max-height 0.5s ease;
}

#mapLegendContent{
  overflow: hidden;
}

#sidebar.fa-circle-info, #mapLegend.fa-circle-info{
  color: var(--darker-grey-color);
}

#legendCollapseBtn {
  position: absolute;
  writing-mode: vertical-rl; /*so arrow points down */
  top: -1.2rem;
  right: 8px;
  background: var(--lighter-accent-color);
  color: white;
  border: 2px solid white;
  border-radius: 4px;
  font-size: 1.1rem;
  cursor: pointer;
  color: white;
  box-shadow: 0px -1px 8px rgba(0,0,0,0.2);
  transition: background-color 0.1s ease;
  /* line-height: 1; */
}

#legendCollapseBtn:hover {
  background-color: var(--darker-grey-color);
}

#mapLegend.collapsed, #mapLegendContent.collapsed {
  max-height: 3.7rem;
}
#mapLegend.collapsed{
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.legendTitle{
	font-size: 1.25rem;
	font-weight: bold;
	margin-bottom: 0.25rem;
}
.legendSubTitle{
	font-size: 1rem;
	font-weight: bold;
	margin-top: 0.5rem;
	margin-bottom: 0.25rem;
}

.legendLine {
    display: flex;
    align-items: center; /* Vertically center contents */
    gap: 0.4rem; /* space between fill and label */
    margin-bottom: 0.25rem;
}

.legendFillBox {
    flex-shrink: 0;
    width: 0.9rem;
    height: 0.9rem;
    border-radius: 2px;
    box-sizing: border-box;
}

.legendLineBox {
    display: inline-block;
    width: 0.9rem;
    height: 0.125rem;
    margin-right: 0.25rem;
    margin-top: 0.35rem;
    vertical-align: middle;
}

.legendIconStudyArea {
    display: inline-block;
    width: 1.5rem;
    height: 1rem;
    background-image: url('../img/StudyAreaBoundary.svg');
    background-repeat: no-repeat;
    box-sizing: border-box;
}

.legendIconCountryBoundary {
    display: inline-block;
    width: 1.4rem;
    height: 0.5rem;
    margin-right: 0.1rem;
    background-image: url('../img/CountryBoundary.svg');
    background-repeat: no-repeat;
    box-sizing: border-box;
}

.legendItemLabel {
    font-size: 0.95rem;
    margin: 0; /* remove bottom margin to reduce spacing */
    line-height: 1;
}

/* for the legend fill boxes */
.extant{
	background-color: #c4928bBF;  /* BF = 75% opacity to match rangesByTypeFill */
	border: 1.5px solid #896661;

}
.possiblyExtant{
	background-color: #eddedbBF;  /* BF = 75% opacity to match rangesByTypeFill */;
	border: 1.5px dashed #a68976;
}
.possiblyExtantResident{
	background-color: #eddedbBF;  /* BF = 75% opacity to match rangesByTypeFill */;
	border: 1.5px dashed #a68976;
}
.extantReintroduced{
	background-color: #c4928bBF;  /* BF = 75% opacity to match rangesByTypeFill */;
	border: 1.5px solid #a13dac;
}
.extantResident{
	background-color: #d5a69cBF;  /* BF = 75% opacity to match rangesByTypeFill */;
	border: 1.5px solid #a68976;
}
.extantIucn{
	background-color: #d5a69cBF;  /* BF = 75% opacity to match rangesByTypeFill */;
	border: 1.5px solid #a68976;
}
.iucnRange{
	background-color: #d5a69cBF;  /* BF = 75% opacity to match rangesByTypeFill */;
	border: 1.5px solid #a68976;
}
.identifiedRange{
	background-color: #d5a69cBF;  /* BF = 75% opacity to match rangesByTypeFill */;
	border: 1.5px solid #a68976;
}
.extinct{
	background-color: #bfc6d0BF;  /* BF = 75% opacity to match rangesByTypeFill */;
	border: 1.5px solid #dc6b77;
}
.possiblyExtinct{
	background-color: #bfc6d0BF;  /* BF = 75% opacity to match rangesByTypeFill */;
	border: 1.5px dashed #dc6b77;
}
.corridor{
	background-color: #9c7cadBF;  /* BF = 75% opacity to match rangesByTypeFill */;
  border: 1.5px solid #845f97;
}
.identifiedCorridorExpert{
	background-color: #9c7cadBF;  /* BF = 75% opacity to match rangesByTypeFill */;
  border: 1.5px solid #845f97;
}
.coreHabitat{
	/* background-color: #B6C0FEBF;  BF = 75% opacity to match rangesByTypeFill; */
  	background-color: #a1adf7bf;  /* BF = 75% opacity to match rangesByTypeFill */;
}

.proposedRoad{
  box-sizing: border-box;
	background-color: #fdb1fe;
	border: 1.5px solid #999B9E;
  margin-right: 0.325rem !important;
}

.builtRoad{
	background-color: #ffffff;
	border: 1.5px solid #949494;
  margin-right: 0.125rem !important;
}

.unpavedMajorRoad{
	background-color: #7e7e7e;
}
.fence{
	background-color: var(--fence-color);
  height: 0.2rem;
  margin-right: 0.325rem !important;
}
.pipeline{
	background-color: #875336;
  margin-right: 0.325rem !important;
}
.canal{
	background-color: #49bae2;
  margin-right: 0.325rem !important;
}

/* Shared rail contianers */
.line-container,
.planned-line-container {
  position: relative;
  width: 1rem;
  height: 0.9rem;
  display: inline-block;
  margin-right: 0.25rem;
}

/* Shared horizontal lines */
.horizontal-line,
.planned-horizontal-line {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 1px;
  transform: translateY(-50%);
  z-index: 0;
}

/* Shared vertical hatch lines */
.vertical-line,
.planned-vertical-line {
  position: absolute;
  top: 50%;
  width: 1px;
  height: 7px;
  transform: translateY(-50%);
  z-index: 1;
}

/* Planned color */
.planned-vertical-line,
.planned-horizontal-line,
.plannedRailway {
  background-color: var(--planned-rail-color);
}

/* Existing color */
.vertical-line,
.horizontal-line,
.builtRailway {
  background-color: var(--existing-rail-color);
}


.protectedArea{
	background-color: #0FC713;
}
.countryBoundary{
	background-color: transparent;
  border: dashed 2px #615251;
  margin-left:3px;
  padding-right:3px;
  margin-right:0px;
  
}
.conflictAreas{
	background-color: #ff658b;
  border: 1px solid red;
}

.floating-select {
  position: relative;
  font-family: sans-serif;
  margin: 0.5rem 0 0 0;
  transition: box-shadow 0.2s ease;
}

.floating-select select option {
  /* background-color: #e6f9e6; light green */
  color: black;
}

.floating-select select {
  appearance: none;
  /* border: none;
  border-bottom: 2px solid var(--accent-color); */
  border: 2px solid var(--accent-color);
  border-radius: 0 0 4px 4px; 
  color:black;
  /* background-color: #e6f9e6; light green */
  padding: 8px 24px 6px 0;
  margin-top: 0.8rem;
  font-size: 1rem;
  text-indent: 4px;
  width: 100%;
  cursor: pointer;
  transition: background-color 0.2s ease;
  box-shadow: 0px 0px 2px rgb(151, 151, 151) 
}

.floating-select select:hover {
  background-color: var(--light-beige-color)
}

.floating-select::after {
  content: '▼';
  font-size: 0.9rem;
  position: absolute;
  right: 8px;
  top: 60%;
  transform: translateY(-50%);
  pointer-events: none;
  transition: transform 0.2s ease;
}

.floating-select label {
  position: absolute;
  left: 0;
  font-size: 1.1rem;
  pointer-events: none;
  background-color: var(--bannerColor);
  color: white;
  padding: 4px 1rem 4px 4px;
  border-radius: 4px 4px 0 0;
}

.floating-select select:focus + label,
.floating-select select:not(:is(:focus)):valid + label {
  top: -0.5rem;
  font-size: 0.75rem;
  color: var(--light-beige-color);
  right:0px;
  

}

.floating-select select:focus-visible {
  outline: none;
}

/* toggle styling */
.toggle-wrapper, /* container for toggle + text */
.toggle-label {
  display: inline-flex;
  align-items: flex-end;  /* bottom-align the toggle and text */
  gap: .25em;
  cursor: pointer;
  font-family: sans-serif;
  font-size: 1rem;
  color: var(--darker-grey-color);
}

.toggle-label input {
  appearance: none;
  width: 1.5rem;
  height: 0.75rem;
  background: #ccc;
  border-radius: 999px;
  position: relative;
  transition: background 0.3s ease;
  outline: none;
  cursor: pointer;
  margin-bottom: 2px; /* nudges toggle a bit lower */
}

.toggle-label input::before {
  content: "";
  position: absolute;
  left: 1.5px;
  top: 1.5px;
  width: calc(0.75rem - 3px);
  height: calc(0.75rem - 3px);
  background: white;
  border-radius: 50%;
  transition: transform 0.3s ease;
}

.toggle-label input:checked {
  background: var(--accent-color);
}

.toggle-label input:checked::before {
  transform: translateX(0.75rem);
}

#conflictInfo, #linearInfo{
  font-size: 0.9rem
}

#legendSeparator>hr {
    height: 0px;
    width: 95%;
    border: none;
    border-top: 1px solid var(--inactive-accent-color);
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}

@media (max-width: 1024px) {
  #mapLegend {
    transform: scale(0.95);
    transform-origin: bottom right;
  }
  #legendCollapseBtn {
    transform: scale(0.95);
    transform-origin: top right;
  }
}

@media (max-width: 768px) {
  #mapLegend {
    transform: scale(0.8);
    transform-origin: bottom right;
    padding: 0.4rem;
  }

  #legendCollapseBtn {
    transform: scale(0.8);
    transform-origin: top right;
  }

  .legendFillBox,
  .legendLineBox,
  .legendIconStudyArea,
  .legendIconCountryBoundary,
  .legendLineBoxDouble {
    transform: scale(0.9);
    transform-origin: left center;
  }

  .legendTitle,
  .legendSubTitle,
  .legendItemLabel {
    line-height: 1.2;
  }
}

@media (max-width: 480px) {
  #mapLegend {
    transform: scale(0.65);
    transform-origin: bottom right;
    padding: 0.3rem;
  }


  #legendCollapseBtn {
    transform: scale(0.9);
    transform-origin: top right;
  }  

  .legendFillBox,
  .legendLineBox,
  .legendIconStudyArea,
  .legendIconCountryBoundary,
  .legendLineBoxDouble {
    transform: scale(0.75);
    transform-origin: left center;
  }

  .legendTitle,
  .legendSubTitle,
  .legendItemLabel {
    line-height: 1.1;
  }
}

