/*
Theme Name: Newsline
Description: Лёгкая адаптивная тема для новостных сайтов и блогов. Макеты ленты (список/сетка), настройки для каждой страницы, вставка кода (реклама, счётчики) в нужные места, связанные записи, кнопка «наверх», страницы политик по умолчанию. Без внешних шрифтов и скриптов.
Version: 1.2.0
Requires at least: 6.0
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: newsline
*/

/* ---------- Переменные (значения из Customizer переопределяются в inline-CSS) ---------- */
:root {
	--nl-accent: #2563eb;
	--nl-text: #1f2937;
	--nl-muted: #6b7280;
	--nl-bg: #ffffff;
	--nl-surface: #f3f4f6;
	--nl-border: #e5e7eb;
	--nl-header-bg: #ffffff;
	--nl-header-text: #111827;
	--nl-footer-bg: #111827;
	--nl-footer-text: #d1d5db;
	--nl-width: 1100px;
	--nl-sidebar: 320px;
	--nl-radius: 10px;
	--nl-size: 17px;
	--nl-font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--nl-font-head: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Основа ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
	margin: 0;
	background: var(--nl-bg);
	color: var(--nl-text);
	font: var(--nl-size)/1.7 var(--nl-font-body);
	-webkit-font-smoothing: antialiased;
	overflow-wrap: break-word;
}
img, video, iframe, embed, object { max-width: 100%; height: auto; }
iframe { border: 0; }
a { color: var(--nl-accent); text-decoration: none; }
a:hover, a:focus { text-decoration: underline; }
h1, h2, h3, h4, h5, h6 { font-family: var(--nl-font-head); line-height: 1.25; margin: 1.4em 0 .6em; color: inherit; }
h1 { font-size: 2em; } h2 { font-size: 1.6em; } h3 { font-size: 1.3em; } h4 { font-size: 1.15em; }
p { margin: 0 0 1.2em; }
ul, ol { padding-left: 1.4em; margin: 0 0 1.2em; }
blockquote { margin: 1.4em 0; padding: .4em 0 .4em 1.2em; border-left: 4px solid var(--nl-accent); color: var(--nl-muted); font-style: italic; }
table { border-collapse: collapse; width: 100%; margin: 0 0 1.4em; }
th, td { border: 1px solid var(--nl-border); padding: .5em .7em; text-align: left; }
pre, code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
pre { background: var(--nl-surface); padding: 1em; overflow: auto; border-radius: 6px; }
code { background: var(--nl-surface); padding: .1em .35em; border-radius: 4px; }
pre code { background: none; padding: 0; }
hr { border: 0; border-top: 1px solid var(--nl-border); margin: 2em 0; }
figure { margin: 0 0 1.4em; }
figcaption, .wp-caption-text { font-size: .85em; color: var(--nl-muted); margin-top: .4em; }
.alignleft { float: left; margin: .3em 1.2em 1em 0; }
.alignright { float: right; margin: .3em 0 1em 1.2em; }
.aligncenter { display: block; margin-left: auto; margin-right: auto; }
.alignwide { margin-left: auto; margin-right: auto; }
.screen-reader-text {
	border: 0; clip: rect(1px, 1px, 1px, 1px); clip-path: inset(50%); height: 1px; margin: -1px;
	overflow: hidden; padding: 0; position: absolute; width: 1px; word-wrap: normal !important;
}
.screen-reader-text:focus {
	background: #fff; clip: auto; clip-path: none; color: #000; display: block; height: auto; left: 8px; top: 8px;
	padding: .8em 1.2em; width: auto; z-index: 100000; box-shadow: 0 0 6px rgba(0,0,0,.3);
}
:focus-visible { outline: 2px solid var(--nl-accent); outline-offset: 2px; }

.nl-container { width: 100%; max-width: var(--nl-width); margin: 0 auto; padding: 0 20px; }

/* ---------- Boxed-макет ---------- */
body.nl-layout-boxed { background: var(--nl-surface); }
body.nl-layout-boxed .site { max-width: calc(var(--nl-width) + 40px); margin: 0 auto; background: var(--nl-bg); box-shadow: 0 0 30px rgba(0,0,0,.08); }

