/* ==========================================================================
   MONETIZATION STYLES — aiagencystack.com
   Philosophy: Ads that feel like content. Revenue without UX damage.
   All slots use CSS containment + aspect-ratio to prevent CLS = 0 shift.
   ========================================================================== */

/* ==========================================================================
   1. CLS PREVENTION — Critical: reserve space before ad loads
   ========================================================================== */

/* Every ad wrapper reserves exact pixel space via aspect-ratio or min-height.
   This prevents Cumulative Layout Shift (CLS) — the #1 PageSpeed killer for ad pages. */

[data-ad-slot] {
  contain: layout style;           /* CSS containment: isolate repaint */
  overflow: hidden;
  position: relative;
  border-radius: 0.75rem;
}

/* Placeholder shimmer shown while ad loads */
[data-ad-slot]::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    var(--wp--preset--color--surface) 25%,
    var(--wp--preset--color--graphite) 50%,
    var(--wp--preset--color--surface) 75%
  );
  background-size: 200% 100%;
  animation: adShimmer 1.5s ease-in-out infinite;
  z-index: 0;
  border-radius: inherit;
}

/* Remove shimmer once ad content is injected */
[data-ad-slot].is-loaded::before {
  display: none;
}

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

/* ==========================================================================
   2. DISPLAY AD SLOTS — Standard IAB sizes
   ========================================================================== */

/* Leaderboard 728×90 — Header/footer placement */
.ad-leaderboard {
  width: 100%;
  max-width: 728px;
  min-height: 90px;
  margin-inline: auto;
  background: var(--wp--preset--color--surface);
  border: 1px solid var(--wp--preset--color--border);
}

/* Medium Rectangle 300×250 — Sidebar, in-content */
.ad-rectangle {
  width: 100%;
  max-width: 300px;
  min-height: 250px;
  background: var(--wp--preset--color--surface);
  border: 1px solid var(--wp--preset--color--border);
}

/* Wide Skyscraper 300×600 — Sticky sidebar */
.ad-halfpage {
  width: 100%;
  max-width: 300px;
  min-height: 600px;
  background: var(--wp--preset--color--surface);
  border: 1px solid var(--wp--preset--color--border);
}

/* Billboard 970×250 — Homepage hero area */
.ad-billboard {
  width: 100%;
  min-height: 250px;
  background: var(--wp--preset--color--surface);
  border: 1px solid var(--wp--preset--color--border);
}

/* Mobile Banner 320×50 — Mobile only */
.ad-mobile-banner {
  width: 100%;
  max-width: 320px;
  min-height: 50px;
  background: var(--wp--preset--color--surface);
  border: 1px solid var(--wp--preset--color--border);
  display: none;
}
@media (max-width: 480px) {
  .ad-mobile-banner { display: block; }
  .ad-leaderboard   { display: none; }
}

/* Ad label — FTC / Google compliance */
.ad-label {
  position: absolute;
  top: 0.375rem;
  right: 0.625rem;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--wp--preset--color--muted);
  z-index: 10;
  pointer-events: none;
  user-select: none;
}

/* ==========================================================================
   3. NATIVE / IN-FEED AD UNITS
   Blend with content but are clearly labeled "Sponsored"
   ========================================================================== */

.ad-native {
  background: var(--wp--preset--color--surface);
  border: 1px solid var(--wp--preset--color--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  position: relative;
  transition: border-color 250ms ease, box-shadow 250ms ease;
}

.ad-native:hover {
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: 0 8px 32px rgba(99,102,241,0.08);
}

/* Native ad header row */
.ad-native__header {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 1rem;
}

.ad-native__logo {
  width: 40px;
  height: 40px;
  border-radius: 0.5rem;
  background: var(--wp--preset--color--graphite);
  border: 1px solid var(--wp--preset--color--border);
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
}

.ad-native__meta {
  flex: 1;
  min-width: 0;
}

.ad-native__name {
  font-weight: 700;
  color: var(--wp--preset--color--white);
  font-size: 0.9375rem;
  margin-bottom: 0.125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ad-native__category {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--wp--preset--color--accent-bright);
}

.ad-native__sponsored {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--wp--preset--color--muted);
  border: 1px solid var(--wp--preset--color--border);
  padding: 0.2rem 0.5rem;
  border-radius: 0.25rem;
  white-space: nowrap;
}

