@import url('https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap');

:root {
  --color1: #3076CF;
  --color2: #a9aabc;
  --color3: #2c3e50;
  --color4: #c3ceff;
  --color5: #953d47;
  --color6: #a786ac;
  --color7: #edeff5;
  --icon-color: #333;
  --sidebar-width: clamp(220px, 92vw, 540px); 
  --sidebar-left-col-width: 44px;
  --toggle-btn-width: 24px;
  --widget-width-scale: 0.93;  /* widget width = sidebar-width * widget-width-scale; differs by screen size  */
}

@media (max-width: 890px) {
  :root {
    --widget-width-scale: 0.98;
  }
} 

html, body {
  font-family: Lato, 'Helvetica Neue', Helvetica, Arial, 'Liberation Sans', sans-serif;
  font-size: 10pt;
  color: var(--color3);
  position: relative;
  overflow: hidden;
  height: 100vh;
  margin: 0;
  padding: 0;
}

.title {
  padding: 10px 0px 10px calc(-30px + var(--sidebar-left-col-width));
  font-size: 14pt;
  font-weight: 600;
  color: var(--color3);
  line-height: 1.4;
  border-left: solid var(--sidebar-left-col-width) var(--color2);
  border-bottom: solid 1px var(--color2);
}

.title-subtitle {
  font-size: 10pt;
  font-style: italic;
  font-weight: normal;
}

/* Map */
#map-wrap {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 1;
} 

.leaflet-container .leaflet-interactive:focus {
  outline: none;
}

@media (hover: none) and (pointer: coarse) {
  .leaflet-tooltip {
    display: none; /* hide map marker labels */
  }
}

/* Sidebar container */
.sidebar-wrap { /* state0: open */
  position: absolute;
  top: 0; 
  bottom: 0; 
  left: 0;
  width: var(--sidebar-width);
  overflow: visible;
  z-index: 1001;
  transform: translateX(0);
  transition: transform 500ms ease;
  will-change: transform;
}
.sidebar-wrap.state1 { /* state1: closed */
  transform: translateX(calc(-1 * var(--sidebar-width)));
}

/* Sidebar slides up-down on small screens */
@media (max-width: 890px) {
  :root {
    --sidebar-peek: 120px;
    --sidebar-max-height: 70vh;
  }
  @supports (height: 100svh) { :root {
      --sidebar-max-height: 70svh;
  }}
  @supports (height: 100dvh) { :root {
      --sidebar-max-height: 70dvh;
  }}
  .sidebar-wrap { /* state0: closed */
    position: fixed;
    inset: auto  0 0 0;
    width: 100vw;
    height: var(--sidebar-max-height);
    overflow-x: visible;
    transform: translateY(calc(100% - var(--sidebar-peek)));
  }
  .sidebar-wrap.state1 { /* state1: open */
    transform: translateY(0px);
  }
}

/* Inner sidebar base */
.sidebar {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 100%; 
  background-color: #f9f9f9; 
  box-shadow: 2px 0 10px rgba(0,0,0,0.15);
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
}

/* Sidebar, vertical centerning at at larger screens */
@media (min-height: 890px) {
  .sidebar {
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: auto;
  }
}

/* Sidebar toggle button */
.toggle-btn {
  position: absolute;
  display: flex;
  background: white;
  border: 1px solid #ccc;
  border-radius: 0 6px 6px 0;
  padding: 0;
  font-size: 20px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1002;
}

/* toggle-btn large screens */
@media (min-width: 891px) {
 .toggle-btn { 
    top: 15%;
    left: 100%;
    width: var(--toggle-btn-width);
    height: 80px;
    transform: translateY(-50%);
 }
  /* state0: open, state1: closed */
  .toggle-btn.state0::after {
    content: "«";
  }
  .toggle-btn.state1::after {
    content: "»";
  }
}

