/*
Theme Name: Lite-v3
Theme URI: https://example.com/
Author: Олег
Author URI: https://google.com
Description: Лёгкая и быстрая тема с одноколоночной сеткой для блога. Новая синяя версия.
Version: 3.0.0
Requires at least: 5.0
Tested up to: 6.8
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: one-column, right-sidebar, custom-menu, post-formats, featured-images, translation-ready, modern, clean
Text Domain: lite-v3
*/

/*--------------------------------------------------------------
>>> TABLE OF CONTENTS:
----------------------------------------------------------------
# Reset & Basics
# Typography & Fonts
# Layout & Structure
    - Site Wrapper & Container
    - Header & Branding
    - Sidebar & Widgets (NEW)
    - Main Content
# Navigation & Menus
# Blog Grid & Posts (FIXED: List layout with 300x300 thumb and alternating alignment)
    - Post Grid Layout
    - Featured Image & Placeholder (FIXED)
# Single Post / Page
# Comments (IMPROVED)
# Forms & Search Widget (FIXED: Vertical/Adaptive)
# Footer
# Pagination
# Media Queries (Responsive)
# Editor Styles (FIX)
# Archive & 404 Styles (NEW)
--------------------------------------------------------------*/

/* # Reset & Basics
--------------------------------------------------------------*/
html {
    font-family: Merriweather, serif;
    font-size: 18px; 
    font-weight: 400;
    line-height: 1.7; 
    margin-top: 0 !important;
}

body {
    color: #333; 
    background-color: #F8F8F8; 
    margin: 0;
}

*, *:before, *:after {
    box-sizing: border-box;
}

a {
    color: #333;
    text-decoration: none;
    background-image: linear-gradient(to bottom, #3498DB 0%, #3498DB 100%); 
    background-repeat: no-repeat;
    background-size: 0 2px; 
    background-position: 0 95%;
    transition: background-size .25s ease-out;
}

a:hover {
    color: #3498DB; 
    background-size: 100% 2px;
}

img {
    max-width: 100%;
    height: auto;
    border: none !important;
    box-shadow: none !important;
    display: block; 
}

/* # Typography & Fonts
--------------------------------------------------------------*/
h1, h2, h3, h4, h5, h6 {
    font-family: Merriweather, serif;
    font-weight: 700; 
    color: #222;
    margin: 0.7em 0 0.5em;
    line-height: 1.3;
}
h1 { font-size: 2.5em; }
h2 { font-size: 2.1em; }
h3 { font-size: 1.7em; }
p { margin: 0 0 1.2em; }

.entry-title {
    font-family: Merriweather, serif;
    color: #333;
    font-size: 1.3em;
    font-weight: 700;
    margin-bottom: 0.5em;
    line-height: 1.4;
}

.entry-title a {
    background-image: linear-gradient(to bottom, #333 0%, #333 100%);
}

#site-title {
    font-family: 'Josefin Sans', sans-serif;
    font-size: 2.2em;
    font-weight: 700;
    margin: 0;
    line-height: 1;
}

#site-description {
    font-family: Lato, sans-serif;
    font-size: 0.9em;
    font-weight: 400;
    color: #888;
    margin-top: 0.5em;
}

/* # Layout & Structure
--------------------------------------------------------------*/
#site-wrapper {
    max-width: 1300px; 
    margin: 0 auto;
    padding: 20px;
}

#content {
    padding: 0;
}

#container {
    display: flex;
    flex-wrap: wrap;
    gap: 30px; 
}

.main {
    width: calc(100% - 350px - 30px);
    margin-top: 0;
    flex-grow: 1;
    order: 1;
}

/* ## Header & Branding */
#header {
    background: transparent; 
    padding: 0;
    border-bottom: none;
    text-align: center;
}
#branding {
    padding: 2em;
    background-color: #fff;
    border-radius: 6px 6px 0 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

/* ## Sidebar */
#sidebar {
    width: 350px;
    background-color: #F8F8F8; 
    padding: 0;
    margin-left: 0; 
    position: sticky;
    top: 20px;
    align-self: flex-start;
    order: 2;
}