/* ---------- Шапка ---------- */
.site-header { background: var(--nl-header-bg); color: var(--nl-header-text); border-bottom: 1px solid var(--nl-border); position: relative; z-index: 50; transition: box-shadow .2s; }
.site-header a { color: var(--nl-header-text); }
.nl-header-sticky .site-header { position: sticky; top: 0; }
body.admin-bar.nl-header-sticky .site-header { top: 32px; }
@media (max-width: 782px) { body.admin-bar.nl-header-sticky .site-header { top: 46px; } }
.site-header.is-scrolled { box-shadow: 0 2px 14px rgba(0,0,0,.1); }
.header-inner { display: flex; align-items: center; gap: 20px; min-height: 52px; flex-wrap: wrap; }
.site-branding { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.site-title { font: 800 1.45em/1.2 var(--nl-font-head); margin: 0; }
.site-title a { text-decoration: none; }
.site-description { margin: 0; font-size: .8em; opacity: .7; }
.custom-logo { max-height: 40px; width: auto; display: block; }
.main-nav .menu, .footer-nav .menu { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 22px; }
.main-nav a { font-weight: 600; font-size: .95em; padding: 6px 0; display: inline-block; }
.main-nav li { position: relative; }
.main-nav .sub-menu {
	list-style: none; margin: 0; padding: 8px 0; position: absolute; left: -12px; top: 100%; min-width: 220px; display: none;
	background: var(--nl-header-bg); border: 1px solid var(--nl-border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.main-nav .sub-menu a { display: block; padding: 8px 16px; font-weight: 500; }
.main-nav li:hover > .sub-menu, .main-nav li:focus-within > .sub-menu { display: block; }
.main-nav .current-menu-item > a, .main-nav .current-menu-ancestor > a { color: var(--nl-accent); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.nl-btn, .header-cta, .nl-loadmore, .comment-form .submit, .search-form .search-submit {
	display: inline-block; background: var(--nl-accent); color: #fff !important; border: 0; border-radius: 8px;
	padding: .55em 1.1em; font: 600 .9em/1.3 var(--nl-font-body); cursor: pointer; text-decoration: none;
}
.nl-btn:hover, .header-cta:hover, .nl-loadmore:hover, .comment-form .submit:hover, .search-form .search-submit:hover { filter: brightness(1.1); text-decoration: none; }
.icon-btn { background: none; border: 0; color: inherit; cursor: pointer; padding: 8px; line-height: 1; font-size: 1.1em; }
.menu-toggle { display: none; }
.header-search { border-top: 1px solid var(--nl-border); padding: 14px 0; }
.header-search[hidden] { display: none; }
.header-center .header-inner { flex-direction: column; gap: 6px; padding: 14px 20px; }
.header-center .site-branding { margin: 0; flex-direction: column; text-align: center; }
.header-center .header-actions { position: absolute; right: 20px; top: 14px; }
.header-center .main-nav .menu { justify-content: center; }

/* Прозрачная шапка */
.nl-header-transparent .site-header { position: absolute; left: 0; right: 0; top: 0; background: transparent; border-bottom-color: rgba(255,255,255,.25); color: #fff; }
.nl-header-transparent .site-header a, .nl-header-transparent .site-header .icon-btn { color: #fff; }
body.admin-bar.nl-header-transparent .site-header { top: 32px; }
.nl-header-transparent .site-content { padding-top: 0; }
.nl-header-transparent .nl-layout { padding-top: 110px; }

@media (max-width: 860px) {
	.menu-toggle { display: inline-block; }
	.main-nav { display: none; width: 100%; order: 10; }
	.main-nav.is-open { display: block; }
	.main-nav .menu { flex-direction: column; gap: 0; padding-bottom: 12px; }
	.main-nav .menu a { display: block; padding: 10px 0; border-bottom: 1px solid var(--nl-border); }
	.main-nav .sub-menu { display: block; position: static; border: 0; box-shadow: none; padding: 0 0 0 16px; background: transparent; }
	.header-center .header-actions { position: static; }
}

/* ---------- Макет страницы ---------- */
.site-content { padding: 32px 0 56px; }
.nl-layout { display: grid; gap: 40px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.nl-has-sidebar .nl-layout { grid-template-columns: minmax(0, 1fr) var(--nl-sidebar); }
.nl-sidebar-left .nl-layout { grid-template-columns: var(--nl-sidebar) minmax(0, 1fr); }
.nl-sidebar-left .widget-area { order: -1; }
.nl-sticky-sidebar .widget-area { position: sticky; top: 90px; }
@media (max-width: 960px) {
	.nl-has-sidebar .nl-layout, .nl-sidebar-left .nl-layout { grid-template-columns: minmax(0, 1fr); }
	.nl-sidebar-left .widget-area { order: 0; }
	.nl-sticky-sidebar .widget-area { position: static; }
}
.nl-full-width .nl-layout { max-width: none; padding: 0; }
.nl-full-width .site-content { padding: 0; }
.nl-full-width .nl-container.nl-layout { max-width: none; }

.archive-header { margin-bottom: 28px; padding-bottom: 14px; border-bottom: 1px solid var(--nl-border); }
.archive-title { margin: 0; font-size: 1.8em; }
.archive-description { color: var(--nl-muted); margin-top: 6px; }

/* ---------- Лента ---------- */
.nl-grid { display: grid; gap: 28px; }
.nl-grid-grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.nl-grid-grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.nl-has-sidebar .nl-grid-grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.nl-grid-list { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 960px) { .nl-grid-grid3, .nl-has-sidebar .nl-grid-grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .nl-grid-grid2, .nl-grid-grid3, .nl-has-sidebar .nl-grid-grid3 { grid-template-columns: minmax(0, 1fr); } }

.nl-card { display: flex; flex-direction: column; background: var(--nl-bg); border: 1px solid var(--nl-border); border-radius: var(--nl-radius); overflow: hidden; transition: transform .15s, box-shadow .15s; }
.nl-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,.08); }
.nl-card-thumb { display: block; aspect-ratio: 16 / 10; background: var(--nl-surface); overflow: hidden; }
.nl-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nl-card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.nl-card-title { font-size: 1.12em; margin: 0; line-height: 1.35; }
.nl-card-title a { color: inherit; }
.nl-card-excerpt { color: var(--nl-muted); font-size: .92em; margin: 0; }
.nl-card-excerpt p { margin: 0; }
.nl-cat { font-size: .72em; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.nl-grid-list .nl-card { flex-direction: row; }
.nl-grid-list .nl-card-thumb { width: 38%; aspect-ratio: auto; min-height: 170px; flex-shrink: 0; }
@media (max-width: 600px) { .nl-grid-list .nl-card { flex-direction: column; } .nl-grid-list .nl-card-thumb { width: 100%; aspect-ratio: 16 / 10; min-height: 0; } }

.entry-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .82em; color: var(--nl-muted); }
.entry-meta a { color: inherit; }

.nl-loadmore-wrap { text-align: center; margin-top: 32px; }
.nl-loadmore[disabled] { opacity: .6; cursor: wait; }
.pagination .nav-links { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 32px; }
.pagination .page-numbers { padding: 8px 14px; border: 1px solid var(--nl-border); border-radius: 8px; color: inherit; }
.pagination .page-numbers.current, .pagination .page-numbers:hover { background: var(--nl-accent); border-color: var(--nl-accent); color: #fff; text-decoration: none; }

/* ---------- Запись и страница ---------- */
.nl-breadcrumbs { font-size: .82em; color: var(--nl-muted); margin-bottom: 14px; }
.nl-breadcrumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.nl-breadcrumbs li + li::before { content: "›"; margin-right: 4px; }
.nl-breadcrumbs a { color: inherit; }
.entry-header { margin-bottom: 18px; }
.entry-title { font-size: 2.1em; margin: 0 0 10px; }
.nl-featured { margin: 0 0 24px; }
.nl-featured img { width: 100%; border-radius: var(--nl-radius); display: block; }
.entry-content::after { content: ""; display: table; clear: both; }
.entry-content > *:last-child { margin-bottom: 0; }
.nl-tags { margin: 28px 0 0; font-size: .88em; }
.nl-tags a { display: inline-block; background: var(--nl-surface); color: inherit; padding: 3px 12px; border-radius: 99px; margin: 0 6px 6px 0; }
.nl-tags a:hover { background: var(--nl-accent); color: #fff; text-decoration: none; }
.nl-author-box { display: flex; gap: 16px; background: var(--nl-surface); border-radius: var(--nl-radius); padding: 18px; margin-top: 32px; }
.nl-author-box img { border-radius: 50%; flex-shrink: 0; }
.nl-author-box h3 { margin: 0 0 4px; font-size: 1.05em; }
.nl-author-box p { margin: 0; font-size: .92em; color: var(--nl-muted); }
.post-navigation .nav-links { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 32px; }
.post-navigation .nav-next { text-align: right; }
.post-navigation a { display: block; padding: 14px 16px; border: 1px solid var(--nl-border); border-radius: var(--nl-radius); color: inherit; font-weight: 600; }
.post-navigation a:hover { border-color: var(--nl-accent); text-decoration: none; }
.nl-related { margin-top: 44px; }
.nl-related > h2 { font-size: 1.3em; margin: 0 0 18px; }
.nl-related .nl-card-excerpt { display: none; }

/* Рекламные блоки */
.nl-ad { margin: 1.6em 0; text-align: center; overflow: hidden; clear: both; }
.widget-area .nl-ad { margin: 0 0 24px; }

/* ---------- Боковая панель и виджеты ---------- */
.widget { margin: 0 0 32px; }
.widget-title { font-size: 1.05em; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 2px solid var(--nl-accent); text-transform: uppercase; letter-spacing: .04em; }
.widget ul { list-style: none; margin: 0; padding: 0; }
.widget li { padding: 6px 0; border-bottom: 1px solid var(--nl-border); }
.widget li:last-child { border-bottom: 0; }
.widget a { color: inherit; }
.widget a:hover { color: var(--nl-accent); }

/* ---------- Поиск ---------- */
.search-form { display: flex; gap: 8px; max-width: 520px; }
.search-form label { flex: 1; margin: 0; }
.search-field { width: 100%; padding: .6em .9em; border: 1px solid var(--nl-border); border-radius: 8px; font: inherit; background: var(--nl-bg); color: var(--nl-text); }

/* ---------- Комментарии ---------- */
.comments-area { margin-top: 44px; }
.comments-title, .comment-reply-title { font-size: 1.3em; margin: 0 0 18px; }
.comment-list { list-style: none; padding: 0; margin: 0 0 30px; }
.comment-list .children { list-style: none; padding-left: 28px; }
.comment-body { padding: 16px 0; border-bottom: 1px solid var(--nl-border); }
.comment-meta { font-size: .85em; color: var(--nl-muted); margin-bottom: 6px; }
.comment-author .avatar { border-radius: 50%; float: left; margin-right: 12px; }
.comment-form input[type="text"], .comment-form input[type="email"], .comment-form input[type="url"], .comment-form textarea {
	width: 100%; padding: .6em .9em; border: 1px solid var(--nl-border); border-radius: 8px; font: inherit; background: var(--nl-bg); color: var(--nl-text);
}

/* ---------- Подвал ---------- */
.site-footer { background: var(--nl-footer-bg); color: var(--nl-footer-text); font-size: .92em; }
.site-footer a { color: inherit; text-decoration: underline; }
.footer-widgets { display: grid; gap: 32px; padding: 44px 20px 12px; }
.footer-cols-1 .footer-widgets { grid-template-columns: 1fr; }
.footer-cols-2 .footer-widgets { grid-template-columns: repeat(2, 1fr); }
.footer-cols-3 .footer-widgets { grid-template-columns: repeat(3, 1fr); }
.footer-cols-4 .footer-widgets { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 800px) { .footer-widgets { grid-template-columns: 1fr !important; } }
.site-footer .widget-title { color: #fff; }
.site-footer .widget li { border-color: rgba(255,255,255,.12); }
.footer-bottom { padding: 22px 20px; text-align: center; border-top: 1px solid rgba(255,255,255,.12); margin-top: 24px; }
.footer-bottom .menu { justify-content: center; margin-bottom: 10px; }
.footer-bottom p { margin: 0; }
.scroll-top {
	position: fixed; right: 20px; bottom: 20px; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
	background: var(--nl-accent); color: #fff; font-size: 20px; line-height: 1; box-shadow: 0 4px 14px rgba(0,0,0,.25);
	opacity: 0; visibility: hidden; transform: translateY(10px); transition: all .2s; z-index: 60;
}
.scroll-top.is-visible { opacity: 1; visibility: visible; transform: none; }

/* ---------- Блоки WordPress ---------- */
.wp-block-image img { height: auto; }
.wp-block-button__link { border-radius: 8px; }
.entry-content .alignwide { max-width: none; }
.has-text-align-center { text-align: center; }

@media (max-width: 600px) {
	.entry-title { font-size: 1.65em; }
	.nl-author-box { flex-direction: column; }
	.post-navigation .nav-links { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
@media print { .site-header, .site-footer, .widget-area, .scroll-top, .nl-ad, .nl-related, .comments-area { display: none !important; } }
