/* OneVoice Gallery */

.ovg-list {
    --ovg-ink: #1d1430;
    --ovg-muted: #6f6385;
    --ovg-surface: #f3eff9;
    --ovg-line: #e6dff0;
    --ovg-accent: #5b2d91;
    --ovg-gradient: linear-gradient(90deg, #943393 0%, #713d98 40%, #3b4da1 100%);
}

/* Оригінальні картки WPFD ховаємо — їх замінюють галерея і картки документів. */
.wpfd_list .file.ovg-src {
    display: none !important;
}

.wpfd_list .ovg-section {
    box-sizing: border-box;
    flex: 0 0 100%;
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
    margin: 0 0 32px;
    padding: 0 10px;
    font-family: inherit;
}

.wpfd_list .ovg-heading {
    margin: 4px 0 14px !important;
    padding: 0 !important;
    color: var(--ovg-muted) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    letter-spacing: .08em;
    line-height: 1.4 !important;
    text-transform: uppercase;
}

/* ---------------------------------------------------------------- Grid */

.ovg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 16px;
}

.ovg-tile {
    position: relative;
    margin: 0;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 14px;
    background: linear-gradient(110deg, #ece6f5 30%, #f7f4fb 50%, #ece6f5 70%) 0 0 / 200% 100%;
    box-shadow: 0 1px 2px rgba(29, 20, 48, .08), 0 8px 20px -8px rgba(59, 31, 110, .25);
    animation: ovg-shimmer 1.4s linear infinite;
}

.ovg-tile.is-loaded {
    background: var(--ovg-surface);
    animation: none;
}

@keyframes ovg-shimmer {
    to { background-position: -200% 0; }
}

.ovg-gallery .ovg-tile__open {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: inherit;
    background: none;
    box-shadow: none;
    cursor: zoom-in;
}

.ovg-gallery .ovg-tile__open:focus-visible {
    outline: 3px solid var(--ovg-accent);
    outline-offset: -3px;
}

.ovg-tile img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    object-fit: cover;
    opacity: 0;
    transition: opacity .3s ease, transform .4s ease;
}

.ovg-tile.is-loaded img {
    opacity: 1;
}

.ovg-tile__actions {
    position: absolute;
    right: 10px;
    bottom: 10px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .2s ease, transform .2s ease;
}

@media (hover: hover) {
    .ovg-tile:hover img {
        transform: scale(1.04);
    }

    .ovg-tile:hover .ovg-tile__actions,
    .ovg-tile:focus-within .ovg-tile__actions {
        opacity: 1;
        transform: none;
    }
}

@media (hover: none) {
    .ovg-tile__actions {
        display: none;
    }
}

.ovg-gallery .ovg-icon-btn {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 4px 14px rgba(20, 10, 40, .3);
    color: var(--ovg-accent);
    cursor: pointer;
    transition: transform .15s ease, background-color .15s ease, color .15s ease;
}

.ovg-gallery .ovg-icon-btn:hover,
.ovg-gallery .ovg-icon-btn:focus-visible {
    background: var(--ovg-accent);
    color: #fff;
    transform: scale(1.06);
}

.ovg-icon-btn svg,
.ovg-btn svg,
.ovg-share svg {
    width: 20px;
    height: 20px;
    flex: none;
}

@media (max-width: 640px) {
    .ovg-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .ovg-tile {
        border-radius: 10px;
    }

    .wpfd_list .ovg-section {
        padding: 0;
    }
}

/* ----------------------------------------------------------- Documents */

.ovg-doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: 16px;
}

.ovg-doc-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-sizing: border-box;
    min-height: 220px;
    padding: 20px;
    border: 1px solid #e6dff0;
    border-radius: 16px;
    background: #fff;
    color: #1d1430;
    transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.ovg-doc-card:hover {
    border-color: #cbbde0;
    box-shadow: 0 14px 30px -18px rgba(59, 31, 110, .45);
}

.ovg-doc-card--placeholder {
    border-color: transparent;
    background: linear-gradient(110deg, #f1ecf8 30%, #f9f7fc 50%, #f1ecf8 70%) 0 0 / 200% 100%;
    animation: ovg-shimmer 1.4s linear infinite;
}

.ovg-doc-card__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 12px;
}

.ovg-doc-card__badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: #f3eff9;
    color: #5b2d91;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    line-height: 1.3;
    text-transform: uppercase;
}

.ovg-doc-card__meta {
    color: #8a7fa0;
    font-size: 12px;
    line-height: 1.4;
}

.wpfd_list .ovg-doc-card__title {
    margin: 2px 0 0 !important;
    padding: 0 !important;
    color: #1d1430 !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
}

