/* =========================================================================
   abc.stories — нативный сторис-виджет (замена GetReview).
   Префикс .abc-stories-* во избежание конфликтов с Aspro Max / Jivo.
   Переменные задаются инлайном из настроек модуля (см. widget.js).
   ========================================================================= */

.abc-stories-root,
.abc-stories-root * {
    box-sizing: border-box;
}

/* ---------- Плавающий кружок (bubble) ---------- */
.abc-stories-bubble {
    position: fixed;
    z-index: var(--abc-st-z, 9999999);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    line-height: 20px;
    text-align: left;
    width: var(--abc-st-w, 130px);
    /* позиция выставляется модификаторами ниже */
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* позиции */
.abc-stories-bubble.pos-bottom-left  { left: var(--abc-st-x, 50px);  bottom: calc(var(--abc-st-y, 50px) + env(safe-area-inset-bottom, 0px)); }
.abc-stories-bubble.pos-bottom-right { right: var(--abc-st-x, 50px); bottom: calc(var(--abc-st-y, 50px) + env(safe-area-inset-bottom, 0px)); }
.abc-stories-bubble.pos-bottom-center{ left: 50%; transform: translateX(-50%); bottom: calc(var(--abc-st-y, 50px) + env(safe-area-inset-bottom, 0px)); }
.abc-stories-bubble.pos-top-left     { left: var(--abc-st-x, 50px);  top: calc(var(--abc-st-y, 50px) + env(safe-area-inset-top, 0px)); }
.abc-stories-bubble.pos-top-right    { right: var(--abc-st-x, 50px); top: calc(var(--abc-st-y, 50px) + env(safe-area-inset-top, 0px)); }

/* карточка-превью (соотношение 130:180 как в GetReview) */
.abc-stories-card {
    position: relative;
    cursor: pointer;
    width: 100%;
}
.abc-stories-card::before {
    content: "";
    display: block;
    padding-top: var(--abc-st-ar, 138.4615%); /* высота/ширина из настроек */
}

.abc-stories-frame {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: var(--abc-st-radius, 20px);
    background: rgba(0, 0, 0, 0.3);
    border: var(--abc-st-bw, 3px) solid var(--abc-st-border, #fff);
    box-shadow: var(--abc-st-shadow, 0 5px 15px rgba(0, 0, 0, 0.2));
    transition: transform 0.2s ease, border-color 0.3s ease;
    transform-origin: left bottom;
    will-change: transform;
}
.abc-stories-card:hover .abc-stories-frame {
    transform: scale(1.05);
    border-color: var(--abc-st-border-hover, #ff0004);
}
.abc-stories-bubble.no-border .abc-stories-frame { border-width: 0; }
.abc-stories-bubble.is-draggable .abc-stories-card { cursor: grab; }

/* кнопка плей по центру кружка (если включена) */
.abc-stories-play {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 6;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    display: flex; align-items: center; justify-content: center;
    pointer-events: none;
}
.abc-stories-play svg { width: 22px; height: 22px; }

.abc-stories-frame video,
.abc-stories-frame .abc-stories-poster {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
.abc-stories-frame video {
    opacity: 0;
    transition: opacity 0.5s ease;
}
.abc-stories-frame video.is-ready { opacity: 1; }

/* градиенты сверху/снизу */
.abc-stories-frame .grad-top,
.abc-stories-frame .grad-bottom {
    position: absolute;
    left: 0; right: 0;
    z-index: 3;
    pointer-events: none;
}
.abc-stories-frame .grad-top {
    top: -1px; height: 100px;
    background: linear-gradient(180deg, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0) 100%);
}
.abc-stories-frame .grad-bottom {
    bottom: -1px; height: 60px;
    background: linear-gradient(0deg, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0) 100%);
}

/* заголовок поверх кружка */
.abc-stories-frame .abc-stories-card-title {
    position: absolute;
    top: 14px; left: 16px; right: 28px;
    z-index: 5;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-align: var(--abc-st-title-align, left);
    text-shadow: 0 1px 4px rgba(0,0,0,0.4);
    line-height: 1.2;
    max-height: 2.4em;
    overflow: hidden;
}

/* крестик закрытия превью (цвета из настроек GetReview) */
.abc-stories-card-close {
    position: absolute;
    top: 8px; right: 8px;
    width: 22px; height: 22px;
    z-index: 10;
    cursor: pointer;
    border-radius: 22px;
    background: var(--abc-st-close-bg, rgba(0, 0, 0, 0.3));
    opacity: 0;
    transition: opacity 0.3s ease-out, background-color 0.2s ease-out;
    display: flex; align-items: center; justify-content: center;
}
.abc-stories-card:hover .abc-stories-card-close { opacity: 1; }
.abc-stories-card-close:hover { filter: brightness(1.3); }
.abc-stories-card-close svg { width: 22px; height: 22px; display: block; color: var(--abc-st-close-icon, #fff); }

/* подпись под кружком */
.abc-stories-bubble .abc-stories-label {
    margin-top: 6px;
    text-align: center;
    font-size: 12px;
    color: rgba(0,0,0,0.6);
}

/* появление */
.abc-stories-bubble {
    animation: abcStFadeIn 0.4s ease-out both;
}
@keyframes abcStFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Полноэкранный плеер ---------- */
.abc-stories-player {
    position: fixed;
    inset: 0;
    z-index: calc(var(--abc-st-z, 9999999) + 1);
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.abc-stories-player.is-open { opacity: 1; visibility: visible; }

.abc-stories-stage {
    position: relative;
    width: 100%;
    max-width: 420px;
    height: 100%;
    max-height: 92vh;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
@media (max-width: 568px) {
    .abc-stories-stage { max-width: 100%; max-height: 100%; border-radius: 0; }
}

.abc-stories-stage video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* прогресс-бары сверху */
.abc-stories-progress {
    position: absolute;
    top: 10px; left: 10px; right: 10px;
    z-index: 20;
    display: flex;
    gap: 4px;
}
.abc-stories-progress .seg {
    flex: 1;
    height: 3px;
    border-radius: 3px;
    background: rgba(255,255,255,0.35);
    overflow: hidden;
}
.abc-stories-progress .seg > i {
    display: block;
    height: 100%;
    width: 0;
    background: #fff;
    border-radius: 3px;
}
.abc-stories-progress .seg.done > i { width: 100%; }

/* верхний градиент + заголовок плеера */
.abc-stories-stage .stage-top {
    position: absolute; top: 0; left: 0; right: 0; height: 120px; z-index: 15;
    background: linear-gradient(180deg, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0) 100%);
    pointer-events: none;
}
.abc-stories-stage .stage-title {
    position: absolute; top: 26px; left: 16px; right: 52px; z-index: 18;
    color: #fff; font-size: 15px; font-weight: 600; text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* кнопки управления (вертикальный стек справа, как в GetReview) */
.abc-stories-close,
.abc-stories-mute {
    position: absolute;
    z-index: 25;
    width: 36px; height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,0.35);
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.abc-stories-close { top: 16px; right: 14px; }
.abc-stories-mute  { top: 60px; right: 14px; }
.abc-stories-close:hover, .abc-stories-mute:hover { background: rgba(0,0,0,0.55); }
.abc-stories-close svg, .abc-stories-mute svg { width: 20px; height: 20px; }

/* счётчик времени */
.abc-stories-time {
    position: absolute;
    top: 24px; right: 60px;
    z-index: 24;
    color: #fff;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
    pointer-events: none;
}

/* режим «скрыть контролы» */
.abc-stories-player.no-controls .abc-stories-mute,
.abc-stories-player.no-controls .abc-stories-time,
.abc-stories-player.no-controls .abc-stories-progress { display: none; }

/* зоны тапа (назад/вперёд) */
.abc-stories-nav {
    position: absolute;
    top: 0; bottom: 0;
    width: 34%;
    z-index: 12;
    cursor: pointer;
}
.abc-stories-nav.prev { left: 0; }
.abc-stories-nav.next { right: 0; }

/* CTA-кнопка (цвет/радиус/стиль из настроек GetReview) */
.abc-stories-cta {
    position: absolute;
    left: 16px; right: 16px;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    z-index: 22;
    display: block;
    text-align: center;
    text-decoration: none;
    padding: 13px 18px;
    border-radius: var(--abc-st-cta-radius, 30px);
    background: var(--abc-st-cta-bg, #ff0004);
    color: var(--abc-st-cta-color, #fff);
    font-size: 15px;
    font-weight: var(--abc-st-cta-weight, 400);
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
    transition: filter 0.2s ease, transform 0.1s ease;
    animation: abcStCtaIn 0.25s ease-out both;
}
@keyframes abcStCtaIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.abc-stories-cta:hover { filter: brightness(1.07); }
.abc-stories-cta:active { transform: translateY(1px); }

.abc-stories-player[hidden] { display: none; }
.abc-stories-root[hidden] { display: none; }

/* ======================================================================
 * Инлайн-режим (компонент abc:stories.widget) — лента-«истории»
 * ====================================================================== */
.abc-stories-inline-strip{
    display:flex;
    gap:16px;
    overflow-x:auto;
    padding:4px 2px 10px;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:none;
}
.abc-stories-inline-strip::-webkit-scrollbar{ display:none; }
.abc-stories-inline-item{
    flex:0 0 auto;
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:8px;
    width:84px;
    padding:0;
    border:0;
    background:none;
    cursor:pointer;
    font:inherit;
    color:inherit;
}
.abc-stories-inline-ring{
    display:block;
    width:84px;
    height:84px;
    border-radius:50%;
    padding:3px;
    background:linear-gradient(135deg,#FF0004,#ff7a00);
    box-sizing:border-box;
    transition:transform .15s ease;
}
.abc-stories-inline-item:hover .abc-stories-inline-ring,
.abc-stories-inline-item:focus-visible .abc-stories-inline-ring{ transform:scale(1.06); }
.abc-stories-inline-media{
    display:block;
    width:100%;
    height:100%;
    border-radius:50%;
    overflow:hidden;
    background:#eee #fff;
    border:2px solid #fff;
    box-sizing:border-box;
}
.abc-stories-inline-media img,
.abc-stories-inline-media video{
    width:100%;
    height:100%;
    object-fit:cover;
    display:block;
}
.abc-stories-inline-cap{
    max-width:84px;
    font-size:12px;
    line-height:1.2;
    text-align:center;
    color:#333;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}
