/* MihDev CMS — frontend (mobile-first).
   Переменные темы (--c-*, --f-*, --fw-*, --fs-*) инжектятся в <style> лейаутом. */

*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: var(--f-body);
    font-weight: var(--fw-body);
    font-size: var(--fs-base);
    line-height: 1.6;
    color: var(--c-text);
    /* Фон всего сайта (фаза 1.5): цвет из layout.page, фолбэк — тема.
       Картинка — на слое body::before ниже (этап 50). */
    background-color: var(--page-bg, var(--c-bg));
}

/* Фон сайта — картинка (этап 50): фиксированный полноэкранный слой ПОД всем
   содержимым. Точно в размер экрана независимо от размера оригинала
   (большая уменьшается, маленькая растягивается), при скролле не двигается —
   поэтому фон виден и под липкой шапкой на любой длине страницы. */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    background-image: var(--page-bg-image, none);
    background-size: 100% 100%;
    pointer-events: none;
}

/* Мобильная версия картинки (телефоны ≤768px) — меньший файл.
   Если её нет (старые загрузки) — фолбэк на оригинал. */
@media (max-width: 768px) {
    body::before {
        background-image: var(--page-bg-image-mobile, var(--page-bg-image, none));
    }
}

/* Фон главной страницы (этап 51): слой ПОД содержимым, НАД общим фоном сайта
   (тот же z-index, но ::after рисуется после ::before). Активен только на
   body.page-home и только когда в «Дизайне → Главная страница» что-то задано;
   иначе --home-bg-image = none и слой пустой. Вписывается в экран целиком —
   как фон сайта (крупная уменьшается, мелкая растягивается). */
body.page-home::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    background-image: var(--home-bg-image, none);
    background-size: 100% 100%;
    pointer-events: none;
}

/* Мобильная версия картинки (телефоны ≤768px) — как у фона сайта. */
@media (max-width: 768px) {
    body.page-home::after {
        background-image: var(--home-bg-image-mobile, var(--home-bg-image, none));
    }
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--c-link); text-decoration: none; }
a:hover { color: var(--c-accent); }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* ---------- Шапка ---------- */
/* transition (этап 69): фон при скролле (.is-scrolled) и тень «собираются»
   плавно, без дёргания. */
.site-header { background-color: var(--header-bg, var(--c-bg)); background-image: var(--header-bg-image, none); background-size: cover; background-position: center; border-bottom: 1px solid rgba(0, 0, 0, .08); position: sticky; top: 0; z-index: 10; transition: background-color .2s ease, box-shadow .2s ease; }
.site-header.is-static { position: static; }
/* has-shadow — статический стиль из настроек макета; is-scrolled — динамическая
   тень при прокрутке (этап 47, ставится JS'ом для sticky-шапки). */
.site-header.has-shadow, .site-header.is-scrolled { box-shadow: 0 2px 12px rgba(0, 0, 0, .08); border-bottom-color: transparent; }
/* Высота шапки (редактор макета): compact / normal / large — через переменную */
.site-header.size-compact { --header-pad-y: 8px; }
.site-header.size-normal { --header-pad-y: 12px; }
.site-header.size-large { --header-pad-y: 20px; }
.site-header__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding-top: var(--header-pad-y, 12px); padding-bottom: var(--header-pad-y, 12px); }
/* Этап 57: --header-text — цвет названия сайта из «Дизайна», пусто = цвет темы */
.site-brand { display: inline-flex; align-items: center; font-family: var(--f-heading); font-weight: var(--fw-heading); font-size: calc(var(--fs-base) * 1.25); color: var(--header-text, var(--c-text)); }
.site-brand:hover { color: var(--c-accent); }
/* Ширина логотипа (image-логотип): переменная из макета, по умолчанию 160px */
.site-brand img { max-height: 48px; width: var(--logo-width, 160px); }

/* Мобильная шапка (фаза 3): высота и ширина логотипа. Блок стоит ПОСЛЕ
   базовых правил — при равной специфичности побеждает более поздний. */
@media (max-width: 959.98px) {
    .site-header.size-mobile-compact { --header-pad-y: 8px; }
    .site-header.size-mobile-normal { --header-pad-y: 12px; }
    .site-header.size-mobile-large { --header-pad-y: 20px; }
    .site-brand img { width: var(--logo-width-mobile, var(--logo-width, 160px)); }
}

/* Навигация: на мобильных скрыта (открывается гамбургером), видна от 960px */
.site-nav { display: none; flex-wrap: wrap; gap: 4px 16px; }
/* Этап 57: --header-link — цвет пунктов меню, пусто = «Цвет ссылок»; hover и
   активный пункт остаются акцентом (правила ниже по специфичности). */
