/* ─── CSS-Variablen ─────────────────────────────────────────────────── */
:root {
  --color-primary:     #c0392b;
  --color-primary-dk:  #96281b;
  --color-primary-bg:  #fdf1f0;
  --color-accent:      #e67e22;
  --color-unlocked:    #27ae60;
  --color-locked:      #7f8c8d;
  --color-text:        #2c3e50;
  --color-muted:       #7f8c8d;
  --color-bg:          #f8f9fa;
  --color-surface:     #ffffff;
  --color-border:      #dde1e4;
  --color-warning:     #f39c12;
  --bar-h:    52px;
  --footer-h: 48px;
  --panel-radius: 16px;
  --transition: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset & Base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  height: -webkit-fill-available;
  background: var(--color-bg);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100%;
  min-height: -webkit-fill-available;
  overflow: hidden;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
  user-select: none;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  touch-action: manipulation;
}
button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

img { display: block; max-width: 100%; }
ul  { list-style: none; }

.hidden { display: none !important; }

/* ─── App-Bar ───────────────────────────────────────────────────────── */
#app-bar {
  position: fixed;
  inset: 0 0 auto 0;
  height: calc(var(--bar-h) + env(safe-area-inset-top, 0px));
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: env(safe-area-inset-top, 0px) 1rem 0;
  z-index: 200;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

#app-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-icon {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 8px;
  color: #fff;
  font-size: 1.2rem;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition);
}
.btn-icon:hover { background: rgba(255,255,255,0.28); }

/* ─── Karten-Container ──────────────────────────────────────────────── */
#main-content {
  position: fixed;
  inset: calc(var(--bar-h) + env(safe-area-inset-top, 0px)) 0 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#map-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── Offline-Karte ─────────────────────────────────────────────────── */
.offline-map {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #e8eaed;
  user-select: none;
  touch-action: none;
  cursor: grab;
}
.offline-map:active { cursor: grabbing; }

.map-inner {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
  will-change: transform;
}

#map-img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
  pointer-events: none;
}

/* ─── Karten-Infozeile ──────────────────────────────────────────────── */

/* ─── GPS-Overlay-Elemente ──────────────────────────────────────────── */
.user-dot {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #2980b9;
  border: 2px solid #fff;
  box-shadow: 0 0 6px rgba(41,128,185,0.7);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 30;
  transition: left 0.4s ease, top 0.4s ease;
}

.accuracy-circle {
  position: absolute;
  border-radius: 50%;
  background: rgba(41,128,185,0.12);
  border: 1px solid rgba(41,128,185,0.35);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 20;
  transition: left 0.4s ease, top 0.4s ease, width 0.4s ease, height 0.4s ease;
}

.heading-arrow {
  position: absolute;
  width: 0;
  height: 0;
  border-left:  6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 16px solid #2980b9;
  transform-origin: center bottom;
  transform: translate(-50%, -100%) rotate(0deg);
  pointer-events: none;
  z-index: 31;
  transition: left 0.4s ease, top 0.4s ease;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

/* ─── Stadtmarker (Schweiz-Übersicht) ───────────────────────────────── */
/*
 * Dot-Zentrum liegt exakt auf der Koordinate.
 * Default: Label unterhalb (flex-column). Positionsvarianten via JS.
 * padding-top(4) + dot-half(7) = 11px → translate(-50%, -11px)
 */
.city-marker {
  position: absolute;
  transform: translate(-50%, -11px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 10;
  padding: 4px;
}
/* Label oberhalb: column-reverse dreht Reihenfolge; Dot jetzt unten */
.city-marker.pos-above {
  flex-direction: column-reverse;
  transform: translate(-50%, calc(-100% + 11px));
}
/* Label rechts: row-Layout; Dot links */
.city-marker.pos-right {
  flex-direction: row;
  align-items: center;
  transform: translate(-11px, -50%);
}
/* Label links: row-reverse; Dot rechts */
.city-marker.pos-left {
  flex-direction: row-reverse;
  align-items: center;
  transform: translate(calc(-100% + 11px), -50%);
}

.city-dot {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--color-primary);
  border: 2.5px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.45);
  transition: transform var(--transition);
}
.city-marker:hover .city-dot,
.city-marker:focus-visible .city-dot {
  transform: scale(1.3);
}

