/*<!--
  _   _ _ _    _                                  
 | \ | (_) | _| | __ _ ___                        
 |  \| | | |/ / |/ _` / __|                       
 | |\  | |   <| | (_| \__ \                       
 |_| \_|_|_|\_\_|\__,_|___/         _             
 \ \   / /_ _  ___| | _____ _ __ __| | __ _  __ _ 
  \ \ / / _` |/ __| |/ / _ \ '__/ _` |/ _` |/ _` |
   \ V / (_| | (__|   <  __/ | | (_| | (_| | (_| |
    \_/ \__,_|\___|_|\_\___|_|  \__,_|\__,_|\__, |
                                            |___/ 
-->*/

/* Hämtar teckensnitt */
/* @import url('https://fonts.googleapis.com/css2?family=Ubuntu:wght@400&display=swap');*/

html, body, #map {
	font-family: "Ubuntu", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	height: 100%;
	margin: 0;
	padding: 0;
}

#map, .leaflet-container {
	background: #a8d0ff; /* havsfärg */
}

/* attribution */
.leaflet-bottom.leaflet-right {
	bottom: 10px;
	right: 10px;
}

.leaflet-control-attribution {
	border-radius: 10px;
}

#csv-input {
	display: none;
}

/* sikte i mitten */


.magnifier {
	height: 30px;
	width: auto;
	padding: 0px;
}
/* Sökfunktionen */

#search-wrapper {
  position: absolute;
  top: 130px;
  right: 20px;
  z-index: 1100;
  padding: 0;
  border-radius: 15px;
  transition: none;
}

#search-wrapper.open { right: 20px; }
#search-wrapper.open #search-box { display: block; }

#search-toggle {
  padding: 0;
  background: white;
  cursor: pointer;
  border-radius: 50%;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
}

#search-box {
  position: relative; 
  margin-top: 20px;
  width: 320px;
  box-sizing: border-box;
  display: none;
  text-align: center;
  font-family: Ubuntu, sans-serif;
}

#search-input {
  padding: 6px;
  width: 100%;              /* matcha boxens bredd */
  border-radius: 5px;
  border: 1px solid #ccc;
  font-family: Ubuntu, sans-serif;
  font-size: 16px;
  box-sizing: border-box;
}

#suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 2000;

  display: none;
  box-sizing: border-box;
  margin: 0;
  padding: 0;

  list-style: none;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;

  max-height: 240px;
  overflow-y: auto;
}

#suggestions.open { display: block; }

#suggestions .suggestion-item {
  text-align: left;
  padding: 8px 12px;
  cursor: pointer;
}
#suggestions .suggestion-item.zebra {
  background: rgba(0, 0, 0, 0.04);
}
#suggestions .suggestion-item:hover {
  background: rgba(0, 0, 0, 0.08);
}

/* --- Sök --- */
#search-wrapper {
  position: absolute;
  top: 130px;
  right: 20px;
  z-index: 1100;
  padding: 0;
  border-radius: 15px;
}

#search-toggle {
  padding: 0;
  background: white;
  cursor: pointer;
  border-radius: 50%;
  box-shadow: 0 0 5px rgba(0,0,0,.3);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  position: relative;     /* ankare för rutan nedan */
}

/* Rutan ligger absolut under knappen och glider in från höger */
#search-box {
  position: absolute;
	margin-top: 20px;
  top: 48px;              /* avstånd nedanför knappen */
  right: 0;
  width: 320px;
  box-sizing: border-box;

  /* startläge (dold) */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(16px);      /* från höger */
  transition: transform .25s ease-out, opacity .25s ease-out, visibility 0s linear .25s;
}

#search-wrapper.open #search-box {
  /* visas */
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
  transition: transform .25s ease-out, opacity .25s ease-out;
}

/* Behåll listan positionerad relativt search-box */
#suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 2000;
  display: none;
}
#suggestions.open { display: block; }

/* Huvudstads-tooltip – lite tajtare text */


/* Gör stängningskrysset mörkrött (#b60000) */
.leaflet-container a.leaflet-popup-close-button {
  color: #b60000 !important;
}

#kommun-popup {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.4);
	z-index: 10000;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

#kommun-popup .popup-stat {
  margin: 6px 0 10px;
  padding: 8px 10px;
  background: #f6f8fa;
  border: 1px solid #e2e6ea;
  border-radius: 6px;
}
#kommun-popup .popup-stat-title {
  font-size: 12px;
  color: #666;
  margin-bottom: 2px;
}
#kommun-popup .popup-stat-value {
  font-size: 16px;
  font-weight: 600;
}

.popup-content {
	background: white;
	max-width: 400px;
	width: 90%;
	max-height: 80vh;
	overflow-y: auto;
	border-radius: 10px;
	padding: 20px;
	font-family: Ubuntu, sans-serif;
	box-shadow: 0 0 10px rgba(0,0,0,0.5);
	position: relative;
}

.popup-content h2 {
	margin-top: 0;
	margin-bottom: 12px;
	font-size: 1.3em;
}

.popup-content table {
	width: 100%;
	border-collapse: collapse;
}

.popup-content td {
	padding: 6px 8px;
	vertical-align: top;
}

.popup-content td:first-child {
	font-weight: 400;
	white-space: nowrap;
}

.popup-content a {
	color: #b60000;
	text-decoration: none;
}

