/* Map page: harbor view, chips on the map, round controls */
.app-karta {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

body.guest-nav .app.app-karta {
  height: auto;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.lager-rad {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 12;
  pointer-events: none;
}

.lager-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  pointer-events: auto;
  padding-bottom: 2px;
  padding-right: 16px;
}
.lager-chips::-webkit-scrollbar {
  display: none;
}
.lager-chips.har-mer {
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 72px), transparent);
  mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 72px), transparent);
}

.lager-rad button {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(245, 240, 232, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #1C2B3A;
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(28, 43, 58, 0.12), 0 1px 2px rgba(28,43,58,0.08);
  transition: background 0.18s ease, color 0.18s ease,
              box-shadow 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}
.lager-rad button:active { transform: scale(0.94); }
.lager-rad button .ph { font-size: 14px; line-height: 1; }

.lager-rad button.is-on {
  background: var(--kat-farg, #0A7A8C);
  border-color: var(--kat-farg, #0A7A8C);
  color: #fff;
  box-shadow: 0 2px 10px rgba(10, 122, 140, 0.32);
}

.lager-rad button[data-layer="sevart"].is-on {
  background: #0A7A8C; border-color: #0A7A8C;
  box-shadow: 0 2px 10px rgba(10,122,140,0.32);
}
.lager-rad button[data-layer="ata"].is-on {
  background: #1B5E3B; border-color: #1B5E3B;
  box-shadow: 0 2px 10px rgba(27,94,59,0.32);
}
.lager-rad button[data-layer="butik"].is-on {
  background: #7B5EA7; border-color: #7B5EA7;
  box-shadow: 0 2px 10px rgba(123,94,167,0.32);
}
.lager-rad button[data-layer="justnu"].is-on {
  background: #C04A4A; border-color: #C04A4A;
  box-shadow: 0 2px 10px rgba(192,74,74,0.32);
}
.lager-rad button[data-layer="kaj"].is-on {
  background: #1C2B3A; border-color: #1C2B3A;
  box-shadow: 0 2px 10px rgba(28,43,58,0.32);
}
.lager-rad button[data-layer="parkering"].is-on,
.lager-rad button[data-layer="buss"].is-on {
  background: #4A7BA7; border-color: #4A7BA7;
  box-shadow: 0 2px 10px rgba(74,123,167,0.32);
}
.lager-rad button[data-layer="uppleva"].is-on {
  background: #D4943A; border-color: #D4943A;
  box-shadow: 0 2px 10px rgba(212,148,58,0.32);
}
.lager-rad button[data-layer="boende"].is-on {
  background: #1d4ed8; border-color: #1d4ed8;
  box-shadow: 0 2px 10px rgba(29,78,216,0.32);
}

.map-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  background: #eceae4;
  z-index: 0;
  touch-action: none;
}

/* Ovanför Leaflets paneler (z-index 200–700) tills MapLibre är pitchad. */
#map-loading {
  position: absolute;
  inset: 0;
  z-index: 800;
  background: #e8e4db;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
#map-loading.is-ready {
  opacity: 0;
}

#karta-loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #f5f5f5;
  z-index: 999;
  pointer-events: none;
}
#karta-loader.is-ready { display: none; }
.karta-loader-spin {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid rgba(28, 43, 58, 0.15);
  border-top-color: #1C2B3A;
  animation: load-spin-rot 0.7s linear infinite;
}

.maplibregl-ctrl-logo,
.maplibregl-compact {
  display: none !important;
}
.maplibregl-ctrl-attrib {
  font-size: 11px !important;
  line-height: 1.6;
  padding: 2px 8px;
  background: rgba(255, 252, 247, 0.92);
  z-index: 16;
}
.maplibregl-ctrl-attrib a {
  min-height: 20px;
  display: inline-block;
}
.basemap-color {
  filter: saturate(0.75) brightness(1.04) contrast(0.92);
}

.leaflet-marker-icon,
.leaflet-marker-shadow,
.karta-pin-wrap,
.karta-cluster-wrap {
  background: none !important;
  border: 0 !important;
  overflow: visible !important;
  will-change: transform;
}

.karta-pin {
  position: relative;
}

