/* NeuroGuide — пошаговая инструкция по сервису (как онбординг в мобильных приложениях).
   Подключается вместе с assets/js/neuroguide.js. Цвета — фирменные из kadry.css. */

:root {
    --ng-gradient: linear-gradient(135deg, #FF4B5C 0%, #9B4DFF 100%);
    --ng-violet: #7B3FE4;
    --ng-text: #1F1D2B;
    --ng-muted: #6B6880;
    --ng-shade: rgba(23, 14, 41, .62);
}

/* ---------- Кнопка «Инструкция» ---------- */
.ng-launch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px 8px 10px;
    border: 1px solid #E3D7FB;
    border-radius: 999px;
    background: #fff;
    color: var(--ng-violet);
    font: 600 14px/1 "Inter", "Calibri", Arial, sans-serif;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(123, 63, 228, .12);
    transition: box-shadow .2s, transform .2s;
    white-space: nowrap;
}
.ng-launch:hover { box-shadow: 0 4px 16px rgba(123, 63, 228, .25); transform: translateY(-1px); }
.ng-launch:focus-visible { outline: 3px solid rgba(155, 77, 255, .45); outline-offset: 2px; }
.ng-launch-ico {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--ng-gradient); color: #fff; font-size: 14px; font-weight: 700;
}
/* Пока пользователь ни разу не открыл инструкцию этого сервиса — кнопка мягко пульсирует */
.ng-launch.ng-new { animation: ng-pulse 2s ease-out 3; }
@keyframes ng-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(155, 77, 255, .5); }
    100% { box-shadow: 0 0 0 14px rgba(155, 77, 255, 0); }
}

/* «Видеоинструкция» — заливка градиентом, «Как пользоваться» — белая */
.ng-launch-video { background: var(--ng-gradient); border-color: transparent; color: #fff; }
.ng-launch-video .ng-launch-ico { background: rgba(255, 255, 255, .25); }

/* Место кнопок: под заголовком и описанием сервиса */
.ng-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 4px; }
.ng-actions-center { justify-content: center; margin: 22px 0 0; }
/* Запасной вариант, если заголовка нет: плавающие кнопки */
.ng-actions.ng-float { position: fixed; right: 20px; bottom: 20px; z-index: 900; margin: 0; }

