* {
	box-sizing: border-box;
}

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

a, a:visited {
	color: #3478F7;
}


#sok {
  position: absolute;
  top: .6em;
  right: 3.1em;
  z-index: 9999;
}

#searchInput {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
}
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: white;
    border: 1px solid #ccc;
    border-top: none;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}
.search-result-item {
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    font-size: 0.9em;
}

.search-result-item a {
    color: #6a6a6a;
    font-weight: normal;
    font-size: 0.9em;    
}

.search-result-item:hover,
.search-result-item.active {
    background: #f0f0f0;
}
.search-result-empty {
    padding: 8px 10px;
    color: #888;
    font-style: italic;
}

.search-row {
    display: flex;
    gap: 4px;    
}

.search-row > * {
		font-size: .9em;	
}

#searchInput {
    flex: 1;
    box-sizing: border-box;
}
#searchButton {
    flex: 0 0 auto;
    padding: 0 10px;
    cursor: pointer;
}

#popup h1 {
	text-transform: uppercase;
	font-size: .9em;
	letter-spacing: .5px;
	text-align: center;
	font-weight: 900;
  	padding-bottom: .8em;
	margin: .1em 1em .3em 1em;  	
}

#popup h2, #popup h3 {
	margin-bottom: 0;
	font-size: 1.24rem;
	margin-top: .3em;
}

#popup h2+h3 {
	font-weight: normal;
	font-size: 1em;	
	margin: 0;
	margin-bottom: .1em;
}

#popup h4{
	margin: 0;
}

#popup p {
	margin: .5em 0;
	line-height: 1.2em;
}

#popup a {
	overflow-wrap: anywhere;	
}

#popup p:last-of-type {
	margin-bottom: 0;
}

#punkt_beskrivn {

}

#punkt_beskrivn_empty {
	color: gray;
}

#popup .omrade {
	color: #555;
	margin-top: 0;
	line-height: 1.1em;
	font-size: .8em;
	margin-bottom: .7em;
}

.highlight {
	width: 25px;
  	height: 25px;
  	border-radius: 30%;
  	border: 3.5px solid rgba(255,41,255,.5);
/*  	mix-blend-mode: multiply;*/
}

.idnr {
	display: none;
	font-family: monospace;
	font-size: .8em;
	color: #a4a0a0;
}

#popup {
	font-size: .9em;
  	padding: 1em;
  	height: 100%;
  	width: 360px;
  	bottom: 0;
  	position: absolute;
  	background: rgba(255,255,255,.75);
  	left: 0;
  	right: 0;
  	-webkit-backdrop-filter: blur(7px);  
  	backdrop-filter: blur(7px);
  	box-shadow: 0px 0px 2.5px rgba(0,0,0,0.2);
  	display: flex;
  	flex-direction: column;
}

#popup label {
	user-select: none;
	font-size: 1em;
	padding-left: .2em;
}

#layers {
	margin-top: auto;
	padding: 1em;
	padding-bottom: 0;
	border-radius: 3px;
}

details#layers  {
	display: flex;
	flex-direction: column-reverse; /* flips summary and content order */
	font-size: .94em;	
}

#layers summary {
	font-weight: bold;
	cursor: pointer;
	user-select: none;
}

/* hide default marker */
#layers summary {
  list-style: none;
}
#layers summary::-webkit-details-marker {
  display: none;
}

/* add your own via ::before */
#layers summary::before {
 	content: "►"; /* or ▶, or whatever you like */
 	display: inline-block;
 	transition: transform 0.4s;
 	font-size: .8em;
 	margin-right: 3px;
	translate: 0 -1.5px;
}

details[open] summary::before {
  transform: rotate(-90deg); /* flips it upward */
}

#layers .detailsContent {
  padding-bottom: .7em;

}

#layers h3 {
	text-transform: uppercase;
	font-size: .8em;
	margin-left: 4px;
	margin-bottom: 4px;
	letter-spacing: .7px;
	margin-top: .6em;
}

#layers h3:first-of-type {
	margin-top: 0;
}

