/* --- Grundlayout --- */
.kran-compare-page {
  margin: 40px auto;
  padding: 0 20px;
  color: #333;
}

.compare-wrapper {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.compare-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  border-bottom: 1px solid #ccc;
}

.compare-cell {
  flex: 1;
  padding: 12px;
  min-width: 0;
  box-sizing: border-box;
  border-right: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.compare-cell.header {
  font-weight: bold;
  background: #f5f5f5;
  color: #000;
  justify-content: flex-start;
}

.compare-row:first-child .compare-cell {
  border-top: 1px solid #ccc;
}

.compare-row:last-child {
  border-bottom: 2px solid #164194;
}

/* --- Dropdown Styling --- */
.compare-cell select.kran-compare-dropdown {
  width: 90%;
  padding: 6px 10px;
  font-size: 14px;
  border: 1px solid #aaa;
  border-radius: 4px;
  background: #fff;
  transition: border-color 0.2s ease;
}

.compare-cell select.kran-compare-dropdown:focus {
  outline: none;
  border-color: #e3000f;
}

/* --- Entfernen-Button neben Dropdown --- */
.kran-delete-btn {
  background: #e3000f;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-weight: bold;
}

/* --- Tabelle bei Ausgabe-Modus --- */
.kran-vergleich-tabelle {
  width: 100%;
  border-collapse: collapse;
  margin-top: 30px;
}

.kran-vergleich-tabelle th,
.kran-vergleich-tabelle td {
  border: 1px solid #ccc;
  padding: 10px;
  text-align: center;
}

.kran-vergleich-tabelle th {
  background: #f0f0f0;
}

.kran-vergleich-tabelle img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border: 1px solid #ddd;
  padding: 4px;
  background: #fff;
}

/* --- Hinweisbox statt alert --- */
.vergleich-hinweis {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 12px 20px;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  transition: opacity 0.3s ease;
  font-size: 15px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.vergleich-hinweis.sichtbar {
  opacity: 1;
}

/* --- "+ Vergleich" Button --- */
.kran-vergleichen-btn.added-animate {
  animation: vergleichAdded 0.6s ease-out;
  background-color: #4CAF50 !important;
  color: #fff !important;
}

@keyframes vergleichAdded {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.20); }
  70%  { transform: scale(0.95); }
  100% { transform: scale(1); }
}

/* Fixierter Vergleichs-Button rechts neben der Tabelle */
#bild-vergleich-btn.fixed-compare-btn {
    position: fixed;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 9999;
    padding: 14px 22px;
    font-size: 16px;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 10px;
}

/* Auf kleinen Screens lieber unten fixieren */
@media (max-width: 1100px) {
    #bild-vergleich-btn.fixed-compare-btn {
        right: 20px;
        top: auto;
        bottom: 20px;
        transform: none;
    }
}

/* --- Responsive (einfaches Beispiel) --- */
@media screen and (max-width: 768px) {
  .compare-row {
    flex-direction: column;
  }

  .compare-cell {
    border-right: none;
    justify-content: flex-start;
    text-align: left;
  }

  .compare-cell select.kran-compare-dropdown {
    width: 100%;
  }
}

/* Bounce-Animation für den Vergleichs-Counter */
.kran-counter-bounce {
  animation: counterBounce 0.6s ease-out;
}

@keyframes counterBounce {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.35); }
  55%  { transform: scale(0.9); }
  75%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ===========================================================
 * FADENKREUZ AUF LASTENDIAGRAMMEN
 * Vergleichsseite ("Diagramme vergleichen") und Produktseite
 * (Klick aufs Diagramm). Aufbau wie im Messe-Terminal.
 * =========================================================== */

