/*!
 * LinkedIn Feed Pro — front-end styles
 *
 * Architecture notes
 * ------------------
 * 1. Everything is namespaced under `.lfp`. No bare element selectors exist in
 *    this file, so the plugin cannot restyle a theme's body, buttons or links.
 * 2. All visual decisions come from custom properties set per-feed by
 *    Style_Engine, so one stylesheet serves any number of differently-styled
 *    feeds on a page.
 * 3. Fallback values on every `var()` mean the feed still renders correctly if
 *    a property is missing — which is exactly what the "Auto" colour preset
 *    relies on to inherit the host theme.
 */

.lfp {
	--lfp-primary: #0a66c2;
	--lfp-accent: var(--lfp-primary);
	--lfp-card-bg: #fff;
	--lfp-bg: transparent;
	--lfp-text: inherit;
	--lfp-muted: #5f6b7a;
	--lfp-border: rgba(0, 0, 0, 0.1);
	--lfp-btn-text: #fff;
	--lfp-hover: var(--lfp-primary);

	--lfp-radius: 14px;
	--lfp-shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 6px 16px -6px rgba(16, 24, 40, 0.1);
	--lfp-pad: 20px;
	--lfp-gap: 24px;

	--lfp-font: inherit;
	--lfp-fs: 15px;
	--lfp-lh: 1.6;
	--lfp-title-fs: 16px;
	--lfp-meta-fs: 13px;

	--lfp-cols: 3;
	--lfp-cols-tablet: 2;
	--lfp-cols-mobile: 1;

	--lfp-ring: color-mix(in srgb, var(--lfp-primary) 45%, transparent);
	--lfp-surface-2: color-mix(in srgb, var(--lfp-text) 4%, transparent);

	box-sizing: border-box;
	color: var(--lfp-text);
	font-family: var(--lfp-font);
	font-size: var(--lfp-fs);
	line-height: var(--lfp-lh);
	background: var(--lfp-bg);
	container-type: inline-size;
}

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

/* ---------------------------------------------------------------- dark mode */

/* An explicit dark choice, and the automatic one, swap only surface tokens.
   Brand colours stay as configured so the site's identity survives. */
