/* Custom Fonts */
@font-face {
  font-family: 'Gt America Mono Bold Trial';
  src: url('./fonts/GT-America-Mono-Bold-Trial.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Gt America Mono Light Trial';
  src: url('./fonts/GT-America-Mono-Light-Trial.otf') format('opentype');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Gt America Mono Regular Trial';
  src: url('./fonts/GT-America-Mono-Regular-Trial.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Gt America Mono Medium Trial';
  src: url('./fonts/GT-America-Mono-Medium-Trial.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* Root Variables */
:root {
  --white: white;
  --black: black;
}

/* Body and Base Styles */
body {
  font-family: 'Gt America Mono Regular Trial', sans-serif;
  font-size: 1vw;
  color: #000;
  background-color: #fff;
  margin: 0;
  padding: 0;
}

html {
  margin: 0;
  padding: 0;
}

/* Headings */
.heading {
  color: #000;
  text-transform: none;
  margin-top: 0;
  margin-bottom: 0;
  padding-left: 0;
  font-family: 'Gt America Mono Bold Trial', sans-serif;
  font-size: 3em;
  line-height: 1.26;
}

.heading.center {
  text-align: center;
  margin-bottom: 25px;
}

/* Text Styles */
.text-light {
  color: #000;
  text-align: left;
  margin-bottom: 10px;
  padding-top: 20px;
  font-family: 'Gt America Mono Light Trial', sans-serif;
  font-size: 1.21em;
  font-weight: 300;
  line-height: 1.26;
  display: block;
}

.text-medium {
  color: #000;
  font-family: 'Gt America Mono Regular Trial', sans-serif;
  font-size: 1.21em;
  font-weight: 400;
  line-height: 1.26;
}

.text-bold {
  color: #000;
  font-family: 'Gt America Mono Bold Trial', sans-serif;
  font-size: 1.7em;
  font-weight: 700;
  line-height: 1.17;
}

/* Buttons */
.button {
  text-align: center;
  background-color: #d62d26;
  border-radius: 25px;
  width: auto;
  padding: .5em 1.5em;
  font-family: 'Gt America Mono Bold Trial', sans-serif;
  font-size: 1.5em;
  font-weight: 700;
  line-height: 1.26;
  color: white;
  border: none;
  cursor: pointer;
}

/* App Layout - Desktop/Laptop */
.app-container {
  width: 100%;
  min-height: 100vh;
  position: relative;
  background-color: #fff;
}

.map-container {
  width: 100%;
  height: 70vh;
  min-height: 500px;
  position: relative;
  z-index: 1;
}

.world-map {
  height: 100% !important;
  width: 100% !important;
}

/* Map Legend Styling */
.plotly .legend {
  font-family: 'Gt America Mono Regular Trial', sans-serif !important;
  font-size: 11px !important;
  color: #000 !important;
  padding: 8px !important;
}

.plotly .legend .legendtitletext {
  font-family: 'Gt America Mono Bold Trial', sans-serif !important;
  font-size: 12px !important;
  color: #000 !important;
  font-weight: 700 !important;
  margin-bottom: 4px !important;
}

.plotly .legend .legendtext {
  font-family: 'Gt America Mono Regular Trial', sans-serif !important;
  font-size: 11px !important;
  /* test a font tightening */
  letter-spacing: -0.5px;
  color: #000 !important;
  font-weight: 400 !important;
}

.plotly .legend .legendtrace .legendsymbols {
  width: 15px !important;
  margin-right: 6px !important;
}

/* Side Panel - Desktop/Laptop */
.side-panel {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(255,255,255,0.95);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  border: 2px solid #ccc;
  width: 320px;
  max-height: calc(100vh - 40px);
  padding: 20px;
  z-index: 100;
  border-radius: 8px;
  font-family: 'Gt America Mono Regular Trial', sans-serif;
  overflow-y: auto;
}

/* Info Button - Responsive */
.info-button-container {
  position: fixed;
  top: 30px;
  left: 30px;
  z-index: 200;
}

.info-button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  border-radius: 50%;
  z-index: 110;
  width: 25px;
  height: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.info-icon {
  width: 25px;
  height: 25px;
}

/* Dropdown - Responsive */
.dropdown-container {
  margin-bottom: 12px;
  margin-top: 5px;
}

.native-dropdown {
  font-family: 'Gt America Mono Regular Trial', sans-serif;
  font-size: 14px;
  width: 100%;
}

/* Line Chart - Responsive */
.line-chart-container {
  margin-top: 10px;
  margin-bottom: 10px;
  max-height: 250px;
}

.line-chart-container.hidden {
  display: none;
}

.line-chart-container.visible {
  display: block;
}

/* Table - Responsive */
.table-container {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #eee;
  font-size: 11px;
  margin-bottom: 10px;
}

/* Reset Button - Responsive */
.reset-button-container {
  margin-top: 8px;
}

.reset-button-container.hidden {
  display: none;
}

.reset-button-container.visible {
  display: block;
}

.reset-button {
  font-size: 10px;
  padding: 6px 12px;
  width: 100%;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.visible {
  display: block !important;
}

/* Map Hover Tooltips */
.hover-content {
  font-family: 'Gt America Mono Regular Trial', sans-serif;
  background: white;
  border: 1px solid #cccccc;
  padding: 8px;
  border-radius: 4px;
}

.hover-ranking {
  font-size: 11px;
  color: #000;
  font-family: 'Gt America Mono Regular Trial', sans-serif;
}

.hover-score {
  font-size: 11px;
  color: #000;
  font-family: 'Gt America Mono Regular Trial', sans-serif;
}

.hover-divider {
  font-size: 11px;
  color: #000;
  font-family: 'Gt America Mono Regular Trial', sans-serif;
}

.hover-category {
  font-size: 12px;
  font-weight: 600;
  font-family: 'Gt America Mono Bold Trial', sans-serif;
  /* Color will be set dynamically via inline style */
}

.hover-country {
  font-size: 16px;
  font-weight: bold;
  font-family: 'Gt America Mono Bold Trial', sans-serif;
  /* Color will be set dynamically via inline style */
}

.hover-population {
  font-size: 11px;
  color: #000;
  font-family: 'Gt America Mono Light Trial', sans-serif;
}

.hover-spacer {
  font-size: 9px;
  color: transparent;
}

.line-chart {
  width: 100%;
  height: 220px;
}

/* Line Chart Plotly Styling */
.line-chart .plotly {
  font-family: 'Gt America Mono Regular Trial', sans-serif !important;
}

.line-chart .plotly .xtick text {
  font-family: 'Gt America Mono Regular Trial', sans-serif !important;
  font-size: 11px !important;
  color: #000 !important;
}

.line-chart .plotly .ytick text {
  font-family: 'Gt America Mono Regular Trial', sans-serif !important;
  font-size: 11px !important;
  color: #000 !important;
}

.line-chart .plotly .xtitle {
  font-family: 'Gt America Mono Medium Trial', sans-serif !important;
  font-size: 12px !important;
  color: #000 !important;
  font-weight: 500 !important;
}

.line-chart .plotly .ytitle {
  font-family: 'Gt America Mono Medium Trial', sans-serif !important;
  font-size: 12px !important;
  color: #000 !important;
  font-weight: 500 !important;
}

/* Line Chart Annotations (Score Labels) */
.line-chart .plotly .annotation,
.line-chart .plotly .annotation text,
.line-chart .plotly .annotation-text {
  font-family: 'Gt America Mono Bold Trial', sans-serif !important;
  font-size: 12px !important;
  font-weight: 700 !important;
}

/* More specific targeting for plotly annotations */
.line-chart g.annotation text {
  font-family: 'Gt America Mono Bold Trial', sans-serif !important;
  font-size: 12px !important;
  font-weight: 700 !important;
}

.line-chart text[data-unformatted] {
  font-family: 'Gt America Mono Bold Trial', sans-serif !important;
  font-size: 12px !important;
  font-weight: 700 !important;
}

/* Line Chart Background */
.line-chart .plotly .bg {
  fill: transparent !important;
}

.line-chart .plotly .plot-container {
  background: transparent !important;
}

/* Line Chart Grid Lines (hide them) */
.line-chart .plotly .xgrid,
.line-chart .plotly .ygrid {
  display: none !important;
}

/* Line Chart Axes Lines */
.line-chart .plotly .xaxis line,
.line-chart .plotly .yaxis line {
  stroke: #ccc !important;
  stroke-width: 1px !important;
}

/* Line Chart Hover */
.line-chart .plotly .hovertext {
  font-family: 'Gt America Mono Regular Trial', sans-serif !important;
  font-size: 11px !important;
}

.line-chart-annotation {
  font-family: 'Gt America Mono Bold Trial', sans-serif;
  font-size: 12px;
  font-weight: 700;
}

/* Table */
.table-container {
  max-height: 600px;
  overflow-y: auto;
  border: 1px solid #eee;
  font-size: 12px;
}

/* Table Styling - Target by ID instead of className */
#table {
  font-family: 'Gt America Mono Light Trial', sans-serif !important;
  font-size: 12px !important;
}

#table .dash-cell {
  font-family: 'Gt America Mono Light Trial', sans-serif !important;
  font-size: 12px !important;
}

#table .dash-header {
  font-family: 'Gt America Mono Regular Trial', sans-serif !important;
  font-size: 12px !important;
}

/* Target the table container in the side panel */
.table-container .dash-table-container {
  font-family: 'Gt America Mono Light Trial', sans-serif !important;
  font-size: 12px !important;
}

.table-container .dash-table-container .dash-spreadsheet-container .dash-spreadsheet-inner table {
  font-family: 'Gt America Mono Light Trial', sans-serif !important;
  font-size: 12px !important;
}

.table-container .dash-table-container .dash-spreadsheet-container .dash-spreadsheet-inner .dash-cell {
  font-family: 'Gt America Mono Light Trial', sans-serif !important;
  font-size: 12px !important;
}

.table-container .dash-table-container .dash-spreadsheet-container .dash-spreadsheet-inner .dash-header {
  font-family: 'Gt America Mono Regular Trial', sans-serif !important;
  font-size: 12px !important;
  font-weight: 600 !important;
}

/* Help Overlay */
.help-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.3);
  z-index: 1000;
}

