/*
Theme Name: Первый сейв
Description: Тема игрового медиа «Первый сейв».
Version: 2.2.1
Requires PHP: 8.3
Text Domain: perviy-seyv
*/

@font-face {
    font-family: Onest;
    src: url('assets/onest-cyrillic.woff2') format('woff2');
    font-weight: 100 900;
    font-display: swap;
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: Onest;
    src: url('assets/onest-latin.woff2') format('woff2');
    font-weight: 100 900;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    color-scheme: dark;
    --page: #101114;
    --panel: #1a1b20;
    --raised: #25272d;
    --rule: #303238;
    --ink: #f7f7f4;
    --muted: #b0b1bc;
    --accent: #d9fa68;
    --accent-ink: #191e12;
    --radius: 16px;
    --gutter: clamp(16px, 3.75vw, 56px);
    --editorial-columns: minmax(0, 2.35fr) minmax(270px, 1fr);
    --editorial-gap: clamp(16px, 2vw, 26px);
    font: 16px/1.5 Onest, system-ui, sans-serif;
    color: var(--ink);
    background: var(--page);
}

*, *::before, *::after { box-sizing: border-box; }
body, p, h1, h2, h3, figure, ul, dl, dd { margin: 0; }
body { min-width: 0; }
img { display: block; max-width: 100%; }
a { color: var(--accent); text-underline-offset: .22em; }
a:hover { text-decoration-thickness: 2px; }
button, input { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
:target { scroll-margin-block-start: 124px; }
[hidden] { display: none !important; }
.shell { width: min(1280px, 100% - var(--gutter) * 2); margin-inline: auto; }
.landing { padding-block: 28px clamp(48px, 7vw, 96px); }

.visually-hidden, .skip:not(:focus) {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    white-space: nowrap;
    clip-path: inset(50%);
}

.skip:focus {
    position: fixed;
    top: 12px;
    left: var(--gutter);
    z-index: 20;
    padding: 10px 16px;
    background: var(--panel);
}

.masthead {
    position: sticky;
    top: 0;
    z-index: 5;
    border-bottom: 1px solid var(--rule);
    background: var(--page);
}

.admin-bar .masthead { top: 32px; }

.masthead-inner {
    display: grid;
    grid-template-columns: minmax(max-content, 1fr) auto minmax(max-content, 1fr);
    min-height: 72px;
    align-items: center;
    gap: 20px;
}

.wordmark {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    white-space: nowrap;
    text-decoration: none;
    font-size: 1.45rem;
    font-weight: 820;
    letter-spacing: -.055em;
}

.mark {
    width: 34px;
    aspect-ratio: 1;
    flex: none;
    background: url('assets/icon.svg?v=2') center / contain no-repeat;
}

.masthead nav { display: flex; align-items: center; gap: clamp(16px, 2.4vw, 34px); }

.masthead nav a {
    position: relative;
    display: inline-flex;
    min-height: 72px;
    align-items: center;
    color: var(--muted);
    white-space: nowrap;
    font-size: .94rem;
    font-weight: 650;
    text-decoration: none;
}

.masthead nav a:hover, .masthead nav a[aria-current] { color: var(--ink); }
.masthead nav a[aria-current]::after {
    position: absolute;
    inset: auto 0 -1px;
    height: 2px;
    background: var(--accent);
    content: '';
}

.quick-search { position: relative; justify-self: end; }

.quick-search summary {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid var(--rule);
    border-radius: 999px;
    list-style: none;
    color: var(--ink);
    font-size: .875rem;
    font-weight: 690;
    cursor: pointer;
}

.quick-search summary::-webkit-details-marker { display: none; }
.quick-search summary:hover, .quick-search[open] summary { background: var(--panel); }

.search-icon {
    position: relative;
    display: inline-block;
    width: 13px;
    height: 13px;
    margin-right: 2px;
    border: 1.75px solid currentColor;
    border-radius: 50%;
}

.search-icon::after {
    position: absolute;
    width: 6px;
    height: 1.75px;
    right: -5px;
    bottom: -2px;
    background: currentColor;
    transform: rotate(46deg);
    content: '';
}

.quick-search form {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    z-index: 1;
    display: flex;
    gap: 8px;
    width: min(370px, 100vw - var(--gutter) * 2);
    padding: 10px;
    border: 1px solid var(--rule);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: 0 12px 30px #0007;
}

.quick-search input {
    width: 100%;
    min-width: 0;
    padding: 0 10px;
    border: 1px solid var(--rule);
    border-radius: 8px;
    background: var(--page);
    color: var(--ink);
}

.action {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: .9375rem;
    font-weight: 780;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.action:hover { background: #e6ff99; }

.front-lead { display: grid; gap: var(--editorial-gap); }
.front-lead--with-rail { grid-template-columns: var(--editorial-columns); }

.feature-stage {
    display: grid;
    grid-template-rows: 1fr auto;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--panel);
}

.feature-stage .feature {
    grid-area: 1 / 1;
    min-height: clamp(334px, 29vw, 406px);
    border-radius: 0;
}

.feature-tabs {
    grid-area: 2 / 1;
    display: flex;
    gap: 5px;
    padding: 6px;
    border-top: 1px solid var(--rule);
}

.feature-tabs button {
    flex: 1 1 0;
    min-height: 44px;
    padding: 5px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-weight: 720;
    font-size: .9rem;
    cursor: pointer;
}

.feature-tabs button:hover { color: var(--ink); background: var(--raised); }
.feature-tabs button[aria-selected='true'] { border-color: #3b442a; background: #272d1b; color: var(--accent); }
.feature-tabs button:focus-visible { outline-offset: -2px; }

@media (prefers-reduced-motion: no-preference) {
    .feature[role='tabpanel']:not([hidden]) .feature-copy { animation: feature-enter 170ms ease-out both; }

    @keyframes feature-enter {
        from { opacity: .68; transform: translateY(3px); }
        to { opacity: 1; transform: translateY(0); }
    }
}

.feature, .topic-hero {
    position: relative;
    isolation: isolate;
    display: flex;
    align-items: flex-end;
    min-height: clamp(360px, 33vw, 450px);
    border-radius: var(--radius);
    background: var(--panel);
}

.feature-media, .topic-cover {
    position: absolute;
    inset: 0;
    z-index: -1;
}

.feature-media img, .topic-cover img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius);
    object-fit: cover;
    object-position: center 57%;
}

.feature-media::after, .topic-cover::after {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(0deg, #0d0e12 4%, #0d0e12df 26%, #0d0e1233 66%, #0d0e1200 90%),
        linear-gradient(90deg, #0d0e1266 0%, #0d0e1200 73%);
    pointer-events: none;
    content: '';
}

.feature-media, .topic-cover { border-radius: inherit; }

.feature-media figcaption, .topic-cover figcaption {
    position: absolute;
    z-index: 1;
    top: 12px;
    right: 12px;
    max-width: calc(100% - 24px);
    padding: 3px 8px;
    border-radius: 6px;
    background: #101114d9;
    color: var(--ink);
    font-size: .6875rem;
}

.feature-media figcaption a, .topic-cover figcaption a { color: inherit; }

.feature-copy, .topic-copy { padding: clamp(23px, 3.2vw, 48px); }

.feature h2, .topic-copy h1, .section-lead h1, .article-head h1 {
    font-size: clamp(2.45rem, 5vw, 4.4rem);
    font-weight: 800;
    line-height: 1.015;
    letter-spacing: -.065em;
    overflow-wrap: anywhere;
    text-wrap: balance;
}

.feature h2 {
    display: -webkit-box;
    max-width: 20ch;
    overflow: hidden;
    font-size: clamp(2.2rem, 4.65vw, 4rem);
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}
.feature-summary, .topic-copy > p {
    max-width: 42ch;
    margin-top: 11px;
    color: #e3e3e8;
    font-size: clamp(.94rem, 1.3vw, 1.06rem);
}

.feature-summary {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.feature-link { margin-top: 22px; }

.guide-rail {
    display: flex;
    flex-direction: column;
    padding: clamp(17px, 1.8vw, 24px);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--panel);
}

.guide-rail h2, .related h2 { font-size: 1.3rem; line-height: 1.2; letter-spacing: -.035em; }
.guide-rail ul, .related ul { padding: 0; list-style: none; }
.guide-rail ul { margin-block: 9px 13px; }
.guide-rail li + li { border-top: 1px solid var(--rule); }

.guide-rail li a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 73px;
    padding-block: 9px;
    color: var(--ink);
    text-decoration: none;
}

.guide-rail-image {
    width: clamp(60px, 5.5vw, 76px);
    height: auto;
    flex: none;
    aspect-ratio: 4 / 3;
    border-radius: 8px;
    object-fit: cover;
    background: var(--raised);
}

.guide-label {
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 680;
    line-height: 1.2;
}

.guide-rail strong { display: block; font-size: .94rem; line-height: 1.25; }
.guide-rail li a:hover strong, .story-link:hover .story-title { color: var(--accent); }

.rail-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    min-height: 43px;
    margin-top: auto;
    padding: 8px 12px;
    border: 1px solid var(--rule);
    border-radius: 8px;
    color: var(--ink);
    font-size: .875rem;
    font-weight: 710;
    text-decoration: none;
}

.rail-link span { color: var(--accent); font-size: 1.15rem; }
.rail-link:hover { background: var(--raised); }

.topic-hero + .feed { margin-top: clamp(32px, 4vw, 56px); }

.editorial-layout {
    display: grid;
    grid-template-columns: var(--editorial-columns);
    align-items: start;
    gap: var(--editorial-gap);
}

.editorial-layout--after-lead { margin-top: clamp(25px, 3vw, 42px); }
.editorial-layout .story-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.editorial-layout--event { grid-template: 'feed event' auto 'feed sections' 1fr / var(--editorial-columns); }
.editorial-layout--event .feed { grid-area: feed; }
.editorial-layout--event .editorial-sidebar { grid-area: sections; }

.event-card {
    grid-area: event;
    padding: clamp(17px, 1.8vw, 24px);
    border: 1px solid #3b442a;
    border-radius: var(--radius);
    background: #1c2118;
}

.event-caption {
    margin-bottom: 7px;
    color: var(--accent);
    font-weight: 720;
    font-size: .78rem;
}

.event-card h2 { font-size: 1.25rem; line-height: 1.22; letter-spacing: -.03em; }
.event-card h2 a { color: var(--ink); text-decoration: none; }
.event-card h2 a:hover { text-decoration: underline; }
.event-time { margin-top: 7px; color: var(--muted); font-size: .85rem; }

.event-countdown {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 14px;
}

.event-countdown span {
    padding: 7px 3px;
    border: 1px solid #394230;
    border-radius: 7px;
    font-size: .75rem;
    text-align: center;
    white-space: nowrap;
}

.event-countdown strong { color: var(--accent); font-variant-numeric: tabular-nums; font-size: 1.12rem; }

.section-links, .article-toc {
    padding: clamp(17px, 2vw, 24px);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--panel);
}

.section-links h2, .article-toc summary {
    font-size: 1.24rem;
    font-weight: 760;
    letter-spacing: -.025em;
}

.section-links ul { margin-top: 9px; padding: 0; list-style: none; }
.section-links li + li { border-top: 1px solid var(--rule); }
.section-links a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    min-height: 46px;
    color: var(--ink);
    font-weight: 650;
    text-decoration: none;
}

.section-links a:hover, .section-links a[aria-current], .section-links a span { color: var(--accent); }

.ad-slot {
    min-height: 250px;
    margin-block: 20px;
}

.section-heading {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px 20px;
    min-height: 44px;
    margin-bottom: 18px;
}

.section-heading h1, .section-heading h2 {
    font-size: clamp(1.9rem, 3.2vw, 2.65rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -.055em;
}

.feed-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    padding: 3px;
    border: 1px solid var(--rule);
    border-radius: 999px;
    background: var(--panel);
}

.feed-controls button {
    min-height: 36px;
    padding: 4px 14px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: .875rem;
    font-weight: 700;
    cursor: pointer;
}

.feed-controls button:hover { color: var(--ink); }
.feed-controls button[aria-pressed='true'] { background: var(--ink); color: var(--page); }
.feed-controls [data-filter-count] { margin-left: .4em; font-size: .75em; opacity: .8; font-variant-numeric: tabular-nums; }