/* # Navigation & Menus
--------------------------------------------------------------*/
#access {
    margin-top: 1.5em;
    background-color: #fff;
    padding: 10px 0;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

#access ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

#access ul li {
    margin: 0;
    border: none;
    border-bottom: 1px solid #f0f0f0;
    padding: 0;
}

#access ul li:last-child {
    border-bottom: none;
}

#access ul li a {
    display: block;
    font-family: Lato, sans-serif;
    font-size: 1em;
    font-weight: 500;
    color: #555;
    background-image: none;
    padding: 12px 20px;
    transition: background-color .2s;
}

#access ul li a:hover {
    color: #3498DB; 
    background-color: #fcfcfc;
}

/* # Blog Grid & Posts (FIXED: List layout with 300x300 thumb and alternating alignment)
--------------------------------------------------------------*/
#content-masonry {
    display: block; 
    gap: 0; 
}

article.hentry {
    background-color: #fff;
    padding: 0; 
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.07); 
    display: block; 
    overflow: hidden; 
    margin-bottom: 30px; 
}

/* Header/Title - Always full width */
.entry-header {
    padding: 20px 20px 0;
}

/* New Content Wrap for Image and Text */
.entry-content-wrap {
    padding: 0 20px 20px;
    overflow: hidden; /* Micro clearfix for floating elements inside */
}

/* Image container styling (300x300 common properties) */
.post-image-container { 
    width: 300px;
    height: 300px;
    margin-bottom: 10px;
    overflow: hidden;
    border-radius: 4px;
    background-color: #ececec;
    flex-shrink: 0; 
}

.post-image-container img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover; /* Ensures image fills 300x300 area */
    transition: none; 
}

/* --- Alternating Layout Rules --- */

/* 1. Image LEFT (Default / Odd post) */
.layout-image-left .post-image-container {
    float: left;
    margin-right: 20px;
    margin-left: 0; 
}

/* 2. Image RIGHT (Even post) */
.layout-image-right .post-image-container {
    float: right;
    margin-left: 20px;
    margin-right: 0;
}

/* Summary text block */
.entry-summary {
    overflow: hidden; /* Contains the text and meta on the side of the image */
    margin-bottom: 0; 
}

/* Meta Expert Styling (Date and Author) */
.entry-meta-expert {
    font-size: 0.9em;
    color: #888;
    margin-bottom: 1em;
    padding-bottom: 0.5em;
    border-bottom: 1px dashed #eee;
}
.entry-meta-expert a {
    color: #555;
    background-image: linear-gradient(to bottom, #3498DB 0%, #3498DB 100%); 
}
.entry-meta-expert a:hover {
    color: #3498DB; 
}
.entry-meta-expert span {
    margin-right: 15px;
}
.entry-meta-expert .onDate {
    font-style: italic;
}


/* Hiding old, deprecated elements from list view */
/* Удаление лишнего, что может конфликтовать с новой структурой */
.post-thumbnail-container, 
.entry-meta-overlay,
.entry-body-wrap {
    display: none;
}
/* Переопределяем для новой структуры: контейнер изображений должен быть видимым */
article.hentry .post-image-container {
    display: block !important; 
}


/* --- FIX: Display for single post view (uses different structure) --- */

/* Re-enable for single view, targeting main block */
.main.single-post .post-thumbnail-container,
.main.single-page .post-thumbnail-container {
    display: block; 
    position: relative;
    border-radius: 4px;
    margin-bottom: 2em;
    aspect-ratio: 16 / 9; 
    height: auto;
    overflow: hidden;
    background-color: #ececec;
    background-image: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
}
.main.single-post .post-thumbnail-container img,
.main.single-page .post-thumbnail-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.main.single-post .entry-meta-overlay,
.main.single-page .entry-meta-overlay {
    display: block;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px 20px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 0.9em;
    pointer-events: auto;
}
.main.single-post .entry-meta-overlay .author a,
.main.single-post .entry-meta-overlay .onDate {
    color: #fff;
}


/* # Single Post / Page
--------------------------------------------------------------*/
.main.single-post .hentry,
.main.single-page .hentry { 
    padding: 30px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.07);
    border-radius: 6px;
    background-color: #fff;
}