.help-overlay.hidden {
  display: none;
}

.help-overlay.visible {
  display: block;
}

/* Help Boxes - Desktop */
.help-box {
  position: absolute;
  background: rgba(255, 255, 255, 0.9);
  padding: 8px 12px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  white-space: nowrap;
  z-index: 1001;
  border: 1px solid rgba(0,0,0,0.1);
  max-width: 200px;
}

.help-box-map {
  top: 30%;
  left: 30%;
  transform: translateX(-50%);
}

.help-box-legend {
  position: fixed;
  top: 480px;
  left: 150px;
  transform: translateX(-50%);
}

.help-box-dropdown {
  top: 60px;
  right: 80px;
}

.help-box-table {
  top: 50%;
  right: 50px;
  transform: translateY(-50%);
}

.help-icon {
  width: 30px;
  height: 30px;
  margin-right: 8px;
}

.help-text {
  font-size: 12px;
  color: #333;
}

/* Override text-medium color inside help overlay */
.help-overlay .text-medium {
  color: #000 !important;
  font-family: 'Gt America Mono Regular Trial', sans-serif !important;
  font-size: 12px !important;
  font-weight: 400 !important;
  line-height: 1.2 !important;
}

/* Close Button - Desktop */
.close-button {
  position: fixed;
  top: 30px;
  left: 30px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0,0,0,0.2);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 18px;
  cursor: pointer;
  color: #666;
  z-index: 1002;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* Color Palette from Article 19 */
