/*
Theme Name: Scale Grid
Theme URI: https://example.com/
Author: Custom Theme
Author URI: https://example.com/
Description: Адаптивная сеточная тема WordPress с фиксированной навигацией, сайдбарами и четырьмя областями подвала.
Version: 1.0.1
Requires at least: 5.8
Requires PHP: 7.4
Text Domain: scale-grid
*/

:root {
    --sg-primary: #ff006e;
    --sg-primary-hover: #d9005d;
    --sg-header: #17191f;
    --sg-page: #0d0f12;
    --sg-card: #181b22;
    --sg-card-hover: #20242d;
    --sg-text: #f4f5f7;
    --sg-muted: #9298a5;
    --sg-border: rgba(255, 255, 255, 0.08);
    --sg-container: 1440px;
    --sg-left-width: 240px;
    --sg-right-width: 280px;
    --sg-gap: 20px;
    --sg-radius: 10px;
    --sg-header-height: 64px;
    --sg-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

body {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding-top: var(--sg-header-height);
    overflow-x: hidden;
    background: var(--sg-page);
    color: var(--sg-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
}

body.admin-bar {
    padding-top: calc(var(--sg-header-height) + 32px);
}

a {
    color: var(--sg-primary);
    text-decoration: none;
}

a:hover {
    color: var(--sg-primary-hover);
}

img,
video,
iframe,
embed,
object,
svg {
    display: block;
    max-width: 100%;
}

img,
video {
    height: auto;
}

iframe,
embed,
object {
    width: 100%;
    max-width: 100%;
}

table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
}

pre,
code {
    max-width: 100%;
    overflow-x: auto;
    overflow-wrap: break-word;
}

p,
h1,
h2,
h3,
h4,
h5,
h6,
a,
span {
    max-width: 100%;
    overflow-wrap: anywhere;
}

button,
input,
textarea,
select {
    max-width: 100%;
    font: inherit;
}

button {
    cursor: pointer;
}

.site-container {
    width: calc(100% - 32px);
    max-width: var(--sg-container);
    min-width: 0;
    margin-right: auto;
    margin-left: auto;
}

.screen-reader-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
    border: 0;
}

.screen-reader-text:focus {
    top: 5px;
    left: 5px;
    z-index: 999999;
    display: block;
    width: auto;
    height: auto;
    padding: 12px 16px;
    overflow: visible;
    clip: auto !important;
    background: #ffffff;
    color: #000000;
    font-size: 14px;
}

/* Header */

.site-header {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 1000;
    width: 100%;
    max-width: 100%;
    height: var(--sg-header-height);
    background: var(--sg-header);
    border-bottom: 1px solid var(--sg-border);
    box-shadow: var(--sg-shadow);
}

body.admin-bar .site-header {
    top: 32px;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    width: calc(100% - 32px);
    max-width: var(--sg-container);
    min-width: 0;
    height: 100%;
    margin-right: auto;
    margin-left: auto;
}

.site-branding {
    display: flex;
    flex: 0 1 auto;
    align-items: center;
    gap: 12px;
    min-width: 0;
    max-width: 70%;
}

.custom-logo-link {
    display: block;
    max-width: 150px;
}

.custom-logo {
    max-width: 100%;
    max-height: 42px;
    width: auto;
}

