/* single-post.css – pełna, finalna wersja z poprawionym sticky */

/*********************************************************
 * 1) Reset overflow na rodzicach, by sticky zadziałało
 *********************************************************/
.single-post-page,
.single-post-page .content-layout,
.single-post-page .sidebar-left,
.single-post-page .sidebar-right {
  overflow: visible !important;
}

/*********************************************************
 * 2) Trójkolumnowy układ
 *********************************************************/
.single-post-page .content-layout {
  display: flex;
  align-items: flex-start;
  gap: var(--gutter);
  max-width: calc(
    var(--post-width) + 2 * var(--sidebar-width) + 2 * var(--gutter)
  );
  margin: 0 auto;
  padding: 20px;
  box-sizing: border-box;
}

/*********************************************************
 * 3) Kolumny boczne – szerokości
 *********************************************************/
.single-post-page .sidebar-left,
.single-post-page .sidebar-right {
  width: var(--sidebar-width);
  flex-shrink: 0;
}

/*********************************************************
 * 4) Środkowa kolumna – treść wpisu
 *********************************************************/
.single-post-page .post-content {
  width: var(--post-width);
  background: var(--bg-color);
}
.single-post-page .post-title {
  font-size: 2.6em;
  font-weight: bold;
  color: var(--accent-color);
  margin-bottom: 0.5em;
}
.single-post-page .post-featured-image {
  margin-bottom: 1.5em;
}
.single-post-page .post-featured-image img {
  width: 100%;
  border-radius: 10px;
  object-fit: cover;
}
.single-post-page .single-post-body p {
  text-align: justify;
}

/*********************************************************
 * 5) Prawa kolumna – proponowane artykuły
 *********************************************************/
.single-post-page .related-posts ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.single-post-page .related-posts li {
  width: var(--sidebar-width);
}
.single-post-page .related-posts .thumb {
  width: 100%;
  padding-top: 56.25%; /* 16:9 */
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  margin-bottom: 0.4em;
}
.single-post-page .related-posts .thumb img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.single-post-page .related-posts .title {
  font-size: 0.9em;
  font-weight: bold;
  line-height: 1.2;
  color: var(--text-color);
}

/*********************************************************
 * 6) Placeholder reklam – wspólne style i sticky
 *********************************************************/
.ad-placeholder {
  width: var(--sidebar-width);
  height: 600px;
  background: #e0e0e0;
  border: 1px dashed #ccc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9em;
  color: #333;

  /* ===== sticky ===== */
  position: -webkit-sticky;
  position: sticky;
  top: 120px;        /* odległość od top okna (header wysokość) */
  z-index: 5;
}
.ad-placeholder .ad-content {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ccc;
}
.ad-placeholder .ad-label {
  width: 100%;
  background: #ddd;
  font-style: italic;
  text-align: center;
  padding: 10px 0;
  color: #666;
  font-size: 0.75em;
}

/* 6a) odstęp przed prawą reklamą */
.single-post-page .related-posts + .ad-placeholder {
  margin-top: var(--gutter);
}

/*********************************************************
 * 7) Responsywność
 *********************************************************/
@media (max-width: 991.98px) {
  .single-post-page .content-layout {
    flex-direction: column;
    padding: 10px;
  }
  .single-post-page .sidebar-left,
  .single-post-page .sidebar-right {
    width: 100%;
    margin-bottom: 20px;
  }
  .single-post-page .post-content {
    width: 100%;
  }
  .ad-placeholder {
    position: relative;
    top: auto;
  }
}



/* ===== COGNIMAT STICKY ADS — FINAL OVERRIDES ===== */
/* Make columns stretch so sticky has travel room */
.single-post-page .content-layout { align-items: stretch !important; }
.single-post-page .sidebar-left, .single-post-page .sidebar-right { position: relative; padding-bottom: 20px; }

/* Desktop: force sticky on rails and placeholders */
@media (min-width: 992px) {
  .ad-rail.ad-sticky,
  .single-post-page .sidebar-left .ad-placeholder,
  .single-post-page .sidebar-right .ad-placeholder {
    position: sticky !important;
    top: calc(var(--admin-bar-offset, 0px) + var(--masthead-height, 0px) + 20px) !important;
    z-index: 0 !important; /* below header */
  }
}

/* Mobile: ensure side elements are not sticky */
@media (max-width: 991.98px) {
  .ad-rail.ad-sticky,
  .single-post-page .sidebar-left .ad-placeholder,
  .single-post-page .sidebar-right .ad-placeholder {
    position: static !important;
    top: auto !important;
  }

  .single-post-page .sidebar-left, .single-post-page .sidebar-right { display: none; }

  .ad-mobile { display:block; margin:16px auto; width:300px; height:300px; }
  .ad-mobile .ad-placeholder, .ad-mobile .ad-sticky { position: static; width:100%; height:100%; }
}
