/*
 * AUTOOL Dynamic Feed — the blog/category counterpart of Dongchedi's
 * dynamic_motor_car page. Shell geometry comes from autool-dongchedi-shell;
 * every page-owned rule stays below .dcd-dynamic-page.
 */

body.dcd-dynamic-active #main {
	padding-top: 0;
	padding-bottom: 0;
}

.dcd-dynamic-page {
	--dcd-feed-gutter: max(16px, 4%);
	--dcd-feed-right: max(
		0px,
		calc(var(--shell-safe-right, 16px) - var(--shell-content-right, 0px))
	);
	--dcd-feed-fixed-left: var(--shell-safe-left, 16px);

	min-height: 70vh;
	padding: 12px var(--dcd-feed-right) 72px var(--dcd-feed-gutter);
	background: var(--dcd-page);
	color: var(--dcd-text);
	font-family: var(--dcd-font-family);
	font-size: var(--dcd-fs-body);
	line-height: var(--dcd-lh-body);
}

.dcd-dynamic-page *,
.dcd-dynamic-page *::before,
.dcd-dynamic-page *::after {
	box-sizing: border-box;
}

/* ------------------------------------------------------------------ */
/* Category tabs — 32px row, active 18px/500 with a 2px yellow marker */
/* ------------------------------------------------------------------ */

.dcd-feed-tabs {
	display: flex;
	align-items: center;
	gap: var(--dcd-space-7);
	width: 100%;
	height: 32px;
	min-width: 0;
	overflow: hidden;
}

.dcd-feed-tabs-scroll {
	display: flex;
	align-items: stretch;
	flex: 1 1 0;
	gap: 28px;
	width: 0;
	min-width: 0;
	overflow-x: auto;
	overflow-y: hidden;
	scrollbar-width: none;
	overscroll-behavior-inline: contain;
	scroll-snap-type: x proximity;
	scroll-padding-inline: 0 20px;
	touch-action: pan-x;
	-webkit-overflow-scrolling: touch;
}

.dcd-feed-tabs-scroll::-webkit-scrollbar {
	display: none;
}

.dcd-feed-tab {
	position: relative;
	display: inline-flex;
	align-items: center;
	flex: 0 0 auto;
	height: 32px;
	font-size: 16px;
	line-height: 24px;
	font-weight: 400;
	white-space: nowrap;
	color: var(--dcd-text-secondary);
	text-decoration: none;
	transition: color 0.16s ease;
	scroll-snap-align: start;
}

.dcd-feed-tab:hover,
.dcd-feed-tab:focus-visible {
	color: var(--dcd-orange-hover-text);
}

.dcd-feed-tab.is-active {
	font-size: 18px;
	font-weight: 500;
	color: var(--dcd-text);
}

.dcd-feed-tab.is-active::after {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	height: 2px;
	content: "";
	background: var(--dcd-yellow);
}

.dcd-feed-tab h1 {
	margin: 0;
	font: inherit;
	color: inherit;
}

.dcd-feed-more {
	position: relative;
	flex: 0 0 auto;
	height: 32px;
}

.dcd-feed-more summary {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
	height: 32px;
	padding: 0 10px;
	border: 1px solid var(--dcd-text-secondary);
	border-radius: var(--dcd-radius-sm);
	font-size: 14px;
	line-height: 20px;
	color: var(--dcd-text);
	background: var(--dcd-surface);
	cursor: pointer;
	list-style: none;
}

.dcd-feed-more summary::-webkit-details-marker {
	display: none;
}

.dcd-feed-more summary svg {
	width: 12px;
	height: 12px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.5;
	stroke-linecap: round;
	stroke-linejoin: round;
	transition: transform 0.16s ease;
}

.dcd-feed-more[open] summary svg {
	transform: rotate(180deg);
}

.dcd-feed-more-menu {
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	z-index: 30;
	display: grid;
	grid-template-columns: repeat(2, minmax(120px, 1fr));
	gap: 4px;
	width: 300px;
	padding: 12px;
	border: 1px solid var(--dcd-border);
	border-radius: var(--dcd-radius-md);
	background: var(--dcd-surface);
	box-shadow: 0 12px 32px rgba(31, 33, 41, 0.14);
}

.dcd-feed-more-menu a {
	display: block;
	min-width: 0;
	padding: 7px 8px;
	border-radius: var(--dcd-radius-sm);
	font-size: 13px;
	line-height: 18px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	color: var(--dcd-text-secondary);
	text-decoration: none;
}

.dcd-feed-more-menu a:hover,
.dcd-feed-more-menu a:focus-visible {
	color: var(--dcd-orange-hover-text);
	background: var(--dcd-hover-tint);
}

/* ------------------------------------------------------------------ */
/* Reference feed grid: 4 outer tracks; list 3 + right rail 1          */
/* ------------------------------------------------------------------ */

