/* 联盟详情弹窗 — 小红书 PC 式左右分栏 */

html.explore-detail-open,
html.bp-aff-detail-open {
  overflow: hidden;
}

.explore-detail-modal[hidden],
.bp-aff-detail-modal[hidden] {
  display: none !important;
}

.explore-detail-modal,
.bp-aff-detail-modal {
  position: fixed;
  inset: 0;
  z-index: 100050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  box-sizing: border-box;
}

.explore-detail-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
}

.bp-aff-detail-modal__panel,
.explore-detail-modal__panel.bp-aff-detail-modal__panel {
  position: relative;
  z-index: 1;
  width: 80vw;
  height: 80vh;
  min-height: 0;
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 2rem);
  margin: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.22);
  --color-primary: var(--theme-palette-color-1, #f08347);
  animation: bp-aff-detail-in 0.18s ease-out;
}

/* 无海报：仅右侧，高度随内容，限制最大高度 */
.bp-aff-detail-modal--compact .bp-aff-detail-modal__panel,
.bp-aff-detail-modal--compact .explore-detail-modal__panel.bp-aff-detail-modal__panel {
  width: min(420px, calc(100vw - 2rem));
  height: auto;
  min-height: 0;
  max-height: min(560px, calc(100vh - 3rem));
  display: flex;
  flex-direction: column;
}

/* 灯箱需压过详情弹窗 */
html.bp-aff-detail-open .image-lightbox {
  z-index: 100080;
}

@keyframes bp-aff-detail-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.bp-aff-detail-modal__close,
.explore-detail-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.06);
  color: #64748b;
  line-height: 0;
  cursor: pointer;
}

.bp-aff-detail-modal__close-icon {
  display: block;
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
}

.bp-aff-detail-modal__close:hover,
.explore-detail-modal__close:hover {
  color: #0f172a;
  background: rgba(15, 23, 42, 0.1);
}

.explore-detail-modal__body,
.bp-aff-detail-modal__body {
  height: 100%;
  padding: 0;
  min-height: 0;
}

/* 无海报：外壳高度跟内容，不把空白撑在按钮下方 */
.bp-aff-detail-modal--compact .bp-aff-detail-modal__body,
.bp-aff-detail-modal--compact .explore-detail-modal__body {
  height: auto;
  flex: 0 1 auto;
  min-height: 0;
  display: block;
  overflow: hidden;
}

/* ——— 布局 ——— */
.bp-aff-detail {
  display: grid;
  /* 右侧约为原宽度的 2/3（约 28%），左侧让出更多给海报 */
  grid-template-columns: minmax(0, 1.72fr) minmax(240px, 0.57fr);
  height: 100%;
  min-height: 0;
}

.bp-aff-detail--no-poster {
  display: flex;
  flex-direction: column;
  height: auto;
  max-height: 100%;
  min-height: 0;
}

.bp-aff-detail__media {
  position: relative;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(120% 80% at 20% 10%, rgba(255, 255, 255, 0.08), transparent 55%),
    linear-gradient(160deg, #1a1f2b 0%, #0f141c 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.bp-aff-detail__media-zoom {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.bp-aff-detail__media-zoom:focus-visible {
  outline: 2px solid var(--color-primary, #f08347);
  outline-offset: -2px;
}

.bp-aff-detail__poster {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
  pointer-events: none;
}

.bp-aff-detail__zoom-hint {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  white-space: nowrap;
}

.bp-aff-detail__media-zoom:hover .bp-aff-detail__zoom-hint,
.bp-aff-detail__media-zoom:focus-visible .bp-aff-detail__zoom-hint {
  opacity: 1;
}

.bp-aff-detail__aside {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  background: #fff;
  border-left: 1px solid rgba(15, 23, 42, 0.06);
}

.bp-aff-detail--no-poster .bp-aff-detail__aside {
  flex: 0 1 auto;
  height: auto;
  border-left: 0;
  min-height: 0;
  max-height: 100%;
}

.bp-aff-detail__header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-shrink: 0;
  padding: 22px 48px 14px 22px;
}

.bp-aff-detail__logo {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  background: #f3f4f6;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.bp-aff-detail__identity {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bp-aff-detail__title {
  margin: 0;
  padding: 0;
  color: #111827;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.35;
}

.bp-aff-detail__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bp-aff-detail__tags span {
  font-size: 12px;
  color: #6b7280;
  height: 22px;
  padding: 0 8px;
  line-height: 22px;
  background: #f3f4f6;
  border-radius: 999px;
}

.bp-aff-detail__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 4px 22px 16px;
  -webkit-overflow-scrolling: touch;
}

