/* Ladekarte — Smartphone-Flow (Auswahl → Karte → E-Mail → Danke).
 *
 * Eine App-artige Vollhöhen-Seite statt einer scrollenden Landingpage: die
 * Besucher kommen per QR-Code mit einem konkreten Ziel und sollen in unter
 * einer Minute fertig sein. Design-Tokens kommen aus base.css; die Karten-
 * Widget-Stile (Suchfeld, Zeichen-Handles) sind aus dem alten tool.css
 * übernommen, damit map.js unverändert weiterläuft.
 */

/* --- App-Rahmen ----------------------------------------------------------- */

body.client {
  height: 100vh;
  height: 100dvh; /* mobile URL-Leiste */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Kein Pull-to-Refresh mitten im Zeichnen, kein grauer Tap-Blitz. */
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* Doppeltipp-Zoom auf Bedienelementen unterbinden; die Karte regelt ihr
   Touch-Verhalten selbst. */
body.client button,
body.client a,
body.client input,
body.client select,
body.client label {
  touch-action: manipulation;
}

.app-top {
  flex: 0 0 auto;
  position: relative;
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 14px;
  padding-left: calc(14px + env(safe-area-inset-left));
  padding-right: calc(14px + env(safe-area-inset-right));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 900;
}

/* Logo mittig in der Kopfzeile, unabhängig vom Zurück-Knopf links. */
.brand {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.brand-logo {
  height: 24px;
  width: auto;
  display: block;
}

.nav-back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  background: none;
  border: 0;
  padding: 8px 10px 8px 6px;
  margin-left: -6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.nav-back:hover {
  background: var(--brand-soft);
  color: var(--brand-ink);
}

.nav-back svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Auf sehr schmalen Geräten würde der Schriftzug „Zurück“ dem mittigen Logo
   zu nahe kommen; dort bleibt nur der Pfeil. */
@media (max-width: 370px) {
  .nav-back {
    font-size: 0;
    gap: 0;
    padding: 10px;
  }
  .nav-back svg {
    width: 20px;
    height: 20px;
  }
}

.app-main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  isolation: isolate;
}

/* Derselbe beschriftungsfreie Karten-Bake wie im normalen Parcelscan liegt
   hinter dem gesamten Client-Flow. Auswahl und Danke-Screen zeigen ihn offen;
   in den Karten-Screens wird er von der interaktiven Leaflet-Karte verdeckt. */
.app-main::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: url("/static/assets/map-light.jpg") center / cover no-repeat;
  opacity: 0.9;
}

:root[data-theme="dark"] .app-main::before {
  background-image: url("/static/assets/map-dark.jpg");
  opacity: 0.5;
}

.screen {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

/* --- 1 · Auswahl ----------------------------------------------------------- */

.screen-choice {
  overflow-y: auto;
  align-items: center;
  padding: clamp(22px, 5vh, 56px) 20px 32px;
}

.choice-inner {
  width: min(100%, 560px);
  animation: fade-up var(--dur-slow) var(--ease) both;
}

.choice-inner h1 {
  font-size: clamp(1.7rem, 5.6vw, 2.5rem);
  margin-bottom: 0.4em;
}

.choice-cards {
  display: grid;
  gap: 12px;
  /* Beide Karten gleich hoch, egal wie lang ihr Text ist. */
  grid-auto-rows: 1fr;
  margin-top: clamp(20px, 4vh, 34px);
}

.choice-card {
  display: flex;
  align-items: center;
  gap: 15px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition:
    border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.choice-card:hover,
.choice-card:focus-visible {
  border-color: var(--brand);
  box-shadow: var(--shadow-brand);
}

.choice-card:active {
  transform: scale(0.99);
}

.choice-icon {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--brand-soft);
}

.choice-icon svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: var(--brand-ink);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.choice-icon svg .bolt {
  stroke: var(--brand-strong);
  stroke-width: 1.9;
}

.choice-icon svg .thin {
  stroke-width: 1.1;
  opacity: 0.65;
}

.choice-text {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.choice-text strong {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}

.choice-text span {
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--muted);
}

.choice-arrow {
  flex: 0 0 auto;
  margin-left: auto;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--brand-ink);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--dur-fast) var(--ease);
}

.choice-card:hover .choice-arrow {
  transform: translateX(3px);
}

.choice-note {
  margin-top: 18px;
}

