/* =========================================================
   Topografiekarte – Konfigurator
   ========================================================= */

:root {
  --paper:      #f6f3ec;
  --paper-2:    #ece7dc;
  --ink:        #1d1c1a;
  --ink-soft:   #5d5952;
  --ink-faint:  #918b80;
  --line:       #d9d2c4;
  --accent:     #2f5d3a;
  --accent-2:   #3d7a4c;
  --gold:       #b4903a;
  --danger:     #a33a2a;
  --radius:     14px;
  --shadow-sm:  0 1px 2px rgba(29,28,26,.06), 0 2px 8px rgba(29,28,26,.05);
  --shadow-md:  0 4px 24px rgba(29,28,26,.10);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: 1fr minmax(360px, 420px);
  height: 100dvh;
  overflow: hidden;
}

.stage {
  position: relative;
  background: #0f1211;
  overflow: hidden;
}

#map { position: absolute; inset: 0; background: #0f1211; }

/* Leaflet-Attribution dezenter */
.leaflet-control-attribution {
  background: rgba(246,243,236,.82) !important;
  font-size: 10px !important;
  color: var(--ink-soft) !important;
}
.leaflet-control-attribution a { color: var(--accent) !important; }
.leaflet-control-zoom a {
  color: var(--ink) !important;
  background: rgba(246,243,236,.94) !important;
  border-color: var(--line) !important;
}

/* ---------- Rahmen-Overlay ---------- */
.frame-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 500;
}

.frame-box {
  position: relative;
  width: min(62vh, 62%, 620px);
  aspect-ratio: 1 / 1;
  border: 1.5px solid rgba(255,255,255,.9);
  border-radius: 4px;
  box-shadow:
    0 0 0 9999px rgba(12,14,13,.52),
    inset 0 0 0 1px rgba(0,0,0,.28),
    0 0 40px rgba(0,0,0,.35);
  transition: box-shadow .25s ease;
}

.corner {
  position: absolute;
  width: 20px; height: 20px;
  border: 2px solid #fff;
}
.corner.tl { top: -2px; left: -2px;  border-right: 0; border-bottom: 0; }
.corner.tr { top: -2px; right: -2px; border-left: 0;  border-bottom: 0; }
.corner.bl { bottom: -2px; left: -2px;  border-right: 0; border-top: 0; }
.corner.br { bottom: -2px; right: -2px; border-left: 0;  border-top: 0; }

.frame-caption {
  position: absolute;
  left: 50%;
  bottom: -34px;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.86);
  background: rgba(12,14,13,.55);
  padding: 5px 12px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}

/* ---------- Suche ---------- */
.search-wrap {
  position: absolute;
  top: 18px; left: 18px;
  width: min(420px, calc(100% - 36px));
  z-index: 600;
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(246,243,236,.97);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 16px;
  box-shadow: var(--shadow-md);
}

.search-icon {
  width: 17px; height: 17px; flex: none;
  fill: none; stroke: var(--ink-soft); stroke-width: 2; stroke-linecap: round;
}

.search input {
  flex: 1;
  border: 0;
  background: none;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  min-width: 0;
}
.search input::placeholder { color: var(--ink-faint); }
.search input::-webkit-search-cancel-button { display: none; }

.search-clear {
  border: 0; background: none; cursor: pointer;
  font-size: 20px; line-height: 1; color: var(--ink-faint); padding: 0 2px;
}

.results {
  list-style: none;
  margin: 8px 0 0;
  padding: 6px;
  background: rgba(246,243,236,.99);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 46vh;
  overflow-y: auto;
}

.results li {
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  line-height: 1.4;
  cursor: pointer;
  color: var(--ink-soft);
}
.results li:hover, .results li[aria-selected="true"] { background: var(--paper-2); color: var(--ink); }
.results li strong { display: block; color: var(--ink); font-weight: 600; }
.results li.empty { cursor: default; color: var(--ink-faint); }

.stage-hint {
  position: absolute;
  bottom: 16px; left: 18px;
  z-index: 600;
  font-size: 12px;
  color: rgba(255,255,255,.72);
  background: rgba(12,14,13,.45);
  padding: 6px 12px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
  transition: opacity .4s ease;
}

/* ---------- Panel ---------- */
.panel {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-left: 1px solid var(--line);
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 26px 0;
}

.brand-mark {
  width: 40px; height: 40px; flex: none;
  border-radius: 10px;
  background: var(--accent);
  display: grid; place-items: center;
}
.brand-mark svg {
  width: 26px; height: 26px;
  fill: none; stroke: #f6f3ec; stroke-width: 1.6; stroke-linecap: round;
}

.brand-name {
  margin: 0;
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.brand-title {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.lede {
  margin: 14px 26px 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink-soft);
}
.lede strong { color: var(--ink); font-weight: 600; }

.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 26px 24px;
  scrollbar-width: thin;
}

.step { padding: 22px 0 4px; border-top: 1px solid var(--line); margin-top: 18px; }
.step:first-child { border-top: 0; margin-top: 4px; }

