* { box-sizing: border-box; }

/* Семантическая дизайн-система: светлая тема по умолчанию.
   --color-primary/--color-accent/--font-family задаются из настроек в <head>. */
:root {
    --bg-primary: #ffffff;
    --bg-surface: #f4f5f7;
    --text-main: #1a1a1a;
    --text-muted: #666666;
    --border-color: #e1e3e8;

    /* Пресеты вертикальных отступов блоков (адаптивные через clamp). */
    --space-small: clamp(16px, 3vw, 28px);
    --space-premium: clamp(40px, 7vw, 96px);
    --space-max: clamp(72px, 12vw, 180px);
}

/* Тёмная тема: явное переключение через data-theme="dark". */
:root[data-theme="dark"] {
    --bg-primary: #14161c;
    --bg-surface: #1d212b;
    --text-main: #eceef3;
    --text-muted: #9aa2b1;
    --border-color: #2b303c;
}

/* Авто-тема: следуем системным настройкам, если тема не задана явно. */
@media (prefers-color-scheme: dark) {
    :root[data-theme="auto"] {
        --bg-primary: #14161c;
        --bg-surface: #1d212b;
        --text-main: #eceef3;
        --text-muted: #9aa2b1;
        --border-color: #2b303c;
    }
}

body {
    margin: 0;
    font-family: var(--font-family, sans-serif);
    color: var(--text-main);
    background: var(--bg-primary);
    line-height: 1.6;
    transition: background-color .3s ease, color .3s ease;
}

