/**
 * ND54 — кросс-устройственная стабильность (главная + кабинеты).
 * Подключается последним.
 */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
    max-width: 100vw;
}

#page-wraper,
.nd54-site-footer,
.dashboard-wrapper,
.nd54-press-dashboard,
.cabinet-wrap,
.cabinet-wrapper {
    max-width: 100%;
    overflow-x: clip;
}

/* Светлые секции: читаемый текст поверх main.min.css (белый по умолчанию) */
.section.my-services,
.section.my-work,
.section.news-carousel-section,
#section4.nd54-appeal-section,
.section.donation.nd54-donation-section {
    color: #1e293b !important;
}

.section.my-services .section-heading h2,
.section.my-work .section-heading h2,
.section.news-carousel-section .section-heading h2,
#section4 .nd54-appeal-title,
.section.donation .section-heading h2 {
    color: #0f172a !important;
}

.section.my-services .section-heading span,
.section.my-work .section-heading span,
.section.news-carousel-section .section-heading span,
#section4 .nd54-appeal-subtitle,
.section.donation .section-heading span,
.section.donation .donation-heading span {
    color: #475569 !important;
}

.section.my-services .section-heading .line-dec,
.section.my-work .section-heading .line-dec,
.section.news-carousel-section .section-heading .line-dec,
.section.donation .section-heading .line-dec {
    background: #2279bd !important;
}

/* Меню-оверлей: правила в nd54-theme.css (общие для всех ширин экрана) */

/* Без «невидимых» блоков на телефонах — reveal сразу видим */
@media (max-width: 991.98px), (hover: none) {
    html.nd54-motion-ready body.nd54-premium-active .nd54-reveal,
    html.nd54-motion-ready body.nd54-premium-active .nd54-reveal.nd54-reveal--visible,
    body.nd54-premium-active .nd54-reveal {
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
    }

    body.nd54-premium-active .section-heading {
        transform: none !important;
        will-change: auto !important;
    }
}

/* Карта и hero */
@media (max-width: 767.98px) {
    .map-explorer-viewport {
        min-height: 240px;
    }

    .map-city-marker {
        max-width: 96px;
        font-size: 0.62rem;
        padding: 3px 6px;
    }

    .right-image-post .row,
    .left-image-post .row {
        flex-direction: column;
    }

    .right-image-post .col-md-3,
    .right-image-post .col-md-4,
    .right-image-post .col-md-8,
    .left-image-post .col-md-3,
    .left-image-post .col-md-4,
    .left-image-post .col-md-8 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .white-button a {
        display: block;
        text-align: center;
        width: 100%;
        max-width: 20rem;
        margin: 0 auto;
    }

    .isotope-toolbar {
        display: flex;
        flex-wrap: wrap;
        gap: 0.35rem;
        justify-content: center;
    }

    .isotope-toolbar label {
        margin: 0 !important;
    }
}

/* Форма обращения и пожертвование */
@media (max-width: 575.98px) {
    #section4.nd54-appeal-section > .container,
    section.donation .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .nd54-appeal-card .card-body {
        padding: 1rem !important;
    }

    .donation-card {
        padding: 1.25rem !important;
    }

    .donation-card .btn-group {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        width: 100%;
    }
}

/* Модалки главной */
#roleModal.role-modal {
    z-index: 10070 !important;
}

#taskModalCustom.custom-modal--open {
    z-index: 10090 !important;
}

#taskModalCustom .custom-modal-container {
    width: min(96vw, 800px);
    max-height: min(88vh, 720px);
}

/* Фоновое аудио — полностью скрыто, не занимает место на экране */
.nd54-ambient-audio-hidden,
#nd54AmbientAudio {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

.nd54-audio-toggle {
    position: fixed;
    z-index: 10040;
    right: max(12px, env(safe-area-inset-right, 0px));
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
    width: 2.75rem;
    height: 2.75rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0;
    border: none;
    border-radius: 50%;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    background: rgba(34, 121, 189, 0.92);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.28);
    transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.nd54-audio-toggle:hover {
    transform: scale(1.06);
    background: #1a5f94;
}

.nd54-audio-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(34, 121, 189, 0.45);
}

.nd54-audio-toggle--playing {
    background: rgba(40, 167, 69, 0.92);
}

.nd54-audio-toggle--playing:hover {
    background: #218838;
}