.dcd-feed-layout {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	column-gap: 16px;
	align-items: start;
	margin-top: 16px;
}

.dcd-feed-list {
	grid-column: span 3;
	min-width: 0;
}

.dcd-feed-layout > .dcd-rail {
	grid-column: span 1;
	min-width: 0;
}

.dcd-feed-layout.has-no-rail .dcd-feed-list {
	grid-column: 1 / -1;
}

.dcd-feed-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	column-gap: 16px;
	row-gap: 40px;
	padding-bottom: 40px;
}

.dcd-feed-layout.has-no-rail .dcd-feed-grid {
	grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* Dongchedi adds one feed track at its 1920px shell tier. Keep the right
   rail at one track and allow the article feed to use the other four. */
@media (min-width: 1920px) {
	.dcd-feed-layout {
		grid-template-columns: repeat(5, minmax(0, 1fr));
	}

	.dcd-feed-list {
		grid-column: span 4;
	}

	.dcd-feed-grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.dcd-feed-layout.has-no-rail .dcd-feed-grid {
		grid-template-columns: repeat(5, minmax(0, 1fr));
	}
}

/* ------------------------------------------------------------------ */
/* Feed card — 56% media, suspended author, 2-line title and 20px meta */
/* ------------------------------------------------------------------ */

.dcd-feed-card {
	min-width: 0;
	margin: 0;
	background: transparent;
	border-radius: 0;
}

.dcd-feed-media {
	position: relative;
	width: 100%;
	aspect-ratio: 25 / 14;
	background: var(--dcd-page-deep);
}

.dcd-feed-media > a {
	display: block;
	width: 100%;
	height: 100%;
	overflow: hidden;
	border-radius: var(--dcd-radius-md);
	background: var(--dcd-page-deep);
}

.dcd-feed-image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.24s ease;
}

.dcd-feed-card:hover .dcd-feed-image {
	transform: scale(1.025);
}

.dcd-feed-save {
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 2;
	display: none;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: var(--dcd-radius-md);
	background: rgba(31, 33, 41, 0.72);
	color: #fff;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.dcd-feed-card:hover .dcd-feed-save,
.dcd-feed-card:focus-within .dcd-feed-save,
.dcd-feed-save.is-saved {
	display: inline-flex;
}

.dcd-feed-save:hover,
.dcd-feed-save:focus-visible,
.dcd-feed-save.is-saved {
	background: var(--dcd-yellow);
	color: var(--dcd-text);
}

.dcd-feed-save svg {
	width: 18px;
	height: 18px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.dcd-feed-save.is-saved svg {
	fill: currentColor;
}

.dcd-feed-author {
	position: absolute;
	right: 8px;
	bottom: -25px;
	left: 10px;
	z-index: 1;
	display: flex;
	align-items: flex-end;
	min-width: 0;
	pointer-events: none;
}

.dcd-feed-avatar {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 40px;
	width: 40px;
	height: 40px;
	border: 2px solid var(--dcd-page);
	border-radius: 50%;
	background: linear-gradient(145deg, var(--dcd-yellow-light), var(--dcd-yellow));
	color: var(--dcd-text);
	font-size: 15px;
	font-weight: 600;
	line-height: 1;
}

.dcd-feed-author-name {
	min-width: 0;
	margin: 0 0 1px 8px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 14px;
	line-height: 14px;
	font-weight: 500;
	color: var(--dcd-text);
}

.dcd-feed-card-title {
	display: -webkit-box;
	height: 44px;
	margin: 36px 0 0;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	font-size: 16px;
	line-height: 22px;
	font-weight: 500;
	text-align: justify;
	color: var(--dcd-text);
}

.dcd-feed-card-title a {
	color: inherit;
	text-decoration: none;
	transition: color 0.16s ease;
}

.dcd-feed-card-title a:hover,
.dcd-feed-card-title a:focus-visible {
	color: var(--dcd-orange-hover-text);
}

.dcd-feed-card-meta {
	display: flex;
	align-items: center;
	gap: 8px;
	height: 20px;
	margin: 8px 0 0;
	overflow: hidden;
	font-size: 14px;
	line-height: 20px;
	white-space: nowrap;
	color: var(--dcd-text-secondary);
}

.dcd-feed-empty {
	grid-column: 1 / -1;
	margin: 0;
	padding: 40px 16px;
	background: var(--dcd-surface);
	text-align: center;
	color: var(--dcd-text-secondary);
}

/* ------------------------------------------------------------------ */
/* Pagination                                                         */
/* ------------------------------------------------------------------ */

.dcd-feed-pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 8px;
	padding: 0 0 8px;
}

.dcd-feed-pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 34px;
	height: 34px;
	padding: 0 10px;
	border: 1px solid var(--dcd-border);
	border-radius: var(--dcd-radius-sm);
	background: var(--dcd-surface);
	color: var(--dcd-text-secondary);
	text-decoration: none;
}