.step h2 {
  display: flex; align-items: center; gap: 9px;
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink);
}

.num {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  font-weight: 700;
}

.opt {
  margin-left: auto;
  font-size: 10.5px;
  letter-spacing: .06em;
  color: var(--ink-faint);
  font-weight: 400;
  text-transform: none;
}

.place {
  margin: 0 0 16px;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.4;
  color: var(--ink);
}

.sub {
  margin: 16px 0 8px;
  font-size: 12px;
  color: var(--ink-soft);
}
.sub:first-of-type { margin-top: 0; }

/* ---------- Slider ---------- */
.slider-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.slider-label output {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: none;
  cursor: pointer;
  margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px; border-radius: 3px; background: var(--line);
}
input[type="range"]::-moz-range-track {
  height: 3px; border-radius: 3px; background: var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px; margin-top: -7.5px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--paper);
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--paper);
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; border-radius: 4px; }

.slider-scale {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--ink-faint);
  margin-top: 2px;
}

.hint {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-faint);
  min-height: 1px;
}
.hint.warn { color: var(--danger); }

/* ---------- Farbfelder ---------- */
.swatches {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 7px;
}

.swatch {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,.14);
  cursor: pointer;
  padding: 0;
  transition: transform .12s ease, box-shadow .12s ease;
}
.swatch:hover { transform: translateY(-2px); }
.swatch[aria-checked="true"] {
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink);
}
.swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- Vorschau ---------- */
.preview {
  margin: 18px 0 0;
  text-align: center;
}
.preview svg {
  width: 100%;
  max-width: 210px;
  aspect-ratio: 1/1;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  display: block;
  margin: 0 auto;
}
.preview figcaption {
  margin-top: 9px;
  font-size: 11px;
  color: var(--ink-faint);
}

/* ---------- Rahmen ---------- */
.frames { display: grid; gap: 9px; }

.frame-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  font: inherit;
  transition: border-color .15s ease, background .15s ease;
}
.frame-opt:hover { border-color: var(--ink-faint); }
.frame-opt[aria-checked="true"] {
  border-color: var(--ink);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.frame-radio {
  width: 16px; height: 16px; flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--ink-faint);
  position: relative;
}
.frame-opt[aria-checked="true"] .frame-radio { border-color: var(--ink); }
.frame-opt[aria-checked="true"] .frame-radio::after {
  content: "";
  position: absolute; inset: 3px;
  border-radius: 50%;
  background: var(--ink);
}

.frame-opt .fname { display: block; font-size: 14px; font-weight: 600; }
.frame-opt .fnote { display: block; font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }
.frame-opt .fprice {
  margin-left: auto;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* ---------- Textfeld ---------- */
#label {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
}
#label:focus { outline: none; border-color: var(--ink); }

/* ---------- Checkout ---------- */
.checkout {
  padding: 18px 26px 22px;
  border-top: 1px solid var(--line);
  background: var(--paper-2);
}

.summary {
  font-size: 12px;
  line-height: 1.65;
  color: var(--ink-soft);
  margin-bottom: 12px;
}
.summary b { color: var(--ink); font-weight: 600; }

.pricerow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}
.pricelabel { font-size: 13px; color: var(--ink-soft); }
.pricelabel small { display: block; font-size: 10.5px; color: var(--ink-faint); }
.price {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.consent {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-soft);
  margin-bottom: 12px;
  cursor: pointer;
}
.consent input {
  flex: none;
  margin: 1px 0 0;
  width: 15px; height: 15px;
  accent-color: var(--accent);
}

.cta {
  position: relative;
  width: 100%;
  padding: 15px 20px;
  border: 0;
  border-radius: 11px;
  background: var(--accent);
  color: #f6f3ec;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease;
}
.cta:hover { background: var(--accent-2); }
.cta:active { transform: translateY(1px); }
.cta:disabled { opacity: .6; cursor: progress; }

.cta-spinner {
  position: absolute;
  right: 18px; top: 50%;
  width: 15px; height: 15px;
  margin-top: -7.5px;
  border: 2px solid rgba(246,243,236,.35);
  border-top-color: #f6f3ec;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--danger);
  line-height: 1.5;
}

.legal {
  margin: 11px 0 0;
  font-size: 11px;
  text-align: center;
  color: var(--ink-faint);
}
.legal a { color: var(--ink-soft); }

/* ---------- Responsiv ---------- */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }
  /* Karte bleibt beim Scrollen oben stehen, damit man Änderungen sofort sieht */
  .stage {
    position: sticky;
    top: 0;
    height: 48vh;
    z-index: 1;
  }
  .panel {
    position: relative;
    z-index: 2;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    margin-top: -18px;
    box-shadow: 0 -8px 24px rgba(15,18,17,.28);
  }
  .brand { padding-top: 18px; }
  .scroll { overflow: visible; }
  .frame-box { width: min(62vw, 280px); }
  .search-wrap { top: 12px; left: 12px; width: calc(100% - 24px); }
  .stage-hint { display: none; }
  .checkout { border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