.site-nav a { padding: 6px 2px; font-weight: 500; border-bottom: 2px solid transparent; color: var(--header-link, var(--c-link)); }
.site-nav a:hover { color: var(--c-accent); }
.site-nav a.is-active { color: var(--c-accent); border-bottom-color: var(--c-accent); }
/* Модификаторы меню (редактор макета) */
.site-nav.is-uppercase { text-transform: uppercase; letter-spacing: .04em; font-size: calc(var(--fs-base) * .95); }
.site-nav.active-color a.is-active { border-bottom-color: transparent; font-weight: 700; }

/* Гамбургер (виден только ниже 960px) */
.nav-toggle { display: inline-flex; flex-direction: column; justify-content: center; gap: 5px; width: 42px; height: 38px; padding: 9px 10px; background: none; border: 1px solid rgba(0, 0, 0, .15); border-radius: 8px; cursor: pointer; }
/* Палочки гамбургера следуют за цветом текста шапки (этап 57). */
.nav-toggle span { display: block; width: 100%; height: 2px; background: var(--header-text, var(--c-text)); border-radius: 2px; }

/* Мобильное меню: панель справа + оверлей (видимо только ниже 960px) */
.mobile-menu { position: fixed; inset: 0; z-index: 50; visibility: hidden; pointer-events: none; }
.mobile-menu.is-open { visibility: visible; pointer-events: auto; }
.mobile-menu__overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); opacity: 0; transition: opacity .2s ease; }
.mobile-menu.is-open .mobile-menu__overlay { opacity: 1; }
.mobile-menu__panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(320px, 85vw); background-color: var(--menu-mobile-bg, var(--c-bg)); background-image: var(--menu-mobile-bg-image, none); background-size: cover; background-position: center; box-shadow: -8px 0 24px rgba(0, 0, 0, .15); transform: translateX(100%); transition: transform .2s ease; }
.mobile-menu.is-open .mobile-menu__panel { transform: translateX(0); }
.mobile-menu__panel nav { padding: 76px 24px 24px; height: 100%; overflow-y: auto; }
/* Этап 57: --menu-mobile-text — цвет пунктов, пусто = «Цвет ссылок»; активный
   остаётся акцентом (правило ниже). */
.mobile-menu__panel a { display: block; padding: 12px 4px; font-size: calc(var(--fs-base) * 1.05); font-weight: 500; border-bottom: 1px solid rgba(0, 0, 0, .08); color: var(--menu-mobile-text, var(--c-link)); }
.mobile-menu__panel a.is-active { color: var(--c-accent); }
/* Стиль активного пункта (редактор макета): в мобильном меню нет подчёркивания,
   поэтому «акцентный цвет» = акцент + полужирный. */
.mobile-menu__panel nav.active-color a.is-active { font-weight: 700; }

/* ---------- Основное ---------- */
.site-main { min-height: 60vh; padding: 32px 0 48px; }

.page-head { margin-bottom: 24px; }
.page-head h1 { margin: 0 0 8px; font-size: var(--fs-h1); }
.page-head p { margin: 0; opacity: .7; max-width: 60ch; }

/* Фон hero — из настроек дизайна (блок «Главный экран», --hero-bg*);
   дефолт — прозрачный. */
.hero { text-align: center; padding: 48px 0 40px; background-color: var(--hero-bg, transparent); background-image: var(--hero-bg-image, none); background-size: var(--hero-bg-size, cover); background-position: center; background-repeat: no-repeat; }
/* Этап 53: высота области hero (из «Дизайна»). Класс ставит home.blade.php
   и sections/hero.blade.php ТОЛЬКО при явных px, подогнанных мышкой —
   дефолтный hero без класса и переменных не меняется. Режимы подгонки
   картинки (cover/contain/stretch) работают внутри области и её высоту
   не меняют.
   aspect-ratio из --hero-ar: 1088 / N (пропорция от референсной ширины):
   при ширине 1088px высота = ровно N px, на любой другой ширине —
   пропорционально ширине экрана (375px → ×0.34). Контент + padding могут
   РАЗОГНать область, но не сожмут: aspect-ratio — предпочтительная пропорция.
   Браузеры без aspect-ratio (до 2021 г.) — фолбэк на фиксированные px. */
.hero--sized { aspect-ratio: var(--hero-ar, auto); display: flex; flex-direction: column; align-items: center; justify-content: center; }
@supports not (aspect-ratio: 1) { .hero--sized { min-height: var(--hero-min-h, auto); } }
/* Этап 57: --hero-text — цвет названия/слогана из «Дизайна», пусто = цвет темы */
.hero h1 { margin: 0 0 12px; font-size: var(--fs-h1); color: var(--hero-text, var(--c-text)); }
.hero p { margin: 0 auto 24px; max-width: 56ch; opacity: .75; font-size: calc(var(--fs-base) * 1.05); color: var(--hero-text, var(--c-text)); }
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