.city-label {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--color-text);
  background: rgba(255,255,255,0.95);
  border: 1.5px solid var(--color-primary);
  border-radius: 6px;
  padding: 2px 7px;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(0,0,0,0.25);
  pointer-events: none;
}

.city-marker--soon {
  cursor: default;
}

/* ─── Hotspot-Marker ────────────────────────────────────────────────── */
/*
 * --hs-pos: CSS-Variable für die Positionierung, damit :hover scale()
 * die gewählte Position nicht überschreibt.
 */
.map-hotspot {
  --hs-pos: translate(-50%, -50%);
  position: absolute;
  transform: var(--hs-pos);
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 20px;
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  z-index: 15;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1.5px solid transparent;
  transition: transform var(--transition), box-shadow var(--transition);
}
.map-hotspot:hover {
  transform: var(--hs-pos) scale(1.08);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.map-hotspot--icon:hover {
  transform: var(--hs-pos);
  box-shadow: none;
}
/* Positionsvarianten: Pill über / unter / rechts / links der Koordinate */
.map-hotspot.pos-above { --hs-pos: translate(-50%, calc(-100% - 5px)); }
.map-hotspot.pos-below { --hs-pos: translate(-50%, 5px); }
.map-hotspot.pos-right { --hs-pos: translate(5px, -50%); }
.map-hotspot.pos-left  { --hs-pos: translate(calc(-100% - 5px), -50%); }

.map-hotspot.locked {
  background: rgba(127,140,141,0.88);
  color: #fff;
  border-color: rgba(255,255,255,0.3);
}
.map-hotspot.unlocked {
  background: var(--color-unlocked);
  color: #fff;
  border-color: rgba(255,255,255,0.3);
}

.hs-icon { font-size: 1rem; flex-shrink: 0; }
.hs-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Icon-basierte Hotspot-Marker — alle Pill-Styles entfernen */
.map-hotspot--icon,
.map-hotspot--icon.locked,
.map-hotspot--icon.unlocked {
  background: none;
  border-color: transparent;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
  gap: 0;
}
/* Wrapper: roter Ring (drop-shadow) + Schatten — immer farbig, auch bei locked */
.hs-icon-wrap {
  display: block;
  filter:
    drop-shadow(0 0 2px var(--color-primary))
    drop-shadow(0 0 2px var(--color-primary))
    drop-shadow(0 0 2px var(--color-primary))
    drop-shadow(0 4px 8px rgba(0,0,0,0.5));
  transition: filter var(--transition), transform var(--transition);
}
.map-hotspot--icon:hover .hs-icon-wrap,
.map-hotspot--icon:focus-visible .hs-icon-wrap {
  filter:
    drop-shadow(0 0 3px var(--color-primary))
    drop-shadow(0 0 3px var(--color-primary))
    drop-shadow(0 0 3px var(--color-primary))
    drop-shadow(0 6px 14px rgba(0,0,0,0.65));
  transform: scale(1.18);
}

/* Icon-Bild: Grayscale nur bei locked, kein Opacity-Fade */
.map-hotspot--icon .hs-icon-img {
  width: 5rem;
  height: 5rem;
  display: block;
}
.map-hotspot--icon.locked .hs-icon-img {
  filter: grayscale(100%);
}
.map-hotspot--icon .hs-label { display: none; }

/* ─── Debug-Kreuz ───────────────────────────────────────────────────── */
.debug-cross {
  position: absolute;
  width: 12px;
  height: 12px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 40;
}
.debug-cross::before,
.debug-cross::after {
  content: '';
  position: absolute;
  background: rgba(255,0,0,0.8);
}
.debug-cross::before { width: 1px; height: 100%; left: 50%; }
.debug-cross::after  { width: 100%; height: 1px; top: 50%; }

/* ─── Header-Menü ───────────────────────────────────────────────────── */
.app-menu {
  position: fixed;
  top: calc(var(--bar-h) + env(safe-area-inset-top, 0px));
  right: 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  z-index: 300;
  min-width: 220px;
  overflow: hidden;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.75rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition);
}
.menu-item:last-child { border-bottom: none; }
.menu-item:hover { background: var(--color-bg); }
.menu-item:disabled { color: var(--color-muted); cursor: default; }
.menu-item--danger { color: var(--color-primary); }

.menu-version {
  padding: 0.45rem 1.1rem;
  font-size: 0.72rem;
  color: var(--color-muted);
  border-top: 1px solid var(--color-border);
  text-align: right;
  letter-spacing: 0.02em;
}