/* toggle-btn small screens */
@media (max-width: 890px) {
  .toggle-btn {
    position: absolute;
    top: calc(0px - var(--toggle-btn-width));
    left: 50%;
    height: var(--toggle-btn-width);
    width: 80px;
    transform: translateX(-50%);
    border-radius: 6px 6px 0 0;
    font-size: 12pt;
    color: var(--color3);
  }
  /* state0: closed, state1: open */
  .toggle-btn.state0::after {
    content: "▲";
  }
  .toggle-btn.state1::after {
    content: "▼";
  }
}

.widget-container {
  width: 100vh;
  border-bottom: 1px solid var(--color2);
}

/* Icons + plot */
.plot-wrap {
  display: grid;
  grid-template-columns: var(--sidebar-left-col-width) 1fr; 
  width: calc(var(--sidebar-width) * var(--widget-width-scale));
  column-gap: 6px;
  align-items: stretch;
  padding-top: 0px;
}

.plot-wrap-recenter {
  grid-template-columns: calc(var(--sidebar-left-col-width) - 7px) 1fr; 
  padding: 0px 0 0 0px;
}

.cell-colored {
  background-color: var(--color2);
}

.city-title {
  display: inline;
  font-size: 16px;
  color: var(--color3); 
  line-height: 1.2;
  padding: 6px 0 0px 0;
}

.city-title-start {
  font-weight: 600;
}

.icon-column {
  display: grid;
  grid-auto-rows: 1fr; 
}

.icon-row {
  display: flex;
  position: relative;
  align-items: center;
  justify-content: right;
  background: none;
  border: none;
  padding: 0 5px 0 0;
  cursor: pointer;
}

.icon-row:focus {
  outline: none;
}

.icon-row .tooltip-text {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  top: -1.5em;
  left: 110%;
  background-color: var(--color3); 
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  transition: opacity 0.2s;
  z-index: 1014;
}

.icon-row:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

@media (max-width: 890px) {
  .icon-row .tooltip-text {
    white-space: normal;
    overflow-wrap: break-word;
    hyphens: auto;
    min-width: 200px;
    max-width: calc(var(--sidebar-width) * var(--widget-width-scale)); 
    top: auto;                             
  }
}

/* Indicator info panel */
.indicator-info-panel {
  display: grid;
  grid-template-columns: var(--sidebar-left-col-width) 1fr; 
  column-gap: 5px;
  align-items: start;
  width: var(--sidebar-width);
  padding: 0 0 10px 0px;
}

.iip-title {
  color: var(--color3);
  padding: 10px 0 2.5px 0px;
  line-height: 1.2;
  font-size: 14px;
}
@media (max-width: 890px ) {
  .iip-title {
    min-height: 2lh; 
  }
}

.iip-title-start {
  font-weight: 600;
}

.iip-info-text {
  font-size: 9pt;
  padding: 3px 0 3px 0;
}

.iip-btn-col {
  display: grid;
  grid-auto-rows: 1fr; 
  background-color: var(--color7);
  border-radius: 8px; 
  padding: 5px 0 5px 0;
  margin-top: 40px;
}

.iip-btn-row {
  display: flex;
  position: relative;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 4px;
  padding: 1px 0; 
  cursor: pointer;
  color: var(--icon-color);
}

.iip-btn-row:hover {
  background-color: var(--color2);
}

.iip-btn-row.clicked {
  background-color: var(--color2);
}

.iip-btn-row:focus {
  outline: none;
}
/* Layout of ranked tables */
.rank-table-outer {
  display: grid;
  grid-template-columns: 1fr; 
  width: calc(var(--sidebar-width) * var(--widget-width-scale) - var(--sidebar-left-col-width)); 
  align-items: stretch;
  padding-left: clamp(1px, 0.83vw, 10px);
}

.rank-table {
  padding: 1px;
  font-size: 14px; /* same as iip-title */
}

.rank-table, .rank-table * {
  box-sizing: border-box;
  font-family: inherit;
}

