/* ============================================================
   Lehrkräfte-Stellen Sachsen-Anhalt — „Liquid Glass" UI
   ============================================================ */

:root {
  --accent: #f5b400;          /* dezenter Sachsen-Anhalt-Gelbton */
  --accent-deep: #c98a00;
  --ink: #1c1c22;
  --ink-soft: #54545e;

  /* Glas-Tokens (hell) */
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-bg-strong: rgba(255, 255, 255, 0.72);
  --glass-brd: rgba(255, 255, 255, 0.65);
  --glass-hi: rgba(255, 255, 255, 0.9);     /* Lichtkante oben */
  --glass-shadow: 0 10px 34px rgba(20, 24, 40, 0.18);
  --blur: blur(22px) saturate(185%);

  --r-lg: 24px;
  --r-md: 16px;
  --r-sm: 12px;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f3f3f6;
    --ink-soft: #b6b6c2;
    --glass-bg: rgba(28, 30, 38, 0.52);
    --glass-bg-strong: rgba(30, 32, 42, 0.74);
    --glass-brd: rgba(255, 255, 255, 0.16);
    --glass-hi: rgba(255, 255, 255, 0.22);
    --glass-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#map {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #dfe7ee;
}

/* ---- Glas-Grundbaustein ----------------------------------- */
.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-brd);
  box-shadow: var(--glass-shadow),
              inset 0 1px 0 var(--glass-hi),
              inset 0 0 0 0.5px rgba(255, 255, 255, 0.08);
}
.panel { border-radius: var(--r-lg); }

/* dünne, helle „Specular"-Kante oben über die ganze Breite */
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(160deg, rgba(255,255,255,.85), rgba(255,255,255,0) 40%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  opacity: .7;
}

/* ---- Kopfzeile -------------------------------------------- */
.header {
  position: fixed;
  z-index: 500;
  top: calc(14px + var(--safe-t));
  left: calc(14px + var(--safe-l));
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px 10px 14px;
}
.header-main { display: flex; align-items: center; gap: 12px; }
.mark {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  color: var(--accent-deep);
  background: radial-gradient(120% 120% at 30% 20%, rgba(245,180,0,.35), rgba(245,180,0,.08));
  border-radius: 13px;
  box-shadow: inset 0 1px 0 var(--glass-hi);
}
.header-text h1 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.header-text p  { margin: 1px 0 0; font-size: 12px; color: var(--ink-soft); }

.count-pill { font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
.count-pill strong { color: var(--ink); font-weight: 680; }

/* ---- Chips / Buttons -------------------------------------- */
.chip {
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-brd);
  box-shadow: inset 0 1px 0 var(--glass-hi);
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
}
.chip:hover { transform: translateY(-1px); }
.chip:active { transform: translateY(0) scale(.98); }
.chip.ghost { padding: 8px 12px; }

/* ---- Sidebar ---------------------------------------------- */
.sidebar {
  position: fixed;
  z-index: 480;
  left: calc(14px + var(--safe-l));
  top: calc(92px + var(--safe-t));
  bottom: calc(58px + var(--safe-b));
  width: 360px;
  max-width: calc(100vw - 28px);
  padding: 14px 8px 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform .32s cubic-bezier(.4,.5,.16,1), opacity .25s ease;
}
.sidebar.collapsed { transform: translateX(calc(-100% - 24px)); opacity: 0; pointer-events: none; }

.search-wrap {
  position: relative;
  margin-right: 6px;
}
.search-ic {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--ink-soft); pointer-events: none;
}
#search {
  width: 100%;
  padding: 11px 12px 11px 38px;
  border-radius: var(--r-md);
  border: 1px solid var(--glass-brd);
  background: var(--glass-bg-strong);
  color: var(--ink);
  font-size: 14px;
  outline: none;
  box-shadow: inset 0 1px 0 var(--glass-hi);
}
#search::placeholder { color: var(--ink-soft); }
#search:focus { border-color: rgba(245,180,0,.7); box-shadow: inset 0 1px 0 var(--glass-hi), 0 0 0 3px rgba(245,180,0,.22); }

.filters { display: flex; flex-direction: column; gap: 12px; margin-right: 6px; }
.filter-label {
  display: block;
  font-size: 11px; font-weight: 640; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-soft); margin-bottom: 7px;
}
.chips { display: flex; flex-wrap: wrap; gap: 7px; }