.ad-native__description {
  color: var(--wp--preset--color--muted);
  font-size: 0.875rem;
  line-height: 1.65;
  margin-bottom: 1rem;
}

.ad-native__cta {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: #FAFAFA;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.5rem 1.25rem;
  border-radius: 9999px;
  text-decoration: none;
  transition: all 200ms ease;
  box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}

.ad-native__cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99,102,241,0.45);
  color: #FAFAFA;
}

/* ==========================================================================
   4. FEATURED AGENCY CARDS — Paid "Featured" listings
   Visually premium but editorially honest (labeled)
   ========================================================================== */

.card--featured {
  position: relative;
  background: var(--wp--preset--color--surface);
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 0.875rem;
  padding: 1.75rem;
  transition: all 250ms ease;
}

.card--featured::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(99,102,241,0.06) 0%, transparent 60%);
  pointer-events: none;
}

.card--featured:hover {
  border-color: rgba(99, 102, 241, 0.65);
  box-shadow: 0 12px 48px rgba(99,102,241,0.14), 0 4px 12px rgba(0,0,0,0.4);
  transform: translateY(-2px);
}

/* Featured badge — top-right corner */
.featured-badge {
  position: absolute;
  top: -1px;
  right: 1.25rem;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: #FAFAFA;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.3rem 0.75rem;
  border-radius: 0 0 0.375rem 0.375rem;
}

/* ==========================================================================
   5. AFFILIATE LINK STYLES — Tracked CTA buttons
   ========================================================================== */

/* Primary affiliate button */
.btn-affiliate {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: #FAFAFA !important;
  font-size: 0.875rem;
  font-weight: 700;
  padding: 0.75rem 1.75rem;
  border-radius: 9999px;
  text-decoration: none !important;
  transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 14px rgba(99,102,241,0.35);
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn-affiliate:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(99,102,241,0.5);
  background: linear-gradient(135deg, #4F46E5, #7C3AED);
}

.btn-affiliate:active {
  transform: translateY(0);
}

/* External link indicator (FTC compliance) */
.btn-affiliate[target="_blank"]::after {
  content: '↗';
  font-size: 0.75em;
  opacity: 0.8;
}

/* Secondary affiliate (text link style) */
.link-affiliate {
  color: var(--wp--preset--color--accent-bright);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid rgba(129, 140, 248, 0.3);
  transition: all 150ms ease;
  padding-bottom: 1px;
}

.link-affiliate:hover {
  color: var(--wp--preset--color--white);
  border-bottom-color: var(--wp--preset--color--white);
}

/* Affiliate disclosure notice — compact */
.affiliate-disclosure {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: var(--wp--preset--color--muted);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--wp--preset--color--border);
  padding: 0.375rem 0.875rem;
  border-radius: 9999px;
}

.affiliate-disclosure::before {
  content: 'ℹ';
  font-size: 0.875rem;
}

/* ==========================================================================
   6. STICKY SIDEBAR AD — Scroll-follows the reader
   ========================================================================== */

.sidebar-sticky-ad {
  position: sticky;
  top: 5.5rem;           /* Below sticky header */
  max-height: calc(100vh - 7rem);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ==========================================================================
   7. IN-CONTENT BANNER — Mid-article, between H2 sections
   Full-width, clearly labeled, high-visibility placement
   ========================================================================== */

.ad-in-content {
  width: 100%;
  background: var(--wp--preset--color--surface);
  border: 1px solid var(--wp--preset--color--border);
  border-radius: 0.75rem;
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  position: relative;
  margin-block: var(--wp--preset--spacing--10);
}

.ad-in-content__left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  min-width: 0;
}

