/* ==========================================================================
   «Нормальный учебник по всему» — дизайн-токены и стили (макет, этап дизайна)
   Палитра из ТЗ, уточнена для WCAG AA:
   --ink-soft  #7A6C56  (вторичный текст, AA 4.7:1)
   --accent-deep #83552C (ссылки, AA 5.9:1)
   ========================================================================== */

:root {
	/* Палитра (ТЗ 6.2) */
	--paper: #faf5ec; /* фон страницы — тёплый лён */
	--surface: #fffdf8; /* поверхности: карточки, статья */
	--ink: #3a3126; /* основной текст — тёплый тёмно-коричневый */
	--ink-soft: #7a6c56; /* вторичный текст: даты, подписи */
	--ink-faint: #8a7c68; /* крупный вторичный (только для больших элементов) */
	--accent: #9c6b3f; /* приглушённый медно-кофейный */
	--accent-hover: #8f5f35;
	--accent-deep: #83552c; /* ссылки и фокус (AA) */
	--line: #e7dcc9; /* рамки, разделители */
	--line-strong: #d6c6a8;
	--focus-ring: rgba(131, 85, 44, 0.35);

	/* Типографика (ТЗ 6.3) */
	--font-display: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;
	--font-body: 'PT Sans', 'Helvetica Neue', Arial, sans-serif;
	--fs-body: 18px;
	--lh-body: 1.6;
	--content-width: 640px; /* колонка статьи, формат A5 (ТЗ 4.2.3) */

	/* Радиусы: разные по иерархии, не «одинаковые ради скруглений» */
	--radius-card: 12px;
	--radius-input: 10px;
	--radius-pill: 999px;
}

/* ---------- База ---------- */

html {
	-webkit-text-size-adjust: 100%;
}

body {
	background-color: var(--paper);
	color: var(--ink);
	font-family: var(--font-body);
	font-size: var(--fs-body);
	line-height: var(--lh-body);
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

::selection {
	background: var(--accent);
	color: #fffdf8;
}

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

a {
	color: var(--accent-deep);
	text-decoration: underline;
	text-underline-offset: 3px;
	text-decoration-thickness: 1px;
	transition: color 0.15s ease;
}

a:hover {
	color: var(--accent);
}

/* Видимый фокус (доступность, ТЗ 6.4) */
:focus-visible {
	outline: 3px solid var(--accent-deep);
	outline-offset: 2px;
	border-radius: 2px;
}

/* Движение: только один сдержанный момент (появление заголовка) и
   hover-отклики. Уважаем prefers-reduced-motion (ТЗ 6.4). */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}

/* ---------- Типографика ---------- */

h1,
h2,
h3,
h4 {
	font-family: var(--font-display);
	font-weight: 800;
	color: var(--ink);
	line-height: 1.12;
	letter-spacing: -0.01em;
	text-wrap: balance;
	overflow-wrap: break-word;
}

/* H1 главной: clamp(2.75rem, 6vw, 4.5rem) — ТЗ 6.3 */
.display-hero {
	font-size: clamp(2.75rem, 6vw, 4.5rem);
	line-height: 1.05;
	letter-spacing: -0.02em;
}

/* H1 статьи ≈ 2.5rem */
.article__title {
	font-size: clamp(2rem, 5vw, 2.5rem);
	line-height: 1.15;
}

h2 {
	font-size: 1.75rem;
	margin: 2.25rem 0 0.75rem;
}

h3 {
	font-size: 1.375rem;
	margin: 1.75rem 0 0.5rem;
}

.lead-note {
	font-size: 1.1875rem;
	line-height: 1.6;
}

/* ---------- Шапка сайта (минимальная) ---------- */

.site-header {
	border-bottom: 1px solid var(--line);
}

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

.site-name {
	font-family: var(--font-display);
	font-weight: 800;
	font-size: 1.125rem;
	color: var(--ink);
	text-decoration: none;
	letter-spacing: -0.01em;
}

.site-name:hover {
	color: var(--accent-deep);
}

.site-header__link {
	font-size: 0.9375rem;
	color: var(--ink-soft);
	text-decoration: none;
	white-space: nowrap;
}

.site-header__link:hover {
	color: var(--accent-deep);
}

/* ---------- Главная: hero ---------- */

.hero {
	max-width: 46rem;
	margin: 0 auto;
	padding: 4.5rem 0 3.5rem;
	text-align: center;
}

.hero__desc {
	margin: 1.5rem auto 0;
	max-width: 38rem;
	font-size: 1.1875rem;
	line-height: 1.6;
	color: var(--ink);
}

.hero__rule {
	width: 3rem;
	height: 3px;
	margin: 2rem auto 1.75rem;
	background: var(--accent);
	border-radius: var(--radius-pill);
}

.hero__cta {
	margin-top: 1.75rem;
}

