/*
 * Кастомные стили темы «СНТ — Садоводство»
 *
 * Разделы:
 * 1. Сброс и CSS-переменные
 * 2. Шапка сайта (header)
 * 3. Герой + CSS-art fallback
 * 4. Основное содержимое
 * 5. Футер
 * 6. Карточки записей
 * 7. Адаптивность и бургер-меню
 * 8. Утилиты (анимации, скролл)
 *
 * @package SNT_Theme
 */

/* ════════════════════════════════════════════════════════════
   1. ПЕРЕМЕННЫЕ И СБРОС
   ════════════════════════════════════════════════════════════ */

:root {
    --snt-primary:    #1a3b2f;
    --snt-secondary:  #2c3e2b;
    --snt-light:      #eef5e6;
    --snt-white:      #ffffff;
    --snt-text:       #1c1c1c;
    --snt-text-muted: #4a4a4a;
    --snt-border:     #d0deca;
    --snt-gold:       #d4a853;
    --snt-radius:     10px;
    --snt-shadow-sm:  0 2px 8px rgba(26,59,47,.08);
    --snt-shadow-md:  0 4px 20px rgba(26,59,47,.13);
    --snt-transition: 0.22s ease;
    --snt-blur:       blur(6px);
}

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

/* Плавный скролл */
html {
    scroll-behavior: smooth;
}

/* Базовый цвет фона */
body {
    background-color: var(--snt-white);
    -webkit-font-smoothing: antialiased;
}

/* Skip-link (доступность WCAG) */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    padding: 0.5rem 1rem;
    background: var(--snt-primary);
    color: #fff;
    border-radius: 0 0 6px 6px;
    font-weight: 600;
    z-index: 9999;
    transition: top .2s;
    text-decoration: none;
}
.skip-link:focus {
    top: 0;
    outline: 2px solid var(--snt-gold);
    outline-offset: 2px;
}

/* ════════════════════════════════════════════════════════════
   2. ШАПКА САЙТА
   ════════════════════════════════════════════════════════════ */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--snt-primary);
    /* На главной накладывается поверх героя через JS */
    transition: background var(--snt-transition), box-shadow var(--snt-transition);
}

/* Состояние при прокрутке */
.site-header.is-scrolled {
    box-shadow: var(--snt-shadow-md);
    background: rgba(26,59,47,0.97);
    backdrop-filter: var(--snt-blur);
    -webkit-backdrop-filter: var(--snt-blur);
}

.site-header__inner {
    max-width: 1200px;
    margin-inline: auto;
    padding-inline: 1.5rem;
}

/* ── Бренд (логотип + название + описание) ──────────────── */
.site-header__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    text-decoration: none;
}

.site-header__brand:focus-within {
    outline: 2px solid var(--snt-gold);
    outline-offset: 4px;
    border-radius: 6px;
}

/* Логотип */
.site-header__brand .wp-block-site-logo img,
.site-header__brand .wp-block-site-logo a {
    display: block;
    border-radius: 6px;
}

/* Название сайта */
.site-header__brand .wp-block-site-title a {
    color: #fff !important;
    text-decoration: none;
    transition: opacity var(--snt-transition);
}
.site-header__brand .wp-block-site-title a:hover {
    opacity: 0.85;
}

/* Описание сайта */
.site-header__brand .wp-block-site-tagline {
    color: rgba(255,255,255,0.72) !important;
}

/* ── Навигация ───────────────────────────────────────────── */
.site-header__nav {
    display: flex;
    align-items: center;
}

/* Ссылки меню */
.snt-nav .wp-block-navigation-item__content {
    color: rgba(255,255,255,0.90);
    font-weight: 500;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    transition: background var(--snt-transition), color var(--snt-transition);
}