.lfp[data-theme="dark"] {
	--lfp-card-bg: var(--lfp-d-card-bg, #16181c);
	--lfp-bg: var(--lfp-d-bg, transparent);
	--lfp-text: var(--lfp-d-text, #e8eaed);
	--lfp-muted: var(--lfp-d-muted, #9aa4b2);
	--lfp-border: var(--lfp-d-border, #2a2e35);
}

@media (prefers-color-scheme: dark) {
	.lfp[data-theme="auto"] {
		--lfp-card-bg: var(--lfp-d-card-bg, #16181c);
		--lfp-bg: var(--lfp-d-bg, transparent);
		--lfp-text: var(--lfp-d-text, #e8eaed);
		--lfp-muted: var(--lfp-d-muted, #9aa4b2);
		--lfp-border: var(--lfp-d-border, #2a2e35);
	}
}

/* The "Auto" colour preset emits no colour properties at all: the feed then
   inherits whatever the theme already established. */
.lfp-feed--inherit-colors {
	--lfp-text: inherit;
	--lfp-muted: inherit;
	--lfp-card-bg: transparent;
	--lfp-border: currentColor;
	--lfp-primary: currentColor;
}

.lfp-feed--inherit-colors .lfp-card {
	border-color: color-mix(in srgb, currentColor 14%, transparent);
}

.lfp-feed--inherit-colors .lfp-card__meta,
.lfp-feed--inherit-colors .lfp-engagement__item {
	opacity: 0.7;
}

/* ------------------------------------------------------------------ layouts */

.lfp-feed__viewport {
	position: relative;
}

.lfp-feed__list {
	display: grid;
	gap: var(--lfp-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

.lfp-feed__item {
	margin: 0;
	padding: 0;
	min-width: 0;
}

.lfp-feed--list .lfp-feed__list {
	grid-template-columns: minmax(0, 1fr);
	max-width: 640px;
}

.lfp-feed--grid .lfp-feed__list {
	grid-template-columns: repeat(var(--lfp-cols), minmax(0, 1fr));
}

/* Masonry uses CSS columns, the only dependency-free way to get a true
   staggered flow. `break-inside` keeps cards whole. */
.lfp-feed--masonry .lfp-feed__list {
	display: block;
	column-count: var(--lfp-cols);
	column-gap: var(--lfp-gap);
}

.lfp-feed--masonry .lfp-feed__item {
	break-inside: avoid;
	margin-bottom: var(--lfp-gap);
	display: inline-block;
	width: 100%;
}

.lfp-feed--carousel .lfp-feed__list {
	grid-auto-flow: column;
	grid-auto-columns: calc((100% - (var(--lfp-cols) - 1) * var(--lfp-gap)) / var(--lfp-cols));
	grid-template-columns: none;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	scrollbar-width: thin;
	padding-bottom: 4px;
	overscroll-behavior-x: contain;
}

.lfp-feed--carousel .lfp-feed__item {
	scroll-snap-align: start;
}

.lfp-carousel__controls {
	display: flex;
	gap: 8px;
	justify-content: flex-end;
	margin-top: 14px;
}

.lfp-carousel__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	padding: 0;
	border: 1px solid var(--lfp-border);
	border-radius: 999px;
	background: var(--lfp-card-bg);
	color: inherit;
	cursor: pointer;
	transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.lfp-carousel__btn:hover:not([disabled]) {
	border-color: var(--lfp-primary);
	color: var(--lfp-primary);
}

.lfp-carousel__btn[disabled] {
	opacity: 0.4;
	cursor: default;
}

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

.lfp-header {
	display: flex;
	align-items: center;
	gap: 14px;
	flex-wrap: wrap;
	margin-bottom: var(--lfp-gap);
	padding-bottom: 18px;
	border-bottom: 1px solid var(--lfp-border);
}

.lfp-header__logo {
	width: 56px;
	height: 56px;
	flex: 0 0 auto;
	border-radius: 12px;
	object-fit: cover;
	background: var(--lfp-surface-2);
}

.lfp-header__body {
	flex: 1 1 200px;
	min-width: 0;
}

.lfp-header__name {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0;
	font-size: calc(var(--lfp-title-fs) + 2px);
	font-weight: 600;
	line-height: 1.25;
}

.lfp-header__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 10px;
	margin: 4px 0 0;
	color: var(--lfp-muted);
	font-size: var(--lfp-meta-fs);
}

.lfp-header__cta {
	flex: 0 0 auto;
}

/* Accent is the secondary brand colour. It defaults to the primary in every
   built-in preset, so these rules change nothing until someone sets it — at
   which point the verified badge, the Follow button and link-card hover all
   pick it up together. */
.lfp-verified {
	display: inline-flex;
	color: var(--lfp-accent, var(--lfp-primary));
	vertical-align: middle;
}

.lfp-header__cta.lfp-button--primary {
	background: var(--lfp-accent, var(--lfp-primary));
}

.lfp-header__cta.lfp-button--primary:hover {
	background: var(--lfp-hover, var(--lfp-accent));
}

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

.lfp-card {
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow: hidden;
	border: 1px solid var(--lfp-border);
	border-radius: var(--lfp-radius);
	background: var(--lfp-card-bg);
	box-shadow: var(--lfp-shadow);
	transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.lfp-card > * + * {
	margin-top: 0;
}

.lfp-card__head {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: var(--lfp-pad) var(--lfp-pad) 0;
}

.lfp-card__avatar {
	width: 44px;
	height: 44px;
	flex: 0 0 auto;
	border-radius: 50%;
	object-fit: cover;
	background: var(--lfp-surface-2);
}

.lfp-card__identity {
	min-width: 0;
}

.lfp-card__author {
	display: flex;
	align-items: center;
	gap: 5px;
	margin: 0;
	font-size: var(--lfp-title-fs);
	font-weight: 600;
	line-height: 1.3;
}

.lfp-card__author a {
	color: inherit;
	text-decoration: none;
}

.lfp-card__author a:hover {
	color: var(--lfp-primary);
	text-decoration: underline;
}

.lfp-card__meta {
	display: flex;
	align-items: center;
	gap: 5px;
	margin: 2px 0 0;
	color: var(--lfp-muted);
	font-size: var(--lfp-meta-fs);
}

.lfp-card__body {
	padding: calc(var(--lfp-pad) * 0.7) var(--lfp-pad) 0;
}

.lfp-post__text {
	margin: 0;
	overflow-wrap: anywhere;
	white-space: normal;
}

.lfp-post__link {
	color: var(--lfp-primary);
	text-decoration: none;
}

.lfp-post__link:hover {
	text-decoration: underline;
}

.lfp-post__toggle {
	margin-top: 6px;
	padding: 2px 0;
	border: 0;
	background: none;
	color: var(--lfp-primary);
	font: inherit;
	font-size: var(--lfp-meta-fs);
	font-weight: 600;
	cursor: pointer;
	border-radius: 4px;
}

.lfp-post__toggle:hover {
	text-decoration: underline;
}

.lfp-post__text[data-expanded="true"] .lfp-post__ellipsis {
	display: none;
}

/* -------------------------------------------------------------------- media */

.lfp-media {
	display: grid;
	gap: 2px;
	margin-top: calc(var(--lfp-pad) * 0.7);
}

.lfp-media--2,
.lfp-media--3,
.lfp-media--4 {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.lfp-media--3 .lfp-media__item:first-child {
	grid-column: 1 / -1;
}

.lfp-media__item {
	position: relative;
	margin: 0;
	overflow: hidden;
	background: var(--lfp-surface-2);
}

.lfp-media--1 .lfp-media__item {
	aspect-ratio: var(--lfp-ratio, 16 / 9);
}

.lfp-media--2 .lfp-media__item,
.lfp-media--3 .lfp-media__item,
.lfp-media--4 .lfp-media__item {
	aspect-ratio: 1 / 1;
}

.lfp-media--3 .lfp-media__item:first-child {
	aspect-ratio: 2 / 1;
}

.lfp-media__link {
	display: block;
	width: 100%;
	height: 100%;
}

.lfp-media__img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: 100%;
	object-fit: cover;
	transition: transform 0.4s ease;
}

.lfp-media__badge {
	position: absolute;
	pointer-events: none;
}

.lfp-media__badge--play {
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: rgba(255, 255, 255, 0.92);
	filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.45));
}

.lfp-media__badge--doc {
	left: 10px;
	bottom: 10px;
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 4px 9px;
	border-radius: 999px;
	background: rgba(16, 24, 40, 0.76);
	color: #fff;
	font-size: 12px;
	font-weight: 500;
	backdrop-filter: blur(4px);
}

.lfp-media__more {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(16, 24, 40, 0.55);
	color: #fff;
	font-size: 22px;
	font-weight: 600;
	pointer-events: none;
}

.lfp-media__caption {
	padding: 8px var(--lfp-pad) 0;
	color: var(--lfp-muted);
	font-size: var(--lfp-meta-fs);
}

/* ---------------------------------------------------------------- link card */

.lfp-linkcard {
	display: flex;
	align-items: stretch;
	gap: 12px;
	margin: calc(var(--lfp-pad) * 0.7) var(--lfp-pad) 0;
	border: 1px solid var(--lfp-border);
	border-radius: calc(var(--lfp-radius) * 0.55);
	overflow: hidden;
	color: inherit;
	text-decoration: none;
	transition: border-color 0.18s ease, background-color 0.18s ease;
}

.lfp-linkcard:hover {
	border-color: var(--lfp-accent, var(--lfp-primary));
	background: var(--lfp-surface-2);
}

.lfp-linkcard__thumb {
	width: 84px;
	height: 84px;
	flex: 0 0 auto;
	object-fit: cover;
	background: var(--lfp-surface-2);
}

.lfp-linkcard__thumb--fallback {
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--lfp-muted);
}

.lfp-linkcard__body {
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 3px;
	padding: 10px 12px 10px 0;
	min-width: 0;
}

.lfp-linkcard__title {
	font-weight: 600;
	font-size: var(--lfp-title-fs);
	line-height: 1.35;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	line-clamp: 2;
	overflow: hidden;
}

.lfp-linkcard__domain {
	color: var(--lfp-muted);
	font-size: var(--lfp-meta-fs);
}

/* --------------------------------------------------------------- card foot */

.lfp-card__foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	flex-wrap: wrap;
	margin-top: auto;
	padding: calc(var(--lfp-pad) * 0.75) var(--lfp-pad) var(--lfp-pad);
}

.lfp-engagement {
	display: flex;
	align-items: center;
	gap: 16px;
	margin: 0;
	padding: 0;
	list-style: none;
	color: var(--lfp-muted);
	font-size: var(--lfp-meta-fs);
}

.lfp-engagement__item {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	margin: 0;
}

/* ------------------------------------------------------------------ buttons */

.lfp-button {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 8px 14px;
	border: 1px solid transparent;
	border-radius: 999px;
	font-family: inherit;
	font-size: var(--lfp-meta-fs);
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.lfp-button--primary {
	background: var(--lfp-primary);
	color: var(--lfp-btn-text);
}

.lfp-button--primary:hover {
	background: var(--lfp-hover);
	color: var(--lfp-btn-text);
}

.lfp-button--ghost {
	border-color: var(--lfp-border);
	background: transparent;
	color: var(--lfp-primary);
}

.lfp-button--ghost:hover {
	border-color: var(--lfp-primary);
	background: var(--lfp-surface-2);
}

/* -------------------------------------------------------------- card styles */

.lfp-feed--card-minimal .lfp-card {
	border-color: transparent;
	box-shadow: none;
	background: transparent;
}

.lfp-feed--card-minimal .lfp-feed__item + .lfp-feed__item .lfp-card {
	border-top: 1px solid var(--lfp-border);
	border-radius: 0;
}

.lfp-feed--card-flat .lfp-card {
	box-shadow: none;
}

.lfp-feed--card-border .lfp-card {
	box-shadow: none;
	border-width: 1.5px;
}

.lfp-feed--card-elevated .lfp-card {
	border-color: transparent;
}

.lfp-feed--card-glass .lfp-card {
	background: color-mix(in srgb, var(--lfp-card-bg) 62%, transparent);
	border-color: color-mix(in srgb, #fff 45%, transparent);
	backdrop-filter: blur(14px) saturate(140%);
	-webkit-backdrop-filter: blur(14px) saturate(140%);
}

.lfp[data-theme="dark"].lfp-feed--card-glass .lfp-card {
	border-color: color-mix(in srgb, #fff 12%, transparent);
}

/* ------------------------------------------------------------------- states */

.lfp-state {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	padding: 44px 24px;
	border: 1px dashed var(--lfp-border);
	border-radius: var(--lfp-radius);
	text-align: center;
}

.lfp-state__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	margin-bottom: 4px;
	border-radius: 50%;
	background: var(--lfp-surface-2);
	color: var(--lfp-muted);
}

.lfp-state__title {
	margin: 0;
	font-size: var(--lfp-title-fs);
	font-weight: 600;
}

.lfp-state__text {
	margin: 0;
	max-width: 44ch;
	color: var(--lfp-muted);
	font-size: var(--lfp-meta-fs);
}

.lfp-state .lfp-button {
	margin-top: 10px;
}

.lfp-state__debug {
	margin: 12px 0 0;
	padding: 10px 12px;
	max-width: 60ch;
	border-radius: 8px;
	background: var(--lfp-surface-2);
	color: var(--lfp-muted);
	font-size: 12px;
	text-align: left;
	overflow-wrap: anywhere;
}

.lfp-demo-note {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	margin: 16px 0 0;
	color: var(--lfp-muted);
	font-size: 12px;
}

/* ----------------------------------------------------------------- skeleton */

.lfp-skeleton .lfp-card {
	gap: 0;
}

.lfp-sk {
	display: block;
	border-radius: 6px;
	background: linear-gradient(
		90deg,
		var(--lfp-surface-2) 25%,
		color-mix(in srgb, var(--lfp-text) 9%, transparent) 37%,
		var(--lfp-surface-2) 63%
	);
	background-size: 400% 100%;
	animation: lfp-shimmer 1.4s ease-in-out infinite;
}

.lfp-sk--avatar {
	width: 44px;
	height: 44px;
	flex: 0 0 auto;
	border-radius: 50%;
}

.lfp-sk--line {
	height: 11px;
	margin-bottom: 9px;
}

.lfp-sk--sm {
	height: 9px;
}

.lfp-sk--media {
	height: 0;
	padding-top: 56.25%;
	margin-top: 6px;
	border-radius: 0;
}

.lfp-sk--w100 { width: 100%; }
.lfp-sk--w90 { width: 90%; }
.lfp-sk--w65 { width: 65%; }
.lfp-sk--w40 { width: 40%; }
.lfp-sk--w35 { width: 35%; }
.lfp-sk--w28 { width: 28%; }

@keyframes lfp-shimmer {
	0% { background-position: 100% 50%; }
	100% { background-position: 0 50%; }
}

/* -------------------------------------------------------------------- embed */

.lfp-card--embed {
	border: 0;
	background: transparent;
	box-shadow: none;
	overflow: visible;
}

.lfp-embed {
	position: relative;
	width: 100%;
	aspect-ratio: 5 / 7;
	min-height: 420px;
	border-radius: var(--lfp-radius);
	overflow: hidden;
	background: var(--lfp-surface-2);
}

.lfp-embed__frame {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

/* -------------------------------------------------- editor-only notices */

/* Rendered only for users who can manage feeds — see Shortcode::notice(). */
.lfp-shortcode-notice {
	margin: 1em 0;
	padding: 12px 16px;
	border: 1px solid rgba(16, 24, 40, 0.12);
	border-left: 3px solid #0a66c2;
	border-radius: 8px;
	background: rgba(10, 102, 194, 0.04);
	color: inherit;
	font-size: 14px;
	line-height: 1.5;
}

/* ----------------------------------------------------------- accessibility */

.lfp-sr-only {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

.lfp :focus-visible {
	outline: 2px solid var(--lfp-primary);
	outline-offset: 2px;
	border-radius: 4px;
}

/* ---------------------------------------------------------------- animation */

.lfp-card:hover {
	transform: translateY(-2px);
	box-shadow: var(--lfp-shadow), 0 10px 30px -14px rgba(16, 24, 40, 0.3);
}

.lfp-media__link:hover .lfp-media__img {
	transform: scale(1.03);
}

.lfp-feed--no-motion .lfp-card,
.lfp-feed--no-motion .lfp-media__img,
.lfp-feed--no-motion .lfp-button,
.lfp-feed--no-motion .lfp-sk {
	transition: none;
	animation: none;
}

.lfp-feed--no-motion .lfp-card:hover {
	transform: none;
}

.lfp-feed--no-motion .lfp-media__link:hover .lfp-media__img {
	transform: none;
}

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

	.lfp-card:hover,
	.lfp-media__link:hover .lfp-media__img {
		transform: none;
	}
}

/* --------------------------------------------------------------- responsive
 *
 * Container queries first, so a feed placed in a narrow sidebar collapses on
 * its own width rather than the viewport's. Viewport media queries follow as a
 * fallback for browsers without container query support, and both are written
 * so the narrower rule always wins.
 */

@container (max-width: 1024px) {
	.lfp-feed--grid .lfp-feed__list,
	.lfp-feed--carousel .lfp-feed__list {
		--lfp-cols: var(--lfp-cols-tablet);
	}

	.lfp-feed--masonry .lfp-feed__list {
		column-count: var(--lfp-cols-tablet);
	}
}

@container (max-width: 640px) {
	.lfp-feed--grid .lfp-feed__list,
	.lfp-feed--carousel .lfp-feed__list {
		--lfp-cols: var(--lfp-cols-mobile);
	}

	.lfp-feed--masonry .lfp-feed__list {
		column-count: var(--lfp-cols-mobile);
	}
}

@media (max-width: 1024px) {
	.lfp-feed--grid .lfp-feed__list,
	.lfp-feed--carousel .lfp-feed__list {
		--lfp-cols: var(--lfp-cols-tablet);
	}

	.lfp-feed--masonry .lfp-feed__list {
		column-count: var(--lfp-cols-tablet);
	}
}

@media (max-width: 640px) {
	.lfp {
		--lfp-gap: min(var(--lfp-gap), 18px);
		--lfp-pad: min(var(--lfp-pad), 18px);
	}

	.lfp-feed--grid .lfp-feed__list,
	.lfp-feed--carousel .lfp-feed__list {
		--lfp-cols: var(--lfp-cols-mobile);
	}

	.lfp-feed--masonry .lfp-feed__list {
		column-count: var(--lfp-cols-mobile);
	}

	/* On a phone the header stops being a row and becomes a stacked block:
	   a shrunken three-column header is unreadable at 320px. */
	.lfp-header {
		align-items: flex-start;
		gap: 12px;
	}

	.lfp-header__logo {
		width: 44px;
		height: 44px;
	}

	.lfp-header__cta {
		width: 100%;
		justify-content: center;
	}

	.lfp-card__foot {
		align-items: flex-start;
	}

	.lfp-state {
		padding: 32px 18px;
	}
}

@media (max-width: 380px) {
	.lfp-engagement {
		gap: 12px;
	}

	.lfp-card__cta {
		width: 100%;
		justify-content: center;
	}
}
