/*
 * Bammat — «Как это работает»: плитки на главной и окно историй.
 *
 * Цвет плитки задаёт владелец в настройке карточек (пастель вида
 * `#e3f2fd`). В светлой теме это сам фон; в тёмной пастельный
 * прямоугольник на чёрном светится, как включённый экран, — там
 * цвет только подмешивается к поверхности.
 */

/* ── Плитки ──────────────────────────────────────────────────────── */

.ba-how-card {
	position: relative;
	display: flex;
	flex-direction: column;
	flex: none;
	width: clamp(132px, 36vw, 164px);
	aspect-ratio: 4 / 5;
	padding: 14px;
	border: 0;
	border-radius: var(--ba-r-lg);
	background: var(--c, var(--ba-surface-2));
	text-align: left;
	color: #14161b;
	cursor: pointer;
	overflow: hidden;
	scroll-snap-align: start;
	box-shadow: inset 0 0 0 1px rgba(16, 18, 22, 0.04);
	transition: transform var(--ba-d1) var(--ba-ease);
	-webkit-tap-highlight-color: transparent;
}
.ba-how-card:active { transform: scale(0.96); }
.ba-how-card:focus-visible { outline: 3px solid var(--ba-accent); outline-offset: 2px; }

/* Знак — крупно и один. Россыпь из восьми знаков фоном владелец
   браковал дважды: она читается наклейкой, а не картинкой. */
.ba-how-e {
	font-size: 42px;
	line-height: 1;
	filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.12));
}
.ba-how-t {
	margin-top: auto;
	font: 750 var(--ba-fs-md)/1.2 var(--ba-font-display);
	letter-spacing: -0.01em;
	text-wrap: balance;
}
.ba-how-n {
	margin-top: 4px;
	font-size: var(--ba-fs-xs);
	font-weight: 600;
	color: rgba(20, 22, 27, 0.55);
}

/* Круг вокруг знака — едва заметный, чтобы плитки разного цвета
   выглядели одной серией. */
.ba-how-card::before {
	content: "";
	position: absolute;
	top: -30px;
	right: -30px;
	width: 110px;
	height: 110px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.45);
	pointer-events: none;
}

