/* ==========================================================================
   article.view.css — Article detail page (flat, clean, cool)
   Loaded by frontend/views/default/mall/article.view.html
   Scoped under .av-wrap. v1 — cool blue accent, content-first typography.
   Sibling of article.index.css — same token language.
   ========================================================================== */

:root {
	/* Neutral surfaces (cool-leaning) */
	--av-bg:            #f4f6fa;
	--av-surface:       #ffffff;
	--av-line:          #e6e9ef;
	--av-line-strong:   #d3d8e2;

	/* Text */
	--av-text-1:        #1a2233;
	--av-text-2:        #4a5366;
	--av-text-3:        #8a93a6;

	/* Cool accent — matches article.index.css */
	--av-accent:        #28A271;
	--av-accent-deep:   #28A271;
	--av-accent-soft:   #ecf8ed;

	/* Type scale */
	--av-fs-xs:         12px;
	--av-fs-sm:         13px;
	--av-fs-base:       14px;
	--av-fs-md:         15px;
	--av-fs-lg:         16px;
	--av-fs-xl:         18px;
	--av-fs-2xl:        22px;
	--av-fs-3xl:        28px;

	/* Rhythm */
	--av-r-1:           4px;
	--av-r-2:           8px;
	--av-r-3:           12px;
	--av-r-4:           16px;
	--av-r-5:           20px;
	--av-r-6:           24px;
	--av-r-7:           32px;
	--av-r-8:           48px;

	/* Radius */
	--av-radius-sm:     4px;
	--av-radius:        8px;
	--av-radius-lg:     12px;

	--av-ease:          cubic-bezier(0.2, 0, 0, 1);
}

/* --------------------------------------------------------------------------
   Local reset
   -------------------------------------------------------------------------- */
.av-wrap,
.av-wrap *,
.av-wrap *::before,
.av-wrap *::after { box-sizing: border-box; }

.av-wrap {
	font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
	font-size: var(--av-fs-base);
	line-height: 1.55;
	color: var(--av-text-1);
	background: var(--av-bg);
	padding: var(--av-r-6) 0;
	border-radius: var(--av-radius);
}

.av-wrap a { color: inherit; text-decoration: none; transition: color .15s var(--av-ease); }
.av-wrap a:hover { color: var(--av-accent); }
.av-wrap img,
.av-wrap video { display: block; max-width: 100%; }
.av-wrap button { font: inherit; color: inherit; cursor: pointer; }
.av-wrap ul,
.av-wrap ol { list-style: none; margin: 0; padding: 0; }

/* --------------------------------------------------------------------------
   Two-column outer layout — sidebar + main
   Sidebar styles are imported conceptually from article.index.css (.ai-*).
   We redeclare the minimum needed for the view page to keep this file
   self-contained and not depend on the index CSS being loaded first.
   -------------------------------------------------------------------------- */

/* --------------------------------------------------------------------------
   Sidebar — category card (mirrors .ai-side)
   -------------------------------------------------------------------------- */
.av-side {
	background: var(--av-surface);
	border: 1px solid var(--av-line);
	border-radius: var(--av-radius);
	overflow: hidden;
	margin-bottom: var(--av-r-4);
}

.av-side-hd {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--av-r-2);
	padding: var(--av-r-3) var(--av-r-4);
	background: var(--av-accent-soft);
	border-bottom: 1px solid var(--av-line);
}

.av-side-title {
	display: flex;
	align-items: center;
	gap: var(--av-r-2);
	font-size: var(--av-fs-md);
	font-weight: 600;
	color: var(--av-text-1);
	letter-spacing: 0.2px;
}
.av-side-title::before {
	content: "";
	width: 3px;
	height: 14px;
	background: var(--av-accent);
	border-radius: 2px;
}
.av-side-hint { font-size: var(--av-fs-xs); color: var(--av-text-3); }

.av-cats { padding: var(--av-r-2) 0; }
.av-cat { border-bottom: 1px solid var(--av-line); }
.av-cat:last-child { border-bottom: 0; }