.site-logo {
    display: block;
    max-width: 100%;
    overflow: hidden;
    color: var(--sg-text);
    font-size: 20px;
    font-weight: 800;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-logo:hover {
    color: var(--sg-primary);
}

.site-description {
    display: none;
    margin: 0;
    color: var(--sg-muted);
    font-size: 12px;
}

/* Navigation */

.main-navigation {
    min-width: 0;
    max-width: 100%;
    margin-left: auto;
}

.main-navigation ul {
    display: flex;
    align-items: center;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.main-navigation li {
    position: relative;
    min-width: 0;
}

.main-navigation a {
    display: block;
    padding: 20px 14px;
    color: var(--sg-text);
    font-size: 14px;
    font-weight: 600;
    line-height: 24px;
    white-space: nowrap;
}

.main-navigation a:hover,
.main-navigation .current-menu-item > a,
.main-navigation .current-menu-ancestor > a {
    color: var(--sg-primary);
}

.main-navigation .menu-item-has-children > a::after {
    display: inline-block;
    margin-left: 7px;
    color: var(--sg-muted);
    content: "▾";
    font-size: 11px;
}

.main-navigation .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    display: none;
    min-width: 220px;
    padding: 8px 0;
    background: var(--sg-card);
    border: 1px solid var(--sg-border);
    border-radius: 0 0 var(--sg-radius) var(--sg-radius);
    box-shadow: var(--sg-shadow);
}

.main-navigation li:hover > .sub-menu,
.main-navigation li:focus-within > .sub-menu {
    display: block;
}

.main-navigation .sub-menu li {
    display: block;
    width: 100%;
}

.main-navigation .sub-menu a {
    padding: 10px 16px;
    white-space: normal;
}

.menu-toggle {
    display: none;
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--sg-border);
    border-radius: 8px;
}

.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    margin: 5px auto;
    background: var(--sg-text);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Main layout */

.site-content {
    width: 100%;
    max-width: 100%;
    padding: 28px 0 40px;
}

.site-layout {
    display: grid;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    grid-template-columns:
        minmax(0, var(--sg-left-width))
        minmax(0, 1fr)
        minmax(0, var(--sg-right-width));
    gap: var(--sg-gap);
    align-items: start;
}

.site-main,
.sidebar-column,
.widget-area {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.sidebar-inner {
    position: sticky;
    top: calc(var(--sg-header-height) + 20px);
}

.widget {
    width: 100%;
    max-width: 100%;
    margin-bottom: var(--sg-gap);
    padding: 16px;
    overflow: hidden;
    background: var(--sg-card);
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.widget:last-child {
    margin-bottom: 0;
}

.widget-title {
    margin: 0 0 12px;
    color: var(--sg-text);
    font-size: 17px;
    line-height: 1.3;
}

.widget ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.widget li {
    padding: 7px 0;
    border-bottom: 1px solid var(--sg-border);
}

.widget li:last-child {
    border-bottom: 0;
}

.widget a {
    color: var(--sg-text);
}

.widget a:hover {
    color: var(--sg-primary);
}

/* Content widget */

.content-widget {
    margin-bottom: var(--sg-gap);
}

.content-widget .widget {
    margin-bottom: 0;
}

/* Unified cards and previews */

.post-grid {
    display: grid;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.post-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    background: var(--sg-card);
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.post-card:hover {
    background: var(--sg-card-hover);
}

.post-thumbnail {
    position: relative;
    display: block;
    width: 100%;
    max-width: 100%;
    aspect-ratio: 16 / 9;
    margin: 0;
    overflow: hidden;
    background: #101216;
}

.post-thumbnail img {
    display: block;
    width: 100%;
    max-width: none;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.25s ease;
}

.post-card:hover .post-thumbnail img {
    transform: scale(1.04);
}

.post-thumbnail-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sg-muted);
    font-size: 13px;
}

.post-card-content {
    display: flex;
    flex: 1;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 14px 16px 16px;
}

.post-card .entry-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    color: var(--sg-muted);
    font-size: 12px;
}

