/*
 * Лента канала Дзена 1.2.8. Static stylesheet: every per-site / per-block option
 * arrives as a CSS custom property (--dfb-*) or a modifier class on .dfb, with the
 * built-in value as the var() fallback.
 * Card titles and the channel name set their own color, so a theme rule
 * `.entry-content a { color }` cannot turn them blue.
 */
.dfb {
	--dfb-bg: transparent;
	--dfb-ink: #1a1a1a;
	--dfb-muted: #808080;
	--dfb-line: rgba(6, 6, 15, 0.08);
	--dfb-card-bg: transparent;
	--dfb-accent: #ff5317;
	--dfb-shadow: none;
	position: relative;
	box-sizing: border-box;
	margin: 1.6rem 0 2rem;
	padding: var(--dfb-pad, 0);
	color: var(--dfb-ink);
	background: var(--dfb-bg);
	border: var(--dfb-bw, 0) solid var(--dfb-bc, transparent);
	border-radius: var(--dfb-radius, 0);
	font-family: inherit;
}

.dfb--light,
.dfb--auto {
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	.dfb--auto {
		--dfb-bg: #171614;
		--dfb-ink: #f4f1ea;
		--dfb-muted: #b7b1a6;
		--dfb-line: rgba(255, 255, 255, 0.1);
		--dfb-card-bg: transparent;
		--dfb-shadow: none;
		color-scheme: dark;
	}
}

.dfb--dark {
	--dfb-bg: #171614;
	--dfb-ink: #f4f1ea;
	--dfb-muted: #b7b1a6;
	--dfb-line: rgba(255, 255, 255, 0.1);
	--dfb-card-bg: #221f1c;
	--dfb-shadow: none;
	color-scheme: dark;
}

.dfb--light {
	--dfb-bg: #fff;
	--dfb-ink: #1a1a1a;
	--dfb-muted: #6b675f;
	--dfb-line: rgba(26, 26, 26, 0.1);
	--dfb-card-bg: #fff;
	--dfb-shadow: none;
}

.dfb *,
.dfb *::before,
.dfb *::after {
	box-sizing: border-box;
}

/* ---------------------------------------------------------------- header */

.dfb__head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 12px;
	margin: 0 2px 14px;
}

.dfb__brand {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
	color: var(--dfb-ink);
	text-decoration: none;
}

.dfb__logo {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	object-fit: cover;
	flex: 0 0 auto;
	background: #f3efe8;
}

.dfb__logo--fallback {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: var(--dfb-accent);
	color: #fff;
	font-weight: 700;
}

.dfb__brand-text {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.dfb__kicker {
	font-size: 11px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--dfb-accent);
	font-weight: 700;
}

