/* =========================================================
   Публичная часть сайта
   ========================================================= */

/* ---------- Базовый сброс ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { overflow-x: hidden; }
body { overflow-x: hidden; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 300;
    background: #faf8f4;
    color: #2b2b2b;
    line-height: 1.75;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

a { color: #8a6d3b; text-decoration: none; }
a:hover { color: #6b5230; }

img { max-width: 100%; display: block; }

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* =========================================================
   Шапка сайта
   ========================================================= */
.site-header {
    border-bottom: 1px solid #ece5da;
    background: #faf8f4;
    position: sticky;
    top: 0;
    z-index: 10;
}
.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    padding-bottom: 1rem;
    gap: 1rem;
}

/* Логотип */
.site-logo {
    display: inline-flex;
    align-items: center;
    gap: .75rem;
    text-decoration: none;
}
.logo-mark {
    width: 44px;
    height: 44px;
    display: block;
    flex-shrink: 0;
}
.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
.logo-name {
    font-family: 'Lora', Georgia, serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: #2b2b2b;
    letter-spacing: .2px;
}
.logo-sub {
    font-family: 'Inter', sans-serif;
    font-size: .72rem;
    color: #a89b86;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    margin-top: 2px;
}
.site-logo:hover .logo-name { color: #8a6d3b; }

/* =========================================================
   Навигация
   ========================================================= */
.site-nav-desktop {
    display: none;
}
.site-nav-desktop .nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: block;
    opacity: .75;
    stroke: currentColor;
}
.site-nav-desktop a.active .nav-icon,
.site-nav-desktop a:hover .nav-icon { opacity: 1; }

@media (min-width: 701px) {
    .site-nav-desktop {
        display: flex;
        align-items: center;
        gap: 1.5rem;
    }
    .site-nav-desktop a {
        display: inline-flex;
        align-items: center;
        gap: .4rem;
        font-size: .92rem;
        color: #7a7a7a;
        text-decoration: none;
        transition: color .15s;
    }
    .site-nav-desktop a.active,
    .site-nav-desktop a:hover { color: #8a6d3b; }
}

/* =========================================================
   Бургер
   ========================================================= */
.burger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 0;
    background: none;
    border: 0;
    cursor: pointer;
    position: relative;
    z-index: 1002;
}
.burger span {
    display: block;
    width: 24px;
    height: 2px;
    background: #2b2b2b;
    border-radius: 2px;
    transition: transform .25s ease, opacity .2s ease;
    margin: 0 auto;
}
.burger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger.active span:nth-child(2) { opacity: 0; }
.burger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 700px) {
    .burger { display: flex; }
}

/* =========================================================
   Слайдер
   ========================================================= */
.slider {
    position: relative;
    width: 100%;
    max-width: 720px; /* Ограничиваем максимальную ширину */
    margin: 1.5rem auto 2rem; /* Уменьшили отступы сверху/снизу */
    aspect-ratio: 16 / 9;
    border-radius: 10px;
    overflow: hidden;
    background: #f3ece2;
    box-shadow: 0 6px 30px rgba(0,0,0,.08);
    touch-action: pan-y; /* Для корректной работы свайпа на мобильных */
}
.slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity .8s ease;
    display: block;
}
.slide.active { opacity: 1; z-index: 1; }
.slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center; /* Фокус на верхнюю часть фото */
    display: block;
}
.slide-caption {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    /* Увеличили нижний отступ, чтобы текст не перекрывался точками */
    padding: 3rem 1.25rem 2.5rem; 
    background: linear-gradient(to top, rgba(0,0,0,.65), rgba(0,0,0,0));
    color: #fff;
    font-family: 'Lora', Georgia, serif;
    font-size: 1.1rem;
    font-style: italic;
    text-align: center;
    pointer-events: none; /* Чтобы текст не перекрывал клики по кнопкам */
}
.slider-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    background: rgba(255,255,255,.75);
    border: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: #2b2b2b;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.slider-nav:hover { background: #fff; }
.slider-nav.prev { left: .75rem; }
.slider-nav.next { right: .75rem; }