.main.single-post .entry-title,
.main.single-page .entry-title {
    font-size: 2em; 
    margin-top: 0;
    margin-bottom: 1em;
}
.main.single-post h1,
.main.single-post h2,
.main.single-post h3,
.main.single-page h1,
.main.single-page h2,
.main.single-page h3 {
    font-size: 1.4em;
    font-weight: 700;
    color: #333;
    padding-bottom: 8px;
    border-bottom: 2px solid #3498DB; 
    margin-top: 1.8em;
    margin-bottom: 1em;
}
.entry-content p {
    margin-bottom: 1.5em;
}
.entry-content a {
    background-position: 0 100%;
}


/* # Comments
--------------------------------------------------------------*/
.comments-area {
    margin-top: 2.5em;
    padding: 30px;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.07);
}

.comments-title {
    font-size: 1.7em;
    margin-bottom: 1em;
}

.comment-list {
    list-style: none;
    padding: 0;
}

.comment-list li {
    padding: 1.5em 0;
    border-bottom: 1px dashed #ddd; 
}

.comment-list li:last-child {
    border-bottom: none;
}

.comment-author img.avatar {
    float: left;
    margin-right: 1.2em;
    border-radius: 50%;
    border: 3px solid #3498DB; 
}

.comment-metadata {
    font-size: 0.9em;
    color: #888;
}

.comment-content {
    margin-top: 0.8em;
    clear: both;
}

/* # Forms & Search Widget (FIXED: Vertical/Adaptive)
--------------------------------------------------------------*/
.comment-form p {
    margin-bottom: 1.2em;
}

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea,
.widget_search input[type="search"],
.search-form input[type="search"] { 
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: border-color .2s;
    font-family: Lato, sans-serif;
    box-sizing: border-box; 
}

.comment-form input:focus,
.comment-form textarea:focus,
.widget_search input[type="search"]:focus,
.search-form input[type="search"]:focus {
    border-color: #3498DB; 
    outline: none;
}

.comment-form input[type="submit"],
.widget_search input[type="submit"],
.search-form input[type="submit"] { 
    background: #3498DB; 
    color: #fff;
    border: none;
    padding: 12px 20px;
    cursor: pointer;
    transition: background .2s, transform .1s;
    background-image: none;
    border-radius: 4px;
    font-weight: 700;
    box-sizing: border-box; 
}

.comment-form input[type="submit"]:hover,
.widget_search input[type="submit"]:hover,
.search-form input[type="submit"]:hover {
    background: #2980b9; 
    transform: translateY(-1px);
}

/* ## Search Widget Specific (FIXED: Vertical/Adaptive) */
.widget_search form,
.search-form {
    display: flex;
    flex-direction: column; 
    gap: 10px; 
    align-items: stretch; 
}

.widget_search input[type="search"],
.search-form input[type="search"] {
    flex-grow: 1; 
    width: 100%; 
    margin: 0; 
}

.widget_search input[type="submit"],
.search-form input[type="submit"] {
    flex-shrink: 0;
    width: 100%; 
    padding-left: 15px;
    padding-right: 15px;
}

