/*
Theme Name: Терновка
Description: Тема для сайта «Терновка — столица николаевских болгар».
Version: 1.1.0
Requires at least: 6.0
Requires PHP: 8.0
Text Domain: ternovka
*/

:root {
    --paper: #f7f1e6;
    --paper-2: #efe6d4;
    --ink: #2b2420;
    --ink-soft: #6b5f55;
    --red: #9e1b1b;
    --red-dark: #761313;
    --green: #2f5a3c;
    --line: #dccfb8;
    --white: #fffdf8;
    --radius: 14px;
    --shadow: 0 8px 24px rgba(60, 40, 20, .10);
    --serif: "PT Serif", Georgia, serif;
    --sans: "PT Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --ornament: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='16' viewBox='0 0 48 16'%3E%3Cpath d='M0 8 L8 0 L16 8 L8 16Z' fill='%239e1b1b'/%3E%3Cpath d='M8 4 L12 8 L8 12 L4 8Z' fill='%23f7f1e6'/%3E%3Cpath d='M24 8 L28 4 L32 8 L28 12Z' fill='%232b2420'/%3E%3Ccircle cx='20' cy='8' r='1.6' fill='%232f5a3c'/%3E%3Ccircle cx='36' cy='8' r='1.6' fill='%232f5a3c'/%3E%3Cpath d='M40 8 L44 4 L48 8 L44 12Z' fill='%239e1b1b'/%3E%3C/svg%3E");
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 18px/1.65 var(--sans);
    -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--red); }
a:hover { color: var(--red-dark); }
h1, h2, h3, h4 { font-family: var(--serif); line-height: 1.2; margin: 0 0 .5em; color: var(--ink); }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
h2 { font-size: clamp(1.5rem, 3.2vw, 2.1rem); }
h3 { font-size: 1.25rem; }

.container { width: min(1180px, 100% - 40px); margin-inline: auto; }
.container.narrow { width: min(820px, 100% - 40px); }
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 10px; top: 10px; background: #fff; padding: 8px 12px; z-index: 100; }