/* --- Kartenbühne ----------------------------------------------------------- */

.screen-map {
  animation: fade-up var(--dur) var(--ease) both;
}

.map-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--surface-2);
}

.map-canvas {
  position: absolute;
  inset: 0;
}

/* Auf der Grundstückskarte sitzt rechts unten bereits der Ebenen-Umschalter;
   das kompakte Quellen-i steht deshalb direkt darüber. */
#screen-site .map-data {
  bottom: 58px;
}

.leaflet-container {
  font: inherit;
  background: var(--surface-2);
}

.leaflet-control-zoom a {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
  font-weight: 600;
}

.leaflet-control-zoom a:hover {
  background: var(--surface-2) !important;
  color: var(--brand-deep) !important;
}

.leaflet-bar {
  box-shadow: var(--shadow-sm) !important;
  border: none !important;
}

/* Fadenkreuz im Zeichenmodus (map.js setzt .is-drawing auf #map-wrap). */
.map-stage.is-drawing .leaflet-container {
  cursor: crosshair;
}

/* --- Suche über der Karte (aus tool.css übernommen) ------------------------ */

.tool-search {
  position: absolute;
  z-index: 1100; /* über Leaflet-Controls (1000) und dem Kartenhinweis */
  top: 12px;
  left: 58px; /* Platz für Leaflets Zoom-Buttons */
  right: 12px;
  max-width: 480px;
}

.tool-search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px 5px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  transition:
    border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}

.tool-search-field:focus-within {
  border-color: rgba(98, 193, 179, 0.7);
  box-shadow: var(--shadow-md), 0 0 0 4px rgba(98, 193, 179, 0.16);
}

.tool-search-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
}

.tool-search-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 16px; /* < 16px zoomt iOS beim Fokus in die Seite */
  color: var(--text);
  padding: 8px 0;
  outline: none;
}

.tool-search-field input::placeholder {
  color: var(--muted);
}

.tool-search-results {
  list-style: none;
  margin: 8px 0 0;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: min(300px, 42vh);
  overflow-y: auto;
  animation: fade-up var(--dur-fast) var(--ease) both;
}

.tool-search-results li button {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 11px;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease);
}

.tool-search-results li button:hover {
  background: var(--brand-soft);
}

.tool-search-empty {
  padding: 10px 11px;
  font-size: 0.88rem;
  color: var(--muted);
}

/* --- Layer-Umschalter + Hinweis -------------------------------------------- */

.map-layer-switch {
  position: absolute;
  z-index: 600;
  right: 12px;
  bottom: 12px;
  display: flex;
  padding: 4px;
  gap: 3px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.map-layer-switch button {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
}

.map-layer-switch button.is-active {
  background: var(--brand-soft);
  color: var(--brand-ink);
}

.map-hint {
  position: absolute;
  z-index: 600;
  left: 12px;
  right: 110px;
  bottom: 12px;
  max-width: 340px;
  padding: 9px 13px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition:
    opacity var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}

.map-hint.is-visible {
  opacity: 1;
  transform: none;
}

/* --- Ladebedarf-Pin -------------------------------------------------------- */

#demand-map {
  cursor: crosshair;
}

.demand-pin-wrap {
  background: none;
  border: 0;
}

.demand-pin {
  width: 34px;
  height: 44px;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.38));
  transform-origin: 50% 100%;
  animation: demand-pin-drop 180ms var(--ease) both;
}

.demand-pin svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: #62c1b3;
  stroke: #ffffff;
  stroke-width: 1.7;
  stroke-linejoin: round;
}

.demand-pin svg .sigma {
  fill: #ffffff;
  stroke: none;
}

.leaflet-marker-draggable .demand-pin {
  cursor: grab;
}

.leaflet-marker-draggable:active .demand-pin {
  cursor: grabbing;
  transform: scale(1.06);
}