.av-cat-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--av-r-2);
	padding: 10px var(--av-r-4);
	font-size: var(--av-fs-md);
	color: var(--av-text-1);
	cursor: pointer;
	user-select: none;
	transition: background .12s var(--av-ease), color .12s var(--av-ease);
}
.av-cat-row a {
	flex: 1 1 auto;
	min-width: 0;
	color: var(--av-text-1);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.av-cat-row a:hover { color: var(--av-accent); }
.av-cat-row:hover { background: var(--av-bg); }
.av-cat-row:hover a { color: var(--av-accent); }
.av-cat-row.is-active { background: var(--av-accent-soft); color: var(--av-accent); }
.av-cat-row.is-active a { color: var(--av-accent); font-weight: 500; }
.av-cat-row.is-active .av-cat-caret { color: var(--av-accent); }

.av-cat-caret {
	flex: 0 0 auto;
	width: 0;
	height: 0;
	border-left: 4px solid transparent;
	border-right: 4px solid transparent;
	border-top: 5px solid currentColor;
	color: var(--av-text-3);
	transition: transform .2s var(--av-ease);
}
.av-cat-row.is-open .av-cat-caret { transform: rotate(180deg); }

.av-sub { display: none; padding: 4px 0 var(--av-r-2); background: var(--av-bg); }
.av-cat.is-open .av-sub { display: block; }

.av-sub li { display: block; }
.av-sub a {
	display: block;
	padding: 8px var(--av-r-4) 8px var(--av-r-6);
	font-size: var(--av-fs-sm);
	color: var(--av-text-2);
	border-left: 2px solid transparent;
	transition: color .12s var(--av-ease), background .12s var(--av-ease), border-color .12s var(--av-ease);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.av-sub a::before { content: "·"; margin-right: 6px; color: var(--av-text-3); }
.av-sub a:hover { color: var(--av-accent); background: var(--av-surface); }
.av-sub a.is-active {
	color: var(--av-accent);
	background: var(--av-surface);
	border-left-color: var(--av-accent);
	font-weight: 500;
}

/* --------------------------------------------------------------------------
   Main column — article (left) + related (right)
   Inside col-main we use a grid: article card + related card.
   -------------------------------------------------------------------------- */
.av-main {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 320px;
	gap: var(--av-r-4);
	align-items: start;
}

/* --------------------------------------------------------------------------
   Article card — content-first
   -------------------------------------------------------------------------- */
.av-article {
	background: var(--av-surface);
	border: 1px solid var(--av-line);
	border-radius: var(--av-radius);
	overflow: hidden;
}

.av-breadcrumb {
	display: flex;
	align-items: center;
	gap: var(--av-r-2);
	padding: var(--av-r-3) var(--av-r-5);
	font-size: var(--av-fs-sm);
	color: var(--av-text-3);
	background: var(--av-bg);
	border-bottom: 1px solid var(--av-line);
}

.av-breadcrumb a { color: var(--av-text-2); }
.av-breadcrumb a:hover { color: var(--av-accent); }
.av-breadcrumb .av-sep { color: var(--av-text-3); }
.av-breadcrumb .av-cur { color: var(--av-text-1); }
.av-breadcrumb .av-back {
	margin-left: auto;
	color: var(--av-text-2);
	display: inline-flex;
	align-items: center;
	gap: 4px;
}
.av-breadcrumb .av-back:hover { color: var(--av-accent); }
.av-breadcrumb .av-back svg { width: 14px; height: 14px; }

/* Article header */
.av-head {
	padding: var(--av-r-6) var(--av-r-5) var(--av-r-4);
	border-bottom: 1px solid var(--av-line);
}

.av-title {
	margin: 0;
	font-size: var(--av-fs-3xl);
	font-weight: 600;
	color: var(--av-text-1);
	line-height: 1.35;
	letter-spacing: -0.3px;
}

.av-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--av-r-4);
	margin-top: var(--av-r-3);
	font-size: var(--av-fs-sm);
	color: var(--av-text-3);
}

