/* Funktionen für Gäste am Berg (map/gast.js): Standort, Notruf, Wege, Verbund-Umschalter.
   Wird von gast.js nur geladen, wenn die Funktionen aktiv sind. */

:root,
.mp-map {
  --gast-blue: #0a7cff;
  --gast-route: #8b2cf5;
  --gast-red: #dc2626;
  --gast-bottom: 120px;
}

/* ---------- Blatt (Wohin?, Route, Notruf) ---------- */

.gast-sheet {
  position: absolute;
  left: 12px;
  bottom: var(--gast-bottom);
  z-index: 6;
  width: 380px;
  max-height: calc(100% - var(--gast-bottom) - 150px);
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--glass-ink, #141b25);
  overflow: hidden;
}

.gast-sheet[hidden] {
  display: none;
}

.gast-sheet header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 6px 18px;
}

.gast-sheet h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.3;
}

.gast-sheet--danger h2 {
  color: var(--gast-red);
}

.gast-sheet__close {
  flex: none;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 27, 37, 0.07);
  color: inherit;
  cursor: pointer;
}

.gast-sheet__body {
  padding: 4px 18px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: 0.9rem;
  line-height: 1.45;
}

.gast-sheet__body p {
  margin: 0 0 10px;
}

.gast-note {
  color: #5e6b7a;
  font-size: 0.8rem;
}

.gast-note i {
  margin-right: 4px;
}

.gast-tip {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.14);
  font-size: 0.82rem;
}

.gast-warn {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(225, 29, 46, 0.1);
  font-size: 0.85rem;
}

.gast-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 12px;
}

.gast-choices--grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.gast-choices button,
.gast-actions button,
.gast-actions a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(20, 27, 37, 0.1);
  border-radius: 12px;
  background: #fff;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.gast-choices--grid button {
  justify-content: flex-start;
}

.gast-choices button i {
  width: 18px;
  color: var(--gast-blue);
}

.gast-choices button:hover,
.gast-actions button:hover {
  border-color: var(--gast-blue);
}

.gast-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.gast-actions .gast-primary {
  flex: 1;
  border-color: var(--gast-blue);
  background: var(--gast-blue);
  color: #fff;
}

.gast-link {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 10px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--gast-blue);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

/* Schalter „Nur blaue Pisten“ */
.gast-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-weight: 600;
  cursor: pointer;
}

.gast-switch input {
  position: absolute;
  opacity: 0;
}

.gast-switch span {
  position: relative;
  width: 40px;
  height: 24px;
  border-radius: 12px;
  background: rgba(20, 27, 37, 0.18);
  transition: background 0.2s;
}

.gast-switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s;
}

.gast-switch input:checked + span {
  background: var(--gast-blue);
}

.gast-switch input:checked + span::after {
  transform: translateX(16px);
}

.gast-switch input:focus-visible + span {
  outline: 2px solid var(--gast-blue);
  outline-offset: 2px;
}

/* ---------- Route ---------- */

.gast-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
}

.gast-summary strong {
  font-size: 1.6rem;
  line-height: 1.1;
  color: var(--gast-route);
}

.gast-summary span {
  color: #5e6b7a;
}

.gast-steps {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.gast-steps li {
  position: relative;
  display: flex;
  gap: 12px;
  padding: 6px 0;
}

/* Verbindungslinie zwischen den Schritten */
.gast-steps li:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 34px;
  bottom: -6px;
  width: 2px;
  background: rgba(20, 27, 37, 0.12);
}

.gast-step__icon {
  flex: none;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: 0.75rem;
}

.gast-step__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.gast-step__text small {
  color: #5e6b7a;
}

/* ---------- Notruf ---------- */

.gast-call {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 4px 0 8px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--gast-red);
  color: #fff;
  text-decoration: none;
}

.gast-call i {
  font-size: 1.3rem;
}

.gast-call span {
  display: flex;
  flex-direction: column;
}

.gast-call strong {
  font-size: 1.1rem;
}

.gast-call small {
  opacity: 0.9;
}

.gast-call--muted {
  background: rgba(20, 27, 37, 0.06);
  color: inherit;
}

.gast-call--muted i {
  color: var(--gast-red);
}

.gast-call--muted strong {
  font-size: 0.95rem;
}

.gast-call--muted small {
  color: #5e6b7a;
  opacity: 1;
}

.gast-pos {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(20, 27, 37, 0.08);
}

.gast-pos p {
  margin: 0;
}

.gast-pos__label {
  color: #5e6b7a;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gast-pos__coords {
  margin: 4px 0 6px !important;
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.gast-pos__coords small {
  font-size: 0.85rem;
  font-weight: 500;
  color: #5e6b7a;
}

/* ---------- Standort, Auto, Hinweise ---------- */

.gast-dot {
  position: relative;
  width: 22px;
  height: 22px;
}

.gast-dot__core {
  position: absolute;
  inset: 0;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--gast-blue);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.gast-dot__pulse {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  background: rgba(10, 124, 255, 0.25);
  animation: gast-pulse 2s ease-out infinite;
}

.gast-dot--sim {
  cursor: grab;
}

@keyframes gast-spin {
  to { transform: rotate(360deg); }
}

@keyframes gast-pulse {
  from { transform: scale(0.4); opacity: 1; }
  to { transform: scale(1.4); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .gast-dot__pulse { animation: none; opacity: 0.6; }
}

.gast-car {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #141b25;
  color: #fff;
  font-size: 0.85rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.gast-toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--gast-bottom) + 60px);
  z-index: 7;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 14px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--glass-ink, #141b25);
  transform: translate(-50%, -12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}

/* Blatt offen: Hinweis oben statt über dem Blatt */
.gast-sheet-open .gast-toast {
  bottom: auto;
  top: 16px;
}

.gast-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.gast-popup-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 24px);
  margin: 4px 12px 12px;
  min-height: 40px;
  border: 0;
  border-radius: 12px;
  background: var(--gast-blue);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Verbund ---------- */

.gast-area-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 12px;
  border-radius: 12px;
  color: var(--glass-ink, #141b25);
  font: inherit;
  cursor: pointer;
}

.gast-area-label strong {
  font-size: 0.95rem;
}

.gast-area-label small {
  font-size: 0.72rem;
  color: #5e6b7a;
}

.gast-zoomed .gast-area-label {
  display: none;
}

@media (max-width: 640px) {
  /* Über der Leiste mit Suche und Filter: Man tippt unten weiter, während das Blatt offen ist */
  .gast-sheet {
    left: 8px;
    right: 8px;
    bottom: var(--gast-bottom);
    width: auto;
    max-height: calc(100% - var(--gast-bottom) - 140px);
  }

  .gast-sheet--route {
    max-height: 44%;
  }
}

/* ---------- Aufgeräumte Bedienung (.gast-ui) ---------- */

/* Unten eine Zeile: Suche („Wohin?“) und Filter-Knopf. body.gast-ui.home schlägt die Regeln der
   Startseite (map.scss, .home .mp-top:not(:has(> .mp-highlights))). */
body.gast-ui.home .mp-top {
  width: min(520px, calc(100% - var(--mp-touch) - 72px));
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "search filter";
}

.gast-ui .mp-search {
  width: 100%;
}

.gast-ui-map .mp-highlights,
.gast-ui-map .mp-highlights__list {
  display: none !important;
}

.gast-filter-btn {
  grid-area: filter;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--mp-touch, 44px);
  padding: 0 16px;
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.6));
  border-radius: 99px;
  background: var(--glass-bg, rgba(255, 255, 255, 0.55));
  -webkit-backdrop-filter: var(--glass-blur);
          backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  color: var(--glass-ink, #141b25);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.gast-subhead {
  margin: 14px 0 6px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5e6b7a;
}

.gast-choices--list {
  flex-direction: column;
}

.gast-choices--list button {
  justify-content: flex-start;
  text-align: left;
}

.gast-choices--list button i {
  color: #ffb703;
}

.gast-choices--list small {
  margin-left: auto;
  font-weight: 500;
  color: #5e6b7a;
}

/* Knopfspalte rechts: Standort, Ebenen, 3D/2D. Ganzes Gebiet und Vollbild entfallen,
   der Kompass erscheint nur bei gedrehter Karte, Plus und Minus nur mit Maus. */
.gast-ui-map .mp-ctrl[title="Ganzes Gebiet zeigen"],
.gast-ui-map .mp-ctrl-group:has(> .mp-ctrl[title^="Vollbild"]) {
  display: none;
}

.gast-ui-map:not(.gast-rotated) .maplibregl-ctrl-compass {
  display: none;
}

@media (pointer: coarse), (max-width: 640px) {
  .gast-ui-map .maplibregl-ctrl-zoom-in,
  .gast-ui-map .maplibregl-ctrl-zoom-out {
    display: none;
  }

  .gast-ui-map:not(.gast-rotated) .maplibregl-ctrl-group:has(> .maplibregl-ctrl-compass) {
    display: none;
  }
}

.gast-locate[data-mode="on"],
.gast-locate[data-mode="sim"] {
  color: var(--gast-blue);
}

.gast-locate[data-mode="busy"] i {
  animation: gast-spin 1.2s linear infinite;
}

/* Notruf ganz oben rechts, „Karte bearbeiten“ direkt links daneben (frühere Mails verweisen auf „oben rechts“) */
.gast-ui .demo-cockpit-btn {
  right: calc(var(--edge) + var(--bar) + var(--gap));
}

@media (max-width: 760px) {
  .gast-ui.has-cockpit-btn:not(.has-view-toggle) .area-picker {
    right: calc(var(--edge) + 2 * (var(--bar) + var(--gap)));
  }
}

.gast-sos {
  position: fixed;
  top: var(--edge);
  right: var(--edge);
  z-index: 1140;
  width: var(--bar);
  height: var(--bar);
  display: grid;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 6px 18px rgba(220, 38, 38, 0.35);
  cursor: pointer;
}

.gast-sos:hover {
  background: #b91c1c;
}

@media (max-width: 1180px) {
  .gast-sos {
    top: calc(var(--edge) + var(--bar) + var(--gap));
  }
}

/* Gebiete des Verbunds im Gebietswähler, eingerückt unter der Demo */
.gast-picker-parts {
  margin: 0 0 6px 14px;
  padding-left: 10px;
  border-left: 2px solid rgba(20, 27, 37, 0.1);
}

.gast-picker-parts a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 10px;
  border-radius: 10px;
  color: var(--glass-ink, #141b25);
  font-weight: 600;
  text-decoration: none;
}

.gast-picker-parts a:hover {
  background: rgba(255, 255, 255, 0.7);
}

.gast-picker-parts em {
  font-style: normal;
  font-weight: 500;
  font-size: 0.8rem;
  color: #5e6b7a;
}

@media (max-width: 640px) {
  body.gast-ui.home .mp-top {
    width: auto;
  }

  .gast-filter-btn {
    width: var(--mp-touch, 44px);
    padding: 0;
    justify-content: center;
  }

  .gast-filter-btn span {
    display: none;
  }
}

/* Pistennummer im Kreis, wie auf der Karte und den Schildern am Berg */
.gast-step__icon--ref {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* Verbund: Gebiet beim Start wählen (home.js, chooser) */
.demo-chooser__parts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 4px 0 10px;
}

.demo-chooser__parts button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid rgba(20, 27, 37, 0.1);
  border-radius: 14px;
  background: #fff;
  color: var(--glass-ink, #141b25);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.demo-chooser__parts button:hover {
  border-color: var(--glass-ink, #141b25);
}

.demo-chooser__parts strong {
  font-size: 1rem;
}

.demo-chooser__parts small {
  color: #5e6b7a;
  font-size: 0.8rem;
}

.demo-chooser__all {
  display: block;
  margin: 0 0 12px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--glass-ink, #141b25);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---------- Filter: Fenster am Knopf, Liste mit Schaltern ---------- */

.gast-sheet.gast-sheet--anchored {
  left: auto;
  right: var(--gast-anchor-right, 12px);
  width: min(300px, calc(100% - 16px));
  overflow: visible;
}

/* Pfeil zum Filter-Knopf */
.gast-sheet--anchored::after {
  content: "";
  position: absolute;
  right: var(--gast-arrow, 20px);
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: rgba(255, 255, 255, 0.95);
  transform: rotate(45deg);
  border-radius: 0 0 3px 0;
}

.gast-sheet--anchored .gast-sheet__body {
  padding-top: 0;
}

.gast-sheet--anchored .gast-subhead:first-child {
  margin-top: 2px;
}

.gast-toggles {
  display: flex;
  flex-direction: column;
}

.gast-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  border-bottom: 1px solid rgba(20, 27, 37, 0.07);
  cursor: pointer;
}

.gast-toggle:last-child {
  border-bottom: 0;
}

.gast-toggle__marker {
  width: 20px;
  display: grid;
  place-items: center;
  color: #3b4654;
}

.gast-toggle__marker .mp-chip__dot {
  opacity: 1 !important;
}

.gast-toggle__label {
  flex: 1;
  font-weight: 600;
}

.gast-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.gast-toggle__switch {
  position: relative;
  flex: none;
  width: 40px;
  height: 24px;
  border-radius: 12px;
  background: rgba(20, 27, 37, 0.18);
  transition: background 0.2s;
}

.gast-toggle__switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s;
}

.gast-toggle input:checked ~ .gast-toggle__switch {
  background: var(--glass-ink, #141b25);
}

.gast-toggle input:checked ~ .gast-toggle__switch::after {
  transform: translateX(16px);
}

.gast-toggle input:focus-visible ~ .gast-toggle__switch {
  outline: 2px solid var(--gast-blue);
  outline-offset: 2px;
}

/* Ausgeblendetes wirkt zurückgenommen */
.gast-toggle:has(input:not(:checked)) .gast-toggle__label,
.gast-toggle:has(input:not(:checked)) .gast-toggle__marker {
  opacity: 0.45;
}

/* Knopf zeigt, dass etwas ausgeblendet ist */
.gast-filter-btn.is-filtered {
  background: var(--glass-ink, #141b25);
  border-color: var(--glass-ink, #141b25);
  color: #fff;
}

.gast-filter-btn[aria-expanded="true"] {
  box-shadow: 0 0 0 3px rgba(20, 27, 37, 0.15), var(--glass-shadow);
}

.gast-filter-btn__count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #fff;
  color: var(--glass-ink, #141b25);
  font-size: 0.75rem;
}

.gast-filter-btn__count[hidden] {
  display: none;
}

@media (max-width: 640px) {
  .gast-filter-btn.is-filtered {
    width: auto;
    padding: 0 10px;
  }
}

.gast-chips-hidden {
  display: none !important;
}

@media (max-width: 640px) {
  /* Am Handy über der Leiste, volle Breite; der Pfeil zeigt weiter auf den Knopf */
  .gast-sheet.gast-sheet--anchored {
    left: 8px;
    right: 8px;
    bottom: var(--gast-bottom);
    width: auto;
    max-height: calc(100% - var(--gast-bottom) - 140px);
  }
}

/* Funktionen-Seite: Route und SOS als kleine Karte in der Textbox */
.gast-mini {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(20, 27, 37, 0.08);
  font-size: 0.9rem;
  line-height: 1.45;
}

.gast-mini p {
  margin: 0 0 8px;
}

.gast-mini .gast-pos {
  margin-top: 8px;
}

.gast-mini .gast-call {
  margin-top: 0;
}

/* Funktionen-Seite: Knopf in der Textbox über der Karte (dort fehlen die Farben von .fx) */
.gast-try-btn {
  --fx-ink: #0f1722;
  margin-top: 6px;
  background: #0f1722;
  color: #fff;
}

.gast-try-btn:hover {
  background: #26303d;
}

/* Für Regionen: Kacheln „Am Berg unterwegs“ */
.fx-here {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 12px;
}

.fx-here img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fx-here__dot {
  position: absolute;
  left: 52%;
  top: 46%;
}

.fx-here__label {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.fx-tile .gast-mini {
  margin-top: 0;
  font-size: 0.85rem;
}

.fx-tile .gast-steps li {
  padding: 4px 0;
}

.fx-tile .gast-steps li:not(:last-child)::before {
  top: 30px;
}

.fx-tile .gast-pos__coords {
  font-size: 1rem;
}

.gast-try {
  margin: 14px 0 0;
}

/* Knopftexte bleiben einzeilig */
.gast-actions button,
.gast-actions a,
.gast-choices button {
  white-space: nowrap;
}