.dfb__channel {
	font-size: 16px;
	font-weight: 700;
	line-height: 1.2;
	color: var(--dfb-ink);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.dfb__head-side {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-left: auto;
	min-width: 0;
}

.dfb__heading {
	margin: 0;
	font-size: var(--dfb-h-size, 20px);
	font-weight: 700;
	line-height: 1.25;
	color: var(--dfb-h-color, var(--dfb-ink));
}

/* The visible text, not the <a>: a theme rule `.entry-content a` cannot restyle it. */
.dfb__heading-text {
	color: var(--dfb-h-color, var(--dfb-ink));
}

.dfb__heading-link {
	color: var(--dfb-h-color, var(--dfb-ink));
	text-decoration: none;
}

.dfb__heading-link:hover .dfb__heading-text {
	text-decoration: underline;
}

/* Heading on its own line above the header (left / center / right). */
.dfb--ha-left .dfb__head-side,
.dfb--ha-center .dfb__head-side,
.dfb--ha-right .dfb__head-side {
	order: -1;
	flex: 1 1 100%;
	margin-left: 0;
}

.dfb--ha-left .dfb__head-side {
	justify-content: flex-start;
	text-align: left;
}

.dfb--ha-center .dfb__head-side {
	justify-content: center;
	text-align: center;
}

.dfb--ha-right .dfb__head-side {
	justify-content: flex-end;
	text-align: right;
}

/* ----------------------------------------------------------------- track */

.dfb__viewport {
	position: relative;
	container-type: inline-size;
	container-name: dfb;
}

.dfb__track {
	display: flex;
	gap: var(--dfb-gap, 16px);
	overflow-x: auto;
	overscroll-behavior-x: contain;
	-webkit-overflow-scrolling: touch;
	scroll-snap-type: x mandatory;
	/* Room above and below the cards so the shadow fades inside the scrollport
	   instead of being cut into a hard gray edge. */
	padding: 10px 2px 22px;
	scrollbar-width: thin;
	scrollbar-color: var(--dfb-line) transparent;
}

.dfb__track:focus-visible {
	outline: 2px solid var(--dfb-accent);
	outline-offset: 2px;
	border-radius: 8px;
}

/* Arrows / dots: scrollbar hidden only once the script is running (.dfb--js);
   without JS the thin native scrollbar stays as a fallback. Swipe/trackpad always work. */
.dfb--js.dfb--l-arrows .dfb__track,
.dfb--js.dfb--l-dots .dfb__track,
.dfb--js.dfb--l-dots-arrows .dfb__track {
	scrollbar-width: none;
	padding-bottom: 22px;
}

.dfb--js.dfb--l-arrows .dfb__track::-webkit-scrollbar,
.dfb--js.dfb--l-dots .dfb__track::-webkit-scrollbar,
.dfb--js.dfb--l-dots-arrows .dfb__track::-webkit-scrollbar {
	display: none;
}

/* Thin styled scrollbar. */
.dfb--l-thin .dfb__track {
	scrollbar-width: thin;
	scrollbar-color: var(--dfb-accent) transparent;
}

.dfb--l-thin .dfb__track::-webkit-scrollbar {
	height: 4px;
}

.dfb--l-thin .dfb__track::-webkit-scrollbar-thumb {
	background: var(--dfb-accent);
	border-radius: 4px;
}

.dfb--l-thin .dfb__track::-webkit-scrollbar-track {
	background: transparent;
}

/* ----------------------------------------------------------------- cards */

.dfb__card {
	flex: 0 0 var(--dfb-card, 280px);
	scroll-snap-align: start;
	display: flex;
	flex-direction: column;
	min-width: 0;
	color: var(--dfb-ink);
	text-decoration: none;
	background: var(--dfb-card-bg, transparent);
	border: var(--dfb-c-bw, 0) solid var(--dfb-c-bc, transparent);
	border-radius: var(--dfb-c-radius, 0);
	overflow: visible;
	box-shadow: var(--dfb-shadow);
	transition: border-color 0.18s ease;
}

/* Beat a theme rule like `.entry-content a` (color + underline), including :visited.
   The title, channel name and heading text also set their own color below. */
.dfb a.dfb__card,
.dfb a.dfb__card:hover,
.dfb a.dfb__card:visited,
.dfb a.dfb__brand,
.dfb a.dfb__brand:hover,
.dfb a.dfb__brand:visited,
.dfb a.dfb__heading-link,
.dfb a.dfb__heading-link:hover,
.dfb a.dfb__heading-link:visited {
	color: var(--dfb-ink);
	text-decoration: none;
}

.dfb__card:hover {
	border-color: var(--dfb-accent);
}

.dfb__card:focus-visible {
	outline: 2px solid var(--dfb-accent);
	outline-offset: 2px;
}

.dfb__media {
	position: relative;
	display: block;
	aspect-ratio: var(--dfb-ratio, 16 / 10);
	border-radius: var(--dfb-c-radius, 16px);
	overflow: hidden;
	background: #ece7df;
}

.dfb__media img,
.dfb__media-empty {
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	display: block;
}

.dfb__badge {
	position: absolute;
	left: 10px;
	bottom: 10px;
	padding: 3px 8px;
	border-radius: 999px;
	background: rgba(18, 16, 14, 0.78);
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.02em;
}

.dfb__badge--video {
	background: var(--dfb-accent);
}

.dfb__body {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 10px 2px 0;
	min-width: 0;
}

.dfb__title {
	font-size: var(--dfb-t-size, 16px);
	font-weight: var(--dfb-t-weight, 700);
	color: var(--dfb-t-color, var(--dfb-ink));
	line-height: 1.3;
	display: -webkit-box;
	-webkit-line-clamp: var(--dfb-t-lines, 3);
	line-clamp: var(--dfb-t-lines, 3);
	-webkit-box-orient: vertical;
	overflow: hidden;
	min-height: 0;
}

.dfb__meta,
.dfb__excerpt {
	color: var(--dfb-muted);
	font-size: 12.5px;
	line-height: 1.4;
}

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

.dfb__excerpt {
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ------------------------------------------------------- arrows and dots */

.dfb__arrow {
	position: absolute;
	top: 22%;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border-radius: 999px;
	border: 1px solid var(--dfb-line);
	background: #fff;
	color: var(--dfb-ink);
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	transition: opacity 0.15s ease, visibility 0.15s;
}

.dfb--dark .dfb__arrow {
	background: #2c2824;
	color: #f4f1ea;
	border-color: rgba(255, 255, 255, 0.12);
}

@media (prefers-color-scheme: dark) {
	.dfb--auto .dfb__arrow {
		background: #2c2824;
		color: #f4f1ea;
		border-color: rgba(255, 255, 255, 0.12);
	}
}

.dfb__arrow--prev {
	left: 4px;
}

.dfb__arrow--next {
	right: 4px;
}

.dfb__arrow[hidden],
.dfb__dots[hidden] {
	display: none;
}

.dfb__arrow:hover {
	border-color: var(--dfb-accent);
	color: var(--dfb-accent);
}

.dfb__arrow:focus-visible,
.dfb__dot:focus-visible {
	outline: 2px solid var(--dfb-accent);
	outline-offset: 2px;
}

/* At either end the arrow fades out; the script moves keyboard focus to the other arrow. */
.dfb__arrow[aria-disabled="true"] {
	opacity: 0;
	visibility: hidden;
}

.dfb__dots {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 4px;
	margin-top: 6px;
}

.dfb__dot {
	width: 24px;
	height: 24px;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
	position: relative;
}

.dfb__dot::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 8px;
	height: 8px;
	margin: -4px 0 0 -4px;
	border-radius: 999px;
	background: var(--dfb-muted);
	opacity: 0.45;
	transition: width 0.15s ease, opacity 0.15s ease;
}

.dfb__dot[aria-current="true"]::before {
	width: 20px;
	margin-left: -10px;
	background: var(--dfb-accent);
	opacity: 1;
}

.dfb__dot[hidden] {
	display: none;
}

/* Touch screens swipe; overlay arrows only for mouse/trackpad users. */
@media (hover: none) and (pointer: coarse) {
	.dfb__arrow {
		display: none;
	}
}

/* Carousel cards (dzen.ru/ria): photo on top, time, then the title.
   Width follows the column: up to 1099px two cards fill the row, so a 1024px
   column shows two cards instead of one. Wider than that, --dfb-card applies. */
.dfb--l-arrows .dfb__card,
.dfb--l-dots .dfb__card,
.dfb--l-dots-arrows .dfb__card,
.dfb--l-thin .dfb__card {
	max-width: calc((100% - var(--dfb-gap, 16px)) / 2);
}

.dfb--l-arrows .dfb__meta,
.dfb--l-dots .dfb__meta,
.dfb--l-dots-arrows .dfb__meta,
.dfb--l-thin .dfb__meta {
	order: -1;
	font-size: 13px;
}

/* ------------------------------------------------------------------ grid */
/* Topic grid (dzen.ru/topic): photo, title, meta. No card chrome. */

.dfb--l-grid .dfb__track {
	display: grid;
	grid-template-columns: repeat(var(--dfb-cols, 3), minmax(0, 1fr));
	overflow: visible;
	scroll-snap-type: none;
	padding: 2px;
	gap: var(--dfb-gap, 20px);
}

.dfb--l-grid .dfb__card,
.dfb--l-list .dfb__card,
.dfb--l-list-right .dfb__card {
	flex: none;
	width: auto;
	max-width: none;
}

.dfb--l-grid .dfb__title {
	min-height: 0;
}

/* ------------------------------------------------------------------ list */
/* Recommend-reading row: thumbnail on the left, title on the right. */

.dfb--l-list .dfb__track,
.dfb--l-list-right .dfb__track {
	flex-direction: column;
	overflow: visible;
	scroll-snap-type: none;
	padding: 2px;
	gap: 0;
}

.dfb--l-list .dfb__card,
.dfb--l-list-right .dfb__card {
	flex-direction: row;
	align-items: center;
	gap: 12px;
	padding: 14px 0;
	border-bottom: 1px solid var(--dfb-line);
	background: transparent;
	box-shadow: none;
}

.dfb--l-list .dfb__card:last-child,
.dfb--l-list-right .dfb__card:last-child {
	border-bottom: 0;
}

.dfb--l-list .dfb__media {
	flex: 0 0 112px;
	width: 112px;
	aspect-ratio: var(--dfb-ratio, 1 / 1);
	align-self: center;
	border-radius: var(--dfb-c-radius, 12px);
}

.dfb--l-list .dfb__body,
.dfb--l-list-right .dfb__body {
	flex: 1 1 auto;
	justify-content: center;
	padding: 0;
}

.dfb--l-list .dfb__title,
.dfb--l-list-right .dfb__title {
	min-height: 0;
	-webkit-line-clamp: var(--dfb-t-lines, 2);
	line-clamp: var(--dfb-t-lines, 2);
}

/* Home-feed row: title on the left, photo on the right (dzen.ru). */
.dfb--l-list-right .dfb__card {
	flex-direction: row-reverse;
	gap: 16px;
	padding: 16px 0;
}

.dfb--l-list-right .dfb__media {
	flex: 0 0 196px;
	width: 196px;
	aspect-ratio: var(--dfb-ratio, 3 / 2);
	border-radius: var(--dfb-c-radius, 12px);
}

.dfb--l-list-right .dfb__title {
	font-size: var(--dfb-t-size, 18px);
	-webkit-line-clamp: var(--dfb-t-lines, 3);
	line-clamp: var(--dfb-t-lines, 3);
}

/* Text only: same row as a list, without the photo. */
.dfb--l-no-photo .dfb__track {
	flex-direction: column;
	overflow: visible;
	scroll-snap-type: none;
	padding: 2px;
	gap: 0;
}

.dfb--l-no-photo .dfb__card {
	flex: none;
	flex-direction: column;
	width: auto;
	max-width: none;
	padding: 12px 0;
	border-bottom: 1px solid var(--dfb-line);
	background: transparent;
	box-shadow: none;
}

.dfb--l-no-photo .dfb__card:last-child {
	border-bottom: 0;
}

.dfb--l-no-photo .dfb__media {
	display: none;
}

.dfb--l-no-photo .dfb__body {
	padding: 0;
}

.dfb--l-no-photo .dfb__title {
	min-height: 0;
}

/* --------------------------------------------------------- card shadows */

.dfb.dfb--sh-none {
	--dfb-shadow: none;
}

.dfb.dfb--sh-soft {
	--dfb-shadow: 0 3px 10px rgba(0, 0, 0, 0.07);
}

.dfb.dfb--sh-strong {
	--dfb-shadow: 0 8px 16px rgba(0, 0, 0, 0.16);
}

/* ---------------------------------------------------------------- notice */

.dfb-notice {
	margin: 1rem 0;
	padding: 12px 14px;
	border: 1px dashed #c9a27a;
	border-radius: 12px;
	background: #fff8f1;
	color: #6a4b2b;
}

/* ------------------------------------------------------------ responsive */

@media (prefers-reduced-motion: reduce) {
	.dfb__card,
	.dfb__arrow,
	.dfb__dot::before {
		transition: none;
	}
	.dfb__card:hover {
		transform: none;
	}
	.dfb__track {
		scroll-behavior: auto;
	}
}

@media (max-width: 900px) {
	.dfb--l-grid .dfb__track {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 640px) {
	.dfb {
		padding: var(--dfb-pad, 0);
		border-radius: var(--dfb-radius, 0);
	}
	.dfb--l-arrows .dfb__card,
	.dfb--l-dots .dfb__card,
	.dfb--l-dots-arrows .dfb__card,
	.dfb--l-thin .dfb__card {
		flex-basis: 84%;
		width: 84%;
		max-width: none;
	}
	.dfb--l-grid .dfb__track {
		grid-template-columns: minmax(0, 1fr);
	}
	.dfb--l-list .dfb__media {
		flex-basis: 96px;
		width: 96px;
	}
	.dfb--l-list-right .dfb__media {
		flex-basis: 120px;
		width: 120px;
	}
	.dfb--l-list .dfb__body,
	.dfb--l-list-right .dfb__body {
		padding: 0;
		gap: 4px;
	}
}

/* Column width, not the viewport: a 1024px-wide feed shows two carousel cards. */
@container dfb (max-width: 1099px) {
	.dfb--l-arrows .dfb__card,
	.dfb--l-dots .dfb__card,
	.dfb--l-dots-arrows .dfb__card,
	.dfb--l-thin .dfb__card {
		flex-basis: calc((100% - var(--dfb-gap, 16px)) / 2);
		width: calc((100% - var(--dfb-gap, 16px)) / 2);
		max-width: none;
	}
}

@container dfb (max-width: 560px) {
	.dfb--l-arrows .dfb__card,
	.dfb--l-dots .dfb__card,
	.dfb--l-dots-arrows .dfb__card,
	.dfb--l-thin .dfb__card {
		flex-basis: 84%;
		width: 84%;
		max-width: none;
	}
}