@keyframes demand-pin-drop {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* --- Zeichen-Handles (aus tool.css übernommen, map.js erwartet die Klassen) - */

.vertex-handle {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #62c1b3;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
  cursor: grab;
  transition: transform 120ms var(--ease);
}

.vertex-handle:hover {
  transform: scale(1.25);
}

.vertex-handle.is-first {
  background: #62c1b3;
  border-color: #ffffff;
}

.leaflet-marker-draggable:active .vertex-handle,
.vertex-handle:active {
  cursor: grabbing;
}

.vertex-midpoint {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid #62c1b3;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
  opacity: 0.7;
  cursor: copy;
  transition:
    transform 120ms var(--ease),
    opacity 120ms var(--ease);
}

.vertex-midpoint:hover {
  opacity: 1;
  transform: scale(1.35);
}

/* --- Fußleiste der Karten-Screens ------------------------------------------ */

.flow-bar {
  flex: 0 0 auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: grid;
  gap: 10px;
  z-index: 700;
}

.flow-step {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.flow-step b {
  color: var(--brand-ink);
  font-family: var(--font-mono);
  font-weight: 600;
  margin-right: 6px;
}

.flow-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.flow-actions .btn {
  flex: 1 1 auto;
}

/* Im Zeichenmodus stehen drei Knöpfe nebeneinander; auf schmalen Handys
   werden sie kompakter statt dreizeilig. */
@media (max-width: 420px) {
  .flow-actions .btn {
    padding: 12px 10px;
    font-size: 0.88rem;
    gap: 6px;
  }
}

.btn-arrow {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-block {
  width: 100%;
}

/* Next step shown but locked until a location exists, so the requirement is
   visible before anyone taps the map by accident. */
.btn.is-locked {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

/* --- Ladebedarf: Region + Volumen ------------------------------------------ */

.region-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: var(--brand-soft);
  border: 1px solid rgba(98, 193, 179, 0.4);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--brand-ink);
}

.region-chip svg {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.region-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.region-chip button {
  margin-left: auto;
  flex: 0 0 auto;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brand-ink);
  background: none;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 2px 4px;
}

.volume-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) 2fr;
  gap: 8px;
}

.volume-row .field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
}

.volume-row input,
.volume-row select {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 12px;
  outline: none;
  transition:
    border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}

.volume-row input:focus,
.volume-row select:focus {
  border-color: rgba(98, 193, 179, 0.7);
  box-shadow: 0 0 0 4px rgba(98, 193, 179, 0.16);
}

/* --- E-Mail-Gate ------------------------------------------------------------ */

.gate-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(10, 26, 24, 0.45);
  backdrop-filter: blur(3px);
  animation: fade-in var(--dur-fast) var(--ease) both;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.gate-card {
  width: min(100%, 520px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg);
  animation: sheet-up var(--dur) var(--ease) both;
}

@keyframes sheet-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@media (min-width: 640px) {
  .gate-backdrop {
    align-items: center;
    padding: 24px;
  }
  .gate-card {
    border-radius: var(--radius-xl);
    padding-bottom: 22px;
  }
}

.gate-card h2 {
  font-size: 1.3rem;
  margin-bottom: 0.35em;
}

.gate-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  padding: 11px 13px;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-strong);
}

.gate-summary .gate-summary-kind {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-ink);
  background: var(--brand-soft);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
}

#gate-form {
  display: grid;
  gap: 12px;
}

#gate-email {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  outline: none;
  transition:
    border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}

#gate-email:focus {
  border-color: rgba(98, 193, 179, 0.7);
  box-shadow: 0 0 0 4px rgba(98, 193, 179, 0.16);
}

.consent {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--muted);
  cursor: pointer;
}

.consent input {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  margin-top: 2px;
  accent-color: var(--brand-strong);
}

.gate-error {
  margin: 0;
  font-size: 0.85rem;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
}

.gate-actions {
  display: flex;
  gap: 8px;
}

.gate-actions .btn-ghost {
  flex: 0 0 auto;
}

.gate-actions .btn-primary {
  flex: 1 1 auto;
}

/* --- Danke ------------------------------------------------------------------ */

.screen-done {
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  text-align: center;
}

.done-inner {
  width: min(100%, 420px);
  animation: fade-up var(--dur-slow) var(--ease) both;
}

.done-check {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brand-soft);
  border: 2px solid var(--brand);
}

.done-check svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: var(--brand-ink);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Visible field label in the e-mail gate: the form asks explicitly for the
   company address, so the label must not stay screen-reader-only. */
.gate-label {
  display: block;
  margin: 0 0 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-strong);
}

/* Während der Ortssuche weicht der Kartenhinweis: bei geöffneter Tastatur ist
   die Karte so niedrig, dass er sonst über den Vorschlägen liegt. */
.map-stage.is-searching .map-hint {
  opacity: 0;
  transform: translateY(6px);
}
