/*
Theme Name: Самара ГИС
Theme URI: https://softlogy.ru/
Author: OpenAI
Description: Лёгкая адаптивная тема для сайта Самара ГИС. Главная страница, записи с тегами и архивы рубрик.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.8
Requires PHP: 7.4
Text Domain: samara-gis
*/

:root {
    --sg-green: #59862c;
    --sg-green-dark: #456d20;
    --sg-green-light: #edf3e8;
    --sg-green-pale: #f6f9f2;
    --sg-text: #898989;
    --sg-heading: #5f6659;
    --sg-white: #ffffff;
    --sg-border: #e8ece4;
    --sg-shadow: 0 10px 30px rgba(48, 68, 34, 0.055);
    --sg-radius: 16px;
    --sg-container: 1160px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    color: var(--sg-text);
    background: #fbfcfa;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

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

a {
    color: var(--sg-green);
    text-decoration: none;
    transition: color .2s ease, opacity .2s ease;
}

a:hover {
    color: var(--sg-green-dark);
}

button, input, textarea, select { font: inherit; }

.container {
    width: min(var(--sg-container), calc(100% - 40px));
    margin-inline: auto;
}

/* =========================================
   ШАПКА И ЛОГОТИП
========================================= */

.site-header {
    position: relative;
    z-index: 5;
    background: rgba(255,255,255,.96);
    border-bottom: 1px solid var(--sg-border);
}

.header-inner {
    min-height: 86px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
}

.site-branding {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    min-width: 0;
}

.site-branding .custom-logo-link {
    display: inline-flex;
    align-items: center;
}

.custom-logo {
    display: block;
    width: auto;
    max-width: 245px;
    max-height: 62px;
    object-fit: contain;
}

.site-name {
    display: inline-flex;
    align-items: baseline;
    gap: 7px;
    color: #777f70;
    font-size: 25px;
    font-weight: 750;
    letter-spacing: -.8px;
    line-height: 1.1;
}

.site-name:hover { color: #777f70; text-decoration: none; }
.site-name strong { color: var(--sg-green); font-weight: 800; }

/* =========================================
   ГЛАВНОЕ МЕНЮ
========================================= */

.primary-navigation { margin-left: auto; }

.primary-navigation .menu,
.primary-navigation ul {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 7px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.primary-navigation li { margin: 0; }

.primary-navigation a {
    display: inline-block;
    padding: 10px 14px;
    border-radius: 9px;
    color: #81877c;
    font-size: 14px;
    font-weight: 600;
}

.primary-navigation a:hover,
.primary-navigation .current-menu-item > a,
.primary-navigation .current_page_item > a {
    color: var(--sg-green-dark);
    background: var(--sg-green-light);
    text-decoration: none;
}

.primary-navigation .menu > li {
    position: relative;
}

.primary-navigation .sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    min-width: 220px;
    padding: 8px;
    margin: 0;
    flex-direction: column;
    gap: 2px;
    list-style: none;
    background: #ffffff;
    border: 1px solid #e8ece4;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(48, 68, 34, 0.10);
}

.primary-navigation .menu-item-has-children:hover > .sub-menu,
.primary-navigation .menu-item-has-children:focus-within > .sub-menu {
    display: flex;
}

.primary-navigation .sub-menu li {
    width: 100%;
}

.primary-navigation .sub-menu a {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border-radius: 7px;
    white-space: nowrap;
}

.primary-navigation .sub-menu a:hover {
    background: #edf3e8;
    color: #456d20;
}

/* =========================================
   ОСНОВНАЯ ОБЛАСТЬ
========================================= */

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

.home-hero {
    position: relative;
    overflow: hidden;
    margin: 34px 0 48px;
    padding: 54px 58px;
    border: 1px solid #e5eddd;
    border-radius: 22px;
    background:
        radial-gradient(circle at 92% 12%, rgba(89,134,44,.12), transparent 25%),
        linear-gradient(120deg, #f5f8f0 0%, #fbfcfa 72%);
}

.home-hero::after {
    content: "";
    position: absolute;
    right: -44px;
    bottom: -88px;
    width: 250px;
    height: 250px;
    border: 1px solid rgba(89,134,44,.12);
    border-radius: 50%;
    box-shadow: 0 0 0 24px rgba(89,134,44,.035), 0 0 0 48px rgba(89,134,44,.025);
    pointer-events: none;
}

.hero-kicker,
.section-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: var(--sg-green);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 1.4px;
    text-transform: uppercase;
}

.hero-kicker::before {
    content: "";
    width: 20px;
    height: 2px;
    border-radius: 3px;
    background: var(--sg-green);
}

.home-hero h1 {
    position: relative;
    z-index: 1;
    max-width: 720px;
    margin: 0 0 14px;
    color: var(--sg-heading);
    font-size: clamp(30px, 4vw, 44px);
    font-weight: 750;
    line-height: 1.17;
    letter-spacing: -1.3px;
}

.home-hero p {
    position: relative;
    z-index: 1;
    max-width: 650px;
    margin: 0;
    font-size: 17px;
}

.home-intro {
    margin: -20px 0 44px;
    padding: 26px 30px;
    border-radius: var(--sg-radius);
    background: var(--sg-white);
    box-shadow: var(--sg-shadow);
}

.home-intro > :first-child { margin-top: 0; }
.home-intro > :last-child { margin-bottom: 0; }

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin: 0 0 22px;
}

.section-heading h2,
.archive-heading h1 {
    margin: 0;
    color: var(--sg-heading);
    font-size: clamp(25px, 3vw, 32px);
    line-height: 1.25;
    letter-spacing: -.6px;
}

.section-heading p {
    margin: 0;
    font-size: 14px;
}

/* =========================================
   СЕТКА ЗАПИСЕЙ И КАРТОЧКИ
========================================= */

.posts-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
}

