/* ==========================================================================
   Видео на сайте: кнопка «Видео» на фото врача и общее окно видео.
   Разметка окна — inc/video.php, логика — assets/js/theme.js (initVideoDialog).
   ========================================================================== */

/* ---------- Кнопка «Видео» поверх фото ---------- */
.pg-play {
    position: absolute;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    margin: 0;
    padding: 0 14px 0 6px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, .94);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    color: var(--pg-primary, #252871);
    box-shadow: 0 8px 20px -10px rgba(21, 24, 51, .45);
    cursor: pointer;
    transition: background-color .25s ease, color .25s ease, transform .25s ease;
}

.pg-play__ic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    padding-left: 2px;
    border-radius: 50%;
    background: var(--pg-primary, #252871);
    color: #fff;
    transition: background-color .25s ease, color .25s ease;
}

.pg-play:hover,
.pg-play:focus-visible {
    background: var(--pg-primary, #252871);
    color: #fff;
}

.pg-play:hover .pg-play__ic,
.pg-play:focus-visible .pg-play__ic {
    background: #fff;
    color: var(--pg-primary, #252871);
}

.pg-play:focus-visible {
    outline: 2px solid var(--pg-primary, #252871);
    outline-offset: 3px;
}

.pg-play:active {
    transform: scale(.97);
}

/* Карточка врача: справа сверху (бейдж категории — слева снизу) */
.pg-play--card {
    top: 12px;
    right: 12px;
}

/* Страница врача: слева снизу, крупнее */
.pg-play--page {
    left: 16px;
    bottom: 16px;
    height: 44px;
    padding: 0 18px 0 7px;
    font-size: 14px;
}

.pg-play--page .pg-play__ic {
    width: 32px;
    height: 32px;
}

/* Фото на странице врача — контейнер для кнопки */
.member-image.has-video {
    position: relative;
}

.member-image.has-video .img-thumbnail {
    display: block;
}

/* ---------- Окно видео ---------- */
.pg-video-dialog,
.pg-video-dialog *,
.pg-video-dialog *::before,
.pg-video-dialog *::after {
    box-sizing: border-box;
}

.pg-video-dialog {
    --vd-ink: #151833;
    --vd-text: #1c1f3a;
    --vd-muted: #6a6d8a;
    --vd-line: #e9e9ee;
    --vd-soft: #f4f4f7;
    --vd-btn: var(--pg-primary, #252871);
    --vd-btn-hover: var(--pg-primary-dark, #1b1e5a);

    width: min(820px, calc(100vw - 32px));
    max-width: none;
    max-height: calc(100dvh - 32px);
    margin: auto;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 24px;
    background: #fff;
    color: var(--vd-text);
    box-shadow: 0 40px 80px -24px rgba(21, 24, 51, .5);
}

.pg-video-dialog::backdrop {
    background: rgba(21, 24, 51, .6);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.pg-video-dialog[open] {
    animation: pg-vd-pop .35s cubic-bezier(.22, 1, .36, 1);
}

@keyframes pg-vd-pop {
    from {
        opacity: 0;
        transform: translateY(16px) scale(.98);
    }
}

@media (prefers-reduced-motion: reduce) {
    .pg-video-dialog[open] {
        animation: none;
    }
}

html.pg-vd-lock {
    overflow: hidden;
}

.pg-video-dialog__box {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 400px) minmax(0, 1fr);
    max-height: calc(100dvh - 32px);
}

.pg-video-dialog__media {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    padding: 8px;
}

.pg-video-dialog video {
    display: block;
    width: 100%;
    max-height: calc(100dvh - 48px);
    aspect-ratio: 9 / 16;
    border-radius: 16px;
    background: var(--vd-ink);
    object-fit: contain;
}

.pg-video-dialog__info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    min-height: 0;
    padding: 56px 32px 32px 24px;
    overflow-y: auto;
}

.pg-video-dialog__chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 12px 0 10px;
    border-radius: 999px;
    background: var(--vd-soft);
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    color: var(--vd-text);
}

.pg-video-dialog__chip::before {
    content: "";
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #ffd3cf, #c9a3e6 55%, #252871);
}

.pg-video-dialog__title {
    margin: 4px 0 0 !important;
    font-size: clamp(22px, 2.4vw, 28px) !important;
    font-weight: 500 !important;
    line-height: 1.2 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
    color: var(--vd-ink) !important;
}

.pg-video-dialog__sub {
    margin: 0 !important;
    font-size: 15px;
    line-height: 1.45;
    color: var(--vd-muted);
}

.pg-video-dialog__text {
    margin: 4px 0 0 !important;
    font-size: 15px;
    line-height: 1.55;
    color: var(--vd-text);
}

.pg-video-dialog__facts {
    display: grid;
    gap: 8px;
    width: 100%;
    margin: 8px 0 0 !important;
    padding: 0 !important;
    list-style: none;
}

.pg-video-dialog__facts li {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin: 0;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--vd-soft);
    font-size: 14px;
    line-height: 1.3;
}

.pg-video-dialog__facts span {
    color: var(--vd-muted);
}

.pg-video-dialog__facts b {
    font-weight: 600;
    text-align: right;
    color: var(--vd-ink);
}

.pg-video-dialog__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    margin-top: auto;
    padding-top: 16px;
}

.pg-video-dialog__btn {
    display: inline-flex;
    flex: 1 1 140px;
    align-items: center;
    justify-content: center;
    height: 48px;
    margin: 0;
    padding: 0 20px;
    border: 1px solid transparent;
    border-radius: 999px;
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none !important;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .25s ease, border-color .25s ease, color .25s ease;
}

.pg-video-dialog__btn--primary {
    background: var(--vd-btn);
    color: #fff !important;
}

.pg-video-dialog__btn--primary:hover {
    background: var(--vd-btn-hover);
}

.pg-video-dialog__btn--ghost {
    border-color: var(--vd-line);
    background: #fff;
    color: var(--vd-ink) !important;
}

.pg-video-dialog__btn--ghost:hover {
    border-color: var(--vd-btn);
    color: var(--vd-btn) !important;
}

.pg-video-dialog__btn:focus-visible,
.pg-video-dialog__close:focus-visible {
    outline: 2px solid var(--vd-btn);
    outline-offset: 3px;
}

.pg-video-dialog [hidden] {
    display: none !important;
}

.pg-video-dialog__close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--vd-soft);
    color: var(--vd-ink);
    cursor: pointer;
    transition: background-color .25s ease;
}