#toggleSidebar {
	position: absolute;
  right: -15px;
  top: 0;
  bottom: 0;
  height: 23px;
  width: 30px;
  margin-top: auto;
  margin-bottom: auto;
  border-radius: 2px;
  -webkit-appearance: none;
  background: white;
  border: 0;
  box-shadow: 0px 0px 1px rgba(0,0,0,0.5);  
  color: #2E7DF6;
  font-family: -apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif;
}

#popup.hidden {
	left: -330px;
}

#popupContent {
	margin: 1em;
	margin-top: 0;
	overflow-y: auto;
	margin-bottom: 0;
}

#popupContent .images {
	margin-top: 1em;	
  display: grid;
	grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 5px;
}

/* more than 1 image, crop to make nice grid */
#popupContent .images:has(figure ~ figure) figure img {
	aspect-ratio: 1 / 1.2;
	object-fit: cover;
}

#popupContent .images img {
	display: block;
	width: 100%;
}

#popupContent .images figure {
	margin: 0;
}

#popupContent .images figcaption {
	font-size: .8em;
	margin-top: .2em;
}

#popupContent .images figcaption a {
	color: black;
  	font-size: .92em;
  	margin-left: .07em;
}

#popupContent img {
	max-width: 100%;
	scroll-snap-align: center;
}

#newPointData {
	padding: .5em;
}

#newPointData input, #newPointData select, #newPointData button {
	font-size: 1em;
}

#newPointData, #newpoint_id {
	display: none;
}

#newpoint_namn input, #newpoint_typ select, #newpoint_beskrivning textarea, #newpoint_imagecaption input {
	width: 100%;
	margin-bottom: 1em;
}

#newpoint_namn input {
	font-size: 1em;
	font-weight: bold;
}

#newpoint_beskrivning textarea {
	height: 130px;
    font-family: inherit;
    font-size: inherit;	
}

#newpoint_button {
	margin: 0 auto;
  	margin-top: 0px;
  	display: block;
  	margin-top: 1em;
  	width: 100px;
}

#image_upload {
	margin-bottom: .65em;
}

#handleImages {
  display: none;
  margin-top: .5em;
}

#newpoint_wkt {
	width: 100%;
}

#newpoint_imagecaption, label[for="newpoint_imagecaption"] {
	display: none;
}

#login {
	margin: 1em;
}

.maplibregl-user-location-dot {
	z-index: 99;
}

.maplibregl-user-location-dot:before {
	animation: none !important;
}

@media (width <= 640px) {

	#popup h1 {
		letter-spacing: 1px;
		padding-bottom: .4em;
	}

	#popupContent figure {
    	scroll-snap-align: center;
    	margin: 0;		
	}	

	#popupContent .images {
		grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
	}

	details#layers  {
		flex-direction: column;
		margin-top: 0;
	}

	details[open] summary::before {
  	transform: rotate(90deg);
	}

	body {
		display: flex;
		flex-direction: column;
	}

	#map {
		flex: 1;
		min-height: 0;
	}

  #popup.animated {
    transition: height 0.25s ease-out;
  }
 
  #popup.expanded {
    overflow-y: auto;         /* expanded: content becomes scrollable */
  }

  #popup {
    min-height: 29px;
    max-height: 80vh;
    background: #fff;
    border-top: 1px solid #ddd;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
		width: 100%;
		/*border-radius: 20px 20px 0 0;*/
		overflow: auto;
		padding: 0;
		position: static;
    height: 340px;              /* starts collapsed at MIN_HEIGHT */
    overflow-y: hidden;        /* collapsed: no internal scroll, whole thing is the "handle" */
    touch-action: pan-y;
  }
	
	#popupContent {
		overflow-y: visible;
	}

  #popup-handle {
    touch-action: none;      /* stop the browser hijacking the gesture */
    cursor: ns-resize;
    display: flex;
    justify-content: center;
    flex-shrink: 0;
    padding-top: 1em;
    padding-bottom: 8px;
		position: sticky;
    top: 0;
    background: white;    
  }
 
  #popup-handle .bar {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: #ccc;
  }

  #toggleSidebar {
  	display: none;
  }
}