.popup-close {
	position: absolute;
	top: 10px;
	right: 12px;
	background: none;
	border: none;
	color: #b60000;
	font-size: 22px;
	cursor: pointer;
}

#legend { 
	display:none;
	position:absolute;
	bottom: 20px !important;
	left: 20px !important;
	z-index:1000;
	background:#fff;
	border:1px solid #ccc;
	border-radius:4px;
	padding:8px 10px;
	font:12px/1.2 system-ui;
	min-width:180px;
	max-width:min(320px, calc(100vw - 40px));
}

#legend-swatches {
	display:flex;
	flex-direction:row;
	align-items:stretch;
	width:100%;
	height:14px;
	box-sizing:border-box;
	overflow:visible;
	gap:8px;
	padding:0;
	border:0;
	background:transparent;
}

#legend-swatches > *,
.legend-swatch {
	display:block;
	flex:1 1 0;
	min-width:0;
	height:100%;
	box-sizing:border-box;
}

#legend-range {
	width:100%;
	margin-top:6px;
	display:flex;
	justify-content:space-between;
}

#stat-sources {
	display: none;
	margin-top: 8px;
	padding-top: 6px;
	border-top: 1px solid #ddd;
	max-width: 260px;
	font: 12px/1.35 Ubuntu, sans-serif;
	color: #333;
}

#stat-sources a {
	color: #b60000;
	text-decoration: none;
}

#stat-sources a:hover,
#stat-sources a:focus {
	text-decoration: underline;
}

.stat-sources-label {
	color: #333;
}

#reset-map {
	position: absolute;
	top: 70px;
	right: 20px;
	z-index: 1000;
	font-size: 14px;
	padding: 4px 8px;
	background: white;
	cursor: pointer;
	border-radius: 50%;
	box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
	display: flex;
	align-items: center;
	justify-content: center;
	border: none; /* om du inte vill ha ram */
}

/* Startläge: göm legend */
#legend.is-hidden {
	display: none;
}

#controls {
	width: 300px;
}

#stat-select {
	position:absolute;
	width: 300px;
	height: 30px;
	top:20px;
	right:20px;
	z-index:1000;
	font-family: Ubuntu, sans-serif;
	font-size:16px;
	color: #b60000;
	padding: 5px 10px;
	box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);

	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	background-color: #fff; /* behövs ofta när man tar bort appearance */
	border: 1px solid #ccc;
	border-radius: 15px;	
}

option {
	font-family: Ubuntu, sans-serif;
}
img.graph-icon {
	width: 15px;
	height: 15px;
	object-fit: contain;
}


/* Centralt kartmeddelande */
#map-center-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  pointer-events: none;    /* blockera inte klick på kartan */
  z-index: 1100;           /* över UI-knapparna (som ligger ~1000) */
  opacity: 0;
  transition: opacity 150ms ease;
  white-space: nowrap;
}

#map-center-message.is-visible {
  opacity: 1;
}

/* === LABELS (konsoliderat) === */

/* Baslager för etiketter (behåll som du har idag) */
.leaflet-label-layer { z-index: 700; pointer-events: none; }

/* Vanliga landetiketter – enkel, mjuk halo (som förr) */
.kommun-label {
  position: absolute;
  transform: translate(-50%, -50%);
  white-space: normal;
  word-break: normal;       /* fallback */
  overflow-wrap: break-word;    /* standardiserat */
  pointer-events: auto;
  background: transparent;
  border: 0;
  box-shadow: none;

  color: #fff;
  font-weight: 400;
  line-height: 1.1;
  text-align: center;

  text-shadow:
    0 0 2px rgba(0,0,0,0.85),
    0 0 4px rgba(0,0,0,0.45);
}

/* Specialområden: behåll din tidigare stil (svart text med vit kant, lätt italics) */
.kommun-label.label-special {
  color: black;
  text-shadow:
      1px 1px 0 #fff,
     -1px 1px 0 #fff,
      1px -1px 0 #fff,
     -1px -1px 0 #fff;
  padding: 2px 4px;
  border-radius: 3px;
  font-style: italic;
  font-family: Ubuntu, sans-serif;
}

.leaflet-container a.leaflet-popup-close-button {
	color: #b60000;
}

#watermark {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 300px;      /* valfritt, justera storlek efter behov */
  height: auto;      /* behåll proportionerna */
  opacity: 0.6;      /* lätt transparens, justera 0–1 */
  pointer-events: none; /* så att bilden inte blockerar klick på kartan */
  z-index: 800;     /* se till att den ligger över kartan */
}
.popup-note {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.35;
  color: #666;
}


/* Växlingsknapp mellan Sverigekartan och Världskartan */
#map-switch {
	position: absolute;
	top: 190px;
	right: 20px;
	z-index: 1100;
	width: 40px;
	height: 40px;
	padding: 0;
	background: white;
	cursor: pointer;
	border-radius: 50%;
	box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
	display: flex;
	align-items: center;
	justify-content: center;
	border: none;
	text-decoration: none;
	color: #b60000;
}

#map-switch:hover,
#map-switch:focus {
	background: #fff;
	outline: none;
	box-shadow: 0 0 7px rgba(0, 0, 0, 0.45);
}

#map-switch k-icon {
	display: block;
	width: 24px;
	height: 24px;
	color: #b60000;
}

#map-switch k-icon svg,
#map-switch .k-icon,
#map-switch svg {
	display: block;
	width: 24px;
	height: 24px;
}