/* ─── Hotspot-Liste ─────────────────────────────────────────────────── */
#hotspot-list-container {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  max-height: 35vh;
  overflow-y: auto;
  flex-shrink: 0;
}

.list-heading {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  padding: 0.5rem 1rem 0.25rem;
}

.hotspot-list { padding: 0 0 0.5rem; }

.hotspot-list-item button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition);
}
.hotspot-list-item:last-child button { border-bottom: none; }
.hotspot-list-item button:hover     { background: var(--color-bg); }

.li-icon  { font-size: 1rem; flex-shrink: 0; }
.li-icon-img {
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  display: block;
}
.li-icon-img.grayscale {
  filter: grayscale(100%);
  opacity: 0.65;
}
.li-title { flex: 1; font-size: 0.88rem; font-weight: 500; }
.li-dist  { font-size: 0.78rem; color: var(--color-muted); white-space: nowrap; }

.hotspot-list-item.locked  .li-title { color: var(--color-locked); }
.hotspot-list-item.unlocked .li-title { color: var(--color-text); }

/* ─── Panels (gemeinsam) ────────────────────────────────────────────── */
.panel {
  position: fixed;
  inset: auto 0 0 0;
  background: var(--color-surface);
  border-radius: var(--panel-radius) var(--panel-radius) 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.18);
  z-index: 300;
  max-height: 65vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform var(--transition);
}
.panel.open { transform: translateY(0); }

.panel-handle {
  width: 42px;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin: 10px auto 4px;
  flex-shrink: 0;
}

.panel-content {
  padding: 0 1.1rem 0.5rem;
}

.panel-footer {
  padding: 0.6rem 1.1rem max(1rem, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--color-border);
}

.panel-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--color-text);
}

.panel-teaser {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--color-muted);
  margin-bottom: 0.6rem;
  font-style: italic;
}

.panel-body {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--color-text);
}

.panel-img {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  object-fit: cover;
  max-height: 200px;
}

.panel-img-credit {
  font-size: 0.72rem;
  color: var(--color-muted);
  margin-bottom: 0.5rem;
}

.btn-secondary {
  display: inline-block;
  padding: 0.45rem 1.1rem;
  border: 1.5px solid var(--color-border);
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-text);
  background: var(--color-bg);
  transition: background var(--transition);
}
.btn-secondary:hover { background: var(--color-border); }

/* ─── Gesperrter Hotspot Panel ──────────────────────────────────────── */
.locked-content {
  padding: 1rem 1.1rem 0.5rem;
  text-align: center;
}

.locked-message {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--color-text);
  margin-bottom: 0.4rem;
}

.locked-distance {
  font-size: 0.88rem;
  color: var(--color-muted);
  font-weight: 600;
}

/* ─── Toast ─────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: calc(var(--bar-h) + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: #2c3e50;
  color: #fff;
  padding: 0.5rem 1.2rem;
  border-radius: 20px;
  font-size: 0.88rem;
  font-weight: 500;
  z-index: 400;
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.toast.show { opacity: 1; }

/* ─── Footer-Bar (entfernt) ─────────────────────────────────────────── */

/* ─── Debug-Panel ───────────────────────────────────────────────────── */
.debug-panel {
  position: fixed;
  top: var(--bar-h);
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.82);
  color: #0f0;
  font-family: monospace;
  font-size: 0.72rem;
  padding: 0.4rem 0.8rem;
  z-index: 500;
  line-height: 1.7;
  pointer-events: none;
}


/* ─── Desktop-Layout (ab 680px) ─────────────────────────────────────── */
@media (min-width: 680px) {
  #main-content {
    flex-direction: row;
    align-items: stretch;
  }

  #map-container {
    flex: 1;
    min-width: 0;
  }

  #hotspot-list-container {
    width: 280px;
    flex-shrink: 0;
  }

  #hotspot-list-container {
    border-top: 1px solid var(--color-border);
    border-left: 1px solid var(--color-border);
    max-height: none;
  }

  .panel { max-width: 480px; left: auto; right: 0; border-radius: var(--panel-radius) 0 0 var(--panel-radius); }
}

/* ─── Kein JS-Fallback ──────────────────────────────────────────────── */
noscript {
  display: block;
  position: fixed;
  inset: 0;
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--color-text);
  text-align: center;
  padding: 2rem;
  z-index: 9999;
}