.ad-in-content__icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.ad-in-content__headline {
  font-weight: 700;
  color: var(--wp--preset--color--white);
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.ad-in-content__subline {
  font-size: 0.8125rem;
  color: var(--wp--preset--color--muted);
  line-height: 1.5;
}

/* ==========================================================================
   8. TOOL COMPARISON TABLE — High-converting affiliate placement
   Used on /compare pages
   ========================================================================== */

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  border-radius: 0.75rem;
  overflow: hidden;
  border: 1px solid var(--wp--preset--color--border);
}

.comparison-table th {
  background: var(--wp--preset--color--surface);
  color: var(--wp--preset--color--ghost);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.875rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid var(--wp--preset--color--border);
}

.comparison-table th:first-child {
  width: 30%;
}

.comparison-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(63, 63, 70, 0.5);
  color: var(--wp--preset--color--ghost);
  font-size: 0.9rem;
  vertical-align: middle;
}

.comparison-table tr:last-child td {
  border-bottom: none;
}

.comparison-table tr:hover td {
  background: rgba(255,255,255,0.02);
}

/* Highlight "Best Value" row */
.comparison-table tr.is-recommended td {
  background: rgba(99, 102, 241, 0.05);
}

.comparison-table tr.is-recommended td:first-child {
  border-left: 3px solid var(--wp--preset--color--accent);
}

.table-check  { color: #22C55E; font-size: 1rem; }
.table-cross  { color: #52525B; font-size: 1rem; }
.table-price  { font-weight: 700; color: var(--wp--preset--color--white); }

/* ==========================================================================
   9. NEWSLETTER / LEAD CAPTURE — Inline conversion unit
   ========================================================================== */

.newsletter-inline {
  background: var(--wp--preset--color--surface);
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: 1rem;
  padding: 2rem 2.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
  position: relative;
  overflow: hidden;
}

.newsletter-inline::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(99,102,241,0.15) 0%, transparent 70%);
  pointer-events: none;
}

.newsletter-inline__copy { flex: 1; min-width: 200px; }

.newsletter-inline__title {
  font-weight: 800;
  font-size: 1.125rem;
  color: var(--wp--preset--color--white);
  margin-bottom: 0.375rem;
}

.newsletter-inline__subtitle {
  color: var(--wp--preset--color--muted);
  font-size: 0.875rem;
  line-height: 1.55;
}

.newsletter-inline__form {
  display: flex;
  gap: 0.625rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 260px;
}

.newsletter-inline__input {
  flex: 1;
  min-width: 180px;
  padding: 0.75rem 1.125rem;
  background: var(--wp--preset--color--graphite);
  border: 1px solid var(--wp--preset--color--border);
  border-radius: 9999px;
  color: var(--wp--preset--color--white);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 150ms ease;
}

.newsletter-inline__input:focus {
  border-color: var(--wp--preset--color--accent);
}

.newsletter-inline__input::placeholder {
  color: var(--wp--preset--color--muted);
}

/* ==========================================================================
   10. RESPONSIVE — Hide heavy units on mobile
   ========================================================================== */

@media (max-width: 768px) {
  .ad-halfpage          { display: none; } /* Skip 300×600 on mobile */
  .ad-leaderboard       { display: none; }
  .ad-billboard         { min-height: 120px; }
  .ad-in-content        { flex-direction: column; align-items: flex-start; padding: 1.25rem; }
  .newsletter-inline    { flex-direction: column; padding: 1.5rem; gap: 1.25rem; }
  .sidebar-sticky-ad    { position: static; }
}

/* ==========================================================================
   11. PERFORMANCE — Intersection Observer lazy-load trigger class
   JS in monetization.js adds .is-visible when slot enters viewport
   ========================================================================== */

[data-ad-lazy] {
  opacity: 0;
  transition: opacity 300ms ease;
}

[data-ad-lazy].is-visible {
  opacity: 1;
}

/* Print: hide all ads */
@media print {
  [data-ad-slot],
  .ad-native,
  .ad-in-content,
  .newsletter-inline,
  .card--featured .featured-badge {
    display: none !important;
  }
}
