/* ==========================================================================
   CMS-specific tweaks layered on top of the design's main.css.
   Keeps the compiled design CSS untouched.
   ========================================================================== */

/* (req 4) When a cropped image doesn't fit by height, keep the TOP visible
   and crop the BOTTOM. */
.work-card img,
.project__gallery .work-card img,
.blog-card__media img,
.case-open__gallery img {
    object-position: top center !important;
}

/* Never letterbox with a dark/black colour — use a neutral that matches the
   light card surface so any gaps read as "background", not black bars. (req 2) */
.work-card,
.project__gallery--full .work-card,
.portfolio .work-col .work-card.work-card--tall {
    background-color: #d9d9d9;
}

/* (req 1/legacy) Tall "tower" works in the portfolio listing: enough height
   and the whole image visible (contain), cropping nothing. */
.portfolio .work-col .work-card.work-card--tall {
    aspect-ratio: 9 / 20;
}
.portfolio .work-col .work-card.work-card--tall img {
    object-fit: contain;
    object-position: top center;
}

/* (req 2) "Rich" works fill the card edge-to-edge (cover) — no side bars. */
.portfolio .work-col[data-type="rich"] .work-card img {
    object-fit: cover;
    object-position: top center;
}

/* (req 3) "Нейрофото" works keep their natural proportions (square, 3:4,
   16:9, …). The card sizes to the image instead of forcing a fixed ratio,
   so nothing is cropped and there are no bars. */
.portfolio .work-col[data-type="neuro"] .work-card,
.portfolio .work-col[data-type="neuro"] .work-card.work-card--square {
    aspect-ratio: auto;
    background: transparent;
}
.portfolio .work-col[data-type="neuro"] .work-card img {
    height: auto;
    object-fit: contain;
}

/* (req 5) Full-width single-column gallery inside a project. */
.project__gallery--full .work-card {
    aspect-ratio: auto;
    background: transparent;
}
.project__gallery--full .work-card img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

/* No zoom-in animation on hover inside a project gallery. */
.project__gallery .work-card:hover img {
    transform: none;
}

/* Back-to-top button — authoritative visibility toggle (overrides design JS). */
.to-top.dv-totop-show {
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
}

/* Work-hours value matches the size of other contact items. */
.contact-link-list li .contacts-schedule {
    font-size: clamp(24px, 3.5vw, 48px);
    font-weight: 600;
    color: #101010;
    line-height: 1.25;
    display: block;
}

/* Disabled prev/next project arrows when there is no adjacent project. */
.btn-nav-arrow.is-disabled {
    opacity: 0.35;
    pointer-events: none;
    cursor: default;
}

/* (req 7.5) Cover / first image of an article stretches to full width. */
.article__figure--wide,
.article__figure--portrait {
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
}
.article__figure--wide img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 14px;
}

/* (req 7.5) Three-in-a-row image grid inside the article body. */
.article__body .article__grid--3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 1.5rem 0;
}
.article__body .article__grid--3 img {
    width: 100%;
    height: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    object-position: top center;
    border-radius: 10px;
}
@media (max-width: 575.98px) {
    .article__body .article__grid--3 { grid-template-columns: repeat(2, 1fr); }
}

/* (Task) Blog article rich text: one-direction vertical rhythm.
   Top margins are intentionally zero to avoid collapsing surprises between
   TinyMCE blocks; spacing is controlled through margin-bottom only. */
