/* 
 * Borosen Slider CSS - Performance Optimierte Version
 * Author: Jan Philip
 * Version: 1.9.1
 */

/* CSS Custom Properties für bessere Wartbarkeit */
:root {
  --borosen-primary-color: var(--wp--preset--color--bvb-gelb);
  --borosen-text-color: var(--wp--preset--color--soft-schwarz);
  --borosen-bg-color: #f0f0f0;
  --borosen-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  --borosen-border-radius: 25px;
  --borosen-transition: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  --borosen-nav-size: 50px;
  --borosen-nav-size-mobile: 40px;
}

/* KRITISCHE STYLES - Diese sind bereits inline geladen, hier als Fallback */
.borosen-slider-wrapper {
  position: relative;
  width: 100%;
  overflow: hidden;
  touch-action: pan-y;
  line-height: 0;
  font-size: 0;
  border-radius: var(--borosen-border-radius) var(--borosen-border-radius) 0 0;
  height: 100%;
  background: var(--borosen-bg-color);
  isolation: isolate;
  /* PERFORMANCE: Hardware-Acceleration */
  transform: translateZ(0);
  will-change: auto;
}

/* Container Query Support */
@supports (container-type: inline-size) {
  .borosen-slider-wrapper {
    container-type: inline-size;
  }
}

/* Slider Core - PERFORMANCE OPTIMIERT */
.borosen-slider {
  display: flex;
  height: 100%;
  /* PERFORMANCE: Optimierungen für smooth scrolling */
  backface-visibility: hidden;
  transform: translateZ(0);
  will-change: transform;
}

.borosen-slider.is-initialized {
  transition: transform var(--borosen-transition);
}

/* Einzelne Slides */
.borosen-slide {
  flex: 0 0 100%;
  min-width: 100%;
  position: relative;
  overflow: hidden;
  height: 100%;
  /* PERFORMANCE: Compositing Layer */
  transform: translateZ(0);
}

/* Responsive Bilder - PERFORMANCE OPTIMIERT */
.borosen-slide-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  /* PERFORMANCE: GPU-Acceleration für Transforms */
  backface-visibility: hidden;
  transform: translateZ(0);
}

/* Hover-Effekte nur auf leistungsstarken Geräten */
@media (hover: hover) and (pointer: fine) and (min-width: 1024px) {
  .borosen-slide-image {
    transition: transform var(--borosen-transition);
  }
  
  .borosen-slide:hover .borosen-slide-image {
    transform: translateZ(0) scale(1.05);
  }
  
  .borosen-slide-image:focus {
    outline: 2px solid var(--borosen-primary-color);
    outline-offset: 2px;
  }
}

/* Lazy Loading Placeholder - VERBESSERT */
.borosen-slide-image.borosen-lazy {
  background: var(--borosen-bg-color);
  opacity: 0.7;
  /* PERFORMANCE: Verhindere Layout-Shifts */
  min-height: 200px;
}

/* Aspect Ratio mit modernem und Fallback-Ansatz */
.borosen-slide-image {
  aspect-ratio: 16/9;
}

/* Fallback für ältere Browser */
@supports not (aspect-ratio: 16/9) {
  .borosen-slide::before {
    content: '';
    display: block;
    padding-bottom: 56.25%; /* 16:9 */
    float: left;
  }
  
  .borosen-slide-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }
}

/* Navigation Buttons - PERFORMANCE OPTIMIERT */
.borosen-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%) translateZ(0);
  background: var(--borosen-primary-color);
  color: var(--borosen-text-color);
  border: none;
  padding: 15px 20px;
  font-size: 24px;
  cursor: pointer;
  z-index: 2;
  border-radius: 50%;
  width: var(--borosen-nav-size);
  height: var(--borosen-nav-size);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
  box-shadow: var(--borosen-shadow);
  line-height: 1;
  /* PERFORMANCE: Composite Layer */
  will-change: transform, opacity;
  backface-visibility: hidden;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.borosen-nav-btn:hover,
.borosen-nav-btn:focus {
  opacity: 1;
  transform: translateY(-50%) translateZ(0) scale(1.1);
  outline: none;
}

.borosen-nav-btn:focus-visible {
  outline: 2px solid var(--borosen-text-color);
  outline-offset: 2px;
}

.borosen-prev { 
  left: 20px; 
}

.borosen-next { 
  right: 20px; 
}

/* Dots Navigation */
.borosen-dots {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateZ(0);
  display: flex;
  gap: 8px;
  z-index: 2;
}

.borosen-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  background: transparent;
  cursor: pointer;
  transition: all 0.3s ease;
}