/* Точки пагинации */
.slider-dots {
    position: absolute;
    bottom: 1rem; /* Чуть подняли от края */
    left: 0; right: 0;
    z-index: 3; /* Поверх подписи */
    display: flex;
    justify-content: center;
    gap: .4rem;
}
.slider-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 0;
    background: rgba(255,255,255,.5);
    cursor: pointer;
    padding: 0;
    transition: background .15s;
}
.slider-dots .dot.active { background: #fff; }

/* =========================================================
   Фильтр рубрик
   ========================================================= */
.category-filter {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .5rem;
    margin: 2rem 0 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #ece5da;
}
.category-filter a {
    padding: .35rem .9rem;
    border-radius: 999px;
    font-size: .88rem;
    color: #7a7a7a;
    border: 1px solid transparent;
    transition: all .15s ease;
}
.category-filter a:hover { color: #8a6d3b; }
.category-filter a.active {
    background: #f3ece2;
    color: #8a6d3b;
    border-color: #e8dcc8;
}
.category-filter .cat-count {
    display: inline-block;
    background: #efe7da;
    color: #8a6d3b;
    font-size: .72rem;
    padding: 0 .4rem;
    border-radius: 999px;
    margin-left: .25rem;
    vertical-align: middle;
}

/* =========================================================
   Поиск
   ========================================================= */
.search-form {
    display: flex;
    gap: .5rem;
    margin: 2rem 0 0;
    flex-wrap: wrap;
}
.search-form input[type=search] {
    flex: 1;
    min-width: 200px;
    padding: .6rem .9rem;
    font-size: 1rem;
    border: 1px solid #e8dcc8;
    border-radius: 999px;
    background: #fff;
    color: #2b2b2b;
    font-family: inherit;
}
.search-form input[type=search]:focus {
    outline: none;
    border-color: #8a6d3b;
    box-shadow: 0 0 0 3px rgba(138,109,59,.15);
}
.search-reset { align-self: center; font-size: .9rem; }
.search-info { color: #a89b86; margin: 1rem 0 0; font-size: .95rem; }

/* =========================================================
   Карточка стиха в списке
   ========================================================= */
.poem-list { display: flex; flex-direction: column; gap: 0; }

.poem-card {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 1.25rem;
    align-items: start;
    padding: 1.5rem 0;
    border-bottom: 1px solid #f0eae0;
}
.poem-card:last-child { border-bottom: 0; }

.poem-card-thumb {
    width: 96px;
    height: 96px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}
.poem-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center; /* Фокус на верхнюю часть фото */
    display: block;
}
.thumb-placeholder {
    display: block;
    width: 100%;
    height: 100%;
}
.thumb-placeholder svg { width: 100%; height: 100%; display: block; }
.poem-card-body { min-width: 0; }

.poem-card-title {
    font-family: 'Lora', Georgia, serif;
    font-weight: 500;
    font-size: 1.25rem;
    margin: 0 0 .35rem;
    line-height: 1.4;
}
.poem-card-title a { color: #2b2b2b; }
.poem-card-title a:hover { color: #8a6d3b; }
.poem-card-meta {
    font-size: .85rem;
    color: #a89b86;
    margin: 0 0 .75rem;
}
.poem-card-excerpt {
    color: #666;
    margin: 0 0 .75rem;
    font-size: .98rem;
}
.poem-card-more {
    font-size: .9rem;
    color: #8a6d3b;
}

/* =========================================================
   Страница стиха
   ========================================================= */
.poem-full { padding: 2.5rem 0 1rem; }
.poem-full-title {
    font-family: 'Lora', Georgia, serif;
    font-weight: 500;
    font-size: 1.9rem;
    line-height: 1.3;
    margin: 0 0 .5rem;
}
.poem-full-meta {
    font-size: .88rem;
    color: #a89b86;
    margin: 0 0 2rem;
}
.draft-badge {
    background: #f3ece2;
    color: #8a6d3b;
    padding: .1rem .55rem;
    border-radius: 999px;
    font-size: .78rem;
}
.poem-full-image {
    max-width: 420px;
    margin: 0 0 2rem;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,.06);
}
.poem-full-image img {
    width: 100%;
    height: auto;
    object-position: top center; /* Фокус на верхнюю часть фото */
    display: block;
}
.poem-full-body {
    font-family: 'Lora', Georgia, serif;
    font-size: 1.15rem;
    line-height: 1.85;
    white-space: pre-wrap;
    color: #2b2b2b;
}
.poem-full-back { margin-top: 3rem; font-size: .92rem; }

/* =========================================================
   О поэте
   ========================================================= */
.about-page { padding: 3rem 0; }
.about-page h1 {
    font-family: 'Lora', Georgia, serif;
    font-weight: 500;
    font-size: 1.7rem;
    margin: 0 0 1.5rem;
}
.about-image {
    max-width: 260px;
    margin: 0 auto 2rem;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,.06);
}
.about-image img { width: 100%; height: auto; display: block; }
.about-text {
    font-size: 1.05rem;
    line-height: 1.85;
    color: #3a3a3a;
}

/* =========================================================
   Пагинация
   ========================================================= */
.pagination {
    display: flex;
    justify-content: center;
    gap: .4rem;
    margin: 3rem 0 1rem;
}
.pagination a {
    padding: .35rem .8rem;
    border-radius: 4px;
    color: #7a7a7a;
    font-size: .9rem;
}
.pagination a.active {
    background: #f3ece2;
    color: #8a6d3b;
}

/* =========================================================
   Пустое состояние
   ========================================================= */
.empty {
    text-align: center;
    color: #a89b86;
    padding: 4rem 0;
    font-style: italic;
}

/* =========================================================
   Футер
   ========================================================= */
.site-footer {
    border-top: 1px solid #ece5da;
    margin-top: 4rem;
    padding: 2rem 0;
    text-align: center;
    font-size: .85rem;
    color: #b0a597;
}
.site-footer p { margin: .25rem 0; }
.admin-link a { color: #c4b9a8; font-size: .8rem; }
.admin-link a:hover { color: #8a6d3b; }

/* =========================================================
   Мобильное меню (публичная часть)
   ========================================================= */
.mobile-menu-overlay,
.mobile-menu {
    display: none;
}

@media (max-width: 700px) {
    /* Затемнение фона */
    .mobile-menu-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(20, 15, 10, .45);
        backdrop-filter: blur(2px);
        z-index: 9998;
        opacity: 0;
        visibility: hidden;
        transition: opacity .3s ease, visibility .3s ease;
    }
    .mobile-menu-overlay.open {
        opacity: 1;
        visibility: visible;
    }

    /* Сама панель */
    .mobile-menu {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(320px, 85vw);
        max-width: 100vw;
        background: #faf8f4;
        box-shadow: -10px 0 40px rgba(0,0,0,.1);
        transform: translateX(100%);
        visibility: hidden;
        transition: transform .4s cubic-bezier(0.25, 1, 0.5, 1), visibility .4s;
        z-index: 9999;
        padding: 1.5rem;
        overflow-y: auto;
        box-sizing: border-box;
    }
    .mobile-menu.open {
        transform: translateX(0);
        visibility: visible;
    }

    /* Заголовок «Меню» в панели, как в админке */
    .mm-title {
        font-family: 'Lora', Georgia, serif;
        font-size: 1.15rem;
        color: #a89b86;
        margin-bottom: .75rem;
        padding-bottom: .75rem;
        border-bottom: 1px solid #ece5da;
    }

    /* Кнопка закрытия (крестик) */
    .mm-close {
        display: flex;
        align-items: center;
        justify-content: center;
        align-self: flex-end;
        width: 44px;
        height: 44px;
        margin-right: -0.5rem;
        margin-bottom: 1rem;
        background: transparent;
        border: 0;
        border-radius: 50%;
        color: #a89b86;
        cursor: pointer;
        transition: color .2s, background .2s;
    }
    .mm-close:hover {
        color: #2b2b2b;
        background: #f3ece2;
    }
    .mm-close svg {
        display: block;
    }

    /* Навигация */
    .mobile-menu .mm-nav {
        display: flex;
        flex-direction: column;
        gap: .5rem;
    }

    .mobile-menu .mm-nav a {
        display: flex;
        align-items: center;
        gap: 1rem;
        padding: 1rem 1.25rem;
        font-family: 'Lora', Georgia, serif;
        font-size: 1.15rem;
        color: #2b2b2b;
        text-decoration: none;
        border-radius: 8px;
        transition: background .2s, color .2s;
    }

    .mobile-menu .mm-nav a:hover,
    .mobile-menu .mm-nav a.active {
        background: #f3ece2;
        color: #8a6d3b;
    }

    /* Иконки в меню */
    .mobile-menu .nav-icon {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
        opacity: .7;
        stroke: currentColor;
        transition: opacity .2s, transform .2s;
    }
    .mobile-menu .mm-nav a:hover .nav-icon,
    .mobile-menu .mm-nav a.active .nav-icon {
        opacity: 1;
        transform: scale(1.05);
    }

    /* Нижняя часть (ссылка на админку) */
    .mm-bottom {
        margin-top: auto;
        padding-top: 1.5rem;
        border-top: 1px solid #ece5da;
    }
    .mm-admin-link {
        display: block;
        text-align: center;
        font-size: .85rem;
        color: #a89b86;
        text-decoration: none;
        padding: .5rem;
        transition: color .2s;
    }
    .mm-admin-link:hover {
        color: #8a6d3b;
    }

    /* ----- Адаптив слайдера для мобильных ----- */
    .slider {
        margin: 1rem auto 1.5rem;
        border-radius: 8px;
        aspect-ratio: 4 / 3; /* Сделали слайдер выше на мобилках, чтобы лица не обрезались */
    }
    .slide-caption {
        /* На мобильных делаем подпись меньше и еще выше */
        font-size: 1rem;
        padding: 2rem 1rem 2.2rem;
    }
    .slider-dots {
        bottom: .75rem;
    }
}

/* =========================================================
   Адаптив публичной части
   ========================================================= */
@media (max-width: 600px) {
    .poem-card { grid-template-columns: 72px 1fr; gap: 1rem; }
    .poem-card-thumb { width: 72px; height: 72px; }

    .poem-full-title { font-size: 1.5rem; }
    .poem-full-body { font-size: 1.05rem; }
    .poem-full-image { max-width: 100%; }
}