/*
 * static/css/ads/ads.css
 * ========================
 * Advertisement styling for TheSelfistry.
 *
 * Goals:
 *   ✓ Zero CLS (Cumulative Layout Shift) — reserved space for all ad slots
 *   ✓ Policy-compliant labels ("Advertisement")
 *   ✓ Responsive ad containers
 *   ✓ Graceful loading states (shimmer placeholder)
 *   ✓ Accessible (role=complementary, aria-label)
 *
 * All ad containers use min-height reservation to prevent layout shift.
 * The shimmer animation gives visual feedback while the ad loads.
 */

/* ─────────────────────────────────────────────────────────────────── */
/* Base Ad Container                                                    */
/* ─────────────────────────────────────────────────────────────────── */

.ad-container {
  position: relative;
  width: 100%;
  overflow: hidden;
  margin-block: 1.5rem;
  text-align: center;
  /* No border/background — networks dislike decorative ad frames */
}

/* Ad label — "Advertisement" / "Sponsored" */
.ad-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #aaa;
  margin-bottom: 4px;
  user-select: none;
}

/* ─────────────────────────────────────────────────────────────────── */
/* Shimmer Placeholder (shown while ad loads)                          */
/* ─────────────────────────────────────────────────────────────────── */

.ad-placeholder {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 37%,
    #f0f0f0 63%
  );
  background-size: 400% 100%;
  animation: adShimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
  min-height: 90px;
  width: 100%;
}

@keyframes adShimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position:   0% 50%; }
}

/* ─────────────────────────────────────────────────────────────────── */
/* CLS-Safe Reserved Dimensions per Slot                              */
/* ─────────────────────────────────────────────────────────────────── */

/* Leaderboard: 728×90 */
.ad-container--top_leaderboard .ad-placeholder,
.ad-container--below_navigation .ad-placeholder {
  min-height: 90px;
  max-width: 728px;
  margin-inline: auto;
}

/* Sidebar slots: 300×250 or 300×600 */
.ad-container--sidebar_top .ad-placeholder,
.ad-container--sidebar_middle .ad-placeholder,
.ad-container--sidebar_bottom .ad-placeholder {
  min-height: 250px;
  max-width: 300px;
  margin-inline: auto;
}

.ad-container--sidebar_sticky .ad-placeholder {
  min-height: 600px;
  max-width: 300px;
  margin-inline: auto;
}

/* In-content: 300×250 or responsive */
.ad-container--in-content .ad-placeholder,
.ad-container--above_content .ad-placeholder,
.ad-container--below_content .ad-placeholder,
.ad-container--middle_content .ad-placeholder {
  min-height: 250px;
}

/* Mobile banner: 320×50 */
.ad-container--mobile_top .ad-placeholder,
.ad-container--mobile_bottom_sticky .ad-placeholder {
  min-height: 50px;
}

/* Footer: responsive */
.ad-container--footer_top .ad-placeholder,
.ad-container--footer_bottom .ad-placeholder {
  min-height: 90px;
}

/* ─────────────────────────────────────────────────────────────────── */
/* In-Content Ads                                                       */
/* ─────────────────────────────────────────────────────────────────── */

.ad-container--in-content {
  margin-block: 2rem;
  padding: 0;
  clear: both;
}

/* ─────────────────────────────────────────────────────────────────── */
/* Affiliate Banner                                                     */
/* ─────────────────────────────────────────────────────────────────── */

.ad-affiliate-link {
  display: block;
  text-decoration: none;
}

.ad-banner-img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin-inline: auto;
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
  transition: opacity 0.2s ease;
}

.ad-affiliate-link:hover .ad-banner-img {
  opacity: 0.92;
}

/* ─────────────────────────────────────────────────────────────────── */
/* Sticky Sidebar Ad                                                    */
/* ─────────────────────────────────────────────────────────────────── */

.ad-sidebar-sticky-wrap {
  position: sticky;
  top: 100px; /* below navbar */
}

/* ─────────────────────────────────────────────────────────────────── */
/* Mobile Sticky Bottom Bar                                             */
/* ─────────────────────────────────────────────────────────────────── */

.ad-sticky-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1050;
  background: #fff;
  box-shadow: 0 -2px 12px rgba(0,0,0,.12);
  padding: 6px 12px;
  text-align: center;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.ad-sticky-close {
  position: absolute;
  top: 4px;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  color: #888;
  transition: color 0.2s;
}

.ad-sticky-close:hover { color: #333; }

/* Hide sticky bottom on desktop — mobile only */
@media (min-width: 768px) {
  .ad-sticky-bottom { display: none; }
}

/* ─────────────────────────────────────────────────────────────────── */
/* Sponsor Disclosure                                                   */
/* ─────────────────────────────────────────────────────────────────── */

.sponsor-disclosure {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: hsl(170 25% 96%);
  border-left: 3px solid var(--color-primary, #63D3C6);
  border-radius: 0 6px 6px 0;
  padding: 12px 16px;
  margin-bottom: 1.5rem;
  font-size: 0.82rem;
  color: #555;
  line-height: 1.55;
}

.sponsor-disclosure__icon {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--color-primary, #63D3C6);
}

.sponsor-disclosure p {
  margin: 0;
}

/* ─────────────────────────────────────────────────────────────────── */
/* Device-specific hiding                                               */
/* ─────────────────────────────────────────────────────────────────── */

/* These classes are added by ads.js based on detected device */
.ad-hide-desktop { display: none !important; }
.ad-hide-mobile  { display: none !important; }
.ad-hide-tablet  { display: none !important; }

@media (min-width: 992px) {
  .ad-show-mobile-only { display: none !important; }
}

@media (max-width: 991px) {
  .ad-show-desktop-only { display: none !important; }
}

/* ─────────────────────────────────────────────────────────────────── */
/* Lazy-loaded state (before IntersectionObserver triggers)            */
/* ─────────────────────────────────────────────────────────────────── */

.ad-lazy .ad-content {
  min-height: 90px;
}

.ad-loaded .ad-placeholder {
  display: none;
}

/* ─────────────────────────────────────────────────────────────────── */
/* Print: never print ads                                               */
/* ─────────────────────────────────────────────────────────────────── */

@media print {
  .ad-container,
  .ad-sticky-bottom,
  .sponsor-disclosure {
    display: none !important;
  }
}