.snt-nav .wp-block-navigation-item__content:hover,
.snt-nav .wp-block-navigation-item.current-menu-item > .wp-block-navigation-item__content {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

/* Иконка подменю */
.snt-nav .wp-block-navigation__submenu-icon {
    opacity: 0.7;
}

/* ── Оверлей мобильного меню ─────────────────────────────── */
.snt-nav .wp-block-navigation__responsive-container {
    background: var(--snt-primary);
}

.snt-nav .wp-block-navigation__responsive-container-content {
    padding: 1.5rem;
}

/* Кнопка бургера */
.snt-nav .wp-block-navigation__responsive-container-open,
.snt-nav .wp-block-navigation__responsive-container-close {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    color: #fff;
    padding: 0.45rem;
    cursor: pointer;
    transition: background var(--snt-transition);
}

.snt-nav .wp-block-navigation__responsive-container-open:hover,
.snt-nav .wp-block-navigation__responsive-container-close:hover {
    background: rgba(255,255,255,0.22);
}

/* ════════════════════════════════════════════════════════════
   3. ГЕРОЙ + CSS-ART FALLBACK
   ════════════════════════════════════════════════════════════ */

.hero-section {
    position: relative;
    overflow: hidden;
}

/* ── Когда изображение задано (cover с фото) ─────────────── */
.hero-cover {
    min-height: 480px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── CSS-art fallback: когда изображения нет ─────────────── */
/*
   Fallback активируется классом .has-no-image (добавляет JS),
   или когда у блока .wp-block-cover нет атрибута с url (нет фото).
   Отображает градиентный фон с SVG-иконкой листа.
*/
.hero-cover.hero-cover--fallback,
.hero-cover:not([style*="background-image"]):not(:has(.wp-block-cover__image-background[src])) {
    background: linear-gradient(160deg, var(--snt-primary) 0%, var(--snt-secondary) 100%);
    min-height: 360px;
    position: relative;
}

/* Декоративный leaf SVG через pseudo-element — CSS-art */
.hero-cover.hero-cover--fallback::before,
.hero-cover:not([style*="background-image"]):not(:has(.wp-block-cover__image-background[src]))::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200' fill='none'%3E%3Cpath d='M100 20 C60 40 30 80 40 140 C50 180 100 185 130 160 C170 130 180 80 160 50 C140 20 120 10 100 20Z' fill='rgba(255,255,255,0.06)'/%3E%3Cpath d='M100 40 C75 55 55 90 62 135 C68 165 100 168 118 150 C148 122 155 80 140 58 C126 36 115 28 100 40Z' fill='rgba(255,255,255,0.05)'/%3E%3Ccircle cx='60' cy='60' r='80' fill='rgba(255,255,255,0.03)'/%3E%3Ccircle cx='150' cy='150' r='60' fill='rgba(255,255,255,0.03)'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    pointer-events: none;
}

/* Большой SVG-лист по центру */
.hero-cover.hero-cover--fallback::after,
.hero-cover:not([style*="background-image"]):not(:has(.wp-block-cover__image-background[src]))::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64' fill='none'%3E%3Cpath d='M32 8 C20 14 10 28 13 46 C15 58 32 60 42 52 C56 42 58 26 50 16 C43 6 37 4 32 8Z' fill='rgba(255,255,255,0.18)' stroke='rgba(255,255,255,0.35)' stroke-width='1'/%3E%3Cpath d='M32 8 L32 56' stroke='rgba(255,255,255,0.25)' stroke-width='1.5' stroke-linecap='round'/%3E%3Cpath d='M32 22 Q42 30 50 28' stroke='rgba(255,255,255,0.2)' stroke-width='1.2' stroke-linecap='round' fill='none'/%3E%3Cpath d='M32 34 Q22 40 16 38' stroke='rgba(255,255,255,0.2)' stroke-width='1.2' stroke-linecap='round' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    pointer-events: none;
    opacity: 0.9;
}

