/* ── Fonts (selbst gehostet – kein Google Fonts) ────────────────────────────── */
@font-face {
  font-family: 'Playfair Display';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/playfair-display-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/source-serif-4-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Source Serif 4';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/source-serif-4-400i.woff2') format('woff2');
}
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/source-serif-4-600.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/dm-mono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/dm-mono-500.woff2') format('woff2');
}

:root {
  --bg:        #f0ede6;
  --surface:   #faf9f5;
  --border:    #ddd8cc;
  --text:      #1e1c18;
  --muted:     #7a7468;
  --accent:    #2d5a1e;
  --acc-light: #e4ede0;
  --f-display: 'Playfair Display', Georgia, serif;
  --f-body:    'Source Serif 4', Palatino, serif;
  --f-ui:      'DM Mono', 'Courier New', monospace;
  --r:         5px;
  --panel-w:   290px;
  --nav-h:     54px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--f-body);
  background:  var(--bg);
  color:       var(--text);
  height:      100dvh;
  display:     flex;
  overflow:    hidden;
}

/* ── Layout ──────────────────────────────────────────────────────────────────── */
#sidebar {
  width:          var(--panel-w);
  min-width:      var(--panel-w);
  background:     var(--surface);
  border-right:   1px solid var(--border);
  display:        flex;
  flex-direction: column;
  overflow-y:     auto;
  z-index:        1000;
  transition:     width 0.2s, min-width 0.2s;
}

#sidebar.collapsed {
  width:        0;
  min-width:    0;
  overflow:     hidden;
  border-right: none;
}

#map-container { flex: 1; position: relative; }
#map { width: 100%; height: 100%; }

/* ── Sidebar Toggle ──────────────────────────────────────────────────────────── */
#sidebar-toggle {
  position:        absolute;
  top:             50%;
  left:            0;
  transform:       translateY(-50%);
  z-index:         1001;
  background:      var(--surface);
  border:          1px solid var(--border);
  border-left:     none;
  border-radius:   0 var(--r) var(--r) 0;
  width:           18px;
  height:          48px;
  cursor:          pointer;
  font-size:       0.6rem;
  color:           var(--muted);
  display:         flex;
  align-items:     center;
  justify-content: center;
  box-shadow:      2px 0 6px rgba(0,0,0,0.08);
  transition:      background 0.15s;
}
#sidebar-toggle:hover { background: #e6e0d4; color: var(--text); }

/* ── Sidebar Footer ─────────────────────────────────────────────────────────── */
.sidebar-footer {
  padding:      12px 16px;
  border-top:   1px solid var(--border);
  display:      flex;
  gap:          1rem;
  font-size:    0.78rem;
}
.sidebar-footer a {
  color:           var(--muted);
  text-decoration: none;
}
.sidebar-footer a:hover { color: var(--text); }

/* ── Header ──────────────────────────────────────────────────────────────────── */
.sidebar-header {
  padding:       18px 16px 14px;
  border-bottom: 1px solid var(--border);
  background:    linear-gradient(150deg, #deebd8 0%, var(--surface) 60%);
}
.header-icon { font-size: 1.5rem; margin-bottom: 4px; }
.sidebar-header h1 {
  font-family:     var(--f-display);
  font-size:       1.4rem;
  font-weight:     700;
  letter-spacing:  -0.02em;
}
.subtitle {
  font-family:    var(--f-ui);
  font-size:      0.6rem;
  color:          var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top:     2px;
}
#tree-count {
  display:       inline-block;
  margin-top:    8px;
  font-family:   var(--f-ui);
  font-size:     0.7rem;
  color:         var(--accent);
  background:    var(--acc-light);
  padding:       3px 10px;
  border-radius: 20px;
  border:        1px solid #c0d4b8;
}

