/**
 * SnapWeb Community sidebar module.
 *
 * Kept separate from search/archive styles so it can be split into its own
 * extension without carrying unrelated FluentCommunity integration code.
 */

body.snapweb-community-sidebar-enabled {
	--snapweb-community-sidebar-bg: var(--el-bg-color, var(--fcom-primary-bg, #fff));
	--snapweb-community-sidebar-soft-bg: var(--el-fill-color-light, var(--fcom-secondary-bg, #f7f8fa));
	--snapweb-community-sidebar-text: var(--el-text-color-primary, var(--fcom-primary-text, #111827));
	--snapweb-community-sidebar-muted: var(--el-text-color-secondary, var(--fcom-secondary-text, #6b7280));
	--snapweb-community-sidebar-border: var(--el-border-color-light, var(--fcom-primary-border, #dfe5ec));
	--snapweb-community-sidebar-radius: var(--fcom-border-radius, 8px);
}

body.snapweb-community-sidebar-enabled .snapweb-community-sidebar-sticky {
	position: sticky !important;
	top: calc(var(--fcom-header-height, 0px) + 16px) !important;
	align-self: flex-start !important;
	max-height: calc(100vh - var(--fcom-header-height, 0px) - 24px) !important;
	overflow: auto !important;
	scrollbar-gutter: stable;
}

body.snapweb-community-sidebar-enabled .snapweb-community-sidebar-sticky:empty {
	display: none !important;
}

body.snapweb-community-sidebar-wrapper .snapweb-fcom-article-page-wrap.snapweb-community-has-side-panel {
	--snapweb-fcom-article-lane: minmax(0, 1fr);
	display: grid !important;
	grid-template-columns: minmax(0, 1fr) minmax(240px, 320px) !important;
	gap: clamp(18px, 2vw, 28px) !important;
	align-items: start !important;
	width: min(1380px, calc(100% - 48px)) !important;
	margin-inline: auto !important;
}

body.snapweb-community-sidebar-wrapper .snapweb-fcom-article-page-wrap.snapweb-community-has-side-panel > .snapweb-fcom-article-page,
body.snapweb-community-sidebar-wrapper .snapweb-fcom-article-page-wrap.snapweb-community-has-side-panel > .snapweb-fcom-article-state {
	min-width: 0 !important;
	width: 100% !important;
}

body.snapweb-community-sidebar-wrapper .snapweb-community-side-panel {
	position: sticky;
	top: calc(var(--fcom-header-height, 0px) + 18px);
	display: grid;
	gap: 14px;
	width: 100%;
	max-height: calc(100vh - var(--fcom-header-height, 0px) - 28px);
	overflow: auto;
	color: var(--snapweb-community-sidebar-text);
}

body.snapweb-community-sidebar-wrapper .snapweb-community-side-panel__widget {
	padding: 16px;
	border: 1px solid var(--snapweb-community-sidebar-border);
	border-radius: var(--snapweb-community-sidebar-radius);
	background: var(--snapweb-community-sidebar-bg);
	box-shadow: none;
}

body.snapweb-community-sidebar-wrapper .snapweb-community-side-panel__widget h3 {
	margin: 0 0 12px !important;
	color: var(--snapweb-community-sidebar-text) !important;
	font-size: 14px !important;
	font-weight: 600 !important;
	line-height: 1.35 !important;
}

body.snapweb-community-sidebar-wrapper .snapweb-community-side-panel__links {
	display: grid;
	gap: 8px;
}

body.snapweb-community-sidebar-wrapper .snapweb-community-side-panel__link {
	display: flex;
	align-items: center;
	justify-content: space-between;
	min-height: 38px;
	padding: 8px 10px;
	border-radius: var(--snapweb-community-sidebar-radius);
	color: var(--snapweb-community-sidebar-text) !important;
	text-decoration: none !important;
	background: transparent;
	transition: background-color .16s ease, color .16s ease;
}

body.snapweb-community-sidebar-wrapper .snapweb-community-side-panel__link:hover,
body.snapweb-community-sidebar-wrapper .snapweb-community-side-panel__link:focus-visible {
	color: var(--snapweb-community-sidebar-text) !important;
	background: var(--snapweb-community-sidebar-soft-bg);
	outline: none;
}

body.snapweb-community-sidebar-wrapper .snapweb-community-side-panel__custom {
	color: var(--snapweb-community-sidebar-muted);
	font-size: 14px;
	line-height: 1.55;
}

body.snapweb-community-sidebar-wrapper .snapweb-community-side-panel__custom :where(p, ul, ol) {
	margin: 0 0 10px;
}

body.snapweb-community-sidebar-wrapper .snapweb-community-side-panel__custom :where(p, ul, ol):last-child {
	margin-bottom: 0;
}

body.snapweb-community-sidebar-wrapper .snapweb-community-side-panel__custom a {
	color: var(--el-color-primary, var(--fcom-accent-color, currentColor)) !important;
}

body.snapweb-community-sidebar-wrapper .snapweb-community-side-panel__widget--empty {
	color: var(--snapweb-community-sidebar-muted);
	font-size: 14px;
	line-height: 1.45;
}

@media (max-width: 1180px) {
	body.snapweb-community-sidebar-wrapper .snapweb-fcom-article-page-wrap.snapweb-community-has-side-panel {
		grid-template-columns: 1fr !important;
	}

	body.snapweb-community-sidebar-wrapper .snapweb-community-side-panel {
		position: static;
		max-height: none;
	}
}