.sheet-parkering-lista {
  display: grid;
  gap: 4px;
  margin: 8px 0 0;
}
.sheet-parkering-lista div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
}
.sheet-parkering-lista dt {
  color: rgba(28, 43, 58, 0.62);
}
.sheet-parkering-lista dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
}

.pin-is-selected .karta-pin {
  transform: scale(1.18) translateY(-3px);
  transform-origin: center bottom;
  filter: drop-shadow(0 4px 12px rgba(28, 43, 58, 0.45));
  transition: transform 0.18s ease, filter 0.18s ease;
}

.karta-pin-namn {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  max-width: none;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.97);
  color: #1C2B3A;
  font-family: Inter, system-ui, sans-serif;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: visible;
  box-shadow: 0 1px 6px rgba(28, 43, 58, 0.12), 0 0 0 1px rgba(28, 43, 58, 0.06);
  pointer-events: none;
}

.karta-pin-namn.is-left {
  left: auto;
  right: calc(100% + 7px);
}

.karta-cluster {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #1C2B3A;
  color: #FFFCF7;
  font-family: Inter, system-ui, sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 10px rgba(28, 43, 58, 0.22);
}
.karta-cluster.is-dim {
  opacity: 0.4;
}

.lista-btn {
  position: absolute;
  top: 54px;
  right: 12px;
  z-index: 14;
}

.map-ctrls {
  position: absolute;
  right: 12px;
  bottom: 18px;
  z-index: 14;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  /* Stay put while the sheet closes (0.32s), then jump. A moving button
     is missed by the tap. */
  transition: bottom 0s linear 0.32s;
}
.map-wrap.sheet-open .map-ctrls {
  bottom: calc(52vh + 28px);
  transition: bottom 0s linear 0s;
}

