:root {
  --blue: #2196F3;
  --green: #4CAF50;
  --pink: #FF4081;
  --background: #f8f9fa;
  --surface: #ffffff;
  --text: #212121;
  --text-secondary: #757575;
  --border: #e0e0e0;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

* {
  box-sizing: border-box;
  font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

html {
  background-color: var(--background);
}

body {
  background-color: var(--surface);
  min-height: 100vh;
}

:root {
  font-size: 16px;
}

h3 {
  font-size: 24px;
}

body {
  color: #333;
  padding: 0;
  margin: 0 auto;
  height: 100%;
}

section.map svg {
  width: 100%;
  height: 100%;
  transform-origin: center;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  image-rendering: optimizeQuality;
  backface-visibility: hidden;
  transform-style: preserve-3d;
  -webkit-font-smoothing: subpixel-antialiased;
}

body {
  display: flex;
  flex-direction: row;
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
}

@media only screen and (max-width: 600px) {
  body {
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
  }

  .map {
    height: 40vh;
    margin-left: 0;
    order: 1;
    width: 100%;
  }

  .countrylist {
    height: 60vh;
    width: 100% !important; /* Force full width on mobile */
    max-height: 60vh;
    order: 2;
    border-top: 1px solid var(--border);
    border-right: none;
  }
}









.countrylist {
  background: #f0f0f0;
  box-shadow: var(--shadow-sm);
  width: 320px; /* Default width for desktop */
  height: 100vh;
  overflow: auto;
  --gap: 12px;
  cursor: pointer;
  padding: 0;
  margin: 0;
  /* support smooth scrolling on safari */
  -webkit-overflow-scrolling: touch;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
  scrollbar-width: thin;
  scrollbar-color: var(--text-secondary) transparent;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.countrylist::-webkit-scrollbar {
  width: 6px;
}

.countrylist::-webkit-scrollbar-track {
  background: transparent;
}

.countrylist::-webkit-scrollbar-thumb {
  background-color: var(--text-secondary);
  border-radius: 3px;
}

.countrylist .region {
  position: relative;
  margin: 0;
  width: 100%;
  background-color: var(--surface);
  padding: 0;
}

.countrylist .region .region-title {
  position: sticky;
  /* Top position will be set by JavaScript */
  padding: 10px 20px;
  background-color: #f0f0f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 500;
  color: var(--text);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.2s ease;
  z-index: 15;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin: 0;
  height: auto;
  cursor: default;
  width: 100%;
}

.countrylist .region .region-title:hover {
  box-shadow: var(--shadow-sm);
}

.countrylist .region .region-title .region-stats {
  display: flex;
  gap: 5px;
  margin-top: 5px;
}

.countrylist .region .region-title .region-stats .stat {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: default;
}

.countrylist .region .region-title .region-stats .stat.him {
  color: var(--blue);
}

.countrylist .region .region-title .region-stats .stat.her {
  color: var(--pink);
}

.countrylist .region .region-title .region-stats .stat.both {
  color: var(--green);
}



/* Stats container styles */
.stats-container {
  padding: 20px;
  background-color: #f0f0f0;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 20;
  box-sizing: border-box;
}



.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 0;
}

.stats-item {
  font-size: 18px;
  font-weight: 500;
  padding: 10px;
  flex: 1;
  text-align: center;
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: default;
}

@media only screen and (max-width: 600px) {
  .stats-container {
    padding: 10px;
  }
  
  .stats-row {
    gap: 5px;
    width: 100%;
  }
  
  .stats-item {
    font-size: 14px;
    padding: 6px 4px;
    white-space: nowrap;
    margin: 0;
  }
  
  .stats-item:last-child {
    margin-right: 0;
  }
}

.stats-item.him {
  color: var(--blue);
}

.stats-item.her {
  color: var(--pink);
}

.stats-item.both {
  color: var(--green);
}
.countrylist .region .region-title h3 {
  margin: 0;
  padding: 0;
  transition: color 0.2s ease;
  line-height: 1.3;
  max-width: 70%;
}

.countrylist .region .region-title.showing-country {
  background-color: var(--surface);
}

.countrylist .region .region-title.showing-country h3 {
  color: #9C27B0; /* Purple color for region title when country is selected */
  font-weight: 500;
}

.countrylist .region .entry {
  margin: 0;
  padding: 6px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease-out;
  color: var(--text);
  background: var(--surface);
  position: relative;
}

.countrylist .region .entry:first-of-type {
  margin-top: 0;
  padding-top: 0;
}

.countrylist .region .entry:hover {
  background: #f7f7f7;
  z-index: 1;
}

.countrylist .region .entry.revealing {
  background: #f7f7f7;
  font-weight: 500;
  color: #9C27B0; /* Purple color for selected country */
  z-index: 2;
  margin: 0;
  box-shadow: inset 4px 0 0 #9C27B0; /* Purple left border */
}

.countrylist .region .entry.hovered {
  color: #9C27B0; /* Full opacity purple */
}

.countrylist .region .entry.visited::after, .countrylist .region .entry.visited-by-him::after, .countrylist .region .entry.visited-by-her::after {
  content: '✔';
  font-size: 12px;
  color: white;
  padding: 1px 3px;
  border-radius: 0;
}

.countrylist .region .entry.visited::after {
  background-color: var(--green);
}

.countrylist .region .entry.visited-by-him::after {
  background-color: var(--blue);
}

.countrylist .region .entry.visited-by-her::after {
  background-color: var(--pink);
}



/* Animate the selected country transition */
.countrylist .region .entry {
  transition: all 0.2s ease-out;
}

.map {
  height: 100vh;
  flex-grow: 1;
  overflow: hidden;
  position: relative;
}

.map svg {
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}

.map svg .land {
  fill: #BBBBBB;
  fill-opacity: 0.7;
  cursor: pointer;
  transition: all 0.3s ease;
}

.map svg .land:hover {
  fill-opacity: 0.9;
}

.map svg .land.hovered {
  fill-opacity: 0.5;
}

.map svg .revealing {
  fill-opacity: 1 !important;
}

.map svg .visited {
  fill: var(--green);
  fill-opacity: 0.7;
}

.visited {
  color: var(--green);
}

.map svg .visited-by-her {
  fill: var(--pink);
  fill-opacity: 0.7
}

.visited-by-her {
  color: var(--pink);
}

.map svg .visited-by-him {
  fill: var(--blue);
  fill-opacity: 0.7;
}

.visited-by-him {
  color: var(--blue);
}

footer {
  grid-area: footer;
}

.country-tooltip {
  position: absolute;
  background-color: white;
  color: black;
  padding: 8px 15px;
  border-radius: 18px;
  font-size: 14px;
  font-weight: bold;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 3px 3px 5px rgba(0,0,0,0.3);
  margin-left: 18px; /* Closer to cursor (50% of original 35px) */
  margin-top: 0; /* No vertical offset */
  border: 2px solid black;
  min-width: 120px; /* Minimum width to prevent size changes */
  text-align: center;
  font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  white-space: normal; /* Allow text wrapping for indicators */
  transition: left 0.01s linear, top 0.01s linear; /* Super fast position updates */
  transform: translateY(-50%); /* Center vertically at cursor position */
}

/* Tooltip indicator styling */
.tooltip-indicator {
  font-size: 12px;
  font-weight: normal;
  display: inline-block;
  margin-top: 4px;
}

/* Comic-style speech bubble with stem/tail */
.country-tooltip:before {
  content: '';
  position: absolute;
  width: 12px; /* Shorter tail stem (50% of original) */
  height: 2px; /* Same as border width */
  background-color: black;
  left: -12px;
  top: calc(50% - 15px); /* Adjust to match cursor position */
  margin-top: 0px;
  z-index: 0;
}

/* Arrow point */
.country-tooltip:after {
  content: '';
  position: absolute;
  left: -17px; /* Closer to tooltip (50% of original distance) */
  top: calc(50% - 15px); /* Adjust to match cursor position */
  margin-top: -8px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 10px solid black;
  z-index: 1;
}

/* Tooltip styles from index.html */
#tooltip {
  position: fixed;
  display: none;
  background-color: var(--surface);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  pointer-events: none;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
  margin-left: 35px;
  min-width: 140px;
  text-align: center;
  white-space: normal;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  opacity: 0;
  transform: translateY(4px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

#tooltip::before {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background-color: var(--surface);
  left: -4px;
  top: 50%;
  margin-top: -4px;
  transform: rotate(45deg);
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.tooltip-indicator {
  font-size: 12px;
  font-weight: normal;
  display: inline-block;
  margin-top: 4px;
}

.tooltip-indicator.visited {
  color: var(--green);
}

.tooltip-indicator.visited-by-him {
  color: var(--blue);
}

.tooltip-indicator.visited-by-her {
  color: var(--pink);
}

/* Map attribution */
.map-attribution {
  position: fixed;
  right: 0;
  bottom: 0;
  padding: 2px;
  font-size: 8px;
}