/* ── Tile-Switcher ───────────────────────────────────────────────────────────── */
.tile-switcher {
  padding:       10px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.tile-btns { display: flex; gap: 4px; margin-top: 5px; }
.tile-btn {
  flex:           1;
  padding:        5px 0;
  font-family:    var(--f-ui);
  font-size:      0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background:     var(--bg);
  border:         1px solid var(--border);
  border-radius:  var(--r);
  cursor:         pointer;
  color:          var(--muted);
  transition:     all 0.15s;
}
.tile-btn:hover  { background: #e6e0d4; color: var(--text); }
.tile-btn.active   { background: var(--accent); color: #fff; border-color: var(--accent); }
.tile-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tile-btn:disabled:hover { background: var(--bg); color: var(--muted); }

/* ── Filter-Panel ────────────────────────────────────────────────────────────── */
.filter-panel {
  padding:       14px 16px;
  border-bottom: 1px solid var(--border);
}
.filter-intro {
  font-family:    var(--f-ui);
  font-size:      0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color:          var(--muted);
  margin-bottom:  10px;
}
.filter-group  { margin-bottom: 10px; }
.filter-label  {
  display:        block;
  font-family:    var(--f-ui);
  font-size:      0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color:          var(--muted);
  margin-bottom:  4px;
}
.select-wrap { position: relative; }
.select-wrap::after {
  content:        '▾';
  position:       absolute;
  right:          9px;
  top:            50%;
  transform:      translateY(-50%);
  color:          var(--muted);
  pointer-events: none;
  font-size:      0.75rem;
}
select {
  width:        100%;
  padding:      7px 26px 7px 9px;
  font-family:  var(--f-body);
  font-size:    0.86rem;
  color:        var(--text);
  background:   var(--bg);
  border:       1px solid var(--border);
  border-radius: var(--r);
  appearance:   none;
  cursor:       pointer;
  transition:   border-color 0.15s, box-shadow 0.15s;
}
select:focus {
  outline:    none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45,90,30,0.1);
}

/* FID-Suchfeld */
.filter-input {
  width:         100%;
  padding:       7px 9px;
  font-family:   var(--f-body);
  font-size:     0.86rem;
  color:         var(--text);
  background:    var(--bg);
  border:        1px solid var(--border);
  border-radius: var(--r);
  transition:    border-color 0.15s, box-shadow 0.15s;
  -moz-appearance: textfield;
}
.filter-input::-webkit-outer-spin-button,
.filter-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.filter-input:focus {
  outline:      none;
  border-color: var(--accent);
  box-shadow:   0 0 0 3px rgba(45,90,30,0.1);
}
.filter-input::placeholder { color: var(--muted); opacity: 0.7; }

.btn-reset {
  width:          100%;
  margin-top:     6px;
  padding:        7px;
  font-family:    var(--f-ui);
  font-size:      0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color:          var(--muted);
  background:     transparent;
  border:         1px solid var(--border);
  border-radius:  var(--r);
  cursor:         pointer;
  transition:     all 0.15s;
}
.btn-reset:hover { background: var(--bg); color: var(--text); }

/* ── Legende ─────────────────────────────────────────────────────────────────── */
.legend { padding: 12px 16px 16px; flex: 1; }
.legend-title {
  font-family:    var(--f-ui);
  font-size:      0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color:          var(--muted);
  margin-bottom:  8px;
}
.legend-section-label {
  font-family:    var(--f-ui);
  font-size:      0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color:          #b0a898;
  margin:         8px 0 4px;
}
.legend-item {
  display:     flex;
  align-items: center;
  gap:         7px;
  font-size:   0.78rem;
  color:       var(--text);
  margin-bottom: 4px;
}
.ldot {
  width:       11px;
  height:      11px;
  border-radius: 50%;
  border:      2px solid #fff;
  box-shadow:  0 0 0 1px rgba(0,0,0,0.15);
  flex-shrink: 0;
}
.lline {
  display:     inline-block;
  width:       22px;
  height:      3px;
  background:  currentColor;
  flex-shrink: 0;
  border-radius: 2px;
}
.layer-toggle {
  display:     flex;
  align-items: center;
  gap:         7px;
  font-size:   0.78rem;
  color:       var(--text);
  cursor:      pointer;
  margin-bottom: 5px;
  user-select: none;
}
.layer-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
}
.ldiamond {
  width:       9px;
  height:      9px;
  transform:   rotate(45deg);
  border:      2px solid #fff;
  box-shadow:  0 0 0 1px rgba(0,0,0,0.15);
  flex-shrink: 0;
}

/* ── Popup ───────────────────────────────────────────────────────────────────── */
.leaflet-popup-content-wrapper {
  border-radius: 6px !important;
  box-shadow:    0 4px 18px rgba(0,0,0,0.13) !important;
  font-family:   var(--f-body) !important;
  padding:       0 !important;
  overflow:      hidden;
}
.leaflet-popup-content { margin: 0 !important; }
.popup-color-bar { height: 4px; width: 100%; }
.popup-inner { padding: 10px 13px 9px; min-width: 170px; }

.popup-fid {
  font-family:    var(--f-display);
  font-size:      1.1rem;
  font-weight:    700;
  color:          var(--text);
  margin-bottom:  6px;
  letter-spacing: -0.01em;
}

.popup-sub    { font-size: 0.78rem; color: var(--muted); margin-bottom: 3px; }
.popup-detail { font-size: 0.78rem; color: var(--text);  margin-top: 2px; }
.popup-inner table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.popup-inner td { padding: 2px 0; }
.popup-inner td:first-child { color: var(--muted); padding-right: 10px; white-space: nowrap; }

/* ── Infotafel-Marker ────────────────────────────────────────────────────────── */
.info-marker {
  background:    #dc2626;
  color:         #fff;
  border-radius: 50%;
  display:       flex;
  align-items:   center;
  justify-content: center;
  font-size:     0.9rem;
  font-weight:   700;
  font-family:   var(--f-ui);
  border:        2px solid #fff;
  box-shadow:    0 2px 6px rgba(0,0,0,0.25);
  cursor:        pointer;
}

/* ── GPS-Control-Button ──────────────────────────────────────────────────────── */
.leaflet-bar a { font-size: 1rem !important; }

/* ── Lade-Overlay ────────────────────────────────────────────────────────────── */
#map-overlay {
  position:       absolute;
  inset:          0;
  background:     rgba(240,237,230,0.8);
  display:        flex;
  align-items:    center;
  justify-content: center;
  z-index:        999;
  font-family:    var(--f-ui);
  font-size:      0.82rem;
  color:          var(--muted);
  letter-spacing: 0.05em;
  backdrop-filter: blur(3px);
  transition:     opacity 0.3s;
}
#map-overlay.hidden { opacity: 0; pointer-events: none; }