.fchip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12.5px; font-weight: 520;
  cursor: pointer; user-select: none;
  background: rgba(255,255,255,.34);
  border: 1px solid var(--glass-brd);
  color: var(--ink);
  transition: background .15s ease, border-color .15s, transform .1s;
}
@media (prefers-color-scheme: dark){ .fchip{ background: rgba(255,255,255,.07);} }
.fchip:active { transform: scale(.96); }
.fchip .dot { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255,255,255,.5); }
.fchip.off { opacity: .42; }
.fchip.off .dot { box-shadow: none; filter: grayscale(.6); }
.fchip.on { background: rgba(255,255,255,.7); border-color: rgba(255,255,255,.85); }
@media (prefers-color-scheme: dark){ .fchip.on{ background: rgba(255,255,255,.16);} }

.select-wrap {
  border-radius: var(--r-md);
  padding: 0;
  position: relative;
  background: var(--glass-bg-strong);
}
.select-wrap::after {
  content: "▾"; position: absolute; right: 13px; top: 50%; transform: translateY(-50%);
  color: var(--ink-soft); pointer-events: none; font-size: 12px;
}
#lkr-select {
  width: 100%; appearance: none; -webkit-appearance: none;
  background: transparent; border: 0; outline: none;
  padding: 11px 30px 11px 13px;
  font-size: 14px; color: var(--ink); cursor: pointer; border-radius: var(--r-md);
}
#lkr-select option { color: #1c1c22; }

/* ---- Umkreissuche ----------------------------------------- */
.umkreis-row { display: flex; gap: 7px; flex-wrap: wrap; }
#locate-btn { display: inline-flex; align-items: center; gap: 7px; font-weight: 560; }
.chip.on {
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  color: #2a1d00; border-color: rgba(255,255,255,.5);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 4px 12px rgba(245,180,0,.3);
}
#umkreis-controls { margin-top: 12px; }
#radius-range {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px;
  border-radius: 6px; outline: none; cursor: pointer;
  background: rgba(120,120,140,.32);
}
#radius-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 19px; height: 19px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent);
  box-shadow: 0 1px 5px rgba(0,0,0,.35); cursor: pointer;
}
#radius-range::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent);
  box-shadow: 0 1px 5px rgba(0,0,0,.35); cursor: pointer;
}
.umkreis-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; font-size: 13px; color: var(--ink-soft); }
.umkreis-meta strong { color: var(--ink); font-weight: 680; }
.umkreis-hint { font-size: 11.5px; color: var(--ink-soft); line-height: 1.45; margin: 9px 2px 0 0; }

/* Mittelpunkt-Pin der Umkreissuche */
.center-pin {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #fff 0 3px, var(--accent) 4px 7px, rgba(245,180,0,.0) 8px);
  border: 2.5px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,.4), inset 0 0 0 2px rgba(255,255,255,.85);
  cursor: grab;
}

.list-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 2px 6px -2px 0; gap: 8px;
}
#list-summary { font-size: 12px; color: var(--ink-soft); }
.link-btn {
  background: none; border: 0; padding: 0; cursor: pointer;
  font-size: 12px; color: var(--accent-deep); font-weight: 600;
}