/* FIX: Отображение поля ввода (с сохранением доступности) */
.search-form label span.screen-reader-text,
.search-form label span.search-field-label { 
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.widget_search label,
.search-form label {
    display: block; 
    width: 100%; 
}


/* # Widgets
--------------------------------------------------------------*/
.widget-container {
    font-family: Merriweather, serif;
    font-size: 1em;
    font-weight: 400;
    margin-bottom: 30px;
    background-color: #fff;
    padding: 20px;
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.widget-title {
    font-family: Lato, sans-serif;
    font-size: 1em;
    font-weight: 700;
    color: #333;
    border-bottom: 2px solid #3498DB; 
    padding-bottom: 0.5em;
    margin-bottom: 1em;
}

.widget-container ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.widget-container ul li {
    margin-bottom: 8px;
    border: none;
    border-bottom: 1px dashed #eee;
    padding: 5px 0;
}

.widget-container ul li a {
    background-image: linear-gradient(to bottom, #333 0%, #333 100%);
    background-position: 0 95%;
}
.widget-container ul li a:hover {
    color: #3498DB; 
}

/* # Footer
--------------------------------------------------------------*/
#footer {
    text-align: center;
    padding: 2em 0;
    margin-top: 30px;
    border-top: 1px solid #eeeeee;
    color: #888;
    font-size: 0.9em;
}

/* # Pagination
--------------------------------------------------------------*/
.navigation.pagination {
    margin: 2em 0;
    text-align: center;
    width: 100%;
}

.nav-links {
    display: inline-flex;
    gap: 8px;
}

.page-numbers {
    display: inline-block;
    padding: 8px 15px;
    border: 1px solid #ddd;
    color: #555;
    background-color: #fff;
    font-size: 1em;
    line-height: 1.5;
    background-image: none;
    border-radius: 4px;
    text-align: center;
    transition: all .2s;
}

.page-numbers:hover {
    background-color: #3498DB; 
    border-color: #3498DB; 
    color: #fff;
}

.page-numbers.current {
    background-color: #333;
    border-color: #333;
    color: #fff;
}

.page-numbers.dots {
    border: none;
    background: none;
    padding: 8px 0;
}

/* # Related Posts
--------------------------------------------------------------*/
.related-posts {
    margin-top: 2em;
    padding: 30px;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.07);
}
.related-posts h3 {
    font-size: 1.5em;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
    margin-top: 0;
}
.related-posts ul {
    list-style: none;
    padding: 0;
    margin-top: 1em;
}
.related-post-item {
    border: none;
    border-bottom: 1px dashed #eee;
    border-radius: 0;
    padding: 10px 0;
    margin-bottom: 0;
    background-color: transparent;
}
.related-post-item a {
    font-weight: 500;
}

/* # Archive & 404 Styles (NEW)
--------------------------------------------------------------*/
.page-header {
    background-color: #fff;
    padding: 30px;
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.07);
    margin-bottom: 30px;
}

.page-title {
    font-size: 2em;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 0.5em;
    color: #222;
}

.taxonomy-description {
    font-size: 1em;
    color: #666;
    margin-top: 1em;
    padding-top: 1em;
    border-top: 1px dashed #eee;
}

.error-404-main .page-404-content {
    background-color: #fff;
    padding: 30px;
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.07);
    text-align: center;
}

.error-404-main .page-content {
    max-width: 500px;
    margin: 0 auto;
}

.error-404-main .page-content ul {
    list-style: none;
    padding: 0;
    margin-top: 1em;
    text-align: left;
    display: inline-block;
}
.error-404-main .page-content li {
    padding: 5px 0;
    border-bottom: 1px dashed #eee;
}


/* # Media Queries (Responsive)
--------------------------------------------------------------*/
@media (max-width: 1024px) {
    #container {
        flex-direction: column;
        gap: 0;
    }
    .main {
        width: 100%;
        order: 1;
    }
    #sidebar {
        width: 100%;
        margin-top: 30px;
        position: static;
        order: 2;
    }
    #site-wrapper {
        padding: 10px;
    }
    #content-masonry {
        gap: 0;
    }
    .page-header {
        margin-bottom: 20px;
        padding: 20px;
    }
    
    /* Global fix for mobile: no float, full width image */
    .post-image-container {
        width: 100% !important;
        height: auto !important;
        float: none !important;
        margin-right: 0 !important;
        margin-left: 0 !important;
        margin-bottom: 15px !important;
        aspect-ratio: 16 / 9;
    }
    
    /* Убираем лишние правила float для мобильных устройств */
    .layout-image-right .post-image-container,
    .layout-image-left .post-image-container {
        float: none;
    }

    .entry-content-wrap {
        padding: 0 20px 20px;
        overflow: visible; 
    }
    
    .entry-summary {
        overflow: visible; 
    }

}

@media (max-width: 768px) {
    html {
        font-size: 17px;
    }
    .main.single-post .hentry,
    .main.single-page .hentry {
        padding: 20px;
    }
    .main.single-post .entry-title,
    .main.single-page .entry-title {
        font-size: 1.8em;
    }
}

/* # Editor Styles (FIX)
--------------------------------------------------------------*/
/* Стиль для блока изображения в редакторе Gutenberg */
.wp-block-image img {
    height: auto;
    width: auto;
    max-width: 100%;
}