/* ── Nav-Bar (Mobile) ────────────────────────────────────────────────────────── */
#app-nav {
  display:    none;
  position:   fixed;
  bottom:     0;
  left:       0;
  right:      0;
  height:     var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index:    2000;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}
.nav-btn {
  flex:            1;
  height:          100%;
  background:      none;
  border:          none;
  font-family:     var(--f-ui);
  font-size:       0.55rem;
  text-transform:  uppercase;
  letter-spacing:  0.06em;
  color:           var(--muted);
  cursor:          pointer;
  display:         flex;
  flex-direction:  column;
  align-items:     center;
  justify-content: center;
  gap:             3px;
  transition:      color 0.15s;
}
.nav-btn span { line-height: 1; }
.nav-btn.active { color: var(--accent); border-top: 2px solid var(--accent); }
.nav-btn:hover  { color: var(--text); }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
/* ── FID-Treffer: gelber Pulsring ────────────────────────────────────────────── */
@keyframes tree-pulse {
  0%   { stroke: #ffff00; stroke-width: 14; stroke-opacity: 1; filter: drop-shadow(0 0 6px #ffff00); }
  100% { stroke: #ffff00; stroke-width: 50; stroke-opacity: 0; filter: drop-shadow(0 0 0px #ffff00); }
}
.tree-pulse {
  animation: tree-pulse 0.8s ease-out 3;
}

@media (max-width: 640px) {
  body {
    flex-direction: column;
    padding-bottom: var(--nav-h);
  }
  #sidebar {
    width:         100%;
    min-width:     unset;
    max-height:    36dvh;
    border-right:  none;
    border-bottom: 1px solid var(--border);
  }
  #sidebar.collapsed {
    max-height:    0;
    border-bottom: none;
  }
  #map-container { flex: 1; min-height: 0; }
  #sidebar-toggle { display: none; }
  #app-nav { display: flex; }
}


/* ─── Infotafel-Icon ──────────────────────────────────────────────────────── */
.info-icon {
  width:            24px;
  height:           24px;
  border-radius:    50%;
  background:       #dc2626;
  color:            #fff;
  font-size:        14px;
  font-weight:      700;
  font-style:       italic;
  font-family:      serif;
  display:          flex;
  align-items:      center;
  justify-content:  center;
  border:           2px solid #fff;
  box-shadow:       0 1px 4px rgba(0,0,0,0.4);
  cursor:           pointer;
}
