/* Kiosk — der große Bildschirm am Messestand.
 *
 * Läuft wahlweise hell oder dunkel (Umschalter unten links bzw. ?theme=light)
 * und mit CARTO-Karte oder Satellitenbild (?layer=satellit). Alle Farben
 * hängen deshalb an den Tokens aus base.css; nur die Zahlen-Labels auf der
 * Karte brauchen eigene Regeln pro Untergrund. Keine Interaktion nötig —
 * alles, was die Seite erzählt, erzählt sie von selbst.
 */

body.kiosk {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 1fr clamp(340px, 27vw, 480px);
  overflow: hidden;
}

/* --- Karte ------------------------------------------------------------------ */

.kiosk-map-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

#kiosk-map {
  position: absolute;
  inset: 0;
  background: var(--surface-2);
}

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

/* Leaflet 1.9.4 nutzt standardmäßig `plus-lighter`; bei überlappenden Tiles
   zeichnet das die Ränder als helle Linien nach. kiosk.js erweitert jede
   Kachel um 2 px, und normaler Blend-Modus lässt die Nachbarkachel die Fuge
   sauber überdecken. Gilt für Karte, Satellit und das Namens-Overlay. */
#kiosk-map .leaflet-tile-pane img.leaflet-tile {
  mix-blend-mode: normal !important;
}

.live-badge {
  position: absolute;
  z-index: 800;
  top: 18px;
  left: 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-strong);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-md);
}

.live-badge.is-stale {
  color: var(--muted);
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #58c294;
  box-shadow: 0 0 0 0 rgba(88, 194, 148, 0.55);
  animation: live-pulse 2s var(--ease) infinite;
}

.live-badge.is-stale .live-dot {
  background: var(--muted);
  animation: none;
}

@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(88, 194, 148, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(88, 194, 148, 0); }
  100% { box-shadow: 0 0 0 0 rgba(88, 194, 148, 0); }
}

/* --- Ansichts-Umschalter (Hell/Dunkel · Karte/Satellit) --------------------- */

.view-switch {
  position: absolute;
  z-index: 800;
  left: 18px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.view-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 12px;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
}

.view-switch button:hover {
  color: var(--text-strong);
}

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

.kiosk-map-wrap .map-data {
  right: 18px;
  bottom: 18px;
}

.view-sep {
  width: 1px;
  height: 20px;
  margin: 0 4px;
  background: var(--border);
}

/* Anzahl-Label in den Ladebedarf-Kreisen: nackte Zahl, kein Tooltip-Kasten.
   Helle Zahl mit dunklem Halo — passt auf dunkle Karte und Satellitenbild. */
.leaflet-tooltip.demand-count {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: #ffe9c4;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.85rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}

/* Auf der hellen CARTO-Karte kehrt sich das um: dunkle Zahl, heller Halo.
   Satellitenbild bleibt auch im hellen Theme dunkler Untergrund. */
:root[data-theme="light"] body.kiosk:not(.is-satellite) .leaflet-tooltip.demand-count {
  color: #6b4a0e;
  text-shadow:
    0 0 3px rgba(255, 255, 255, 0.9),
    0 1px 4px rgba(255, 255, 255, 0.8);
}

.leaflet-tooltip.demand-count::before {
  display: none;
}

/* Hover-Tooltips im Kiosk-Stil. */
.leaflet-tooltip.kiosk-tip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  box-shadow: var(--shadow-md);
  font-size: 0.85rem;
}

.leaflet-tooltip.kiosk-tip::before {
  display: none;
}

/* Reveal eines neuen Ladebedarfs. Der SVG-Pfad beginnt bei zwölf Uhr und ist
   im Uhrzeigersinn definiert; kiosk.js bewegt seinen Dash-Offset erst zum
   Zeichnen vorwärts und anschließend zum Abbauen in derselben Richtung. */
.demand-reveal-wrap {
  background: transparent;
  border: 0;
}

.demand-reveal,
.demand-reveal svg {
  width: 100%;
  height: 100%;
}

.demand-reveal {
  position: relative;
  filter:
    drop-shadow(0 1px 2px rgba(0, 0, 0, 0.82))
    drop-shadow(0 0 9px rgba(98, 193, 179, 0.48));
}

.demand-reveal svg {
  display: block;
  overflow: visible;
}

.demand-reveal-ring {
  fill: none;
  stroke: #62c1b3;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-dasharray: 0.045 0.03;
  vector-effect: non-scaling-stroke;
}

.demand-reveal-mask {
  fill: none;
  stroke: #ffffff;
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
}

.leaflet-overlay-pane path.demand-marker-reveal {
  animation: demand-marker-pulse 1.35s var(--ease) infinite;
}

@keyframes demand-marker-pulse {
  0% {
    filter: drop-shadow(0 0 2px rgba(255, 207, 105, 0.75));
    stroke-width: 1.5;
  }
  50% {
    filter:
      drop-shadow(0 0 7px rgba(255, 207, 105, 1))
      drop-shadow(0 0 15px rgba(224, 180, 88, 0.72));
    stroke-width: 3;
  }
  100% {
    filter: drop-shadow(0 0 2px rgba(255, 207, 105, 0.75));
    stroke-width: 1.5;
  }
}

