/* removed @import of Google Fonts; fonts are loaded in index.html */

body {
  margin: 0;
  background: #f2f2f2;
}

* {
  font-family: monospace;
  box-sizing: border-box;
  letter-spacing: -0.25px;
}

.container{
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
  padding: 20px;
}

.landing .container{
  min-height: 100vh;
}

.landing #map,
.landing #searchResults,
.landing #mapContainer
{
  display: none;
}

.landing #searchContainer {
    position: absolute; /* Changed from fixed */
    top: 50%;
    left: 20px; /* Match container padding */
    right: 20px; /* Match container padding */
    transform: translateY(-100%); /* Only vertical transform needed */
    max-width: 800px;
    /* The padding-left/right hacks are no longer needed */
}

.landing #topicsContainer {
    position: absolute;
    top: 50vh; /* Start at the horizontal midpoint */
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 800px; /* To align with search bar */
    justify-content: center;
    padding-top: 20px; /* Add some space from the search bar */
}

.landing #tagline {
  display: block;
  position: absolute;
  top: 25vh; /* Center vertically in the top half */
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  font-size: 25px;
  font-weight: bold;
  width: 100%; /* Ensure it centers across the page */
  letter-spacing: -0.5px;
}

#tagline {
  display: none;
  position: absolute; /* Changed from fixed */
  top: calc(50% - 100px);
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  font-size: 22px;
  width: 100%; /* Ensure it centers across the page */
}

#mapContainer {
  padding-top: 20px;
  padding-left: 60px;
  padding-right: 60px;
  overflow: hidden;
  height: 48vw;
  max-height: 600px;
}

#map {
  height: 100%;
  margin: 0 auto;
  position: relative; /* Keep for positioning of tooltips */
  padding-bottom: 0px !important;
}

#legend {
    display: flex;
    flex-wrap: wrap;
    column-gap: 8px;
    row-gap: 6px;
    padding-top: 10px;
}

#legend .legend-item {
    display: flex;
    align-items: center;
    margin-right: 6px;
}

#legend .legend-swatch {
    width: 28px;
    height: 20px;
    margin-right: 8px;
    border: 1px solid #393939;
    flex-shrink: 0;
}

#legend .legend-swatch.transparent {
    border-style: dashed;
}

#legend .legend-label {
    font-size: 14px;
}

/* Spectrum gradient legend styles */
#legend.spectrum-legend {
    display: block;
}

#legend .spectrum-gradient-bar {
    position: relative;
    height: 20px;
    width: 100%;
    border-radius: 4px;
    border: 2px solid black;
    margin-bottom: 8px;
    margin-top: 8px;
}

#legend .spectrum-marker {
    position: absolute;
    top: 0;
    width: 2px;
    height: 100%;
    background-color: #000;
    transform: translateX(-1px);
}

#legend .spectrum-labels-container {
    display: flex;
    justify-content: space-between;
    width: 100%;
    gap: 4px;
}

#legend .spectrum-label {
    flex: 1;
    font-size: 13px;
    line-height: 1.2;
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-width: 0; /* Allow flex items to shrink below content size */
}

#searchResults {
    position: relative;
}

/* Expand/collapse all controls */
.expand-collapse-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    padding-top: 5px;
}

.expand-collapse-btn {
    padding: 4px 10px;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-left: 10px;
    width: 80px;
    text-align: center;
}

.expand-collapse-btn:hover {
    background-color: #e0e0e0;
}

.expand-collapse-btn:active {
    background-color: #d0d0d0;
}

/* Utility class for hidden scrollbars */
.hide-scrollbar {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.hide-scrollbar::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome, Safari, Opera */
}

/* Country article list styles */
#searchResults .country-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 5px;
    white-space: nowrap;
}

#searchResults .country-summary {
    font-size: 15px;
    color: black;
    font-style: italic;
    line-height: 1.5;
    margin-bottom: 5px;
}

#searchResults .country-mini-spectrum {
    position: relative;
    width: 68px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid #393939;
    flex-shrink: 0;
}

#searchResults .country-spectrum-marker {
    position: absolute;
    top: 2px;
    left: 0;
    width: 2px;
    height: calc(100% - 4px);
    background-color: #000;
    pointer-events: none;
    border-radius: 2px;
}

#searchResults ul {
  font-size: 15px;
  padding-inline-start: 0;
  margin-block-start: 22px;
  margin-block-end: 24px;
  /* margin-block-start: 12px;
  margin-block-end: 12px; */
  transition: background-color .5s ease-out; /* Smooth transition for background color */
}

#searchResults li {
  font-weight: normal;
  padding-bottom: 5px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow-x: hidden;
  list-style: none;
}

#searchResults li .article-color-box {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 6px;
    vertical-align: middle;
    flex-shrink: 0;
}

#searchResults li .article-bullet-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #000;
    margin-right: 4px;
    margin-left: 1px;
    vertical-align: middle;
    flex-shrink: 0;
    position: relative;
}

#searchResults li:last-child {
  padding-bottom: 0;
}

