html, body {
  height: 100%;
  overflow: hidden;
}

@font-face {
  font-family: 'NexaBook';
  src: url('fonts/nexabook.otf') format('opentype');
}
@font-face {
  font-family: 'NexaBold';
  src: url('fonts/nexabold.otf') format('opentype');
}
@font-face {
  font-family: 'NexaBlack';
  src: url('fonts/nexablack.otf') format('opentype');
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'NexaBook', Arial, sans-serif;
  background-color: #fffef6;
  color: white;
  scroll-behavior: smooth;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #fffef6;
  height: 60px;
  padding: 1rem 0.9rem 1rem 1rem;
  position: relative;
  border-bottom: 1px solid rgba(0, 0, 0, 0.25);
}

.logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  height: 100%;
}

.logo-link img {
  height: 46px;
  object-fit: contain;
}

.wordmark-wrapper {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  height: 100%;
  display: flex;
  align-items: center;
}

.wordmark-wrapper img {
  height: 42px;
  object-fit: contain;
}

@media (max-width: 600px) {
  .wordmark-wrapper img {
    height: 40px;
  }
}

#map {
  height: calc(var(--vh, 1vh) * 100 - 60px);
  width: 100%;
  position: relative;
}

.btn {
  padding: 10px 16px;
  font-size: 1rem;
  background: #f47c31;
  color: #fffef6;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'NexaBook', Arial, sans-serif;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: background 0.3s, color 0.3s;
}

.btn:focus {
  outline: 2px solid #333;
  outline-offset: 2px;
}

#removeRouteBtn {
  position: absolute;
  bottom: 25px;
  right: 13px;
  z-index: 1500;
}

.info-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.info-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

#infoOverlay {
  opacity: 1 !important;
  pointer-events: auto !important;
}

.info-box {
  background: #fffef6;
  color: #333;
  padding: 2rem;
  border-radius: 10px;
  max-width: 90%;
  width: 400px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  text-align: center;
  font-family: 'NexaBook', Arial, sans-serif;
}

.info-box h2 {
  margin-top: 0;
  font-family: 'NexaBold', Arial, sans-serif;
}

@media (max-width: 480px) {
  .info-box {
    width: 90%;
    max-width: 340px;
    font-size: 0.95rem;
    padding: 1.5rem;
  }
}

#aboutOverlay .info-box,
#AaaOverlay .info-box,
#SchemaOverlay .info-box {
  margin-top: 100px;
  margin-bottom: 100px;
  max-height: calc(100vh - 200px);
  text-align: left;
  overflow-y: auto;
  position: relative;
}

@media (max-width: 600px) {
  #aboutOverlay .info-box,
  #AaaOverlay .info-box,
  #SchemaOverlay .info-box {
    width: clamp(240px, 85%, 320px);
    padding: 2.5rem 1.5rem 1.5rem;
    margin-top: 100px;
    margin-bottom: 100px;
    max-height: calc(100vh - 200px);
  }

  #aboutOverlay .menu-close,
  #AaaOverlay .menu-close,
  #SchemaOverlay .menu-close {
    position: absolute;
    top: 0.7rem;
    right: 1rem;
  }
}

.info-box a {
  color: #f47c31;
  text-decoration: underline;
  font-family: 'NexaBold', Arial, sans-serif;
  transition: color 0.3s;
}

