/* ==========================================================================
   Isolated Affiliate Advertisement Styles (.yp-* namespace)
   No external UI frameworks required. Mobile-first & fluid.
   ========================================================================== */

.yp-ad-slot {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 1.5rem auto;
  box-sizing: border-box;
  overflow: hidden;
  clear: both;
}

.yp-ad-slot:empty {
  display: none !important;
}

.yp-affiliate-ad {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.yp-affiliate-ad:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.yp-affiliate-link {
  display: flex;
  flex-direction: row;
  align-items: center;
  width: 100%;
  height: 100%;
  text-decoration: none;
  color: inherit;
  box-sizing: border-box;
  outline: none;
}

.yp-affiliate-link:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}

/* 100% Image-Only Banner */
.yp-mode-image-only .yp-affiliate-link {
  display: block;
  height: 100%;
}

.yp-mode-image-only .yp-affiliate-image-wrap {
  width: 100%;
  height: 100%;
  max-height: none;
}

.yp-mode-image-only .yp-affiliate-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Image Wrappers */
.yp-affiliate-image-wrap {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-color: #f8fafc;
  min-height: 80px;
}

.yp-affiliate-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: opacity 0.3s ease;
}

/* Content Area */
.yp-affiliate-content {
  box-sizing: border-box;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.5rem;
  overflow: hidden;
}

.yp-affiliate-title {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  color: #0f172a;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.yp-affiliate-description {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.875rem;
  line-height: 1.4;
  color: #475569;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.yp-affiliate-button {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  margin-top: 0.25rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #ffffff;
  background-color: #ff9900; /* Warm e-commerce accent */
  border: none;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease;
}

.yp-affiliate-link:hover .yp-affiliate-button {
  background-color: #e68a00;
}

/* Dynamic Orientation Styling (imageWidth = 'auto') */
.yp-layout-auto .yp-affiliate-image-wrap {
  flex: 0 0 40%;
}
.yp-layout-auto .yp-affiliate-content {
  flex: 0 0 60%;
}

.yp-img-portrait .yp-affiliate-image-wrap {
  flex: 0 0 30% !important;
}
.yp-img-portrait .yp-affiliate-content {
  flex: 0 0 70% !important;
}

.yp-img-landscape .yp-affiliate-image-wrap {
  flex: 0 0 45% !important;
}
.yp-img-landscape .yp-affiliate-content {
  flex: 0 0 55% !important;
}

/* Compact Banners (e.g. 720x90, 728x90) */
@container (max-height: 120px) or (max-width: 480px) {
  .yp-affiliate-content {
    padding: 0.5rem 0.75rem;
    gap: 0.25rem;
  }
  .yp-affiliate-title {
    font-size: 0.875rem;
    -webkit-line-clamp: 1;
  }
  .yp-affiliate-description {
    font-size: 0.75rem;
    -webkit-line-clamp: 1;
  }
  .yp-affiliate-button {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }
}

/* Mobile Split Layout Breakpoint */
@media screen and (max-width: 600px) {
  .yp-affiliate-link:not(.yp-mode-image-only .yp-affiliate-link) {
    flex-direction: column !important;
  }

  .yp-affiliate-image-wrap {
    width: 100% !important;
    flex: none !important;
    height: 180px;
  }

  .yp-affiliate-content {
    width: 100% !important;
    flex: none !important;
    padding: 1rem;
  }

  .yp-ad-slot {
    aspect-ratio: auto !important;
  }
}