/**
 * Content sidebar — Tooliak.ir/blog style
 * Independent floating ad cards + white widget boxes with soft shadow
 */

.site-content-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.75rem;
  align-items: start;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 clamp(0.875rem, 2.5vw, 1.5rem) 2.5rem;
  width: 100%;
  min-width: 0;
}

.site-content-layout__main {
  min-width: 0;
}

@media (min-width: 1024px) {
  .site-content-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 2rem;
    padding-bottom: 3.5rem;
  }

  .site-content-sidebar {
    position: sticky;
    top: 5.75rem;
    width: 300px;
  }
}

.site-content-sidebar {
  --scs-radius: 1rem;
  --scs-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  --scs-shadow-hover: 0 10px 28px rgba(15, 23, 42, 0.1);
  --scs-border: #eef1f5;
  --scs-ink: #1e293b;
  --scs-muted: #64748b;
  --scs-accent: var(--kids-primary, #5b8def);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* =========================================================
   AD BANNERS — exact Tooliak.ir/blog cards
   ========================================================= */
.scs-ads {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  width: 100%;
}

/* Soft98-style rotating ad unit */
.scs-ad-slider {
  position: relative;
  width: 100%;
  max-width: 300px;
  margin-inline: auto;
}

.scs-ad-slider__viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 300 / 250;
  min-height: 250px;
  overflow: hidden;
  border-radius: 1rem;
}

.scs-ad-slider .scs-ad-slide {
  position: absolute;
  inset: 0;
  margin: 0;
  max-width: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 420ms ease, visibility 420ms ease;
  z-index: 1;
}

.scs-ad-slider .scs-ad-slide.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 2;
}

.scs-ad-slider__dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

.scs-ad-slider__dot {
  width: 0.55rem;
  height: 0.55rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #cbd5e1;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.scs-ad-slider__dot.is-active {
  background: #3b82f6;
  transform: scale(1.2);
}

.scs-ad-slider__dot:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.scs-ad {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 300px;
  margin-inline: auto;
  overflow: hidden;
  border-radius: 1rem;
  background: #fff;
  border: 1px solid #e8edf3;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.05);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 180ms ease, border-color 180ms ease;
  min-height: 0;
}

.scs-ad:hover {
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.09);
  border-color: #e2e8f0;
  color: inherit;
}