:root[data-theme="dark"] .ba-how-card {
	background: color-mix(in srgb, var(--c, #888) 16%, var(--ba-surface-2));
	color: var(--ba-ink);
	box-shadow: inset 0 0 0 1px var(--ba-line);
}
:root[data-theme="dark"] .ba-how-n { color: var(--ba-ink-3); }
:root[data-theme="dark"] .ba-how-card::before { background: rgba(255, 255, 255, 0.04); }
@media (prefers-color-scheme: dark) {
	:root[data-theme="system"] .ba-how-card {
		background: color-mix(in srgb, var(--c, #888) 16%, var(--ba-surface-2));
		color: var(--ba-ink);
		box-shadow: inset 0 0 0 1px var(--ba-line);
	}
	:root[data-theme="system"] .ba-how-n { color: var(--ba-ink-3); }
	:root[data-theme="system"] .ba-how-card::before { background: rgba(255, 255, 255, 0.04); }
}

/* ── Окно историй ────────────────────────────────────────────────── */

.ba-story {
	position: fixed;
	inset: 0;
	z-index: 9100;
	display: flex;
	align-items: stretch;
	justify-content: center;
	background: rgba(8, 10, 14, 0.72);
	opacity: 0;
	transition: opacity 0.26s var(--ba-ease);
}
.ba-story[hidden] { display: none; }
.ba-story.is-open { opacity: 1; }

.ba-story-card {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
	padding: calc(var(--ba-safe-t) + 12px) 20px calc(var(--ba-safe-b) + 28px);
	overflow: hidden;
	background: var(--sc, #eef2ff);
	color: #14161b;
	transform: scale(0.94);
	transition: transform 0.34s var(--ba-ease-out), background-color 0.45s var(--ba-ease);
	touch-action: pan-y;
	user-select: none;
	-webkit-user-select: none;
}
.ba-story.is-open .ba-story-card { transform: none; }

:root[data-theme="dark"] .ba-story-card { background: color-mix(in srgb, var(--sc, #888) 18%, #11141b); color: #f2f4f8; }
@media (prefers-color-scheme: dark) {
	:root[data-theme="system"] .ba-story-card { background: color-mix(in srgb, var(--sc, #888) 18%, #11141b); color: #f2f4f8; }
}

.ba-story-bars { position: relative; z-index: 3; display: flex; gap: 4px; }
.ba-story-bars i {
	position: relative;
	flex: 1;
	height: 3px;
	border-radius: 2px;
	background: rgba(20, 22, 27, 0.14);
	overflow: hidden;
}
.ba-story-bars i::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	background: currentColor;
	transform: scaleX(var(--p, 0));
	transform-origin: left;
}
:root[data-theme="dark"] .ba-story-bars i { background: rgba(255, 255, 255, 0.18); }
@media (prefers-color-scheme: dark) { :root[data-theme="system"] .ba-story-bars i { background: rgba(255, 255, 255, 0.18); } }

.ba-story-top {
	position: relative;
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-top: 12px;
}
.ba-story-who { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: var(--ba-fs-md); }
.ba-story-who-e {
	display: grid;
	place-items: center;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.6);
	font-size: 17px;
}
:root[data-theme="dark"] .ba-story-who-e { background: rgba(255, 255, 255, 0.08); }
.ba-story-x {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(20, 22, 27, 0.08);
	color: inherit;
	cursor: pointer;
}
:root[data-theme="dark"] .ba-story-x { background: rgba(255, 255, 255, 0.1); }
.ba-story-x .ba-i { width: 20px; height: 20px; }

.ba-story-stage {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	justify-content: center;
	flex: 1;
	padding: 12px 4px 0;
}
.ba-story-stage.is-in { animation: ba-story-in 0.4s var(--ba-ease-out) both; }
@keyframes ba-story-in {
	from { opacity: 0; transform: translateY(14px); }
	to { opacity: 1; transform: none; }
}

.ba-story-art {
	display: grid;
	place-items: center;
	width: 132px;
	height: 132px;
	margin-bottom: 34px;
	border-radius: 40px;
	background: rgba(255, 255, 255, 0.62);
	box-shadow: 0 24px 48px -20px rgba(16, 18, 22, 0.35);
	font-size: 68px;
	line-height: 1;
}
:root[data-theme="dark"] .ba-story-art { background: rgba(255, 255, 255, 0.07); box-shadow: none; }
@media (prefers-color-scheme: dark) { :root[data-theme="system"] .ba-story-art { background: rgba(255, 255, 255, 0.07); box-shadow: none; } }

.ba-story-step {
	margin: 0 0 8px;
	font-size: var(--ba-fs-sm);
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--ba-accent);
}
.ba-story-t {
	margin: 0 0 12px;
	font: 800 32px/1.1 var(--ba-font-display);
	letter-spacing: var(--ba-track-tight);
	text-wrap: balance;
}
.ba-story-d {
	margin: 0;
	max-width: 34ch;
	font-size: var(--ba-fs-lg);
	line-height: 1.5;
	opacity: 0.78;
	text-wrap: pretty;
}

/* Касание: левая треть — назад, остальное — вперёд (как в Instagram:
   вперёд листают чаще, и целиться туда не нужно). */
.ba-story-nav {
	position: absolute;
	top: 90px;
	bottom: 0;
	z-index: 2;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}
.ba-story-nav--prev { left: 0; width: 33%; }
.ba-story-nav--next { right: 0; width: 67%; }

@media (min-width: 600px) {
	.ba-story { align-items: center; padding: 24px; }
	.ba-story-card {
		max-width: 420px;
		height: min(760px, calc(100dvh - 48px));
		padding: 18px 28px 36px;
		border-radius: var(--ba-r-xl);
		box-shadow: var(--ba-sh-3);
	}
	/* На компьютере касаются мышью — видимые стрелки по бокам. */
	.ba-story-nav { top: 50%; bottom: auto; width: 44px; height: 44px; margin-top: -22px; border-radius: 50%; background: rgba(255, 255, 255, 0.7) no-repeat center / 20px; box-shadow: var(--ba-sh-2); }
	.ba-story-nav--prev { left: 12px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2314161b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 5l-7 7 7 7'/%3E%3C/svg%3E"); }
	.ba-story-nav--next { right: 12px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2314161b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 5l7 7-7 7'/%3E%3C/svg%3E"); }
	.ba-story-t { font-size: 34px; }
}

@media (prefers-reduced-motion: reduce) {
	.ba-story, .ba-story-card, .ba-story-stage.is-in { transition: none; animation: none; }
}

/* ── Шторка «?» ──────────────────────────────────────────────────── */
/*
 * Шторка крупнее, плитки выше (владелец, 30 сентября). Ленту на полэкрана
 * сменила сетка в два столбца: все шаги видны сразу, листать вбок
 * нечего, а плитка 3:4 — это уже картинка, а не значок.
 */
.ba-sheet--how { height: min(86dvh, 820px); }
.ba-sheet--how .ba-sheet-scroll { padding-bottom: calc(24px + var(--ba-safe-b)); }
.ba-how-lead { margin: 0 0 14px; color: var(--ba-ink-2); font-size: var(--ba-fs-md); line-height: 1.45; }
.ba-sheet--how .ba-how-rail { margin: 0; overflow: visible; }
.ba-sheet--how .ba-how-rail .ba-rail-track {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px;
	width: auto;
	padding: 0;
	overflow: visible;
}
.ba-sheet--how .ba-how-card { width: auto; aspect-ratio: 3 / 4; padding: 16px; }

/*
 * Новость — карточка во всю ширину над плитками, с ярлыком «New»
 * (владелец, 8 октября: «выделить карточку как NEW»). Лежит плашмя:
 * знак слева, заголовок и одна фраза «как» справа. Рамка и ярлык —
 * цветом акции, как метка у кнопки «?», которая сюда привела.
 */
.ba-sheet--how .ba-how-card--new {
	grid-column: 1 / -1;
	aspect-ratio: auto;
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	align-items: center;
	gap: 4px 14px;
	padding: 18px 16px;
	box-shadow: inset 0 0 0 2px var(--ba-promo);
}
.ba-sheet--how .ba-how-card--new .ba-how-e { grid-row: 1 / 3; font-size: 46px; }
.ba-sheet--how .ba-how-card--new .ba-how-t { margin-top: 0; padding-right: 54px; align-self: end; }
.ba-sheet--how .ba-how-card--new .ba-how-n { margin-top: 0; align-self: start; font-size: var(--ba-fs-sm); font-weight: 500; line-height: 1.35; color: rgba(20, 22, 27, 0.7); }
/* Спрятанная спрятана: у карточки своё `display`, и атрибут `hidden`
   сам по себе его не перебивает (на этом 22 августа показывался крестик
   поиска). */
.ba-how-card--new[hidden] { display: none !important; }
.ba-how-new {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 1;
	padding: 3px 9px 4px;
	border-radius: 999px;
	background: var(--ba-promo);
	color: var(--ba-promo-ink);
	font: 800 11px/1.2 var(--ba-font);
	letter-spacing: 0.03em;
	text-transform: uppercase;
}
.ba-sheet--how .ba-how-e { font-size: 54px; }
.ba-sheet--how .ba-how-t { font-size: var(--ba-fs-lg); }
@media (min-width: 720px) {
	.ba-sheet--how .ba-how-rail .ba-rail-track { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