.pg-video-dialog__close:hover {
    background: var(--vd-line);
}

/* Горизонтальное видео: видео сверху во всю ширину, текст под ним */
.pg-video-dialog.is-wide {
    width: min(960px, calc(100vw - 32px));
}

.pg-video-dialog.is-wide .pg-video-dialog__box {
    grid-template-columns: minmax(0, 1fr);
    overflow-y: auto;
}

.pg-video-dialog.is-wide video {
    aspect-ratio: 16 / 9;
    max-height: calc(100dvh - 240px);
}

.pg-video-dialog.is-wide .pg-video-dialog__info {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 6px 24px;
    padding: 16px 24px 24px;
    overflow: visible;
}

.pg-video-dialog.is-wide .pg-video-dialog__info > * {
    grid-column: 1;
}

.pg-video-dialog.is-wide .pg-video-dialog__chip {
    justify-self: start;
}

.pg-video-dialog.is-wide .pg-video-dialog__actions {
    grid-column: 2;
    grid-row: 1 / span 6;
    align-self: end;
    width: auto;
    padding-top: 0;
}

.pg-video-dialog.is-wide .pg-video-dialog__close {
    background: rgba(255, 255, 255, .92);
}

/* ---------- Телефоны ---------- */
@media (max-width: 767px) {
    .pg-video-dialog,
    .pg-video-dialog.is-wide {
        width: calc(100vw - 16px);
        max-height: calc(100dvh - 16px);
        border-radius: 20px;
    }

    .pg-video-dialog__box,
    .pg-video-dialog.is-wide .pg-video-dialog__box {
        grid-template-columns: minmax(0, 1fr);
        max-height: calc(100dvh - 16px);
        overflow-y: auto;
    }

    .pg-video-dialog video {
        width: auto;
        max-width: 100%;
        max-height: 62dvh;
        margin: 0 auto;
    }

    .pg-video-dialog.is-wide video {
        width: 100%;
        max-height: 50dvh;
    }

    .pg-video-dialog__info,
    .pg-video-dialog.is-wide .pg-video-dialog__info {
        display: flex;
        padding: 8px 16px 16px;
        overflow: visible;
    }

    /* Кнопки записи всегда под рукой — прилипают к низу окна */
    .pg-video-dialog__actions,
    .pg-video-dialog.is-wide .pg-video-dialog__actions {
        position: sticky;
        bottom: 0;
        z-index: 1;
        width: calc(100% + 32px);
        margin: 0 -16px -16px;
        padding: 12px 16px 16px;
        background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #fff 24%);
    }

    .pg-video-dialog__facts li {
        padding: 10px 14px;
    }

    .pg-video-dialog__close {
        top: 16px;
        right: 16px;
        background: rgba(255, 255, 255, .92);
    }

    .pg-play--page {
        left: 12px;
        bottom: 12px;
    }
}