.ovg-doc-card .ovg-doc-card__title-btn {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.ovg-doc-card .ovg-doc-card__title-btn:hover {
    color: #5b2d91;
}


.ovg-doc-card__excerpt {
    display: -webkit-box;
    margin: 0 !important;
    overflow: hidden;
    color: #6f6385;
    font-size: 14px;
    line-height: 1.55;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.ovg-doc-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
    padding-top: 6px;
}

.ovg-doc-card__actions .ovg-btn {
    flex: 1 1 130px;
}

/* ------------------------------------------------------------- Buttons */

.ovg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 48px;
    margin: 0;
    padding: 0 22px;
    border: 0;
    border-radius: 999px;
    font: 600 16px/1 inherit;
    font-family: inherit;
    letter-spacing: normal;
    text-decoration: none !important;
    text-transform: none;
    white-space: nowrap;
    cursor: pointer;
    transition: transform .15s ease, filter .15s ease, background-color .15s ease;
}

.ovg-btn:active {
    transform: scale(.97);
}

.ovg-btn--light {
    background: #fff;
    color: #2b1650 !important;
}

.ovg-btn--light:hover {
    background: #efe9f8;
}

.ovg-btn--accent {
    background: linear-gradient(90deg, #943393 0%, #713d98 40%, #3b4da1 100%);
    color: #fff !important;
}

.ovg-btn--accent:hover {
    filter: brightness(1.1);
}

.ovg-btn--outline {
    background: transparent;
    box-shadow: inset 0 0 0 1.5px #d5c9e6;
    color: #3a1f66 !important;
}

.ovg-btn--outline:hover {
    background: #f3eff9;
}

.ovg-btn--sm {
    height: 42px;
    padding: 0 16px;
    font-size: 14px;
}

.ovg-btn.is-done {
    background: #2f8f5b;
}

/* ------------------------------------------------------------ Lightbox */

/* Вище за плаваючі кнопки теми («нагору», чати тощо). */
.pswp {
    --pswp-root-z-index: 2147483000;
}

.pswp__ovg-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(8, 4, 20, .75), rgba(8, 4, 20, 0));
    pointer-events: none;
    transition: opacity .25s ease;
}

.pswp__ovg-bar > * {
    pointer-events: auto;
}

.pswp__counter {
    font-family: inherit;
    font-weight: 600;
    opacity: .9;
}

