/*
Theme Name: PageSorter Theme
Theme URI: https://page-sort.ru/
Author: PageSorter
Description: Минимальная WordPress-native тема для нового сайта PageSorter.
Version: 0.1.0
Requires at least: 6.0
Requires PHP: 8.0
Text Domain: pagesort-theme
*/

@font-face {
    font-family: "Inter";
    src: url("assets/fonts/InterVariable.woff2") format("woff2");
    font-display: swap;
    font-style: normal;
    font-weight: 100 900;
}

:root {
    --ps-primary: #2196f3;
    --ps-primary-dark: #1976d2;
    --ps-primary-soft: #e3f2fd;
    --ps-primary-soft-hover: #d6ecff;
    --ps-bg: #f5f7fb;
    --ps-card: #ffffff;
    --ps-surface: #ffffff;
    --ps-surface-soft: #f8fbff;
    --ps-surface-muted: #f2f4f7;
    --ps-text: #1d2939;
    --ps-muted: #667085;
    --ps-footer-text: #667085;
    --ps-border: #dde5ef;
    --ps-focus: rgba(33, 150, 243, 0.28);
    --ps-error: #c62828;
    --ps-danger-soft: #fff1f0;
    --ps-success: #2e7d32;
    --ps-warning: #9a6700;
    --ps-disabled-bg: #f2f4f7;
    --ps-overlay: rgba(255, 255, 255, 0.9);
    --ps-backdrop: rgba(18, 24, 38, 0.58);
    --ps-on-primary: #ffffff;
    --ps-tooltip-bg: #111827;
    --ps-tooltip-text: #ffffff;
    --ps-shadow: 0 10px 30px rgba(28, 44, 64, 0.08);
    --ps-layout: 1080px;
    --ps-radius: 14px;
}

html[data-theme="dark"] {
    --ps-primary: #64b5f6;
    --ps-primary-dark: #90caf9;
    --ps-primary-soft: #263238;
    --ps-primary-soft-hover: #30454f;
    --ps-bg: #121212;
    --ps-card: #1e1e1e;
    --ps-surface: #1e1e1e;
    --ps-surface-soft: #263238;
    --ps-surface-muted: #242424;
    --ps-text: #e0e0e0;
    --ps-muted: #888888;
    --ps-footer-text: #888888;
    --ps-border: #333333;
    --ps-focus: rgba(100, 181, 246, 0.34);
    --ps-error: #ef9a9a;
    --ps-danger-soft: #3d2525;
    --ps-success: #a5d6a7;
    --ps-warning: #ffd54f;
    --ps-disabled-bg: #2b2b2b;
    --ps-overlay: rgba(30, 30, 30, 0.94);
    --ps-backdrop: rgba(0, 0, 0, 0.68);
    --ps-tooltip-bg: #e0e0e0;
    --ps-tooltip-text: #121212;
    --ps-shadow: 0 16px 36px rgba(0, 0, 0, 0.32);
}

* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
}

html.is-menu-open,
html.is-menu-open body {
    overflow: hidden;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--ps-bg);
    color: var(--ps-text);
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;
    text-rendering: optimizeLegibility;
}

a {
    color: var(--ps-primary-dark);
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.16em;
}

a:hover {
    color: var(--ps-primary);
}

a:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--ps-focus);
}

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

.site-header {
    position: relative;
    z-index: 10;
    background: var(--ps-card);
    border-bottom: 1px solid var(--ps-border);
}

.site-header__inner,
.site-footer__inner,
.site-main {
    width: min(var(--ps-layout), calc(100% - 2rem));
    margin: 0 auto;
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 0;
}

.site-branding {
    display: flex;
    flex: 0 1 auto;
    flex-direction: column;
    gap: 0.15rem;
}

.site-title {
    color: var(--ps-text);
    font-size: 1.4rem;
    font-weight: 750;
    line-height: 1.15;
    text-decoration: none;
}

.site-title:hover {
    color: var(--ps-primary-dark);
}

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

