/*
 * Основной CSS. Грузится асинхронно, первый экран уже нарисован
 * критическим стилем (assets/css/critical.css).
 *
 * Система «Разберём». Проверено по чек-листу гайда:
 *   — ни одной тени, ни одного градиента, ни одного объёма;
 *   — радиусы только 8 / 12 / 20 / 999;
 *   — все отступы кратны 8;
 *   — Киноварь нигде не означает ошибку; у ошибки своего цвета нет;
 *   — капслока нет; выключка везде влево; переносы отключены.
 */

/* --- Секции ---------------------------------------------------------------- */
.section { margin: 64px 0; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; }

.section-title {
	font-size: 28px;
	line-height: 34px;
	font-weight: 600;
	letter-spacing: -.01em;
	margin-bottom: 24px;
}

.section-link { font-size: 17px; font-weight: 600; white-space: nowrap; color: var(--text); }
.section-link:hover { color: var(--accent-text); }

.empty {
	padding: 24px;
	border: 1px solid var(--border);
	border-radius: var(--r);
	color: var(--text-muted);
}

/* --- Текст статьи ----------------------------------------------------------- */
.entry { max-width: var(--measure); }
.entry h2 { margin-top: 48px; font-size: 28px; line-height: 34px; font-weight: 600; letter-spacing: -.01em; }
.entry h3 { margin-top: 32px; font-size: 20px; line-height: 28px; font-weight: 600; }
.entry ul, .entry ol { padding-left: 24px; }
.entry li { margin-bottom: 8px; }
.entry img { border-radius: var(--r); }

.entry blockquote {
	margin: 32px 0;
	padding-left: 16px;
	border-left: 2px solid var(--border);
	color: var(--text-muted);
}

/* --- Счётчик до работы -------------------------------------------------------
   Нейтральный: срок — это факт, а не тревога. */
.countdown {
	display: inline-block;
	padding: 8px 16px;
	margin-bottom: 24px;
	border: 1px solid var(--border);
	border-radius: var(--r-pill);
	color: var(--text-muted);
	font-size: 14px;
	line-height: 20px;
	letter-spacing: .01em;
	font-weight: 500;
}

/* --- Ступени ------------------------------------------------------------------
   Приём для содержания: ось 2 px, узлы Ø 10, шаг кратен 24.
   Используется в списке «Что внутри» и в разборах. */
.inside__list {
	position: relative;
	list-style: none;
	margin: 0;
	padding: 0 0 0 32px;
}

.inside__list::before {
	content: "";
	position: absolute;
	left: 4px;
	top: 8px;
	bottom: 8px;
	width: 2px;
	background: var(--border);
}

.inside__item { position: relative; padding-bottom: 24px; }
.inside__item:last-child { padding-bottom: 0; }

.inside__item::before {
	content: "";
	position: absolute;
	left: -32px;
	top: 8px;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--accent);
}

.steps { position: relative; padding-left: 40px; }

.steps::before {
	content: "";
	position: absolute;
	left: 4px;
	top: 8px;
	bottom: 8px;
	width: 2px;
	background: var(--border);
}

.step { position: relative; padding-bottom: 32px; }
.step:last-child { padding-bottom: 0; }

.step__node {
	position: absolute;
	left: -40px;
	top: 8px;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--border);
}
.step--done .step__node { background: var(--accent); }
.step--now .step__node { background: transparent; border: 2px solid var(--accent); }

/* --- Формулы ------------------------------------------------------------------
   Математика набирается математическим шрифтом, отдельной строкой,
   выключка влево. Подсветка — фон, символ остаётся цветом текста. */
.formula {
	font-family: var(--ff-math);
	font-size: 24px;
	line-height: 32px;
	margin: 24px 0;
	color: var(--text);
}

.hl {
	background: var(--accent-soft);
	border-radius: var(--r-sm);
	padding: 2px 4px;
}

.cond { border-left: 2px solid var(--border); padding-left: 16px; }