/* Сдержанное появление заголовка (единственный анимированный момент) */
@keyframes rise {
	from {
		opacity: 0;
		transform: translateY(12px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.hero__in {
	animation: rise 0.55s ease-out both;
}

.hero__in:nth-child(2) {
	animation-delay: 0.08s;
}
.hero__in:nth-child(3) {
	animation-delay: 0.16s;
}
.hero__in:nth-child(4) {
	animation-delay: 0.24s;
}

/* ---------- Кнопки ---------- */

.btn-blog {
	display: inline-flex;
	align-items: center;
	gap: 0.55rem;
	padding: 0.7rem 1.6rem;
	border-radius: var(--radius-pill);
	border: 1px solid var(--accent);
	background: var(--accent);
	color: #fffdf8;
	font-family: var(--font-body);
	font-weight: 700;
	font-size: 1rem;
	line-height: 1.3;
	text-decoration: none;
	transition:
		background-color 0.15s ease,
		border-color 0.15s ease,
		color 0.15s ease;
}

.btn-blog:hover {
	background: var(--accent-hover);
	border-color: var(--accent-hover);
	color: #fffdf8;
}

.btn-blog svg {
	width: 1.05em;
	height: 1.05em;
	flex: none;
}

/* ---------- Плитка статей (ТЗ 4.1.3) ---------- */

.post-grid {
	row-gap: 1.5rem;
}

.post-card {
	height: 100%;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius-card);
	overflow: hidden;
	transition:
		border-color 0.2s ease,
		box-shadow 0.2s ease;
}

.post-card:hover {
	border-color: var(--accent);
}

.post-card__link {
	display: block;
	color: inherit;
	text-decoration: none;
}

.post-card__link:hover {
	color: inherit;
}

.post-card__cover {
	aspect-ratio: 4 / 3;
	overflow: hidden;
	background: var(--line);
}

.post-card__cover img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.25s ease;
}

.post-card:hover .post-card__cover img {
	transform: scale(1.04);
}

.post-card__title {
	margin: 0;
	padding: 1rem 1.125rem 1.125rem;
	font-size: 1.125rem;
	line-height: 1.3;
	letter-spacing: -0.005em;
	transition: color 0.15s ease;
}

.post-card:hover .post-card__title {
	color: var(--accent-deep);
}

/* Обложка плитки «Предложить статью»: плюс по центру, как мотив на обложках */
.post-card__cover--plus {
	display: flex;
	align-items: center;
	justify-content: center;
	background: #f1e8d6;
	color: var(--accent);
}

.post-card__cover--plus svg {
	width: 2.75rem;
	height: 2.75rem;
}

/* ---------- Страница статьи (ТЗ 4.2) ---------- */

.article {
	max-width: var(--content-width);
	margin: 0 auto;
	padding: 2.5rem 0 1rem;
}

.article__cover {
	margin: 0 0 2rem;
	border: 1px solid var(--line);
	border-radius: var(--radius-card);
	overflow: hidden;
}

.article__cover img {
	width: 100%;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	display: block;
}

.article__back {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	margin-bottom: 1.75rem;
	color: var(--ink-soft);
	font-size: 0.9375rem;
	text-decoration: none;
}

.article__back:hover {
	color: var(--accent-deep);
}

.article__back svg {
	width: 1rem;
	height: 1rem;
	flex: none;
}

/* Теги (разделы статьи, например «Физика») */
.tag-list {
	display: flex;
	flex-wrap: wrap;
	gap: 0.45rem;
	list-style: none;
	margin: 1.1rem 0 0;
	padding: 0;
}

.tag {
	display: inline-block;
	padding: 0.28rem 0.8rem;
	border: 1px solid var(--line-strong);
	border-radius: var(--radius-pill);
	font-size: 0.875rem;
	color: var(--ink-soft);
	background: transparent;
}

/* Автор и дата — внизу статьи, теги справа */
.article__byline {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: flex-end;
	gap: 1rem;
	margin-top: 2.5rem;
	padding-top: 1.25rem;
	border-top: 1px solid var(--line);
}

.article__byline-meta p {
	margin: 0;
}

.article__author {
	color: var(--ink);
	font-weight: 700;
}

.article__date {
	margin-top: 0.25rem;
	color: var(--ink-soft);
	font-size: 0.9375rem;
}

.article__byline .tag-list {
	margin: 0;
}

/* Контент статьи: строка 65–75 символов, интерлиньяж 1.5–1.7 (ТЗ 4.2.3) */
.article__body {
	margin-top: 2.25rem;
	font-size: var(--fs-body);
	line-height: 1.65;
	/* Длинные слова и ссылки переносим по строкам, а не ломаем вёрстку */
	overflow-wrap: break-word;
	word-break: break-word;
}

.article__body p {
	margin: 0 0 1.25rem;
}

.article__body ul,
.article__body ol {
	margin: 0 0 1.25rem;
	padding-left: 1.5rem;
}

.article__body li {
	margin-bottom: 0.4rem;
	padding-left: 0.25rem;
}

.article__body li::marker {
	color: var(--accent);
}

.article__body blockquote {
	margin: 1.75rem 0;
	padding: 0.35rem 0 0.35rem 1.25rem;
	border-left: 3px solid var(--accent);
	color: var(--ink-soft);
	font-style: italic;
	font-size: 1.0625rem;
	line-height: 1.6;
}

.article__body blockquote p {
	margin-bottom: 0.35rem;
}

.article__body blockquote cite {
	display: block;
	font-style: normal;
	font-size: 0.875rem;
	color: var(--ink-faint);
	margin-top: 0.5rem;
}

.article__body figure {
	margin: 2rem 0;
}

.article__body figure img {
	width: 100%;
	border: 1px solid var(--line);
	border-radius: var(--radius-input);
}

.article__body figcaption {
	margin-top: 0.55rem;
	text-align: center;
	font-size: 0.875rem;
	color: var(--ink-soft);
}

/* Встроенное видео 16:9 (embed: YouTube / VK Video / Rutube) */
.article__body .video-embed {
	margin: 2rem 0;
	aspect-ratio: 16 / 9;
	border: 1px solid var(--line);
	border-radius: var(--radius-input);
	overflow: hidden;
	background: var(--surface);
	position: relative;
}

.video-embed iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

/* Заглушка плеера для макета: локальный постер + кнопка play */
.video-embed__poster {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.9rem;
	background: var(--line);
	color: var(--ink-soft);
	font-size: 1.0625rem;
}

.video-embed__poster svg {
	width: 2.75rem;
	height: 2.75rem;
	color: var(--accent);
}

/* ---------- Блок действий со статьёй (ТЗ 4.2.5) ---------- */

.article__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 1.25rem;
	margin-top: 2.25rem;
	padding: 1.5rem 0 0.25rem;
	border-top: 1px solid var(--line);
}