.story-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(16px, 2vw, 26px);
}

.story { min-width: 0; }

.story-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--panel);
    color: var(--ink);
    text-decoration: none;
}

.story-link:hover { border-color: #595c65; }

.story-image {
    overflow: hidden;
    aspect-ratio: 16 / 9;
    border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
    background: var(--raised);
}

.story-image img { width: 100%; height: 100%; object-fit: cover; }
.story-copy { padding: clamp(15px, 1.7vw, 22px); }

.category {
    color: var(--accent);
    font-size: .75rem;
    font-weight: 700;
    line-height: 1.3;
}

.category time { color: var(--muted); font-weight: 520; white-space: nowrap; }
.category time::before { content: '·'; display: inline-block; margin-inline: .5em; }

.story-title {
    margin-top: 7px;
    font-size: clamp(1.15rem, 1.75vw, 1.45rem);
    font-weight: 750;
    line-height: 1.19;
    letter-spacing: -.035em;
    overflow-wrap: anywhere;
}

.story-title + p { max-width: 49ch; margin-top: 9px; color: var(--muted); font-size: .875rem; line-height: 1.48; }

.footer { border-top: 1px solid var(--rule); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px 30px; padding-block: 24px; }
.footer .wordmark { font-size: 1.2rem; }
.footer .mark { width: 28px; }
.footer nav { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.footer nav a { color: var(--muted); font-size: .875rem; text-decoration: none; }
.footer nav a:hover { color: var(--ink); text-decoration: underline; }

.breadcrumbs, .article-path {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px 12px;
    color: var(--muted);
    font-size: .875rem;
}

.breadcrumbs { margin-bottom: 16px; }
.breadcrumbs a, .article-path a { color: var(--ink); text-decoration: none; }
.breadcrumbs a:hover, .article-path a:hover { text-decoration: underline; }

.topic-hero { min-height: clamp(345px, 31vw, 420px); }
.topic-cover img { object-position: center 55%; }
.topic-copy h1 { font-size: clamp(3.35rem, 8vw, 6rem); }

.topic-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 25px;
    margin-top: 16px;
    padding-top: 11px;
    border-top: 1px solid #ffffff47;
}

.topic-facts dt { color: #e3e3e8; font-size: .75rem; }
.topic-facts dd { font-weight: 720; font-size: .9rem; }

.section-lead { max-width: 780px; margin-block: 12px 24px; }
.section-lead p { max-width: 64ch; margin-top: 12px; color: var(--muted); }
.pagination { margin-top: 26px; }
.nav-links { display: flex; flex-wrap: wrap; gap: 6px; }

.page-numbers {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid var(--rule);
    border-radius: 8px;
    color: var(--ink);
    text-decoration: none;
}

.page-numbers.current { border-color: var(--accent); color: var(--accent); }

.article-layout {
    display: grid;
    grid-template-columns: minmax(0, 830px) minmax(250px, 315px);
    justify-content: space-between;
    align-items: start;
    gap: clamp(24px, 4.5vw, 75px);
    padding-block: clamp(26px, 5vw, 66px);
}

.reference { min-width: 0; }
.article-path span { border-left: 1px solid var(--rule); padding-left: 12px; }
.article-head h1 { margin-top: 14px; font-size: clamp(2.15rem, 4.4vw, 3.9rem); }
.intro { max-width: 63ch; margin-top: 16px; color: #e1e2e8; font-size: clamp(1.05rem, 1.75vw, 1.3rem); }
.checked { margin-top: 12px; color: var(--muted); font-size: .875rem; }
.article-cover { margin-top: 25px; }
.article-cover img { width: 100%; height: auto; max-height: 420px; border-radius: var(--radius); object-fit: cover; }
.article-cover figcaption { margin-top: 5px; text-align: right; color: var(--muted); font-size: .78rem; }
.article-cover figcaption a { color: inherit; }

.article-toc { margin-top: 24px; }
.article-toc summary { cursor: pointer; }
.article-toc summary::marker { color: var(--accent); }
.article-toc ol { margin: 14px 0 0; padding-left: 1.55em; }
.article-toc li + li { margin-top: 5px; }
.article-toc a { color: var(--ink); text-decoration-color: var(--muted); }

.article-content { margin-top: 25px; line-height: 1.65; }
.article-content h2, .article-content h3 { margin-top: 1.35em; line-height: 1.22; letter-spacing: -.03em; text-wrap: pretty; }
.article-content h2 { font-size: clamp(1.46rem, 2.55vw, 2rem); }
.article-content h3 { font-size: clamp(1.19rem, 2vw, 1.47rem); }
.article-content p, .article-content ul, .article-content ol { max-width: 72ch; margin-block: .7em; overflow-wrap: anywhere; }
.article-content ul, .article-content ol { padding-left: 1.35em; }
.article-content li + li { margin-top: .35em; }
.article-section { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--rule); }
.article-section > h2:first-child { margin-top: 0; }
.article-content .wp-block-table { margin-block: 18px; overflow-x: auto; }
.article-content table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.article-content .wp-block-table th, .article-content .wp-block-table td { min-width: 125px; padding: 10px 12px; border: 1px solid var(--rule); text-align: left; vertical-align: top; }
.article-content th { background: var(--raised); }

.related {
    position: sticky;
    top: 100px;
    padding: 20px;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--panel);
}

.related ul { margin-top: 12px; }
.related li + li { border-top: 1px solid var(--rule); }
.related a { display: block; padding-block: 10px; color: var(--ink); text-decoration: none; font-weight: 620; }
.related a:hover { text-decoration: underline; }

.storage-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(72px, 125px);
    align-items: center;
    gap: 10px 12px;
    max-width: 500px;
    margin-top: 16px;
    padding: clamp(13px, 2.5vw, 20px);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--panel);
}

