/* Rufus-3D-Druck Clean v2.7.0
   Phoca Gallery Styling
   Ziel: Phoca Gallery optisch an das Rufus-Template anpassen, ohne Core-Dateien der Komponente zu ändern.
*/

:where(.pf-com-phocagallery, .com-phocagallery, .com_phocagallery, .phocagallery, #phocagallery) {
  --pg-rufus-card: rgba(17,24,39,.78);
  --pg-rufus-card-strong: rgba(17,24,39,.92);
  --pg-rufus-border: color-mix(in srgb, var(--pf-border, rgba(148,163,184,.22)), transparent 6%);
  --pg-rufus-muted: var(--pf-muted, #b7c4d6);
  --pg-rufus-text: var(--pf-text, #f8fafc);
}

/* Komponentenseite im gleichen Card-Look wie Beiträge */
.pf-com-phocagallery .pf-component:has(.phocagallery),
.pf-com-phocagallery .pf-component:has(#phocagallery),
.pf-com-phocagallery .pf-component:has(.pg-category-view),
.pf-com-phocagallery .pf-component:has(.pg-categories-view) {
  padding: clamp(1.25rem, 3vw, 2.2rem);
}

/* Hauptcontainer und Überschriften */
.com-phocagallery,
.com_phocagallery,
.phocagallery,
#phocagallery,
.pg-categories-view,
.pg-category-view,
.pg-detail-view {
  color: var(--pg-rufus-text);
}

.com-phocagallery h1,
.com-phocagallery h2,
.com-phocagallery h3,
.com_phocagallery h1,
.com_phocagallery h2,
.com_phocagallery h3,
.phocagallery h1,
.phocagallery h2,
.phocagallery h3,
#phocagallery h1,
#phocagallery h2,
#phocagallery h3 {
  color: var(--pg-rufus-text);
  letter-spacing: -.04em;
}

.phocagallery a,
#phocagallery a,
.com-phocagallery a,
.com_phocagallery a {
  color: inherit;
  text-decoration: none;
}

.phocagallery a:hover,
#phocagallery a:hover,
.com-phocagallery a:hover,
.com_phocagallery a:hover {
  color: var(--pf-second, #18d4ff);
}

/* Kategorien- und Bilderraster: viele Phoca-Versionen nutzen unterschiedliche Klassen.
   Deshalb werden die bekannten Varianten gesammelt gestylt. */
.pg-categories,
.pg-categories-view,
.pg-category-view,
.phocagallerycategories,
.phocagallery,
#phocagallery .pg-cv-box,
#phocagallery .pg-item-box {
  max-width: 100%;
}

.pg-categories-view .pg-cv-box,
.pg-category-view .pg-item-box,
.pg-item-box,
.pg-category-box,
.phocagallery-box-file,
.phocagallery-box-file-first,
.phocagallery-box-file-second,
.phocagallery-box,
.phocagallerycategories .category,
.phocagallery-categories .category {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--pg-rufus-border) !important;
  border-radius: 26px !important;
  background:
    radial-gradient(circle at 18% 12%, color-mix(in srgb, var(--pf-second, #18d4ff), transparent 78%), transparent 22rem),
    radial-gradient(circle at 86% 96%, color-mix(in srgb, var(--pf-accent, #ff8a00), transparent 82%), transparent 22rem),
    linear-gradient(145deg, rgba(17,24,39,.86), rgba(17,24,39,.54)) !important;
  box-shadow: 0 22px 65px rgba(0,0,0,.24);
  backdrop-filter: blur(18px);
  transition: transform .24s ease, border-color .24s ease, box-shadow .24s ease, background .24s ease;
}

.pg-categories-view .pg-cv-box:hover,
.pg-category-view .pg-item-box:hover,
.pg-item-box:hover,
.pg-category-box:hover,
.phocagallery-box-file:hover,
.phocagallery-box:hover,
.phocagallerycategories .category:hover,
.phocagallery-categories .category:hover {
  transform: translateY(-5px);
  border-color: color-mix(in srgb, var(--pf-second, #18d4ff), transparent 35%) !important;
  box-shadow:
    0 28px 85px rgba(0,0,0,.30),
    0 0 0 1px color-mix(in srgb, var(--pf-second, #18d4ff), transparent 72%);
}

/* Raster neutralisieren und modernisieren */
.pg-categories-view,
.pg-category-view,
.phocagallery,
#phocagallery {
  gap: 1rem;
}

.pg-categories-view .pg-row,
.pg-category-view .pg-row,
#phocagallery .pg-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0 !important;
}

#phocagallery .pg-cv-box,
#phocagallery .pg-item-box,
.pg-cv-box,
.pg-item-box,
.pg-category-box {
  margin: .5rem !important;
  padding: .9rem !important;
}

/* Bilder */
.pg-item-box img,
.pg-category-box img,
.phocagallery-box-file img,
.phocagallery-box img,
#phocagallery img,
.com-phocagallery img,
.com_phocagallery img {
  border-radius: 18px;
  max-width: 100%;
  height: auto;
}

.pg-item-box img,
.phocagallery-box-file img,
.phocagallery-box img {
  width: 100%;
  object-fit: cover;
}

/* Phoca setzt teils Inline-Breiten. Diese Regel macht die Boxen responsive,
   ohne die Komponente zu beschädigen. */
.pg-category-view .pg-item-box,
.pg-categories-view .pg-cv-box,
#phocagallery .pg-item-box,
#phocagallery .pg-cv-box {
  max-width: min(100%, 320px);
}

/* Namen, Beschreibungen, Zähler */
.pg-name,
.pg-cv-name,
.pg-category-name,
.phocagallery-name,
.phocagallery-box-file-name,
.phocagallery-box-file-first,
.phocagallery-box-file-second,
#phocagallery .name {
  color: var(--pg-rufus-text) !important;
  font-weight: 850;
  letter-spacing: -.02em;
}

.pg-description,
.pg-category-desc,
.pg-cv-desc,
.phocagallery-desc,
.phocagallery-image-box-caption,
#phocagallery .small,
#phocagallery small {
  color: var(--pg-rufus-muted) !important;
  line-height: 1.65;
}

.pg-number,
.pg-num,
.pg-count,
.phocagallery-count,
#phocagallery .badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  border: 1px solid var(--pg-rufus-border);
  border-radius: 999px;
  padding: .25rem .55rem;
  background: rgba(255,255,255,.07);
  color: var(--pg-rufus-muted);
  font-weight: 700;
}

/* Buttons, Zurück, Weiter, Pagination */
#phocagallery .btn,
#phocagallery button,
.com-phocagallery .btn,
.com_phocagallery .btn,
.phocagallery .btn,
.pg-pagination a,
.pg-pagination span,
.pagination a,
.pagination span {
  border: 1px solid var(--pg-rufus-border) !important;
  border-radius: 999px !important;
  background: rgba(255,255,255,.08) !important;
  color: var(--pg-rufus-text) !important;
  box-shadow: none !important;
}

#phocagallery .btn:hover,
#phocagallery button:hover,
.com-phocagallery .btn:hover,
.com_phocagallery .btn:hover,
.phocagallery .btn:hover,
.pg-pagination a:hover,
.pagination a:hover {
  background: linear-gradient(135deg, var(--pf-accent, #ff8a00), var(--pf-second, #18d4ff)) !important;
  color: #101827 !important;
  border-color: transparent !important;
}

/* Kategorie-Filter oben, falls Phoca/Module Selects oder Formulare ausgeben */
#phocagallery select,
#phocagallery input,
#phocagallery textarea,
.com-phocagallery select,
.com-phocagallery input,
.com-phocagallery textarea,
.com_phocagallery select,
.com_phocagallery input,
.com_phocagallery textarea {
  border: 1px solid var(--pg-rufus-border);
  border-radius: 16px;
  background: rgba(17,24,39,.78);
  color: var(--pg-rufus-text);
  padding: .7rem .9rem;
}

#phocagallery label,
.com-phocagallery label,
.com_phocagallery label {
  color: var(--pg-rufus-muted);
}

/* Detailansicht / großes Bild */
.pg-detail-view,
#phocagallery .pg-detail,
.com-phocagallery .pg-detail {
  text-align: center;
}

.pg-detail-view img,
#phocagallery .pg-detail img,
.com-phocagallery .pg-detail img {
  max-height: min(72vh, 780px);
  object-fit: contain;
  border-radius: 28px;
  box-shadow: var(--pf-shadow, 0 24px 90px rgba(0,0,0,.35));
}

/* Plugin-Ausgabe innerhalb normaler Joomla-Beiträge */
.pf-component .phocagallery,
.pf-component #phocagallery {
  margin-top: 1rem;
}

/* Mobile */
@media (max-width: 760px) {
  .pg-category-view .pg-item-box,
  .pg-categories-view .pg-cv-box,
  #phocagallery .pg-item-box,
  #phocagallery .pg-cv-box,
  .phocagallery-box-file,
  .phocagallery-box {
    width: 100% !important;
    max-width: 100% !important;
    margin: .45rem 0 !important;
  }

  .pg-categories-view .pg-row,
  .pg-category-view .pg-row,
  #phocagallery .pg-row {
    display: grid;
    grid-template-columns: 1fr;
  }
}


/* ==========================================================================
   Rufus v2.8.0 – eigene, stabile Phoca-Bildanzeige
   Hintergrund: Die Phoca-Detail-Popups verschiedener Versionen/Detailfenster
   erzeugen je nach Server/JS-Library sehr große schwarze Flächen. Deshalb
   übernimmt das Template Bildklicks in der Galerie und öffnet eine eigene,
   responsive Lightbox mit Zurück/Weiter/Schließen.
   ========================================================================== */

.pf-rufus-phoca-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vw, 34px);
  background:
    radial-gradient(circle at 18% 15%, color-mix(in srgb, var(--pf-second, #18d4ff), transparent 78%), transparent 30rem),
    radial-gradient(circle at 84% 90%, color-mix(in srgb, var(--pf-accent, #ff8a00), transparent 78%), transparent 30rem),
    rgba(0, 0, 0, .92);
  backdrop-filter: blur(8px);
}

.pf-rufus-phoca-lightbox.is-open {
  display: flex;
}

.pf-rufus-phoca-lightbox__stage {
  position: relative;
  width: min(1180px, 100%);
  max-height: calc(100vh - 30px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: clamp(10px, 2vw, 18px);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: clamp(18px, 3vw, 30px);
  background: rgba(8, 13, 22, .86);
  box-shadow: 0 30px 120px rgba(0,0,0,.72);
}

.pf-rufus-phoca-lightbox__bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.pf-rufus-phoca-lightbox__imagewrap {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.pf-rufus-phoca-lightbox__image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 150px);
  object-fit: contain;
  border-radius: clamp(12px, 2vw, 22px);
  box-shadow: 0 18px 70px rgba(0,0,0,.55);
  background: rgba(255,255,255,.04);
}

.pf-rufus-phoca-lightbox__caption {
  min-height: 1.5em;
  color: rgba(238,244,255,.82);
  text-align: center;
  font-size: clamp(.9rem, 1.4vw, 1.05rem);
}

.pf-rufus-phoca-lightbox__button {
  appearance: none;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  min-width: 44px;
  min-height: 42px;
  padding: 9px 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--pf-accent, #ff8a00), var(--pf-second, #18d4ff));
  color: #06111c;
  font-weight: 900;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 16px 44px rgba(0,0,0,.28);
}

.pf-rufus-phoca-lightbox__button:hover,
.pf-rufus-phoca-lightbox__button:focus {
  transform: translateY(-1px);
  outline: 2px solid rgba(24,212,255,.35);
  outline-offset: 3px;
}

.pf-rufus-phoca-lightbox__button[disabled] {
  opacity: .35;
  cursor: not-allowed;
  transform: none;
}

body.pf-rufus-phoca-lock {
  overflow: hidden !important;
}

/* Normale Phoca-Detailansicht, falls ein Bild doch als component.php geöffnet wird */
body.pf-component-only.pf-com-phocagallery {
  background:
    radial-gradient(circle at 0% 0%, rgba(24,212,255,.16), transparent 28rem),
    radial-gradient(circle at 100% 100%, rgba(255,138,0,.14), transparent 28rem),
    #03070d !important;
}

body.pf-component-only.pf-com-phocagallery .pf-main,
body.pf-component-only.pf-com-phocagallery .pf-component-main {
  min-height: 100vh;
  padding: 12px !important;
}

body.pf-component-only.pf-com-phocagallery .pf-container,
body.pf-component-only.pf-com-phocagallery .pf-component-container,
body.pf-component-only.pf-com-phocagallery .pf-component,
body.pf-component-only.pf-com-phocagallery .pf-component-output {
  width: min(1100px, 100%) !important;
  max-width: min(1100px, 100%) !important;
  margin: 0 auto !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

body.pf-component-only.pf-com-phocagallery #phocagallery,
body.pf-component-only.pf-com-phocagallery .phocagallery,
body.pf-component-only.pf-com-phocagallery .pg-detail,
body.pf-component-only.pf-com-phocagallery .pg-detail-view {
  text-align: center !important;
}

body.pf-component-only.pf-com-phocagallery #phocagallery img,
body.pf-component-only.pf-com-phocagallery .phocagallery img,
body.pf-component-only.pf-com-phocagallery .pg-detail img,
body.pf-component-only.pf-com-phocagallery .pg-detail-view img {
  display: block !important;
  width: auto !important;
  height: auto !important;
  max-width: calc(100vw - 36px) !important;
  max-height: calc(100vh - 120px) !important;
  object-fit: contain !important;
  margin: 16px auto !important;
  border-radius: 18px;
  box-shadow: 0 22px 80px rgba(0,0,0,.5);
}

/* Sicherheitsnetz für verbreitete Lightbox-Libraries, ohne sie zu zerstören */
.mfp-wrap img.mfp-img,
.fancybox-container img,
.fancybox__container img,
.pswp img,
.lg-outer img,
#sbox-window img,
#sbox-content img {
  max-width: calc(100vw - 40px) !important;
  max-height: calc(100vh - 120px) !important;
  object-fit: contain !important;
}

@media (max-width: 700px) {
  .pf-rufus-phoca-lightbox {
    padding: 8px;
  }

  .pf-rufus-phoca-lightbox__stage {
    max-height: calc(100vh - 16px);
    border-radius: 18px;
    padding: 8px;
  }

  .pf-rufus-phoca-lightbox__image {
    max-height: calc(100vh - 132px);
  }

  .pf-rufus-phoca-lightbox__button {
    min-height: 38px;
    min-width: 40px;
    padding: 7px 12px;
  }
}
