/*
 * Окно предложения ключа доступа (nb-passkey-offer).
 *
 * Чистый CSS без Bootstrap, Unify и сборки Tailwind: модуль встаёт и на страницы
 * Bootstrap-виджета входа, и на тёмный лендинг Tw-виджета. Цвета — токены --nb-*
 * из src/theme/nb-palette.css; где палитры на странице нет, срабатывают запасные
 * значения тех же токенов светлой темы.
 *
 * Вид — как у шторки «Ещё» нижнего меню (_more_menu_sheet.php): подложка
 * --nb-background-2, белая карточка 22px с мягкой тенью, иконки на круге 44px
 * --nb-surface-1, выезд снизу за 240ms ease-out. Правила неслоёные и под корнем
 * .nb-po: Unify оформляет h2, p, ul и button вне слоёв и иначе перебил бы их.
 */

.nb-po {
    position: fixed;
    inset: 0;
    z-index: 2147483200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    visibility: hidden;
    transition: visibility 0s linear 240ms;
    color: var(--nb-foreground, oklch(26.9% 0.006 133.9));
    font-size: 16px;
    line-height: 1.5;
    text-align: left;
    -webkit-text-size-adjust: 100%;
}

.nb-po[data-open] {
    visibility: visible;
    transition: none;
}

.nb-po *,
.nb-po *::before,
.nb-po *::after {
    box-sizing: border-box;
}

.nb-po-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    opacity: 0;
    transition: opacity 240ms ease-out;
}

.nb-po[data-open] .nb-po-backdrop {
    opacity: 1;
}

/* Телефон: нижняя шторка во всю ширину. Селектор из двух классов: CSS сайта
   держит неслоёное [aria-labelledby] { padding-left: 0 }, а у панели этот атрибут есть */
.nb-po .nb-po-panel {
    position: relative;
    width: 100%;
    max-height: calc(100% - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--nb-background-2, oklch(95.5% 0.004 133.9));
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -8px 32px -12px rgba(15, 23, 42, .28);
    padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 240ms ease-out;
    outline: none;
}

.nb-po[data-open] .nb-po-panel {
    transform: translateY(0);
}

.nb-po-grip {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 20px;
    margin: 0 -20px;
    touch-action: none;
}

.nb-po-handle {
    display: block;
    width: 36px;
    height: 5px;
    border-radius: 999px;
    background: var(--nb-surface-1, oklch(89.7% 0.008 133.9));
}

.nb-po-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.nb-po-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 999px;
    background: var(--nb-primary-50, oklch(97% 0.055 133.9));
    color: var(--nb-primary-700, oklch(54.5% 0.1539 133.9));
}

.nb-po-tile svg {
    display: block;
    width: 28px;
    height: 28px;
}

/* Крестик — как у шторки «Ещё»: цель касания 44px, круг 40px */
.nb-po .nb-po-close {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    margin: 0 -6px 0 0;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--nb-foreground, oklch(26.9% 0.006 133.9));
    cursor: pointer;
}

.nb-po-close-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: var(--nb-surface-1, oklch(89.7% 0.008 133.9));
}

.nb-po-close svg {
    display: block;
    width: 20px;
    height: 20px;
}

.nb-po .nb-po-title {
    margin: 16px 0 0;
    padding: 0;
    font-size: 22px;
    line-height: 28px;
    font-weight: 700;
    letter-spacing: normal;
    text-transform: none;
    color: var(--nb-foreground, oklch(26.9% 0.006 133.9));
}

.nb-po .nb-po-lead {
    margin: 8px 0 0;
    padding: 0;
    font-size: 16px;
    line-height: 24px;
    color: var(--nb-muted-foreground-1, oklch(52.8% 0.016 133.9));
}

/* Карточка пунктов — как группа плиток в шторке «Ещё» */
.nb-po .nb-po-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 16px 0 0;
    padding: 12px 16px;
    list-style: none;
    background: var(--nb-card, #fff);
    border-radius: 22px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .06);
}

.nb-po .nb-po-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    margin: 0;
    padding: 4px 0;
    font-size: 15px;
    line-height: 18px;
    color: var(--nb-foreground, oklch(26.9% 0.006 133.9));
}