.storage-form label { font-size: .94rem; font-weight: 650; }
.storage-form input {
    width: 100%;
    min-height: 44px;
    padding: 6px 8px;
    border: 1px solid #696b76;
    border-radius: 8px;
    background: var(--page);
    color: var(--ink);
}

.storage-form button { justify-self: start; }
.storage-form output { grid-column: 1 / -1; color: var(--ink); }
.storage-form output:empty { display: none; }

@media (max-width: 900px) {
    .story-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .front-lead--with-rail, .editorial-layout { grid-template-columns: minmax(0, 1fr); }
    .editorial-layout--event { grid-template: 'event' auto 'feed' auto 'sections' auto / minmax(0, 1fr); }
    .masthead-inner { min-height: 66px; gap: 16px; }
    .masthead nav a { min-height: 66px; }
}

@media (max-width: 800px) {
    .article-layout { grid-template-columns: minmax(0, 1fr); }
    .related { position: static; }
    .guide-rail-image { width: 76px; }
}

@media (max-width: 782px) {
    .admin-bar .masthead { top: 46px; }
}

@media (max-width: 680px) {
    .masthead-inner { grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; padding-top: 9px; }
    .masthead nav { grid-row: 2; grid-column: 1 / -1; justify-content: space-between; gap: 8px; }
    .masthead nav a { min-height: 46px; font-size: .85rem; }
    .wordmark { font-size: 1.25rem; }
    .mark { width: 30px; }
}

@media (max-width: 560px) {
    .landing { padding-top: 16px; }
    .feature-stage .feature { min-height: 318px; }
    .feature h2 { font-size: clamp(1.95rem, 8.6vw, 3.25rem); -webkit-line-clamp: 3; }
    .feature-link { margin-top: 17px; }
    .guide-rail li a { min-height: 70px; }
    .guide-rail-image { width: 66px; }
    .feed-controls button { min-height: 44px; padding-inline: 8px; font-size: .81rem; }
    .story-list { grid-template-columns: minmax(0, 1fr); }
    .editorial-layout .story-list { grid-template-columns: minmax(0, 1fr); }
    .topic-hero { min-height: 325px; }
    .footer-inner { align-items: flex-start; flex-direction: column; }
}

@media (forced-colors: active) {
    .masthead nav a[aria-current], .feed-controls button[aria-pressed='true'] { text-decoration: underline; }
}
