/* ==========================================================================
   Social Posts – LinkedIn-artiges Layout
   Genutzt von:
     - template-parts/content-social.php (Einzelansicht)
     - template-parts/card-social.php   (Karte im News-Feed)
   Aktiviert sich automatisch fuer Beitraege der Kategorie "social".
   ========================================================================== */

/* --- Lokale Tokens (auf Basis der globalen Custom Properties) --- */
:root {
  --sl-card-width: 600px;
  --sl-radius: 12px;
  --sl-border: #e3e3e3;
  --sl-name: #54595F;       /* dunkelgrau */
  --sl-muted: #7A7A7A;      /* meta-grau  */
  --sl-text: #2b2b2b;       /* fliesstext */
}

/* ==========================================================================
   1. Einzelansicht (single)
   ========================================================================== */

.sl-single {
  background: var(--color-bg-light, #F5F5F5);
  padding: 40px 16px 64px;
  min-height: 60vh;
}

.sl-single__back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: var(--sl-card-width);
  margin: 0 auto 16px;
  width: 100%;
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 500;
  color: var(--sl-muted);
  text-decoration: none;
}
.sl-single__back:hover { color: var(--color-magenta); }
.sl-single__back i { font-size: 16px; }

.sl-post {
  max-width: var(--sl-card-width);
  margin: 0 auto;
  background: #ffffff;
  border: 1px solid var(--sl-border);
  border-radius: var(--sl-radius);
  overflow: hidden;
  font-family: var(--font-primary);
  color: var(--sl-text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* --- Autor-Kopf --- */
.sl-post__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 10px;
}

.sl-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-magenta);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.sl-avatar img { width: 100%; height: 100%; object-fit: cover; }

.sl-post__author { flex: 1; min-width: 0; line-height: 1.3; }
.sl-post__name {
  font-weight: 700;
  font-size: 15px;
  color: var(--sl-name);
  margin: 0;
}
.sl-post__sub {
  font-size: 12.5px;
  color: var(--sl-muted);
  margin: 1px 0 0;
}
.sl-post__date {
  font-size: 12px;
  color: var(--sl-muted);
  margin: 1px 0 0;
  display: flex;
  align-items: center;
  gap: 5px;
}
.sl-post__date i { font-size: 13px; }

.sl-post__menu {
  font-size: 20px;
  color: var(--sl-muted);
  align-self: flex-start;
  line-height: 1;
}

/* --- Titel des Beitrags --- */
.sl-post__title {
  margin: 0;
  padding: 4px 18px 2px;
  font-family: var(--font-primary);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--sl-name);
}

/* --- Textkoerper --- */
.sl-post__body {
  padding: 4px 18px 14px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--sl-text);
}
.sl-post__body p { margin: 0 0 0.8em; }
.sl-post__body p:last-child { margin-bottom: 0; }
.sl-post__body a { color: var(--color-primary); text-decoration: none; }
.sl-post__body a:hover { text-decoration: underline; }
.sl-post__body h2,
.sl-post__body h3 { color: var(--sl-name); margin: 0.8em 0 0.4em; }

/* --- Aufzaehlungen: Theme setzt global list-style:none -> hier wiederherstellen --- */
.sl-post__body ul,
.sl-post__body ol {
  margin: 0 0 0.8em;
  padding-left: 1.5em;
}
.sl-post__body ul { list-style: disc; }
.sl-post__body ol { list-style: decimal; }
.sl-post__body li { margin: 0.25em 0; list-style: inherit; }
.sl-post__body li p { margin: 0; }

/* Klick aufs Bild oeffnet Vollbild (siehe SocialLightbox) */
.sl-post__body img { cursor: zoom-in; }

/* --- Einzelbild im Text: randlos ueber die volle Kartenbreite --- */
.sl-post__body > img,
.sl-post__body p > img,
.sl-post__body figure.wp-block-image {
  display: block;
  width: calc(100% + 36px);
  max-width: calc(100% + 36px);
  margin: 12px -18px;
  height: auto;
}
.sl-post__body figure.wp-block-image { margin-left: -18px; margin-right: -18px; }
.sl-post__body figure.wp-block-image img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
}
.sl-post__body figure.wp-block-image figcaption {
  padding: 6px 18px 0;
  font-size: 12.5px;
  color: var(--sl-muted);
}

