/* ---------------------------------------------------------------------------
   karte.weltsein.de — Gelände in 3D
   Tokens, Typografie und Kopfzeile sind aus /var/www/weltsein.de übernommen
   (siehe DESIGN.md dort). Neu ist nur, was die vollflächige Karte braucht.
   --------------------------------------------------------------------------- */

/* Fonts */
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/fonts/Inter-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/fonts/Inter-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Block BE';
  src: url('/fonts/BlockBE-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Block BE Condensed';
  src: url('/fonts/BlockBE-Condensed.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}

:root {
  --brand: #4a7a3f;
  --brand-light: #5a8f4e;
  --bg: #faf9f7;
  --bg-secondary: #f0eee9;
  --text: #3d4a3f;
  --text-muted: #7a8b7e;
  --border: #d8d4cc;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  --font-display: 'Block BE', 'Block BE Condensed', Impact, 'Arial Black', sans-serif;
  /* Kartenspezifisch: Panels liegen über dem Globus, brauchen also Deckkraft */
  --panel: rgba(250, 249, 247, 0.92);
  --globe: #e8e5df;
}

html.dark {
  --brand: #8fa37a;
  --brand-light: #a0b48c;
  --bg: #1a1b17;
  --bg-secondary: #242421;
  --text: #c8d4ca;
  --text-muted: #7a8b7e;
  --border: #3a3a36;
  --panel: rgba(26, 27, 23, 0.92);
  --globe: #22231f;
}

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

html, body {
  height: 100%;
  overflow: hidden;                      /* die Karte scrollt, nicht die Seite */
  font-family: var(--font-body);
  font-size: 17px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* --- Karte ---------------------------------------------------------------- */
#cesium {
  position: fixed;
  inset: 0;
  background: var(--globe);
}
#cesium canvas { display: block; }

/* Cesium bringt eigene Widget-Styles mit; die wenigen sichtbaren Reste
   (Infobox, Credits) auf die Tokens ziehen. */
.cesium-widget-credits { display: none !important; }

/* --- Kopfzeile (aus weltsein.de) ----------------------------------------- */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  padding: 0.6rem clamp(1rem, 4vw, 4rem);
  background: var(--panel);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.site-header .inner {
  width: 100%;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: clamp(0.75rem, 3vw, 3rem);
}
.site-title {
  display: inline-block;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 4vw, 1.75rem);
  font-weight: 400;
  line-height: 1;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.site-title span { color: var(--brand); }
.site-title:hover { opacity: 0.8; }
.header-controls { display: flex; align-items: center; gap: 0.5rem; }
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
}
.theme-toggle:hover { border-color: var(--brand); color: var(--brand); }

/* --- Overlay -------------------------------------------------------------- */
.panel {
  position: fixed;
  z-index: 10;
  background: var(--panel);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.6;
  color: var(--text-muted);
  padding: 0.5rem 0.7rem;
}

#info {
  left: clamp(0.5rem, 4vw, 4rem);
  bottom: 0.75rem;
  max-width: min(22rem, calc(100vw - 6rem));
  padding: 0.35rem 1.6rem 0.35rem 0.55rem;
  font-size: 0.62rem;
  line-height: 1.5;
}
#info[hidden] { display: none; }
#info .name { color: var(--text); }
#info a { color: var(--brand); text-decoration: none; }
#info a:hover { text-decoration: underline; }
#info .quelle { display: block; }

/* Schließen: kleiner Knopf in der Ecke, die Trefferfläche greift über den
   sichtbaren Rand hinaus, damit er auf dem Handy bedienbar bleibt. */
#info-zu {
  position: absolute;
  top: 0;
  right: 0;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}
#info-zu:hover { color: var(--brand); }

#info-auf {
  left: clamp(0.5rem, 4vw, 4rem);
  bottom: 0.75rem;
  width: 1.7rem;
  height: 1.7rem;
  padding: 0;
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
}
#info-auf[hidden] { display: none; }
#info-auf:hover { color: var(--brand); border-color: var(--brand); }

#readout {
  right: clamp(0.5rem, 4vw, 4rem);
  bottom: 0.75rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#readout .wert { color: var(--text); }

#tools {
  right: clamp(0.5rem, 4vw, 4rem);
  top: 5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.35rem;
}
#tools button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  min-width: 44px; min-height: 44px;
  cursor: pointer;
}
#tools button:hover { border-color: var(--brand); color: var(--brand); }
#tools button[aria-pressed="true"] { color: var(--brand); border-color: var(--brand); }

/* Ladehinweis, bis Terrain und erste Kacheln stehen */
#laden {
  position: fixed;
  z-index: 11;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.6rem 1rem;
}
#laden[hidden] { display: none; }

@media (max-width: 768px) {
  #tools { top: auto; bottom: 4.5rem; }
  #readout { bottom: 0.5rem; font-size: 0.65rem; }
  #info { bottom: 2.5rem; font-size: 0.58rem; }
  #info-auf { bottom: 2.5rem; }
}

/* --- Ortssuche ------------------------------------------------------------ */
#suche {
  left: clamp(0.5rem, 4vw, 4rem);
  top: 5rem;
  width: min(20rem, calc(100vw - 2rem));
  padding: 0;
  overflow: hidden;
}
#suchfeld {
  width: 100%;
  border: none;
  background: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.6rem 0.7rem;
  min-height: 44px;
}
#suchfeld::placeholder { color: var(--text-muted); }
#suchfeld:focus { outline: none; }
#suche:focus-within { border-color: var(--brand); }

#treffer {
  list-style: none;
  max-height: min(22rem, 50vh);
  overflow-y: auto;
  border-top: 1px solid var(--border);
}
#treffer[hidden] { display: none; }
#treffer li {
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  border-bottom: 1px solid var(--border);
}
#treffer li:last-child { border-bottom: none; }
#treffer li:hover,
#treffer li[aria-selected="true"] { background: var(--bg-secondary); }
#treffer .ort { color: var(--text); }
#treffer .kreis { color: var(--text-muted); font-size: 0.65rem; text-align: right; }
#treffer .leer { color: var(--text-muted); cursor: default; }

/* --- Messung -------------------------------------------------------------- */
#messung {
  right: clamp(0.5rem, 4vw, 4rem);
  bottom: 3.2rem;
  max-width: min(20rem, calc(100vw - 2rem));
  text-align: right;
}
#messung[hidden] { display: none; }
#messwert {
  display: block;
  color: var(--text);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
#messung .hinweis { display: block; font-size: 0.6rem; }

@media (max-width: 768px) {
  #suche { top: 4.5rem; width: calc(100vw - 5.5rem); }
  #messung { bottom: 2.6rem; }
}

/* --- Markierte Punkte ----------------------------------------------------- */
/* Sitzt in der Werkzeugspalte, damit der Zähler nicht mit ihr kollidiert,
   wenn Knöpfe dazukommen. */
#marker-zahl {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0.15rem 0 0.1rem;
  white-space: nowrap;
}
#marker-zahl[hidden] { display: none; }
