/*
 * Product Placement shell.
 * Participates in Theme Page wide-content (alignwide / wide-size tokens),
 * matching Channel / Video Details / native [zype_video] roots.
 * Without .alignwide, ZypeOTT entry-content rules cap direct children at
 * --zype-content-width instead of --zype-wide-width.
 */
.zype-product-placement {
    --zype-product-placement-wide: var(
        --wp--style--global--wide-size,
        var(--zype-wide-width, var(--wp--style--global--content-size, 100%))
    );
    position: relative;
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    box-sizing: border-box;
}

.zype-product-placement.alignwide,
.entry-content > .zype-product-placement,
.wp-block-post-content > .zype-product-placement {
    width: 100%;
    max-width: min(100%, var(--zype-product-placement-wide));
    margin-left: auto;
    margin-right: auto;
    margin-inline: auto;
    box-sizing: border-box;
}

/*
 * Unlock Theme Page Columns hosts that wrap a lone alignwide product-placement
 * root and would otherwise inherit narrower content-size from entry-content.
 */
.entry-content.alignwide > .wp-block-columns:has(> .wp-block-column > .zype-product-placement.alignwide),
.wp-block-post-content.alignwide > .wp-block-columns:has(> .wp-block-column > .zype-product-placement.alignwide) {
    max-width: min(100%, var(--wp--style--global--wide-size, var(--zype-wide-width, 100%)));
    width: 100%;
}

.zype-product-placement__player {
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* Nested video root fills the placement shell (theme wide column already owned by shell). */
.zype-product-placement .zype_video,
.zype-product-placement .zype_video.alignwide {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
}

.zype-product-overlay {
    position: absolute;
    z-index: 20;
    max-width: min(22%, 320px);
    min-width: 110px;
    background: #fff;
    color: #111827;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.zype-product-overlay[hidden] {
    display: none !important;
}

.zype-product-overlay--topleft { top: 12px; left: 12px; right: auto; bottom: auto; transform: none; }
.zype-product-overlay--topcenter { top: 12px; left: 50%; right: auto; bottom: auto; transform: translateX(-50%); }
.zype-product-overlay--topright { top: 12px; right: 12px; left: auto; bottom: auto; transform: none; }
.zype-product-overlay--botleft { bottom: 52px; left: 12px; right: auto; top: auto; transform: none; }
.zype-product-overlay--botcenter { bottom: 52px; left: 50%; right: auto; top: auto; transform: translateX(-50%); }
.zype-product-overlay--bottomright { bottom: 52px; right: 12px; left: auto; top: auto; transform: none; }

.zype-product-overlay__mini,
.zype-product-overlay__full {
    padding: 8px 10px;
}

.zype-product-overlay__mini {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.zype-product-overlay__full {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.zype-product-overlay--display-full .zype-product-overlay__mini { display: none; }
.zype-product-overlay--display-full .zype-product-overlay__full { display: flex; }
.zype-product-overlay--display-full .zype-product-overlay__collapse { display: none; }

.zype-product-overlay--display-mini .zype-product-overlay__full { display: none; }
.zype-product-overlay--display-mini.is-expanded .zype-product-overlay__mini { display: none; }
.zype-product-overlay--display-mini.is-expanded .zype-product-overlay__full { display: flex; }

.zype-product-overlay a {
    color: #111827;
    text-decoration: underline;
}

.zype-product-overlay__link {
    display: block;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    overflow: hidden;
}

.zype-product-overlay__image {
    display: block;
    max-width: 100%;
    width: 100%;
    height: auto;
    border-radius: 4px;
    object-fit: cover;
    background: #111827;
}

.zype-product-overlay__title {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.35;
}

.zype-product-overlay__expand,
.zype-product-overlay__collapse {
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.9);
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    width: 22px;
    height: 22px;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.zype-product-overlay__collapse {
    order: -1;
    background: #fff;
    color: #111827;
    border-color: rgba(0, 0, 0, 0.3);
}

.zype-product-pause-ad {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.72);
}

.zype-product-pause-ad[hidden] {
    display: none !important;
}

.zype-product-pause-ad__content {
    background: #111827;
    color: #fff;
    padding: 16px;
    border-radius: 8px;
    max-width: 320px;
    text-align: center;
}

.zype-product-pause-ad__content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto 8px;
}

.zype-product-pause-ad__close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #fff;
    border: 0;
    border-radius: 999px;
    width: 32px;
    height: 32px;
    cursor: pointer;
}