/* --- Mehrere Bilder = LinkedIn-artiges Raster (Galerie-Block) --- */
.sl-post__body .wp-block-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  width: calc(100% + 36px);
  margin: 12px -18px;
}
.sl-post__body .wp-block-gallery figure,
.sl-post__body .wp-block-gallery .wp-block-image {
  margin: 0;
  width: auto;
  max-width: none;
}
.sl-post__body .wp-block-gallery img {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  margin: 0;
}
/* Genau ein Bild in der Galerie -> volle Breite, Originalverhaeltnis */
.sl-post__body .wp-block-gallery.columns-1 { grid-template-columns: 1fr; }
.sl-post__body .wp-block-gallery.columns-1 img { aspect-ratio: auto; height: auto; }

/* --- Klassische [gallery]-Shortcode-Galerie (Classic Editor) --- */
.sl-post__body .gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  width: calc(100% + 36px);
  margin: 12px -18px;
}
.sl-post__body .gallery br { display: none; }
.sl-post__body .gallery .gallery-item {
  width: auto !important;
  margin: 0 !important;
  float: none !important;
  text-align: left;
}
.sl-post__body .gallery .gallery-item img {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: none !important;
  display: block;
}

.sl-post__tags {
  padding: 0 18px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-primary);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sl-post__tags a { color: inherit; text-decoration: none; }
.sl-post__tags a:hover { text-decoration: underline; }

/* --- Hauptbild (Featured) --- */
.sl-post__media { display: block; background: #f1f1f1; }
.sl-post__media img {
  display: block;
  width: 100%;
  height: auto;
}

/* --- Abschluss: letztes Element bekommt unten etwas Luft --- */
.sl-post__media:last-child img { display: block; }

/* ==========================================================================
   2. Feed-Karte (im News-Grid)
   ========================================================================== */

/* Spannt im 3-Spalten-News-Grid die volle Breite und hebt sich so ab */
.card--social {
  grid-column: 1 / -1;
  justify-self: center;
  width: 100%;
  max-width: var(--sl-card-width);
  margin: 0 auto;
  background: #ffffff;
  border: 1px solid var(--sl-border);
  border-radius: var(--sl-radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  padding: 0;
  font-family: var(--font-primary);
  color: var(--sl-text);
  text-decoration: none;
  display: block;
  transition: box-shadow 0.3s ease;
}
.card--social:hover { box-shadow: var(--card-shadow-hover); }

.card--social .sl-post__head { padding: 14px 16px 8px; }
.card--social .sl-post__body { padding: 2px 16px 12px; font-size: 14.5px; }
.card--social .sl-post__name { font-size: 14.5px; }

.card--social .sl-card__excerpt {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card--social .sl-post__media img {
  max-height: 360px;
  object-fit: cover;
}

.card--social .sl-card__cta {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-magenta);
}
.card--social .sl-card__cta i { font-size: 16px; }

/* ==========================================================================
   2b. Bilder-Carousel (mehrere Bilder durchscrollen, wie bei Facebook)
   JS (SocialCarousel) wandelt eine Galerie in ein wischbares Carousel um.
   Ohne JS bleibt die Galerie ein Raster (siehe oben) – sauberer Fallback.
   ========================================================================== */

.sl-carousel {
  position: relative;
  width: calc(100% + 36px);
  margin: 12px -18px;
}

.sl-carousel__track {
  display: flex !important;
  grid-template-columns: none !important;
  gap: 0 !important;
  width: 100% !important;
  margin: 0 !important;
  background: #000;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.sl-carousel__track::-webkit-scrollbar { display: none; }

.sl-carousel__track > * {
  flex: 0 0 100% !important;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  scroll-snap-align: center;
}
.sl-carousel__track img {
  display: block;
  width: 100%;
  height: clamp(260px, 56vw, 480px) !important;
  object-fit: cover !important;
  aspect-ratio: auto !important;
  margin: 0 !important;
}

.sl-carousel__btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #1a1a1a;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  transition: background 0.15s ease;
}
.sl-carousel__btn:hover { background: #ffffff; }
.sl-carousel__btn--prev { left: 10px; }
.sl-carousel__btn--next { right: 10px; }
.sl-carousel__btn[hidden] { display: none; }

.sl-carousel__counter {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 2;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 11px;
}

.sl-carousel__dots {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 0 2px;
}
.sl-carousel__dot {
  width: 6px;
  height: 6px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #cfcfcf;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.sl-carousel__dot.is-active { background: var(--color-magenta); transform: scale(1.25); }

@media (max-width: 768px) {
  .sl-carousel__btn { display: none; } /* mobil: einfach wischen */
}

/* ==========================================================================
   2c. Lightbox – Klick aufs Bild oeffnet es im Vollbild (nicht zum Beitrag)
   ========================================================================== */

.sl-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10050; /* ueber dem Overlay (9999) */
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.92);
}
.sl-lightbox.is-active { display: flex; }

.sl-lightbox__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  cursor: default;
}

.sl-lightbox__close {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.sl-lightbox__close:hover { background: rgba(255, 255, 255, 0.3); }

/* ==========================================================================
   2d. News-Artikel im Overlay (gleiche Optik/Popup wie Social-Beitraege)
   ========================================================================== */

.sl-article {
  background: #ffffff;
  font-family: var(--font-primary);
  color: var(--sl-text);
}

.sl-article__media img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 380px;
  object-fit: cover;
}

.sl-article__inner { padding: 20px 22px 24px; }

.sl-article__cat {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-magenta);
}