.article__body--blog {
    --article-gap-empty: 10px;
    --article-gap-tight: 12px;
    --article-gap-heading: 16px;
    --article-gap-text: 24px;
    --article-gap-block: 32px;
    --article-gap-section: 38px;
    line-height: 1.72;
}
.article__body--blog h2,
.article__body--blog h3,
.article__body--blog h4,
.article__body--blog h5,
.article__body--blog h6 {
    margin-top: 0;
    color: #101010;
    font-weight: 600;
    line-height: 1.25;
}
.article__body--blog h2 {
    margin-bottom: var(--article-gap-heading);
    font-size: clamp(24px, 2.6vw, 32px);
}
.article__body--blog h3 {
    margin-bottom: var(--article-gap-heading);
    font-size: clamp(22px, 2.2vw, 28px);
}
.article__body--blog h4 {
    margin-bottom: var(--article-gap-tight);
    font-size: clamp(19px, 1.8vw, 22px);
}
.article__body--blog h5,
.article__body--blog h6 {
    margin-bottom: var(--article-gap-tight);
    font-size: 18px;
}
.article__body--blog p {
    margin: 0 0 var(--article-gap-text);
}
.article__body--blog ul,
.article__body--blog ol {
    margin: 0 0 var(--article-gap-text);
    padding-left: 1.45em;
}
.article__body--blog li {
    margin: 0 0 10px;
    padding-left: .1em;
}
.article__body--blog li:last-child,
.article__body--blog li > :last-child {
    margin-bottom: 0;
}
.article__body--blog li > p,
.article__body--blog li > ul,
.article__body--blog li > ol {
    margin-bottom: 10px;
}
.article__body--blog ul ul,
.article__body--blog ul ol,
.article__body--blog ol ul,
.article__body--blog ol ol {
    margin-top: 10px;
    margin-bottom: 0;
}
.article__body--blog blockquote,
.article__body--blog figure,
.article__body--blog table,
.article__body--blog pre,
.article__body--blog hr,
.article__body--blog .article__figure,
.article__body--blog .article__grid,
.article__body--blog .dv-article-slider,
.article__body--blog .dv-baf {
    margin-top: 0;
    margin-bottom: var(--article-gap-block);
}
.article__body--blog .dv-article-slider,
.article__body--blog .dv-baf {
    margin-right: auto;
    margin-left: auto;
}
.article__body--blog p:has(> img:only-child) {
    margin-bottom: var(--article-gap-block);
}
.article__body--blog p:has(> img:only-child) img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 14px;
}
.article__body--blog figcaption {
    margin-top: 10px;
    margin-bottom: 0;
    color: #4e4e50;
    font-size: 14px;
    line-height: 1.45;
}
.article__body--blog :is(p, ul, ol, blockquote, figure, table, pre, hr, .article__figure, .article__grid, .dv-article-slider, .dv-baf):has(+ :is(h2, h3)) {
    margin-bottom: var(--article-gap-section);
}
.article__body--blog :is(p, ul, ol, blockquote, figure, table, pre, hr, .article__figure, .article__grid, .dv-article-slider, .dv-baf):has(+ :is(h4, h5, h6)) {
    margin-bottom: 28px;
}
.article__body--blog .article__empty-block,
.article__body--blog p:empty,
.article__body--blog p:has(> br:only-child),
.article__body--blog :is(h2, h3, h4, h5, h6):empty,
.article__body--blog :is(h2, h3, h4, h5, h6):has(> br:only-child) {
    margin: 0 0 var(--article-gap-empty);
    min-height: 0;
    font-size: 0;
    line-height: 0;
}
.article__body--blog .article__empty-block > br,
.article__body--blog p:has(> br:only-child) br,
.article__body--blog :is(h2, h3, h4, h5, h6):has(> br:only-child) br {
    display: none;
}
.article__body--blog > :first-child {
    margin-top: 0;
}
.article__body--blog > :last-child {
    margin-bottom: 0;
}
.article__body--blog + .article__body--blog,
.article__body--blog + .article__cta {
    margin-top: 32px;
}

/* (req 1) Цитаты в теле статьи. Кнопка «Цитата» редактора вставляет обычный
   <blockquote>; без оформления он сливается с текстом. Оформляем как дизайнерскую
   цитату (.article__quote): красная линия слева, крупный акцентный текст. */
.article__body blockquote {
    margin: 36px 0;
    padding: 4px 0 4px 28px;
    border-left: 4px solid #E03328;
    font-style: normal;
}
.article__body--blog blockquote {
    margin-top: 0;
    margin-bottom: var(--article-gap-block);
}
.article__body blockquote p {
    font-weight: 600;
    font-size: clamp(20px, 2.4vw, 28px);
    line-height: 1.3;
    color: #101010;
    margin: 0;
}
.article__body blockquote p + p { margin-top: .5em; }
.article__body blockquote cite,
.article__body blockquote footer {
    display: block;
    margin-top: 14px;
    color: #4e4e50;
    font-weight: 500;
    font-size: 16px;
    font-style: normal;
}

/* (req 7.6 / 2 + 3.x) Image slider — standardized height, image centered.
   Empty space around an undersized image is filled white (3.3). Site-style
   round arrows (3.1) and a reviews-like scrollbar (3.2) instead of bullets. */
.dv-article-slider {
    position: relative;
    margin: 1.5rem auto;
    background: transparent;
}
.dv-article-slider .swiper-wrapper {
    height: clamp(320px, 58vh, 560px);
}
.dv-article-slider .swiper-slide {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;            /* (3.3) пустое пространство заливаем белым */
    border-radius: 14px;
    overflow: hidden;
}
.dv-article-slider .swiper-slide img {
    max-height: 100%;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    display: block;
}