/* --- Превью заданий ------------------------------------------------------------ */
.preview__item {
	padding: 24px;
	margin-bottom: 16px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--r);
}
.preview__text { margin: 0; }
.preview__img { margin-top: 16px; border-radius: var(--r-sm); display: block; }
.preview__note { color: var(--text-muted); font-size: 14px; line-height: 20px; letter-spacing: .01em; }

/* --- CTA Telegram ---------------------------------------------------------------
   Ни градиента, ни цветной плашки: акцент один — кнопка. */
.cta {
	display: flex;
	gap: 24px;
	align-items: flex-start;
	margin: 64px 0;
	padding: 32px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--r-lg);
}

.cta__icon {
	flex: none;
	display: grid;
	place-items: center;
	width: 48px; height: 48px;
	border: 1px solid var(--border);
	border-radius: var(--r);
	color: var(--text-muted);
}

.cta__body { min-width: 0; }
.cta__title { margin: 0 0 8px; font-size: 28px; line-height: 34px; font-weight: 600; letter-spacing: -.01em; }
.cta__subtitle { margin: 0 0 24px; color: var(--text-muted); }
.cta__social { display: block; color: var(--text); }
.cta__note { margin: 16px 0 0; font-size: 14px; line-height: 20px; letter-spacing: .01em; color: var(--text-muted); }

/* Липкая мобильная кнопка */
.cta-sticky {
	position: fixed;
	left: 0; right: 0;
	bottom: 64px;
	z-index: 35;
	padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
	background: var(--bg);
	border-top: 1px solid var(--border);
	transform: translateY(120%);
	transition: transform .4s cubic-bezier(.32, .72, 0, 1);
}
.cta-sticky[hidden] { display: block; }
.cta-sticky.is-visible { transform: translateY(0); }
.cta-sticky__button { width: 100%; }

/* Плавающая кнопка (десктоп) */
.tg-float {
	position: fixed;
	right: 32px;
	bottom: 32px;
	z-index: 35;
	display: none;
	align-items: center;
	gap: 8px;
	height: 48px;
	padding: 0 24px;
	border-radius: var(--r-pill);
	background: var(--accent-text);
	color: var(--paper);
	font-weight: 600;
	opacity: 0;
	transform: translateY(8px);
	transition: opacity .4s cubic-bezier(.32, .72, 0, 1), transform .4s cubic-bezier(.32, .72, 0, 1);
}
.tg-float[hidden] { display: none; }
.tg-float.is-visible { opacity: 1; transform: translateY(0); }
.tg-float:hover { text-decoration: none; background: var(--accent); }

/* --- Расписание ------------------------------------------------------------------ */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table {
	width: 100%;
	min-width: 560px;
	border-collapse: collapse;
	font-size: 17px;
	font-variant-numeric: tabular-nums;
}
.table th, .table td { text-align: left; padding: 16px; border-bottom: 1px solid var(--border); }
.table th { font-size: 14px; line-height: 20px; letter-spacing: .01em; font-weight: 600; color: var(--text-muted); }
.table tr:last-child td { border-bottom: 0; }

/* --- FAQ ---------------------------------------------------------------------------
   Нативные <details>: без JS, работает с клавиатуры, читается скринридером. */
.faq__list { display: grid; gap: 8px; }

.faq__item {
	border: 1px solid var(--border);
	border-radius: var(--r);
	overflow: hidden;
}

.faq__question {
	position: relative;
	padding: 16px 56px 16px 24px;
	font-size: 20px;
	line-height: 28px;
	font-weight: 600;
	cursor: pointer;
	list-style: none;
}
.faq__question::-webkit-details-marker { display: none; }

.faq__question::after {
	content: "+";
	position: absolute;
	right: 24px;
	top: 16px;
	font-size: 20px;
	line-height: 28px;
	color: var(--text-muted);
}
.faq__item[open] .faq__question::after { content: "−"; }

.faq__answer { padding: 0 24px 24px; color: var(--text-muted); }
.faq__answer p { margin: 0; }