/* 无海报：正文不抢高度，按钮紧跟内容 */
.bp-aff-detail--no-poster .bp-aff-detail__body {
  flex: 0 1 auto;
}

.bp-aff-detail__desc {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.7;
  color: #4b5563;
  white-space: pre-wrap;
}

.bp-aff-detail__code {
  margin: 0 0 10px;
  max-width: 100%;
}

.bp-aff-detail__code .article-nav-code__capsule {
  width: 100%;
}

.bp-aff-detail__code .article-nav-code__value {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bp-aff-detail__code-note {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.6;
  color: #6b7280;
  white-space: pre-wrap;
}

.bp-aff-detail__footer {
  flex-shrink: 0;
  margin-top: auto;
  padding: 14px 22px 18px;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  background: #fff;
}

.bp-aff-detail--no-poster .bp-aff-detail__footer {
  margin-top: 0;
}

.bp-aff-detail__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.bp-aff-detail__btn {
  flex: 1 1 calc(50% - 5px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none !important;
  box-sizing: border-box;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease,
    filter 0.15s ease;
}

.bp-aff-detail__btn--primary {
  background: var(--color-primary, #f08347);
  color: #fff !important;
  border: 1px solid transparent;
}

.bp-aff-detail__btn--primary:hover {
  filter: brightness(1.05);
  color: #fff !important;
}

.bp-aff-detail__btn--secondary {
  background: #fff;
  color: var(--color-primary, #f08347) !important;
  border: 1px solid var(--color-primary, #f08347);
}

.bp-aff-detail__btn--secondary:hover {
  background: color-mix(in srgb, var(--color-primary, #f08347) 10%, #fff);
}

.bp-aff-detail__actions .bp-aff-detail__btn:only-child {
  flex-basis: 100%;
}

@media screen and (max-width: 768px) {
  .explore-detail-modal,
  .bp-aff-detail-modal {
    padding: 1rem;
    align-items: center;
    justify-content: center;
  }

  /* 有海报：宽高各约 80% */
  .bp-aff-detail-modal__panel,
  .explore-detail-modal__panel.bp-aff-detail-modal__panel {
    width: 80vw;
    height: 80vh;
    min-height: 0;
    max-width: 80vw;
    max-height: 80vh;
    border-radius: 14px;
  }

  /* 无海报：宽度适中，高度随内容 */
  .bp-aff-detail-modal--compact .bp-aff-detail-modal__panel,
  .bp-aff-detail-modal--compact .explore-detail-modal__panel.bp-aff-detail-modal__panel {
    width: min(420px, 80vw);
    height: auto;
    min-height: 0;
    max-width: 80vw;
    max-height: min(80vh, 560px);
    border-radius: 14px;
  }

  .bp-aff-detail {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(160px, 36%) minmax(0, 1fr);
  }

  .bp-aff-detail--no-poster {
    display: flex;
    flex-direction: column;
    grid-template-rows: none;
    height: auto;
    max-height: 100%;
  }

  .bp-aff-detail__aside {
    border-left: 0;
    border-top: 1px solid rgba(15, 23, 42, 0.06);
  }

  .bp-aff-detail--no-poster .bp-aff-detail__aside {
    border-top: 0;
  }

  .bp-aff-detail__header {
    padding-top: 18px;
  }
}