/* ---- Ergebnisliste ---------------------------------------- */
.results {
  list-style: none; margin: 0; padding: 2px 6px 6px 0;
  overflow-y: auto; flex: 1;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.results::-webkit-scrollbar { width: 8px; }
.results::-webkit-scrollbar-thumb { background: rgba(120,120,140,.35); border-radius: 8px; }

.result {
  display: grid; grid-template-columns: auto 1fr auto; gap: 11px;
  align-items: start;
  padding: 11px 11px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .14s ease, transform .1s ease;
}
.result + .result { margin-top: 3px; }
.result:hover { background: rgba(255,255,255,.42); }
@media (prefers-color-scheme: dark){ .result:hover{ background: rgba(255,255,255,.08);} }
.result.active { background: rgba(245,180,0,.18); box-shadow: inset 0 0 0 1px rgba(245,180,0,.4); }
.result .tag { width: 11px; height: 11px; border-radius: 50%; margin-top: 4px; box-shadow: 0 0 0 2px rgba(255,255,255,.55); }
.result .r-title { font-size: 13.5px; font-weight: 600; line-height: 1.25; letter-spacing: -.01em; }
.result .r-sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.result .r-fach { font-size: 12px; color: var(--ink); margin-top: 3px; font-weight: 520; }
.result .r-dist { align-self: center; font-size: 12px; font-weight: 660; color: var(--accent-deep); white-space: nowrap; }
@media (prefers-color-scheme: dark) { .result .r-dist { color: #f5c542; } }

.empty { padding: 24px 10px; text-align: center; color: var(--ink-soft); font-size: 13px; }

/* ---- Detailkarte ------------------------------------------ */
.detail {
  position: fixed;
  z-index: 600;
  right: calc(14px + var(--safe-r));
  top: calc(14px + var(--safe-t));
  width: 380px;
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 130px - var(--safe-t) - var(--safe-b));
  padding: 18px 18px 16px;
  overflow-y: auto;
  background: var(--glass-bg-strong);
}
.detail-close {
  position: absolute; top: 12px; right: 12px;
  width: 30px; height: 30px; padding: 0;
  font-size: 18px; line-height: 1; display: grid; place-items: center;
}
.d-form { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.d-form .dot { width: 10px; height: 10px; border-radius: 50%; }
.detail h2 { margin: 10px 0 2px; font-size: 19px; letter-spacing: -.02em; line-height: 1.2; padding-right: 26px; }
.d-addr { font-size: 13px; color: var(--ink-soft); margin: 4px 0 14px; line-height: 1.45; }
.d-grid { display: grid; grid-template-columns: 112px 1fr; gap: 8px 12px; font-size: 13px; }
.d-grid dt { color: var(--ink-soft); }
.d-grid dd { margin: 0; font-weight: 520; }
.d-frist { color: var(--accent-deep); font-weight: 700; }
@media (prefers-color-scheme: dark) { .d-frist { color: #f5c542; } }
.d-wiederholung {
  margin: 12px 0 0; padding: 9px 12px; border-radius: 12px;
  font-size: 12.5px; font-weight: 560; line-height: 1.4;
  color: #7a4f00; background: rgba(245, 180, 0, 0.16);
  border: 1px solid rgba(245, 180, 0, 0.4);
}
@media (prefers-color-scheme: dark) {
  .d-wiederholung { color: #f5c542; background: rgba(245, 180, 0, 0.12); border-color: rgba(245, 180, 0, 0.3); }
}
.r-wdh {
  display: inline-block; font-size: 11px; font-weight: 700;
  color: var(--accent-deep); background: rgba(245, 180, 0, 0.18);
  border-radius: 6px; padding: 0 5px; margin-left: 3px;
}
@media (prefers-color-scheme: dark) { .r-wdh { color: #f5c542; background: rgba(245, 180, 0, 0.16); } }
.d-section { margin-top: 14px; }
.d-section h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); margin: 0 0 5px; }
.d-section p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--ink); white-space: pre-line; }

/* ---- Cluster-Liste (mehrere Stellen an einem Standort) ---- */
.cl-list { list-style: none; margin: 12px 0 0; padding: 0; }
.cl-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 11px; align-items: start;
  padding: 10px 10px; border-radius: 12px; cursor: pointer;
  transition: background .14s ease, transform .1s ease;
}
.cl-item + .cl-item { margin-top: 2px; }
.cl-item:hover { background: rgba(255, 255, 255, 0.5); }
@media (prefers-color-scheme: dark) { .cl-item:hover { background: rgba(255, 255, 255, 0.08); } }
.cl-item:active { transform: scale(0.99); }
.cl-item .tag { width: 11px; height: 11px; border-radius: 50%; margin-top: 4px; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55); }
.cl-fach { font-size: 13.5px; font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; }
.cl-sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.cl-back {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 0 8px;
  background: none; border: 0; padding: 4px 2px 4px 0; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--accent-deep);
}
.cl-back:hover { text-decoration: underline; }
@media (prefers-color-scheme: dark) { .cl-back { color: #f5c542; } }
.d-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 15px; border-radius: 12px; font-size: 13px; font-weight: 600;
  text-decoration: none; cursor: pointer; border: 1px solid var(--glass-brd);
}
.btn.primary { background: linear-gradient(180deg, var(--accent), var(--accent-deep)); color: #2a1d00; border-color: rgba(255,255,255,.4); box-shadow: 0 6px 16px rgba(245,180,0,.35), inset 0 1px 0 rgba(255,255,255,.5); }
.btn.secondary { background: var(--glass-bg); color: var(--ink); }

/* ---- Footer ----------------------------------------------- */
.footer {
  position: fixed;
  z-index: 450;
  left: calc(14px + var(--safe-l));
  bottom: calc(14px + var(--safe-b));
  padding: 7px 13px;
  font-size: 11.5px;
  color: var(--ink-soft);
  display: flex; align-items: center; gap: 7px;
}
.dot-sep { opacity: .5; }
.footer a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .15s, border-color .15s;
}
.footer a:hover { color: var(--ink); border-bottom-color: currentColor; }

/* Pflicht-Links in der Sidebar: nur mobil (Desktop nutzt den Footer) */
.sidebar-legal { display: none; }
.sidebar-legal a { color: var(--ink-soft); text-decoration: none; }
.sidebar-legal a:hover, .sidebar-legal a:active { color: var(--ink); }

/* ---- Marker / Cluster ------------------------------------- */
.school-marker {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.95);
  box-shadow: 0 2px 6px rgba(0,0,0,.35), 0 0 0 1px rgba(0,0,0,.06);
}
.cluster-ico {
  display: grid; place-items: center;
  border-radius: 50%;
  color: #fff; font-weight: 680; font-size: 13px;
  background: rgba(40,44,60,.42);
  -webkit-backdrop-filter: blur(8px) saturate(160%);
  backdrop-filter: blur(8px) saturate(160%);
  border: 1.5px solid rgba(255,255,255,.7);
  box-shadow: 0 4px 14px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.5);
}
.cluster-ico span { text-shadow: 0 1px 2px rgba(0,0,0,.4); }