.post-card .entry-title {
    display: -webkit-box;
    margin: 6px 0 0;
    overflow: hidden;
    color: var(--sg-text);
    font-size: 18px;
    line-height: 1.3;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.post-card .entry-title a {
    color: inherit;
}

.post-card .entry-title a:hover {
    color: var(--sg-primary);
}

.post-card .entry-summary {
    display: -webkit-box;
    margin-top: 8px;
    overflow: hidden;
    color: var(--sg-muted);
    font-size: 14px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

/* Single posts and pages */

.entry-content,
.page-card,
.archive-header,
.search-header,
.no-results {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 22px;
    overflow: hidden;
    background: var(--sg-card);
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.entry-title {
    margin: 0 0 10px;
    color: var(--sg-text);
    font-size: clamp(23px, 3vw, 34px);
    line-height: 1.2;
}

.entry-title a {
    color: inherit;
}

.entry-title a:hover {
    color: var(--sg-primary);
}

.entry-meta {
    margin-bottom: 14px;
    color: var(--sg-muted);
    font-size: 13px;
}

.entry-meta a {
    color: var(--sg-muted);
}

.entry-meta a:hover {
    color: var(--sg-primary);
}

.entry-content {
    margin-bottom: var(--sg-gap);
}

.entry-content > :first-child {
    margin-top: 0;
}

.entry-content > :last-child {
    margin-bottom: 0;
}

.entry-content p,
.entry-content ul,
.entry-content ol,
.entry-content blockquote {
    max-width: 100%;
    margin-top: 0;
    margin-bottom: 1.2em;
}

.entry-content ul,
.entry-content ol {
    padding-left: 22px;
}

.entry-content h2,
.entry-content h3,
.entry-content h4 {
    margin-top: 1.5em;
    line-height: 1.25;
}

.entry-content blockquote {
    margin-right: 0;
    margin-left: 0;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.04);
    border-left: 3px solid var(--sg-primary);
}

.entry-content pre {
    max-width: 100%;
    padding: 14px;
    overflow-x: auto;
    background: #090a0c;
    border-radius: 8px;
}

.entry-content code {
    max-width: 100%;
    overflow-wrap: anywhere;
}

.alignwide {
    width: 100%;
    max-width: 100%;
    margin-right: 0;
    margin-left: 0;
}

.alignfull {
    width: 100%;
    max-width: 100%;
    margin-right: 0;
    margin-left: 0;
    transform: none;
}

.wp-caption {
    max-width: 100%;
}

.wp-caption-text {
    color: var(--sg-muted);
    font-size: 13px;
}

/* Buttons and forms */

button,
input[type="submit"],
input[type="button"],
input[type="reset"],
.wp-block-button__link {
    display: inline-block;
    max-width: 100%;
    padding: 10px 16px;
    background: var(--sg-primary);
    color: #ffffff;
    border: 0;
    border-radius: 7px;
    transition: background 0.2s ease, transform 0.2s ease;
}

button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover,
.wp-block-button__link:hover {
    background: var(--sg-primary-hover);
    color: #ffffff;
    transform: translateY(-1px);
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="search"],
input[type="password"],
textarea,
select {
    width: 100%;
    max-width: 100%;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--sg-text);
    border: 1px solid var(--sg-border);
    border-radius: 7px;
}

textarea {
    min-height: 130px;
    resize: vertical;
}

/* Archive and search */

.archive-header,
.search-header {
    margin-bottom: var(--sg-gap);
}

.archive-title,
.search-title {
    margin: 0;
    font-size: clamp(24px, 4vw, 38px);
    line-height: 1.2;
}

.archive-description {
    margin-top: 12px;
    color: var(--sg-muted);
}

/* Pagination */

.pagination,
.posts-navigation {
    max-width: 100%;
    margin-top: 24px;
}

.pagination .nav-links,
.posts-navigation .nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pagination a,
.pagination span,
.posts-navigation a {
    display: inline-block;
    max-width: 100%;
    padding: 8px 12px;
    background: var(--sg-card);
    color: var(--sg-text);
    border: 1px solid var(--sg-border);
    border-radius: 7px;
}

.pagination .current,
.pagination a:hover,
.posts-navigation a:hover {
    background: var(--sg-primary);
    color: #ffffff;
}

/* Comments */

.comments-area {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-top: var(--sg-gap);
    padding: 22px;
    overflow: hidden;
    background: var(--sg-card);
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius);
}

.comments-title {
    margin-top: 0;
}

.comment-list {
    max-width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
}

.comment-list .comment {
    max-width: 100%;
    margin-bottom: 16px;
    padding-bottom: 16px;
    overflow-wrap: anywhere;
    border-bottom: 1px solid var(--sg-border);
}

.comment-meta {
    color: var(--sg-muted);
    font-size: 13px;
}

/* Footer */

.site-footer {
    width: 100%;
    max-width: 100%;
    padding: 36px 0 20px;
    background: var(--sg-header);
    border-top: 1px solid var(--sg-border);
}