.post-card {
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius);
    background: var(--sg-white);
    box-shadow: 0 4px 18px rgba(48,68,34,.025);
    transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}

.post-card:hover {
    transform: translateY(-4px);
    border-color: #dce8d1;
    box-shadow: var(--sg-shadow);
}

.post-card-image {
    display: block;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    background: var(--sg-green-pale);
}

.post-card-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .35s ease;
}

.post-card:hover .post-card-image img { transform: scale(1.035); }

.post-card-image--empty {
    display: grid;
    place-items: center;
    color: rgba(89,134,44,.5);
    background: linear-gradient(135deg, #f2f6ed, #e8f0df);
}

.post-card-image--empty span {
    font-size: 34px;
    font-weight: 800;
    opacity: .5;
}

.post-card-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: flex-start;
    padding: 21px 22px 22px;
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 13px;
    margin-bottom: 10px;
    color: #a0a49c;
    font-size: 12px;
    font-weight: 600;
}

.post-category {
    color: var(--sg-green);
}

.post-card h2 {
    margin: 0 0 10px;
    color: var(--sg-heading);
    font-size: 19px;
    line-height: 1.38;
    letter-spacing: -.25px;
}

.post-card h2 a { color: inherit; }
.post-card h2 a:hover { color: var(--sg-green); text-decoration: none; }

.post-card-excerpt {
    margin: 0 0 17px;
    font-size: 14px;
    line-height: 1.65;
}

.post-card-excerpt p { margin: 0; }

.read-more {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: auto;
    color: var(--sg-green);
    font-size: 13px;
    font-weight: 750;
}

.read-more::after {
    content: "→";
    font-size: 17px;
    transition: transform .2s ease;
}

.read-more:hover::after { transform: translateX(4px); }

/* =========================================
   АРХИВ
========================================= */

.archive-heading {
    margin: 12px 0 28px;
    padding: 34px 38px;
    border: 1px solid #e5eddd;
    border-radius: 18px;
    background: linear-gradient(120deg, #f3f7ee, #fbfcfa);
}

.archive-heading .description {
    max-width: 760px;
    margin-top: 12px;
}

.archive-heading .description > :last-child { margin-bottom: 0; }

.empty-state {
    padding: 36px;
    border: 1px dashed #dce6d3;
    border-radius: var(--sg-radius);
    background: #fff;
    text-align: center;
}

/* =========================================
   СТРАНИЦА ЗАПИСИ И ОБЫЧНАЯ СТРАНИЦА
========================================= */

.content-wrap {
    max-width: 860px;
    margin: 34px auto 60px;
}

.article,
.page-entry {
    padding: clamp(24px, 5vw, 52px);
    border: 1px solid var(--sg-border);
    border-radius: 20px;
    background: var(--sg-white);
    box-shadow: var(--sg-shadow);
}

.article-header { margin-bottom: 28px; }

.article-header h1,
.page-entry h1 {
    margin: 12px 0 16px;
    color: var(--sg-heading);
    font-size: clamp(30px, 4vw, 42px);
    line-height: 1.2;
    letter-spacing: -1px;
}

.article-featured-image {
    overflow: hidden;
    margin: 0 0 30px;
    border-radius: 14px;
    background: var(--sg-green-pale);
}

.article-featured-image img {
    display: block;
    width: 100%;
    height: auto;
}

.entry-content { overflow-wrap: break-word; }
.entry-content > :first-child { margin-top: 0; }
.entry-content h2,
.entry-content h3,
.entry-content h4 {
    margin-top: 1.8em;
    color: var(--sg-heading);
    line-height: 1.3;
}
.entry-content a { text-decoration: underline; text-underline-offset: 3px; }
.entry-content blockquote {
    margin: 26px 0;
    padding: 18px 24px;
    border-left: 3px solid var(--sg-green);
    border-radius: 0 10px 10px 0;
    background: var(--sg-green-pale);
}
.entry-content img { border-radius: 10px; }
.entry-content figure { margin-inline: 0; }
.entry-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
}
.entry-content th,
.entry-content td {
    padding: 11px 13px;
    border: 1px solid var(--sg-border);
    text-align: left;
}
.entry-content th { background: var(--sg-green-pale); color: var(--sg-heading); }
.entry-content pre {
    overflow-x: auto;
    padding: 18px;
    border-radius: 10px;
    background: #f4f6f2;
}
.entry-content iframe { max-width: 100%; }