/* Style variants */
.scs-ad--blue .scs-ad__fallback-cta,
.scs-ad--blue.scs-ad--media .scs-ad__chip { color: #fff; }
.scs-ad--blue.scs-ad--media .scs-ad__chip { background: #3b82f6; box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35); }
.scs-ad--blue .scs-ad__fallback-cta { color: #3b82f6; }
.scs-ad--blue .scs-ad__fallback-icon { background: #eff6ff; color: #3b82f6; }

.scs-ad--pink.scs-ad--media .scs-ad__chip { background: #ec4899; color: #fff; box-shadow: 0 2px 8px rgba(236, 72, 153, 0.35); }
.scs-ad--pink .scs-ad__fallback-cta { color: #ec4899; }
.scs-ad--pink .scs-ad__fallback-icon { background: #fdf2f8; color: #ec4899; }

.scs-ad--yellow.scs-ad--media .scs-ad__chip { background: #f59e0b; color: #fff; box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35); }
.scs-ad--yellow .scs-ad__fallback-cta { color: #d97706; }
.scs-ad--yellow .scs-ad__fallback-icon { background: #fffbeb; color: #d97706; }

.scs-ad--green.scs-ad--media .scs-ad__chip { background: #10b981; color: #fff; box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35); }
.scs-ad--green .scs-ad__fallback-cta { color: #059669; }
.scs-ad--green .scs-ad__fallback-icon { background: #ecfdf5; color: #059669; }

.scs-ad--html {
  aspect-ratio: 300 / 250;
  min-height: 250px;
  background: #fff;
}

.scs-ad__html {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.scs-ad__html img,
.scs-ad__html iframe {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Corner chip — Tooliak "تبلیغات" / category tag */
.scs-ad__chip {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: #64748b;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.2;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
  pointer-events: none;
}

.scs-ad--media .scs-ad__chip {
  background: #3b82f6;
  color: #fff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

.scs-ad--slot .scs-ad__chip {
  background: #f1f5f9;
  color: #94a3b8;
  box-shadow: none;
}

/* Image banner 300×250 — keep consistent card height with slot */
.scs-ad--media {
  aspect-ratio: 300 / 250;
  background: #f8fafc;
  min-height: 250px;
}

.scs-ad__media {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.scs-ad__media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

/* Text-only live ad (no image uploaded) */
.scs-ad--text {
  aspect-ratio: 300 / 250;
  min-height: 250px;
  background: #fff;
}

.scs-ad__fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  flex: 1;
  min-height: 100%;
  padding: 2.25rem 1.1rem 1.25rem;
  text-align: center;
}

.scs-ad__fallback-icon {
  width: 2.75rem;
  height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  background: #f1f5f9;
  color: #94a3b8;
  font-size: 1rem;
  margin-bottom: 0.2rem;
}

.scs-ad__fallback-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: #334155;
  line-height: 1.4;
}

.scs-ad__fallback-sub {
  font-size: 0.75rem;
  font-weight: 600;
  color: #94a3b8;
  line-height: 1.5;
  max-width: 15rem;
}

.scs-ad__fallback-cta {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  font-weight: 800;
  color: #3b82f6;
}

/* Tooliak empty inventory slot */
.scs-ad--slot {
  aspect-ratio: 300 / 250;
  min-height: 250px;
  background: #fff;
}

.scs-ad__slot-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  flex: 1;
  padding: 2.4rem 1.15rem 1rem;
  text-align: center;
}

.scs-ad__slot-icon {
  width: 2.85rem;
  height: 2.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.15rem;
  border-radius: 0.75rem;
  background: #f1f5f9;
  color: #a0aec0;
  font-size: 1.05rem;
}

.scs-ad__slot-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: #475569;
  line-height: 1.35;
}

.scs-ad__slot-size {
  font-size: 0.8rem;
  font-weight: 600;
  color: #94a3b8;
  direction: ltr;
  unicode-bidi: isolate;
}

.scs-ad__slot-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: auto;
  padding: 0.85rem 1rem;
  border-top: 1px solid #f1f5f9;
  font-size: 0.74rem;
  font-weight: 700;
  color: #64748b;
  text-align: center;
  line-height: 1.45;
  transition: color 150ms ease, background 150ms ease;
}

.scs-ad--slot:hover .scs-ad__slot-foot {
  color: #3b82f6;
  background: #f8fafc;
}

/* =========================================================
   CONTENT WIDGET BOX — popular / recent
   ========================================================= */
.scs-box {
  background: #fff;
  border: 1px solid var(--scs-border);
  border-radius: var(--scs-radius);
  box-shadow: var(--scs-shadow);
  overflow: hidden;
}

.scs-box__head {
  padding: 1rem 1.1rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
}

.scs-box__title {
  position: relative;
  margin: 0;
  padding-right: 0.7rem;
  font-size: 0.95rem;
  font-weight: 900;
  color: var(--scs-ink);
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.scs-box__title::before {
  content: '';
  position: absolute;
  right: 0;
  top: 0.15rem;
  bottom: 0.15rem;
  width: 3px;
  border-radius: 999px;
  background: var(--scs-accent);
}

.scs-feed {
  list-style: none;
  margin: 0;
  padding: 0.45rem 0.55rem;
  display: flex;
  flex-direction: column;
}

.scs-feed > li + li {
  border-top: 1px solid #f5f7fa;
}

.scs-feed__item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.7rem 0.5rem;
  border-radius: 0.75rem;
  text-decoration: none;
  color: inherit;
  transition: background 150ms ease;
}

.scs-feed__item:hover {
  background: #f7f9fc;
  color: inherit;
}

.scs-feed__thumb {
  width: 3.35rem;
  height: 3.35rem;
  border-radius: 0.7rem;
  overflow: hidden;
  flex-shrink: 0;
  background: #eef3f9;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.scs-feed__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scs-feed__thumb--icon {
  color: var(--scs-accent);
  font-size: 0.95rem;
  background: #eef4ff;
}

.scs-feed__body {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-top: 0.1rem;
}

.scs-feed__title {
  font-size: 0.8125rem;
  font-weight: 800;
  color: var(--scs-ink);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.scs-feed__item:hover .scs-feed__title {
  color: var(--scs-accent);
}

.scs-feed__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: #64748b;
}

.scs-feed__meta i {
  margin-left: 0.2rem;
  font-size: 0.65rem;
}

.scs-box__more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin: 0.15rem 0.75rem 0.85rem;
  padding: 0.65rem 0.85rem;
  border-radius: 0.75rem;
  background: #f7f9fc;
  color: var(--scs-accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-decoration: none;
  transition: background 150ms ease, gap 150ms ease;
}

.scs-box__more:hover {
  background: #eef4ff;
  gap: 0.55rem;
  color: #3a72d9;
}

/* =========================================================
   Mobile
   ========================================================= */
@media (max-width: 1023px) {
  .scs-ads {
    flex-direction: row;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 0.75rem;
    padding-bottom: 0.35rem;
  }

  .scs-ad {
    flex: 0 0 min(78vw, 300px);
    max-width: 300px;
    scroll-snap-align: start;
    margin-inline: 0;
  }

  .scs-ad--media,
  .scs-ad--text,
  .scs-ad--slot {
    aspect-ratio: 300 / 250;
    height: auto;
    min-height: 0;
  }

  .scs-ad__media img {
    height: 100%;
  }
}

/* Page integrations */
.page-cartoons-educational .site-content-layout,
.page-cartoons-long .site-content-layout {
  padding-top: 0;
}

.page-cartoons-educational .blog-page-container,
.page-cartoons-long .blog-page-container {
  max-width: none;
  padding: 0;
}

#blog-list .site-content-layout {
  margin-top: 0;
}

#blog-list .blog-page-body .site-content-layout {
  padding-top: 1.75rem;
}

/* Align sidebar top edge with featured section title / first content block */
@media (min-width: 1024px) {
  #blog-list .site-content-sidebar {
    margin-top: 0;
    padding-top: 0;
  }

  #blog-list .scs-ads {
    margin-top: 0;
  }

  #blog-list .blog-featured-section .blog-section-title,
  #blog-list .blog-posts-heading {
    min-height: 2.35rem;
  }
}

.blog-detail-new .site-content-layout {
  padding-top: 1rem;
}

/* Admin preview */
.sidebar-ad-preview-wrap .scs-ad,
.sidebar-ad-preview-wrap .scs-promo,
.sidebar-ad-preview-wrap .site-sidebar-ad {
  pointer-events: none;
}

.sidebar-ad-preview-wrap .scs-ad:hover {
  transform: none;
  box-shadow: var(--scs-shadow);
}

/* Legacy aliases (admin / older markup) */
.site-sidebar-ad {
  display: block;
  text-decoration: none;
  color: inherit;
}

.site-sidebar-ad__inner {
  background: #fff;
  border: 1px solid var(--scs-border, #eef1f5);
  border-radius: 1rem;
  padding: 0.85rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.site-sidebar-ad__img {
  width: 52px;
  height: 52px;
  border-radius: 0.75rem;
  overflow: hidden;
  flex-shrink: 0;
}

.site-sidebar-ad__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.site-sidebar-ad__title {
  font-size: 0.84rem;
  font-weight: 900;
  margin: 0 0 0.2rem;
  color: #1e293b;
}

.site-sidebar-ad__subtitle {
  font-size: 0.72rem;
  color: #64748b;
  margin: 0 0 0.45rem;
}

.site-sidebar-ad__cta {
  font-size: 0.72rem;
  font-weight: 800;
  color: #5b8def;
}

@media (prefers-reduced-motion: reduce) {
  .scs-ad,
  .scs-ad__media img,
  .scs-feed__item,
  .scs-box__more {
    transition: none;
  }

  .scs-ad:hover {
    transform: none;
  }
}