/* Leaflet-Popup im Glas-Look */
.leaflet-popup-content-wrapper {
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-brd);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-hi);
  border-radius: var(--r-md);
  color: var(--ink);
}
.leaflet-popup-tip { background: var(--glass-bg-strong); }
.leaflet-popup-content { margin: 11px 14px; font-size: 13px; }
.leaflet-popup-content b { font-weight: 640; }
.lp-sub { color: var(--ink-soft); font-size: 12px; }
.lp-link { color: var(--accent-deep); font-weight: 600; cursor: pointer; }
.leaflet-control-zoom a {
  background: var(--glass-bg-strong) !important;
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-color: var(--glass-brd) !important;
  color: var(--ink) !important;
}
.leaflet-bar { box-shadow: var(--glass-shadow) !important; border-radius: 12px !important; overflow: hidden; }
/* Zoomleiste etwas über die Attribution heben */
.leaflet-bottom.leaflet-right .leaflet-control-zoom { margin-bottom: 22px; margin-right: 14px; }
.leaflet-control-attribution {
  background: rgba(255,255,255,.55) !important;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border-radius: 8px 0 0 0; font-size: 10px;
}

/* ---- Mobile: Sidebar als Bottom-Sheet --------------------- */
@media (max-width: 720px) {
  .header { right: calc(14px + var(--safe-r)); justify-content: space-between; }
  .sidebar {
    left: 0; right: 0; bottom: 0; top: auto;
    width: 100%; max-width: 100%;
    max-height: 56vh;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    padding: 12px 8px calc(10px + var(--safe-b)) 14px;
  }
  .sidebar.collapsed { transform: translateY(calc(100% + 24px)); }
  .detail { left: 14px; right: 14px; width: auto; top: auto; bottom: 14px; max-height: 70vh; }
  .footer { display: none; }
  .sidebar-legal {
    display: flex; align-items: center; justify-content: center; gap: 7px;
    margin-right: 6px;
    padding: 8px 0 calc(2px + var(--safe-b));
    font-size: 12px; color: var(--ink-soft);
    border-top: 1px solid var(--glass-brd);
  }
  .leaflet-control-zoom { display: none; } /* Touch: Pinch-to-Zoom */
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