.post-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 34px;
    padding-top: 22px;
    border-top: 1px solid var(--sg-border);
}

.post-tags-label {
    margin-right: 4px;
    color: #777f70;
    font-size: 13px;
    font-weight: 700;
}

.tag-link {
    display: inline-flex;
    padding: 5px 11px;
    border: 1px solid #e2ebd9;
    border-radius: 30px;
    background: var(--sg-green-pale);
    color: var(--sg-green-dark);
    font-size: 12px;
    font-weight: 600;
}

.tag-link:hover {
    border-color: var(--sg-green);
    background: var(--sg-green-light);
    text-decoration: none;
}

.post-navigation {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 22px;
}

.post-navigation a {
    display: block;
    padding: 15px 18px;
    border: 1px solid var(--sg-border);
    border-radius: 12px;
    background: #fff;
    color: var(--sg-heading);
    font-size: 14px;
    font-weight: 650;
}
.post-navigation a:hover {
    border-color: #d6e4ca;
    background: var(--sg-green-pale);
    text-decoration: none;
}
.post-navigation .nav-next { text-align: right; }
.post-navigation small {
    display: block;
    margin-bottom: 3px;
    color: #a0a49c;
    font-size: 11px;
    font-weight: 600;
}

/* =========================================
   ПАГИНАЦИЯ
========================================= */

.pagination,
.posts-pagination { margin: 34px 0 10px; }

.nav-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 7px;
}

.page-numbers {
    display: inline-flex;
    min-width: 38px;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    padding: 7px 12px;
    border: 1px solid var(--sg-border);
    border-radius: 9px;
    background: #fff;
    color: var(--sg-text);
    font-size: 14px;
}
.page-numbers.current,
.page-numbers:hover {
    border-color: var(--sg-green);
    background: var(--sg-green);
    color: #fff;
    text-decoration: none;
}

/* =========================================
   ПОДВАЛ
========================================= */

.site-footer {
    margin-top: 70px;
    padding: 34px 0 26px;
    border-top: 1px solid var(--sg-border);
    background: #f5f8f1;
}

/* Верхняя строка: логотип + меню в 2 колонки */
.footer-inner {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 20px 50px;
    padding-bottom: 22px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--sg-border);
}

.footer-brand {
    color: #77816d;
    font-weight: 750;
}
.footer-brand strong { color: var(--sg-green); }

/* Логотип в подвале */
.footer-branding .custom-logo {
    display: block;
    width: auto;
    max-width: 190px;
    max-height: 48px;
    object-fit: contain;
}

.footer-branding .site-name {
    font-size: 23px;
}

/* Меню в подвале — сразу за логотипом, горизонтальная сетка в 2 колонки */
.footer-navigation {
    margin-left: 0;
    min-width: 0;
}