/* Кнопки */
.btn {
    display: inline-block; padding: 12px 22px; border-radius: 999px;
    background: var(--red); color: #fff; text-decoration: none; font-weight: 700;
    border: 2px solid var(--red); cursor: pointer; font: 700 16px/1.2 var(--sans);
    transition: background .2s, transform .2s;
}
.btn:hover { background: var(--red-dark); border-color: var(--red-dark); color: #fff; transform: translateY(-1px); }
.btn-big { padding: 16px 28px; font-size: 17px; }
.btn-light { background: var(--white); color: var(--red); border-color: var(--white); }
.btn-light:hover { background: var(--paper-2); border-color: var(--paper-2); color: var(--red-dark); }
.btn-outline { background: transparent; color: #fff; border-color: rgba(255,255,255,.8); }
.btn-outline:hover { background: rgba(255,255,255,.15); border-color: #fff; }

/* Орнамент */
.ornament { height: 16px; background: var(--ornament) repeat-x center; opacity: .9; }

/* Шапка */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: rgba(247, 241, 230, .94); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}
.admin-bar .site-header { top: 32px; }
@media (max-width: 782px) { .admin-bar .site-header { top: 46px; } }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 72px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand-mark {
    width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
    background: var(--red); color: #fff; font: 700 22px var(--serif);
    box-shadow: inset 0 0 0 3px var(--paper), 0 0 0 2px var(--red);
}
.brand-logo { width: 44px; height: 44px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font: 700 22px var(--serif); }
.brand-tag { font-size: 13px; color: var(--ink-soft); }

.main-nav .menu { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; }
.main-nav a {
    display: block; padding: 8px 14px; border-radius: 999px; text-decoration: none;
    color: var(--ink); font-weight: 700; font-size: 16px;
}
.main-nav a:hover { background: var(--paper-2); color: var(--red); }
.main-nav .current-menu-item > a, .main-nav .current_page_item > a { background: var(--red); color: #fff; }
.menu-toggle { display: none; }

.main-nav { margin-left: auto; }
.header-tools { display: flex; align-items: center; gap: 8px; }

/* Переключатель языков */
.lang { position: relative; }
.lang-btn {
    display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px 0 6px;
    border: 1px solid var(--line); border-radius: 999px; background: var(--white);
    font: 700 14px var(--sans); color: var(--ink); cursor: pointer;
}
.lang-btn:hover { border-color: var(--red); }
.lang .flag {
    width: 26px; height: 26px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(0,0,0,.12); display: block;
}
.lang .flag svg { width: 100%; height: 100%; display: block; }
.lang .caret { width: 10px; height: 6px; }
.lang-menu {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; min-width: 190px;
    list-style: none; margin: 0; padding: 6px; background: var(--white);
    border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.lang-menu[hidden] { display: none; }
.lang-menu button {
    display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px;
    border: 0; border-radius: 8px; background: transparent; cursor: pointer;
    font: 400 16px var(--sans); color: var(--ink); text-align: left;
}
.lang-menu button:hover { background: var(--paper-2); }
.lang-menu button.is-active { font-weight: 700; color: var(--red); }

/* Прячем служебные элементы Google Translate */
.gt-holder { position: absolute; left: -9999px; top: 0; }
body { top: 0 !important; position: static !important; }
iframe.skiptranslate, .skiptranslate > iframe, .goog-te-banner-frame,
#goog-gt-tt, .goog-te-balloon-frame, .VIpgJd-ZVi9od-ORHb-OEVmcd,
.VIpgJd-ZVi9od-aZ2wEe-wOHMyf, .VIpgJd-yAWNEb-L7lbkb { display: none !important; }
.goog-text-highlight { background: none !important; box-shadow: none !important; }
font { background: transparent !important; box-shadow: none !important; }

@media (max-width: 900px) {
    .brand-tag { font-size: 12px; }
    .menu-toggle {
        display: flex; flex-direction: column; justify-content: center; gap: 5px;
        width: 46px; height: 46px; border: 0; background: transparent; cursor: pointer; padding: 10px;
    }
    .menu-toggle span { display: block; height: 3px; background: var(--ink); border-radius: 2px; transition: .25s; }
    .menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
    .menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
    .menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }
    .main-nav {
        position: absolute; left: 0; right: 0; top: 100%; margin-left: 0;
        background: var(--paper); border-bottom: 1px solid var(--line);
        box-shadow: var(--shadow); display: none;
    }
    .main-nav.open { display: block; }
    .main-nav .menu { flex-direction: column; padding: 10px 20px 20px; }
    .main-nav a { padding: 14px 16px; font-size: 18px; border-radius: 10px; }
}

@media (max-width: 420px) {
    .lang-btn .lang-code { display: none; }
    .lang-btn { padding: 0 10px 0 6px; gap: 6px; }
    .brand-mark { width: 38px; height: 38px; font-size: 19px; }
    .brand-name { font-size: 20px; }
}

/* Главный экран */
.hero {
    position: relative; min-height: min(78vh, 680px); display: flex; align-items: flex-end;
    background: linear-gradient(135deg, #5a1010 0%, #8e1d1d 45%, #2f5a3c 100%);
    background-size: cover; background-position: center; color: #fff;
}
.hero:not(.has-photo)::before {
    content: ""; position: absolute; inset: 0; opacity: .12;
    background: var(--ornament) repeat; background-size: 96px 32px;
}
.hero-overlay { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.05) 30%, rgba(0,0,0,.6) 100%); }
.hero-content { position: relative; padding: 80px 0 70px; }
.hero-title { color: #fff; font-size: clamp(3rem, 11vw, 7rem); letter-spacing: .02em; margin: 0; text-shadow: 0 4px 30px rgba(0,0,0,.35); }
.hero-sub { font: italic 400 clamp(1.2rem, 3vw, 1.8rem) var(--serif); margin: 0 0 28px; opacity: .95; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* Вступление */
.intro { padding: 56px 0 24px; }
.intro-text { max-width: 760px; margin: 0 auto; text-align: center; font: 1.25rem/1.7 var(--serif); }

/* Карточки разделов */
.sections-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; padding: 24px 0 40px; }
.section-card {
    position: relative; display: flex; flex-direction: column; padding: 30px 28px; min-height: 240px;
    background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
    text-decoration: none; color: var(--ink); overflow: hidden; transition: transform .2s, box-shadow .2s;
}
.section-card::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 8px; background: var(--ornament) repeat-x; background-size: 36px 12px; }
.section-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); color: var(--ink); }
.section-num { font: 700 14px var(--sans); color: var(--red); letter-spacing: .1em; margin-bottom: 12px; }
.section-card p { color: var(--ink-soft); flex: 1; }
.section-more { color: var(--red); font-weight: 700; }
@media (max-width: 860px) { .sections-grid { grid-template-columns: 1fr; } .section-card { min-height: 0; } }

