/* Леонида: ночь и закат южного побережья, жидкое стекло поверх неоновой вывески.
   Палитра та же, что в админке (frontend/src/theme.css) */
:root {
	--vi-blue: #3d5fcd;
	--vi-violet: #8a3dc1;
	--vi-magenta: #db35bb;
	--vi-flamingo: #fd5c88;
	--vi-orange: #ff954c;
	--vi-pink: #ff8aae;
	--vi-cream: #fff1dc;
	--vi-lilac: #cfc6dc;
	--vi-muted: #9d96b8;
	--vi-night-0: #0c0d1b;

	--vi-sunset-wide: linear-gradient(110deg, var(--vi-violet) 0%, var(--vi-magenta) 40%, var(--vi-flamingo) 70%, var(--vi-orange) 100%);
	--vi-night: linear-gradient(189deg, #1f1f38 0.55%, #18182d 30.38%, #111222 65.19%, #0c0d1b 100%);

	--glass-bg: linear-gradient(135deg, rgba(255, 241, 220, 0.14), rgba(255, 241, 220, 0.04) 60%);
	--glass-blur: blur(22px) saturate(160%);
	--glass-edge: inset 0 1px 0 rgba(255, 255, 255, 0.28), inset 0 -1px 0 rgba(0, 0, 0, 0.25), inset 0 0 0 1px rgba(255, 241, 220, 0.10);
	--glass-shadow: 0 24px 60px -20px rgba(5, 5, 15, 0.65);
	--glass-border: linear-gradient(140deg, rgba(255, 241, 220, 0.55), rgba(255, 241, 220, 0.06) 35%, rgba(219, 53, 187, 0.22) 70%, rgba(255, 149, 76, 0.6));

	--neon-glow: 0 0 36px var(--vi-flamingo), 0 0 12px rgba(253, 92, 136, 0.8);
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	min-height: 100%;
	background: var(--vi-night-0);
	color: var(--vi-cream);
	font-family: 'Bitter', Georgia, serif;
	-webkit-font-smoothing: antialiased;
}

body {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

.page {
	position: relative;
	z-index: 2;
	flex: 1 0 auto;
}

/* ---------- фон: медленно плывущие пятна заката и зерно ---------- */

.bg {
	position: fixed;
	inset: 0;
	z-index: 0;
	overflow: hidden;
	background: var(--vi-night);
}

.bg .blob {
	position: absolute;
	width: 70vmax;
	height: 70vmax;
	border-radius: 50%;
	filter: blur(70px);
	opacity: 0.7;
	will-change: transform;
	animation: drift 46s ease-in-out infinite alternate;
}

.blob.blue {
	background: radial-gradient(closest-side, rgba(61, 95, 205, 0.75), transparent);
	top: -32vmax;
	left: -22vmax;
}

.blob.violet {
	background: radial-gradient(closest-side, rgba(138, 61, 193, 0.6), transparent);
	top: -28vmax;
	right: -30vmax;
	animation-duration: 58s;
	animation-delay: -12s;
}

.blob.flamingo {
	background: radial-gradient(closest-side, rgba(253, 92, 136, 0.45), rgba(219, 53, 187, 0.18) 60%, transparent);
	bottom: -42vmax;
	right: -18vmax;
	animation-duration: 64s;
	animation-delay: -30s;
}

.blob.orange {
	background: radial-gradient(closest-side, rgba(255, 149, 76, 0.32), transparent);
	bottom: -40vmax;
	left: -26vmax;
	animation-duration: 52s;
	animation-delay: -20s;
}

@keyframes drift {
	0% { transform: translate3d(0, 0, 0) scale(1); }
	50% { transform: translate3d(6vmax, 4vmax, 0) scale(1.08); }
	100% { transform: translate3d(-4vmax, 7vmax, 0) scale(0.96); }
}

.bg::after {
	content: '';
	position: absolute;
	inset: -50%;
	background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
	opacity: 0.08;
	mix-blend-mode: overlay;
	pointer-events: none;
}

/* ---------- неоновая вывеска; --p (0..1) — доля прокрутки первого экрана ---------- */

.neon {
	position: fixed;
	inset: 0;
	z-index: 1;
	display: flex;
	justify-content: center;
	align-items: center;
	pointer-events: none;
	font-family: 'Monoton', cursive;
	font-size: 15vw;
	line-height: 1;
	white-space: nowrap;
	user-select: none;
	opacity: calc(1 - var(--p, 0) * 0.6);
	filter: blur(calc(var(--p, 0) * 5px));
	transform: scale(calc(1 - var(--p, 0) * 0.06));
}

.neon span {
	transition: color 0.05s, text-shadow 0.05s;
}

.neon .ignat span {
	color: #f6eeff;
	text-shadow: 0 0 4px rgba(255, 255, 255, 0.75), 0 0 18px #b97ce9, 0 0 46px rgba(138, 61, 193, 0.85), 0 0 110px rgba(61, 95, 205, 0.95);
}

.neon .one span {
	color: #ffc08a;
	text-shadow: 0 0 4px rgba(255, 230, 200, 0.8), 0 0 18px #ff954c, 0 0 46px rgba(253, 92, 136, 0.85), 0 0 110px rgba(219, 53, 187, 0.9);
}

.neon span.off {
	color: rgba(255, 241, 220, 0.08) !important;
	text-shadow: none !important;
}

/* ---------- стекло ---------- */

.glass {
	background: var(--glass-bg), rgba(20, 20, 39, 0.38);
	backdrop-filter: var(--glass-blur);
	-webkit-backdrop-filter: var(--glass-blur);
	box-shadow: var(--glass-edge), var(--glass-shadow);
}

/* ---------- переключатель тем ---------- */

.theme-switch {
	position: absolute;
	top: 16px;
	right: 18px;
	z-index: 5;
	display: flex;
	gap: 2px;
	padding: 4px;
	border-radius: 999px;
}

.theme-switch button {
	padding: 7px 14px;
	border: 0;
	border-radius: 999px;
	background: none;
	font-family: 'Bitter', serif;
	font-size: 12px;
	font-weight: 500;
	letter-spacing: 1.2px;
	text-transform: uppercase;
	color: rgba(255, 241, 220, 0.7);
	cursor: pointer;
	transition: color 0.3s, background 0.3s;
}

.theme-switch button:hover,
.theme-switch button:focus-visible {
	color: var(--vi-cream);
	background: rgba(255, 241, 220, 0.1);
	outline: none;
}

.theme-switch button.active {
	color: #fff;
	background: var(--vi-sunset-wide);
	box-shadow: 0 4px 18px -6px rgba(253, 92, 136, 0.8);
	cursor: default;
}

/* ---------- навигация ---------- */

.menu {
	position: relative;
	z-index: 4;
	padding-top: 8vh;
}

.menu > ul {
	display: flex;
	justify-content: space-evenly;
	width: 90%;
	max-width: 1100px;
	margin: 0 auto;
	padding: 0;
	list-style: none;
}

.menu li {
	position: relative;
	list-style: none;
}

.menu a,
.dock a {
	position: relative;
	display: block;
	font-family: 'Bitter', serif;
	font-weight: 500;
	text-transform: uppercase;
	text-decoration: none;
	color: var(--vi-cream);
	border-radius: 999px;
	transition: color 0.3s, text-shadow 0.3s, background 0.3s, box-shadow 0.3s;
}

.menu > ul > li > a {
	padding: 14px 24px;
	font-size: 19px;
	letter-spacing: 2px;
	text-shadow: 0 1px 12px rgba(0, 0, 0, 0.5);
}

.menu a:hover,
.menu a:focus-visible,
.dock a:hover,
.dock a:focus-visible {
	color: var(--vi-pink);
	text-shadow: var(--neon-glow);
	background: var(--glass-bg);
	box-shadow: var(--glass-edge);
	backdrop-filter: var(--glass-blur);
	-webkit-backdrop-filter: var(--glass-blur);
	outline: none;
}

.menu li.active > a,
.dock li.active > a {
	color: var(--vi-pink);
	text-shadow: var(--neon-glow);
}

.menu > ul > li.active > a::after {
	content: '';
	position: absolute;
	left: 24px;
	right: 24px;
	bottom: 6px;
	height: 2px;
	border-radius: 2px;
	background: var(--vi-sunset-wide);
	box-shadow: 0 0 12px rgba(253, 92, 136, 0.7);
}

/* Подменю — вложенные разделы; открывается наведением или фокусом с клавиатуры */
.menu .submenu {
	display: none;
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	min-width: 100%;
	margin: 6px 0 0;
	padding: 6px;
	border-radius: 20px;
	list-style: none;
}

.menu li:hover > .submenu,
.menu li:focus-within > .submenu {
	display: block;
}

.menu .submenu a {
	padding: 10px 18px;
	font-size: 14px;
	font-weight: 400;
	letter-spacing: 1px;
	white-space: nowrap;
}

/* Плывет у нижнего края экрана, а в конце страницы встает над подвалом: подпись всегда последняя */
.dock {
	position: sticky;
	bottom: 18px;
	z-index: 10;
	width: fit-content;
	max-width: calc(100vw - 16px);
	margin: 0 auto;
	padding: 6px;
	border-radius: 999px;
	transform: translateY(calc(100% + 24px));
	opacity: 0;
	pointer-events: none;
	transition: transform 0.5s cubic-bezier(.2, .8, .2, 1), opacity 0.35s;
}

.dock.visible {
	transform: translateY(0);
	opacity: 1;
	pointer-events: auto;
}

.dock ul {
	display: flex;
	gap: 2px;
	margin: 0;
	padding: 0;
	list-style: none;
	overflow-x: auto;
	scrollbar-width: none;
}

.dock a {
	padding: 10px 18px;
	font-size: 13px;
	letter-spacing: 1.5px;
	white-space: nowrap;
}

/* ---------- карточки раздела ---------- */

.cards {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: clamp(18px, 2.4vw, 34px);
	width: min(1240px, 92vw);
	margin: 7vh auto 0;
	padding-bottom: 8vh;
}

.panel + .cards {
	margin-top: clamp(18px, 2.4vw, 34px);
}

/* Одинокая карточка в последнем ряду — по центру, как в оригинальной теме */
.cards > .card:last-child:nth-child(odd) {
	grid-column: 1 / -1;
	justify-self: center;
	width: calc(50% - clamp(18px, 2.4vw, 34px) / 2);
}

.card {
	position: relative;
	display: block;
	padding: 10px;
	border-radius: 30px;
	color: var(--vi-cream);
	text-decoration: none;
	transform: perspective(1200px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(var(--lift, 0px));
	transition: transform 0.6s cubic-bezier(.2, .8, .2, 1), box-shadow 0.6s;
	isolation: isolate;
}

.card::before,
.panel::before {
	content: '';
	position: absolute;
	inset: 0;
	border-radius: inherit;
	padding: 1px;
	background: var(--glass-border);
	-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
	-webkit-mask-composite: xor;
	mask-composite: exclude;
	pointer-events: none;
	z-index: 2;
}

/* Блик, который следует за курсором */
.card::after {
	content: '';
	position: absolute;
	inset: 0;
	border-radius: inherit;
	background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%), rgba(255, 236, 245, 0.24), transparent 45%);
	opacity: 0;
	transition: opacity 0.4s;
	pointer-events: none;
	z-index: 3;
	mix-blend-mode: soft-light;
}

.card:hover,
.card:focus-visible {
	--lift: -6px;
	box-shadow: var(--glass-edge), 0 40px 80px -24px rgba(5, 5, 15, 0.8), 0 0 70px -18px rgba(253, 92, 136, 0.45);
	outline: none;
}

.card:hover::after {
	opacity: 1;
}

.card .media {
	position: relative;
	display: block;
	overflow: hidden;
	border-radius: 21px;
	aspect-ratio: 16 / 10.5;
	background: linear-gradient(160deg, #3a3577, #6a3ea8 40%, #dc4f94 75%, #ffa458);
}

.card img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transform: scale(1.01);
	transition: transform 1.2s cubic-bezier(.2, .8, .2, 1), filter 0.6s;
	filter: saturate(0.95) contrast(1.02);
}

.card:hover img {
	transform: scale(1.06);
	filter: saturate(1.08) contrast(1.04);
}

.card .media::after {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(180deg, transparent 45%, rgba(12, 13, 27, 0.55) 100%);
	pointer-events: none;
}

.card .caption {
	position: absolute;
	left: 24px;
	right: 24px;
	bottom: 24px;
	z-index: 1;
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 4px 16px;
	padding: 14px 20px 15px;
	border-radius: 18px;
	background: linear-gradient(135deg, rgba(255, 241, 220, 0.18), rgba(255, 241, 220, 0.05)), rgba(20, 20, 39, 0.3);
	backdrop-filter: blur(18px) saturate(170%);
	-webkit-backdrop-filter: blur(18px) saturate(170%);
	box-shadow: var(--glass-edge);
}

.card .title {
	font-size: clamp(20px, 2.1vw, 30px);
	font-weight: 600;
	line-height: 1.2;
	text-shadow: 0 1px 10px rgba(0, 0, 0, 0.35);
}

.card .dates {
	font-size: 14px;
	letter-spacing: 0.5px;
	color: var(--vi-lilac);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

/* ---------- панель статьи ---------- */

.panel {
	position: relative;
	width: min(1000px, 92vw);
	margin: 7vh auto 8vh;
	padding: clamp(22px, 4vw, 56px);
	border-radius: 32px;
	/* Текст должен читаться поверх неона, поэтому стекло плотнее, чем у карточек */
	background: var(--glass-bg), rgba(16, 16, 32, 0.68);
}

.post {
	display: flex;
	flex-direction: column;
	font-size: 18px;
	line-height: 1.8;
	color: #f2e8da;
	overflow-wrap: break-word;
}

.post > :first-child {
	margin-top: 0;
}

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

.post > h1,
.post > h2,
.post > h3 {
	line-height: 1.25;
	font-weight: 600;
	color: var(--vi-cream);
}

.post > h1 {
	font-size: clamp(30px, 4vw, 44px);
	margin: 0 0 0.6em;
	text-align: center;
	/* Не градиент через background-clip: он закрашивает и эмодзи-флаги в заголовках */
	color: #ffe3ec;
	text-shadow: 0 0 28px rgba(253, 92, 136, 0.45), 0 0 60px rgba(138, 61, 193, 0.35);
}

.post > h2 {
	position: relative;
	font-size: clamp(24px, 2.6vw, 30px);
	margin: 1.6em 0 0.6em;
	padding-bottom: 0.35em;
}

.post > h2::after {
	content: '';
	position: absolute;
	left: 0;
	bottom: 0;
	width: 72px;
	height: 2px;
	border-radius: 2px;
	background: var(--vi-sunset-wide);
	box-shadow: 0 0 12px rgba(253, 92, 136, 0.6);
}

.post > h2 > a {
	color: inherit;
	text-decoration: none;
}

.post > h3 {
	font-size: 22px;
	margin: 1.4em 0 0.4em;
}

.post > p {
	margin: 0 0 1em;
	letter-spacing: 0.01rem;
}

.post a {
	color: var(--vi-pink);
	text-decoration: underline;
	text-decoration-color: rgba(253, 92, 136, 0.45);
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
	transition: color 0.2s, text-shadow 0.2s, text-decoration-color 0.2s;
}

.post a:hover {
	color: #ffd0e0;
	text-decoration-color: var(--vi-flamingo);
	text-shadow: 0 0 16px rgba(253, 92, 136, 0.8);
}

.post strong,
.post b {
	color: var(--vi-cream);
	font-weight: 600;
}

/* картинки и видео; width и height в разметке нужны, чтобы страница не прыгала при загрузке */
.post > img,
.post > video {
	display: block;
	width: 100%;
	height: auto;
	margin: 0.4em auto 1.2em;
	border-radius: 18px;
	box-shadow: 0 18px 50px -24px rgba(5, 5, 15, 0.9);
}

.post > .vertical-scale {
	width: 48%;
}

.post > img.pixel-vertical-scale {
	width: 35%;
}

.post > video.video-vertical-scale {
	width: 45%;
}

.post > audio {
	display: block;
	width: 100%;
	margin: 0.4em auto 1.2em;
}

.post > .central-element {
	margin-left: auto;
	margin-right: auto;
}

/* цитаты: 💡 — заметка, 🚨 — предупреждение */
.post > blockquote {
	position: relative;
	margin: 0.4em 0 1.4em;
	padding: 16px 20px 16px 52px;
	border-radius: 18px;
	background: linear-gradient(135deg, rgba(61, 95, 205, 0.22), rgba(138, 61, 193, 0.12));
	box-shadow: var(--glass-edge);
}

.post > blockquote::before {
	content: '💡';
	position: absolute;
	left: 18px;
	top: 15px;
}

.post > blockquote.warning {
	background: linear-gradient(135deg, rgba(253, 92, 136, 0.24), rgba(255, 149, 76, 0.12));
}

.post > blockquote.warning::before {
	content: '🚨';
}

/* списки */
.post > ul,
.post > ol {
	margin: 0 0 1.2em;
	padding-left: 1.6em;
}

.post > ul {
	list-style: none;
	padding-left: 0;
}

.post > ul > li {
	position: relative;
	padding-left: 1.4em;
}

.post > ul > li::before {
	content: '';
	position: absolute;
	left: 0.2em;
	top: 0.72em;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--vi-sunset-wide);
	box-shadow: 0 0 10px rgba(253, 92, 136, 0.7);
}

.post > ol > li::marker {
	color: var(--vi-pink);
	font-weight: 600;
}

/* оглавление истории */
.post > ul.toc {
	padding: 14px;
	border-radius: 22px;
	background: rgba(12, 13, 27, 0.35);
	box-shadow: var(--glass-edge);
}

.post > ul.toc > li {
	padding: 0;
}

.post > ul.toc > li::before {
	display: none;
}

.post > ul.toc a {
	display: block;
	padding: 8px 16px;
	border-radius: 14px;
	color: var(--vi-lilac);
	text-decoration: none;
	line-height: 1.5;
}

.post > ul.toc a:hover {
	color: var(--vi-cream);
	text-shadow: none;
	background: rgba(255, 241, 220, 0.08);
}

.post > ul.toc a.active {
	color: var(--vi-cream);
	background: linear-gradient(110deg, rgba(138, 61, 193, 0.45), rgba(253, 92, 136, 0.35));
	box-shadow: var(--glass-edge);
}

/* код */
.post code {
	padding: 0.1em 0.4em;
	border-radius: 6px;
	background: rgba(255, 241, 220, 0.08);
	font-size: 0.88em;
}

.post pre {
	margin: 0.4em 0 1.4em;
}

.post pre > code,
.post pre > code.hljs {
	display: block;
	padding: 18px 20px;
	border-radius: 16px;
	background: rgba(8, 8, 20, 0.7);
	box-shadow: var(--glass-edge);
	font-family: ui-monospace, 'SF Mono', Menlo, monospace;
	font-size: 14px;
	line-height: 1.6;
	overflow-x: auto;
}

/* навигация по главам */
.navigation {
	display: flex;
	gap: 16px;
	margin-top: 2em;
}

.navigation a {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 2px;
	padding: 14px 20px;
	border-radius: 20px;
	text-decoration: none;
	transition: transform 0.4s cubic-bezier(.2, .8, .2, 1), box-shadow 0.4s;
}

.navigation a.next {
	align-items: flex-end;
	text-align: right;
}

.navigation a:hover {
	transform: translateY(-3px);
	text-shadow: none;
	box-shadow: var(--glass-edge), 0 0 50px -16px rgba(253, 92, 136, 0.6);
}

.navigation .label {
	font-size: 12px;
	letter-spacing: 1.5px;
	text-transform: uppercase;
	color: var(--vi-muted);
}

.navigation .prev .label::before {
	content: '← ';
}

.navigation .next .label::after {
	content: ' →';
}

.navigation .name {
	color: var(--vi-cream);
	font-weight: 500;
	line-height: 1.4;
}

/* Twemoji на Windows */
img.emoji {
	display: inline;
	width: 1em;
	height: 1em;
	margin: 0 0.05em 0 0.1em;
	vertical-align: -0.1em;
	box-shadow: none;
	border-radius: 0;
}

/* ---------- подвал ---------- */

footer {
	position: relative;
	z-index: 2;
	display: flex;
	justify-content: center;
	padding: 22px 0 28px;
}

footer span {
	padding: 12px 24px;
	border-radius: 999px;
	font-size: 15px;
	color: rgba(255, 241, 220, 0.85);
}

/* ---------- телефоны ---------- */

@media (max-width: 760px) {
	.theme-switch {
		top: 10px;
		right: 10px;
	}

	.theme-switch button {
		padding: 6px 11px;
		font-size: 11px;
	}

	.menu {
		padding-top: 64px;
	}

	.menu > ul {
		flex-direction: column;
		align-items: center;
		gap: 2px;
	}

	.menu > ul > li > a {
		font-size: 17px;
		padding: 11px 22px;
	}

	/* Наведения на телефоне нет: вложенные разделы открываются карточками на странице раздела */
	.menu li:hover > .submenu,
	.menu li:focus-within > .submenu {
		display: none;
	}

	.cards {
		grid-template-columns: 1fr;
		width: 92vw;
		margin-top: 4vh;
	}

	.cards > .card:last-child:nth-child(odd) {
		width: 100%;
	}

	.card {
		border-radius: 26px;
		padding: 8px;
	}

	.card .media {
		border-radius: 19px;
		aspect-ratio: 4 / 3.4;
	}

	.card .caption {
		left: 16px;
		right: 16px;
		bottom: 16px;
		padding: 12px 16px;
	}

	.panel {
		width: 96vw;
		margin-top: 4vh;
		border-radius: 26px;
	}

	.post {
		font-size: 16.5px;
	}

	.post > .vertical-scale,
	.post > video.video-vertical-scale {
		width: 90%;
	}

	.post > img.pixel-vertical-scale {
		width: 70%;
	}

	.navigation {
		flex-direction: column;
	}

	.dock {
		bottom: 12px;
	}

	.dock a {
		padding: 9px 12px;
		font-size: 11.5px;
		letter-spacing: 1px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.bg .blob {
		animation: none;
	}

	.card,
	.card img,
	.dock,
	.navigation a {
		transition: none;
	}
}