/* (3.1) Стрелки листания в стилистике сайта (как кнопки на странице проекта). */
.dv-article-slider .dv-slider-arrow {
    position: absolute;
    top: calc(clamp(320px, 58vh, 560px) / 2);
    transform: translateY(-50%);
    z-index: 5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 1.5px solid rgba(16, 16, 16, .22);
    background: rgba(255, 255, 255, .9);
    color: #101010;
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease, color .2s ease, opacity .2s ease;
}
.dv-article-slider .dv-slider-arrow:hover {
    background: #101010;
    border-color: #101010;
    color: #f2f2f2;
}
.dv-article-slider .dv-slider-arrow svg { width: 22px; height: 22px; }
.dv-article-slider .dv-slider-prev { left: 12px; }
.dv-article-slider .dv-slider-next { right: 12px; }
.dv-article-slider .dv-slider-arrow.swiper-button-disabled {
    opacity: .35;
    pointer-events: none;
}

/* (3.2) Скролл-бар вместо буллитов — как у блока отзывов. */
.dv-article-slider.swiper .swiper-scrollbar {
    position: relative;
    left: 0;
    right: auto;
    bottom: auto;
    top: auto;
    width: 100%;
    height: 4px;
    margin-top: 24px;
    background-color: rgba(16, 16, 16, 0.1);
    border-radius: 2px;
}
.dv-article-slider .swiper-scrollbar-drag {
    background-color: #ffd94f;
    border-radius: 2px;
    cursor: grab;
}
.dv-article-slider .swiper-scrollbar-drag:active { cursor: grabbing; }

/* (req 7.6 / 1) Before / after — standardized height. The block shrinks to
   the contained image (width: fit-content) and is centered, so the sides stay
   transparent instead of stretching to full width. */
.dv-baf {
    position: relative;
    width: fit-content;
    max-width: 100%;
    height: clamp(320px, 58vh, 560px);
    margin: 1.5rem auto;
    user-select: none;
    line-height: 0;
}
.dv-baf__after,
.dv-baf__before img {
    height: 100%;
    width: auto;
    max-width: 100%;
    display: block;
    border-radius: 14px;
}
.dv-baf__before {
    position: absolute;
    inset: 0;
    clip-path: inset(0 50% 0 0);
    overflow: hidden;
}
.dv-baf__handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 36px;
    margin-left: -18px;
    cursor: ew-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Let the pointer drag the divider instead of scrolling the page on touch,
       and never select text while dragging. */
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.dv-baf__handle::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    margin-left: -1px;
    background: #fff;
}
.dv-baf__handle::after {
    content: '⇔';
    position: relative;
    z-index: 1;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fff;
    color: #101010;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,.3);
}

/* Media library multi-select badges. */
.dv-media__item { position: relative; }
.dv-media__badge {
    position: absolute; top: 6px; left: 6px; min-width: 22px; height: 22px;
    border-radius: 999px; background: var(--dv-accent); color: #fff;
    font-size: 12px; display: none; align-items: center; justify-content: center; padding: 0 6px;
}
.dv-media__item.is-selected { outline: 3px solid var(--dv-accent); }
.dv-media__item.is-selected .dv-media__badge { display: flex; }

