/**
 * Tax Letter Help - Native Ad Styles
 * Conversion-safe, visually neutral ad placements
 */

/* ========================================
   GLOBAL AD STYLES
   ======================================== */

.native-ad {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 0;
  position: relative;
}

.ad-label {
  font-size: 0.75rem;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  font-weight: 500;
  text-align: center;
}

/* Ensure ads don't look like CTAs */
.native-ad [id^="ad-"] {
  min-height: 100px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ========================================
   1. POST-CONTENT NATIVE AD (PRIMARY)
   ======================================== */

.post-content-ad {
  margin-top: 48px;
  margin-bottom: 32px;
  padding: 0 1.5rem;
}

.post-content-ad .ad-label {
  margin-bottom: 16px;
}

#ad-post-content {
  min-height: 250px;
  max-height: 400px;
}

/* ========================================
   2. EXIT / SCROLL-END GRID (DESKTOP ONLY)
   ======================================== */

.exit-grid-ad {
  margin-top: 64px;
  margin-bottom: 48px;
  padding: 0 1.5rem;
  display: none; /* Hidden by default, shown by JS */
}

.exit-grid-ad.visible {
  display: block;
}

.exit-grid-ad .ad-label {
  font-size: 0.875rem;
  margin-bottom: 20px;
  color: #6b7280;
}

#ad-exit-grid {
  min-height: 300px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

/* Desktop only */
@media (max-width: 768px) {
  .exit-grid-ad,
  .desktop-only {
    display: none !important;
  }
}

/* ========================================
   3. MOBILE FOOTER STICKY (SECONDARY)
   ======================================== */

.mobile-footer-ad {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-top: 2px solid #e5e7eb;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
  padding: 12px 16px;
  z-index: 9999;
  transform: translateY(100%);
  transition: transform 0.3s ease-in-out;
  display: none; /* Hidden by default */
}

.mobile-footer-ad.visible {
  display: block;
  transform: translateY(0);
}

.mobile-footer-ad .ad-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #f3f4f6;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  color: #6b7280;
  line-height: 1;
  padding: 0;
  transition: background-color 0.2s;
}

.mobile-footer-ad .ad-close:hover {
  background: #e5e7eb;
  color: #374151;
}

#ad-mobile-footer {
  min-height: 50px;
  max-height: 100px;
  background: #fafafa;
  border-radius: 6px;
}

/* Mobile only */
@media (min-width: 769px) {
  .mobile-footer-ad,
  .mobile-only {
    display: none !important;
  }
}

/* ========================================
   SAFETY RULES
   ======================================== */

/* Ensure ads never overlap with forms or CTAs */
.native-ad {
  pointer-events: auto;
}

/* Prevent ads from looking like buttons */
.native-ad a,
.native-ad button {
  background: transparent !important;
  border: 1px solid #d1d5db !important;
  color: #374151 !important;
}

/* Clear visual separation from content */
.native-ad::before {
  content: '';
  display: block;
  height: 1px;
  background: linear-gradient(to right, transparent, #e5e7eb 20%, #e5e7eb 80%, transparent);
  margin-bottom: 24px;
}

.native-ad::after {
  content: '';
  display: block;
  height: 1px;
  background: linear-gradient(to right, transparent, #e5e7eb 20%, #e5e7eb 80%, transparent);
  margin-top: 24px;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 640px) {
  .post-content-ad {
    margin-top: 32px;
    margin-bottom: 24px;
    padding: 0 1rem;
  }

  #ad-post-content {
    min-height: 200px;
  }

  .mobile-footer-ad {
    padding: 10px 12px;
  }

  #ad-mobile-footer {
    min-height: 50px;
  }
}

/* ========================================
   TABLET ADJUSTMENTS
   ======================================== */

@media (min-width: 769px) and (max-width: 1024px) {
  .post-content-ad,
  .exit-grid-ad {
    max-width: 720px;
  }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.native-ad:focus-within {
  outline: 2px solid #3b82f6;
  outline-offset: 4px;
}

.ad-close:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .mobile-footer-ad {
    transition: none;
  }
}

/* ========================================
   LOADING STATES
   ======================================== */

.native-ad[data-loading="true"] [id^="ad-"]::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 3px solid #e5e7eb;
  border-top-color: #9ca3af;
  border-radius: 50%;
  animation: ad-spinner 0.8s linear infinite;
}

@keyframes ad-spinner {
  to {
    transform: rotate(360deg);
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  .native-ad,
  .mobile-footer-ad {
    display: none !important;
  }
}
