/* ==========================================================================
   Geoportal Rodenkirchen.de – Karte
   Nutzt die Design-Tokens aus app.css (--rk-*), damit Hell/Dunkel automatisch passt.
   ========================================================================== */

body.page-map main { padding: 0; }
body.page-map { overflow-x: clip; }
body.page-map .servicebar { display: none; }
body.rk-map-locked { overflow: hidden; }

.rk-geoportal {
  --rk-panel-w: 320px;
  height: var(--rk-map-h, calc(100vh - 140px));
  display: flex;
  flex-direction: column;
  background: var(--rk-bg);
  position: relative;
}
.rk-geoportal.is-fullscreen,
.rk-geoportal:fullscreen {
  position: fixed; inset: 0; z-index: 2000; height: 100vh; height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- Kopfzeile: Suche + Werkzeuge ---------- */
.rk-maptop {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
  padding: .6rem 12px; border-bottom: 1px solid var(--rk-border); background: var(--rk-bg);
  position: relative; z-index: 1010;
}
.rk-search { position: relative; flex: 1 1 320px; min-width: 0; }
.rk-search .form-control {
  height: 46px; padding-left: 2.6rem; border-radius: 999px; border: 1.5px solid var(--rk-border-strong);
  background: var(--rk-surface); color: var(--rk-text); font-weight: 500;
}
.rk-search .form-control:focus { border-color: var(--rk-primary); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--rk-primary) 25%, transparent); background: var(--rk-bg); }
.rk-search__glass { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--rk-text-muted); pointer-events: none; }
.rk-search__results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: .35rem; list-style: none;
  background: var(--rk-bg); border: 1px solid var(--rk-border); border-radius: var(--rk-radius);
  box-shadow: 0 14px 40px rgba(10, 20, 30, .18); max-height: min(60vh, 420px); overflow: auto; z-index: 1100;
}
.rk-search__item { display: flex; gap: .75rem; align-items: center; padding: .55rem .6rem; border-radius: 10px; cursor: pointer; }
.rk-search__item:hover, .rk-search__item[aria-selected="true"] { background: var(--rk-surface-2); }
.rk-search__icon { flex: 0 0 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--c) 14%, var(--rk-bg)); color: var(--c); }
.rk-search__text { min-width: 0; display: flex; flex-direction: column; }
.rk-search__text strong { font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rk-search__text small { color: var(--rk-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rk-search__hint { padding: .6rem; color: var(--rk-text-muted); font-size: .9rem; }

.rk-tools { display: flex; gap: .4rem; flex-wrap: nowrap; position: relative; }
.rk-tool {
  display: inline-flex; align-items: center; gap: .45rem; height: 46px; padding: 0 1rem; border-radius: 999px;
  border: 1.5px solid var(--rk-border-strong); background: var(--rk-bg); color: var(--rk-text); font-weight: 700; font-size: .9rem; white-space: nowrap;
  flex: 0 0 auto; position: relative;
}
.rk-tool:hover { background: var(--rk-surface); }
.rk-tool:focus-visible { outline: 3px solid var(--rk-primary); outline-offset: 2px; }
.rk-tool[aria-expanded="true"], .rk-tool[aria-pressed="true"] { background: var(--rk-primary); color: var(--rk-on-primary); border-color: var(--rk-primary); }
.rk-tool:disabled { opacity: .6; }
.rk-tool--icon { width: 46px; padding: 0; justify-content: center; }
.rk-tool--layers { display: none; }
.rk-tool__badge:empty { display: none; }
.rk-tool__badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--rk-accent); color: #18232E; font-size: .72rem; display: inline-flex; align-items: center; justify-content: center; }

/* ---------- Körper: Ebenen-Leiste + Karte ---------- */
.rk-mapbody { flex: 1 1 auto; min-height: 0; display: flex; position: relative; overflow: hidden; }
.rk-mapwrap { flex: 1 1 auto; position: relative; min-width: 0; }
.rk-map { position: absolute; inset: 0; background: var(--rk-surface); }
.rk-map:focus-visible { outline: 3px solid var(--rk-primary); outline-offset: -3px; }
.rk-map__fallback { padding: 2rem; text-align: center; }

.rk-layers {
  flex: 0 0 var(--rk-panel-w); display: flex; flex-direction: column; min-height: 0;
  background: var(--rk-bg); border-right: 1px solid var(--rk-border); z-index: 1005;
}
.rk-layers__head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1rem .4rem; }
.rk-layers__head .btn-close { display: none; }
.rk-layers__list { flex: 1 1 auto; overflow: auto; padding: 0 .6rem .6rem; overscroll-behavior: contain; }
.rk-layers__group { margin: .4rem 0 .6rem; }
.rk-layers__group legend { font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--rk-text-muted); padding: .4rem .5rem; margin: 0; }
.rk-layers__note { font-size: .72rem; color: var(--rk-text-muted); padding: .6rem 1rem; margin: 0; border-top: 1px solid var(--rk-border); }