.av-meta-item {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.av-meta-item svg {
	width: 14px;
	height: 14px;
	color: var(--av-text-3);
}

.av-meta-tag {
	display: inline-flex;
	align-items: center;
	padding: 2px 8px;
	background: var(--av-accent-soft);
	color: var(--av-accent);
	border-radius: var(--av-radius-sm);
	font-size: var(--av-fs-xs);
	font-weight: 500;
}

/* Video block (optional) */
.av-video {
	padding: var(--av-r-4) var(--av-r-5) 0;
}
.av-video-frame {
	position: relative;
	width: 100%;
	max-width: 760px;
	margin: 0 auto;
	background: #000;
	border-radius: var(--av-radius);
	overflow: hidden;
	aspect-ratio: 16 / 9;
}
.av-video-frame video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Article body */
.av-body {
	padding: var(--av-r-6) var(--av-r-5);
	max-width: 760px;
	margin: 0 auto;
	font-size: var(--av-fs-md);
	line-height: 1.85;
	color: var(--av-text-2);
}

.av-body p { margin: 0 0 var(--av-r-4); }
.av-body p:last-child { margin-bottom: 0; }

.av-body img,
.av-body video {
	max-width: 100%;
	height: auto;
	border-radius: var(--av-radius);
	margin: var(--av-r-4) 0;
}

.av-body h2,
.av-body h3 {
	margin: var(--av-r-6) 0 var(--av-r-3);
	font-weight: 600;
	color: var(--av-text-1);
	line-height: 1.4;
}
.av-body h2 { font-size: var(--av-fs-xl); }
.av-body h3 { font-size: var(--av-fs-lg); }

.av-body a { color: var(--av-accent); }
.av-body a:hover { color: var(--av-accent-deep); text-decoration: underline; text-underline-offset: 3px; }

.av-body blockquote {
	margin: var(--av-r-5) 0;
	padding: var(--av-r-3) var(--av-r-4);
	background: var(--av-bg);
	border-left: 3px solid var(--av-accent);
	color: var(--av-text-2);
	border-radius: 0 var(--av-radius-sm) var(--av-radius-sm) 0;
}

.av-body code {
	padding: 1px 6px;
	background: var(--av-bg);
	color: var(--av-accent);
	border-radius: var(--av-radius-sm);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: .92em;
}

.av-body pre {
	padding: var(--av-r-3) var(--av-r-4);
	background: var(--av-bg);
	border: 1px solid var(--av-line);
	border-radius: var(--av-radius);
	overflow-x: auto;
	font-size: var(--av-fs-sm);
}
.av-body pre code { padding: 0; background: transparent; color: var(--av-text-1); }

/* Prev / next nav (footer of article card) */
.av-pager {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0;
	border-top: 1px solid var(--av-line);
	background: var(--av-bg);
}

.av-pager-cell {
	position: relative;
	padding: var(--av-r-3) var(--av-r-5);
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: var(--av-fs-sm);
	color: var(--av-text-2);
	transition: background .2s var(--av-ease);
}
/* Top accent line — revealed on hover to imply direction.
   Prev cell: line grows from the left edge.
   Next cell: line grows from the right edge. */
.av-pager-cell::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 2px;
	background: var(--av-accent);
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform .22s var(--av-ease);
}
.av-pager-cell.is-next::before { transform-origin: right center; }

.av-pager-cell + .av-pager-cell { border-left: 1px solid var(--av-line); }

/* Interactive state: only when the cell has a real link */
.av-pager-cell:not(.is-empty) { cursor: pointer; }
.av-pager-cell:not(.is-empty):hover { background: var(--av-accent-soft); }
.av-pager-cell:not(.is-empty):hover::before { transform: scaleX(1); }

.av-pager-label {
	font-size: var(--av-fs-xs);
	color: var(--av-text-3);
	letter-spacing: 0.5px;
	transition: color .2s var(--av-ease);
}
.av-pager-cell:not(.is-empty):hover .av-pager-label { color: var(--av-accent); }

.av-pager-cell a {
	display: flex;
	align-items: center;
	gap: 6px;
	color: var(--av-text-1);
	font-size: var(--av-fs-sm);
	font-weight: 500;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	transition: color .2s var(--av-ease);
}
.av-pager-cell:not(.is-empty):hover a { color: var(--av-accent); }

.av-pager-cell.is-next a { justify-content: flex-end; text-align: right; }
.av-pager-cell.is-empty { cursor: default; }
.av-pager-cell.is-empty a { color: var(--av-text-3); pointer-events: none; }

/* Arrow — translates in the direction of navigation on hover.
   Prev (arrow on the left) slides further left.
   Next (arrow on the right) slides further right. */
.av-pager-cell .av-arrow {
	flex: 0 0 auto;
	width: 14px;
	height: 14px;
	color: var(--av-text-3);
	transition: transform .22s var(--av-ease), color .2s var(--av-ease);
}
.av-pager-cell:not(.is-empty):hover .av-arrow {
	color: var(--av-accent);
	transform: translateX(-4px);
}
.av-pager-cell.is-next:not(.is-empty):hover .av-arrow {
	transform: translateX(4px);
}

/* Subtle title nudge — same direction as the arrow.
   Adds a "lean" toward the target without affecting layout. */
