/* hillsha.de — terrain relief from open LiDAR/elevation data
   Design system lifted from weltsein.de (forest green, paper neutrals,
   Inter + JetBrains Mono, hairlines, sibling dark mode, no shadows). */

/* ---------- Fonts (self-hosted) ---------- */
@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;
}

/* ---------- Tokens ---------- */
:root {
  --brand: #4a7a3f;
  --brand-light: #5a8f4e;
  --bg: #faf9f7;
  --bg-secondary: #f0eee9;
  --text: #3d4a3f;
  --text-muted: #7a8b7e;
  --border: #d8d4cc;
  --code-bg: #f0eee9;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

  --error: #cc3333;
  --error-bg: #ffeaea;
  --error-border: #ffcccc;
  --success: #227722;
  --success-bg: #eaffea;
  --success-border: #ccffcc;
}

html.dark {
  --brand: #8fa37a;
  --brand-light: #a0b48c;
  --bg: #1a1b17;
  --bg-secondary: #242421;
  --text: #c8d4ca;
  --text-muted: #7a8b7e;
  --border: #3a3a36;
  --code-bg: #242421;

  --error: #e06666;
  --error-bg: #2a0a0a;
  --error-border: #662222;
  --success: #66bb66;
  --success-bg: #0a2a0a;
  --success-border: #226622;
}

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

html { font-size: 18px; }
body {
  font-family: var(--font-body);
  font-size: clamp(1rem, 2.5vw, 1.125rem);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
  transition: background-color 0.2s, color 0.2s;
}

h1, h2, h3 {
  font-family: var(--font-mono);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  padding: 0.5rem 1rem; background: var(--bg); color: var(--brand);
  border: 2px solid var(--brand); border-radius: 0 0 4px 0; text-decoration: none;
}
.skip-link:focus { left: 0; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- App shell: map + side panel ---------- */
.app {
  display: grid;
  grid-template-columns: 1fr 420px;
  height: 100vh;
}
#map { position: relative; height: 100vh; width: 100%; }

/* Invert the light OSM raster so it sits in dark mode (sibling, not afterthought). */
html.dark .maplibregl-canvas {
  filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.92);
}

/* ---------- Floating header card (over map) ---------- */
.site-header {
  position: absolute; z-index: 3; top: 14px; left: 14px; right: 14px;
  display: flex; align-items: flex-start; gap: 12px; max-width: 560px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 12px 16px;
}
.site-header .inner { flex: 1; min-width: 0; }
.site-title { font-family: var(--font-mono); font-weight: 700; font-size: 1rem; color: var(--text); }
.site-title .badge { color: var(--brand); }
.site-header p { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; line-height: 1.45; }
.header-controls { flex: none; display: flex; gap: 6px; }

.theme-toggle, .lang-toggle {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  font-family: var(--font-mono); font-size: 0.75rem; border-radius: 4px; cursor: pointer;
  min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center;
}
.theme-toggle:hover, .lang-toggle:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- Side panel ---------- */
.panel {
  height: 100vh; overflow-y: auto;
  border-left: 1px solid var(--border);
  background: var(--bg);
  padding: 1.25rem 1.25rem 3rem;
  -webkit-overflow-scrolling: touch;
}
.panel-section { margin-bottom: 1.5rem; }
.panel h2 { font-size: 1.05rem; margin-bottom: 0.4rem; }
.panel h3 {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); margin: 1.25rem 0 0.6rem;
  padding-bottom: 0.35rem; border-bottom: 1px solid var(--border);
}
.panel-hint { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.panel-coords { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); }

/* Placeholder / empty states */
.placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 0.75rem; min-height: 60vh; color: var(--text-muted);
  padding: 1rem;
}
.placeholder .glyph { font-size: 2.4rem; color: var(--brand); line-height: 1; }
.placeholder-icon { width: 104px; height: 104px; display: block; }
.placeholder p { font-size: 0.9rem; max-width: 30ch; }

/* ---------- Offer / product list ---------- */
.offer-product {
  display: block; width: 100%; text-align: left;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text);
  padding: 0.7rem 0.8rem; margin-bottom: 0.6rem; cursor: pointer;
  font-family: var(--font-body); transition: border-color 0.15s;
}
.offer-product:hover { border-color: var(--brand); }
.offer-product:focus-visible { outline: none; border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.offer-product.selected { border-color: var(--brand); background: var(--bg-secondary); }
.offer-product-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.offer-product-title { font-weight: 700; font-size: 0.92rem; }
.offer-product-meta {
  font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-muted);
  margin-top: 0.3rem; display: flex; flex-wrap: wrap; gap: 0.4rem 0.6rem;
}
.offer-product-attr {
  font-size: 0.7rem; color: var(--text-muted); margin-top: 0.4rem; line-height: 1.4;
}
.offer-product-attr b { color: var(--text); font-weight: 700; }