.site-header__actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex: 0 0 auto;
}

.theme-toggle,
.menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.65rem;
    height: 2.65rem;
    border: 1px solid var(--ps-border);
    border-radius: 999px;
    appearance: none;
    background: var(--ps-surface-soft);
    color: var(--ps-primary-dark);
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.theme-toggle:hover,
.menu-toggle:hover {
    border-color: var(--ps-primary);
    background: var(--ps-primary-soft-hover);
    color: var(--ps-primary-dark);
}

.theme-toggle:focus-visible,
.menu-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--ps-focus);
}

.theme-toggle__icon {
    width: 1.25rem;
    height: 1.25rem;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.theme-toggle__icon_sun,
html[data-theme="dark"] .theme-toggle__icon_moon {
    display: none;
}

html[data-theme="dark"] .theme-toggle__icon_sun {
    display: block;
}

.menu-toggle {
    display: none;
    position: relative;
    z-index: 30;
    flex-direction: column;
    gap: 0.26rem;
}

.menu-toggle__bar {
    display: block;
    width: 1.15rem;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

html.is-menu-open .menu-toggle__bar:nth-child(1) {
    transform: translateY(0.38rem) rotate(45deg);
}

html.is-menu-open .menu-toggle__bar:nth-child(2) {
    opacity: 0;
}

html.is-menu-open .menu-toggle__bar:nth-child(3) {
    transform: translateY(-0.38rem) rotate(-45deg);
}

.site-navigation-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: var(--ps-backdrop);
}

.site-description {
    margin: 0;
    color: var(--ps-muted);
    font-size: 0.9rem;
}

.primary-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.primary-menu .menu-item {
    list-style: none;
}

.primary-menu .sub-menu {
    margin: 0;
    padding: 0;
    list-style: none;
}

.primary-menu a {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    color: var(--ps-text);
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.primary-menu a:hover,
.primary-menu .current-menu-item > a,
.primary-menu .current-menu-ancestor > a {
    background: var(--ps-primary-soft);
    color: var(--ps-primary-dark);
}

.submenu-toggle {
    display: none;
}

.site-main {
    flex: 1;
    padding: 2rem 0 3rem;
}

.content-card {
    background: var(--ps-card);
    border: 1px solid var(--ps-border);
    border-radius: var(--ps-radius);
    box-shadow: var(--ps-shadow);
    padding: 2rem;
    overflow-wrap: break-word;
}

.content-card_tool {
    padding: clamp(1rem, 3vw, 2.5rem);
}

.entry-title {
    margin: 0 0 1rem;
    color: var(--ps-primary-dark);
    font-size: 2rem;
    line-height: 1.12;
}

.entry-content {
    color: var(--ps-text);
}

.entry-content > * {
    margin: 0 0 1rem;
}

.entry-content > hr,
.entry-content > .wp-block-separator {
    margin: 2rem 0;
}

.entry-content > :last-child {
    margin-bottom: 0;
}

.entry-content > :where(h2, h3, h4, h5, h6),
.entry-content .wp-block-heading {
    color: var(--ps-primary-dark);
    font-weight: 750;
    line-height: 1.22;
}

.entry-content > h2,
.entry-content .wp-block-heading:is(h2) {
    font-size: 1.5rem;
}

.entry-content > h3,
.entry-content .wp-block-heading:is(h3) {
    font-size: 1.25rem;
}

.entry-content > h4,
.entry-content .wp-block-heading:is(h4) {
    font-size: 1.1rem;
}

.entry-content > p small,
.entry-content .wp-block-caption,
.entry-content figcaption {
    color: var(--ps-muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

.entry-content > p strong,
.entry-content > :where(ul, ol) strong {
    color: var(--ps-text);
    font-weight: 750;
}

.entry-content > :where(ul, ol),
.entry-content .wp-block-list {
    padding-left: 1.35rem;
}

.entry-content > :where(ul, ol) :where(ul, ol),
.entry-content .wp-block-list :where(ul, ol) {
    margin-top: 0.35rem;
}

.entry-content > :where(ul, ol) li + li,
.entry-content .wp-block-list li + li {
    margin-top: 0.35rem;
}

.entry-content > :where(ul, ol) li::marker,
.entry-content .wp-block-list li::marker {
    color: var(--ps-primary);
    font-weight: 700;
}

.entry-content > p code,
.entry-content > :where(ul, ol) code,
.entry-content .wp-block-code code {
    padding: 0.1rem 0.28rem;
    border-radius: 6px;
    background: var(--ps-primary-soft);
    color: var(--ps-primary-dark);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.92em;
}

.entry-content > pre,
.entry-content > .wp-block-code,
.entry-content > .wp-block-preformatted {
    padding: 1rem;
    border: 1px solid var(--ps-border);
    border-radius: 10px;
    background: var(--ps-surface-soft);
    overflow-x: auto;
    color: var(--ps-text);
}

.entry-content .wp-block-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.entry-content .wp-block-button__link,
.entry-content .wp-block-file__button,
.entry-content .wp-block-search__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.65rem;
    padding: 0.65rem 1rem;
    border: 1px solid var(--ps-primary);
    border-radius: 8px;
    background: var(--ps-primary);
    color: var(--ps-on-primary);
    font: inherit;
    font-weight: 650;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.entry-content .wp-block-button__link:hover,
.entry-content .wp-block-file__button:hover,
.entry-content .wp-block-search__button:hover {
    border-color: var(--ps-primary-dark);
    background: var(--ps-primary-dark);
    color: var(--ps-on-primary);
}

.entry-content .wp-block-button__link:focus-visible,
.entry-content .wp-block-file__button:focus-visible,
.entry-content .wp-block-search__button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--ps-focus);
}

.entry-content .wp-block-button.is-style-outline > .wp-block-button__link {
    background: transparent;
    color: var(--ps-primary-dark);
}

.entry-content .wp-block-button.is-style-outline > .wp-block-button__link:hover {
    background: var(--ps-primary-dark);
    color: var(--ps-on-primary);
}

.entry-content .wp-block-separator {
    border: 0;
    border-top: 1px solid var(--ps-border);
    background: transparent;
}

.entry-content .wp-block-separator.is-style-wide {
    width: 100%;
}

.entry-content .wp-block-details {
    padding: 0;
    border: 0;
}

.entry-content .wp-block-details > summary {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 2.5rem;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--ps-border);
    border-radius: 10px;
    background: var(--ps-surface-soft);
    color: var(--ps-primary-dark);
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}

.entry-content .wp-block-details > summary::-webkit-details-marker {
    display: none;
}

.entry-content .wp-block-details > summary::before {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 1.45rem;
    height: 1.45rem;
    border-radius: 999px;
    background: var(--ps-primary);
    color: var(--ps-on-primary);
    content: "+";
    font-weight: 800;
    line-height: 1;
}

.entry-content .wp-block-details[open] > summary::before {
    content: "-";
}

.entry-content .wp-block-details > summary:hover,
.entry-content .wp-block-details > summary:focus-visible {
    border-color: var(--ps-primary);
    background: var(--ps-primary-soft-hover);
    outline: none;
    box-shadow: 0 0 0 3px var(--ps-focus);
}

.entry-content .wp-block-details > :not(summary) {
    margin: 0.85rem 0 0;
}

.entry-content .wp-block-accordion {
    display: grid;
    gap: 0.75rem;
}

.entry-content .wp-block-accordion-item {
    padding: 0.85rem 1rem;
    border: 1px solid var(--ps-border);
    border-radius: 12px;
    background: var(--ps-surface);
    overflow-wrap: anywhere;
}

.entry-content .wp-block-accordion-heading {
    margin: 0;
}

.entry-content .wp-block-quote,
.entry-content .wp-block-pullquote {
    padding: 1rem;
    border: 1px solid var(--ps-border);
    border-left: 4px solid var(--ps-primary);
    border-radius: 10px;
    background: var(--ps-primary-soft);
    color: var(--ps-text);
}

.entry-content .wp-block-quote cite,
.entry-content .wp-block-pullquote cite {
    color: var(--ps-muted);
    font-size: 0.9rem;
}

.entry-content .wp-block-table {
    overflow-x: auto;
}

.entry-content .wp-block-table table {
    width: 100%;
    min-width: 32rem;
    border-collapse: collapse;
    background: var(--ps-surface);
}

.entry-content .wp-block-table th,
.entry-content .wp-block-table td {
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--ps-border);
    text-align: left;
    vertical-align: top;
}