.map-ctrl {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  background: rgba(245, 240, 232, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #1C2B3A;
  font-size: 18px;
  box-shadow: 0 2px 10px rgba(28, 43, 58, 0.14);
  cursor: pointer;
  padding: 0;
}
.map-ctrl i {
  font-size: 18px;
  line-height: 1;
}
.map-ctrl.is-busy {
  opacity: 0.55;
}
.lista-btn[aria-expanded="true"] {
  background: #1C2B3A;
  color: #fff;
}

.karta-meny {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  width: min(300px, 86vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background: #FFFCF7;
  transform: translateX(-105%);
  transition: transform 0.22s ease;
  overflow: auto;
}
.karta-meny.open {
  transform: translateX(0);
  box-shadow: 8px 0 24px rgba(28, 43, 58, 0.16);
}
.karta-meny-rubrik {
  margin: 6px 0 0;
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(28, 43, 58, 0.55);
}
.karta-meny-kat,
.karta-meny-avstand {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.karta-meny-kat button,
.karta-meny-avstand button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(28, 43, 58, 0.18);
  background: #fff;
  color: #1C2B3A;
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.karta-meny-kat button.is-on,
.karta-meny-avstand button.is-on {
  background: var(--kat-farg, #1C2B3A);
  border-color: var(--kat-farg, #1C2B3A);
  color: #fff;
}
.karta-meny-lista {
  margin-top: auto;
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: #1C2B3A;
  color: #fff;
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.map-locate.visar-avstand {
  width: auto;
  height: 40px;
  padding: 0 14px 0 12px;
  gap: 6px;
  border-radius: 999px;
  display: flex;
}
.map-locate-text {
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.pin-lista {
  position: absolute;
  top: 56px;
  left: 8px;
  right: 8px;
  z-index: 15;
  margin: 0;
  padding: 6px 0 0;
  max-height: 42%;
  overflow: auto;
  background: #FFFCF7;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(28, 43, 58, 0.16);
}
.pin-lista[hidden] { display: none; }
.pin-lista-rader {
  margin: 0;
  padding: 0;
  list-style: none;
}
.pin-lista button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 8px 14px;
  border: 0;
  background: none;
  text-align: left;
  font-family: Inter, system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: #1C2B3A;
  cursor: pointer;
}
.pin-lista button > .ph {
  flex: 0 0 auto;
  font-size: 16px;
  color: #1C2B3A;
}
.pin-lista .lista-namn {
  flex: 1 1 auto;
  min-width: 0;
}
.pin-lista .lista-meta {
  flex: 0 1 auto;
  max-width: 48%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(28, 43, 58, 0.55);
}
.pin-lista-notis {
  padding: 4px 14px 2px;
}
.lista-dolda {
  margin: 0;
  padding: 10px 14px 0;
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
  color: rgba(28, 43, 58, 0.72);
}
.lista-dolda[hidden] { display: none; }
.pin-lista-notis[hidden] { display: none; }
.pin-lista li.is-shut button {
  opacity: 0.55;
}
.lista-stangda {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 4px 0 0;
  padding: 0 14px;
  border-top: 1px solid #E0D9CF;
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: #1C2B3A;
  cursor: pointer;
}
.lista-stangda input {
  width: 18px;
  height: 18px;
  accent-color: #1C2B3A;
}

.pin-sheet {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 13;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 52vh;
  background: #FFFCF7;
  border-radius: 20px;
  box-shadow: 0 8px 40px rgba(28, 43, 58, 0.22);
  border: 1px solid rgba(28, 43, 58, 0.08);
  transform: translateY(calc(100% + 20px));
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition:
    transform 0.32s cubic-bezier(0.34, 1.4, 0.64, 1),
    opacity 0.22s ease,
    visibility 0s linear 0.32s;
}

.pin-sheet.is-on {
  display: flex;
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transition:
    transform 0.32s cubic-bezier(0.34, 1.4, 0.64, 1),
    opacity 0.22s ease,
    visibility 0s linear 0s;
}

.pin-sheet [hidden] { display: none !important; }

.sheet-accent-bar {
  height: 4px;
  width: 100%;
  background: #0A7A8C;
  flex-shrink: 0;
}

.sheet-img-wrap {
  width: 100%;
  height: 130px;
  flex-shrink: 0;
  overflow: hidden;
  background: #D9D0C3;
  position: relative;
  z-index: 1;
}

.sheet-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 40%;
  display: block;
  transition: opacity 0.22s ease;
}
.sheet-img-wrap img:not(.leaflet-tile):not(.leaflet-marker-icon):not(.leaflet-marker-shadow):not(.leaflet-image-layer) {
  transition: opacity 0.22s ease;
}

.sheet-img-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 55%, rgba(28, 43, 58, 0.35) 100%);
  pointer-events: none;
}

.sheet-img-wrap:has(img[hidden]) {
  display: none;
}

.sheet-credit {
  margin: 0;
  padding: 4px 16px 0;
  font-size: 0.68rem;
  line-height: 1.3;
  color: #8a8178;
}

.sheet-body {
  padding: 12px 16px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
}

.sheet-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  min-height: 22px;
}

.sheet-cat-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
}

.pin-sheet h2 {
  font-family: "Playfair Display", Palatino, Georgia, serif;
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 2rem 0.25rem 0;
  color: #1C2B3A;
  line-height: 1.2;
}

.pin-sheet p {
  margin: 0 0 0.3rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: rgba(28, 43, 58, 0.72);
}

.pin-sheet [data-sheet-text] {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pin-sheet .sheet-status {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 4px 0 6px;
  font-size: 0.8rem;
  font-weight: 650;
  color: #2E7D32;
}

.pin-sheet .sheet-status::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2E7D32;
  flex-shrink: 0;
}

.pin-sheet .sheet-status.is-shut {
  color: rgba(28, 43, 58, 0.45);
}

.pin-sheet .sheet-status.is-shut::before {
  background: rgba(28, 43, 58, 0.3);
}

.pin-sheet .sheet-status.is-okand {
  color: rgba(28, 43, 58, 0.72);
}

.pin-sheet .sheet-status.is-okand::before {
  display: none;
}

.pin-sheet .walk {
  color: rgba(28, 43, 58, 0.5);
  font-size: 0.75rem;
  margin: 0;
}

.sheet-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.pin-sheet .guide-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  background: #0A7A8C;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 650;
  text-decoration: none;
}

.pin-sheet .maps-link {
  display: inline-flex;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted, #6B7A8D);
  text-decoration: none;
  padding: 0;
  border: none;
  background: none;
}