/* Tags / badges */
.tag {
  display: inline-block; font-family: var(--font-mono); font-size: 0.6rem;
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0.12rem 0.4rem; border: 1px solid var(--border); border-radius: 3px;
  color: var(--text-muted); white-space: nowrap;
}
.tag.tag-product { color: var(--brand); border-color: var(--brand); }
.badge-confidence {
  font-family: var(--font-mono); font-size: 0.6rem; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 0.12rem 0.4rem; border-radius: 3px; border: 1px solid;
  white-space: nowrap;
}
.badge-confidence.high   { color: var(--success); border-color: var(--success); }
.badge-confidence.medium { color: #b58900; border-color: #b58900; }
.badge-confidence.low    { color: var(--text-muted); border-color: var(--border); }

.attributions-footer {
  font-family: var(--font-mono); font-size: 0.62rem; color: var(--text-muted);
  line-height: 1.5; margin-top: 0.6rem; padding-top: 0.6rem; border-top: 1px solid var(--border);
}

/* ---------- Forms / checkboxes / sliders ---------- */
.check-grid { display: flex; flex-direction: column; gap: 0.1rem; }
.check {
  display: flex; align-items: center; gap: 0.6rem;
  min-height: 44px; padding: 0.2rem 0.3rem; border-radius: 4px; cursor: pointer;
}
.check:hover { background: var(--bg-secondary); }
.check input { width: 18px; height: 18px; accent-color: var(--brand); flex: none; cursor: pointer; }
.check span { font-size: 0.9rem; }
.check small { display: block; font-size: 0.72rem; color: var(--text-muted); }
.check .check-label { display: flex; flex-direction: column; }

.slider-group { margin-bottom: 0.9rem; }
.slider-group label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-muted); margin-bottom: 0.25rem;
}
.slider-group output { color: var(--text); font-weight: 700; }
.slider {
  width: 100%; display: block; accent-color: var(--brand); cursor: pointer;
  min-height: 28px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.5rem 1rem; border: 1px solid var(--border); border-radius: 4px;
  font-family: var(--font-mono); font-size: 0.82rem; cursor: pointer; text-decoration: none;
  min-height: 44px; min-width: 44px; background: var(--bg); color: var(--text);
}
.btn:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-light); color: #fff; border-color: var(--brand-light); }
.btn-primary:disabled:hover { background: var(--brand); border-color: var(--brand); }
.btn-block { width: 100%; }
.btn-sm { font-size: 0.72rem; padding: 0.35rem 0.65rem; min-height: 38px; }
.btn-ghost { background: none; }

.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.btn:focus-visible, .check:focus-within, .offer-product:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 1px;
}

/* ---------- Progress ---------- */
.progress { margin: 0.5rem 0; }
.progress-steps {
  display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.75rem;
  font-family: var(--font-mono); font-size: 0.6rem;
}
.progress-step {
  padding: 0.2rem 0.4rem; border: 1px solid var(--border); border-radius: 3px;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em;
}
.progress-step.active { border-color: var(--brand); color: var(--brand); background: var(--bg-secondary); }
.progress-step.done { color: var(--brand); border-color: var(--brand); }
.progress-bar {
  height: 6px; border-radius: 3px; background: var(--bg-secondary);
  border: 1px solid var(--border); overflow: hidden;
}
.progress-bar-fill {
  height: 100%; background: var(--brand); width: 0%;
  transition: width 0.4s ease;
}
.progress-msg { font-size: 0.88rem; margin-top: 0.6rem; color: var(--text); }
.progress-msg .spinner {
  display: inline-block; width: 0.8em; height: 0.8em; margin-right: 0.4em;
  border: 2px solid var(--border); border-top-color: var(--brand); border-radius: 50%;
  animation: spin 0.8s linear infinite; vertical-align: -0.05em;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Results ---------- */
.layer-toggle {
  display: flex; align-items: center; gap: 0.55rem; min-height: 44px;
  padding: 0.3rem 0.4rem; border-radius: 4px; cursor: pointer;
}
.layer-toggle:hover { background: var(--bg-secondary); }
.layer-toggle input[type=radio] { width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.layer-toggle span { font-size: 0.9rem; }
.download-list { display: flex; flex-direction: column; gap: 0.5rem; }
.download-list .btn { justify-content: space-between; }
.download-size { font-size: 0.68rem; color: var(--text-muted); }
.btn-primary .download-size { color: rgba(255,255,255,0.85); }

/* Countdown */
.countdown {
  border: 1px solid var(--brand); border-radius: 6px; background: var(--bg-secondary);
  padding: 0.85rem 1rem; margin-bottom: 1.25rem;
}
.countdown-time {
  font-family: var(--font-mono); font-weight: 700; font-size: 1.6rem; color: var(--brand);
  line-height: 1; margin-bottom: 0.3rem;
}
.countdown-time.urgent { color: var(--error); }
.countdown-label {
  font-family: var(--font-mono); font-size: 0.62rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
}
.countdown-note { font-size: 0.74rem; color: var(--text-muted); margin-top: 0.5rem; line-height: 1.45; }

/* ---------- Messages ---------- */
.msg { padding: 0.75rem 1rem; border-radius: 4px; margin: 0.75rem 0; font-size: 0.85rem; line-height: 1.5; }
.msg-error { background: var(--error-bg); color: var(--error); border: 1px solid var(--error-border); }
.msg-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.msg-info { background: var(--bg-secondary); color: var(--text-muted); border: 1px solid var(--border); }

/* ---------- MapLibre popup (hairlines, no shadow) ---------- */
.maplibregl-popup-content {
  padding: 0; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg); box-shadow: none; color: var(--text);
}
.maplibregl-popup-tip { display: none; }
.maplibregl-popup-close-button { color: var(--text-muted); font-size: 18px; padding: 2px 8px; }
.map-popup {
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted);
  padding: 0.6rem 0.8rem; max-width: 220px; line-height: 1.5;
}
.map-popup b { color: var(--text); }
.maplibregl-ctrl-attrib { font-size: 0.6rem; }

/* ---------- Responsive: stack panel below map ---------- */
@media (max-width: 860px) {
  html { font-size: 16px; }
  body { overflow: auto; height: auto; }
  .app { grid-template-columns: 1fr; height: auto; }
  #map { height: 55vh; }
  .panel { height: auto; min-height: 45vh; border-left: none; border-top: 1px solid var(--border); }
  .site-header { max-width: none; }
  .placeholder { min-height: 30vh; }
}