.pswp__ovg-bar .ovg-btn--ig {
    flex: none;
    width: 48px;
    padding: 0;
    background: radial-gradient(circle at 30% 110%, #fdf497 0%, #fd5949 45%, #d6249f 60%, #285aeb 95%);
    color: #fff !important;
}

.pswp__ovg-bar .ovg-btn--ig svg {
    width: 24px;
    height: 24px;
}

@media (max-width: 420px) {
    .pswp__ovg-bar .ovg-btn {
        flex: 1;
        padding: 0 12px;
    }

    .pswp__ovg-bar .ovg-btn--ig {
        flex: none;
        padding: 0;
    }

    /* Три кнопки на вузькому екрані: «Завантажити» стає круглою іконкою. */
    .pswp__ovg-bar.has-instagram .ovg-btn--light {
        flex: none;
        width: 48px;
        padding: 0;
    }

    .pswp__ovg-bar.has-instagram .ovg-btn--light span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
}

/* --------------------------------------------------------- Share panel */

/* Модальне вікно завжди фіксоване: інакше тема робить його absolute у верху сторінки,
   і фокус на кнопці «Закрити» прокручує сторінку на початок. */
dialog.ovg-share,
dialog.ovg-reader {
    position: fixed !important;
    inset: 0 !important;
}

.ovg-share {
    box-sizing: border-box;
    width: min(440px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    margin: auto;
    padding: 20px;
    border: 0;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 30px 80px rgba(10, 5, 25, .45);
    color: #1d1430;
    font-family: inherit;
}

.ovg-share::backdrop {
    background: rgba(10, 5, 25, .6);
}

.ovg-share .ovg-share__close {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #f3eff9;
    color: #3a1f66;
    cursor: pointer;
}

.ovg-share__networks {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 18px;
}

.ovg-share .ovg-share__net {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    border-radius: 12px;
    color: #3a2a55 !important;
    font-size: 12px;
    text-decoration: none !important;
    transition: background-color .15s ease;
}

.ovg-share .ovg-share__net:hover {
    background: #f3eff9;
}

.ovg-share__icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    color: #fff;
}

.ovg-share__icon svg {
    width: 24px;
    height: 24px;
}

.ovg-share__net--facebook .ovg-share__icon { background: #1877f2; }
.ovg-share__net--telegram .ovg-share__icon { background: #229ed9; }
.ovg-share__net--viber .ovg-share__icon { background: #7360f2; }
.ovg-share__net--whatsapp .ovg-share__icon { background: #25d366; }

@media (prefers-reduced-motion: reduce) {
    .ovg-tile,
    .ovg-tile img,
    .ovg-tile__actions,
    .ovg-btn,
    .pswp__ovg-bar {
        animation: none;
        transition: none;
    }

    .ovg-tile:hover img {
        transform: none;
    }
}

/* -------------------------------------------------------------- Reader */

html.ovg-no-scroll {
    overflow: hidden;
}

.ovg-reader {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    width: min(920px, calc(100vw - 48px));
    height: calc(100vh - 48px);
    height: calc(100dvh - 48px);
    max-width: none;
    max-height: none;
    margin: auto;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 20px;
    background: #f1edf7;
    box-shadow: 0 30px 80px rgba(10, 5, 25, .45);
    color: #1d1430;
    font-family: inherit;
}

.ovg-reader:not([open]) {
    display: none;
}

.ovg-reader::backdrop {
    background: rgba(10, 5, 25, .7);
}

.ovg-reader__bar {
    display: flex;
    flex: none;
    align-items: center;
    gap: 16px;
    padding: 14px 16px 14px 24px;
    border-bottom: 1px solid #e6dff0;
    background: #fff;
}

.ovg-reader__info {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.ovg-reader__title {
    overflow: hidden;
    font-size: 17px;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ovg-reader__actions {
    display: flex;
    flex: none;
    align-items: center;
    gap: 10px;
}

.ovg-reader__body {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.ovg-reader__status {
    margin: 0;
    padding: 64px 24px;
    color: #6f6385;
    font-size: 15px;
    text-align: center;
}

.ovg-reader__status.is-error {
    color: #8a2d4f;
}

.ovg-reader__frame {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}

/* docx-preview: «паперова» сторінка, що стискається разом з екраном.
   !important потрібен, бо бібліотека пише розміри й поля сторінки в inline-стилі. */
.ovg-reader .ovg-docx-wrapper {
    display: block !important;
    padding: 24px !important;
    background: transparent !important;
}

.ovg-reader .ovg-docx-wrapper > section.ovg-docx {
    box-sizing: border-box !important;
    width: auto !important;
    max-width: 800px !important;
    min-height: 0 !important;
    margin: 0 auto 24px !important;
    padding: clamp(24px, 7%, 72px) !important;
    border-radius: 4px;
    box-shadow: 0 10px 30px -12px rgba(29, 20, 48, .35) !important;
    overflow-wrap: break-word;
}

.ovg-reader section.ovg-docx img,
.ovg-reader section.ovg-docx table {
    max-width: 100% !important;
    height: auto !important;
}

.ovg-reader section.ovg-docx table {
    display: block;
    overflow-x: auto;
}

/* Тема робить span/a/i inline-block: тоді текст пункту списку успадковує від'ємний
   text-indent абзацу і наїжджає на маркер. У документі вони мають бути звичайними inline. */
.ovg-reader section.ovg-docx span,
.ovg-reader section.ovg-docx a,
.ovg-reader section.ovg-docx i {
    display: inline;
}

/* Маркер займає місце відступу (у Word це табуляція), щоб перенесені рядки пункту
   починалися рівно під текстом. */
.ovg-reader section.ovg-docx p[class*="-num-"]::before {
    display: inline-block;
    min-width: 18pt;
    text-indent: 0;
}

/* Телефон або вузьке вікно: на весь екран, суцільний текст без «паперу». */
@media (max-width: 760px) {
    .ovg-reader {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        background: #fff;
    }

    .ovg-reader__bar {
        padding: 10px 10px 10px 16px;
        padding-top: calc(10px + env(safe-area-inset-top));
    }

    .ovg-reader__info .ovg-doc-card__badge {
        display: none;
    }

    .ovg-reader .ovg-docx-wrapper {
        padding: 0 !important;
    }

    .ovg-reader .ovg-docx-wrapper > section.ovg-docx {
        max-width: none !important;
        margin: 0 !important;
        padding: 20px 18px !important;
        border-radius: 0;
        box-shadow: none !important;
    }

    .ovg-reader .ovg-docx-wrapper > section.ovg-docx:last-child {
        padding-bottom: calc(32px + env(safe-area-inset-bottom)) !important;
    }

    .ovg-reader section.ovg-docx p,
    .ovg-reader section.ovg-docx span {
        font-size: max(16px, 1em);
        line-height: 1.6;
    }
}

@media (max-width: 420px) {
    .ovg-reader__actions .ovg-btn span {
        display: none;
    }

    .ovg-reader__actions .ovg-btn {
        width: 42px;
        padding: 0;
    }
}

/* Захист від стилів теми (text-transform заголовків, кольори кнопок) */
.wpfd_list .ovg-doc-card__title,
.ovg-doc-card .ovg-doc-card__title-btn,
.ovg-reader__title {
    text-transform: none !important;
    letter-spacing: normal !important;
}

.ovg-reader .ovg-share__close,
.ovg-share .ovg-share__close {
    width: 40px !important;
    height: 40px !important;
    min-width: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: #f3eff9 !important;
    box-shadow: none !important;
    color: #3a1f66 !important;
}

.ovg-reader .ovg-share__close:hover,
.ovg-share .ovg-share__close:hover {
    background: #e8e0f4 !important;
}

.ovg-btn.ovg-btn--outline {
    border: 1.5px solid #d5c9e6 !important;
    box-shadow: none !important;
    background: #fff;
}

.ovg-btn.ovg-btn--outline:hover {
    border-color: #b9a6d6 !important;
    background: #f7f3fc;
}

/* Панель «Поділитися» (комп'ютер): картинка, дві зрозумілі кнопки, посилання — під спойлером */
.ovg-share {
    width: min(400px, calc(100vw - 32px));
    padding: 24px;
    text-align: center;
}

.ovg-share .ovg-share__close {
    position: absolute;
    top: 12px;
    right: 12px;
}

.ovg-share__preview {
    display: block;
    width: 180px;
    height: 180px;
    margin: 4px auto 14px;
    border-radius: 14px;
    object-fit: cover;
    box-shadow: 0 10px 26px -12px rgba(29, 20, 48, .5);
}

.ovg-share .ovg-share__heading {
    margin: 0 0 18px !important;
    color: #1d1430 !important;
    font-size: 19px !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    text-transform: none !important;
}

.ovg-share__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ovg-share__actions .ovg-btn {
    width: 100%;
}

.ovg-share__help {
    margin: 12px 0 0;
    padding: 12px 14px;
    border-radius: 12px;
    background: #eef8f2;
    color: #1f5f3d;
    font-size: 14px;
    line-height: 1.45;
    text-align: left;
}

.ovg-share__help[hidden] {
    display: none;
}

.ovg-share__more {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid #efe9f6;
}

.ovg-share__more .ovg-share__networks {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 4px;
    margin: 0;
}

.ovg-share__more .ovg-share__net {
    gap: 6px;
    padding: 6px 0;
    font-size: 11px !important;
}

.ovg-share__more .ovg-share__net span:last-child {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ovg-share__more .ovg-share__icon {
    width: 44px;
    height: 44px;
}

.ovg-share__net--instagram .ovg-share__icon {
    background: radial-gradient(circle at 30% 110%, #fdf497 0%, #fd5949 45%, #d6249f 60%, #285aeb 95%);
}

.ovg-share button.ovg-share__net {
    margin: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.ovg-share__net--link .ovg-share__icon {
    background: #6f6385;
}


/* Значки соцмереж: два ряди по три, з підписами */
.ovg-share__more .ovg-share__networks {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px 8px;
}

.ovg-share__more .ovg-share__net {
    gap: 6px;
    padding: 6px 0;
    border-radius: 12px;
    font-size: 13px !important;
}

.ovg-share__more .ovg-share__net span:last-child {
    overflow: visible;
    white-space: normal;
}

.ovg-share__more .ovg-share__icon {
    width: 48px;
    height: 48px;
    transition: transform .15s ease, filter .15s ease;
}

.ovg-share__more .ovg-share__net:hover .ovg-share__icon {
    transform: translateY(-2px);
    filter: brightness(1.08);
}

/* Довгі заголовки документів — не більше трьох рядків */
.wpfd_list .ovg-doc-card__title {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}


/* WPFD на мобільному ховає дерево через slideUp (inline display:none); на ширшому екрані повертаємо. */
@media (min-width: 721px) {
    .wpfd-container .wpfd-foldertree {
        display: block !important;
    }
}

/* Дати свят у дереві папок — лише на телефоні (на ширшому екрані їх видно на картках) */
@media (max-width: 720px) {
    .jaofiletree a[data-ovg-date]::after {
        content: attr(data-ovg-date);
        display: block;
        margin-top: 1px;
        color: #7b3fa0;
        font-size: .8em;
        font-weight: 600;
        line-height: 1.3;
    }
}

/* Дати свят на картках папок (WPFD Category Icons): окремий рядок між назвою і кількістю матеріалів */
.wpfd-categories .wpfdci-text[data-ovg-date]::before {
    content: attr(data-ovg-date);
    order: 1;
    color: #7b3fa0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
}

.wpfd-categories .wpfdci-text > .wpfdci-count {
    order: 2;
}

.wpfd-categories .wpfdci-count[data-ovg-count]::after {
    content: attr(data-ovg-count);
}