.footer-menu {
    display: grid;
    grid-template-columns: repeat(2, minmax(160px, 1fr));
    grid-auto-flow: row;
    gap: 6px 40px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.footer-menu > li {
    display: block;
    width: 100%;
}

/* Подменю в подвале не выводим */
.footer-menu .sub-menu {
    display: none !important;
}

.footer-navigation a {
    display: inline-block;
    padding: 4px 0;
    color: #898989;
    font-size: 14px;
    font-weight: 600;
    transition: color .2s ease;
}

.footer-navigation a:hover {
    color: #59862c;
}

/* Юридическая информация */
.footer-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.footer-legal {
    margin: 0;
    color: #898989;
    font-size: 12px;
    line-height: 1.65;
}

.footer-legal strong {
    margin-right: 4px;
    color: var(--sg-heading);
    font-weight: 750;
}

.footer-legal a {
    color: var(--sg-green);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.footer-legal a:hover {
    color: var(--sg-green-dark);
}

.footer-copyright {
    color: #77816d;
    font-size: 13px;
    font-weight: 650;
}

/* =========================================
   ПОИСК И 404
========================================= */

.search-form {
    display: flex;
    gap: 8px;
    max-width: 560px;
    margin-top: 22px;
}
.search-form input[type="search"] {
    flex: 1;
    min-width: 0;
    padding: 12px 15px;
    border: 1px solid var(--sg-border);
    border-radius: 9px;
    color: var(--sg-text);
    background: #fff;
}
.search-form input[type="submit"] {
    padding: 12px 18px;
    border: 0;
    border-radius: 9px;
    background: var(--sg-green);
    color: #fff;
    cursor: pointer;
}
.search-form input[type="submit"]:hover { background: var(--sg-green-dark); }

/* =========================================
   ИЗОБРАЖЕНИЯ БЕЗ МИНИАТЮРЫ
========================================= */

.post-card-image-placeholder {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f3f7ee, #e8f0df);
}

.post-card-fallback-logo {
    display: block;
    width: auto;
    height: auto;
    max-width: 65%;
    max-height: 65%;
    object-fit: contain;
}

.post-card-placeholder-text {
    display: inline-flex;
    gap: 6px;
    align-items: baseline;
    color: #777f70;
    font-size: 25px;
    font-weight: 750;
}

.post-card-placeholder-text strong {
    color: #59862c;
}

/* Логотип вместо отсутствующего изображения в публикации */
.article-featured-image--placeholder {
    display: grid;
    place-items: center;
    aspect-ratio: 16 / 9;
    min-height: 220px;
    background: linear-gradient(135deg, #f3f7ee, #e8f0df);
    border-radius: 14px;
    overflow: hidden;
}

.article-featured-image--placeholder .post-card-image-placeholder {
    width: 100%;
    height: 100%;
    min-height: 220px;
}

.article-featured-image--placeholder .post-card-fallback-logo {
    max-width: 65%;
    max-height: 65%;
}

/* =========================================
   АДАПТИВ
========================================= */

@media (max-width: 900px) {
    .posts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .header-inner { gap: 18px; }
    .primary-navigation a { padding-inline: 10px; }
}

@media (max-width: 640px) {
    .container { width: min(100% - 28px, var(--sg-container)); }
    .header-inner {
        min-height: auto;
        padding-top: 17px;
        padding-bottom: 14px;
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }
    .custom-logo { max-width: 210px; max-height: 52px; }
    .site-name { font-size: 23px; }
    .primary-navigation { width: 100%; margin: 0; }
    .primary-navigation .menu,
    .primary-navigation ul {
        justify-content: flex-start;
        gap: 2px;
    }
    .primary-navigation a { padding: 8px 10px; font-size: 13px; }
    .primary-navigation .sub-menu { min-width: 190px; }

    .home-hero {
        margin: 22px 0 34px;
        padding: 34px 25px;
        border-radius: 16px;
    }
    .home-hero h1 { font-size: 31px; }
    .home-hero p { font-size: 15px; }

    .posts-grid { grid-template-columns: 1fr; gap: 16px; }
    .post-card-body { padding: 19px; }

    .archive-heading { padding: 27px 23px; }
    .content-wrap { margin-top: 22px; }
    .article, .page-entry { padding: 24px 20px; border-radius: 15px; }
    .article-header h1, .page-entry h1 { font-size: 30px; }
    .post-navigation { grid-template-columns: 1fr; }
    .post-navigation .nav-next { text-align: left; }

    /* Подвал на мобильных: логотип сверху, меню под ним в 2 колонки */
    .footer-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }
    .footer-navigation {
        width: 100%;
    }
    .footer-menu {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 4px 20px;
        width: 100%;
    }
    .footer-navigation a {
        font-size: 13px;
    }
    .footer-legal {
        font-size: 11px;
        line-height: 1.6;
    }

    /* Адаптация изображений в постах */
    .content-wrap {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }
    .article {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
    }
    .article-featured-image {
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
        overflow: hidden;
    }
    .article-featured-image img {
        display: block;
        width: 100%;
        max-width: 100%;
        height: auto;
    }
    .entry-content img,
    .entry-content video,
    .entry-content iframe {
        display: block;
        max-width: 100% !important;
        height: auto;
    }
    .entry-content figure,
    .entry-content .wp-block-image {
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
    .entry-content .alignwide,
    .entry-content .alignfull {
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
    .entry-content table,
    .entry-content pre {
        display: block;
        max-width: 100%;
        overflow-x: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
    }
}