.rank-table-row-base {
  display: grid;
  grid-template-columns:
    minmax(3ch, 1fr)
    minmax(0, 8fr)
    minmax(0, 4fr);
  width: 100%;
  min-width: 0;
  text-align: left;
  line-height: 16px;
  background: none;
  border: none;
  border-radius: 0px;
  padding: 1.5px 0;   
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  font: inherit;
}

.rank-table-row:hover {
  background-color: var(--color2);
  border-radius: 4px;
}

.rank-table-row:focus {
  outline: none;
}

.rank-table-row-even {
  background-color: var(--color7);
}

.rank-table-row.rank-table-row-last {
  border-bottom: solid 1.4px black;
  border-radius: 4px 4px 0px 0px;
  padding-bottom: 4px;
}

.rank-table-header {
  color: var(--color3); 
  font-weight: bold;
  cursor: default;
  border-top: solid 1.4px black;
  border-bottom: solid 1px black;
  padding: 4px 0;
}

.rank-table-col-left {
  text-align: left;
  padding-left: 8px;
}

.rank-table-col-right {
  text-align: right;
  padding-right: 10px;
}

.rank-button {
  transition: transform 0.2s ease;
}

.rank-button:hover {
  transform: scale(1.1);
}

.indicator-icon {
  color: var(--icon-color);
}

/* Data source info text + box ~ footer*/
.data-info-grid {
  display: grid;
  grid-template-columns: var(--sidebar-left-col-width) 1fr;
  width: calc(var(--sidebar-width) * var(--widget-width-scale));
  column-gap: 1px;
  align-items: stretch;
}

.data-info {
  font-size: 10pt;
  padding: 3px 0 10px 0px;
}

.data-info-title {
  font-weight: 600;
}

.data-info-icon {
  color: var(--color3);
  border-radius: 80px;
  background-color: var(--color7);
  cursor: pointer;
}

.data-info-icon:hover {
  color: var(--color7);
  background-color: var(--color2);
}

.data-info-btn {
  background: none;
  border: none;
  padding: 0; 
  margin: none;
}

.info-box-overlay {
  display: flex;
  position: fixed;
  inset: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) 0;
  align-items: flex-end;
  justify-content: center;
  background-color: rgba(0,0,0,0.45);
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.info-box-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.info-box-modal {
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  max-height: min(650px, calc(100vh - 10px));
  overflow: hidden;
  background-color: var(--color7);
  transform: translateY(16px);
  opacity: 0; 
  transition: transform 300ms ease, opacity 300ms ease;
  will-change: transform, opacity;
}
@media (max-width: 890px) {
  .info-box-modal {
    max-height: calc(100% - 10px);
    overflow: auto;
  }
}
/*
@media (max-width: 890px) {
  .info-box-modal {
    max-height: min(380px, calc(100vh - 6px));
  }
}
@supports (height: 100svh) { 
  @media (max-width: 890px) {
    .info-box-modal {
      max-height: min(380px, calc(100svh - 6px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
    }
 }
}
@supports (height: 100dvh) {
  @media (max-width: 890px) {
    .info-box-modal {
      max-height: min(380px, calc(100dvh - 6px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
    }
  }
}
*/

.info-box-overlay.open .info-box-modal {
  transform: translateY(0);
  opacity: 1;
}

.info-box-header {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  justify-content: space-between;
  font-size: 14pt;
  font-weight: 600;
  background-color: var(--color7);
  padding: 20px 26px 6px 26px;
}

.info-box-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  font-size: 11pt;
  line-height: 1.5;
  padding: 0 46px 30px 26px;
  white-space: normal;
  overflow-wrap: break-word;
  hyphens: auto;
}

@media (max-width: 890px) {
  .info-box-body {
    padding: 0 20px 20px 26px;
  }
}

.info-box-close-btn {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  font-size: 13pt;
  cursor: pointer;
  padding: 4px 8px;
  color: var(--color3);
}