.article__actions-title {
	margin: 0 0 0.75rem;
	font-size: 0.9375rem;
	font-family: var(--font-body);
	font-weight: 700;
	color: var(--ink-soft);
}

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

.share-btn {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.5rem 1rem;
	border: 1px solid var(--line-strong);
	border-radius: var(--radius-pill);
	background: transparent;
	color: var(--ink-soft);
	font-family: var(--font-body);
	font-size: 0.9375rem;
	text-decoration: none;
	transition:
		border-color 0.15s ease,
		color 0.15s ease;
}

.share-btn:hover {
	border-color: var(--accent);
	color: var(--accent-deep);
}

.share-btn svg {
	width: 1.1rem;
	height: 1.1rem;
	flex: none;
}

/* ---------- Форма «Предложить статью» (ТЗ 4.4) ---------- */

.suggest {
	max-width: var(--content-width);
	margin: 0 auto;
	padding: 3rem 0 1rem;
}

.suggest__desc {
	margin: 1rem 0 2rem;
	color: var(--ink-soft);
	font-size: 1.0625rem;
}

.form-label {
	font-weight: 700;
	color: var(--ink);
}

.form-control,
.form-select {
	border: 1px solid var(--line-strong);
	border-radius: var(--radius-input);
	background-color: var(--surface);
	color: var(--ink);
	font-family: var(--font-body);
	font-size: 1.0625rem;
	padding: 0.65rem 0.9rem;
}

.form-control::placeholder {
	color: var(--ink-faint);
}

.form-control:focus,
.form-select:focus {
	border-color: var(--accent);
	box-shadow: 0 0 0 0.25rem var(--focus-ring);
}

/* Макет WYSIWYG-редактора (реальный редактор — на этапе админки) */
.editor {
	border: 1px solid var(--line-strong);
	border-radius: var(--radius-input);
	overflow: hidden;
	background: var(--surface);
}

.editor__toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 0.2rem;
	padding: 0.4rem;
	background: #f4eddd;
	border-bottom: 1px solid var(--line);
}

.editor__tool {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.1rem;
	height: 2.1rem;
	border: 0;
	border-radius: 6px;
	background: transparent;
	color: var(--ink-soft);
	font-family: var(--font-display);
	font-weight: 700;
	font-size: 0.9375rem;
}

.editor__tool:hover {
	background: var(--line);
	color: var(--ink);
}

.editor__tool svg {
	width: 1.1rem;
	height: 1.1rem;
}

.editor__area {
	min-height: 300px;
	padding: 1rem 1.125rem;
	font-size: 1.0625rem;
	line-height: 1.6;
}

/* Quill 2 в формах: убираем двойные рамки, подстраиваем под палитру */
.editor .ql-toolbar {
	border: 0;
	border-bottom: 1px solid var(--line);
	border-radius: 0;
	background: #f4eddd;
}