.user-location-icon,
.leaflet-marker-pane .leaflet-marker-icon.user-location {
  width: 18px;
  height: 18px;
  background-color: #6278b3;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

.leaflet-routing-container {
  display: none !important;
}

.leaflet-popup-pane {
  z-index: 1100 !important;
}

.leaflet-popup-content {
  background: #fffef6;
  font-family: 'NexaBook', Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.4;
}

.leaflet-popup-content strong {
  font-family: 'NexaBold', Arial, sans-serif;
}

.leaflet-popup-content .route-btn {
  margin-top: 0.65rem;
  display: inline-block;
}

.leaflet-control-zoom a,
.leaflet-control-layers-toggle,
.leaflet-control-layers-expanded,
.leaflet-popup-content-wrapper,
.leaflet-popup-tip,
.leaflet-routing-container {
  background-color: #fffef6 !important;
}

.leaflet-control-zoom a:hover,
.leaflet-control-layers-toggle:hover,
.leaflet-control-locate:hover {
  background-color: #fffef6 !important;
}

.leaflet-control-zoom a:active,
.leaflet-control-layers-toggle:active,
.leaflet-control-locate:active {
  background-color: #fcf1b6 !important;
}

/* Hamburgermeny */
.menu-toggle {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  background-image: url('bars.svg');
  background-repeat: no-repeat;
  background-position: center;
  background-size: 30px 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.menu-wrapper {
  margin-left: auto;
  position: relative;
  z-index: 3000;
}

body.no-scroll {
  overflow: hidden;
}

.menu-drawer {
  position: fixed;
  top: 0;
  right: -250px;
  height: 100vh;
  width: 250px;
  background-color: #fffef6;
  border-left: 1px solid rgba(0, 0, 0, 0.25);
  /* box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2); */
  display: flex;
  flex-direction: column;
  padding-top: 60px;
  transition: right 0.3s ease;
  z-index: 2000;
}

.menu-drawer.open {
  right: 0;
}

.menu-drawer a {
  padding: 1rem;
  text-decoration: none;
  color: #333;
  font-family: 'NexaBook', Arial, sans-serif;
  border-bottom: 1px solid #eee;
}

.menu-drawer a:hover {
  background-color: #f47c31;
  color: #fffef6;
}

.menu-close {
  background: none;
  border: none;
  font-size: 2rem;
  color: #18171c;
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  cursor: pointer;
}

.about-svg-wrapper {
  text-align: center;
  margin-top: 1rem;
}

.about-svg-wrapper img {
  width: 150px;
  max-width: 100%;
  height: auto;
  display: inline-block;
}

/* === Macha lagerväljare och platsknapp === */
/* Platsknappen */
.leaflet-control-locate {
  display: block;
  width: 40px !important;
  height: 40px !important;
  background-color: #fffef6 !important;
  background-image: url('locate.svg');
  background-repeat: no-repeat;
  background-position: center;
  background-size: 30px 30px !important;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.25) !important;
  box-shadow: none !important;
}

/* Lagerväljarens ikon */
.leaflet-control-layers-toggle {
  width: 40px !important;
  height: 40px !important;
  background-image: url('funnel.svg') !important;
  border-radius: 4px !important;
  background-size: 30px 30px !important;
  border: 1px solid rgba(0, 0, 0, 0.25) !important;
  box-shadow: none !important;
}

.leaflet-control-layers {
  border: none !important;
  box-shadow: none !important;
  border-radius: 4px !important;
}

.leaflet-control-layers-expanded {
  border: 1px solid rgba(0, 0, 0, 0.25) !important;
  box-shadow: none !important;
  background: #fffef6 !important;
  border-radius: 4px !important;
}

.leaflet-control-layers-list {
  border: none !important
}

#spinnerOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}
.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #f47c31;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* === Dark mode === 
@media (prefers-color-scheme: dark) {
  body {
    background-color: #181818;
    color: #f4f4f4;
  }

  header {
    background-color: #fffef6;
    color: #fff;
  }

  .info-box {
    background: #232323;
    color: #f4f4f4;
  }

  .btn {
    background: #f47c31;
    color: #fff;
  }
} */

/* ==================== */
/* PRESTANDOPTIMERINGAR */
/* ==================== */

.leaflet-container {
  will-change: transform;
  backface-visibility: hidden;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.leaflet-marker-icon {
  will-change: transform;
  backface-visibility: hidden;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  will-change: transform;
}

/* Reducera animationer för bättre prestanda */
/*.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon, 
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  transition: none !important;
  animation: none !important;
} */

/* Optimera för hardware acceleration */
.leaflet-map-pane {
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

/* Fix för vissa rendering issues på mobile */
.leaflet-tile-pane {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* Optimera overlay animations */
.info-overlay {
  will-change: opacity;
}

/* Optimera knappar för touch devices */
.btn,
.menu-toggle,
.menu-close {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Prevent layout shifts */
.leaflet-control {
  will-change: transform;
}

/* Optimera spinner */
.spinner {
  will-change: transform;
}