/* Protect images from casual copying / dragging / saving. */
img {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* (req 1) Mobile menu links must be clickable — force the offcanvas above
   everything and keep links interactive. */
.offcanvas { z-index: 1100 !important; }
.offcanvas-backdrop { z-index: 1090 !important; }
.offcanvas .offcanvas-body,
.offcanvas .main-nav,
.offcanvas .offcanvas-contacts,
.offcanvas .nav-link,
.offcanvas a,
.offcanvas .btn {
    pointer-events: auto !important;
    position: relative;
    z-index: 2;
}

/* Responsive (mobile/tablet) colour tweaks. */
@media (max-width: 991.98px) {
    /* Softer red / yellow surfaces. */
    .price-card--red { background-color: #E03328; }
    .price-card--yellow { background-color: #F5D253; }

    /* (req 2 / 3) Accent buttons become yellow on mobile (prices «Заказать
       разработку», блог «Перейти в блог», и т.п.). */
    .btn-accent,
    .btn-accent:hover,
    .btn-accent:focus,
    .btn-accent:active {
        --bs-btn-bg: #F5D253;
        --bs-btn-border-color: #F5D253;
        --bs-btn-hover-bg: #f2c93f;
        --bs-btn-hover-border-color: #f2c93f;
        --bs-btn-color: #101010;
        --bs-btn-hover-color: #101010;
        background-color: #F5D253;
        border-color: #F5D253;
        color: #101010;
    }

    /* (req 4) Compare block and footer background. */
    .compare { background-color: #E03328; }
    .site-footer { background-color: #E03328; }
}

/* (req 4) Divider lines between cases / services must have straight ends —
   remove the rounded corners the base accordion applies to first/last items. */
.cases .accordion-item,
.cases .accordion-item:first-of-type,
.cases .accordion-item:last-of-type,
.services .accordion-item,
.services .accordion-item:first-of-type,
.services .accordion-item:last-of-type,
.cases .accordion-button,
.services .accordion-button,
.cases .accordion-collapse,
.services .accordion-collapse {
    border-radius: 0 !important;
}

/* (req 5) Review author name aligned to the left edge of the text. */
.review-card {
    grid-template-columns: 1fr;
    grid-template-areas: "thumb" "author" "text" "link";
}
.review-card__thumb { width: clamp(88px, 26vw, 120px); }
.review-card__author {
    justify-self: start;
    text-align: left;
}

/* (req 2) Page preloader. */
#dv-preloader {
    position: fixed;
    inset: 0;
    z-index: 4000;
    background: #f2f2f2;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .4s ease, visibility .4s ease;
}
#dv-preloader.is-hidden {
    opacity: 0;
    visibility: hidden;
}
#dv-preloader .dv-preloader__spinner {
    width: 54px;
    height: 54px;
    border: 4px solid rgba(16, 16, 16, 0.12);
    border-top-color: #E03328;
    border-radius: 50%;
    animation: dvSpin .8s linear infinite;
}
@keyframes dvSpin { to { transform: rotate(360deg); } }

/* (Task) SEO-текст внутренних страниц — блок перед футером. */
.seo-text {
    padding-block: 8px 56px;
}
.seo-text__inner {
    /* На всю ширину блока, стандартный текст: 16px, regular. */
    color: inherit;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.7;
}
.seo-text__inner > :first-child { margin-top: 0; }
.seo-text__inner > :last-child { margin-bottom: 0; }
.seo-text__inner h2,
.seo-text__inner h3,
.seo-text__inner h4 {
    color: #101010;
    font-weight: 700;
    line-height: 1.25;
    margin: 1.4em 0 .5em;
}
.seo-text__inner h2 { font-size: clamp(20px, 2.4vw, 26px); }
.seo-text__inner h3 { font-size: clamp(18px, 2vw, 21px); }
.seo-text__inner h4 { font-size: 18px; }
.seo-text__inner p { margin: 0 0 1em; }
.seo-text__inner ul,
.seo-text__inner ol { margin: 0 0 1em; padding-left: 1.4em; }
.seo-text__inner li { margin-bottom: .4em; }
.seo-text__inner a { color: #E03328; text-decoration: underline; }
.seo-text__inner img { max-width: 100%; height: auto; border-radius: 12px; }

/* (Task) Этапы — на адаптивах изображение во всю ширину контейнера и БЕЗ
   обрезки: показываем в натуральных пропорциях (без aspect-ratio + cover). */
@media (max-width: 991.98px) {
    .stage__media { aspect-ratio: auto; }
    .stage__media img { height: auto; }
}

/* (Task) FAQ — ответ шире: 8 из 12 колонок на ПК, на всю ширину на мобильных. */
.faq .accordion-body { max-width: 100%; }
@media (min-width: 992px) {
    .faq .accordion-body { max-width: 66.6667%; }
}

/* (Task) Отзывы — имя автора всегда выровнено по левому краю текста отзыва.
   На ПК карточка — это flex-колонка, и базовое `align-self: center` у имени
   центрировало его по горизонтали; сбрасываем на левый край. */
.review-card__author { align-self: flex-start; }

/* На мобильных/планшетах фото сверху, а имя автора и текст идут под ним
   в столбик, выровненные по одному (левому) краю. */
@media (max-width: 991.98px) {
    .review-card { display: block; }
    .review-card__body { display: block; }
    .review-card__thumb { width: clamp(88px, 26vw, 120px); margin-bottom: 14px; }
    .review-card__author { margin-bottom: 8px; }
    .review-card__text { margin-bottom: 12px; }
}