.sl-article__title {
  margin: 0 0 10px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--sl-name);
}

.sl-article__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--sl-muted);
}

.sl-article__content { font-size: 15px; line-height: 1.7; }
.sl-article__content p { margin: 0 0 1em; }
.sl-article__content p:last-child { margin-bottom: 0; }
.sl-article__content h2,
.sl-article__content h3 { color: var(--sl-name); margin: 1em 0 0.4em; }
.sl-article__content a { color: var(--color-primary); text-decoration: none; }
.sl-article__content a:hover { text-decoration: underline; }
.sl-article__content ul,
.sl-article__content ol { margin: 0 0 1em; padding-left: 1.5em; }
.sl-article__content ul { list-style: disc; }
.sl-article__content ol { list-style: decimal; }
.sl-article__content li { margin: 0.25em 0; list-style: inherit; }
.sl-article__content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 12px 0;
  cursor: zoom-in;
}

.sl-article__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.sl-article__tag { font-size: 13px; font-weight: 500; color: var(--color-primary); }

/* Im Overlay: abgerundete Karte mit Schatten (wie .sl-post) */
.sl-overlay__panel .sl-article {
  border-radius: var(--sl-radius);
  overflow: hidden;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.28);
}

/* ==========================================================================
   3. Overlay (Homepage-Teaser oeffnet die LinkedIn-/News-Ansicht im Popup)
   ========================================================================== */

.sl-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding: 6vh 16px 40px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sl-overlay.is-active { display: flex; }

.sl-overlay__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 25, 0.62);
  cursor: pointer;
}

.sl-overlay__panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--sl-card-width);
  animation: sl-overlay-in 0.25s ease;
}

@keyframes sl-overlay-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.sl-overlay__close {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #ffffff;
  color: var(--sl-name);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  transition: color 0.15s ease, transform 0.15s ease;
}
.sl-overlay__close:hover { color: var(--color-magenta); transform: scale(1.05); }

/* Die .sl-post-Karte fuellt das Panel komplett aus */
.sl-overlay__panel .sl-post {
  max-width: 100%;
  margin: 0;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.28);
}

/* ==========================================================================
   4. Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .sl-single { padding: 24px 0 48px; }
  .sl-single__back { padding: 0 16px; }
  .sl-post,
  .card--social { border-radius: 0; border-left: none; border-right: none; }
  .card--social { max-width: 100%; }

  .sl-overlay { padding: 0; align-items: stretch; }
  .sl-overlay__panel { max-width: 100%; }
  .sl-overlay__panel .sl-post { box-shadow: none; min-height: 100vh; }
  .sl-overlay__close { top: 10px; right: 10px; }
}
