/* WSO-Aktionsorte-Finder — nur Logofarben plus Schwarz und Weiß */
:root {
  --wso-red: #800508;
  --wso-orange: #dd6b12;
  --white: #ffffff;
  --black: #000000;
  --black-60: rgba(0, 0, 0, 0.6);
  --black-12: rgba(0, 0, 0, 0.12);
  --orange-15: rgba(221, 107, 18, 0.15);
  --panel-w: 400px;
  --radius: 14px;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Archivo Black", "Archivo", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--white);
  color: var(--black);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Kopfleiste ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--wso-red);
  color: var(--white);
  border-bottom: 4px solid var(--wso-orange);
  position: relative;
  z-index: 1000;
}
.topbar-logo { width: 40px; height: 40px; flex: none; }
.topbar h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.05rem, 4.2vw, 1.5rem);
  letter-spacing: 0.01em;
  line-height: 1.1;
}

/* ---------- Layout: Handy zuerst ---------- */
.layout { display: flex; flex-direction: column; }
.map-wrap { position: relative; height: 58vh; height: 58dvh; min-height: 320px; }
#map { position: absolute; inset: 0; }
.panel { padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }

@media (min-width: 900px) {
  body { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
  .layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr var(--panel-w);
  }
  .map-wrap { height: auto; min-height: 0; }
  .panel {
    overflow-y: auto;
    border-left: 4px solid var(--wso-orange);
    padding: 20px;
  }
}
@media (min-width: 1400px) { :root { --panel-w: 440px; } }

/* ---------- Karte: Overlays ---------- */
.map-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 500;
  background: var(--wso-red);
  color: var(--white);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  border: 2px solid var(--wso-orange);
  white-space: nowrap;
  max-width: calc(100% - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  transition: opacity 0.4s;
}
.map-hint.faded { opacity: 0; }

.loading {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--white);
  color: var(--wso-red);
  font-weight: 700;
  padding: 8px 16px 8px 8px;
  border-radius: 999px;
  border: 2px solid var(--wso-orange);
  box-shadow: 0 4px 14px var(--black-12);
}
.loading[hidden] { display: none; }
.loading-logo { width: 28px; height: 28px; animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Marker ---------- */
.wso-marker { display: flex; flex-direction: column; align-items: center; }
.wso-marker img {
  width: 38px; height: 38px;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s;
}
.wso-marker.active img { transform: scale(1.25); }
.wso-marker span {
  margin-top: 3px;
  background: var(--white);
  color: var(--black);
  border: 2px solid var(--wso-red);
  font-size: 12px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
}
.wso-marker.active span { background: var(--wso-red); color: var(--white); }

.target-pin { filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.4)); }

/* ---------- Routen: animierte Striche ---------- */
.route-line {
  stroke-dasharray: 10 12;
  stroke-linecap: round;
  animation: dash-move 1.1s linear infinite;
  transition: stroke 0.2s, stroke-width 0.2s, opacity 0.2s;
}
@keyframes dash-move { to { stroke-dashoffset: -22; } }
@media (prefers-reduced-motion: reduce) {
  .route-line { animation: none; }
  .loading-logo { animation: none; }
  .bar-fill { transition: none !important; }
}

/* ---------- Panel ---------- */
.search { display: flex; gap: 8px; margin-bottom: 14px; }
.search input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 16px; /* verhindert Zoom auf iOS */
  padding: 10px 14px;
  border: 2px solid var(--wso-red);
  border-radius: 999px;
  background: var(--white);
  color: var(--black);
  outline: none;
}
.search input:focus { border-color: var(--wso-orange); box-shadow: 0 0 0 3px var(--orange-15); }
.search button, .link-btn {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.search button {
  padding: 10px 16px;
  border: none;
  border-radius: 999px;
  background: var(--wso-orange);
  color: var(--white);
}
.search button:hover { background: var(--wso-red); }

.card {
  border: 2px solid var(--wso-orange);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  background: var(--white);
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--wso-red);
}

.target-name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.2;
  margin-top: 4px;
  word-break: break-word;
}
.link-btn {
  margin-top: 8px;
  padding: 0;
  border: none;
  background: none;
  color: var(--wso-orange);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--wso-red); }
.link-btn[hidden] { display: none; }

.fairness {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--wso-red);
  border-color: var(--wso-red);
  color: var(--white);
}
.fairness .eyebrow { color: var(--white); opacity: 0.85; }
.fair-item + .fair-item { border-left: 2px solid var(--wso-orange); padding-left: 16px; }
.fair-value { font-family: var(--font-display); font-size: 2rem; line-height: 1.1; margin-top: 4px; }
.fair-value small { font-family: var(--font); font-size: 0.9rem; font-weight: 600; }

.avg-legend { font-size: 0.78rem; color: var(--black-60); display: flex; align-items: center; gap: 6px; }
.avg-swatch { width: 0; height: 14px; border-left: 2px dashed var(--black); }

/* ---------- Balkendiagramm ---------- */
.bars { margin-top: 10px; }
.bar-row {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 6px 4px;
  margin: 0 -4px;
  width: calc(100% + 8px);
  border-radius: 8px;
  cursor: pointer;
}
.bar-row:hover, .bar-row.active { background: var(--orange-15); }
.bar-label { display: flex; justify-content: space-between; gap: 8px; font-size: 0.92rem; margin-bottom: 4px; }
.bar-label b { font-weight: 700; }
.bar-label .meta { color: var(--black-60); white-space: nowrap; }
.bar-label .meta strong { color: var(--black); }
.bar-track { position: relative; height: 16px; }
.bar-fill {
  height: 100%;
  width: 0;
  background: var(--wso-orange);
  border-radius: 4px;
  transition: width 0.7s cubic-bezier(.2, .8, .2, 1), background 0.2s;
}
.bar-row.active .bar-fill { background: var(--wso-red); }
.bar-row.failed .bar-fill { background: repeating-linear-gradient(45deg, var(--black-12) 0 6px, transparent 6px 12px); width: 100% !important; }
.bar-avg {
  position: absolute;
  top: -4px;
  bottom: -4px;
  border-left: 2px dashed var(--black);
  transition: left 0.7s cubic-bezier(.2, .8, .2, 1);
}

/* ---------- Isochronen-Legende ---------- */
.iso-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 10px 0 6px; font-size: 0.88rem; }
.iso-legend span { display: inline-flex; align-items: center; gap: 6px; }
.iso-legend i { width: 18px; height: 14px; border-radius: 3px; border: 1px solid var(--wso-orange); }

/* ---------- Schalter ---------- */
.switch { position: relative; display: inline-flex; cursor: pointer; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track {
  width: 46px; height: 26px;
  border-radius: 999px;
  background: var(--white);
  border: 2px solid var(--wso-red);
  position: relative;
  transition: background 0.2s, border-color 0.2s;
}
.switch-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--wso-red);
  transition: transform 0.2s, background 0.2s;
}
.switch input:checked + .switch-track { background: var(--wso-orange); border-color: var(--wso-orange); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); background: var(--white); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--orange-15); }
.iso-head { align-items: center; flex-wrap: nowrap; }
.iso-off .iso-legend, .iso-off .note { opacity: 0.45; }

.note { font-size: 0.82rem; color: var(--black-60); margin: 6px 0 0; line-height: 1.45; }
.note.small { font-size: 0.75rem; }

.error {
  border: 2px solid var(--wso-red);
  background: var(--white);
  color: var(--wso-red);
  font-weight: 600;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.error[hidden] { display: none; }

/* Leaflet-Feinschliff */
.leaflet-container { font-family: var(--font); }
.leaflet-bar a { color: var(--wso-red); }