img { max-width: 100%; display: block; }
a { color: var(--color-accent, #e63946); }

/* Доступность (задача 122): видимый фокус на всех интерактивных элементах. */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible,
summary:focus-visible {
    outline: 3px solid var(--color-accent, #e63946);
    outline-offset: 2px;
    border-radius: 3px;
}
/* Ссылка «пропустить к содержимому» для клавиатуры/скринридеров. */
.skip-link {
    position: absolute; left: -999px; top: 0; z-index: 10000;
    background: var(--bg-surface); color: var(--text-main); padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

.site-header__inner { max-width: 1140px; margin: 0 auto; padding: 20px; display: flex; align-items: center; gap: 20px; }
.site-header__zone { display: flex; align-items: center; gap: 18px; }
.site-header__zone--left { justify-content: flex-start; }
.site-header__zone--center { justify-content: center; flex: 1; }
.site-header__zone--right { justify-content: flex-end; margin-left: auto; }
/* Когда логотип по центру, левая и правая зоны делят пространство поровну */
.site-header--logo-center .site-header__zone--left,
.site-header--logo-center .site-header__zone--right { flex: 1; }
.site-header--logo-center .site-header__zone--right { margin-left: 0; }

.site-menu { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.site-menu a, .site-menu__link { text-decoration: none; color: var(--color-primary, #1a1a1a); font-weight: 600; }
.site-menu a:hover, .site-menu__link:hover { color: var(--color-accent, #e63946); }

/* Выпадающее подменю (задача 3, группа 3) */
.site-menu__item { position: relative; }
.site-menu__item--has-children > .site-menu__link { display: inline-flex; align-items: center; gap: 4px; }
.site-menu__toggle { background: none; border: 0; cursor: pointer; font-size: 0.8em; color: inherit; padding: 0 2px; line-height: 1; }
.site-submenu {
    position: absolute; top: 100%; left: 0; min-width: 180px; z-index: 50;
    display: none; flex-direction: column; gap: 2px; padding: 8px;
    background: var(--bg-surface, #fff); border: 1px solid var(--border, #e0e0e0);
    border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.site-submenu__link { padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.site-submenu__link:hover { background: var(--bg-muted, #f2f2f2); }
/* Desktop: раскрытие по hover и по фокусу внутри пункта (клавиатура). */
@media (hover: hover) {
    .site-menu__item--has-children:hover > .site-submenu,
    .site-menu__item--has-children:focus-within > .site-submenu { display: flex; }
}
/* Явное раскрытие по клику/тапу (мобильные): JS ставит .is-open на пункт. */
.site-menu__item.is-open > .site-submenu { display: flex; }

.site-lang-switcher { display: flex; gap: 8px; }
.site-lang-switcher__item { text-decoration: none; color: #888; font-weight: 600; font-size: 14px; }
.site-lang-switcher__item.is-active { color: var(--color-primary, #1a1a1a); }

.site-social { display: flex; gap: 8px; }
.site-social__link {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--color-primary, #1a1a1a); color: #fff;
    text-decoration: none; font-weight: 700; font-size: 14px;
}

.site-cta {
    display: inline-block; padding: 9px 20px; border-radius: 8px;
    text-decoration: none; font-weight: 600; font-size: 14px;
}
.site-cta--filled { background: var(--color-accent, #e63946); color: #fff; }
.site-cta--outline { border: 2px solid var(--color-accent, #e63946); color: var(--color-accent, #e63946); }

.site-theme-toggle {
    background: transparent; border: 1px solid var(--border-color); color: var(--text-main);
    width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 16px; line-height: 1;
}

@media (max-width: 720px) {
    .site-header__inner { flex-wrap: wrap; }
    .site-header__zone { flex-wrap: wrap; gap: 12px; }
}

/* Раскладка с сайдбаром */
.layout { max-width: 1140px; margin: 0 auto; padding: 20px; display: grid; gap: 30px; }
.layout--left { grid-template-columns: 300px 1fr; }
.layout--right { grid-template-columns: 1fr 300px; }
@media (max-width: 860px) { .layout--left, .layout--right { grid-template-columns: 1fr; } }
.layout__sidebar { min-width: 0; }

.widget { margin-bottom: 28px; }
.widget__title { font-size: 18px; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 2px solid var(--color-accent, #e63946); }
.widget-latest-news, .widget-projects, .widget-team { list-style: none; margin: 0; padding: 0; }
.widget-latest-news li { margin-bottom: 12px; }
.widget-latest-news a { text-decoration: none; color: var(--color-primary, #1a1a1a); font-weight: 600; display: block; }
.widget-latest-news time { font-size: 12px; color: var(--text-muted); }
.widget-projects li, .widget-team li { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.widget-projects img, .widget-team img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; }
.widget-team div { display: flex; flex-direction: column; }
.widget-team span { font-size: 13px; color: var(--text-muted); }
.widget-contacts__line { margin: 6px 0; }
.widget-contacts__social { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.widget-social-link { font-size: 13px; text-decoration: none; color: var(--color-accent, #e63946); font-weight: 600; }
.widget-empty { color: var(--text-muted); font-size: 14px; }
.site-header__logo {
    display: inline-flex;
    align-items: center;
    font-weight: 700;
    font-size: 20px;
    text-decoration: none;
    color: var(--color-primary, #1a1a1a);
}
.site-header__logo img { max-height: 48px; }

.site-content { max-width: 1140px; margin: 0 auto; padding: 20px; }
.site-footer { text-align: center; padding: 30px 20px; color: var(--text-muted); font-size: 14px; }

/* Система «воздуха»: вертикальные отступы блоков через пресеты (clamp). */
.cms-block { margin: 0; padding: var(--space-premium) 0; }
.cms-block--space-none { padding: 0; }
.cms-block--space-small { padding: var(--space-small) 0; }
.cms-block--space-premium { padding: var(--space-premium) 0; }
.cms-block--space-max { padding: var(--space-max) 0; }

/* Микро-анимации появления при скролле (Intersection Observer, группа 4.2). */
.cms-block[data-reveal] { opacity: 0; transition: opacity .7s ease, transform .7s ease; }
.cms-block[data-reveal-type="slide-up"] { transform: translateY(28px); }
.cms-block[data-reveal-type="slide-left"] { transform: translateX(-32px); }
.cms-block[data-reveal-type="slide-right"] { transform: translateX(32px); }
.cms-block[data-reveal-type="zoom-in"] { transform: scale(.94); }
/* fade — только прозрачность (transform не нужен). */
.cms-block[data-reveal].is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
    .cms-block[data-reveal] { opacity: 1 !important; transform: none !important; transition: none; }
}

.block-text__title { font-size: 28px; margin-bottom: 12px; }

.block-cta { text-align: center; padding: 40px; background: var(--bg-surface); border-radius: 12px; }
.block-cta__button {
    display: inline-block;
    margin-top: 16px;
    padding: 12px 28px;
    background: var(--color-accent, #e63946);
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
}

.block-advantages__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 24px; }
.block-advantages__item { text-align: center; padding: 20px; }
.block-advantages__icon { font-size: 32px; margin-bottom: 8px; }

.block-slider { position: relative; overflow: hidden; border-radius: 12px; }
.block-slider__slide { display: none; }
.block-slider__slide.is-active { display: block; }
.block-slider__nav { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; pointer-events: none; padding: 0 12px; }
.block-slider__nav button {
    pointer-events: auto;
    background: rgba(0, 0, 0, .4);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
}

.block-gallery__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.block-gallery__item img { border-radius: 8px; }

.block-form__field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.block-form__field input, .block-form__field textarea {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
}
.block-form__submit {
    padding: 12px 24px;
    background: var(--color-primary, #1a1a1a);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}
.block-form__submit.is-loading { opacity: .7; cursor: progress; }

/* AJAX-состояния публичной формы (задача 67.1) */
.block-form__field.is-error input,
.block-form__field.is-error textarea { border-color: var(--color-accent, #e63946); }
.block-form__error { color: var(--color-accent, #e63946); font-size: 13px; }
.block-form__message { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 15px; }
.block-form__message--error { background: #fdecea; color: #c0392b; }
.block-form__thanks {
    padding: 24px; border-radius: 12px; background: var(--bg-surface);
    text-align: center; font-size: 18px; font-weight: 600; animation: fadeIn .4s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.site-alert { padding: 12px 18px; border-radius: 8px; margin-bottom: 20px; font-size: 15px; }
.site-alert--success { background: #e6f4ea; color: #1e7e34; }
.site-alert--error { background: #fdecea; color: #e63946; }

.news-list__item { display: flex; gap: 20px; margin-bottom: 30px; padding-bottom: 30px; border-bottom: 1px solid var(--border-color); }
.news-list__body h2 { margin: 6px 0; }
.news-list__body time { font-size: 13px; color: var(--text-muted); }

/* Обложка в списке новостей: адаптивная, с фокальной точкой */
.news-list__cover { position: relative; display: block; width: 220px; flex-shrink: 0; border-radius: 8px; overflow: hidden; aspect-ratio: 16 / 10; }
.news-list__cover picture, .news-list__img { display: block; width: 100%; height: 100%; }
.news-list__img { object-fit: cover; }
@media (max-width: 560px) { .news-list__item { flex-direction: column; } .news-list__cover { width: 100%; } }

/* Значок Play на видео-обложках */
.news-list__play, .news-video__play {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 64px; height: 64px; border-radius: 50%; border: none; cursor: pointer;
    background: rgba(0,0,0,.55);
}
.news-list__play::after, .news-video__play::after {
    content: ''; position: absolute; top: 50%; left: 54%; transform: translate(-50%, -50%);
    border-style: solid; border-width: 12px 0 12px 20px; border-color: transparent transparent transparent #fff;
}
.news-list__cover--video .news-list__play { pointer-events: none; }

.news-single time { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.news-single__cover { border-radius: 12px; overflow: hidden; margin-bottom: 20px; }
.news-single__cover-img { width: 100%; max-height: 520px; object-fit: cover; }
.news-single__back { margin-top: 28px; }

/* Раскладка «изображение сбоку» */
.news-side { display: grid; grid-template-columns: 320px 1fr; gap: 28px; align-items: start; }
.news-side__media { border-radius: 12px; overflow: hidden; position: sticky; top: 20px; }
.news-side__img { width: 100%; object-fit: cover; }
@media (max-width: 720px) { .news-side { grid-template-columns: 1fr; } .news-side__media { position: static; } }

/* Слайдер галереи новости */
.news-slider { position: relative; border-radius: 12px; overflow: hidden; margin-bottom: 24px; aspect-ratio: 16 / 9; background: var(--bg-surface); }
.news-slider__slide { position: absolute; inset: 0; opacity: 0; transition: opacity .4s ease; }
.news-slider__slide.is-active { opacity: 1; }
.news-slider__slide picture, .news-slider__img { width: 100%; height: 100%; display: block; }
.news-slider__img { object-fit: cover; }
.news-slider__nav {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
    width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
    background: rgba(0,0,0,.45); color: #fff; font-size: 26px; line-height: 1;
}
.news-slider__nav--prev { left: 12px; }
.news-slider__nav--next { right: 12px; }

/* Ленивый YouTube-плеер */
.news-video { position: relative; border-radius: 12px; overflow: hidden; margin-bottom: 24px; aspect-ratio: 16 / 9; background: #000; cursor: pointer; }
.news-video__thumb { width: 100%; height: 100%; object-fit: cover; }
.news-video__iframe { width: 100%; height: 100%; border: 0; display: block; }

/* Скелетон-заглушки (до загрузки медиа) */
.skeleton { position: relative; background: var(--bg-surface); }
.skeleton::before {
    content: ''; position: absolute; inset: 0; z-index: 1;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.18), transparent);
    background-size: 200% 100%; animation: skeleton-shimmer 1.3s ease-in-out infinite;
}
.skeleton > * { position: relative; z-index: 0; }
@keyframes skeleton-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton::before { animation: none; } }

/* --- Печатные стили (задача 63.2): чистый документ с логотипом и canonical --- */
.print-only { display: none; }
@media print {
    /* Скрываем всё «служебное»: шапку, сайдбары, футер, переключатель темы,
       соцкнопки, CTA, cookie-баннер, кнопки шеринга, слайдер-навигацию. */
    .site-header, .layout__sidebar, .site-footer, .site-theme-toggle,
    .site-social, .site-cta, .site-lang-switcher, .site-menu,
    .cookie-banner, .share-buttons, .news-slider__nav, .news-video__play,
    .news-single__back { display: none !important; }

    html, body { background: #fff !important; color: #000 !important; }
    a { color: #000 !important; text-decoration: none; }
    .site-content, .layout { max-width: none; margin: 0; padding: 0; display: block; }
    .cms-block, .cms-block[data-reveal] { opacity: 1 !important; transform: none !important; padding: 12px 0 !important; }
    img, picture { max-width: 100% !important; }

    /* Печатная «шапка»: логотип и адрес страницы. */
    .print-only { display: block !important; }
    .print-header { margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid #000; }
    .print-header img { max-height: 48px; }
    .print-header .print-name { font-size: 20px; font-weight: 700; }
    .print-footer { margin-top: 18px; padding-top: 10px; border-top: 1px solid #000; font-size: 12px; color: #000; }
    /* Раскрываем ссылки после текста, где это уместно. */
    .news-single__content a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 11px; }
}

/* Cookie-Consent баннер (задача 116) */
.cookie-banner {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 9998;
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
    padding: 14px 20px; background: var(--bg-surface); border-top: 1px solid var(--border-color);
    box-shadow: 0 -6px 20px rgba(0,0,0,.08); font-size: 14px;
}
.cookie-banner__text { flex: 1; min-width: 220px; color: var(--text-main); }
.cookie-banner__text a { color: var(--color-accent, #e63946); }
.cookie-banner__accept, .cookie-banner__decline {
    padding: 9px 18px; border-radius: 8px; cursor: pointer; font-weight: 600; border: 1px solid var(--border-color);
}
.cookie-banner__accept { background: var(--color-accent, #e63946); color: #fff; border-color: transparent; }
.cookie-banner__decline { background: transparent; color: var(--text-main); }

/* Лайтбокс для блоков галереи */
.cms-lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: none; align-items: center; justify-content: center; z-index: 9999; padding: 20px; }
.cms-lightbox.is-open { display: flex; }
.cms-lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 8px; }
.cms-lightbox__close { position: absolute; top: 16px; right: 20px; background: none; border: none; color: #fff; font-size: 40px; line-height: 1; cursor: pointer; }

/* Полоса предпросмотра (группа 5.2) */
.preview-bar {
    position: sticky; top: 0; z-index: 9999; text-align: center;
    background: #b45309; color: #fff; padding: 8px 16px; font-weight: 600; font-size: 14px;
}
body.is-preview { outline: 3px solid #b45309; outline-offset: -3px; }

/* Блок «Колонки» (группа 4.1) */
.cms-columns { display: grid; }
.cms-columns--2 { grid-template-columns: repeat(2, 1fr); }
.cms-columns--3 { grid-template-columns: repeat(3, 1fr); }
.cms-columns--4 { grid-template-columns: repeat(4, 1fr); }
.cms-columns--gap-small { gap: 12px; }
.cms-columns--gap-medium { gap: 28px; }
.cms-columns--gap-large { gap: 48px; }
/* Вложенные блоки не добавляют собственный вертикальный «воздух». */
.cms-columns__col > .cms-block { padding-top: 0; padding-bottom: 0; }
@media (max-width: 720px) { .cms-columns--2, .cms-columns--3, .cms-columns--4 { grid-template-columns: 1fr; } }

/* Новые блоки (группа 4): отзывы, счётчики, команда, проекты */
.block-testimonials__title, .block-counters__title, .block-team__title, .block-projects__title {
    text-align: center; margin: 0 0 28px;
}
.block-testimonials__track {
    display: flex; gap: 20px; overflow-x: auto; scroll-snap-type: x mandatory;
    padding-bottom: 10px; scrollbar-width: thin;
}
.testimonial {
    scroll-snap-align: start; flex: 0 0 min(360px, 85%); margin: 0;
    background: var(--bg-surface); border-radius: 12px; padding: 24px; text-align: center;
}
.testimonial__photo { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; margin: 0 auto 14px; }
.testimonial__quote { margin: 0 0 14px; font-style: italic; }
.testimonial__name { display: block; font-weight: 700; }
.testimonial__company { color: var(--text-muted); font-size: 14px; }

.block-counters__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 24px; text-align: center; }
.counter__value, .counter__suffix { font-size: clamp(32px, 5vw, 56px); font-weight: 800; color: var(--color-accent, #e63946); line-height: 1; }
.counter__suffix { margin-left: 2px; }
.counter__label { margin-top: 8px; color: var(--text-muted); }

.block-team__grid, .block-projects__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px; }
.team-card { text-align: center; }
.team-card__photo { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 12px; margin-bottom: 12px; }
.team-card__name { font-weight: 700; }
.team-card__position { color: var(--text-muted); font-size: 14px; }
.project-card { display: block; text-decoration: none; color: inherit; background: var(--bg-surface); border-radius: 12px; overflow: hidden; }
.project-card__cover { width: 100%; aspect-ratio: 16/10; object-fit: cover; }
.project-card__title { font-weight: 700; padding: 12px 14px 0; }
.project-card__desc { padding: 6px 14px 14px; margin: 0; color: var(--text-muted); font-size: 14px; }
.block-team__empty, .block-projects__empty { text-align: center; color: var(--text-muted); }

/* SVG-иконка в блоке преимуществ (группа 4.3) */
.block-advantages__icon--svg svg { width: 48px; height: 48px; display: block; margin: 0 auto; }
.block-advantages__icon--svg svg [fill]:not([fill="none"]) { fill: currentColor; }

/* FAQ / аккордеон (группа 6) */
.block-faq__title { text-align: center; margin: 0 0 24px; }
.block-faq__list { max-width: 760px; margin: 0 auto; }
.faq-item { border-bottom: 1px solid var(--border-color); }
.faq-item__q { cursor: pointer; padding: 16px 0; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.faq-item__q::after { content: '+'; font-size: 22px; color: var(--color-accent, #e63946); margin-left: 12px; }
.faq-item[open] .faq-item__q::after { content: '−'; }
.faq-item__q::-webkit-details-marker { display: none; }
.faq-item__a { padding: 0 0 16px; color: var(--text-muted); }
