/* ---------------------------------------------------------------
   Loppemarked i Fjellerad – kort
   Mobil-først. Kortet fylder hele skærmen, resten flyder ovenpå.
---------------------------------------------------------------- */

:root {
  --groen:        #2e7d32;
  --groen-moerk:  #1b5e20;
  --groen-lys:    #e8f5e9;
  --tekst:        #1c2321;
  --tekst-svag:   #5c6b64;
  --flade:        #ffffff;
  --kant:         #e2e8e4;
  --skygge:       0 2px 10px rgba(0, 0, 0, .16);
  --skygge-stor:  0 -4px 24px rgba(0, 0, 0, .18);
  --radius:       14px;
  --safe-top:     env(safe-area-inset-top, 0px);
  --safe-bund:    env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--tekst);
  background: #eef2ef;
  -webkit-text-size-adjust: 100%;
}

/* --- Kortet fylder hele viewporten --- */
#map {
  position: fixed;
  inset: 0;
  height: 100%;
  height: 100dvh;
  width: 100%;
  background: #eef2ef;
  z-index: 0;
}

/* --- Topbjælke --- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: calc(var(--safe-top) + 10px) 14px 10px;
  background: linear-gradient(to bottom, rgba(255,255,255,.97) 55%, rgba(255,255,255,0));
  pointer-events: none;
}

.topbar__title h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--groen-moerk);
}

.topbar__title p {
  margin: 2px 0 0;
  font-size: .8rem;
  color: var(--tekst-svag);
}

/* --- Flydende knapper --- */
.fabs {
  position: fixed;
  right: 12px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* Løftes over bundpanelet via JS-variabel */
  bottom: calc(var(--sheet-hoejde, 76px) + var(--safe-bund) + 14px);
  transition: bottom .28s cubic-bezier(.4, 0, .2, 1);
}

.fab {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: var(--flade);
  box-shadow: var(--skygge);
  color: var(--tekst-svag);
  display: grid;
  place-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color .15s, background .15s;
}

.fab svg { width: 22px; height: 22px; fill: currentColor; }
.fab:active { background: #f2f6f3; }
.fab.is-active { color: #1a73e8; }
.fab.is-soeger svg { animation: puls 1.1s ease-in-out infinite; }

@keyframes puls { 50% { opacity: .35; } }

/* --- Bundpanel --- */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1001;
  background: var(--flade);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--skygge-stor);
  padding-bottom: var(--safe-bund);
  display: flex;
  flex-direction: column;
  max-height: 62dvh;
}

.sheet__handle {
  flex: 0 0 auto;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 8px 16px 12px;
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  color: var(--groen-moerk);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  -webkit-tap-highlight-color: transparent;
}

.sheet__grip {
  display: block;
  width: 42px;
  height: 5px;
  border-radius: 3px;
  background: #cfd8d3;
}

.sheet__body {
  display: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 14px 14px;
}

.sheet.is-open .sheet__body { display: block; }

.sheet__hint {
  margin: 0 0 12px;
  font-size: .82rem;
  line-height: 1.45;
  color: var(--tekst-svag);
  background: var(--groen-lys);
  border-radius: 10px;
  padding: 10px 12px;
}

.sheet__foot {
  margin: 14px 0 0;
  font-size: .68rem;
  color: #92a09a;
  text-align: center;
}

/* --- Bodliste --- */
.stalls {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stall {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--kant);
  border-radius: 12px;
  background: var(--flade);
  transition: border-color .15s, background .15s;
}

.stall.is-valgt {
  border-color: var(--groen);
  background: var(--groen-lys);
}

.stall__nr {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--groen);
  color: #fff;
  font-size: .85rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.stall__info {
  flex: 1 1 auto;
  min-width: 0;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  text-align: left;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.stall__adresse {
  display: block;
  font-weight: 600;
  font-size: .93rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stall__meta {
  display: block;
  font-size: .78rem;
  color: var(--tekst-svag);
  margin-top: 1px;
}

.stall__nav {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--groen);
  color: #fff;
  font-size: .8rem;
  font-weight: 600;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.stall__nav svg { width: 14px; height: 14px; fill: currentColor; }
.stall__nav:active { background: var(--groen-moerk); }

/* --- Markører på kortet --- */
.bod-markoer {
  background: none;
  border: 0;
}

.bod-markoer__pin {
  position: relative;
  width: 30px;
  height: 40px;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35));
  transition: transform .18s cubic-bezier(.34, 1.56, .64, 1);
  transform-origin: 50% 100%;
}

.bod-markoer__pin svg { width: 100%; height: 100%; display: block; }

.bod-markoer__nr {
  position: absolute;
  top: 5px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: .78rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  pointer-events: none;
}

.bod-markoer.is-valgt .bod-markoer__pin { transform: scale(1.28); }
.bod-markoer.is-valgt .bod-markoer__pin svg path { fill: #c62828; }

/* Egen position */
.mig-markoer { background: none; border: 0; }

.mig-markoer__prik {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1a73e8;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .18), 0 1px 4px rgba(0, 0, 0, .35);
}

/* --- Leaflet-popup i sidens stil --- */
.leaflet-popup-content-wrapper {
  border-radius: 12px;
  box-shadow: var(--skygge);
}

.leaflet-popup-content {
  margin: 12px 14px;
  font-size: .9rem;
  line-height: 1.4;
}

.popup__nr {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--groen);
  margin-bottom: 2px;
}

.popup__adresse {
  font-weight: 700;
  font-size: 1rem;
}

.popup__by {
  color: var(--tekst-svag);
  font-size: .84rem;
}

.popup__afstand {
  display: block;
  margin-top: 4px;
  font-size: .8rem;
  color: var(--tekst-svag);
}

.popup__knapper {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.popup__knap {
  flex: 1 1 auto;
  text-align: center;
  padding: 9px 10px;
  border-radius: 9px;
  font-size: .82rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

/* Leaflet farver alle links i .leaflet-container blåt – vi vinder på specificitet. */
.leaflet-container a.popup__knap--primar { background: var(--groen); color: #fff; }
.leaflet-container a.popup__knap--primar:active { background: var(--groen-moerk); }
.leaflet-container a.popup__knap--sekundar { background: #eef2ef; color: var(--tekst); }
.leaflet-container a.popup__knap--sekundar:active { background: #e2e8e4; }

/* Leaflet-kontroller væk fra vores egne elementer */
.leaflet-control-zoom { display: none; }

.leaflet-bottom.leaflet-right .leaflet-control-attribution {
  margin: 0 0 calc(var(--sheet-luk-hoejde, 76px) + var(--safe-bund) + 2px) 0;
  font-size: .62rem;
  background: rgba(255, 255, 255, .78);
  transition: margin-bottom .28s cubic-bezier(.4, 0, .2, 1);
}

/* --- Større skærme: panelet bliver et sidepanel --- */
@media (min-width: 760px) {
  .sheet {
    top: 0;
    right: auto;
    bottom: 0;
    width: 380px;
    max-height: none;
    border-radius: 0;
    box-shadow: 2px 0 18px rgba(0, 0, 0, .14);
    padding-top: var(--safe-top);
  }

  .sheet__handle { display: none; }
  .sheet__body { display: block; padding-top: 78px; }

  .topbar {
    left: 0;
    width: 380px;
    right: auto;
    background: var(--flade);
    z-index: 1002;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--kant);
  }

  .fabs { bottom: calc(var(--safe-bund) + 20px); right: 20px; }

  .leaflet-bottom.leaflet-right .leaflet-control-attribution { margin-bottom: 0; }

  .leaflet-control-zoom {
    display: block;
    margin-left: 396px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}