.pin-sheet .maps-link:hover {
  color: var(--navy);
  text-decoration: underline;
}

.sheet-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(245, 240, 232, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #1C2B3A;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 6px rgba(28, 43, 58, 0.20);
}

.note-sheet {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 13;
  display: block;
  padding: 20px 16px 16px;
  overflow: hidden;
  background: #FFFCF7;
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(28, 43, 58, 0.18);
  transform: translateY(calc(100% + 20px));
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition:
    transform 0.32s cubic-bezier(0.34, 1.4, 0.64, 1),
    opacity 0.22s ease,
    visibility 0s linear 0.32s;
}
.note-sheet.is-on {
  display: block;
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transition:
    transform 0.32s cubic-bezier(0.34, 1.4, 0.64, 1),
    opacity 0.22s ease,
    visibility 0s linear 0s;
}
.note-sheet p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.4;
  color: #1C2B3A;
}

/* #map är en egen stacking context under flikraden. 1000 är Leaflets
   kontroll-lager och ligger över tile-panelen (200), annars täcker
   MapLibre-canvasen kreditlänken. */
.leaflet-bottom.leaflet-left,
.leaflet-bottom.leaflet-right {
  max-width: calc(100% - 8px);
  z-index: 1000;
}
.leaflet-control-attribution,
.maplibregl-ctrl-attrib,
.maplibregl-ctrl-attrib-inner {
  max-width: 100% !important;
  white-space: normal !important;
  height: auto !important;
  overflow: visible !important;
}
.leaflet-control-attribution {
  font-size: 11px !important;
  line-height: 24px;
  min-height: 24px;
  padding: 0 8px;
  background: rgba(255, 252, 247, 0.92) !important;
  margin: 0 0 6px 8px !important;
}
.maplibregl-ctrl-attrib {
  display: none !important;
}
.leaflet-control-attribution a {
  display: inline-block;
  min-height: 24px;
  line-height: 24px;
  pointer-events: auto;
}
@media (max-width: 767px) {
  .map-wrap.sheet-open .leaflet-bottom,
  .map-wrap.sheet-open .maplibregl-ctrl-bottom-left,
  .map-wrap.sheet-open .maplibregl-ctrl-bottom-right {
    bottom: var(--kredit-lyft, 0px);
  }
}

.sheet-handelser {
  white-space: pre-line;
  margin: 0 0 8px;
  font-weight: 600;
}
.sheet-handelser[hidden] { display: none; }

@media (min-width: 768px) {
  .app.app-karta {
    max-width: none;
  }

  .site {
    padding: 0.6rem 8px 0.5rem 14px;
  }

  .pin-sheet {
    left: 10px;
    top: 10px;
    bottom: 10px;
    right: auto;
    width: 300px;
    max-height: none;
    border-radius: 16px;
  }

  .pin-sheet::before {
    display: none;
  }

  .sheet-img-wrap {
    height: 168px;
  }

  .pin-sheet [data-sheet-text] {
    -webkit-line-clamp: 4;
  }

  .map-wrap.sheet-open .map-ctrls {
    bottom: 18px;
  }

  .map-wrap.sheet-open .lager-rad {
    left: 320px;
    transition: left 0.2s ease;
  }

  .pin-lista {
    top: 56px;
    left: 320px;
    right: auto;
    width: 320px;
    max-height: 60%;
    border-radius: 14px;
  }

  .map-wrap:not(.sheet-open) .pin-lista {
    left: 8px;
  }

  .map-wrap.sheet-open .lista-btn {
    right: 12px;
  }
}

.map-3d-mark {
  font-family: Inter, system-ui, sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
}

.map-3d-btn.is-on {
  background: #1C2B3A;
  border-color: #1C2B3A;
  color: #fff;
  box-shadow: 0 2px 12px rgba(28,43,58,0.32);
}

@media (prefers-reduced-motion: reduce) {
  .pin-sheet,
  .pin-sheet.is-on,
  .note-sheet,
  .note-sheet.is-on,
  .lager-rad button,
  .map-ctrls,
  .map-wrap.sheet-open .map-ctrls {
    transition: none;
  }
}