.rk-layer { border-radius: 12px; }
.rk-layer.is-on { background: color-mix(in srgb, var(--c) 8%, var(--rk-bg)); }
.rk-layer__row { display: flex; align-items: center; gap: .65rem; min-height: 48px; padding: .3rem .5rem; cursor: pointer; border-radius: 12px; }
.rk-layer__row:hover { background: var(--rk-surface); }
.rk-layer__row .form-check-input { margin: 0; flex: 0 0 auto; width: 1.25rem; height: 1.25rem; }
.rk-layer__row .form-check-input:checked { background-color: var(--c); border-color: var(--c); }
.rk-layer__icon { flex: 0 0 32px; height: 32px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--c) 15%, var(--rk-bg)); color: var(--c); }
[data-theme="dark"] .rk-layer__icon { color: color-mix(in srgb, var(--c) 55%, white); }
.rk-layer__label { flex: 1 1 auto; font-weight: 600; }
.rk-layer.has-filter .rk-layer__label::after { content: " · gefiltert"; font-weight: 500; font-size: .78rem; color: var(--rk-text-muted); }
.rk-layer__count { font-size: .8rem; font-weight: 700; color: var(--rk-text-muted); font-variant-numeric: tabular-nums; }
.rk-layer__msg { font-size: .8rem; color: var(--rk-text-muted); padding: 0 .6rem .4rem 3.9rem; }
.rk-layer__filters { padding: .1rem .6rem .7rem 3.9rem; display: grid; gap: .45rem; }
.rk-layer__filters .form-check { margin: 0; font-size: .9rem; display: flex; align-items: center; gap: .5rem; padding-left: 0; }
.rk-layer__filters .form-check .form-check-input { margin: 0; float: none; flex: 0 0 auto; }
.rk-layer__select { display: grid; gap: .15rem; font-size: .8rem; color: var(--rk-text-muted); font-weight: 600; }
.rk-layer__select .form-select { font-size: .9rem; }

/* ---------- Marker ---------- */
.rk-pin-wrap { background: none; border: 0; }
.rk-pin {
  --c: var(--rk-primary);
  width: 34px; height: 34px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); margin: 2px 0 0;
  display: flex; align-items: center; justify-content: center; background: var(--c); color: #fff;
  border: 2.5px solid #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .3); transition: transform .15s;
}
.rk-pin i { transform: rotate(45deg); font-size: 14px; }
.rk-pin.is-selected { transform: rotate(-45deg) scale(1.25); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 35%, transparent), 0 4px 12px rgba(0, 0, 0, .35); }
.rk-pin--place { --c: #18232E; }
.leaflet-marker-icon:focus-visible .rk-pin { outline: 3px solid var(--rk-accent); outline-offset: 2px; }
.leaflet-marker-icon:focus { outline: none; }

.rk-cluster { background: none; }
.rk-cluster span {
  width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--c); color: #fff; font-weight: 800; font-size: .9rem;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--c) 30%, transparent), 0 3px 8px rgba(0, 0, 0, .3); border: 2px solid #fff;
}
.rk-shape { cursor: pointer; }