.dcd-feed-pagination a:hover,
.dcd-feed-pagination a:focus-visible,
.dcd-feed-pagination .current {
	border-color: var(--dcd-yellow);
	background: var(--dcd-yellow-active-gradient);
	color: var(--dcd-text);
}

/* ------------------------------------------------------------------ */
/* Reading mode switcher — fixed 10px from the bottom                 */
/* ------------------------------------------------------------------ */

.dcd-feed-mode {
	position: fixed;
	left: var(--dcd-feed-fixed-left);
	bottom: calc(10px + env(safe-area-inset-bottom, 0px));
	z-index: var(--dcd-z-floor-nav, 100);
	display: flex;
	align-items: center;
	min-height: 32px;
	padding: 6px 12px;
	border-radius: var(--dcd-radius-sm);
	background: var(--dcd-surface);
	box-shadow: 0 4px 12px rgba(31, 33, 41, 0.1), 0 1px 3px rgba(31, 33, 41, 0.08);
	font-size: 14px;
	line-height: 20px;
	white-space: nowrap;
}

.dcd-feed-mode-current {
	margin-right: 12px;
	padding: 0 6px;
	border-radius: var(--dcd-radius-sm);
	background: rgba(0, 168, 96, 0.1);
	color: var(--dcd-green);
}

.dcd-feed-mode-item {
	position: relative;
	display: inline-flex;
	align-items: center;
	border-bottom: 1px dashed var(--dcd-text-muted);
	color: var(--dcd-text-muted);
	text-decoration: none;
}

.dcd-feed-mode-item:hover,
.dcd-feed-mode-item:focus-visible {
	color: var(--dcd-orange-hover-text);
}

.dcd-feed-mode-item.is-active {
	border-bottom-color: transparent;
	color: var(--dcd-text);
}

.dcd-feed-mode-rule {
	width: 1px;
	height: 12px;
	margin: 0 12px;
	background: var(--dcd-border);
}

.dcd-feed-mode-tip {
	position: absolute;
	bottom: calc(100% + 10px);
	left: 50%;
	display: none;
	width: 233px;
	padding: 12px;
	border-radius: var(--dcd-radius-md);
	background: rgba(0, 0, 0, 0.76);
	color: #fff;
	font-size: 14px;
	line-height: 20px;
	white-space: normal;
	transform: translateX(-50%);
}

.dcd-feed-mode-tip::after {
	position: absolute;
	top: 100%;
	left: 50%;
	width: 0;
	height: 0;
	margin-left: -6px;
	content: "";
	border-top: 8px solid rgba(0, 0, 0, 0.76);
	border-right: 6px solid transparent;
	border-left: 6px solid transparent;
}

.dcd-feed-mode-item:hover .dcd-feed-mode-tip,
.dcd-feed-mode-item:focus-visible .dcd-feed-mode-tip {
	display: block;
}

/* ------------------------------------------------------------------ */
/* Adaptive layout — reference desktop geometry, professional mobile  */
/* ------------------------------------------------------------------ */

@media (max-width: 1023px) {
	/* All primary categories stay in the native horizontal slider. The
	   desktop-only More/tag popover must never consume adaptive width. */
	.dcd-feed-more {
		display: none;
	}

	.dcd-feed-layout {
		grid-template-columns: minmax(0, 1fr);
		row-gap: 40px;
	}

	.dcd-feed-list,
	.dcd-feed-layout > .dcd-rail {
		grid-column: 1;
	}

	.dcd-feed-grid,
	.dcd-feed-layout.has-no-rail .dcd-feed-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.dcd-feed-layout > .dcd-rail {
		width: 100%;
	}
}

@media (max-width: 767px) {
	.dcd-feed-tabs {
		gap: 0;
	}

	.dcd-feed-tabs-scroll {
		gap: 22px;
	}

	.dcd-feed-layout {
		margin-top: 16px;
	}

	.dcd-feed-save {
		display: inline-flex;
	}

	.dcd-feed-mode {
		font-size: 13px;
	}

	.dcd-feed-mode-current {
		margin-right: 8px;
	}

	.dcd-feed-mode-rule {
		margin: 0 8px;
	}
}

@media (max-width: 639px) {
	.dcd-feed-grid,
	.dcd-feed-layout.has-no-rail .dcd-feed-grid {
		grid-template-columns: minmax(0, 1fr);
	}

	.dcd-feed-card-title {
		text-align: left;
	}
}

@media (max-width: 359px) {
	.dcd-feed-mode {
		padding-right: 8px;
		padding-left: 8px;
	}

	.dcd-feed-mode-current {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.dcd-feed-image,
	.dcd-feed-more summary svg {
		transition: none;
	}
}