#searchResults .iso {
  font-size: 16px;
  display: inline-block;
  font-weight: bold;
}

#searchResults .date {
  display: inline-block;
  padding-right: 8px;
}

#searchResults .toggle {
  display: inline-block;
  cursor: pointer;
}

#searchResults .domain {
  /* margin-left: 6px; */
  font-size: 0.9em;
}

#searchResults .collapse {
  display: none;
}

#searchResults a {
  text-decoration: none;
}

.section-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-align: center;
    margin: 30px 0;
    visibility: hidden; /* Hide by default */
    font-size: 22px;
    /* font-weight: bold; */
}

.section-separator.visible {
    visibility: visible;
}

.section-separator::before,
.section-separator::after {
    content: '';
    flex: 1;
    border-bottom: 1px dashed black;
}

.section-separator:not(:empty)::before {
    margin-right: .5em;
}

.section-separator:not(:empty)::after {
    margin-left: .5em;
}

#searchContainer {
  height: 50px;
  position: relative;
  margin: 0 auto;
}

#searchContainer .searchQuery {
  height: 100%;
  font-size: 16px;
  padding: 10px;
  border: 3px solid black;
  border-right: none;
  border-radius: 5px 0 0 5px;
  outline: none;
  color: #3b3b3b;
  width: calc(100% - 80px);
  float: left;
}

#topicsContainer {
  padding-top: 20px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

#topicsContainer span {
  font-size: 16px;
}

.topic-button {
  color: black;
  padding: 4px 10px;
  border: 1px solid #999;
  border-radius: 15px;
  background-color: #fff;
  cursor: pointer;
  font-size: 13px;
  transition: background-color 0.2s, color 0.2s;
  white-space: nowrap; /* Prevent text inside from wrapping */
  height: 26px;
  vertical-align: middle;
}

.topic-button:hover {
  background-color: #3f3f3f;
  color: white;
  border-color: #1f1f1f;
}

#searchContainer .searchQuery:focus{
  color: black;
}

.hoverinfo {
    padding: 10px;
    border-radius: 3px;
    background-color: #fff;
    color: #000;
    border: 1px solid #ccc;
}

.hoverinfo ul {
    margin-top: 5px;
    margin-bottom: 0;
    padding-left: 20px;
    list-style-type: disc;
}

input[type=text] {
  padding: 4px;
}

.loader {
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid #fff;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  animation: spin 1s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

#searchResults .highlight {
  background-color: #abbdcf; /* The color it will flash to */
}

#helpIcon {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: black;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  z-index: 1000;
  opacity: .5;
}

#helpIcon:hover {
  opacity: 1;
}

#modalOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: none; /* Hidden by default */
  /* padding: 20px; */
  z-index: 2000;
  font-size: 16px;
}

#modalOverlay.visible {
  display: block; /* Show the modal */
}

#modalContent {
  background-color: white;
  padding: 40px;
  border-radius: 5px;
  max-width: 800px;
  margin: 0 auto;
  position: relative;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  padding: 20px;
  height: 100%;
  overflow-y: auto;
}

#modalClose {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  color: black;
}

#modalClose:hover {
  color: black;
}

.searchButton {
  height: 100%;
  width: 80px;
  padding: 10px 15px;
  border: 3px solid black;
  background: black;
  color: white;
  cursor: pointer;
  border-radius: 0 5px 5px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  float: right;
}

.searchButton svg {
    width: 20px;
    height: 20px;
    stroke-width: 3;
}

.searchQuery {
    padding: 10px;
    border: 1px solid #ccc;
}

.show-more-button {
    width: 100%;
    padding: 10px;
    margin: 20px 0;
    font-size: 16px;
    font-weight: bold;
    color: #333;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.2s;
}

.show-more-button:hover {
    background-color: #e0e0e0;
}

/* Mobile */
@media (max-width: 768px) {
  #mapContainer {
    padding-left: 0px;
    padding-right: 0px;
    height: 60vw;
  }

  #legend {
    grid-template-columns: 1fr;
    justify-content: flex-start; /* Align items to the start, not spaced out */
  }

  #legend .spectrum-label {
    font-size: 11px;
  }

  #searchResults .country-summary {
    font-size: 13px;
    text-align: justify;
  }

  #searchResults ul {
    overflow-x: scroll;
    padding-bottom: 10px;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
  }

  #searchResults ul::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome, Safari, Opera */
  }

  #searchResults li {
    text-overflow: inherit;
    overflow-x: visible;
  }

  /* Make topics scrollable on one line on mobile after search */
  body:not(.landing) #topicsContainer {
    display: grid;
    grid-template-rows: repeat(2, 1fr); /* Create two equal rows */
    grid-auto-flow: column; /* Fill columns first, then add new columns */
    grid-auto-columns: max-content; /* Make columns as wide as their content */
    column-gap: 8px; /* Space between columns of pills */
    overflow-x: auto; /* Enable horizontal scrolling */
  }

  .legend-item {
      flex-basis: 100%; /* Each item takes the full width on mobile */
  }

  .section-separator {
      font-size: 18px;
  }
}