/* Главная страница: шапка накладывается на героя */
.is-front-page .site-header {
    position: fixed;
    width: 100%;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.is-front-page .site-header.is-scrolled {
    background: rgba(26,59,47,0.96);
    backdrop-filter: var(--snt-blur);
    -webkit-backdrop-filter: var(--snt-blur);
}

/* Для главной: отступ под fixed шапкой */
.is-front-page .hero-section {
    margin-top: 0;
    /* JS установит padding-top равный высоте шапки */
}

/* ════════════════════════════════════════════════════════════
   4. ОСНОВНОЕ СОДЕРЖИМОЕ
   ════════════════════════════════════════════════════════════ */

.site-main {
    min-height: 60vh;
}

/* Отступ содержимого */
.site-main > :not(:first-child):not(.alignfull):not(.alignwide) {
    max-width: 840px;
    margin-inline: auto;
}

/* Заголовок страницы */
.page-header {
    padding-block: 2.5rem 1.5rem;
}

.page-header .wp-block-post-title {
    color: var(--snt-primary);
    margin: 0;
}

/* Контент */
.wp-block-post-content {
    max-width: 840px;
}

/* Ссылки в контенте */
.entry-content a,
.wp-block-post-content a {
    color: var(--snt-primary);
    text-decoration: underline;
    text-decoration-color: rgba(26,59,47,0.4);
    text-underline-offset: 2px;
    transition: color var(--snt-transition), text-decoration-color var(--snt-transition);
}

.entry-content a:hover,
.wp-block-post-content a:hover {
    color: var(--snt-secondary);
    text-decoration-color: var(--snt-secondary);
}

/* ════════════════════════════════════════════════════════════
   5. ФУТЕР
   ════════════════════════════════════════════════════════════ */

.site-footer__wrapper {
    background-color: var(--snt-primary);
}

.site-footer__inner {
    max-width: 1200px;
    margin-inline: auto;
}

.site-footer__brand .wp-block-site-title a,
.site-footer__brand .wp-block-site-title {
    color: #fff !important;
    text-decoration: none;
}

.site-footer__brand .wp-block-site-tagline {
    color: rgba(255,255,255,0.65) !important;
}

/* Копирайт */
.site-footer__copy {
    color: rgba(255,255,255,0.6);
    font-size: 0.875rem;
    line-height: 1.5;
}

/* ════════════════════════════════════════════════════════════
   6. КАРТОЧКИ ЗАПИСЕЙ
   ════════════════════════════════════════════════════════════ */

.post-card {
    background: var(--snt-white);
    border-radius: var(--snt-radius);
    border: 1px solid var(--snt-border);
    overflow: hidden;
    transition: box-shadow var(--snt-transition), transform var(--snt-transition);
}

.post-card:hover {
    box-shadow: var(--snt-shadow-md);
    transform: translateY(-2px);
}

.post-card .wp-block-post-title a {
    color: var(--snt-primary);
    text-decoration: none;
}

.post-card .wp-block-post-title a:hover {
    color: var(--snt-secondary);
}

/* Плавное появление (IntersectionObserver) */
.post-card,
.snt-accordion {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.45s ease, transform 0.45s ease;
}

.post-card.is-visible,
.snt-accordion.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ════════════════════════════════════════════════════════════
   7. АДАПТИВНОСТЬ
   ════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    /* Шапка: два столбца → одна строка */
    .site-header__inner {
        padding-inline: 1rem;
    }

    /* Герой меньше на мобильных */
    .hero-cover {
        min-height: 300px !important;
    }

    /* Grid → один столбец */
    .wp-block-post-template.is-flex-container.is-flex-container-2-columns {
        grid-template-columns: 1fr;
    }

    /* Футер: вертикально */
    .site-footer__inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.25rem !important;
    }
}

@media (max-width: 480px) {
    .site-header__brand .wp-block-site-tagline {
        display: none; /* Скрываем описание на очень маленьких экранах */
    }
    .hero-cover {
        min-height: 240px !important;
    }
}

/* ════════════════════════════════════════════════════════════
   8. УТИЛИТЫ
   ════════════════════════════════════════════════════════════ */

/* Плавный скролл */
@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

/* Disable animations если пользователь просит */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
    .post-card,
    .snt-accordion {
        opacity: 1;
        transform: none;
    }
}

/* Выделение текста */
::selection {
    background-color: rgba(26,59,47,0.15);
    color: var(--snt-primary);
}