.editor .ql-container {
	border: 0;
	font-family: var(--font-body);
	font-size: 1.0625rem;
}

.editor .ql-editor {
	min-height: 300px;
	padding: 1rem 1.125rem;
	line-height: 1.6;
}

.editor .ql-editor.ql-blank::before {
	color: var(--ink-faint);
	font-style: normal;
}

/* Скрытое поле-honeypot (защита от спама, ТЗ 4.4.4): невидимо, не для людей */
.hp-field {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	opacity: 0;
	pointer-events: none;
}

.form-note {
	font-size: 0.875rem;
	color: var(--ink-soft);
}

/* Галочки согласий: акцент сайта вместо синего Bootstrap */
.form-check-input:checked {
	background-color: var(--accent);
	border-color: var(--accent);
}

.form-check-input:focus {
	border-color: var(--accent);
	box-shadow: 0 0 0 0.25rem var(--focus-ring);
}

.form-check-label a {
	color: var(--accent-deep);
}

/* ---------- Футер ---------- */

.site-footer {
	margin-top: 4.5rem;
	border-top: 1px solid var(--line);
	padding: 2rem 0 2.5rem;
	color: var(--ink-soft);
	font-size: 0.9375rem;
}

.site-footer__inner {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 0.75rem;
}

.site-footer a {
	color: var(--ink-soft);
}

.site-footer a:hover {
	color: var(--accent-deep);
}

/* ==========================================================================
   Печатная A5-версия (ТЗ 4.3)
   ========================================================================== */

@page {
	size: A5 portrait;
	margin: 17mm 16mm;
}

/* Экранный предпросмотр листа A5: страница книги на экране, при печати — чистая */
@media screen {
	.print-sheet {
		max-width: 620px;
		margin: 2rem auto;
		background: #fff;
		padding: 3rem 2.5rem;
		border-radius: 4px;
		box-shadow:
			0 1px 4px rgba(58, 49, 38, 0.12),
			0 14px 44px rgba(58, 49, 38, 0.09);
	}
}

.print-page {
	font-family: var(--font-body);
	font-size: 14px;
	line-height: 1.55;
	color: var(--ink);
}

.print-page__title {
	font-family: var(--font-display);
	font-weight: 800;
	font-size: 24px;
	line-height: 1.2;
	margin: 0 0 0.4rem;
}

.print-page__meta {
	font-size: 12.5px;
	color: var(--ink-soft);
	margin: 0 0 1.1rem;
	border-bottom: 1px solid var(--line);
	padding-bottom: 0.9rem;
}

.print-page__cover {
	margin: 0 0 1.1rem;
}

.print-page__cover img {
	width: 100%;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	display: block;
	border: 1px solid var(--line);
}

.print-page__body {
	overflow-wrap: break-word;
	word-break: break-word;
}

.print-page__body p {
	margin: 0 0 0.8rem;
}

.print-page__body h2 {
	font-size: 17px;
	margin: 1.1rem 0 0.4rem;
}

.print-page__body ul,
.print-page__body ol {
	margin: 0 0 0.8rem;
	padding-left: 1.25rem;
}

.print-page__body blockquote {
	margin: 1rem 0;
	padding-left: 0.9rem;
	border-left: 3px solid var(--accent);
	color: var(--ink-soft);
	font-style: italic;
}

.print-page__body figure {
	margin: 1.1rem 0;
}

.print-page__body figure img {
	width: 100%;
	border: 1px solid var(--line);
}

.print-page__body figcaption {
	font-size: 12px;
	color: var(--ink-soft);
	text-align: center;
	margin-top: 0.35rem;
}

.print-page__signature {
	margin-top: 1.4rem;
	padding-top: 0.8rem;
	border-top: 1px solid var(--line);
	color: var(--ink-soft);
}

/* Нумерация страниц: подхватится серверной генерацией (Dompdf);
   браузерная печать — «Сохранить как PDF» без колонтитулов браузера */
@page {
	@bottom-center {
		content: counter(page);
		font-size: 10px;
		color: #8a7c68;
	}
}

/* Обычные страницы сайта при печати: только контент статьи.
   Поля страницы задаются в @page (17×16мм); если в диалоге печати
   выбрано «Без полей», браузер их игнорирует — это настройка диалога. */
@media print {
	body {
		background: #fff;
		margin: 0;
		padding: 0;
	}
	.print-sheet {
		max-width: none;
		margin: 0;
		padding: 0;
		border-radius: 0;
		box-shadow: none;
	}
	.site-header,
	.site-footer,
	.article__actions,
	.no-print {
		display: none !important;
	}
	.article {
		max-width: none;
		padding: 0;
	}
	.article__cover {
		border: 0;
		border-radius: 0;
	}
}