/* --- Перелинковка и шаринг ------------------------------------------------------------ */
.cards--compact { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.related__links { display: flex; flex-wrap: wrap; gap: 24px; margin-top: 24px; font-weight: 600; }

.share { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 48px 0; }
.share__label { color: var(--text-muted); font-size: 14px; line-height: 20px; letter-spacing: .01em; }

.share__btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	height: 40px;
	padding: 0 16px;
	border: 1px solid var(--border);
	border-radius: var(--r-pill);
	background: transparent;
	color: var(--text);
	font: inherit;
	font-size: 14px;
	cursor: pointer;
	transition: border-color .2s ease;
}
.share__btn:hover { border-color: var(--text-muted); text-decoration: none; }

.dates { display: flex; flex-wrap: wrap; gap: 24px; color: var(--text-muted); font-size: 14px; line-height: 20px; letter-spacing: .01em; }

/* --- Хабы и чипсы ---------------------------------------------------------------------- */
.hubs { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }

.hub {
	padding: 24px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--r);
	transition: border-color .2s ease;
}
.hub:hover { border-color: var(--text-muted); }
.hub__title { font-size: 20px; line-height: 28px; font-weight: 600; margin-bottom: 8px; }
.hub__title a { color: var(--text); }
.hub__title a:hover { text-decoration: underline; }
.hub__desc { color: var(--text-muted); }
.hub__links { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 16px 0; padding: 0; font-size: 14px; }
.hub__links a { display: inline-block; padding: 4px 12px; border: 1px solid var(--border); border-radius: var(--r-pill); color: var(--text); }
.hub__links a:hover { border-color: var(--text-muted); text-decoration: none; }
.hub__count { margin: 0; color: var(--text-muted); font-size: 14px; line-height: 20px; letter-spacing: .01em; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	height: 40px;
	padding: 0 16px;
	border: 1px solid var(--border);
	border-radius: var(--r-pill);
	color: var(--text);
	font-size: 17px;
	transition: border-color .2s ease;
}
.chip:hover { border-color: var(--text-muted); text-decoration: none; }
.chip__count { color: var(--text-muted); font-size: 14px; }

/* --- Главная ------------------------------------------------------------------------------ */
.hero { padding: 120px 0 64px; }

.hero__title {
	font-size: 56px;
	line-height: 60px;
	font-weight: 700;
	letter-spacing: -.02em;
	max-width: 880px;
	margin-bottom: 24px;
}

.hero__lead { max-width: var(--measure); color: var(--text-muted); }
.hero__search { max-width: 620px; margin: 32px 0; }

.calendar { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.calendar__link {
	display: grid;
	grid-template-columns: 120px minmax(0, 1fr) auto;
	align-items: center;
	gap: 16px;
	padding: 16px 24px;
	border: 1px solid var(--border);
	border-radius: var(--r);
	color: var(--text);
	transition: border-color .2s ease;
}
.calendar__link:hover { border-color: var(--text-muted); text-decoration: none; }
.calendar__date { font-weight: 600; font-variant-numeric: tabular-nums; }
.calendar__klass { color: var(--text-muted); margin-left: 8px; }
.calendar__left { color: var(--text-muted); font-size: 14px; white-space: nowrap; }

.discussions { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.discussions a {
	display: grid;
	gap: 8px;
	padding: 16px 24px;
	border: 1px solid var(--border);
	border-radius: var(--r);
	color: var(--text);
}
.discussions a:hover { border-color: var(--text-muted); text-decoration: none; }
.discussions__author { font-weight: 600; }
.discussions__text { color: var(--text-muted); }
.discussions__post { font-size: 14px; line-height: 20px; letter-spacing: .01em; color: var(--text-muted); }

/* --- Фильтры каталога ------------------------------------------------------------------------ */
.filters {
	padding: 24px;
	margin-bottom: 32px;
	border: 1px solid var(--border);
	border-radius: var(--r);
}

.filters__row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.filters__field { display: flex; flex-direction: column; gap: 8px; }
.filters__label { font-size: 14px; line-height: 20px; letter-spacing: .01em; color: var(--text-muted); font-weight: 500; }

.filters select {
	height: 48px;
	padding: 0 16px;
	border: 1px solid var(--border);
	border-radius: var(--r-sm);
	background: var(--surface);
	color: var(--text);
	font: inherit;
	font-size: 17px;
}

.filters__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-top: 24px; }
.filters__found { color: var(--text-muted); font-size: 14px; }

.catalog.is-loading { opacity: .4; pointer-events: none; transition: opacity .2s ease; }

/* --- Пагинация ---------------------------------------------------------------------------------- */
.pagination { margin: 48px 0; }
.pagination__list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }

.pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 48px;
	height: 48px;
	padding: 0 16px;
	border: 1px solid var(--border);
	border-radius: var(--r-pill);
	color: var(--text);
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}
.pagination .page-numbers:hover { border-color: var(--text-muted); text-decoration: none; }
.pagination .page-numbers.current { background: var(--accent-text); border-color: var(--accent-text); color: var(--paper); }

/* --- Подсказки поиска ------------------------------------------------------------------------------ */
.search__results {
	position: absolute;
	left: 0; right: 0;
	top: calc(100% + 8px);
	z-index: 50;
	max-height: 60vh;
	overflow-y: auto;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--r);
}

.search__result {
	display: block;
	padding: 16px;
	color: var(--text);
	border-bottom: 1px solid var(--border);
}
.search__result:last-child { border-bottom: 0; }
.search__result:hover,
.search__result.is-active { background: var(--surface-2); text-decoration: none; }
.search__result-title { display: block; font-weight: 600; }
.search__result-meta { display: block; margin-top: 4px; font-size: 14px; line-height: 20px; letter-spacing: .01em; color: var(--text-muted); }
.search__empty { padding: 16px; color: var(--text-muted); }

.search-page__form { max-width: 620px; margin-bottom: 32px; }

/* --- Сайдбар и виджеты -------------------------------------------------------------------------------- */
.sidebar { display: grid; gap: 24px; align-content: start; }

.widget {
	padding: 24px;
	border: 1px solid var(--border);
	border-radius: var(--r);
}
.widget__title { font-size: 20px; line-height: 28px; font-weight: 600; margin-bottom: 16px; }
.widget__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.widget__note { display: block; margin-top: 4px; color: var(--text-muted); font-size: 14px; line-height: 20px; letter-spacing: .01em; }

.recent-comments { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.recent-comments a { display: grid; gap: 4px; color: var(--text); }
.recent-comments a:hover { text-decoration: none; }
.recent-comments__author { font-weight: 600; font-size: 14px; }
.recent-comments__text { color: var(--text-muted); font-size: 14px; line-height: 20px; }

/* --- Комментарии ------------------------------------------------------------------------------------------ */
.comments { margin-top: 64px; padding-top: 32px; border-top: 1px solid var(--border); }

.comments__list { list-style: none; margin: 0 0 32px; padding: 0; display: grid; gap: 16px; }
.comments__list .children { list-style: none; margin: 16px 0 0 24px; padding: 0; display: grid; gap: 16px; }

.comment-item__body {
	padding: 24px;
	border: 1px solid var(--border);
	border-radius: var(--r);
}

.comment-item__head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }

.comment-item__avatar {
	display: grid;
	place-items: center;
	width: 32px; height: 32px;
	border: 1px solid var(--border);
	border-radius: 50%;
	color: var(--text-muted);
	font-weight: 600;
	font-size: 14px;
}

.comment-item__author { font-weight: 600; }
.comment-item__date { color: var(--text-muted); font-size: 14px; line-height: 20px; letter-spacing: .01em; }
.comment-item__text p:last-child { margin-bottom: 0; }
.comment-item__pending { color: var(--text-muted); font-size: 14px; line-height: 20px; }
.comment-item__actions { margin-top: 8px; font-size: 14px; }

.comments__empty, .comments__closed { color: var(--text-muted); }

.comment-form { display: grid; gap: 16px; max-width: var(--measure); }
.comment-form label { display: block; margin-bottom: 8px; font-weight: 600; }
.comment-form p { margin: 0; }

.comment-form input[type="text"],
.comment-form textarea {
	width: 100%;
	padding: 12px 16px;
	border: 1px solid var(--border);
	border-radius: var(--r-sm);
	background: var(--surface);
	color: var(--text);
	font: inherit;
	font-size: 17px;
}
.comment-form textarea { resize: vertical; min-height: 112px; }
.comment-form .form-submit { margin: 0; }
.comment-notes { color: var(--text-muted); font-size: 14px; line-height: 20px; }

