/* ============================================================
   BESD Bild – Frontend + Editor
   - Frontend: Cover-Link klickt überall
   - Editor: Höhe-Handle (unten) + Fokus-Handle (rechts vertikal)
   ============================================================ */

/* Container */
.besd-bild {
  position: relative;
  display: block;
  margin: 5px 0;
  max-width: 100%;
  border-radius: 16px;
  overflow: hidden;
  background: var(--red2);
  box-shadow: var(--bildshadow); 
}

/* Klickcursor wenn Link gesetzt */
.besd-bild--linked { cursor: pointer; }

/* Bild */
.besd-bild img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  /* object-position kommt inline aus PHP/Editor */
}

/* Placeholder (Editor wenn kein Bild) */
.besd-bild__placeholder {
  width: 100%;
  padding: 40% 0;
  background: #f3f4f6;
  text-align: center;
  font-family: "Roboto Condensed", sans-serif;
  font-size: 14px;
  color: #111;
}

/* Cover-Link (Frontend): liegt über allem */
.besd-bild__coverlink {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: block;
  text-decoration: none;
  cursor: pointer;
}

/* Caption (Overlay) */
.besd-bild figcaption {
  position: absolute;
  bottom: 0;
  width: 100%;
  padding: 48px 16px 12px 16px;
  color: #fff;
  font-size: 18px;
  line-height: 22px;
  text-shadow: 0 6px 12px rgba(0, 0, 0, 0.99);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.65) 22%, rgba(0, 0, 0, 0) 100%);
  font-family: "Roboto Condensed", sans-serif;

  /* Frontend: Caption fängt keine Klicks ab (Cover-Link macht Klick) */
  pointer-events: none;
}

/* Editor: Caption muss editierbar bleiben */
.besd-img-editor-wrap .besd-bild.is-editor figcaption {
  pointer-events: auto;
}

/* ============================================================
   Editor-UI (wie Spacer): Label + Handles
   ============================================================ */

/* Default: Frontend zeigt UI nie */
.besd-bild__label,
.besd-bild__focuslabel,
.besd-bild__handle,
.besd-bild__focus { display: none; }

/* Editor: anzeigen */
.editor-styles-wrapper .besd-bild.is-editor .besd-bild__label,
.editor-styles-wrapper .besd-bild.is-editor .besd-bild__focuslabel,
.editor-styles-wrapper .besd-bild.is-editor .besd-bild__handle,
.editor-styles-wrapper .besd-bild.is-editor .besd-bild__focus,
.block-editor-writing-flow .besd-bild.is-editor .besd-bild__label,
.block-editor-writing-flow .besd-bild.is-editor .besd-bild__focuslabel,
.block-editor-writing-flow .besd-bild.is-editor .besd-bild__handle,
.block-editor-writing-flow .besd-bild.is-editor .besd-bild__focus {
  display: block;
}

/* px-Label oben links */
.editor-styles-wrapper .besd-bild.is-editor .besd-bild__label,
.block-editor-writing-flow .besd-bild.is-editor .besd-bild__label {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 60;
  padding: 2px 8px;
  min-height: 18px;
  line-height: 1;
  white-space: nowrap;
  font-size: 12px;
  color: #111;
  background: rgba(255,255,255,.95);
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 999px;
  pointer-events: none;
  user-select: none;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

/* Fokus-Label oben rechts (klein) */
.editor-styles-wrapper .besd-bild.is-editor .besd-bild__focuslabel,
.block-editor-writing-flow .besd-bild.is-editor .besd-bild__focuslabel {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 60;
  padding: 2px 8px;
  min-height: 18px;
  line-height: 1;
  white-space: nowrap;
  font-size: 12px;
  color: #111;
  background: rgba(255,255,255,.95);
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 999px;
  pointer-events: none;
  user-select: none;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

/* Handle 1: Höhe unten zentriert */
.editor-styles-wrapper .besd-bild.is-editor .besd-bild__handle,
.block-editor-writing-flow .besd-bild.is-editor .besd-bild__handle {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  width: 44px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.15);
  background: linear-gradient(#fff, #f3f4f6);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
  cursor: ns-resize;
  z-index: 60;
}

.editor-styles-wrapper .besd-bild.is-editor .besd-bild__handle:before,
.block-editor-writing-flow .besd-bild.is-editor .besd-bild__handle:before {
  content: "";
  position: absolute;
  inset: 5px 12px;
  border-top: 2px solid #9ca3af;
  border-bottom: 2px solid #9ca3af;
  border-radius: 2px;
}

/* Handle 2: Fokus rechts (vertikaler Slider) */
.editor-styles-wrapper .besd-bild.is-editor .besd-bild__focus,
.block-editor-writing-flow .besd-bild.is-editor .besd-bild__focus {
  --besd-focus-y: 50; /* wird inline überschrieben */
  position: absolute;
  right: 10px;
  top: 42px;
  bottom: 10px;
  width: 22px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.15);
  background: rgba(255,255,255,.92);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
  cursor: ns-resize;
  z-index: 60;
  padding: 0;
}

/* Track-Linie */
.editor-styles-wrapper .besd-bild.is-editor .besd-bild__focus:before,
.block-editor-writing-flow .besd-bild.is-editor .besd-bild__focus:before {
  content: "";
  position: absolute;
  left: 50%;
  top: 8px;
  bottom: 8px;
  width: 2px;
  transform: translateX(-50%);
  background: rgba(0,0,0,.20);
  border-radius: 2px;
}

/* Thumb */
.editor-styles-wrapper .besd-bild.is-editor .besd-bild__focus:after,
.block-editor-writing-flow .besd-bild.is-editor .besd-bild__focus:after {
  content: "";
  position: absolute;
  left: 50%;
  top: calc((var(--besd-focus-y) * 1%) - 7px);
  width: 14px;
  height: 14px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: #111;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
}

.editor-styles-wrapper .besd-bild.is-editor .besd-bild__handle:focus,
.editor-styles-wrapper .besd-bild.is-editor .besd-bild__focus:focus {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* Editor wrapper */
.besd-img-editor-wrap { margin-bottom: 0.5rem; }