.footer-widgets {
    display: grid;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--sg-gap);
}

.footer-widget {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.footer-widget .widget {
    height: 100%;
    margin-bottom: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.footer-bottom {
    max-width: 100%;
    margin-top: 28px;
    padding-top: 18px;
    color: var(--sg-muted);
    font-size: 13px;
    text-align: center;
    overflow-wrap: anywhere;
    border-top: 1px solid var(--sg-border);
}

.footer-bottom p {
    max-width: 100%;
    margin: 0;
}

/* Responsive */

@media (max-width: 1280px) {
    .post-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 1180px) {
    :root {
        --sg-left-width: 215px;
        --sg-right-width: 250px;
    }

    .main-navigation a {
        padding-right: 10px;
        padding-left: 10px;
    }
}

@media (max-width: 1020px) {
    .site-layout {
        grid-template-columns: var(--sg-left-width) minmax(0, 1fr);
    }

    .right-sidebar {
        display: none;
    }

    .footer-widgets {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 800px) {
    .post-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    :root {
        --sg-header-height: 58px;
        --sg-gap: 14px;
    }

    body.admin-bar {
        padding-top: calc(var(--sg-header-height) + 46px);
    }

    body.admin-bar .site-header {
        top: 46px;
    }

    .site-container,
    .header-inner {
        width: calc(100% - 24px);
        max-width: var(--sg-container);
        min-width: 0;
    }

    .site-content {
        width: 100%;
        max-width: 100%;
        padding-top: 18px;
    }

    .header-inner {
        position: relative;
    }

    .menu-toggle {
        display: block;
        flex: 0 0 auto;
    }

    .main-navigation {
        position: absolute;
        top: var(--sg-header-height);
        right: 0;
        left: 0;
        display: none;
        width: 100%;
        max-width: 100%;
        max-height: calc(100vh - var(--sg-header-height));
        overflow-x: hidden;
        overflow-y: auto;
        background: var(--sg-header);
        border-top: 1px solid var(--sg-border);
        box-shadow: var(--sg-shadow);
    }

    .main-navigation.is-open {
        display: block;
    }

    .main-navigation ul {
        display: block;
        width: 100%;
        max-width: 100%;
    }

    .main-navigation li {
        width: 100%;
        max-width: 100%;
        border-bottom: 1px solid var(--sg-border);
    }

    .main-navigation a {
        width: 100%;
        max-width: 100%;
        padding: 13px 16px;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .main-navigation .sub-menu {
        position: static;
        display: none;
        width: 100%;
        min-width: 0;
        padding: 0;
        background: rgba(255, 255, 255, 0.03);
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .main-navigation li.menu-item-open > .sub-menu {
        display: block;
    }

    .main-navigation .sub-menu a {
        padding-left: 32px;
    }

    .site-layout {
        display: block;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .site-main,
    .left-sidebar,
    .right-sidebar {
        display: block;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .left-sidebar,
    .right-sidebar {
        margin-top: var(--sg-gap);
    }

    .site-main {
        margin-bottom: var(--sg-gap);
    }

    .sidebar-inner {
        position: static;
    }

    .footer-widgets {
        grid-template-columns: 1fr;
    }

    .footer-widget .widget {
        height: auto;
        margin-bottom: var(--sg-gap);
        padding: 0;
    }
}

@media (max-width: 560px) {
    .post-grid {
        width: 100%;
        max-width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .post-card {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .post-card-content {
        padding: 10px;
    }

    .post-card .entry-title {
        font-size: 15px;
    }

    .post-card .entry-meta {
        font-size: 10px;
    }

    .post-card .entry-summary {
        display: none;
    }
}

@media (max-width: 480px) {
    .entry-content,
    .page-card,
    .archive-header,
    .search-header,
    .no-results,
    .comments-area {
        padding: 16px;
    }

    .entry-title {
        font-size: 25px;
    }
}

@media (max-width: 340px) {
    .post-grid {
        grid-template-columns: 1fr;
    }

    .post-card .entry-title {
        font-size: 17px;
    }
}