.av-pager-cell a > span {
	transition: transform .22s var(--av-ease);
}
.av-pager-cell:not(.is-empty):hover a > span { transform: translateX(-2px); }
.av-pager-cell.is-next:not(.is-empty):hover a > span { transform: translateX(2px); }

/* --------------------------------------------------------------------------
   Related card (right column inside .av-main)
   -------------------------------------------------------------------------- */
.av-related {
	background: var(--av-surface);
	border: 1px solid var(--av-line);
	border-radius: var(--av-radius);
	overflow: hidden;
	position: sticky;
	top: var(--av-r-4);
}

.av-related-hd {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--av-r-2);
	padding: var(--av-r-3) var(--av-r-4);
	background: var(--av-accent-soft);
	border-bottom: 1px solid var(--av-line);
}

.av-related-title {
	display: flex;
	align-items: center;
	gap: var(--av-r-2);
	font-size: var(--av-fs-md);
	font-weight: 600;
	color: var(--av-text-1);
	letter-spacing: 0.2px;
}
.av-related-title::before {
	content: "";
	width: 3px;
	height: 14px;
	background: var(--av-accent);
	border-radius: 2px;
}

.av-related-more {
	font-size: var(--av-fs-xs);
	color: var(--av-text-3);
}
.av-related-more:hover { color: var(--av-accent); }

.av-related-list { padding: var(--av-r-2) 0; }

.av-related-item {
	border-bottom: 1px solid var(--av-line);
}
.av-related-item:last-child { border-bottom: 0; }

.av-related-link {
	display: flex;
	gap: var(--av-r-3);
	padding: 10px var(--av-r-4);
	transition: background .12s var(--av-ease);
}
.av-related-link:hover { background: var(--av-bg); }

.av-related-num {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	font-size: var(--av-fs-xs);
	font-weight: 600;
	color: var(--av-text-3);
	background: var(--av-bg);
	border-radius: var(--av-radius-sm);
	font-variant-numeric: tabular-nums;
	transition: color .12s var(--av-ease), background .12s var(--av-ease);
}
.av-related-item:nth-child(-n+3) .av-related-num {
	background: var(--av-accent-soft);
	color: var(--av-accent);
}
.av-related-link:hover .av-related-num { color: var(--av-accent); }

.av-related-body {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.av-related-text {
	font-size: var(--av-fs-sm);
	color: var(--av-text-1);
	line-height: 1.5;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	transition: color .12s var(--av-ease);
}
.av-related-link:hover .av-related-text { color: var(--av-accent); }

.av-related-date {
	font-size: var(--av-fs-xs);
	color: var(--av-text-3);
	font-variant-numeric: tabular-nums;
}

/* Empty related state */
.av-related-empty {
	padding: var(--av-r-5) var(--av-r-4);
	text-align: center;
	color: var(--av-text-3);
	font-size: var(--av-fs-sm);
}

/* --------------------------------------------------------------------------
   Responsive
   Use #page-article to match the specificity of main.css declarations.
   -------------------------------------------------------------------------- */
@media (max-width: 1180px) {
	#page-article.av-wrap .col-sub  { width: 200px; }
	#page-article.av-wrap .col-main { width: calc(100% - 212px); }
	.av-main { grid-template-columns: minmax(0, 1fr) 280px; }
}

@media (max-width: 960px) {
	#page-article.av-wrap .col-sub,
	#page-article.av-wrap .col-main { float: none; width: 100%; }
	#page-article.av-wrap .col-main { margin-top: var(--av-r-4); }
	.av-main { grid-template-columns: 1fr; }
	.av-related { position: static; }
}

@media (max-width: 640px) {
	.av-head,
	.av-body,
	.av-video,
	.av-breadcrumb { padding-left: var(--av-r-3); padding-right: var(--av-r-3); }
	.av-title { font-size: var(--av-fs-2xl); }
	.av-pager { grid-template-columns: 1fr; }
	.av-pager-cell + .av-pager-cell { border-left: 0; border-top: 1px solid var(--av-line); }
}

/* --------------------------------------------------------------------------
   A11y / motion
   -------------------------------------------------------------------------- */
.av-cat-row:focus-visible,
.av-related-link:focus-visible,
.av-breadcrumb a:focus-visible,
.av-pager-cell a:focus-visible {
	outline: 2px solid var(--av-accent);
	outline-offset: -2px;
	border-radius: var(--av-radius-sm);
}

@media (prefers-reduced-motion: reduce) {
	.av-wrap *,
	.av-wrap *::before,
	.av-wrap *::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}
