/**
 * Стили статейных блоков (виджеты в HTML статей с бэка).
 * Порт из старого проекта: src/css/_textblock.scss + _hastooltip.scss
 * (в референсе root 62.5% — rem переведены в px умножением на 10).
 * Всё scoped под .article-textblock, чтобы не пересекаться с приложением.
 * Файл лежит в public и подключается неблокирующе (rel=preload → stylesheet)
 * через useArticleStyles() — НЕ импортировать в бандл.
 *
 * Отличия от референса:
 * - .table-wrapper_wide и .gridgallery не делают full-bleed на ширину вьюпорта:
 *   наша статья уже колонки с оглавлением, блоки живут внутри неё.
 * - брейкпоинты референса: md=768px, lg=992px.
 */

/* --- таблицы --- */

.article-textblock .table-wrapper {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: thin;
    box-sizing: border-box;
}

/* внутри обёртки таблица возвращается к нативной раскладке (базовый
   article-textblock делает table display:block для простых таблиц) */
.article-textblock .table-wrapper table {
    display: table;
    width: auto;
    max-width: none;
    overflow-x: visible;
    border-collapse: collapse;
    margin-block: 0;
}
.article-textblock .table-wrapper tr {
    background-color: var(--bg);
}
.article-textblock .table-wrapper tr:nth-child(even) {
    background-color: var(--bg-gray);
}
.article-textblock .table-wrapper th,
.article-textblock .table-wrapper td {
    border: none;
    padding: 10px 20px;
}
.article-textblock .table-wrapper th ~ *,
.article-textblock .table-wrapper td ~ * {
    padding-left: 5px;
}
.article-textblock .table-wrapper th:not([align]),
.article-textblock .table-wrapper td:not([align]) {
    text-align: left;
}
.article-textblock .table-wrapper th {
    vertical-align: middle;
    font-weight: 400;
}

.article-textblock > .table-wrapper {
    margin-block: 20px;
}
.article-textblock > .table-wrapper:last-child {
    margin-bottom: 0;
}
.article-textblock h1 + .table-wrapper,
.article-textblock h2 + .table-wrapper,
.article-textblock h3 + .table-wrapper,
.article-textblock h4 + .table-wrapper {
    margin-top: 30px;
}

/* таблица сравнения: карточки-колонки на серых плашках */
.article-textblock table.table-compare {
    display: table; /* на случай таблицы без обёртки .table-wrapper — перекрывает display:block базы */
    border-spacing: 10px 5px;
    border-collapse: separate;
}
.article-textblock table.table-compare td,
.article-textblock table.table-compare th {
    width: 212px;
    min-width: 212px;
}
.article-textblock table.table-compare th {
    font-size: 20px;
    font-weight: 400;
    line-height: 1.2;
    padding: 0 0 5px;
    background: none;
}
.article-textblock table.table-compare td {
    font-size: 16px;
    font-weight: 400;
    line-height: 1.1875;
    background-color: var(--table-compare-bg);
    padding: 10px;
    border-radius: var(--corner);
}
.article-textblock table.table-compare small,
.article-textblock table.table-compare .table-compare__label {
    font-size: 14px;
    font-weight: 400;
    line-height: 1.143;
}
.article-textblock table.table-compare * + p {
    margin-top: 5px;
}
.article-textblock table.table-compare img {
    border-radius: var(--corner);
    max-height: 186px;
    max-width: 100%;
    margin-block: 0;
}
@supports selector(:has(*)) {
    .article-textblock table.table-compare img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        max-height: none;
    }
}
.article-textblock table.table-compare td:has(> img) {
    padding: 0;
    height: 186px;
}

/* --- подписи и хелперы отступов из вёрстки статей --- */

.article-textblock .tb-caption {
    font-size: 14px;
    font-weight: 300;
    line-height: 1.143;
    color: var(--text-secondary); /* в референсе var(--font), но --font в dark не переопределяется */
}
.article-textblock .tb-caption,
.article-textblock * + .tb-caption {
    margin-top: 10px !important;
}
.article-textblock *:has(+ .tb-caption) {
    margin-bottom: 10px !important;
}

.article-textblock .mt-0 {
    margin-top: 0 !important;
}
.article-textblock .mt-10 {
    margin-top: 10px !important;
}

/* --- плашки-цитаты и акценты --- */