.entry-content .wp-block-table th {
    background: var(--ps-primary-soft);
    color: var(--ps-primary-dark);
    font-weight: 750;
}

.entry-content .wp-block-group {
    padding: 0;
}

.entry-content .wp-block-group.has-background {
    padding: 1rem;
    border-radius: 12px;
}

.entry-content .wp-block-columns {
    gap: 1rem;
}

.entry-content .wp-block-media-text {
    gap: 1.25rem;
}

.entry-content .wp-block-image img,
.entry-content .wp-block-gallery img,
.entry-content .wp-block-media-text img {
    border-radius: 10px;
}

.entry-content .wp-block-search {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.entry-content .wp-block-search__inside-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    width: 100%;
}

.entry-content .wp-block-search__input {
    flex: 1 1 16rem;
    min-height: 2.65rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--ps-border);
    border-radius: 8px;
    background: var(--ps-surface);
    color: var(--ps-text);
    font: inherit;
    line-height: 1.4;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.entry-content .wp-block-search__input:focus {
    border-color: var(--ps-primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--ps-focus);
}

.entry-content .wp-block-file {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
}

.content-card .entry-content > .alignwide,
.content-card .entry-content > .alignfull {
    width: 100%;
    max-width: 100%;
    margin-right: 0;
    margin-left: 0;
}