.borosen-dot.active,
.borosen-dot:hover {
  background: var(--borosen-primary-color);
  border-color: var(--borosen-primary-color);
}

/* Lightbox - PERFORMANCE OPTIMIERT */
.borosen-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(15px) saturate(180%);
  -webkit-backdrop-filter: blur(15px) saturate(180%);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  /* PERFORMANCE: Hardware-Acceleration */
  transform: translateZ(0);
  will-change: opacity;
  transition: opacity 0.3s ease;
}

.borosen-lightbox.active {
  display: flex;
  opacity: 1;
}

.borosen-lightbox-content {
  position: relative;
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  /* PERFORMANCE: Composite Layer */
  transform: translateZ(0);
}

.borosen-lightbox-img-container {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  /* PERFORMANCE: Smooth Transitions */
  transition: transform var(--borosen-transition);
  will-change: transform;
  backface-visibility: hidden;
}

/* Lightbox Slides - Verbesserte mobile Zentrierung */
.borosen-lightbox-slide {
  width: 100%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  cursor: pointer;
  padding: 20px;
  box-sizing: border-box;
}

.borosen-lightbox-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  pointer-events: auto;
  cursor: default;
  user-select: none;
  display: block;
  /* PERFORMANCE: Prevent layout shifts */
  min-height: 100px;
}

/* Close Button - WordPress Admin Bar berücksichtigen */
.borosen-lightbox-close {
  position: fixed;
  top: calc(30px + var(--wp-admin--admin-bar--height, 0px));
  right: 30px;
  font-size: 30px;
  color: rgba(0, 0, 0, 0.8);
  background: rgba(255, 255, 255, 0.9);
  border: none;
  cursor: pointer;
  z-index: 10000;
  width: var(--borosen-nav-size);
  height: var(--borosen-nav-size);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--borosen-shadow);
  line-height: 1;
  /* PERFORMANCE */
  transition: transform 0.2s ease, background-color 0.2s ease;
  will-change: transform;
  backface-visibility: hidden;
}

.borosen-lightbox-close:hover,
.borosen-lightbox-close:focus {
  background: rgba(255, 255, 255, 1);
  transform: translateZ(0) scale(1.1);
  outline: none;
}

/* Lightbox Navigation Buttons - Verbesserte Positionierung */
.borosen-lightbox .borosen-nav-btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%) translateZ(0);
  z-index: 10001;
}

.borosen-lightbox .borosen-prev {
  left: 20px;
}

.borosen-lightbox .borosen-next {
  right: 20px;
}

/* Loading States - VERBESSERT */
.borosen-slide-image[loading] {
  background: var(--borosen-bg-color);
}

.borosen-slide-image:not([src]) {
  opacity: 0;
}

/* PERFORMANCE: Reduzierte Animation bei schwacher Hardware */
@media (prefers-reduced-motion: reduce) {
  .borosen-slider,
  .borosen-slide-image,
  .borosen-nav-btn,
  .borosen-lightbox,
  .borosen-lightbox-img-container {
    transition: none;
  }
  
  .borosen-slide:hover .borosen-slide-image {
    transform: translateZ(0);
  }
}

/* Tablet Anpassungen */
@media (max-width: 1024px) and (min-width: 768px) {
  .borosen-slide-image {
    aspect-ratio: 4/3;
  }
  
  @supports not (aspect-ratio: 4/3) {
    .borosen-slide::before {
      padding-bottom: 75%; /* 4:3 */
    }
  }
  
  .borosen-lightbox-img {
    max-height: calc(85vh - var(--wp-admin--admin-bar--height, 0px));
  }
}

/* Mobile Anpassungen - PERFORMANCE OPTIMIERT */
@media (max-width: 767px) {
  :root {
    --borosen-nav-size: var(--borosen-nav-size-mobile);
  }
  
  .borosen-slide-image {
    aspect-ratio: 4/3;
  }
  
  @supports not (aspect-ratio: 4/3) {
    .borosen-slide::before {
      padding-bottom: 75%; /* 4:3 */
    }
  }
  
  /* PERFORMANCE: Reduziere Backdrop-Filter auf Mobile */
  .borosen-lightbox {
    backdrop-filter: blur(10px) saturate(150%);
    -webkit-backdrop-filter: blur(10px) saturate(150%);
  }
  
  /* Lightbox mobile Optimierungen */
  .borosen-lightbox-slide {
    padding: 60px 10px 80px;
    height: 100vh;
    align-items: center;
    justify-content: center;
  }
  
  .borosen-lightbox-img {
    max-height: calc(80vh - var(--wp-admin--admin-bar--height, 0px));
    max-width: calc(100vw - 20px);
  }
  
  .borosen-lightbox .borosen-prev { 
    left: 10px; 
  }
  
  .borosen-lightbox .borosen-next { 
    right: 10px; 
  }
  
  .borosen-lightbox-close {
    top: calc(20px + var(--wp-admin--admin-bar--height, 0px));
    right: 20px;
    font-size: 24px;
  }
  
  .borosen-dots {
    bottom: 10px;
  }
  
  .borosen-nav-btn {
    font-size: 16px;
  }
  
  /* Slider Navigation mobile */
  .borosen-prev { 
    left: 10px; 
  }
  
  .borosen-next { 
    right: 10px; 
  }
  
  /* PERFORMANCE: Hover-Effekte auf Mobile deaktivieren */
  .borosen-slide:hover .borosen-slide-image {
    transform: translateZ(0);
  }
}

