/**
 * Lenny Face — front-end styles (v2).
 *
 * Card design: rounded white card, NEW / HOT badge, bordered glyph box,
 * divider, footer with category tag + heart / share / green Copy actions.
 */

:root {
	--lf-green: #3d9a68;
	--lf-green-dark: #2f7f54;
	--lf-green-soft: #e7f4ec;
	--lf-ink: #5b6b66;
	--lf-ink-strong: #33413c;
	--lf-line: #ececec;
	--lf-line-soft: #f2f2f0;
	--lf-card-bg: #ffffff;
	--lf-page-bg: #f7f7f5;
	--lf-radius: 22px;
	--lf-radius-sm: 14px;
	--lf-badge-new-bg: #fbdce4;
	--lf-badge-new-ink: #e2456f;
	--lf-badge-hot-bg: #fde8cf;
	--lf-badge-hot-ink: #e07b1f;
}

.lenny-face-wrapper {
	margin: 1.25rem 0;
	font-family: inherit;
}

/* The [hidden] attribute must always win, even against the display rules
 * below and against theme CSS — filtering and the two-tier menu depend on it. */
.lenny-face-card[hidden],
.lenny-face-filters[hidden],
.lenny-face-empty[hidden],
.lenny-face-hint[hidden],
.lenny-face-viewall[hidden],
.lenny-face-wrapper [hidden] {
	display: none !important;
}

.lf-sprite {
	position: absolute;
	width: 0;
	height: 0;
	overflow: hidden;
}

/* ------------------------------------------------------------- toolbar */

.lenny-face-toolbar {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	margin-bottom: 1rem;
}

.lenny-face-search {
	position: relative;
	max-width: 420px;
}

.lenny-face-search-icon {
	position: absolute;
	left: 0.85rem;
	top: 50%;
	width: 18px;
	height: 18px;
	transform: translateY(-50%);
	color: var(--lf-ink);
	pointer-events: none;
}

.lenny-face-search-input {
	width: 100%;
	padding: 0.65rem 1rem 0.65rem 2.5rem;
	border: 1px solid var(--lf-line);
	border-radius: 999px;
	background: var(--lf-card-bg);
	font-size: 0.95rem;
	color: var(--lf-ink-strong);
}

.lenny-face-search-input:focus {
	outline: 2px solid var(--lf-green);
	outline-offset: 1px;
	border-color: transparent;
}

.lenny-face-filters {
	display: flex;
	flex-wrap: nowrap;
	gap: 0.5rem;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	padding-bottom: 4px;
	scroll-snap-type: x proximity;
}

.lenny-face-filters::-webkit-scrollbar {
	display: none;
}

.lenny-face-filters .lenny-face-chip {
	flex: 0 0 auto;
	scroll-snap-align: start;
}

.lenny-face-subbar {
	margin-top: 0.25rem;
	padding-left: 0.25rem;
	border-left: 3px solid var(--lf-green-soft);
}

.lenny-face-viewall {
	margin: 1rem 0 0;
	font-size: 0.95rem;
}

.lenny-face-viewall-link {
	color: var(--lf-green-dark);
	font-weight: 700;
	text-decoration: none;
}

.lenny-face-viewall-link:hover {
	text-decoration: underline;
}