.btn { display: inline-block; padding: 10px 22px; border-radius: 10px; font-weight: 600; line-height: 1.4; border: 1px solid transparent; }
.btn:hover { color: #fff; background: var(--c-accent); border-color: var(--c-accent); }
.btn--primary { background: var(--c-link); border-color: var(--c-link); color: #fff; }
.btn--primary:hover { background: var(--c-accent); }
.btn--ghost { border-color: currentColor; }

/* ---------- Секции и карточки ---------- */
.section { margin-top: 48px; }
/* Отступы и скругление — только когда у секции есть фон (класс .has-bg ставит вьюха) */
.section.has-bg { padding: 32px 24px; border-radius: 16px; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section__head h2 { margin: 0; font-size: var(--fs-h2); }
.section__more { white-space: nowrap; font-weight: 600; }

/* Секции редактора шаблонов */
.section__text { max-width: 80ch; line-height: 1.65; }
.section__text h2, .section__text h3, .section__text h4 { margin: 20px 0 8px; line-height: 1.3; }
.section__text p { margin: 0 0 12px; }
.section__text ul, .section__text ol { margin: 0 0 12px; padding-left: 24px; }
.section__image { margin: 0; text-align: center; }
.section__image img { max-width: 100%; border-radius: 14px; }
.section__image--left { text-align: left; }
.section__image--right { text-align: right; }
.section__image figcaption { margin-top: 8px; opacity: .7; font-size: calc(var(--fs-base) * .9); }

.grid { display: grid; gap: 20px; grid-template-columns: 1fr; }

/* Этап 72: --card-bg — «Дизайн → Фон и контент → Фон карточек»; пусто —
   цвет темы (--c-bg), поведение как до этапа. */
.card { display: flex; flex-direction: column; background: var(--card-bg, var(--c-bg)); border: 1px solid rgba(0, 0, 0, .08); border-radius: 14px; overflow: hidden; transition: transform .15s ease, box-shadow .15s ease; }
/* Hover-эффект карточек (этап 40): единый для галереи, новостей, портфолио
   и каталога. Переменные --card-hover-* обнуляются из LayoutService::css(),
   если эффект выключен в «Настройки → Дизайн → Эффекты». */
a.card:hover, article.card:hover { transform: translateY(var(--card-hover-lift, -2px)); box-shadow: var(--card-hover-shadow, 0 8px 24px rgba(0, 0, 0, .10)); }
.card__media { aspect-ratio: 16 / 9; overflow: hidden; background: rgba(0, 0, 0, .05); }
.card__media img { width: 100%; height: 100%; object-fit: cover; }
.card__body { display: flex; flex-direction: column; gap: 8px; padding: 16px; flex: 1; }
.card__title { margin: 0; font-size: var(--fs-h3); line-height: 1.3; }
a.card:hover .card__title, article.card:hover .card__title { color: var(--card-hover-title, var(--c-accent)); }
.card__excerpt { margin: 0; opacity: .75; font-size: calc(var(--fs-base) * .95); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card__meta { margin-top: auto; padding-top: 8px; font-size: calc(var(--fs-base) * .85); opacity: .6; }
/* Бейдж категории в карточке новости (этап 20) */
.card__category { display: inline-block; margin-right: 10px; padding: 1px 10px; border-radius: 999px; background: rgba(0, 0, 0, .08); font-size: calc(var(--fs-base) * .85); opacity: 1; }
.card__category:hover { color: var(--c-accent); background: rgba(0, 0, 0, .14); }

/* ---------- Блоки конструктора (фаза 2) ---------- */
.divider { border: none; border-top: 1px solid rgba(0, 0, 0, .15); margin: 8px 0; }
.divider--dashed { border-top-style: dashed; }
.divider--dotted { border-top-style: dotted; }

.quote { margin: 0 auto; max-width: 720px; padding: 8px 24px; border-left: 4px solid var(--c-accent); font-size: calc(var(--fs-base) * 1.15); line-height: 1.6; }
.quote p { margin: 0 0 8px; }
.quote cite { display: block; opacity: .7; font-style: normal; font-size: calc(var(--fs-base) * .95); }

.section--cta { max-width: 720px; margin-left: auto; margin-right: auto; text-align: center; }
.section--cta h2 { margin: 0 0 12px; font-size: var(--fs-h2); }
.section--cta p { margin: 0 auto 20px; opacity: .8; max-width: 56ch; }

.video-embed { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: rgba(0, 0, 0, .05); }
.video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-embed__caption { margin: 8px 0 0; opacity: .7; font-size: calc(var(--fs-base) * .9); text-align: center; }

.columns { display: grid; gap: 24px; grid-template-columns: 1fr; }
.columns__item h3 { margin: 0 0 8px; font-size: var(--fs-h3); }

.feature { background: var(--c-bg); border: 1px solid rgba(0, 0, 0, .08); border-radius: 14px; padding: 20px; }
.feature h3 { margin: 0 0 8px; font-size: var(--fs-h3); }
.feature p { margin: 0; opacity: .75; }

/* Этап 62: форма — по центру секции (max-width + авто-поля, как у CTA).
   Текст внутри полей центрируем НЕ — только сам блок. */
.section--form .section__head { justify-content: center; }
.section--form-intro { opacity: .8; max-width: 60ch; margin: 0 auto 16px; }
/* Анти-спам ханипот: за экраном, для людей невидим. Намеренно НЕ
   display:none — часть ботов пропускает такие поля, а «за экраном» его
   видят и заполняют. */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Фича «Файлы»: секция со ссылкой на скачивание + счётчик. */
.section--file { text-align: center; }
.file-count { margin-top: 10px; color: var(--c-text); opacity: .65; font-size: calc(var(--fs-base, 1rem) * .9); }

.contact-form { display: grid; gap: 14px; max-width: 560px; margin: 0 auto; }
.contact-form label { display: grid; gap: 6px; font-weight: 500; }
.contact-form input, .contact-form textarea { width: 100%; padding: 10px 12px; border: 1px solid rgba(0, 0, 0, .2); border-radius: 10px; font: inherit; background: var(--c-bg); color: inherit; }
.contact-form input:focus, .contact-form textarea:focus { outline: 2px solid var(--c-accent); outline-offset: 1px; }
.form-success { padding: 16px 20px; border-radius: 12px; background: rgba(34, 197, 94, .12); border: 1px solid rgba(34, 197, 94, .4); max-width: 560px; margin: 0 auto; }
.form-errors { padding: 12px 16px; margin: 0 auto 16px; border-radius: 12px; background: rgba(239, 68, 68, .1); border: 1px solid rgba(239, 68, 68, .4); max-width: 560px; }
.form-errors ul { margin: 0; padding-left: 18px; }

/* ---------- Статья ---------- */
.article { max-width: 780px; margin: 0 auto; }

/* Область вывода контента (фаза 1.5): фон из layout.content или override айтема.
   Этап 51: подложка вписывается в область целиком (как фон сайта), без кропа —
   крупная картинка уменьшается, мелкая растягивается под размер области. */
.article, .gallery-section {
    background-color: var(--content-bg, transparent);
    background-image: var(--content-bg-image, none);
    background-size: 100% 100%;
}
/* Отступы и скругление — только когда фон есть (класс .has-bg ставит вьюха) */
.article.has-bg, .gallery-section.has-bg { padding: 24px; border-radius: 16px; }
.article h1 { font-size: var(--fs-h1); line-height: 1.2; margin: 0 0 8px; }
/* Этап 67: цвет заголовков из «Дизайна» (ThemeService → --c-heading).
   Пусто = inherit — наследуют цвет текста, поведение как до этапа. */
.section__head h2, .section--cta h2, .article h1,
.article__content h2, .article__content h3, .article__content h4 { color: var(--c-heading, inherit); }
/* Этап 66: хлебные крошки на страницах новостей/портфолио. */
.breadcrumbs { margin-bottom: 14px; font-size: calc(var(--fs-base) * .85); opacity: .75; overflow-wrap: anywhere; }
.breadcrumbs a { color: inherit; text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs__sep { margin: 0 8px; opacity: .7; }
.article__meta { opacity: .65; margin-bottom: 16px; font-size: calc(var(--fs-base) * .9); }
.article__cover { border-radius: 14px; margin-bottom: 24px; width: 100%; object-fit: cover; }
/* Этап 63: портфолио — витрина презентаций. Страницы PDF (WebP, рендер при
   сохранении) выводятся крупно, постранично вниз; статья с презентацией
   шире стандартной колонки (article--wide в вьюхе). */
.article--wide { max-width: 960px; }
.article__lead { font-size: calc(var(--fs-base) * 1.1); opacity: .8; margin: 0 0 24px; line-height: 1.6; }
.presentation { margin: 0 0 8px; }
.presentation__page { display: block; width: 100%; height: auto; border-radius: 10px; box-shadow: 0 2px 12px rgba(0, 0, 0, .15); margin-bottom: 24px; background: #fff; }
.presentation__page:last-child { margin-bottom: 0; }
.article__content { line-height: 1.7; }
.article__content p { margin: 0 0 1em; }
.article__content h2, .article__content h3, .article__content h4 { margin: 1.6em 0 .6em; line-height: 1.25; }
.article__content img { border-radius: 10px; margin: 16px 0; max-width: 100%; height: auto; }
/* Фича «Файлы» (статья о плагинах): списки и код в теле статьи.
   Тёмная плашка для pre — читается и на светлой, и на тёмной теме;
   инлайновый code — полупрозрачный фон, адаптивный к цвету текста. */
.article__content ul, .article__content ol { margin: 0 0 1em; padding-left: 1.4em; }
.article__content li { margin-bottom: .35em; }
.article__content code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; background-color: color-mix(in srgb, currentColor 10%, transparent); border-radius: 4px; padding: .1em .35em; }
.article__content pre { background-color: #1e1e28; color: #e8e8f0; border-radius: 10px; padding: 14px 16px; overflow-x: auto; margin: 0 0 1em; line-height: 1.5; }
.article__content pre code { background: none; padding: 0; color: inherit; font-size: .88em; }
/* Картинки из редактора (Trix-вложения, этап 52): обёртка figure + классы
   выравнивания/обтекания mih-img-*. Ширина — атрибут width на <img>;
   классы ставит скрипт в layouts/app.blade.php по JSON вложения
   (data-trix-attachment: align/float), стили ниже. */
.article__content figure { margin: 0; }
.article__content figcaption:empty { display: none; }
.article__content figure.attachment { margin: 16px 0; }
.article__content figure.attachment img { display: block; margin: 0; max-width: 100%; height: auto; }
/* По центру: картинка на своей строке, по центру колонки */
.article__content figure.attachment.mih-img-center { text-align: center; }
.article__content figure.attachment.mih-img-center img { display: inline-block; vertical-align: middle; }
/* Вправо без обтекания: на своей строке у правого края */
.article__content figure.attachment.mih-img-right:not(.mih-img-float) img { margin-left: auto; }
/* Обтекание текстом: картинка прижата к левому/правому краю, текст идёт рядом */
.article__content figure.attachment.mih-img-float img { float: left; margin: 4px 16px 8px 0; }
.article__content figure.attachment.mih-img-right.mih-img-float img { float: right; margin: 4px 0 8px 16px; }
/* Подпись: дефолтная Trix («имя файла + размер») скрыта, добавленная
   редактором вручную (класс --edited) показывается. */
.article__content figure.attachment figcaption { font-size: .85em; opacity: .7; margin-top: 6px; }
.article__content figure.attachment figcaption:not(.attachment__caption--edited) { display: none; }
.article__content ul, .article__content ol { padding-left: 1.4em; margin: 0 0 1em; }
.article__content blockquote { margin: 1.2em 0; padding: .4em 1em; border-left: 4px solid var(--c-accent); background: rgba(0, 0, 0, .03); }
.article__content a { text-decoration: underline; }
.article__actions { margin-top: 32px; display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- Пустые состояния, подвал, пагинация ---------- */
.empty { padding: 48px 16px; text-align: center; border: 1px dashed rgba(0, 0, 0, .2); border-radius: 14px; opacity: .75; }
.empty p { margin: 0 0 16px; }

.site-footer { background-color: var(--footer-bg, transparent); background-image: var(--footer-bg-image, none); background-size: cover; background-position: center; color: var(--footer-text, inherit); border-top: 1px solid rgba(0, 0, 0, .08); padding: 20px 0; font-size: calc(var(--fs-base) * .9); text-align: center; }
.site-footer p { margin: 0; }
/* Брендинг «Работает на mihdev-cms»: мельче и приглушённее строки подвала. */
.site-footer__powered { margin-top: 6px; font-size: .85em; opacity: .75; }
.site-footer__powered a { color: inherit; text-decoration: none; border-bottom: 1px solid currentColor; }
.site-footer__powered a:hover { color: var(--c-accent); border-bottom-color: var(--c-accent); }

.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 32px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 6px 12px; border-radius: 8px; border: 1px solid rgba(0, 0, 0, .15); }
.pagination span.is-active { background: var(--c-link); border-color: var(--c-link); color: #fff; }

/* ---------- Эффекты оформления (этап 47): базовая полировка.
   Все анимации уважают prefers-reduced-motion; без JS эффекты не
   применяются вовсе (контент всегда видим). ---------- */

/* Плавные ховер-состояния: цвета меняются постепенно, а не мгновенно.
   У .card свой transition (transform/box-shadow) — он приоритетнее. */
a, .btn { transition: color .15s ease, background-color .15s ease, border-color .15s ease; }
.site-nav a { transition: color .15s ease, border-color .15s ease; }
.card__title { transition: color .15s ease; }
.gallery-tabs a, .news-filters a, .pagination a { transition: color .15s ease, background-color .15s ease, border-color .15s ease; }

/* Выделение текста — мягкая тонировка в цвет акцента. */
::selection { background: color-mix(in srgb, var(--c-accent, #2563eb) 25%, transparent); }

/* Плавный скролл к якорям + отступ под sticky-шапку. */
html { scroll-padding-top: 90px; }
@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

/* Fade-in картинок при загрузке: классы ставит JS (см. лейаут). */
img.fx-fade { opacity: 0; transition: opacity .3s ease; }
img.fx-fade.is-loaded { opacity: 1; }

/* Появление секций при прокрутке: атрибут data-reveal ставит JS, когда
   эффект включён в «Настройки → Дизайн → Эффекты». */
[data-reveal] { opacity: 0; transform: translateY(12px); transition: opacity .3s ease, transform .3s ease; }
[data-reveal].is-visible { opacity: 1; transform: none; }

/* prefers-reduced-motion: анимации отключены, контент виден сразу. */
@media (prefers-reduced-motion: reduce) {
    img.fx-fade, [data-reveal] { transition: none; }
    [data-reveal] { opacity: 1; transform: none; }
}

/* ---------- Брейкпоинты (mobile-first) ---------- */
@media (min-width: 640px) {
    .grid { grid-template-columns: repeat(2, 1fr); }
    .grid--1 { grid-template-columns: 1fr; }
    .columns { grid-template-columns: repeat(2, 1fr); }
    .site-main { padding: 48px 0 64px; }
}

@media (min-width: 960px) {
    .grid--3 { grid-template-columns: repeat(3, 1fr); }
    .columns--3 { grid-template-columns: repeat(3, 1fr); }

    /* Десктоп: обычная навигация; гамбургер и мобильное меню не нужны */
    .site-nav { display: flex; }
    .nav-toggle, .mobile-menu { display: none; }
}

/* ---------- Галерея и категории новостей (общий стиль чипов) ---------- */
.gallery-tabs, .news-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.gallery-tabs a, .news-filters a { padding: 6px 14px; border-radius: 999px; border: 1px solid rgba(0, 0, 0, .15); font-weight: 500; }
.gallery-tabs a:hover, .news-filters a:hover { color: var(--c-accent); border-color: var(--c-accent); }
.gallery-tabs a.is-active, .news-filters a.is-active { background: var(--c-link); border-color: var(--c-link); color: #fff; }

.gallery-section { margin-top: 32px; }
.gallery-section:first-of-type { margin-top: 0; }
.gallery-section__title { font-size: var(--fs-h2); margin: 0 0 16px; }

.gallery-grid { columns: 160px; column-gap: 12px; }
.gallery-item { break-inside: avoid; margin: 0 0 12px; border-radius: 12px; overflow: hidden; cursor: zoom-in; position: relative; background: rgba(0, 0, 0, .05); transition: transform .3s ease, box-shadow .3s ease; }
/* Hover-zoom ×2 (этап 26): увеличивается САМА карточка целиком и ложится
   поверх соседей (z-index + тень) — вся фотография видна крупнее перед
   полным просмотром. Увеличение от центра: курсор остаётся внутри,
   мерцания hover нет. */
.gallery-item img { width: 100%; display: block; }
/* Zoom отключается переменной --gallery-zoom-scale из LayoutService::css()
   («Настройки → Дизайн → Эффекты»): scale(1) + без тени. */
.gallery-item:hover { transform: scale(var(--gallery-zoom-scale, 2)); z-index: 2; box-shadow: var(--gallery-zoom-shadow, 0 12px 32px rgba(0, 0, 0, .25)); }
.gallery-item figcaption { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 10px 8px; font-size: calc(var(--fs-base) * .85); color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .65)); opacity: 0; transition: opacity .2s ease; }
.gallery-item:hover figcaption { opacity: 1; }

/* Лайтбокс (нативный <dialog>) */
.lightbox { width: 100vw; height: 100vh; max-width: 100%; max-height: 100%; padding: 0; border: none; background: transparent; display: flex; align-items: center; justify-content: center; transition: opacity .2s ease; }
/* Ловушка: display:flex выше перебивает UA-скрытие ЗАКРЫТОГО <dialog> — без этого
   после close() он рендерился position:absolute (UA) в своём месте в DOM: ящик
   100vw×100vh с последним фото поверх футера. В закрытом состоянии скрываем явно. */
.lightbox:not([open]) { display: none; }
.lightbox::backdrop { background: rgba(0, 0, 0, .85); transition: opacity .2s ease; }
/* Анимация открытия/закрытия (этап 47): открытие — @starting-style,
   закрытие — класс .is-closing (JS держит dialog до конца перехода). */
@starting-style {
    .lightbox[open] { opacity: 0; }
    .lightbox[open]::backdrop { opacity: 0; }
}
.lightbox.is-closing, .lightbox.is-closing::backdrop { opacity: 0; }
@media (prefers-reduced-motion: reduce) {
    .lightbox, .lightbox::backdrop { transition: none; }
}
.lightbox__figure { margin: 0; display: flex; flex-direction: column; gap: 10px; align-items: center; max-width: 92vw; }
.lightbox__img { max-width: 92vw; max-height: 76vh; border-radius: 10px; object-fit: contain; }
.lightbox__caption { color: #fff; font-size: calc(var(--fs-base) * .95); text-align: center; padding: 0 16px; }
/* Этап 31: строки подписи — название / описание / автор. */
.lightbox__caption-title { font-weight: 600; }
.lightbox__caption-desc { color: rgba(255, 255, 255, .85); margin-top: 4px; }
.lightbox__caption-author { color: rgba(255, 255, 255, .65); font-size: calc(var(--fs-base) * .85); margin-top: 4px; }
.lightbox__counter { color: rgba(255, 255, 255, .65); font-size: calc(var(--fs-base) * .8); text-align: center; }
.lightbox__close, .lightbox__nav { position: absolute; z-index: 1; background: rgba(255, 255, 255, .14); color: #fff; border: none; border-radius: 999px; width: 44px; height: 44px; font-size: 26px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.lightbox__close:hover, .lightbox__nav:hover { background: rgba(255, 255, 255, .3); }
.lightbox__close { top: 16px; right: 16px; }
.lightbox__nav--prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lightbox__nav--next { right: 16px; top: 50%; transform: translateY(-50%); }

/* Превью шаблона (редактор, админка) */
.preview-banner {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #b45309;
    color: #fff;
    text-align: center;
    font-size: 14px;
    line-height: 1.4;
    padding: 8px 16px;
}

/* ---------- Поиск (этап 20) ---------- */
/* Компактная форма в шапке: видима только на desktop (от 960px). */
.site-search { display: none; }
@media (min-width: 960px) {
    .site-search { display: flex; }
}
.site-search input[type="search"] {
    width: 180px;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, .2);
    /* Этап 65: фон/текст поля поиска из «Дизайна» (вкладка «Поиск»);
       фолбэк — полупрозрачный белый и цвет текста темы. Правило покрывает
       и мобильное меню (форма несёт оба класса site-search). */
    background: var(--search-bg, rgba(255, 255, 255, .65));
    color: var(--search-text, currentColor);
    font: inherit;
    font-size: calc(var(--fs-base) * .9);
}
.site-search input[type="search"]:focus { outline: 2px solid var(--c-accent); outline-offset: 1px; border-color: transparent; }

/* Дубль формы в мобильном меню (панель видима только ниже 960px). */
.site-search--mobile { display: flex; gap: 8px; padding: 20px 24px 0; }
.site-search--mobile input[type="search"] { flex: 1; min-width: 0; width: auto; padding: 10px 14px; border-radius: 10px; }
.site-search--mobile + nav { padding-top: 16px; }

/* Страница /search */
.search-form { display: flex; gap: 10px; margin-bottom: 32px; max-width: 640px; }
/* Этап 65: было background: transparent — на тёмном фоне (настраивается в
   «Дизайне») поле сливалось со страницей и его было не найти. Теперь тот же
   фолбэк, что в шапке, + переменные из вкладки «Поиск». */
.search-form input[type="search"] { flex: 1; min-width: 0; padding: 12px 16px; border-radius: 10px; border: 1px solid rgba(0, 0, 0, .2); background: var(--search-bg, rgba(255, 255, 255, .65)); color: var(--search-text, currentColor); font: inherit; }
.search-form input[type="search"]:focus { outline: 2px solid var(--c-accent); outline-offset: 1px; border-color: transparent; }

.search-results { margin-bottom: 36px; }
.search-results h2 { font-size: var(--fs-h2); margin: 0 0 8px; }
.search-results__count { font-size: .7em; font-weight: 400; opacity: .6; margin-left: 6px; }
.search-results ul { list-style: none; margin: 0; padding: 0; }
.search-results li { padding: 14px 0; border-bottom: 1px solid rgba(0, 0, 0, .08); }
.search-results li a { font-weight: 600; font-size: calc(var(--fs-base) * 1.05); }
.search-results li p { margin: 4px 0; opacity: .75; }
.search-results li small { opacity: .6; }

/* Плагин «Каталог» (этап 27) */
.catalog-price { margin-top: auto; padding-top: 8px; font-weight: 600; }

/* Корзина (этап 30) */
.catalog-add { margin-top: 10px; }
.catalog-add__btn { width: 100%; }
.cart { display: grid; gap: 28px; }
.cart__table { width: 100%; border-collapse: collapse; }
.cart__table th, .cart__table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid rgba(0, 0, 0, .08); vertical-align: middle; }
.cart__table thead th { font-size: .85em; opacity: .7; }
.cart__table tfoot th { font-size: 1.05em; }
.cart__qty-form { display: flex; gap: 6px; align-items: center; }
.cart__qty-form input { width: 64px; padding: 6px 8px; border: 1px solid rgba(0, 0, 0, .2); border-radius: 8px; font: inherit; background: var(--c-bg); color: inherit; }
.cart__remove { border: none; background: none; cursor: pointer; font-size: 1em; opacity: .5; padding: 4px 8px; }
.cart__remove:hover { opacity: 1; color: #ef4444; }
.cart__order-form small { font-weight: 400; opacity: .6; }

/* ---------- Защита изображений (этап 56) ----------
   Клиентские барьеры: без выделения, перетаскивания и iOS long-press callout.
   Контекстное меню по <img> подавляется и заменяется мини-меню с единственным
   пунктом «Скопировать ссылку» (JS в фронтенд-лейауте); в лайтбоксе — явная
   кнопка. Серверный уровень (водяной знак на прямые/внешние запросы) —
   ImageProtectionService, см. /storage/{path}. */
img { user-select: none; -webkit-user-select: none; -webkit-user-drag: none; -webkit-touch-callout: none; }

.mih-copy-menu { position: fixed; z-index: 200; display: none; min-width: 190px; padding: 4px 0; background: var(--c-bg, #fff); color: var(--c-text, #111); border: 1px solid rgba(0, 0, 0, .15); box-shadow: 0 8px 24px rgba(0, 0, 0, .18); font-size: 14px; text-align: left; }
.mih-copy-menu button { display: block; width: 100%; padding: 8px 16px; background: none; border: 0; cursor: pointer; font: inherit; color: inherit; white-space: nowrap; }
.mih-copy-menu button:hover, .mih-copy-menu button:focus-visible { background: rgba(0, 0, 0, .08); outline: none; }

/* Подтверждение «Скопировано». position:fixed работает и внутри открытого
   <dialog> (у него нет transform), поэтому JS вешает его туда же, как и меню. */
.mih-copy-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 210; padding: 10px 18px; background: rgba(0, 0, 0, .85); color: #fff; font-size: 14px; opacity: 0; transition: opacity .2s ease; pointer-events: none; }
.mih-copy-toast.is-visible { opacity: 1; }

/* Панель результата (этапы 59–60): на http буфер проверить нельзя, и
   execCommand недостоверен (Firefox и Chromium возвращают true, не
   скопировав — доказано в этапе 60), поэтому панель ВСЕГДА показывает
   ссылку как настоящий выделенный текст — пользователь видит её и копирует
   своим жестом. Подпись нейтральная: страница не заявляет об успехе. */
.mih-copy-panel { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 210; width: min(560px, calc(100vw - 32px)); padding: 12px 40px 12px 14px; background: var(--c-bg, #fff); color: var(--c-text, #111); border: 1px solid rgba(0, 0, 0, .15); box-shadow: 0 8px 24px rgba(0, 0, 0, .18); font-size: 14px; opacity: 0; transition: opacity .2s ease; pointer-events: none; }
.mih-copy-panel.is-visible { opacity: 1; pointer-events: auto; }
.mih-copy-panel__caption { margin-bottom: 8px; line-height: 1.4; }
.mih-copy-panel__url { width: 100%; box-sizing: border-box; padding: 6px 10px; border: 1px solid rgba(0, 0, 0, .2); background: rgba(0, 0, 0, .04); color: inherit; font: inherit; font-size: 13px; border-radius: 4px; }
.mih-copy-panel__close { position: absolute; top: 6px; right: 8px; width: 26px; height: 26px; padding: 0; background: none; border: 0; cursor: pointer; font-size: 18px; line-height: 1; color: inherit; opacity: .6; }
.mih-copy-panel__close:hover, .mih-copy-panel__close:focus-visible { opacity: 1; outline: none; }

/* Кнопка «Скопировать ссылку» в лайтбоксе (свободный верхний левый угол). */
.lightbox__copy { position: absolute; top: 16px; left: 16px; z-index: 1; padding: 8px 14px; background: rgba(255, 255, 255, .14); color: #fff; border: none; border-radius: 999px; font: inherit; font-size: calc(var(--fs-base) * .85); cursor: pointer; }
.lightbox__copy:hover { background: rgba(255, 255, 255, .3); }

/* Чекбокс согласия на обработку ПДн (этап 70): общий блок форм (обратная
   связь, заказ). Цвет акцента — из переменной темы. */
.consent { display: flex; align-items: flex-start; gap: 10px; font-size: calc(var(--fs-base) * .9); line-height: 1.45; }
.consent input[type="checkbox"] { flex-shrink: 0; margin-top: 3px; width: 16px; height: 16px; accent-color: var(--c-link, #0b57d0); }
.consent a { color: var(--c-link, #0b57d0); text-decoration: underline; }

/* Cookie-баннер (этап 71): нижняя плашка «Принять/Отклонить». Цвета — из
   переменных темы (подстраивается под любой дизайн); z-index выше меню
   копирования (200/210) и оверлея мобильного меню. */
.cookie-consent { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 250; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; padding: 14px 18px; background: var(--c-bg, #fff); color: var(--c-text, #111); border: 1px solid rgba(0, 0, 0, .15); box-shadow: 0 8px 24px rgba(0, 0, 0, .18); font-size: calc(var(--fs-base) * .9); line-height: 1.5; }
.cookie-consent p { margin: 0; flex: 1 1 320px; }
.cookie-consent a { color: var(--c-link, #0b57d0); text-decoration: underline; }
.cookie-consent__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cookie-consent .btn { padding: 8px 18px; font-size: calc(var(--fs-base) * .9); }