.rk-me { background: none; }
.rk-me span { display: block; width: 22px; height: 22px; border-radius: 50%; background: #1A73E8; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(26, 115, 232, .25); }
.rk-me-radius { fill: #1A73E8; fill-opacity: .08; stroke: #1A73E8; stroke-opacity: .4; stroke-width: 1.5; stroke-dasharray: 4 4; }

/* ---------- Popup (Desktop) & Inhalte (auch im Sheet) ---------- */
.rk-leaflet-popup .leaflet-popup-content-wrapper { border-radius: 16px; background: var(--rk-bg); color: var(--rk-text); box-shadow: 0 14px 40px rgba(10, 20, 30, .22); }
.rk-leaflet-popup .leaflet-popup-tip { background: var(--rk-bg); }
.rk-leaflet-popup .leaflet-popup-content { margin: 16px 18px; font-family: var(--rk-font); font-size: .95rem; line-height: 1.45; }
.rk-leaflet-popup a.leaflet-popup-close-button { width: 32px; height: 32px; font-size: 22px; color: var(--rk-text-muted); }

.rk-pop__head { margin-bottom: .5rem; padding-right: 1.2rem; }
.rk-pop__badge { display: inline-flex; gap: .35rem; align-items: center; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--c); }
[data-theme="dark"] .rk-pop__badge { color: color-mix(in srgb, var(--c) 55%, white); }
.rk-pop__state { display: inline-block; margin-left: .4rem; font-size: .72rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px; background: var(--rk-surface); color: var(--rk-text-muted); }
.rk-pop__state.is-live { background: var(--rk-green-soft); color: var(--rk-success); }
.rk-pop__state.is-free { background: var(--rk-yellow-soft); color: var(--rk-warning); }
.rk-pop__state.is-warn { background: var(--rk-red-soft); color: var(--rk-danger); }
.rk-pop__title { font-size: 1.1rem; font-weight: 800; margin: .25rem 0 .15rem; line-height: 1.25; }
.rk-pop__sub { margin: 0; color: var(--rk-text-muted); font-size: .88rem; }
.rk-pop__logo { float: right; border-radius: 10px; object-fit: cover; margin: 0 0 .5rem .5rem; }
.rk-pop__text { margin: .4rem 0; }
.rk-pop__facts { list-style: none; padding: 0; margin: .5rem 0; display: grid; gap: .35rem; }
.rk-pop__facts li { display: flex; gap: .55rem; align-items: baseline; }
.rk-pop__facts i { width: 1rem; color: var(--rk-text-muted); text-align: center; }
.rk-pop__h { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--rk-text-muted); margin: .7rem 0 .3rem; }
.rk-pop__events { list-style: none; padding: 0; margin: 0 0 .5rem; display: grid; gap: .3rem; }
.rk-pop__events li { display: flex; justify-content: space-between; gap: .5rem; }
.rk-pop__events small { color: var(--rk-text-muted); white-space: nowrap; }
.rk-pop__big { font-size: 2rem; font-weight: 800; margin: .2rem 0; }
.rk-pop__big small { font-size: 1rem; color: var(--rk-text-muted); }
.rk-pop__spark { width: 100%; height: 40px; }
.rk-pop__source { font-size: .75rem; color: var(--rk-text-muted); margin: .4rem 0; }
.rk-pop__actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .7rem; }
.rk-pop__actions .btn { border-radius: 999px; font-weight: 700; min-height: 36px; display: inline-flex; align-items: center; gap: .35rem; }
.rk-pop__actions .btn-primary { color: var(--rk-on-primary); }

/* ---------- Detail-/Listen-Sheet ----------
   Desktop: schwebende Karte rechts. Smartphone: Bottom-Sheet. */