.color-primary { color: #d62d26; }
.color-secondary { color: #b90748; }
.color-tertiary { color: #691b32; }

.bg-primary { background-color: #d62d26; }
.bg-secondary { background-color: #b90748; }
.bg-light { background-color: #f3f7f2; }

/* ===== MOBILE LAYOUT (768px and below) ===== */
@media screen and (max-width: 768px) {
  /* Reset any global margins/padding */
  body, html {
    margin: 0 !important;
    padding: 0 !important;
    overflow-x: hidden !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  
  /* App Container */
  .app-container {
    flex-direction: column;
    overflow-x: hidden; /* Prevent horizontal scroll */
    width: 100%;
    max-width: 100vw;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  
  /* Map - Increased vertical size on Mobile */
  .map-container {
    width: 100%;
    max-width: 100vw;
    height: 30vh;  /* Increased from 30vh for more vertical space */
    min-height: 250px;  /* Increased from 250px */
    margin: 0 auto 2px auto;  /* Reduced margin */
    overflow: hidden;
    box-sizing: border-box;
    position: relative;
  }
  
  .world-map {
    height: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    position: relative !important;
  }
  
  /* Plotly containers */
  .map-container #world-map {
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  /* Plotly plot boundaries */
  .map-container .js-plotly-plot,
  .map-container .plotly,
  .map-container svg {
    transform: translateX(0%) !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  /* Force Plotly figure to fill container completely */
  .map-container .js-plotly-plot .plotly .main-svg {
    width: 100% !important;
    height: 100% !important;
  }
  
  /* Remove any default spacing from plot area */
  .map-container .js-plotly-plot .plotly .subplot {
    margin: 0 !important;
    padding: 0 !important;
  }
  
  /* Info Button - Hidden on mobile */
  .info-button-container {
    display: none !important;
  }
  
  /* Reset Button - Hidden on mobile */
  .reset-button-container {
    display: none !important;
  }

  /* Components */
  .table-container {
    display: none !important; /* Hide table on mobile */
  }
  
  .line-chart-container {
    max-height: 200px;
  }
  
  /* Mobile Dropdown - Position outside side panel */
  .dropdown-container {
    position: fixed !important;
    top: calc(30vh + 10px) !important;  /* Position just below the map */
    left: 10px !important;
    right: 10px !important;
    width: calc(100vw - 20px) !important;
    margin: 0 !important;
    z-index: 2000 !important;
    background: transparent !important;
    border-radius: 0 !important;
    padding: 10px !important;
    box-shadow: none !important;
    border: none !important;
  }
  
  .native-dropdown {
    font-size: 16px !important;  /* Larger font for better mobile readability */
    padding: 12px !important;    /* More padding for easier touch */
    min-height: 44px !important; /* Standard mobile touch target */
    width: 100% !important;
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
  }
  
  /* Adjust side panel to account for fixed dropdown */
  .side-panel {
    position: relative;
    top: 80px !important;  /* Push down more to make room for dropdown */
    right: 0;
    left: 0;
    width: calc(100% - 20px);
    max-width: none;
    margin: 10px;
    padding: 15px;
    border-radius: 8px;
    border: none !important;  /* Remove any borders */
    box-shadow: none !important;  /* Remove shadows */
  }
  
  /* Map Legend - Mobile horizontal layout */
  .plotly .legend {
    font-family: 'Gt America Mono Regular Trial', sans-serif !important;
    font-size: 8px !important;
    color: #000 !important;
    padding: 6px !important;
    position: relative !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    margin: 2px auto !important;  /* Reduced from 5px to 2px */
    background: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    width: auto !important;
    max-width: calc(100vw - 20px) !important;
    
    /* Simple horizontal layout - let items flow naturally */
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 4px !important;
    overflow-x: auto !important;
  }
  
  /* Flexible legend items for wrapping layout */
  .plotly .legend .legendtrace {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 2px 4px !important;
    font-size: 10px !important;  /* Increased from 9px to 10px */
    flex-shrink: 0 !important;
    white-space: nowrap !important;
  }
  
  .plotly .legend .legendtext {
    font-size: 10px !important;  /* Increased from 9px to 10px */
    white-space: nowrap !important;
  }
  
  .plotly .legend .legendtitletext {
    font-family: 'Gt America Mono Bold Trial', sans-serif !important;
    font-size: 11px !important;  /* Increased from 10px to 11px */
    color: #000 !important;
    font-weight: 700 !important;
    margin-bottom: 2px !important;
    text-align: center !important;
  }
  
  .plotly .legend .legendtext {
    font-family: 'Gt America Mono Regular Trial', sans-serif !important;
    font-size: 10px !important;  /* Increased from 9px to 10px */
    letter-spacing: -0.2px !important;
    color: #000 !important;
    font-weight: 400 !important;
  }
  
  /* Typography */
  body {
    font-size: 14px;
  }
  
  .heading {
    font-size: 24px;
  }
  
  .text-light,
  .text-medium {
    font-size: 13px;
  }
  
  .text-bold {
    font-size: 18px;
  }
  
  .native-dropdown {
    font-size: 13px;
  }
  
  .button {
    font-size: 11px;
    padding: 8px 12px;
  }
  
  .reset-button {
    font-size: 10px;
    padding: 6px 10px;
  }
  
  /* Help Overlay */
  .help-box {
    padding: 6px 10px;
    font-size: 11px;
    max-width: 180px;
  }
  
  .help-box-map {
    top: 25%;
    left: 50%;
    transform: translateX(-50%);
  }
  
  .help-box-legend {
    bottom: 15%;
    left: 10%;
  }
  
  .help-box-dropdown {
    top: 15px;
    right: 15px;
  }
  
  .help-box-table {
    top: 60%;
    right: 15px;
  }
  
  .close-button {
    top: 15px;
    right: 15px;
    width: 25px;
    height: 25px;
    font-size: 16px;
  }
  
  .help-icon {
    width: 25px;
    height: 25px;
    margin-right: 6px;
  }
  
  .help-text {
    font-size: 10px;
  }
}