.nb-po-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    background: var(--nb-surface-1, oklch(89.7% 0.008 133.9));
    color: var(--nb-primary-700, oklch(54.5% 0.1539 133.9));
}

.nb-po-item-icon svg {
    display: block;
    width: 22px;
    height: 22px;
}

.nb-po-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;
}

.nb-po .nb-po-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 52px;
    margin: 0;
    padding: 14px 20px;
    border: 0;
    border-radius: 12px;
    background: var(--nb-primary, oklch(54.5% 0.1539 133.9));
    color: var(--nb-primary-foreground, #fff);
    font-size: 16px;
    line-height: 20px;
    font-weight: 600;
    text-transform: none;
    box-shadow: 0 8px 20px -8px rgba(15, 23, 42, .35);
    cursor: pointer;
    transition: background-color 150ms ease-out;
}

.nb-po .nb-po-primary:hover {
    background: var(--nb-primary-hover, oklch(45.5% 0.125 133.9));
}

.nb-po .nb-po-primary[disabled] {
    cursor: progress;
    opacity: .75;
}

.nb-po .nb-po-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 10px 16px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--nb-muted-foreground-1, oklch(52.8% 0.016 133.9));
    font-size: 15px;
    line-height: 18px;
    font-weight: 600;
    text-transform: none;
    cursor: pointer;
}

.nb-po .nb-po-secondary:hover {
    color: var(--nb-foreground, oklch(26.9% 0.006 133.9));
}

.nb-po .nb-po-close:focus-visible,
.nb-po .nb-po-primary:focus-visible,
.nb-po .nb-po-secondary:focus-visible {
    outline: 2px solid var(--nb-primary, oklch(54.5% 0.1539 133.9));
    outline-offset: 2px;
}

.nb-po .nb-po-close:focus:not(:focus-visible),
.nb-po .nb-po-primary:focus:not(:focus-visible),
.nb-po .nb-po-secondary:focus:not(:focus-visible),
.nb-po-panel:focus {
    outline: none;
}

.nb-po .nb-po-status {
    margin: 12px 0 0;
    font-size: 14px;
    line-height: 20px;
    color: var(--nb-muted-foreground-1, oklch(52.8% 0.016 133.9));
}

.nb-po .nb-po-status[data-type="error"] {
    color: var(--nb-destructive-1, oklch(57.7% 0.245 27.325));
}

.nb-po .nb-po-status:empty {
    display: none;
}

/* Готово: ключ создан */
.nb-po-done {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px 0 16px;
    text-align: center;
}

.nb-po-done[hidden],
.nb-po-content[hidden] {
    display: none;
}

.nb-po-done-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 999px;
    background: var(--nb-primary, oklch(54.5% 0.1539 133.9));
    color: var(--nb-primary-foreground, #fff);
}

.nb-po-done-mark svg {
    display: block;
    width: 28px;
    height: 28px;
}

.nb-po .nb-po-done-text {
    margin: 0;
    font-size: 18px;
    line-height: 24px;
    font-weight: 700;
    color: var(--nb-foreground, oklch(26.9% 0.006 133.9));
}

/* Десктоп и планшет: окно 440px по центру. «Ещё» на широком экране не показывается,
   поэтому скругление и тень — от её карточек и формы из STYLE_REFERENCE */
@media (min-width: 768px) {
    .nb-po {
        align-items: center;
        padding: 24px;
    }

    .nb-po .nb-po-panel {
        width: 440px;
        max-width: 100%;
        max-height: calc(100% - 48px);
        border-radius: 22px;
        box-shadow: 0 24px 48px -28px rgba(15, 23, 42, .28);
        padding: 24px;
        opacity: 0;
        transform: translateY(16px);
        transition: transform 240ms ease-out, opacity 240ms ease-out;
    }

    .nb-po[data-open] .nb-po-panel {
        opacity: 1;
    }

    .nb-po-grip {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .nb-po,
    .nb-po-backdrop,
    .nb-po-panel {
        transition: none !important;
    }
}