.article-textblock .tb-feature {
    position: relative;
    padding-left: 26px;
}
.article-textblock .tb-feature::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background: linear-gradient(180.89deg, #7fbb5a -41.8%, #1175cb 150.72%);
}
.article-textblock .tb-feature + img {
    margin-top: 10px;
}
.article-textblock h2.tb-feature {
    font-size: 25px;
    font-weight: 400;
    line-height: 1.16;
    padding: 0 0 16px;
    margin-bottom: 10px;
}
.article-textblock h2.tb-feature + * {
    margin-top: 10px;
}
.article-textblock h2.tb-feature::before {
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    height: 6px;
    width: auto;
    background: linear-gradient(-90deg, #7fbb5a -41.8%, #1175cb 150.72%);
}

.article-textblock .tb-quote-gray {
    margin-block: 30px;
    background-color: var(--cl-gray);
    color: var(--text); /* в референсе var(--cl-text), но --cl-text в dark не переопределяется */
    padding: 20px 25px;
    border-radius: var(--corner);
    box-sizing: border-box;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 15px;
    font-size: 20px;
    font-weight: 400;
    line-height: 1.2;
}
.article-textblock .tb-quote-gray + .tb-quote-blue,
.article-textblock .tb-quote-gray + .tb-quote-gray,
.article-textblock .tb-quote-blue + .tb-quote-blue,
.article-textblock .tb-quote-blue + .tb-quote-gray {
    margin-top: -20px;
}
.article-textblock .tb-quote-gray p + p {
    margin: 0;
}
.article-textblock .tb-quote-gray__text {
    font-size: 18px;
    font-weight: 400;
    line-height: 1.167;
}
.article-textblock .tb-quote-gray__author {
    color: var(--cl-text-light);
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding-left: 42px;
    box-sizing: border-box;
    position: relative;
    text-align: right;
    align-self: flex-start;
}
.article-textblock .tb-quote-gray__author::before {
    content: '';
    display: block;
    width: 32px;
    height: 1px;
    background-color: currentColor;
    position: absolute;
    left: 0;
    top: 0.6em;
}
@media (min-width: 768px) {
    .article-textblock .tb-quote-gray__author {
        padding-left: 96px;
    }
    .article-textblock .tb-quote-gray__author::before {
        width: 86px;
    }
}
.article-textblock .tb-quote-gray__pos {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.143;
}

.article-textblock .tb-quote-blue {
    margin-block: 30px;
    box-sizing: border-box;
    padding: 20px 25px 20px 67px;
    border-radius: var(--corner);
    background-color: var(--cl-blue);
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    color: var(--cl-white);
    position: relative;
    font-size: 20px;
    font-weight: 400;
    line-height: 1.2;
}
.article-textblock .tb-quote-blue::before {
    content: '';
    display: block;
    width: 28px;
    height: 18px;
    background-color: currentColor;
    position: absolute;
    top: 50%;
    left: 25px;
    transform: translateY(-50%);
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: 28px 18px;
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='18' fill='none' viewBox='0 0 28 18'%3E%3Cpath stroke='%23fff' d='M7.6 8.3 1.65 2.18a1 1 0 0 1 .72-1.7H18.3a1 1 0 0 1 .71.3l7.31 7.5a1 1 0 0 1 0 1.4l-7.3 7.5a1 1 0 0 1-.72.3H2.37a1 1 0 0 1-.72-1.7L7.6 9.7a1 1 0 0 0 0-1.4Z'/%3E%3C/svg%3E");
}

/* серые плашки-списки (tb-list-plates) */
.article-textblock .tb-list-plates {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.1875;
}
.article-textblock .tb-list-plates li {
    padding: 10px;
    border-radius: var(--corner);
    background-color: var(--art-plates-bg);
    position: relative;
    display: flex;
    align-items: center;
}

/* список-плашки с точками (ul-plates) */
.article-textblock .ul-plates {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 20px;
    font-size: 20px;
    font-weight: 400;
    line-height: 1.2;
}
@media (min-width: 768px) {
    .article-textblock .ul-plates_cols {
        grid-template-columns: 1fr 1fr;
        gap: 30px;
    }
}
.article-textblock .ul-plates > li {
    position: relative;
    background-color: var(--bg-gray);
    padding: 25px 25px 25px 43px;
    border-radius: var(--corner);
}
.article-textblock .ul-plates > li::before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--primary);
    position: absolute;
    left: 25px;
    top: 33px;
}

/* маркированный список с точками в ряд (ul-special) */
.article-textblock .ul-special {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 25px 50px;
}
@media (min-width: 768px) {
    .article-textblock .ul-special {
        flex-direction: row;
    }
}
.article-textblock .ul-special > li {
    font-size: 16px;
    font-weight: 400;
    line-height: 1.1875;
    position: relative;
    padding-left: 18px;
}
.article-textblock .ul-special > li::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--primary);
    position: absolute;
    left: 0;
    top: 6px;
    display: block;
}
@media (min-width: 768px) {
    .article-textblock .ul-special > li {
        flex: 1;
    }
}