/* Kurzer Premium-Reveal für ein neu eingezeichnetes Grundstück. Die eigentliche
   Bewegung des diagonalen Gradienten steuert kiosk.js direkt im SVG. */
.leaflet-overlay-pane path.parcel-shine-active {
  filter:
    drop-shadow(0 0 5px rgba(156, 235, 221, 0.95))
    drop-shadow(0 0 14px rgba(98, 193, 179, 0.75));
}

/* --- Seitenpanel ------------------------------------------------------------ */

.kiosk-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: clamp(14px, 1.8vh, 22px);
  padding: clamp(18px, 2.4vh, 30px) clamp(18px, 1.8vw, 30px);
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow: hidden;
}

.kiosk-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.kiosk-brand .brand-logo {
  height: clamp(22px, 2.6vh, 30px);
  width: auto;
}

.brand-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
}

.brand-product {
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}

.kiosk-panel h1 {
  font-size: clamp(1.35rem, 1.9vw, 2rem);
  margin: 0;
}

/* --- KPIs ------------------------------------------------------------------- */

/* Instrumententafel statt Kacheln: Haarlinien trennen die drei Werte, Farbe
   sitzt allein in der Zahl und entspricht dem jeweiligen Kartensymbol. */
.kpis {
  display: grid;
  grid-template-columns: 1fr;
  border-block: 1px solid var(--border);
}

.kpi {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  align-items: center;
  gap: 15px;
  padding: clamp(9px, 1.25vh, 13px) 0;
}

.kpi + .kpi {
  border-top: 1px solid var(--border);
}

.kpi strong {
  font-size: clamp(1.5rem, 2.2vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  text-align: right;
}

.kpi-demand strong {
  color: var(--warning);
}

.kpi-site strong {
  color: var(--success);
}

.kpi-station {
  grid-column: auto;
}

.kpi-station strong {
  color: #2f6fed;
}

.kpi span {
  font-size: clamp(0.72rem, 0.85vw, 0.85rem);
  color: var(--muted);
  line-height: 1.35;
  min-width: 0;
}

/* --- Legende ---------------------------------------------------------------- */

.legend {
  display: flex;
  gap: 10px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.legend-demand {
  background: #e0b458;
  box-shadow: 0 0 8px rgba(224, 180, 88, 0.6);
}

.legend-site {
  background: #62c1b3;
  box-shadow: 0 0 8px rgba(98, 193, 179, 0.6);
}

.legend-station {
  background: #62c1b3;
  box-shadow: 0 0 8px rgba(98, 193, 179, 0.58);
}

/* --- Ladestandort-Pins ------------------------------------------------------ */

.station-pin-wrap {
  background: none;
  border: none;
}

.station-pin {
  position: relative;
  width: 30px;
  height: 38px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

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

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

.station-badge {
  position: absolute;
  top: -5px;
  right: -7px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: #ffffff;
  border: 1.5px solid #62c1b3;
  color: #0b756b;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

/* --- Feed ------------------------------------------------------------------- */

.feed-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.feed-wrap h2 {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.feed {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  /* Der Feed füllt den Rest des Panels; ältere Einträge laufen unten aus. */
  mask-image: linear-gradient(to bottom, #000 78%, transparent 100%);
}

.feed li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--border-2);
  font-size: clamp(0.82rem, 0.95vw, 0.95rem);
}

.feed li.is-new {
  animation: fade-up var(--dur) var(--ease) both;
}

/* Frisch eingetroffene Zeilen kündigt der Punkt an, nicht ein Rahmen. */
.feed li.is-new .feed-kind.is-site {
  box-shadow: 0 0 10px rgba(98, 193, 179, 0.9);
}

.feed li.is-new .feed-kind.is-demand {
  box-shadow: 0 0 10px rgba(224, 180, 88, 0.9);
}

.feed-kind {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.feed-kind.is-site { background: #62c1b3; }
.feed-kind.is-demand { background: #e0b458; }

.feed-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.feed-text strong {
  color: var(--text-strong);
  font-weight: 600;
}

.feed-time {
  flex: 0 0 92px;
  width: 92px;
  margin-left: auto;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--muted);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  /* nowrap, sonst löst der Flex-Algorithmus die Breite als min-content auf
     und „gerade eben“ bricht um. */
  white-space: nowrap;
}

.feed-empty {
  font-size: 0.9rem;
  padding: 8px 2px;
}

/* --- Mitmachen (QR) ---------------------------------------------------------- */

.join {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 1.6vh, 18px);
  background: var(--brand-softer);
  border: 1px solid rgba(98, 193, 179, 0.35);
  border-radius: var(--radius-lg);
}

.qr {
  flex: 0 0 auto;
  width: clamp(96px, 11vh, 150px);
  height: clamp(96px, 11vh, 150px);
  display: grid;
  place-items: center;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px;
}

.qr svg {
  width: 100%;
  height: 100%;
  display: block;
}

.qr:empty {
  display: none;
}


.credit {
  flex: 0 0 auto;
  margin: 0;
  font-size: 0.68rem;
}

/* --- Hochformat / schmale Screens ------------------------------------------- */

@media (max-width: 900px), (orientation: portrait) {
  body.kiosk {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  .kiosk-panel {
    border-left: 0;
    border-top: 1px solid var(--border);
    max-height: 46vh;
  }
}