/* ---------- Окно видео ---------- */
.ng-noscroll, .ng-noscroll body { overflow: hidden !important; }
.ng-video {
    position: fixed; inset: 0; z-index: 2147483100;
    display: flex; align-items: center; justify-content: center;
    padding: 16px; background: var(--ng-shade);
    animation: ng-fade .2s ease-out;
}
@keyframes ng-fade { from { opacity: 0; } to { opacity: 1; } }
.ng-video-box {
    position: relative;
    /* ширина подстраивается и под ширину, и под высоту экрана: видео 16:9 + шапка и низ окна всегда помещаются */
    width: 960px; max-width: 100%;
    width: min(960px, 100%, calc((100vh - 150px) * 16 / 9));
    background: #fff; border-radius: 16px; overflow: hidden;
    box-shadow: 0 18px 50px rgba(23, 14, 41, .35);
    font: 400 15px/1.4 "Inter", "Calibri", Arial, sans-serif; color: var(--ng-text);
}
.ng-video-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 10px 10px 20px; border-bottom: 1px solid #F0ECF7; }
.ng-video-title { font-weight: 700; font-size: 15px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ng-video-head .ng-close { position: static; flex: none; }
/* 16:9 через padding — работает во всех браузерах, включая старые сборки */
.ng-video-frame { position: relative; height: 0; padding-top: 56.25%; background: #000; overflow: hidden; }
.ng-video-frame iframe { position: absolute !important; top: 0; left: 0; width: 100% !important; height: 100% !important; max-height: none !important; border: 0; margin: 0; }
.ng-video-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px; border-top: 1px solid #F0ECF7; }
.ng-video-foot a { color: var(--ng-violet); font-weight: 600; }

/* ---------- Затемнение и подсветка ---------- */
.ng-root { position: fixed; inset: 0; z-index: 2147483000; pointer-events: none; }
/* Затемнение не ловит клики: подсвеченный элемент остаётся живым (его можно нажать, раскрыть, заполнить),
   а клики по остальной странице отсекает neuroguide.js */
.ng-catcher { position: fixed; inset: 0; pointer-events: none; background: transparent; }
.ng-catcher.ng-dim { background: var(--ng-shade); }
.ng-spot {
    position: fixed;
    border-radius: 12px;
    box-shadow: 0 0 0 9999px var(--ng-shade), 0 0 0 3px #fff, 0 0 0 7px rgba(155, 77, 255, .55);
    transition: top .3s ease, left .3s ease, width .3s ease, height .3s ease;
    pointer-events: none;
}

/* ---------- Карточка шага ---------- */
.ng-card {
    position: fixed;
    width: 380px;
    max-width: calc(100vw - 24px);
    background: #fff;
    color: var(--ng-text);
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(23, 14, 41, .35);
    padding: 20px 20px 16px;
    pointer-events: auto;
    font: 400 15px/1.5 "Inter", "Calibri", Arial, sans-serif;
    transition: top .3s ease, left .3s ease, opacity .2s;
}
.ng-card.ng-center { top: 50% !important; left: 50% !important; transform: translate(-50%, -50%); }
.ng-card::before { /* стрелка к подсвеченному элементу */
    content: ""; position: absolute; width: 14px; height: 14px; background: #fff;
    transform: rotate(45deg); display: none;
}
.ng-card[data-side="bottom"]::before { display: block; top: -7px;  left: var(--ng-arrow, 30px); }
.ng-card[data-side="top"]::before    { display: block; bottom: -7px; left: var(--ng-arrow, 30px); }
.ng-card[data-side="right"]::before  { display: block; left: -7px;  top: var(--ng-arrow, 24px); }
.ng-card[data-side="left"]::before   { display: block; right: -7px; top: var(--ng-arrow, 24px); }

.ng-step-no {
    display: inline-block; margin-bottom: 8px; padding: 3px 10px; border-radius: 999px;
    background: #F3ECFF; color: var(--ng-violet); font-size: 12px; font-weight: 600;
}
.ng-badge-later {
    display: inline-block; margin: 0 0 8px 6px; padding: 3px 10px; border-radius: 999px;
    background: #FFF1E6; color: #B4540A; font-size: 12px; font-weight: 600;
}
.ng-title { margin: 0 0 6px; font-size: 17px; font-weight: 700; line-height: 1.3; }
.ng-text { margin: 0; color: #3D3A4F; }
.ng-text b { color: var(--ng-text); }
.ng-text ul { margin: 6px 0 0; padding-left: 18px; }
.ng-close {
    position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border: 0; border-radius: 50%;
    background: transparent; color: var(--ng-muted); font-size: 22px; line-height: 1; cursor: pointer;
}
.ng-close:hover { background: #F4F2F8; }

.ng-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; }
.ng-dots { display: flex; flex-wrap: wrap; gap: 4px; max-width: 190px; }
.ng-dot { width: 6px; height: 6px; border-radius: 50%; background: #E2DCEE; border: 0; padding: 0; cursor: pointer; }
.ng-dot.ng-on { background: var(--ng-violet); width: 16px; border-radius: 4px; }
.ng-btns { display: flex; gap: 8px; }
.ng-btn {
    border: 0; border-radius: 10px; padding: 9px 16px; cursor: pointer;
    font: 600 14px/1 "Inter", "Calibri", Arial, sans-serif;
}
.ng-btn-back { background: #F4F2F8; color: var(--ng-text); }
.ng-btn-next { background: var(--ng-gradient); color: #fff; }
.ng-btn:hover { filter: brightness(.96); }
.ng-btn:focus-visible, .ng-dot:focus-visible, .ng-close:focus-visible { outline: 3px solid rgba(155, 77, 255, .45); outline-offset: 2px; }

@media (max-width: 560px) {
    /* На телефоне карточка всегда прижата к низу экрана, как шторка */
    .ng-card, .ng-card.ng-center {
        top: auto !important; left: 12px !important; right: 12px; bottom: 12px;
        width: auto; transform: none;
    }
    .ng-card::before { display: none !important; }
}

.ng-noanim .ng-spot, .ng-noanim .ng-card { transition: none; }

@media (prefers-reduced-motion: reduce) {
    .ng-spot, .ng-card, .ng-launch { transition: none; animation: none; }
}

/* Пока открыты подсказки или видео — прячем плавающие виджеты (кнопка чата Битрикс24 и т. п.),
   чтобы они не перекрывали карточку и кнопку «Далее» */
.ng-busy .b24-widget-button-wrapper,
.ng-busy .b24-widget-button-shadow { visibility: hidden !important; }

/* ---------- Блок «Рекомендации по теме» (assets/js/kadry-recs.js) ---------- */
.kr-block { margin: 32px 0 8px; font-family: "Inter", "Calibri", Arial, sans-serif; }
.kr-headrow { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 14px; }
.kr-head { margin: 0 !important; font-size: 20px; font-weight: 700; color: var(--ng-text); }
.kr-src { color: var(--ng-muted); font-size: 14px; }
.kr-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.kr-card {
    display: flex; flex-direction: column; gap: 8px; min-height: 136px;
    padding: 16px 18px; background: #fff; border: 1px solid #ECE7F5; border-radius: 14px;
    color: var(--ng-text) !important; text-decoration: none !important;
    box-shadow: 0 1px 3px rgba(31, 29, 43, .04);
    transition: box-shadow .2s, transform .2s, border-color .2s;
}
.kr-card:hover { border-color: #D9C8FA; box-shadow: 0 6px 18px rgba(123, 63, 228, .14); transform: translateY(-2px); }
.kr-card:focus-visible { outline: 3px solid rgba(155, 77, 255, .45); outline-offset: 2px; }
.kr-type {
    align-self: flex-start; padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600; line-height: 1.4;
    background: #F3ECFF; color: var(--ng-violet);
}
.kr-qa .kr-type { background: #FFECEF; color: #D23452; }
.kr-form .kr-type { background: #E8F7EF; color: #1B8A55; }
.kr-law .kr-type { background: #EEF2F7; color: #44546A; }
.kr-video .kr-type { background: #FFF3E3; color: #B4540A; }
.kr-title { flex: 1; font-size: 15px; font-weight: 600; line-height: 1.4; }
.kr-go { font-size: 13px; font-weight: 600; color: var(--ng-violet); }
@media (max-width: 1100px) { .kr-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .kr-grid { grid-template-columns: 1fr; } .kr-card { min-height: 0; } }