.lenny-face-chip {
	appearance: none;
	display: inline-block;
	padding: 0.42rem 0.95rem;
	border: 1px solid var(--lf-line, #ececec);
	border-radius: 999px;
	background: var(--lf-card-bg, #fff);
	color: var(--lf-ink, #5b6b66);
	font-size: 0.88rem;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	text-decoration: none !important;
	border-bottom-width: 1px;
	box-shadow: none;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.lenny-face-chip:hover,
.lenny-face-chip:focus-visible {
	border-color: var(--lf-green, #3d9a68);
	color: var(--lf-green-dark, #2f7f54);
	background: var(--lf-green-soft, #e7f4ec);
	text-decoration: none !important;
}

.lenny-face-chip.is-active,
.lenny-face-chip.is-active:hover,
.lenny-face-chip.is-active:focus-visible {
	background: var(--lf-green, #3d9a68);
	border-color: var(--lf-green, #3d9a68);
	color: #fff;
}

/* ---------------------------------------------------------------- grid */

.lenny-face-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 1rem;
}

.lenny-face-wrapper[data-columns="2"] .lenny-face-grid { grid-template-columns: repeat(2, 1fr); }
.lenny-face-wrapper[data-columns="3"] .lenny-face-grid { grid-template-columns: repeat(3, 1fr); }
.lenny-face-wrapper[data-columns="4"] .lenny-face-grid { grid-template-columns: repeat(4, 1fr); }
.lenny-face-wrapper[data-columns="5"] .lenny-face-grid { grid-template-columns: repeat(5, 1fr); }

@media (max-width: 720px) {
	.lenny-face-wrapper[data-columns="3"] .lenny-face-grid,
	.lenny-face-wrapper[data-columns="4"] .lenny-face-grid,
	.lenny-face-wrapper[data-columns="5"] .lenny-face-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

/* --- Mobile: two columns with a compact card ------------------------- */

@media (max-width: 480px) {
	.lenny-face-grid,
	.lenny-face-wrapper[data-columns] .lenny-face-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		grid-auto-flow: row dense;
		gap: 0.5rem;
	}

	/* The handful of extra-long faces take the full row rather than being
	 * shrunk into illegibility. Dense packing keeps the grid gap-free. */
	.lenny-face-card.lf-xl,
	.lenny-face-card.lf-multiline {
		grid-column: span 2;
	}

	.lenny-face-glyph.lf-pre {
		font-size: 0.8rem;
		line-height: 1.45;
	}

	.lenny-face-card {
		padding: 0.5rem;
		gap: 0.4rem;
		border-radius: 15px;
	}

	.lenny-face-glyphbox {
		min-height: 66px;
		padding: 0.55rem 0.3rem;
		border-radius: 10px;
	}

	.lenny-face-card .lenny-face-glyph { font-size: 1.2rem; }
	.lenny-face-card.lf-m .lenny-face-glyph { font-size: 0.95rem; }
	.lenny-face-card.lf-l .lenny-face-glyph { font-size: 0.75rem; }
	.lenny-face-card.lf-xl .lenny-face-glyph { font-size: 1.15rem; }

	.lenny-face-meta {
		flex-direction: column;
		align-items: stretch;
		gap: 0.35rem;
		padding-top: 0.4rem;
	}

	.lenny-face-tag {
		flex: 0 0 auto;
		font-size: 0.75rem;
		text-align: center;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.lenny-face-actions {
		margin-left: 0;
		gap: 0.3rem;
		justify-content: space-between;
	}

	.lenny-face-fav,
	.lenny-face-share {
		width: 34px;
		height: 34px;
		border-radius: 10px;
	}

	/* Copy goes icon-only and stretches — the label would not fit, and the
	 * whole card is tap-to-copy anyway. */
	.lenny-face-copy {
		flex: 1 1 auto;
		height: 34px;
		padding: 0;
		justify-content: center;
		border-radius: 10px;
		overflow: hidden;
	}

	.lenny-face-copy .lenny-face-copy-label {
		display: none;
	}

	/* On success the icon gives way to the confirmation text, so the
	 * feedback survives the icon-only treatment. */
	.lenny-face-copy.is-copied .lenny-face-copy-label {
		display: inline;
		font-size: 0.72rem;
		white-space: nowrap;
	}

	.lenny-face-copy.is-copied .lf-icon {
		display: none;
	}

	.lenny-face-badge {
		top: -0.45rem;
		left: 0.6rem;
		padding: 0.22rem 0.55rem;
		font-size: 0.62rem;
	}

	/* Page chrome: tighter edges and vertical rhythm so the grid starts
	 * higher and every card gains width. */
	.lf-container {
		padding: 1.1rem 0.6rem 2rem;
	}

	.lenny-face-wrapper {
		margin: 0.75rem 0;
	}

	.lf-breadcrumbs {
		margin-bottom: 0.6rem;
	}

	.lf-h1 {
		margin-bottom: 0.35rem;
	}

	.lf-intro {
		margin-bottom: 0.9rem;
		font-size: 0.92rem;
	}

	.lenny-face-toolbar {
		gap: 0.5rem;
		margin-bottom: 0.75rem;
	}

	.lf-linkchips {
		margin-bottom: 0.45rem;
	}

	.lf-linkchips.lf-subrow {
		margin-bottom: 0.85rem;
	}

	.lenny-face-subbar {
		margin-top: 0.15rem;
	}

	.lenny-face-more {
		margin-top: 1rem;
	}

	.lf-related {
		margin-top: 1.6rem;
	}

	.lf-related h2 {
		margin-bottom: 0.6rem;
	}
}

/* Very small phones: one column — two would be unreadable. */
@media (max-width: 339px) {
	.lenny-face-grid,
	.lenny-face-wrapper[data-columns] .lenny-face-grid {
		grid-template-columns: 1fr;
	}

	.lenny-face-card.lf-xl {
		grid-column: auto;
	}
}

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

.lenny-face-card {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	padding: 1rem;
	background: var(--lf-card-bg);
	border: 1px solid var(--lf-line-soft);
	border-radius: var(--lf-radius);
	box-shadow: 0 1px 2px rgba(30, 45, 38, 0.04), 0 6px 18px rgba(30, 45, 38, 0.05);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.lenny-face-card:hover {
	transform: translateY(-2px);
	box-shadow: 0 2px 4px rgba(30, 45, 38, 0.05), 0 10px 26px rgba(30, 45, 38, 0.09);
}

.lenny-face-card.is-copied {
	border-color: var(--lf-green);
}

/* Badges — NEW (pink) / HOT (orange), overlapping the top-left corner. */

.lenny-face-badge {
	position: absolute;
	top: -0.55rem;
	left: 1rem;
	z-index: 1;
	padding: 0.28rem 0.75rem;
	border-radius: 999px;
	font-size: 0.7rem;
	font-weight: 800;
	letter-spacing: 0.06em;
	line-height: 1;
	box-shadow: 0 2px 6px rgba(30, 45, 38, 0.10);
}

.lenny-face-badge.is-new {
	background: var(--lf-badge-new-bg);
	color: var(--lf-badge-new-ink);
}

.lenny-face-badge.is-hot {
	background: var(--lf-badge-hot-bg);
	color: var(--lf-badge-hot-ink);
}

/* Glyph box — the bordered inner panel holding the face. */

.lenny-face-glyphbox {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 110px;
	padding: 1.25rem 0.75rem;
	border: 1px solid var(--lf-line);
	border-radius: 16px;
	background: #fdfdfc;
	overflow: hidden;
	cursor: pointer;
}

.lenny-face-glyph {
	font-size: 2.1rem;
	line-height: 1.3;
	color: var(--lf-ink-strong);
	text-align: center;
	word-break: keep-all;
	white-space: nowrap;
	max-width: 100%;
	user-select: all;
	-webkit-user-select: all;
}

/* Length-aware sizing: the longer the face renders, the smaller it is set,
 * so nothing overflows its card. Buckets are assigned server-side from each
 * face's visual width (combining marks ignored, CJK counted double). */
.lenny-face-card.lf-m .lenny-face-glyph { font-size: 1.7rem; }
.lenny-face-card.lf-l .lenny-face-glyph { font-size: 1.3rem; }
.lenny-face-card.lf-xl .lenny-face-glyph { font-size: 1.05rem; }

/* Multi-line cards: dividers, borders and bio templates. These span more
 * columns and render their content as a monospace block so alignment and
 * newlines survive. */
.lenny-face-card.lf-multiline {
	grid-column: span 2;
}

.lenny-face-glyphbox.lf-block {
	min-height: 96px;
	padding: 1rem 1.1rem;
	align-items: stretch;
	justify-content: flex-start;
}

.lenny-face-glyph.lf-pre {
	margin: 0;
	font-family: "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", monospace;
	font-size: 0.94rem;
	line-height: 1.5;
	white-space: pre;
	text-align: left;
	overflow-x: auto;
	max-width: 100%;
	color: var(--lf-ink-strong);
	-webkit-user-select: all;
	user-select: all;
}

/* Footer row — divider, tag, actions. */

.lenny-face-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	padding-top: 0.75rem;
	border-top: 1px solid var(--lf-line-soft);
}

.lenny-face-tag {
	flex: 1 1 auto;
	min-width: 0;
	font-size: 0.92rem;
	font-weight: 700;
	color: var(--lf-ink);
}

.lenny-face-actions {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	flex-shrink: 0;
	margin-left: auto;
}

.lf-icon {
	width: 19px;
	height: 19px;
	display: block;
}

/* Heart + share: outlined square buttons with green icons. */

.lenny-face-fav,
.lenny-face-share {
	appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 1px solid var(--lf-line);
	border-radius: var(--lf-radius-sm);
	background: var(--lf-card-bg);
	color: var(--lf-green);
	cursor: pointer;
	transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.lenny-face-fav:hover,
.lenny-face-share:hover,
.lenny-face-fav:focus-visible,
.lenny-face-share:focus-visible {
	border-color: var(--lf-green);
	background: var(--lf-green-soft);
}

.lenny-face-fav:active,
.lenny-face-share:active,
.lenny-face-copy:active {
	transform: scale(0.96);
}

.lenny-face-fav .lf-icon-heart-fill { display: none; }
.lenny-face-fav.is-active .lf-icon-heart { display: none; }
.lenny-face-fav.is-active .lf-icon-heart-fill { display: block; }
.lenny-face-fav.is-active { color: #e2456f; border-color: #f4c3d1; background: #fdf1f5; }

/* Copy — the green pill. */

.lenny-face-copy {
	appearance: none;
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	height: 40px;
	padding: 0 0.95rem;
	border: 1px solid var(--lf-green);
	border-radius: var(--lf-radius-sm);
	background: var(--lf-green);
	color: #fff;
	font-size: 0.95rem;
	font-weight: 700;
	cursor: pointer;
	transition: background 0.15s ease, transform 0.1s ease;
}

.lenny-face-copy:hover,
.lenny-face-copy:focus-visible {
	background: var(--lf-green-dark);
	border-color: var(--lf-green-dark);
	color: #fff;
}

.lenny-face-copy.is-copied,
.lenny-face-share.is-copied {
	background: var(--lf-green-dark);
	border-color: var(--lf-green-dark);
	color: #fff;
}

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

.lenny-face-status {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

.lenny-face-empty,
.lenny-face-hint {
	margin: 1rem 0 0;
	color: var(--lf-ink);
	font-size: 0.92rem;
}

.lenny-face-more {
	text-align: center;
	margin-top: 1.4rem;
}

.lenny-face-loadmore {
	appearance: none;
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.7rem 1.8rem;
	border: 1.5px solid var(--lf-green, #3d9a68);
	border-radius: 999px;
	background: var(--lf-card-bg, #fff);
	color: var(--lf-green-dark, #2f7f54);
	font-size: 0.98rem;
	font-weight: 700;
	cursor: pointer;
	box-shadow: 0 1px 2px rgba(30, 45, 38, 0.05);
	transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.lenny-face-loadmore::after {
	content: "\2193";
	font-weight: 800;
}

.lenny-face-loadmore:hover,
.lenny-face-loadmore:focus-visible {
	background: var(--lf-green, #3d9a68);
	color: #fff;
}

.lenny-face-loadmore:active {
	transform: scale(0.97);
}

/* ------------------------------------------------- routed page chrome */

.lf-page {
	background: var(--lf-page-bg, #f7f7f5);
}

/* Routed pages have no post, so many themes fall back to a narrow
 * content-with-sidebar layout with nothing in the sidebar. Reclaim the
 * full width — scoped strictly to our own body class. */
body.lenny-face-page #primary,
body.lenny-face-page #content,
body.lenny-face-page .content-area,
body.lenny-face-page .site-main,
body.lenny-face-page .site-content .ast-container,
body.lenny-face-page .container-fluid,
body.lenny-face-page .container {
	width: 100% !important;
	max-width: 100% !important;
	flex: 1 1 100% !important;
}

body.lenny-face-page #secondary,
body.lenny-face-page .widget-area,
body.lenny-face-page aside#sidebar,
body.lenny-face-page .sidebar-primary {
	display: none !important;
}

.lf-container {
	max-width: 1140px;
	margin: 0 auto;
	padding: 2rem 1rem 3rem;
}

.lf-breadcrumbs {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
	align-items: center;
	font-size: 0.85rem;
	color: #7a8781;
	margin-bottom: 1rem;
}

.lf-breadcrumbs a {
	color: #5b6b66;
	text-decoration: none;
}

.lf-breadcrumbs a:hover {
	color: #2f7f54;
	text-decoration: underline;
}

.lf-h1 {
	margin: 0 0 0.5rem;
	font-size: clamp(1.6rem, 4vw, 2.3rem);
	line-height: 1.2;
	color: #33413c;
}

.lf-intro {
	margin: 0 0 1.25rem;
	font-size: 1.02rem;
	color: #5b6b66;
	max-width: 62ch;
}

.lf-linkchips {
	margin-bottom: 0.6rem;
}

.lf-linkchips.lf-subrow {
	margin-bottom: 1.25rem;
	padding-left: 0.25rem;
	border-left: 3px solid var(--lf-green-soft, #e7f4ec);
}

#lf-swap.is-loading {
	opacity: 0.55;
	pointer-events: none;
	transition: opacity 0.15s ease;
}

.lf-related {
	margin-top: 2.5rem;
}

.lf-related h2 {
	font-size: 1.15rem;
	color: var(--lf-ink-strong, #33413c);
	margin: 0 0 0.85rem;
}

.lf-related-links {
	display: flex;
	flex-wrap: wrap;
	gap: 0.6rem;
}

.lf-related-links a {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.62rem 1.2rem;
	border: 1.5px solid var(--lf-line, #ececec);
	border-radius: 999px;
	background: var(--lf-card-bg, #fff);
	color: var(--lf-ink-strong, #33413c);
	font-size: 0.92rem;
	font-weight: 700;
	text-decoration: none !important;
	box-shadow: 0 1px 2px rgba(30, 45, 38, 0.05);
	transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.lf-related-links a::after {
	content: "\2192";
	color: var(--lf-green, #3d9a68);
	font-weight: 800;
	transition: transform 0.15s ease;
}

.lf-related-links a:hover,
.lf-related-links a:focus-visible {
	border-color: var(--lf-green, #3d9a68);
	background: var(--lf-green-soft, #e7f4ec);
	color: var(--lf-green-dark, #2f7f54);
	transform: translateY(-1px);
	box-shadow: 0 4px 10px rgba(30, 45, 38, 0.09);
}

.lf-related-links a:hover::after,
.lf-related-links a:focus-visible::after {
	transform: translateX(3px);
}

/* --------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
	.lenny-face-card,
	.lenny-face-chip,
	.lenny-face-copy,
	.lenny-face-fav,
	.lenny-face-share,
	#lf-swap.is-loading {
		transition: none;
	}
	.lenny-face-card:hover {
		transform: none;
	}
}
