/* ================================================
   Popup Banner v1.6.1 — Стили фронтенда
   ================================================ */

:root {
    --pb-max-width: 640px;
    --pb-gutter: 16px;
    --pb-gutter-sm: 12px;
    --pb-text-fade: 0.75rem;
}

/* ---------- Общая база ---------- */
.pb-overlay {
    position: fixed;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.pb-overlay.pb-visible { opacity: 1; visibility: visible; }

/* ---------- Модальное окно ---------- */
.pb-overlay.pb-mode-modal {
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
.pb-mode-modal .pb-box {
    transform: scale(0.88) translateY(20px);
    transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1);
    width: 100%;
    max-width: min(var(--pb-max-width), calc(100% - var(--pb-gutter) * 2));
    box-sizing: border-box;
}
.pb-mode-modal.pb-visible .pb-box { transform: scale(1) translateY(0); }

/* ---------- Панель снизу ---------- */
.pb-overlay.pb-mode-slidein {
    inset: auto 0 0 0;
    display: block;
    background: transparent;
}
.pb-mode-slidein .pb-box {
    transform: translateY(110%);
    transition: transform 0.42s cubic-bezier(0.22,1,0.36,1);
    width: 100%;
    max-width: min(var(--pb-max-width), calc(100% - var(--pb-gutter) * 2));
    margin: 0 auto var(--pb-gutter);
    box-sizing: border-box;
    box-shadow: 0 -4px 32px rgba(0,0,0,0.14), 0 8px 24px rgba(0,0,0,0.1);
    border-radius: 16px 16px 12px 12px;
}
.pb-mode-slidein.pb-visible .pb-box { transform: translateY(0); }

/* ---------- Блок попапа ---------- */
.pb-box {
    position: relative;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.22), 0 4px 16px rgba(0,0,0,0.1);
    padding: 0;
    overflow: hidden;
    box-sizing: border-box;
    max-width: 100%;
}

/* ---------- Контент ---------- */
.pb-banner-content {
    padding: 20px 20px 0;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}