/* информационная плашка */
.article-textblock .plate {
    font-size: 14px;
    font-weight: 400;
    line-height: 1.143;
    padding: 20px 15px;
    background-color: var(--bg-gray);
    border-radius: var(--corner);
    max-width: none;
}
.article-textblock .plate > p {
    max-width: 654px;
    margin-inline: auto;
}
.article-textblock .plate + * {
    margin-top: 30px;
}
.article-textblock * + .plate {
    margin-top: 30px;
}
@media (min-width: 768px) {
    .article-textblock .plate {
        padding: 40px 32px;
    }
}

/* крупный акцентный текст */
.article-textblock .hugetext {
    display: block;
    margin: 30px auto;
    text-align: center;
    font-size: 32px;
    line-height: 1;
    font-weight: 700;
}
.article-textblock .hugetext__highlight {
    font-size: 60px;
    color: var(--primary);
}

/* --- медиа --- */

.article-textblock video {
    margin: 20px auto;
    display: block;
    max-width: 100%;
    max-height: 95vh;
    max-height: 95dvh;
}

.article-textblock hr {
    margin-block: 30px !important;
    border: none;
    border-top: 1px solid var(--border-color);
    max-width: 360px;
    width: 100%;
    margin-inline: auto;
}

/* декоративная цитата (без классов-модификаторов) */
.article-textblock blockquote:not(.tb-quote-gray):not(.tb-quote-blue) {
    font-size: 20px;
    font-weight: 400;
    line-height: 1.2;
    display: block;
    position: relative;
    max-width: 354px;
    margin: 30px auto;
    padding: 33px 17px;
    text-align: center;
}
.article-textblock blockquote:not(.tb-quote-gray):not(.tb-quote-blue)::before,
.article-textblock blockquote:not(.tb-quote-gray):not(.tb-quote-blue)::after {
    content: '';
    display: block;
    position: absolute;
    left: 10px;
    right: 10px;
    height: 23px;
    background:
        radial-gradient(
            circle 23px at center,
            var(--primary) 1.5px,
            var(--bg) 1.5px,
            var(--bg) 11.5px,
            transparent 11.5px
        ),
        linear-gradient(
            to bottom,
            var(--bg) 11px,
            var(--primary) 12px,
            var(--bg) 12px
        );
    background-size: 23px 23px, 100% 100%;
    background-repeat: no-repeat;
    background-position: center, center;
}
.article-textblock blockquote:not(.tb-quote-gray):not(.tb-quote-blue)::before {
    top: 0;
}
.article-textblock blockquote:not(.tb-quote-gray):not(.tb-quote-blue)::after {
    bottom: 0;
}

/* горизонтальная лента картинок */
.article-textblock .textblock__pics {
    margin-block: 30px 50px;
    padding-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(var(--artpics-cols, 2), 1fr);
    gap: 10px;
    overflow: auto;
}
.article-textblock .textblock__pics:last-child {
    margin-bottom: 0;
}
.article-textblock .textblock__pics > img,
.article-textblock .textblock__pics > picture {
    margin: 0;
    min-width: 220px;
    border-radius: var(--corner);
}

/* иконки платежей/банков */
.article-textblock .paypics {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.article-textblock .paypics:has(.paypics__figure) {
    gap: 24px 50px;
}
.article-textblock .paypics + *,
.article-textblock * + .paypics {
    margin-top: 15px;
}
.article-textblock .paypics__pic {
    height: 30px;
    flex-shrink: 0;
}
.article-textblock .paypics__pic img {
    height: 100%;
    width: auto;
    margin-block: 0;
}
.article-textblock .paypics__figure {
    display: flex;
    margin: 0;
    padding: 0;
    gap: 5px 15px;
    flex-wrap: wrap;
}
.article-textblock .paypics__caption {
    font-size: 14px;
    font-weight: 400;
    line-height: 1.143;
    margin: 0;
    padding: 0;
}

/* фиксированной высоты медиа-блоки */
.article-textblock .m-h370,
.article-textblock .m-h260 {
    display: block;
}
.article-textblock .m-h370 {
    height: 370px;
}
.article-textblock .m-h260 {
    height: 260px;
}
.article-textblock .m-h370 img,
.article-textblock .m-h260 img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* --- галереи --- */

.article-textblock .gridgallery {
    margin-block: 20px;
    box-sizing: border-box;
    max-width: 100%;
    display: grid;
    grid-auto-rows: auto;
    gap: 20px;
}
.article-textblock .gridgallery + .gridgallery {
    margin-top: 60px;
}
@media (min-width: 768px) {
    .article-textblock .gridgallery + .gridgallery {
        margin-top: 100px;
    }
}
.article-textblock .gridgallery__item {
    position: relative;
}
.article-textblock .gridgallery img {
    border-radius: var(--corner);
    margin-block: 0;
}

.article-textblock .gridgallery.m-3x-v {
    grid-template-columns: repeat(2, 1fr);
}
.article-textblock .gridgallery.m-3x-v .gridgallery__item:nth-child(3n + 1) {
    grid-column: span 2;
}
.article-textblock .gridgallery.m-3x-v .gridgallery__item:nth-child(3n + 3) img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.article-textblock .gridgallery.m-3x-h {
    grid-template-columns: repeat(2, 1fr);
}
@media (max-width: 767.98px) {
    .article-textblock .gridgallery.m-3x-h .gridgallery__item:nth-child(3n + 1) {
        grid-column: span 2;
    }
    .article-textblock .gridgallery.m-3x-h .gridgallery__item:nth-child(3n + 3) img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
}
@media (min-width: 768px) {
    .article-textblock .gridgallery.m-3x-h {
        grid-template-columns: 2.12fr 1fr;
    }
    .article-textblock .gridgallery.m-3x-h .gridgallery__item:nth-child(3n + 1) {
        grid-row: span 2;
    }
    .article-textblock .gridgallery.m-3x-h .gridgallery__item:nth-child(3n + 1) img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        position: absolute;
    }
}