.zype-product-placement__chapters,
.chapter-bar {
    margin-top: 10px;
    position: relative;
    height: 14px;
    width: 100%;
    border-radius: 999px;
    background: transparent;
    overflow: visible;
}

.chapter-bar--hidden {
    display: none !important;
}

.zype-product-chapters__markers,
.chapter-bar-markers {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    pointer-events: none;
}

.chapter-bar-markers .chapter-marker {
    position: absolute;
    top: 0;
    height: 100%;
    min-width: 2px;
    padding: 0;
    border: 0;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 2px;
    pointer-events: auto;
    cursor: pointer;
    transition: background 0.15s ease;
}

.chapter-bar-markers .chapter-marker:hover {
    background: rgba(255, 255, 255, 0.85);
}

.zype-product-placement__scrub,
.custom-scrub {
    margin-top: 10px;
    position: relative;
    height: 14px;
    border-radius: 999px;
    background: #111827;
    border: 1px solid #374151;
    overflow: hidden;
}

.zype-product-scrub__progress,
.custom-scrub-progress {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #2563eb, #1d4ed8);
    transition: width 120ms linear;
}

.zype-product-scrub__markers,
.custom-scrub-markers {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.custom-scrub-markers--hidden {
    visibility: hidden;
    opacity: 0;
}

.custom-marker {
    position: absolute;
    top: 0;
    height: 100%;
    pointer-events: none;
}

.custom-marker-segment {
    min-width: 2px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 2px;
}

.zype-product-placement__debug {
    margin-top: 16px;
    padding: 12px 14px;
    border: 1px dashed #c3c4c7;
    border-radius: 6px;
    background: #f6f7f7;
    color: #1d2327;
    font-size: 13px;
}

.zype-product-placement__debug-title {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 600;
}

.zype-product-placement__debug-empty {
    margin: 0;
    color: #646970;
}

.zype-product-placement__debug-table-wrap {
    overflow-x: auto;
}

.zype-product-placement__debug-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.zype-product-placement__debug-table th,
.zype-product-placement__debug-table td {
    padding: 8px 10px;
    border: 1px solid #dcdcde;
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}

.zype-product-placement__debug-table th {
    background: #f0f0f1;
    font-weight: 600;
}

.zype-product-placement__debug-table td:last-child,
.zype-product-placement__debug-table th:last-child {
    white-space: normal;
    min-width: 180px;
}

.zype-product-placement__admin-notice {
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid #dba617;
    border-left-width: 4px;
    border-radius: 4px;
    background: #fcf9e8;
    color: #1d2327;
    font-size: 13px;
}

.zype-product-placement__admin-notice-summary {
    margin: 0;
    font-weight: 600;
}

.zype-product-placement__admin-notice-details {
    margin: 8px 0 0;
    padding-left: 18px;
}

.zype-product-placement__admin-notice-details li {
    margin: 0 0 4px;
}

.zype-product-card {
    display: grid;
    gap: 12px;
    max-width: 320px;
    border: 1px solid #dcdcde;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.zype-product-card__image img {
    display: block;
    width: 100%;
    height: auto;
}

.zype-product-card__body {
    padding: 12px 16px 16px;
}

.zype-product-card__title {
    margin: 0 0 8px;
    font-size: 1.1rem;
}

.zype-product-card__qr img {
    display: block;
    margin-top: 8px;
}

@media (max-width: 600px) {
    .zype-product-overlay {
        left: 12px !important;
        right: 12px !important;
        transform: none !important;
        max-width: none;
        min-width: 0;
    }
}