.pb-banner-content img,
.pb-banner-content video,
.pb-banner-content iframe,
.pb-banner-content svg {
    max-width: 100%;
    height: auto;
}
.pb-banner-content table {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
}
.pb-banner-content .DistributionPopup { display:flex;flex-direction:column;gap:10px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif; }
.pb-banner-content .DistributionInfo  { display:flex;align-items:center;gap:12px; }
.pb-banner-content .DistributionIcon  { width:48px;height:48px;border-radius:12px;background-size:cover;background-position:center;flex-shrink:0; }
.pb-banner-content .DistributionIcon_skin_dark { display:none; }
.pb-banner-content .DistributionTitle { font-size:18px;font-weight:700;color:#1a1a1a;line-height:1.3; }
.pb-banner-content .DistributionDescription { font-size:14px;color:#555;line-height:1.5;padding-bottom:4px; }
.pb-banner-content .DistributionActions { display:none !important; }

/* ---------- Кнопки (всегда в одну строку) ---------- */
.pb-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 10px;
    padding: 16px 20px 12px;
    min-width: 0;
}
.pb-btn {
    display: flex;
    align-items: center;
    justify-content: stretch;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 22px;
    line-height: 1.2;
    text-decoration: none;
    transition: opacity .18s ease, transform .15s ease, box-shadow .18s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-sizing: border-box;
    overflow: hidden;
    min-width: 0;
}
.pb-btn:hover  { opacity: .88; transform: translateY(-1px); }
.pb-btn:active { transform: translateY(0); opacity: 1; }
/* Подпись на всю ширину кнопки — затухание у правого края кнопки, а не у конца текста */
.pb-btn-label {
    display: block;
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-align: center;
    -webkit-mask-image: linear-gradient(
        to right,
        #000 0%,
        #000 calc(100% - var(--pb-text-fade)),
        transparent 100%
    );
    mask-image: linear-gradient(
        to right,
        #000 0%,
        #000 calc(100% - var(--pb-text-fade)),
        transparent 100%
    );
}
.pb-btn-close {
    background: #f0f0f0;
    color: #333;
    flex: 0 1 auto;
    min-width: 0;
    max-width: 48%;
}
.pb-btn-close:hover { background: #e4e4e4; opacity: 1; }
.pb-btn-install {
    background: #ff6200;
    color: #ffffff !important;
    flex: 1 1 auto;
    min-width: 0;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.pb-btn-install:hover { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.24); }

/* ---------- Маркировка рекламы (рекламодатель + ERID) ---------- */
.pb-erid { font-size:11px;color:#999;padding:0 20px 14px;text-align:left;line-height:1.4; }

/* ================================================
   ЭФФЕКТЫ НА .pb-box
   Класс pb-fx-{name} вешается через JS после появления окна
   ================================================ */

/* 1. Волна света — диагональный блик как по стеклу */
@keyframes pb-fx-glare {
    0%   { left: -60%; opacity: 0; }
    10%  { opacity: 1; }
    60%  { left: 130%; opacity: .6; }
    61%,100% { left: -60%; opacity: 0; }
}
.pb-box.pb-fx-glare::after {
    content: '';
    position: absolute;
    top: -20px; left: -60%;
    width: 40%; height: 200%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
    transform: rotate(20deg);
    pointer-events: none;
    animation: pb-fx-glare 0.9s ease-in-out forwards;
}

/* 2. Яркая вспышка */
@keyframes pb-fx-flash {
    0%   { opacity: 0; }
    15%  { opacity: .75; }
    100% { opacity: 0; }
}
.pb-box.pb-fx-flash::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,240,0.92);
    pointer-events: none;
    border-radius: inherit;
    animation: pb-fx-flash 0.55s ease-out forwards;
}

/* 3. Пульсация — вдох и выдох */
@keyframes pb-fx-pulse {
    0%   { transform: scale(1) translateY(0); }
    40%  { transform: scale(1.045) translateY(-3px); }
    100% { transform: scale(1) translateY(0); }
}
.pb-mode-modal .pb-box.pb-fx-pulse { animation: pb-fx-pulse 0.65s cubic-bezier(0.34,1.56,0.64,1) forwards; }

/* 4. Лёгкое дрожание */
@keyframes pb-fx-shake {
    0%,100% { transform: translateX(0); }
    15%  { transform: translateX(-7px); }
    30%  { transform: translateX(6px); }
    45%  { transform: translateX(-5px); }
    60%  { transform: translateX(4px); }
    75%  { transform: translateX(-2px); }
    88%  { transform: translateX(1px); }
}
.pb-box.pb-fx-shake { animation: pb-fx-shake 0.7s ease-out forwards; }

/* 5. Свечение краёв */
@keyframes pb-fx-glow {
    0%   { box-shadow: 0 24px 64px rgba(0,0,0,0.22), 0 4px 16px rgba(0,0,0,0.1); }
    45%  { box-shadow: 0 0 0 6px rgba(120,160,255,0.45), 0 0 40px rgba(100,140,255,0.35), 0 24px 64px rgba(0,0,0,0.18); }
    100% { box-shadow: 0 24px 64px rgba(0,0,0,0.22), 0 4px 16px rgba(0,0,0,0.1); }
}
.pb-box.pb-fx-glow { animation: pb-fx-glow 1.1s ease-in-out forwards; }

/* 6. Полоса сканирования */
@keyframes pb-fx-scanline {
    0%   { top: -8px; opacity: 0; }
    5%   { opacity: 1; }
    90%  { opacity: .8; }
    100% { top: 110%; opacity: 0; }
}
.pb-box.pb-fx-scanline::after {
    content: '';
    position: absolute;
    left: 0; top: -8px;
    width: 100%; height: 10px;
    background: linear-gradient(180deg, transparent, rgba(255,255,255,.55), transparent);
    pointer-events: none;
    animation: pb-fx-scanline 0.8s linear forwards;
}

/* 7. Рябь — упругие края при появлении */
@keyframes pb-fx-ripple {
    0%   { border-radius: 16px; }
    18%  { border-radius: 20px 12px 18px 14px; }
    35%  { border-radius: 14px 20px 12px 20px; }
    52%  { border-radius: 18px 14px 20px 12px; }
    68%  { border-radius: 15px 18px 14px 18px; }
    82%  { border-radius: 17px 15px 16px 15px; }
    100% { border-radius: 16px; }
}
.pb-box.pb-fx-ripple { animation: pb-fx-ripple 0.9s ease-out forwards; }

/* ---------- Шорткод (встраивание в контент) ---------- */
.pb-shortcode {
    position: relative;
    display: block;
    margin: 1.5em auto;
    width: 100%;
    max-width: var(--pb-max-width);
    clear: both;
    box-sizing: border-box;
}
.pb-shortcode-container {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #e2e4e7;
    border-radius: 16px;
}
.pb-shortcode .pb-box {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    box-shadow: none;
    transform: none;
    transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
/* Фоновые подложки шаблонов — без наследования скругления от .pb-box */
.pb-shortcode .pb-banner-content .pb-tpl-bg-img,
.pb-shortcode .pb-banner-content .pb-tpl-bg-shade {
    border-radius: 0;
}
.pb-shortcode:not(.pb-shortcode-visible) {
    display: none;
}
.pb-shortcode.pb-shortcode-visible .pb-box {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* ================================================
   Адаптив
   ================================================ */

/* Планшеты и мобильные: на всю ширину экрана, скругление только сверху */
@media (max-width: 768px) {
    :root {
        --pb-gutter: 0;
        --pb-gutter-sm: 0;
    }

    /* Только всплывающий баннер — скругление сверху */
    .pb-overlay .pb-box,
    .pb-mode-modal .pb-box,
    .pb-mode-slidein .pb-box {
        border-radius: 16px 16px 0 0 !important;
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
    }

    .pb-overlay .pb-box.pb-fx-ripple {
        animation: none !important;
    }

    /* Шорткод: прямоугольный блок, без тени и без внутренних скруглений */
    .pb-shortcode-container {
        border-radius: 0;
        border-color: #dcdcde;
        box-shadow: none;
    }
    .pb-shortcode .pb-box {
        border-radius: 0 !important;
        box-shadow: none !important;
    }
    .pb-shortcode .pb-banner-content .pb-tpl-bg-img,
    .pb-shortcode .pb-banner-content .pb-tpl-bg-shade {
        border-radius: 0 !important;
    }

    .pb-mode-modal .pb-box,
    .pb-mode-slidein .pb-box {
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
    }

    .pb-overlay.pb-mode-modal {
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        align-items: stretch;
        padding: 0;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .pb-mode-modal .pb-box {
        margin-bottom: 0;
        align-self: stretch;
    }

    .pb-mode-slidein { inset: auto 0 0 0; }
    .pb-mode-slidein .pb-box {
        margin: 0;
        border-radius: 16px 16px 0 0;
    }

    /* Шорткод: выход на полную ширину viewport внутри контента темы */
    .pb-shortcode {
        width: 100vw;
        max-width: 100vw;
        margin-top: 1.25em;
        margin-bottom: 1.25em;
        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);
        padding: 0;
    }

    .pb-banner-content { padding: 18px 18px 0; }
    .pb-actions { padding: 14px 18px 10px; gap: 8px; }
    .pb-erid { padding: 0 18px 12px; }
    .pb-banner-content .DistributionTitle { font-size: 17px; }
}

/* Смартфоны — уточнение типографики и отступов */
@media (max-width: 520px) {
    :root {
        --pb-text-fade: 0.6rem;
    }
    .pb-banner-content { padding: 16px 16px 0; }
    .pb-banner-content .DistributionTitle { font-size: 16px; }
    .pb-banner-content .DistributionDescription { font-size: 13px; }
    .pb-actions {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 8px;
        padding: 12px 16px 10px;
    }
    .pb-btn {
        padding: 10px 14px;
        font-size: 13px;
    }
    .pb-btn-close {
        padding: 10px 12px;
    }
    .pb-erid {
        text-align: center;
        padding: 0 16px 12px;
        font-size: 10px;
    }
}

/* Очень узкие экраны */
@media (max-width: 360px) {
    :root {
        --pb-text-fade: 0.5rem;
    }
    .pb-banner-content { padding: 14px 14px 0; }
    .pb-actions { padding: 10px 12px 8px; gap: 6px; }
    .pb-btn { font-size: 12px; padding: 9px 10px; }
    .pb-btn-close { padding: 9px 10px; max-width: 44%; }
}