.nd54-audio-toggle i {
    font-size: 1.1rem;
    pointer-events: none;
}

/* -------------------------------------------------------------------------- */
/* Личные кабинеты                                                           */
/* -------------------------------------------------------------------------- */

.dashboard-wrapper {
    padding: 1rem;
}

@media (max-width: 767.98px) {
    .dashboard-wrapper {
        padding: 0.5rem;
    }

    .main-nav-tabs,
    .sub-nav-tabs,
    .workspace-tabs,
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        gap: 0.25rem;
    }

    .main-nav-tabs .nav-link,
    .sub-nav-tabs .btn,
    .sub-nav-tab,
    .workspace-tabs .nav-link {
        white-space: nowrap;
        flex-shrink: 0;
    }

    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100vw - 1rem);
    }

    .modal-fullscreen-md-down {
        width: 100%;
        max-width: none;
        margin: 0;
    }

    .table-responsive {
        margin-bottom: 0.75rem;
        border-radius: 8px;
    }

    .card-header,
    .card-body {
        padding: 0.75rem;
    }

    .btn-toolbar,
    .d-flex.gap-2.flex-wrap {
        width: 100%;
    }

    .nd54-press-dashboard .press-shell {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* Руководитель: панели и графики */
@media (max-width: 991.98px) {
    .dashboard-wrapper .row > [class*="col-"] {
        margin-bottom: 0.75rem;
    }

    .chart-container,
    canvas {
        max-width: 100%;
        height: auto !important;
    }
}

/* Дружинник: вкладки */
@media (max-width: 767.98px) {
    #appealSearch,
    #appealStatusFilter {
        width: 100% !important;
        min-width: 0 !important;
    }
}

/* Заявитель */
@media (max-width: 575.98px) {
    .zayavitel-hero,
    .appeal-card .card-body {
        padding: 1rem;
    }
}

/* Кандидат: тесты и материалы */
@media (max-width: 767.98px) {
    .candidate-test-card,
    .material-card {
        margin-bottom: 0.75rem;
    }
}

/* Главная: фотогалерея — одинаковые кадры, без «разъезжающихся» фото разного формата */
.section.my-work .nd54-gallery-wrap .carousel-item > .row {
    align-items: stretch;
}

.section.my-work .nd54-gallery-wrap .nd54-gallery-tile {
    display: flex;
}

.section.my-work .nd54-gallery-wrap figure.snip1321.nd54-gallery-card {
    position: relative;
    width: 100%;
    margin: 0;
    padding: 0.5rem;
    overflow: visible;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow:
        0 4px 12px rgba(15, 23, 42, 0.08),
        0 18px 36px rgba(15, 23, 42, 0.06);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.section.my-work .nd54-gallery-wrap figure.snip1321.nd54-gallery-card:hover {
    transform: translateY(-4px);
    border-color: rgba(34, 121, 189, 0.35);
    box-shadow:
        0 10px 24px rgba(15, 23, 42, 0.12),
        0 26px 48px rgba(34, 121, 189, 0.14);
}

/* Единый визуальный кадр: обрезка без искажения */
.section.my-work .nd54-gallery-wrap .nd54-gallery-img-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 10px;
    background: linear-gradient(155deg, #e2e8f0, #cbd5e1);
    flex-shrink: 0;
}

.section.my-work .nd54-gallery-wrap .nd54-gallery-img-wrap img.nd54-gallery-photo {
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    object-position: center;
    display: block;
    border-radius: 10px;
    vertical-align: middle;
    transition: transform 0.45s ease;
}

.section.my-work .nd54-gallery-wrap figure.snip1321.nd54-gallery-card:hover .nd54-gallery-img-wrap img.nd54-gallery-photo {
    transform: scale(1.04);
}

/* Подписи под фото — снипет snip1321 по умолчанию делает их невидимым оверлеем */
.section.my-work .nd54-gallery-wrap figure.snip1321.nd54-gallery-card::after {
    display: none;
}

.section.my-work .nd54-gallery-wrap figure.snip1321.nd54-gallery-card figcaption {
    position: static;
    top: auto;
    left: auto;
    right: auto;
    opacity: 1;
    transform: none;
    transition: none;
    flex-grow: 1;
    margin-top: 0.65rem;
    padding: 0 0.15rem;
    text-align: left;
}

.section.my-work .nd54-gallery-wrap figure.snip1321.nd54-gallery-card:hover figcaption,
.section.my-work .nd54-gallery-wrap figure.snip1321.nd54-gallery-card.hover figcaption {
    opacity: 1;
    transform: none;
    transition-delay: 0s;
}

.section.my-work .nd54-gallery-wrap figure.snip1321.nd54-gallery-card figcaption h4 {
    margin-top: 0;
    color: #0f172a;
}

.section.my-work .nd54-gallery-wrap figure.snip1321.nd54-gallery-card figcaption .nd54-gallery-card-text {
    color: #64748b;
}

.section.my-work .nd54-gallery-wrap figure.snip1321.nd54-gallery-card figcaption i {
    font-size: 16px;
    width: 36px;
    height: 36px;
    line-height: 36px;
    vertical-align: middle;
}

.section.my-work .nd54-photo-carousel {
    position: relative;
    overflow: hidden;
    padding-bottom: 0.5rem;
}

.section.my-work .nd54-photo-carousel .carousel-inner {
    overflow: hidden;
}

/* Стрелки как у блока новостей: маленькие круглые кнопки, без ширины 15% от карусели */
#nd54PhotoCarousel .carousel-control-prev,
#nd54PhotoCarousel .carousel-control-next {
    width: 2.5rem !important;
    min-width: 2.5rem !important;
    max-width: 2.5rem !important;
    height: 2.5rem;
    top: 50%;
    bottom: auto;
    margin-top: 0;
    padding: 0 !important;
    opacity: 0.92;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: opacity 0.2s ease, background 0.2s ease, transform 0.2s ease;
    transform: translateY(-50%);
}