/* Блоки */
.block { padding: 36px 0; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; border-bottom: 2px solid var(--line); padding-bottom: 10px; }
.block-head h2 { margin: 0; }
.block-head a { font-weight: 700; text-decoration: none; white-space: nowrap; }

/* Сетки */
.grid { display: grid; gap: 22px; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-photos { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.grid-people { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: transform .2s, box-shadow .2s; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card-link { display: flex; flex-direction: column; height: 100%; color: inherit; text-decoration: none; }
.card-media { aspect-ratio: 4 / 3; background: var(--paper-2); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.card:hover .card-media img { transform: scale(1.04); }
.card-noimg { width: 100%; height: 100%; display: grid; place-items: center; background: var(--paper-2) var(--ornament) repeat; background-size: 48px 16px; }
.card-noimg span { width: 64px; height: 64px; border-radius: 50%; background: var(--paper); display: grid; place-items: center; font: 700 30px var(--serif); color: var(--red); }
.card-body { padding: 16px 18px 20px; }
.card-tag { display: inline-block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--green); margin-bottom: 6px; }
.card-title { margin: 0 0 6px; font-size: 1.15rem; }
.card-excerpt { margin: 0; color: var(--ink-soft); font-size: 15px; line-height: 1.5; }

.card-photo .card-media { aspect-ratio: 1; }
.card-photo .card-body { padding: 10px 12px 12px; }
.card-photo .card-title { font: 700 14px/1.35 var(--sans); }

.card-person { text-align: center; }
.card-person .card-media { aspect-ratio: 1; width: 160px; margin: 24px auto 0; border-radius: 50%; border: 4px solid var(--paper); box-shadow: 0 0 0 2px var(--red); }

/* CTA */
.cta { margin-top: 30px; background: var(--green); color: #fff; }
.cta-inner { display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 50px 0; }
.cta h2 { color: #fff; }
.cta p { margin: 0; opacity: .9; max-width: 620px; }
.cta .btn { background: #fff; color: var(--green); border-color: #fff; flex-shrink: 0; }
@media (max-width: 760px) { .cta-inner { flex-direction: column; align-items: flex-start; } }

/* Внутренние страницы */
.page-hero { padding: 54px 0 34px; background: var(--paper-2); }
.page-hero h1 { margin: 0; }
.page-hero p { margin: 10px 0 0; }
.eyebrow { display: inline-block; font-size: 14px; font-weight: 700; color: var(--red); text-transform: uppercase; letter-spacing: .1em; text-decoration: none; margin-bottom: 10px; }
.meta { color: var(--ink-soft); margin-top: 10px; font-size: 15px; }
.page-intro { max-width: 820px; margin: 40px 0 34px; font-size: 1.1rem; }
.section-cta { margin: 50px 0 60px; padding: 28px; border: 2px dashed var(--line); border-radius: var(--radius); text-align: center; }
.section-cta p { margin: 0 0 14px; }
.empty-state { text-align: center; padding: 50px 20px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.empty-state p { color: var(--ink-soft); margin: 0 0 16px; }

/* Текст статьи */
.entry-content { padding-bottom: 20px; }
.entry-content > * { margin-block: 0 1.1em; }
.entry-content h2, .entry-content h3 { margin-top: 1.6em; }
.entry-content img { border-radius: 8px; }
.entry-content blockquote { margin-inline: 0; padding: 6px 0 6px 22px; border-left: 4px solid var(--red); font: italic 1.15rem var(--serif); color: var(--ink-soft); }
.entry-content figcaption, .single-cover figcaption { font-size: 14px; color: var(--ink-soft); text-align: center; margin-top: 8px; }
.single-cover { margin: 36px 0 28px; }
.single-cover img { border-radius: var(--radius); width: 100%; }
.single .entry-content { font-size: 1.08rem; }

/* Галереи (блок «Галерея» и шорткод [gallery]) */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.gallery-item { margin: 0; }
.gallery-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.wp-block-gallery img { border-radius: 8px; }

.post-nav { display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); padding: 24px 0 60px; font-weight: 700; }
.post-nav a { text-decoration: none; }

/* Пагинация */
.pagination, .navigation.pagination { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin: 36px 0; }
.pagination .page-numbers { padding: 8px 14px; border-radius: 8px; background: var(--white); border: 1px solid var(--line); text-decoration: none; }
.pagination .current { background: var(--red); color: #fff; border-color: var(--red); }
.nav-links { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }

/* Форма предложки */
.submit-form { display: grid; gap: 18px; background: var(--white); padding: 28px; border: 1px solid var(--line); border-radius: var(--radius); margin: 20px 0 60px; }
.submit-form label { display: grid; gap: 6px; font-weight: 700; font-size: 16px; }
.submit-form input[type=text], .submit-form textarea, .submit-form select {
    width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
    background: var(--paper); font: 400 17px var(--sans); color: var(--ink);
}
.submit-form input:focus, .submit-form textarea:focus, .submit-form select:focus { outline: 2px solid var(--red); outline-offset: 1px; border-color: transparent; }
.submit-form input[type=file] { font: 400 15px var(--sans); }
.submit-form .check { display: flex; align-items: flex-start; gap: 10px; font-weight: 400; }
.submit-form .check input { margin-top: 6px; width: 18px; height: 18px; flex-shrink: 0; }
.form-row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 640px) { .form-row.two { grid-template-columns: 1fr; } .submit-form { padding: 20px; } }
.hp { position: absolute; left: -9999px; height: 0; overflow: hidden; }
.notice { padding: 16px 20px; border-radius: 10px; font-weight: 700; margin: 20px 0; }
.notice-ok { background: #e3f1e6; color: var(--green); border: 1px solid #b7d8bf; }
.notice-err { background: #f8e3e3; color: var(--red-dark); border: 1px solid #e5b5b5; }

/* Подвал */
.site-footer { background: var(--ink); color: #e9e0d0; margin-top: 0; }
.site-footer .ornament { opacity: 1; }
.footer-inner { display: flex; justify-content: space-between; gap: 30px; flex-wrap: wrap; padding: 44px 0 28px; }
.footer-inner p { margin: 6px 0 14px; color: #c8bba6; max-width: 460px; }
.footer-name { font: 700 26px var(--serif); color: #fff; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.12); padding: 18px 0 26px; font-size: 14px; color: #a99c88; }

/* Просмотр фото */
.lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(15, 10, 8, .94); display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; max-width: 92vw; max-height: 88vh; text-align: center; }
.lightbox img { max-width: 92vw; max-height: 80vh; object-fit: contain; margin: auto; border-radius: 6px; }
.lightbox figcaption { color: #ddd; margin-top: 12px; font-size: 15px; }
.lightbox button { position: absolute; background: rgba(255,255,255,.1); color: #fff; border: 0; cursor: pointer; font-size: 38px; width: 54px; height: 54px; border-radius: 50%; line-height: 1; }
.lightbox button:hover { background: rgba(255,255,255,.25); }
.lb-close { top: 16px; right: 16px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }
