/*
 * Модальное окно «Лицензии и компоненты» (0.241.16, вид — 0.241.17).
 *
 * Общий модуль для сайта (public.php, rcc.php, rcc_home.php) и админки (admin.php):
 * подключается последним, поэтому опирается только на базовые токены и fallback-значения.
 * Сайт задаёт --c-*, админка — --a-*; берём первый доступный, иначе — литерал.
 *
 * Цветовой код группы и лицензии — переменные --lic-tone / --lic-tone-soft (.lic-tone--*).
 */

/* ---------- палитра ---------- */

.lic-tone--blue { --lic-tone: #1f5aa8; --lic-tone-soft: #eaf2fb; }
.lic-tone--teal { --lic-tone: #1e7f8c; --lic-tone-soft: #e6f4f5; }
.lic-tone--green { --lic-tone: #3f8a6f; --lic-tone-soft: #e9f5ef; }
.lic-tone--violet { --lic-tone: #6d5ca0; --lic-tone-soft: #efedf8; }
.lic-tone--rose { --lic-tone: #a9557a; --lic-tone-soft: #faedf2; }
.lic-tone--sand { --lic-tone: #a9793f; --lic-tone-soft: #f9f2e7; }
.lic-tone--slate { --lic-tone: #55677d; --lic-tone-soft: #eef2f6; }

/* ---------- каркас окна ---------- */

.lic-modal {
    position: fixed;
    inset: 0;
    z-index: 130;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
}

.lic-modal.is-open { display: flex; }

.lic-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 25, 45, .58);
    backdrop-filter: blur(3px);
}

.lic-modal__box {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 960px;
    max-width: 100%;
    max-height: min(88vh, 920px);
    background: var(--c-white, var(--a-surface, #fff));
    border-radius: 16px;
    box-shadow: 0 30px 80px rgba(10, 25, 45, .42), 0 2px 8px rgba(10, 25, 45, .18);
    overflow: hidden;
}

.lic-modal.is-open .lic-modal__box { animation: lic-in .18s ease-out both; }

@keyframes lic-in {
    from { opacity: 0; transform: translateY(10px) scale(.985); }
    to { opacity: 1; transform: none; }
}

/* ---------- шапка ---------- */

.lic-modal__head {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-4, 16px);
    flex: 0 0 auto;
    padding: 20px 22px;
    color: #fff;
    background:
        radial-gradient(120% 150% at 88% -30%, rgba(30, 127, 140, .55) 0%, rgba(30, 127, 140, 0) 58%),
        linear-gradient(120deg, #0b3d67 0%, #14548b 58%, #1b6f86 100%);
}

/* Тонкая сетка в шапке: глубина без картинок и внешних запросов. */
.lic-modal__head::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px);
    background-size: 22px 22px;
    -webkit-mask-image: linear-gradient(90deg, rgba(0, 0, 0, .9), transparent 78%);
    mask-image: linear-gradient(90deg, rgba(0, 0, 0, .9), transparent 78%);
    pointer-events: none;
}

.lic-modal__badge {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    border-radius: 13px;
    background: rgba(255, 255, 255, .16);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28), 0 6px 18px rgba(4, 20, 36, .28);
    color: #fff;
}

.lic-modal__badge .ic { width: 24px; height: 24px; }

.lic-modal__titles { position: relative; z-index: 1; min-width: 0; }

.lic-modal__title {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.22;
    letter-spacing: -.01em;
    color: #fff;
}

.lic-modal__sub {
    margin: 3px 0 0;
    font-size: .875rem;
    line-height: 1.35;
    color: rgba(255, 255, 255, .84);
}

.lic-modal__count {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    height: 28px;
    margin-left: auto;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .14);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22);
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .02em;
    color: #fff;
    white-space: nowrap;
}

.lic-modal__x {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    cursor: pointer;
    transition: background .15s ease, transform .15s ease;
}

.lic-modal__x svg { width: 20px; height: 20px; }

.lic-modal__x:hover { background: rgba(255, 255, 255, .26); transform: rotate(90deg); }

.lic-modal__x:focus-visible,
.lic-modal__foot .lic-btn:focus-visible,
.lic-card__link:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- содержимое ---------- */

.lic-modal__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 20px 22px 10px;
    background:
        radial-gradient(90% 60% at 100% 0%, rgba(31, 90, 168, .06), rgba(31, 90, 168, 0) 60%),
        var(--c-blue-50, #f6f9fc);
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #c3d2e2 transparent;
}

.lic-modal__body::-webkit-scrollbar { width: 10px; }
.lic-modal__body::-webkit-scrollbar-thumb {
    background: #c3d2e2;
    border: 3px solid transparent;
    border-radius: 999px;
    background-clip: content-box;
}
.lic-modal__body::-webkit-scrollbar-thumb:hover { background: #a9bdd3; background-clip: content-box; }

.lic-group { scroll-margin-top: 8px; }
.lic-group + .lic-group { margin-top: 26px; }

.lic-group__head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lic-group__bar {
    flex: 0 0 auto;
    width: 4px;
    height: 18px;
    border-radius: 999px;
    background: var(--lic-tone, #55677d);
}

.lic-group__title {
    margin: 0;
    font-size: .8125rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--lic-tone, #0d4573);
}

.lic-group__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--lic-tone-soft, #eef2f6);
    color: var(--lic-tone, #55677d);
    font-size: .6875rem;
    font-weight: 700;
}

.lic-group__note {
    margin: 6px 0 14px;
    padding-left: 14px;
    font-size: .8125rem;
    line-height: 1.45;
    color: var(--c-muted, var(--a-muted, #5b6d80));
}

.lic-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Одна карточка в группе (ядро CMS, mPDF) — на всю ширину: пустая ячейка справа выглядит провалом. */
.lic-list > .lic-card:only-child { grid-column: 1 / -1; }

.lic-card {
    display: flex;
    align-items: flex-start;
    gap: 13px;
    padding: 15px;
    background: var(--c-white, var(--a-surface, #fff));
    border: 1px solid var(--c-border, var(--a-border, #e3ebf2));
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(13, 69, 115, .05);
    transition: box-shadow .16s ease, transform .16s ease, border-color .16s ease;
}

.lic-card:hover {
    transform: translateY(-1px);
    border-color: var(--lic-tone-soft, #e3ebf2);
    box-shadow: 0 10px 24px rgba(13, 69, 115, .12);
}

.lic-card__mark {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: var(--lic-tone-soft, #eef2f6);
    color: var(--lic-tone, #1f5aa8);
    font-size: .8125rem;
    font-weight: 700;
    letter-spacing: -.02em;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .7);
}

.lic-card__main { min-width: 0; flex: 1 1 auto; }

.lic-card__top {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px;
}

.lic-card__name {
    font-size: .9375rem;
    line-height: 1.3;
    color: var(--c-dark, var(--a-text, #15293d));
}

.lic-card__ver {
    font-size: .75rem;
    color: var(--c-muted, var(--a-faint, #5b6d80));
}

.lic-card__use {
    margin: 5px 0 9px;
    font-size: .8125rem;
    line-height: 1.46;
    color: var(--c-text, var(--a-text, #2c3e50));
}

.lic-card__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 10px;
    font-size: .75rem;
    color: var(--c-muted, var(--a-muted, #5b6d80));
}

.lic-card__holder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.lic-chip {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    background: #eef2f6;
    color: #55677d;
    font-size: .6875rem;
    font-weight: 600;
    letter-spacing: .02em;
    white-space: nowrap;
}

.lic-chip--permissive { background: #e9f5ef; color: #2f7859; }
.lic-chip--apache { background: #eaf2fb; color: #1f5aa8; }
.lic-chip--gpl { background: #f9f2e7; color: #8f6425; }
.lic-chip--lgpl { background: #efedf8; color: #5d4c8f; }
.lic-chip--proprietary { background: #eef2f6; color: #4c5e73; }
.lic-chip--service { background: #eaf5f6; color: #1e6f7c; }

.lic-card__link {
    color: var(--c-blue-600, var(--a-accent, #15598f));
    text-decoration: none;
    border-bottom: 1px solid rgba(21, 89, 143, .35);
    white-space: nowrap;
}

.lic-card__link::after { content: " ↗"; font-size: .9em; }

.lic-card__link:hover {
    color: var(--c-blue, #0d4573);
    border-bottom-color: currentColor;
}

.lic-modal__legal {
    margin: 24px 0 14px;
    padding: 14px 16px;
    border-left: 3px solid var(--c-blue-600, var(--a-accent, #15598f));
    border-radius: 0 10px 10px 0;
    background: var(--c-white, #fff);
    box-shadow: inset 0 0 0 1px rgba(13, 69, 115, .06);
    font-size: .8125rem;
    line-height: 1.5;
    color: var(--c-text, var(--a-text, #2c3e50));
}

/* ---------- подвал окна ---------- */

.lic-modal__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex: 0 0 auto;
    padding: 14px 22px;
    border-top: 1px solid var(--c-border, var(--a-border, #e3ebf2));
    background: var(--c-white, var(--a-surface, #fff));
    box-shadow: 0 -6px 18px rgba(13, 69, 115, .05);
}

.lic-modal__ver {
    font-size: .75rem;
    line-height: 1.4;
    color: var(--c-muted, var(--a-muted, #5b6d80));
}

.lic-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 20px;
    border: 0;
    border-radius: 9px;
    background: linear-gradient(180deg, #1f5aa8, #17406d);
    color: #fff;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(23, 64, 109, .28);
    transition: filter .15s ease, box-shadow .15s ease;
}

.lic-btn:hover { filter: brightness(1.08); box-shadow: 0 6px 16px rgba(23, 64, 109, .34); }
.lic-btn:active { filter: brightness(.96); }

/* ---------- адаптив, движение, печать ---------- */

@media (max-width: 760px) {
    .lic-modal { padding: 12px; }
    .lic-modal__box { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); border-radius: 14px; }
    .lic-modal__head { padding: 14px 16px; gap: 12px; }
    .lic-modal__badge { width: 40px; height: 40px; border-radius: 11px; }
    .lic-modal__title { font-size: 1.1rem; }
    .lic-modal__sub { font-size: .8125rem; }
    .lic-modal__count { display: none; }
    .lic-modal__body { padding: 16px 16px 6px; }
    .lic-list { grid-template-columns: minmax(0, 1fr); }
    .lic-group__note { padding-left: 12px; }
    .lic-modal__foot { flex-direction: column; align-items: stretch; padding: 12px 16px; }
    .lic-modal__ver { text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
    .lic-modal.is-open .lic-modal__box { animation: none; }
    .lic-modal__x,
    .lic-card,
    .lic-btn { transition: none; }
    .lic-modal__x:hover { transform: none; }
    .lic-card:hover { transform: none; }
}

@media print {
    .lic-modal { display: none !important; }
}

/* Блокировка прокрутки страницы под окном (класс общий с модалкой объявлений). */
html.is-modal-open,
html.is-modal-open body { overflow: hidden; }