.site-footer {
    margin-top: auto;
    background: var(--ps-card);
    border-top: 1px solid var(--ps-border);
}

.site-footer__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.5rem 0;
    color: var(--ps-footer-text);
    font-size: 0.95rem;
}

.site-footer__info,
.site-footer__links {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.site-footer__info {
    flex-wrap: wrap;
}

.site-footer__info strong {
    color: var(--ps-text);
}

.site-footer__links a {
    color: var(--ps-footer-text);
}

.site-footer__links a:hover {
    color: var(--ps-primary-dark);
}

.site-footer__icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    border: 1px solid var(--ps-border);
    border-radius: 999px;
    background: var(--ps-surface-soft);
    text-decoration: none;
}

.site-footer__icon-link svg {
    width: 1.15rem;
    height: 1.15rem;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

@media (min-width: 992px) {
    .site-navigation {
        display: block;
    }

    .primary-menu > .menu-item {
        position: relative;
    }

    .primary-menu .sub-menu {
        position: absolute;
        top: calc(100% + 0.5rem);
        left: 0;
        z-index: 30;
        min-width: 13rem;
        padding: 0.45rem;
        background: var(--ps-card);
        border: 1px solid var(--ps-border);
        border-radius: 14px;
        box-shadow: var(--ps-shadow);
        opacity: 0;
        pointer-events: none;
        transform: translateY(-0.25rem);
        visibility: hidden;
        transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
    }

    .primary-menu .sub-menu::before {
        content: "";
        position: absolute;
        right: 0;
        bottom: 100%;
        left: 0;
        height: 0.5rem;
    }

    .primary-menu .menu-item-has-children:hover > .sub-menu,
    .primary-menu .menu-item-has-children:focus-within > .sub-menu {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
        visibility: visible;
    }

    .primary-menu .sub-menu a {
        display: flex;
        width: 100%;
        min-width: max-content;
        padding: 0.55rem 0.7rem;
        border-radius: 10px;
        white-space: nowrap;
    }
}

@media (max-width: 991.98px) {
    html.has-js .site-header__inner {
        flex-wrap: nowrap;
    }

    html.has-js .site-branding {
        min-width: 0;
    }

    html.has-js .site-title,
    html.has-js .site-description {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    html.has-js .menu-toggle {
        display: inline-flex;
    }

    html.has-js .site-navigation {
        position: fixed;
        top: 0;
        right: 0;
        z-index: 25;
        width: 100%;
        max-width: 450px;
        height: 100dvh;
        margin-left: 0;
        padding: clamp(4.5rem, 10vw, 5.5rem) 1.25rem 1.5rem;
        background: var(--ps-card);
        border-left: 1px solid var(--ps-border);
        box-shadow: var(--ps-shadow);
        overflow-y: auto;
        transform: translateX(100%);
        transition: transform 0.22s ease;
    }

    html.has-js.is-menu-open .site-navigation {
        transform: translateX(0);
    }

    html.has-js .primary-menu {
        flex-direction: column;
        gap: 0.35rem;
    }

    html.has-js .primary-menu > .menu-item-has-children {
        display: flex;
        flex-wrap: wrap;
        align-items: stretch;
        gap: 0.35rem;
    }

    html.has-js .primary-menu a {
        width: 100%;
        min-height: 2.85rem;
        padding: 0.75rem 0.9rem;
        border-radius: 10px;
    }

    html.has-js .primary-menu > .menu-item-has-children > a {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
    }

    html.has-js .submenu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 2.85rem;
        min-height: 2.85rem;
        border: 1px solid var(--ps-border);
        border-radius: 10px;
        appearance: none;
        background: var(--ps-surface-soft);
        color: var(--ps-primary-dark);
        cursor: pointer;
        transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    }

    html.has-js .submenu-toggle::before {
        content: "";
        width: 0.45rem;
        height: 0.45rem;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: translateY(-0.1rem) rotate(45deg);
        transition: transform 0.2s ease;
    }

    html.has-js .submenu-toggle:hover {
        border-color: var(--ps-primary);
        background: var(--ps-primary-soft-hover);
    }

    html.has-js .submenu-toggle:focus-visible {
        outline: none;
        box-shadow: 0 0 0 3px var(--ps-focus);
    }

    html.has-js .is-submenu-open > .submenu-toggle::before {
        transform: translateY(0.1rem) rotate(225deg);
    }

    html.has-js .primary-menu .sub-menu {
        display: none;
        flex: 0 0 100%;
        width: 100%;
        margin: 0.1rem 0 0;
        padding: 0.15rem 0 0.2rem 0.85rem;
        border-left: 1px solid var(--ps-border);
    }

    html.has-js .primary-menu .is-submenu-open > .sub-menu {
        display: block;
    }

    html.has-js .primary-menu .sub-menu a {
        min-height: 2.55rem;
        padding: 0.65rem 0.75rem;
        color: var(--ps-muted);
    }
}

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

@media (max-width: 700px) {
    .site-header__inner,
    .site-footer__inner {
        flex-direction: column;
        align-items: flex-start;
    }

    html.has-js .site-header__inner {
        flex-direction: row;
        align-items: center;
    }

    .site-footer__links {
        flex-wrap: wrap;
    }

    .content-card {
        padding: 1rem;
    }

    .entry-title {
        font-size: 1.7rem;
    }

    .entry-content .wp-block-buttons,
    .entry-content .wp-block-button,
    .entry-content .wp-block-button__link,
    .entry-content .wp-block-file__button,
    .entry-content .wp-block-search__button {
        width: 100%;
    }

    .entry-content .wp-block-search__inside-wrapper {
        flex-direction: column;
    }

    .entry-content .wp-block-search__input {
        flex-basis: auto;
        width: 100%;
    }

    .entry-content .wp-block-media-text.is-stacked-on-mobile {
        display: block;
    }

    .entry-content .wp-block-details > summary {
        align-items: flex-start;
    }

    .entry-content .wp-block-table table {
        min-width: 28rem;
    }
}