.rk-sheet {
  position: absolute; z-index: 1020; top: 12px; right: 12px; bottom: 12px; width: 380px; max-width: calc(100% - 24px);
  display: flex; flex-direction: column; background: var(--rk-bg); color: var(--rk-text);
  border-radius: 20px; box-shadow: 0 18px 50px rgba(10, 20, 30, .25); border: 1px solid var(--rk-border);
  opacity: 0; transform: translateX(16px); transition: opacity .2s, transform .25s ease;
}
.rk-sheet.is-open { opacity: 1; transform: none; }
.rk-sheet__handle { display: none; }
.rk-sheet__head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .9rem 1rem .4rem 1.1rem; }
.rk-sheet__title { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--rk-text-muted); margin: 0; }
.rk-sheet__body { flex: 1 1 auto; overflow: auto; padding: 0 1.1rem 1.1rem; overscroll-behavior: contain; }
.rk-sheet .rk-pop__head { padding-right: 0; }

.rk-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: .25rem; }
.rk-list__item { width: 100%; display: flex; align-items: center; gap: .75rem; padding: .55rem .5rem; border: 0; border-radius: 12px; background: none; color: inherit; text-align: left; min-height: 52px; }
.rk-list__item:hover, .rk-list__item:focus-visible { background: var(--rk-surface); }
.rk-list__icon { flex: 0 0 36px; height: 36px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--c) 15%, var(--rk-bg)); color: var(--c); }
.rk-list__text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.rk-list__text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rk-list__text small { color: var(--rk-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rk-list__dist { font-weight: 700; font-size: .85rem; color: var(--rk-text-muted); white-space: nowrap; }

.rk-toast {
  position: absolute; z-index: 1030; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: min(90%, 460px);
  background: #18232E; color: #fff; padding: .7rem 1rem; border-radius: 14px; font-size: .9rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
}

/* ---------- Leaflet an das Design anpassen ---------- */
.rk-map .leaflet-control-zoom a, .rk-map .leaflet-bar a { width: 40px; height: 40px; line-height: 40px; background: var(--rk-bg); color: var(--rk-text); border-color: var(--rk-border); }
.rk-map .leaflet-bar { border: 1px solid var(--rk-border); border-radius: 12px; overflow: hidden; box-shadow: 0 4px 12px rgba(0, 0, 0, .12); }
.rk-map .leaflet-control-attribution { font-size: .68rem; background: color-mix(in srgb, var(--rk-bg) 85%, transparent); color: var(--rk-text-muted); }
.rk-map .leaflet-control-attribution a { color: var(--rk-primary); }
.rk-map .leaflet-control-scale-line { background: color-mix(in srgb, var(--rk-bg) 80%, transparent); color: var(--rk-text); border-color: var(--rk-text-muted); }
.rk-map .leaflet-tooltip { background: var(--rk-bg); color: var(--rk-text); border-color: var(--rk-border); border-radius: 10px; font-family: var(--rk-font); }

/* Dunkelmodus: OSM-Kacheln invertieren statt zweiter Kachelquelle (keine Zusatzkosten, kein Dritter) */
.rk-map--dark { background: #0f161d; }
.rk-map--dark .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.88) saturate(.7); }

/* ---------- Smartphone & Tablet ---------- */
@media (max-width: 991.98px) {
  .rk-tool--layers { display: inline-flex; }
  .rk-layers {
    position: absolute; left: 0; right: 0; bottom: 0; max-height: 75%; z-index: 1025;
    border-radius: 22px 22px 0 0; border: 1px solid var(--rk-border); box-shadow: 0 -12px 40px rgba(10, 20, 30, .25);
    transform: translateY(105%); visibility: hidden; transition: transform .25s ease, visibility 0s .25s;
  }
  .rk-layers.is-open { transform: none; visibility: visible; transition: transform .25s ease; }
  .rk-layers__head .btn-close { display: block; }
}

@media (max-width: 767.98px) {
  .rk-maptop { padding: .5rem 10px; gap: .4rem; }
  .rk-search { flex-basis: 100%; }
  .rk-search .form-control { height: 44px; }
  .rk-tools { width: 100%; min-width: 0; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .rk-tools::-webkit-scrollbar { display: none; }
  .rk-tool { height: 40px; padding: 0 .85rem; font-size: .85rem; }
  .rk-tool--icon { width: 40px; padding: 0; }
  .rk-tool--home { display: none; }

  .rk-sheet {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; max-width: none; max-height: 55%;
    border-radius: 22px 22px 0 0; border-bottom: 0; transform: translateY(100%); opacity: 1;
  }
  .rk-sheet.is-open { transform: none; }
  .rk-sheet.is-full { max-height: calc(100% - 12px); height: calc(100% - 12px); }
  .rk-sheet__handle { display: flex; justify-content: center; padding: 10px 0 2px; cursor: grab; touch-action: none; }
  .rk-sheet__handle span { width: 44px; height: 5px; border-radius: 3px; background: var(--rk-border-strong); }
  .rk-sheet__head { padding-top: .3rem; }
  .rk-map .leaflet-bottom.leaflet-right { margin-bottom: 4px; }
}

/* Schließen-Kreuz im Dunkelmodus sichtbar machen */
[data-theme="dark"] .rk-geoportal .btn-close { filter: invert(1) grayscale(1) brightness(2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .rk-geoportal .btn-close { filter: invert(1) grayscale(1) brightness(2); } }
.rk-sheet__close:focus:not(:focus-visible) { box-shadow: none; }

/* ---------- Routenplaner ---------- */
.rk-route { display: grid; gap: .8rem; }
.rk-route__to { display: flex; gap: .7rem; align-items: center; margin: 0; padding: .6rem .8rem; border-radius: var(--rk-radius); background: var(--rk-surface); }
.rk-route__to i { color: #B42318; font-size: 1.2rem; }
.rk-route__to span { display: flex; flex-direction: column; line-height: 1.25; }
.rk-route__to small { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--rk-text-muted); font-weight: 700; }
.rk-route__from { position: relative; }
.rk-route__list { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; }
.rk-route__list li { display: flex; gap: .6rem; align-items: flex-start; padding: .55rem .7rem; cursor: pointer; }
.rk-route__list li span { display: flex; flex-direction: column; }
.rk-route__list li small { color: var(--rk-text-muted); }
.rk-route__list li:hover, .rk-route__list li:focus { background: var(--rk-blue-soft); outline: none; }
.rk-route__modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; border: 0; padding: 0; margin: 0; }
.rk-route__mode { display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: .55rem .3rem; border: 1px solid var(--rk-border-strong); border-radius: var(--rk-radius); font-weight: 700; font-size: .88rem; cursor: pointer; background: var(--rk-bg); }
.rk-route__mode i { font-size: 1.15rem; }
.btn-check:checked + .rk-route__mode { background: var(--rk-primary); border-color: var(--rk-primary); color: var(--rk-on-primary); }
.btn-check:focus-visible + .rk-route__mode { outline: 3px solid color-mix(in srgb, var(--rk-primary) 40%, transparent); outline-offset: 2px; }
.rk-route__summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .7rem; padding: .7rem .9rem; border-radius: var(--rk-radius); background: var(--rk-blue-soft); }
.rk-route__summary strong { font-size: 1.5rem; }
.rk-route__steps summary { font-weight: 700; cursor: pointer; padding: .3rem 0; }
.rk-route__steps ol { margin: .4rem 0 0; padding-left: 1.3rem; display: grid; gap: .35rem; max-height: 320px; overflow: auto; }
.rk-route__steps li small { display: block; color: var(--rk-text-muted); }
.rk-route__ext { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .4rem; }
.rk-route__ext > span { flex-basis: 100%; }
.rk-route__src { font-size: .75rem; color: var(--rk-text-muted); margin: .6rem 0 0; }
.rk-pin--route { --c: #B42318; }
.rk-route-chip { position: absolute; top: .7rem; left: .7rem; z-index: 800; display: flex; align-items: stretch; border-radius: 999px; background: var(--rk-bg); box-shadow: 0 4px 16px rgba(0,0,0,.2); overflow: hidden; }
.rk-route-chip button { border: 0; background: transparent; color: var(--rk-text); padding: .45rem .8rem; display: inline-flex; gap: .4rem; align-items: center; }
.rk-route-chip__open i { color: var(--rk-primary); }
.rk-route-chip__close { border-left: 1px solid var(--rk-border) !important; }