#nd54PhotoCarousel .carousel-control-prev {
    left: 0.35rem;
}

#nd54PhotoCarousel .carousel-control-next {
    right: 0.35rem;
}

#nd54PhotoCarousel .carousel-control-prev:hover,
#nd54PhotoCarousel .carousel-control-next:hover,
#nd54PhotoCarousel .carousel-control-prev:focus,
#nd54PhotoCarousel .carousel-control-next:focus {
    opacity: 1;
    transform: translateY(-50%) scale(1.05);
    background: rgba(34, 121, 189, 0.55);
}

#nd54PhotoCarousel .carousel-control-prev-icon,
#nd54PhotoCarousel .carousel-control-next-icon {
    width: 1.35rem;
    height: 1.35rem;
}

@media (prefers-reduced-motion: reduce) {
    .section.my-work .nd54-gallery-wrap figure.snip1321.nd54-gallery-card:hover {
        transform: none;
    }

    .section.my-work .nd54-gallery-wrap figure.snip1321.nd54-gallery-card:hover .nd54-gallery-img-wrap img.nd54-gallery-photo {
        transform: none;
    }
}

/* Превью «лупой»: модальное окно Bootstrap */
.section.my-work .nd54-gallery-wrap a.nd54-gallery-zoom:focus-visible {
    outline: 2px solid rgba(34, 121, 189, 0.95);
    outline-offset: 3px;
    border-radius: 6px;
}

.nd54-gallery-fs-body {
    background: #050505;
}

.nd54-gallery-fs-img {
    max-width: 100%;
    max-height: min(82vh, 900px);
    width: auto;
    height: auto;
    object-fit: contain;
    margin: 0 auto;
    display: block;
}

/*
 * Глобальный .modal / .modal-content в profile.css (старый кастомный оверлей, z-index 1000 и width 300px)
 * конфликтует с Bootstrap: модалка уходит под #page-wraper (10000), ломается вёрстка и «прорывается» на страницу.
 */
#nd54GalleryFullscreenModal.modal {
    z-index: 10090 !important;
    background-color: transparent !important;
}

#nd54GalleryFullscreenModal .modal-dialog {
    max-width: min(920px, 96vw);
    margin: 1.75rem auto;
}

#nd54GalleryFullscreenModal .modal-content.nd54-gallery-fs-modal {
    display: flex !important;
    flex-direction: column !important;
    width: auto !important;
    max-width: min(920px, 96vw) !important;
    margin: 0 !important;
    padding: 0 !important;
}

body.modal-open:has(#nd54GalleryFullscreenModal.show) > .modal-backdrop.show {
    z-index: 10085 !important;
}