.article-textblock .gridgallery.m-5x {
    grid-template-columns: 1fr 1fr;
}
@media (max-width: 767.98px) {
    .article-textblock .gridgallery.m-5x .gridgallery__item {
        grid-column: span 2;
    }
    .article-textblock .gridgallery.m-5x .gridgallery__item:nth-child(1),
    .article-textblock .gridgallery.m-5x .gridgallery__item:nth-child(4),
    .article-textblock .gridgallery.m-5x .gridgallery__item:nth-child(5) {
        order: -1;
    }
    .article-textblock .gridgallery.m-5x .gridgallery__item:nth-child(4),
    .article-textblock .gridgallery.m-5x .gridgallery__item:nth-child(5) {
        grid-column: auto;
    }
    .article-textblock .gridgallery.m-5x .gridgallery__item:nth-child(5) img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
}
@media (min-width: 768px) {
    .article-textblock .gridgallery.m-5x {
        grid-template-columns: 1.26fr 1.26fr 2fr;
    }
    .article-textblock .gridgallery.m-5x .gridgallery__item:nth-child(5n + 1) {
        grid-row: span 8;
        grid-column: 1 / 3;
    }
    .article-textblock .gridgallery.m-5x .gridgallery__item:nth-child(5n + 2),
    .article-textblock .gridgallery.m-5x .gridgallery__item:nth-child(5n + 3) {
        grid-row: span 6;
    }
    .article-textblock .gridgallery.m-5x .gridgallery__item:nth-child(5n + 4),
    .article-textblock .gridgallery.m-5x .gridgallery__item:nth-child(5n + 5) {
        grid-row: span 4;
    }
    .article-textblock .gridgallery.m-5x .gridgallery__item:nth-child(5n + 1) img {
        position: absolute;
    }
    .article-textblock .gridgallery.m-5x .gridgallery__item:nth-child(5n + 1) img,
    .article-textblock .gridgallery.m-5x .gridgallery__item:nth-child(5n + 4) img,
    .article-textblock .gridgallery.m-5x .gridgallery__item:nth-child(5n + 5) img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
}

/* скругления галереи только снаружи */
.article-textblock .gridgallery.m-corners img {
    border-radius: var(--corner) var(--corner) 0 0;
}
.article-textblock .gridgallery.m-corners.m-3x-h .gridgallery__item:nth-child(3n + 1) img,
.article-textblock .gridgallery.m-corners.m-3x-v .gridgallery__item:nth-child(3n + 1) img {
    border-radius: var(--corner) 0 0 var(--corner);
}
.article-textblock .gridgallery.m-corners.m-5x .gridgallery__item:nth-child(5n + 1) img {
    border-radius: var(--corner) 0 0 var(--corner);
}

/* --- тултипы в тексте --- */

.article-textblock .hastooltip {
    position: relative;
    color: var(--secondary);
    cursor: pointer;
}
.article-textblock .hastooltip__tooltip {
    position: absolute;
    top: calc(100% + 0.5em);
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--tooltip-bg);
    color: var(--text);
    padding: 10px;
    border-radius: var(--corner);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 10;
    width: max-content;
    max-width: 280px;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.167;
    cursor: default;
    opacity: 0;
    visibility: hidden;
    transition-property: opacity, visibility;
    transition-duration: var(--transition-duration, 0.3s);
    transition-delay: var(--transition-delay, 0.4s);
}
.article-textblock .hastooltip:hover .hastooltip__tooltip,
.article-textblock .hastooltip:focus-visible .hastooltip__tooltip,
.article-textblock .hastooltip__tooltip[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
    transition-delay: var(--transition-delay, 0s);
}
.article-textblock .hastooltip__tooltip.m-overflow-right {
    left: auto;
    right: -10px;
    transform: translateX(0);
}
.article-textblock .hastooltip__tooltip.m-overflow-left {
    left: -10px;
    right: auto;
    transform: translateX(0);
}