/* Extra kleine Screens - Noch aggressivere Zentrierung */
@media (max-width: 480px) {
  .borosen-slide-image {
    aspect-ratio: 1/1;
  }
  
  @supports not (aspect-ratio: 1/1) {
    .borosen-slide::before {
      padding-bottom: 100%; /* 1:1 */
    }
  }
  
  /* PERFORMANCE: Weniger Blur auf sehr kleinen Geräten */
  .borosen-lightbox {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
  
  .borosen-lightbox-slide {
    padding: 80px 5px 100px;
  }
  
  .borosen-lightbox-img {
    max-height: calc(70vh - var(--wp-admin--admin-bar--height, 0px));
    max-width: calc(100vw - 10px);
  }
  
  .borosen-lightbox .borosen-prev { 
    left: 5px; 
  }
  
  .borosen-lightbox .borosen-next { 
    right: 5px; 
  }
  
  /* Slider Navigation extra small */
  .borosen-prev { 
    left: 5px; 
  }
  
  .borosen-next { 
    right: 5px; 
  }
}

/* PERFORMANCE: Landscape Orientierung auf mobilen Geräten */
@media (max-width: 767px) and (orientation: landscape) {
  .borosen-lightbox-slide {
    padding: 20px 10px;
  }
  
  .borosen-lightbox-img {
    max-height: calc(90vh - var(--wp-admin--admin-bar--height, 0px));
  }
}

/* Sehr hohe Screens (z.B. moderne Smartphones) */
@media (max-width: 767px) and (min-height: 800px) {
  .borosen-lightbox-slide {
    padding: 100px 10px 120px;
  }
}

/* PERFORMANCE: High DPI Displays - Conditional Shadow */
@media (-webkit-min-device-pixel-ratio: 2) and (min-width: 1024px), 
       (min-resolution: 192dpi) and (min-width: 1024px) {
  .borosen-nav-btn,
  .borosen-lightbox-close {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  }
}

/* PERFORMANCE: Fallback für Browser ohne Backdrop-Filter */
@supports not (backdrop-filter: blur()) {
  .borosen-lightbox {
    background: rgba(255, 255, 255, 0.95);
  }
}

/* PERFORMANCE: Container Queries (experimentell) - nur auf Desktop */
@media (min-width: 1024px) {
  @container (max-width: 480px) {
    .borosen-slide-image {
      aspect-ratio: 1/1;
    }
  }

  @container (min-width: 481px) and (max-width: 768px) {
    .borosen-slide-image {
      aspect-ratio: 4/3;
    }
  }

  @container (min-width: 769px) {
    .borosen-slide-image {
      aspect-ratio: 16/9;
    }
  }
}

/* PERFORMANCE: Dark Mode Support - Conditional */
@media (prefers-color-scheme: dark) and (min-width: 768px) {
  :root {
    --borosen-bg-color: #2a2a2a;
  }
  
  .borosen-lightbox {
    background: rgba(0, 0, 0, 0.8);
  }
  
  .borosen-lightbox-close {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(0, 0, 0, 0.8);
  }
  
  .borosen-lightbox-close:hover {
    background: rgba(0, 0, 0, 0.9);
  }
}

/* PERFORMANCE: Print Styles - Minimal für bessere Performance */
@media print {
  .borosen-slider-wrapper {
    overflow: visible;
    height: auto;
    border-radius: 0;
    background: transparent;
  }
  
  .borosen-slider {
    display: block;
  }
  
  .borosen-slide {
    display: block;
    page-break-inside: avoid;
    margin-bottom: 1cm;
  }
  
  .borosen-nav-btn,
  .borosen-dots,
  .borosen-lightbox {
    display: none !important;
  }
  
  .borosen-slide-image {
    aspect-ratio: auto;
    height: auto;
    max-height: none;
    transform: none !important;
    transition: none !important;
  }
}