/* Ловушка для ботов: убираем из потока, но не через display:none. */
.vsosh-hp { position: absolute !important; left: -9999px !important; height: 0; overflow: hidden; }

/* У ошибки в этой системе нет своего цвета: она нейтральная. */
.comments__status { min-height: 24px; font-weight: 600; }
.comments__status.is-ok { color: var(--ok); }
.comments__status.is-error { color: var(--text); }

/* --- Подвал -------------------------------------------------------------------------------------------------- */
.footer { border-top: 1px solid var(--border); padding: 64px 0 0; }
.footer__inner { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 32px; }
.footer__title { font-size: 20px; line-height: 28px; font-weight: 600; margin-bottom: 16px; }
.footer__about { color: var(--text-muted); max-width: 360px; margin-top: 16px; }
.footer__menu { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.footer__menu a { color: var(--text-muted); }
.footer__menu a:hover { color: var(--text); }
.footer__bottom { padding: 32px; margin-top: 32px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 14px; line-height: 20px; }
.footer__bottom p { margin: 0; }

/* --- Мобильная нижняя навигация ----------------------------------------------------------------------------------- */
.bottom-nav {
	position: fixed;
	left: 0; right: 0; bottom: 0;
	z-index: 40;
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: 1fr;
	background: var(--bg);
	border-top: 1px solid var(--border);
	padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav__item {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	padding: 8px 4px;
	border: 0;
	background: none;
	color: var(--text-muted);
	font: inherit;
	font-size: 14px;
	line-height: 20px;
	cursor: pointer;
}
.bottom-nav__item:hover, .bottom-nav__item.is-active { color: var(--text); text-decoration: none; }

/* --- Рез 30° ----------------------------------------------------------------------------------------------------------
   Единственный диагональный угол в системе. Резать можно фон, плашку,
   обложку. Нельзя: текст, формулу, логотип, иконку. */
.cut {
	position: relative;
	overflow: hidden;
	border-radius: var(--r-lg);
}

.cut::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(150deg, transparent 0 49.6%, var(--bg) 49.6% 50.4%, transparent 50.4% 100%);
	pointer-events: none;
}

/* --- Адаптив ------------------------------------------------------------------------------------------------------------- */
@media (max-width: 899px) {
	body { padding-bottom: 64px; }
	.header__search { max-width: none; }
	.header__tg span { display: none; }
	.hero { padding: 64px 0 32px; }
	.hero__title { font-size: 40px; line-height: 44px; }
	.title { font-size: 30px; line-height: 36px; }
	.cta { flex-direction: column; padding: 24px; }
	.calendar__link { grid-template-columns: 104px minmax(0, 1fr); }
	.calendar__left { grid-column: 1 / -1; }
}

@media (min-width: 900px) {
	.bottom-nav { display: none; }
	.cta-sticky { display: none !important; }
	.tg-float { display: flex; }
	body { padding-bottom: 0; }
}

@media (max-width: 560px) {
	/* В шапке остаются знак, поиск и переключатель темы: словознак и кнопка
	   Telegram не помещаются, а Telegram и так есть в нижней навигации. */
	.logo__text { display: none; }
	.header__tg { display: none; }
	.header__inner { gap: 16px; }
	.header__actions { gap: 8px; }
}

@media (max-width: 400px) {
	.container { padding: 0 20px; }
	.search__submit { display: none; }
	.cards { grid-template-columns: 1fr; }
}

/* --- Системные настройки ------------------------------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after {
		animation-duration: .01ms !important;
		transition-duration: .01ms !important;
	}
}

/* --- Печать ------------------------------------------------------------------------------------------------------------------ */
@media print {
	.header, .footer, .bottom-nav, .tg-float, .cta, .cta-sticky, .sidebar, .share, .comments__form { display: none !important; }
	body { background: #fff; color: #000; }
	.layout { grid-template-columns: 1fr; }
}
