/* =============================================================
   Slider-Plugin – plugin.css  v3.0 (08/2025)
   -------------------------------------------------------------
   • Viewport mit variablem Seitenverhältnis (Default 2:1)
   • Bild-Fit per Variable: cover | contain
   • Externe Caption-Zeile unter dem Bild
   • Dots/Buttons im Viewport, kein Overlap
   • Dark-Mode, A11y, Responsive & Fallback
   • Kompaktmodus: Controls ausblenden, bei Interaktion einblenden
   ============================================================= */

/*****************************************************************
 * 1.  Globale Variablen (Farben, Ratio, Fit)
 *****************************************************************/
:root {
  /* UI-Farben */
  --mr-btn-bg:   rgba(0, 0, 0, 0.40);
  --mr-ui-text:      #f2f2f2;

  /* Caption-Farben */
  --mr-caption-text: #111111;
  --mr-caption-bg:   rgba(255,255,255,.85);
  --mr-caption-border: rgba(0,0,0,.08);

  /* Layout */
  --mr-ar:  2 / 1;
  --mr-fit: cover;
}

@media (prefers-color-scheme: dark) {
  :root {
    --mr-btn-bg:   rgba(255,255,255,0.30);
    --mr-ui-text:  #ffffff;

    --mr-caption-text: #ffffff;
    --mr-caption-bg:   rgba(0,0,0,.55);
    --mr-caption-border: rgba(255,255,255,.14);
  }
}

/*****************************************************************
 * 2.  Reset nur im Slider-Scope
 *****************************************************************/
.mr-slider, .mr-slider * { box-sizing: border-box; margin: 0; padding: 0; }

/*****************************************************************
 * 3.  Gesamtrahmen
 *****************************************************************/
.mr-slider { position: relative; max-width: 100%; margin-inline: auto; }

/*****************************************************************
 * 4.  Viewport für die Slides (Bildbereich)
 *****************************************************************/
.mr-slider-viewport {
  position: relative;
  aspect-ratio: var(--mr-ar);
  max-height: 60vh;
  overflow: hidden;
  box-shadow: 0 0 8px rgba(0,0,0,.15);
}

/*****************************************************************
 * 5.  Slides & Bilder im Viewport
 *****************************************************************/
.mr-slider .mr-slides { display: none; position: absolute; inset: 0; }
.mr-slider .mr-slides img { width: 100%; height: 100%; object-fit: var(--mr-fit); }

/*****************************************************************
 * 6.  Externe Caption-Zeile (unter dem Viewport)
 *****************************************************************/
.mr-caption {
  margin-top: 8px;
  padding: 10px 14px;
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.35;

  /* Platz bleibt stabil – JS setzt min-height dynamisch */
  min-height: 0;

  /* Mehrzeilig mit Kappung */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;

  color: var(--mr-caption-text);
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.mr-caption.has-text {
  background: var(--mr-caption-bg);
  border-color: var(--mr-caption-border);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/*****************************************************************
 * 7.  Navigations-Buttons & Dots (liegen im Viewport)
 *****************************************************************/
.mr-slider button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: var(--mr-btn-bg);
  color: var(--mr-ui-text);
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  transition: opacity .2s ease;
  z-index: 2;
}
.mr-slider button:focus { outline: 2px solid var(--mr-ui-text); outline-offset: 2px; }
.mr-slider .mr-prev  { left: 0; }
.mr-slider .mr-next  { right: 0; }
.mr-slider .mr-pause { top: auto; bottom: 20px; left: 50%; transform: translateX(-50%); font-size: 1rem; }

/* Kompakt-Modus: Pfeile & Pause standardmäßig ausblenden */
.mr-compact .mr-prev,
.mr-compact .mr-next,
.mr-compact .mr-pause {
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

/* Hover mit Maus über dem Viewport */
@media (hover: hover) {
  .mr-compact .mr-slider-viewport:hover .mr-prev,
  .mr-compact .mr-slider-viewport:hover .mr-next,
  .mr-compact .mr-slider-viewport:hover .mr-pause {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Keyboard / Screenreader: sobald etwas im Viewport Fokus hat */
.mr-compact .mr-slider-viewport:focus-within .mr-prev,
.mr-compact .mr-slider-viewport:focus-within .mr-next,
.mr-compact .mr-slider-viewport:focus-within .mr-pause {
  opacity: 1;
  pointer-events: auto;
}

/* JS-Fallback: wenn .mr-hover am Root gesetzt ist */
.mr-compact.mr-hover .mr-prev,
.mr-compact.mr-hover .mr-next,
.mr-compact.mr-hover .mr-pause {
  opacity: 1;
  pointer-events: auto;
}

/* Punkt-Navigation (unten mittig im Viewport) */
.mr-dots {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 16px;
  list-style: none;
  padding: 3px 16px;
  z-index: 2;
}
.mr-dots li { width: 8px; height: 8px; border-radius: 50%; background: var(--mr-btn-bg); cursor: pointer; }
.mr-dots li[aria-selected="true"], .mr-dots li:hover { background: var(--mr-ui-text); }

/*****************************************************************
 * 8.  Animationen – Klassen + Keyframes
 *****************************************************************/
.mr-slider .fade         { animation: fade 2s; }
.mr-slider .slideInRight { animation: slideInRight 1s both; }
.mr-slider .flip         { animation: flip 1s cubic-bezier(.25,.46,.45,.94) both; }
.mr-slider .zoomIn       { animation: zoomIn 1s both; }
.mr-slider .fadeInLeft   { animation: fadeInLeft 1s both; }

@keyframes fade { from { opacity: .4; } to { opacity: 1; } }
@keyframes slideInRight { from { transform: translateX(100%); visibility: visible; } to { transform: translateX(0); } }
@keyframes flip { from { transform: rotateY(80deg); opacity: 0; } to { transform: rotateY(0); opacity: 1; } }
@keyframes zoomIn { from { transform: scale(.8); opacity: 0; } to { transform: scale(1);  opacity: 1; } }
@keyframes fadeInLeft { from { transform: translateX(-20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/*****************************************************************
 * 9.  Fehlermeldung
 *****************************************************************/
.mr-slider-error { color: #c00; }

/*****************************************************************
 * 10. Responsive Feinschliff
 *****************************************************************/
@media (min-width: 36rem) { .mr-caption { font-size: 1.05rem; padding: 12px 18px; } }

/*****************************************************************
 * 11. Fallback für Browser ohne CSS aspect-ratio
 *****************************************************************/
@supports not (aspect-ratio: 2 / 1) {
  .mr-slider-viewport { height: 200px; }
  @media (min-width: 36rem) { .mr-slider-viewport { height: 400px; } }
}

/* 12. Legacy per-slide Caption ausblenden */
.mr-slider .text { display: none; }
.mr-slider .text:empty { display: none !important; }