/* Symbol für Hinweis und Knopf */
.kv-fk-icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* --- Produktseite: Knopf unter dem Diagramm --- */
.klaas-btn.kv-fk-start {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  margin: 12px auto 0;
}
.klaas-btn.kv-fk-start .kv-fk-icon { color: #e3000f; }
a.kv-fk-link { cursor: crosshair; }

/* --- Dialog --- */
html.kv-fk-offen { overflow: hidden; }   /* Seite dahinter scrollt nicht mit */

.kv-fk-dialog {
  --kv-fk-rot: #e3000f;
  --kv-fk-max-h: calc(100dvh - 240px);
  box-sizing: border-box;
  width: min(96vw, 1800px);
  max-width: none;
  max-height: calc(100vh - 16px);
  max-height: calc(100dvh - 16px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #fff;
  color: #3A404B;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .35);
  overflow: auto;
}
.kv-fk-dialog::backdrop { background: rgba(24, 24, 27, .85); }

.kv-fk-innen { padding: 14px 20px 20px; }

.kv-fk-kopf {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}
.kv-fk-dialog .kv-fk-titel {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  font-size: 20px;
  line-height: 1.3;
  font-weight: 700;
  color: #164194;
}
.kv-fk-hinweis {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  line-height: 1.3;
  color: #5A5A5A;
}
.kv-fk-hinweis .kv-fk-icon { color: var(--kv-fk-rot); }
.kv-fk-hinweis-maus { display: none; }
@media (hover: hover) and (pointer: fine) {
  .kv-fk-hinweis-maus  { display: inline; }
  .kv-fk-hinweis-touch { display: none; }
}
.kv-fk-dialog .kv-fk-schliessen {
  flex: none;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #F0F2F5;
  color: #164194;
  font-size: 20px;
  line-height: 44px;
  text-align: center;
  cursor: pointer;
}
.kv-fk-dialog .kv-fk-schliessen:hover,
.kv-fk-dialog .kv-fk-schliessen:focus-visible { background: #B4CDF0; }

/* Zwei Diagramme nebeneinander, eins allein größer */
.kv-fk-paar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: start;
}
.kv-fk-paar.einzeln { grid-template-columns: minmax(0, 1fr); }

/* Gemeinsamer Maßstab: Bildgrößen setzt das Skript, unten bündig, damit
 * die 0-m-Linien beider Diagramme auf einer Höhe liegen */
.kv-fk-paar.massstab { align-items: end; }
.kv-fk-paar.massstab .kv-fk-flaeche img { max-width: none; max-height: none; }

.kv-fk {
  margin: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.kv-fk-unterschrift {
  width: 100%;
  margin: 0 0 8px;
  padding: 0;
  text-align: center;
  font-size: 16px;
  line-height: 1.3;
}
.kv-fk-unterschrift b { color: #164194; }

/* Messwerte am Kreuz */
.kv-fk-werte {
  display: block;
  min-height: 1.3em;
  margin-top: 2px;
  font-size: 14px;
  color: #3A404B;
  font-variant-numeric: tabular-nums;
}
.kv-fk-werte:empty { min-height: 0; margin: 0; }

.kv-fk-dialog .kv-fk-fuss {
  margin: 12px 0 0;
  padding: 0;
  font-size: 13px;
  line-height: 1.4;
  color: #5A5A5A;
  text-align: center;
}
.kv-fk-dialog .kv-fk-fuss[hidden] { display: none; }

/* Die Fläche ist genau so groß wie das Bild - Linien und Lupe beziehen
 * sich auf das Bild, nicht auf den Platz drumherum */
.kv-fk-flaeche {
  --x: .5;
  --y: .5;
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  outline-offset: 3px;
  cursor: crosshair;
  touch-action: none;            /* Ziehen bewegt das Kreuz, nicht die Seite */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.kv-fk-flaeche img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: var(--kv-fk-max-h);   /* beide Diagramme ganz sichtbar, ohne Scrollen */
  margin: 0;
  padding: 0;
  border: 0;
  box-shadow: 0 0 0 1px #ddd;
  border-radius: 4px;
  pointer-events: none;
}

.kv-fk-linie { position: absolute; background: var(--kv-fk-rot); pointer-events: none; }
.kv-fk-h { left: 0; right: 0; height: 2px; top: calc(var(--y) * 100%); margin-top: -1px; }
.kv-fk-v { top: 0; bottom: 0; width: 2px; left: calc(var(--x) * 100%); margin-left: -1px; }
.kv-fk-punkt {
  position: absolute;
  left: calc(var(--x) * 100%);
  top: calc(var(--y) * 100%);
  width: 18px;
  height: 18px;
  box-sizing: border-box;
  transform: translate(-50%, -50%);
  border: 2px solid var(--kv-fk-rot);
  border-radius: 50%;
  pointer-events: none;
}

/* Lupe über dem Finger: zeigt das Bild 2,5-fach um den Schnittpunkt.
 * --w/--h = dargestellte Bildgröße in px (setzt das Skript). Der Rand
 * von 3px verschiebt die Mitte des Hintergrunds, daher "- 3px". */
.kv-fk-lupe {
  --d: clamp(120px, 24vmin, 176px);
  --z: 2.5;
  display: none;
  position: absolute;
  z-index: 2;
  box-sizing: border-box;
  width: var(--d);
  height: var(--d);
  left: clamp(calc(var(--d) / 2), calc(var(--x) * 100%), calc(100% - var(--d) / 2));
  top: calc(var(--y) * 100%);
  transform: translate(-50%, calc(-100% - 28px));
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 8px 24px rgba(24, 32, 48, .3);
  background-color: #fff;
  background-repeat: no-repeat;
  background-size: calc(var(--w) * var(--z)) calc(var(--h) * var(--z));
  background-position:
    calc(var(--d) / 2 - 3px - var(--x) * var(--w) * var(--z))
    calc(var(--d) / 2 - 3px - var(--y) * var(--h) * var(--z));
  pointer-events: none;
}
.kv-fk-flaeche.zieht .kv-fk-lupe { display: block; }
.kv-fk-lupe.unten { transform: translate(-50%, 28px); }
.kv-fk-lupe::before,
.kv-fk-lupe::after { content: ''; position: absolute; background: var(--kv-fk-rot); }
.kv-fk-lupe::before { left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px; }
.kv-fk-lupe::after  { top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; }

/* Smartphone hochkant: untereinander, beide trotzdem ohne Scrollen */
@media (max-width: 760px) and (orientation: portrait) {
  .kv-fk-innen { padding: 10px 12px 14px; }
  .kv-fk-kopf { flex-wrap: wrap; gap: 6px 12px; }
  .kv-fk-hinweis { order: 3; width: 100%; }
  .kv-fk-paar { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .kv-fk-dialog {
    width: calc(100vw - 16px);
    --kv-fk-max-h: calc((100dvh - 330px) / 2);
  }
  .kv-fk-paar.einzeln { --kv-fk-max-h: calc(100dvh - 260px); }
}