/* 名片页广告单元 v2 */
.card-ad-section {
    margin: 16px 0 0;
    padding: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    transition: opacity 0.25s ease, transform 0.25s ease, max-height 0.3s ease;
}

.card-ad-section.is-dismissing {
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
}

.card-ad-section[hidden] {
    display: none !important;
}

.card-ad-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px 4px;
}

.card-ad-label {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    letter-spacing: 0.02em;
}

.card-ad-dismiss {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin: -4px -4px -4px 0;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.card-ad-dismiss:hover {
    background: rgba(15, 23, 42, 0.06);
    color: #475569;
}

.card-ad-carousel-outer {
    padding: 0 12px 12px;
}

.card-ad-slides-viewport {
    width: 100%;
    overflow: hidden;
    border-radius: 10px;
    background: #f1f5f9;
    aspect-ratio: 2 / 1;
    min-height: 120px;
}

/* 仅直投或优量汇渲染完成后：高度随内容 */
.card-ad-slides-viewport.is-house-only,
.card-ad-slides-viewport.has-ylh-h5-ready,
.card-ad-slides-viewport.has-ylh-pc-ready {
    aspect-ratio: auto;
    height: auto;
}

.card-ad-slides {
    display: flex;
    align-items: stretch;
    transition: transform 0.35s ease;
    will-change: transform;
}

/* 固定 2:1 骨架（优量汇加载中） */
.card-ad-slides-viewport:not(.is-house-only):not(.has-ylh-h5-ready):not(.has-ylh-pc-ready) .card-ad-slides {
    height: 100%;
}

.card-ad-slide {
    flex: 0 0 auto;
    flex-shrink: 0;
    box-sizing: border-box;
    min-width: 0;
    align-self: stretch;
}

.card-ad-slides-viewport:not(.is-house-only):not(.has-ylh-h5-ready):not(.has-ylh-pc-ready) .card-ad-slide--ylh {
    height: 100%;
}

.card-ad-slides-viewport:not(.is-house-only):not(.has-ylh-h5-ready):not(.has-ylh-pc-ready) .card-ad-slide--ylh .card-ad-slide-inner,
.card-ad-slides-viewport:not(.is-house-only):not(.has-ylh-h5-ready):not(.has-ylh-pc-ready) .card-ad-slide--ylh .card-ad-media--pc {
    height: 100%;
}

.card-ad-slide-inner {
    width: 100%;
}

.card-ad-media {
    position: relative;
    width: 100%;
    border-radius: 10px;
}

.card-ad-media--ylh {
    display: block;
    width: 100%;
    min-height: 120px;
}

.card-ad-media--ylh.card-ad-media--pc:not(.is-ready) {
    overflow: hidden;
    height: 100%;
    min-height: 120px;
}

.card-ad-media--ylh.card-ad-media--pc.is-ready {
    overflow: visible;
    height: auto;
    min-height: 120px;
}

/* H5 联盟模板需完整展示，禁止裁切 */
.card-ad-media--ylh.card-ad-media--h5 {
    overflow: visible;
    height: auto;
    min-height: 120px;
}

.card-ad-media--ylh.card-ad-media--h5.is-ready {
    overflow: visible;
}

.card-ad-media--ylh.card-ad-media--h5 > * {
    max-width: 100%;
}

.card-ad-skeleton {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #e2e8f0 0%, #f1f5f9 50%, #e2e8f0 100%);
    background-size: 200% 100%;
    animation: card-ad-shimmer 1.2s ease-in-out infinite;
}

.card-ad-media--ylh.is-ready .card-ad-skeleton,
.card-ad-media--ylh.is-failed .card-ad-skeleton {
    display: none;
}

@keyframes card-ad-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.card-ad-media--house {
    overflow: visible;
    height: auto;
}

.card-ad-image-link {
    display: block;
    width: 100%;
    line-height: 0;
}

.card-ad-media--house .card-ad-image-link {
    height: auto;
}

.card-ad-slides-viewport:not(.is-house-only):not(.has-ylh-h5-ready):not(.has-ylh-pc-ready) .card-ad-media--house .card-ad-image-link {
    height: 100%;
}

.card-ad-image-link:hover {
    opacity: 0.95;
}

.card-ad-image,
.card-ad-media--house img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 300px;
    object-fit: contain;
}

.card-ad-slides-viewport:not(.is-house-only):not(.has-ylh-h5-ready):not(.has-ylh-pc-ready) .card-ad-media--house img {
    height: 100%;
    max-height: 100%;
    object-fit: contain;
}

.card-ad-html-wrap {
    width: 100%;
    overflow: auto;
    font-size: 14px;
}

.card-ad-ylh-inner {
    position: relative;
    width: 100%;
    min-height: 80px;
}

.card-ad-media--pc .card-ad-ylh-inner {
    height: 100%;
    min-height: 120px;
}

.card-ad-media--h5 .card-ad-ylh-inner {
    height: auto;
}

.card-ad-ylh-inner img:not(.card-ad-ylh-logo),
.card-ad-ylh-inner video,
.card-ad-ylh-inner iframe,
.card-ad-media--h5 img,
.card-ad-media--h5 video {
    display: block;
    max-width: 100%;
    width: 100%;
    height: auto;
    object-fit: contain;
}

.card-ad-ylh-meta {
    padding: 8px 10px 10px;
    font-size: 13px;
    line-height: 1.4;
}

.card-ad-ylh-media {
    width: 100%;
    min-height: 120px;
}

.card-ad-ylh-logo-wrap {
    line-height: 0;
    max-width: 48px;
}

.card-ad-ylh-logo {
    display: block;
    height: 12px;
    width: auto;
    max-width: 44px;
    object-fit: contain;
    opacity: 0.5;
}

.card-ad-ylh-title {
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 4px;
}

.card-ad-ylh-desc {
    color: #64748b;
    font-size: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-ad-ylh-btn {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 14px;
    border-radius: 6px;
    background: #667eea;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}

.card-ad-ylh-click-stub {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.card-ad-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px 4px;
}

.card-ad-dot {
    width: 6px;
    height: 6px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #cbd5e1;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.card-ad-dot.is-active {
    background: #667eea;
    transform: scale(1.15);
}

.error-page .card-ad-section {
    margin-top: 24px;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 480px) {
    .card-ad-dismiss {
        width: 36px;
        height: 36px;
    }
}

.card-ad-debug {
    position: fixed;
    bottom: 12px;
    left: 12px;
    right: 12px;
    max-height: 40vh;
    overflow: auto;
    padding: 10px;
    font-size: 11px;
    font-family: monospace;
    background: rgba(15, 23, 42, 0.92);
    color: #e2e8f0;
    border-radius: 8px;
    z-index: 99999;
}
