/* =====================================================================
   CloudPe Glossary — mirrors the Astro glossary UI (GlossaryIndex.tsx).
   Uses the CloudPe Events Theme design tokens:
   --primary, --primary-100, --primary-foreground, --card, --border,
   --background, --foreground, --muted-foreground, --font-heading, --font-body
   ===================================================================== */

.glossary-page {
	background: var(--background);
	color: var(--foreground);
}

/* ---------- Hero ---------- */
.glossary-hero {
	border-bottom: 1px solid var(--border);
	background: color-mix( in srgb, var(--muted-foreground) 6%, var(--background) );
	overflow: hidden;
}

.glossary-hero__inner {
	max-width: 1024px;
	margin: 0 auto;
	padding: 64px 24px;
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
}

@media (min-width: 640px) {
	.glossary-hero__inner { padding: 80px 24px; }
}

.glossary-badge {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 6px 12px;
	border-radius: 999px;
	border: 1px solid color-mix( in srgb, var(--primary) 20%, transparent );
	background: color-mix( in srgb, var(--primary) 10%, transparent );
	color: var(--primary);
	font-family: var(--font-body);
	font-size: 12px;
	font-weight: 500;
	margin-bottom: 20px;
}

.glossary-hero__title {
	font-family: var(--font-heading);
	font-size: 40px;
	font-weight: 700;
	line-height: 1.1;
	letter-spacing: -0.02em;
	color: var(--foreground);
	margin: 0;
}

@media (min-width: 768px) {
	.glossary-hero__title { font-size: 56px; }
}

.glossary-hero__accent { color: var(--primary); }

.glossary-hero__subtitle {
	max-width: 640px;
	margin: 20px auto 0;
	font-family: var(--font-body);
	font-size: 16px;
	line-height: 1.6;
	color: var(--muted-foreground);
}

@media (min-width: 640px) {
	.glossary-hero__subtitle { font-size: 18px; }
}

/* ---------- Search ---------- */
.glossary-search {
	position: relative;
	width: 100%;
	max-width: 576px;
	margin: 32px auto 0;
}

.glossary-search > svg {
	position: absolute;
	left: 16px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--muted-foreground);
	pointer-events: none;
}

.glossary-search__input {
	width: 100%;
	font-family: var(--font-body);
	font-size: 14px;
	padding: 12px 64px 12px 44px;
	border-radius: 12px;
	border: 1px solid var(--border);
	background: var(--card);
	color: var(--foreground);
	box-shadow: 0 1px 2px rgba(0,0,0,0.05);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.glossary-search__input::placeholder { color: var(--muted-foreground); }

.glossary-search__input:focus {
	outline: none;
	border-color: var(--primary);
	box-shadow: 0 0 0 3px color-mix( in srgb, var(--primary) 20%, transparent );
}

.glossary-search__kbd {
	position: absolute;
	right: 16px;
	top: 50%;
	transform: translateY(-50%);
	display: inline-flex;
	align-items: center;
	gap: 2px;
	padding: 2px 6px;
	border-radius: 4px;
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 10px;
	color: var(--muted-foreground);
	border: 1px solid var(--border);
	background: var(--background);
}

@media (max-width: 640px) {
	.glossary-search__kbd { display: none; }
}

/* ---------- A–Z filter bar (sticky) ---------- */
.glossary-alpha-bar {
	position: sticky;
	top: 0;
	z-index: 40;
	background: color-mix( in srgb, var(--background) 95%, transparent );
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	border-bottom: 1px solid var(--border);
}

.glossary-alpha {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	justify-content: space-between;
	gap: 4px;
	padding: 16px 40px;
}

@media (min-width: 1200px) {
	.glossary-alpha { padding: 16px 112px; }
}

/* Below the desktop threshold the 27 items can't fit on one line, so wrap
   them and center — buttons keep their natural size instead of overflowing. */
@media (max-width: 900px) {
	.glossary-alpha {
		flex-wrap: wrap;
		justify-content: center;
		gap: 6px;
	}
}

@media (max-width: 640px) {
	.glossary-alpha { padding: 16px 20px; }
}

.glossary-alpha__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 40px;
	/* One-line layout: let each letter shrink to share the row evenly instead
	   of a fixed width that overflows/wraps. min-width keeps the hit area sane. */
	flex: 1 1 0;
	min-width: 26px;
	max-width: 40px;
	padding: 0;
	border: none;
	background: transparent;
	border-radius: 8px;
	font-family: var(--font-body);
	font-size: 16px;
	font-weight: 600;
	color: var(--primary);
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

@media (max-width: 900px) {
	/* Wrapped rows: revert to fixed square buttons so they read as a grid. */
	.glossary-alpha__btn {
		flex: 0 0 auto;
		width: 40px;
		min-width: 40px;
		max-width: 40px;
	}
}

.glossary-alpha__btn:hover:not(.is-disabled):not(.is-selected) {
	background: color-mix( in srgb, var(--primary) 10%, transparent );
}

.glossary-alpha__btn.is-selected {
	background: var(--primary);
	color: var(--primary-foreground, #fff);
	cursor: default;
}

.glossary-alpha__btn.is-disabled {
	color: color-mix( in srgb, var(--muted-foreground) 30%, transparent );
	cursor: not-allowed;
}

/* ---------- Body ---------- */
/* Width + side padding mirror the A–Z alpha bar so the 3 term columns sit
   centered and aligned directly beneath the letters above. */
.glossary-body {
	max-width: 1400px;
	margin: 0 auto;
	padding: 48px 40px;
}

@media (min-width: 1200px) {
	.glossary-body { padding: 48px 112px; }
}

.glossary-results {
	font-family: var(--font-body);
	font-size: 14px;
	color: var(--muted-foreground);
	margin: 0 0 32px;
}

/* A single card wraps the whole glossary. Letter groups are laid out by JS
   (see the script in the template) into a row-first masonry: A B C D across the
   first row, E F G H next, etc. — but each item packs tightly under its column
   so there are NO reserved-row vertical gaps. Container is position:relative and
   its height is set by JS; items are absolutely positioned within it. */
.glossary-groups {
	position: relative;
	padding: 32px;
	border-radius: 16px;
	border: 1px solid color-mix( in srgb, var(--border) 60%, transparent );
	background: color-mix( in srgb, var(--card) 55%, transparent );
}

/* Fallback before JS runs (and if JS is disabled): simple responsive columns. */
.glossary-groups:not(.is-masonry):not(.is-empty) {
	columns: 4;
	column-gap: 48px;
	column-rule: 1px solid color-mix( in srgb, var(--border) 70%, transparent );
}
.glossary-groups:not(.is-masonry) .glossary-group {
	break-inside: avoid;
	-webkit-column-break-inside: avoid;
	margin-bottom: 28px;
}

@media (max-width: 1100px) { .glossary-groups:not(.is-masonry):not(.is-empty) { columns: 3; } }
@media (max-width: 900px)  { .glossary-groups:not(.is-masonry):not(.is-empty) { columns: 2; } }
@media (max-width: 560px)  { .glossary-groups:not(.is-masonry):not(.is-empty) { columns: 1; } }

/* Empty state: no multi-column flow — the message must stay a single block. */
.glossary-groups.is-empty {
	columns: auto;
	column-rule: none;
}

/* ---------- Letter group (positioned by the masonry script) ---------- */
.glossary-group {
	scroll-margin-top: 160px;
}

/* When masonry is active, items are absolutely positioned; the vertical divider
   is drawn on each item's right edge (JS omits it on last-in-row columns). */
.glossary-groups.is-masonry .glossary-group {
	position: absolute;
	top: 0;
	box-sizing: border-box;
}

.glossary-groups.is-masonry .glossary-group.has-divider {
	border-right: 1px solid color-mix( in srgb, var(--border) 70%, transparent );
}

.glossary-group__letter {
	font-family: var(--font-heading);
	font-size: 28px;
	font-weight: 700;
	color: var(--foreground);
	margin: 0 0 10px;
	line-height: 1;
}

.glossary-group__list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.glossary-item { margin: 0; }

/* ---------- Term (plain text link) ---------- */
.glossary-term {
	display: inline-block;
	padding: 4px 0;
	font-family: var(--font-body);
	font-size: 15px;
	font-weight: 400;
	color: var(--foreground);
	text-decoration: none;
	transition: color 0.15s ease;
}

.glossary-term:hover {
	color: var(--primary);
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* ---------- No results ---------- */
.glossary-noresults {
	text-align: center;
	padding: 80px 0;
}

.glossary-noresults__icon { font-size: 40px; margin-bottom: 16px; }

.glossary-noresults__title {
	font-family: var(--font-heading);
	font-size: 18px;
	font-weight: 600;
	color: var(--foreground);
	margin: 0 0 8px;
}

.glossary-noresults__text {
	font-family: var(--font-body);
	font-size: 14px;
	color: var(--muted-foreground);
	margin: 0 0 16px;
}

.glossary-noresults__clear {
	background: none;
	border: none;
	color: var(--primary);
	font-family: var(--font-body);
	font-size: 14px;
	cursor: pointer;
	text-decoration: underline;
}

.glossary-empty {
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	font-family: var(--font-body);
	color: var(--muted-foreground);
	font-size: 15px;
	padding: 48px 24px;
	min-height: 160px;
}

@media (min-width: 768px) {
	.glossary-empty {
		padding: 72px 32px;
		min-height: 220px;
		font-size: 16px;
	}
}

@media (min-width: 1200px) {
	.glossary-empty {
		padding: 96px 40px;
		min-height: 280px;
	}
}

/* ---------- CTA ---------- */
.glossary-cta {
	margin-top: 64px;
	padding: 32px;
	border-radius: 16px;
	border: 1px solid color-mix( in srgb, var(--primary) 20%, transparent );
	background: color-mix( in srgb, var(--primary) 5%, transparent );
	text-align: center;
}

.glossary-cta__title {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	font-family: var(--font-heading);
	font-size: 18px;
	font-weight: 600;
	color: var(--foreground);
	margin: 0 0 8px;
}

.glossary-cta__title svg { color: var(--primary); }

.glossary-cta__text {
	max-width: 576px;
	margin: 0 auto 20px;
	font-family: var(--font-body);
	font-size: 14px;
	color: var(--muted-foreground);
}

.glossary-cta__link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 10px 20px;
	border-radius: 8px;
	background: var(--primary);
	color: var(--primary-foreground, #fff);
	font-family: var(--font-body);
	font-size: 14px;
	font-weight: 500;
	text-decoration: none;
	transition: opacity 0.15s ease;
}

.glossary-cta__link:hover { opacity: 0.9; }

/* ---------- Single glossary term page ---------- */
/* Compound selectors (base theme class + glossary class) so these win over the
   theme's centered .blog-content-frame / .blog-content, which load afterward. */
.blog-content-frame.glossary-term-frame,
.blog-content.glossary-term-content,
.blog-content.glossary-term-content h1,
.blog-content.glossary-term-content h2,
.blog-content.glossary-term-content h3,
.blog-content.glossary-term-content h4,
.blog-content.glossary-term-content p,
.blog-content.glossary-term-content li { text-align: left; }

.blog-content.glossary-term-content > *:first-child { margin-top: 0; }

/* The theme hides all .blog-content img (display:none). Re-enable images inside
   glossary term definitions and align them to the content column width. */
.blog-content.glossary-term-content figure,
.blog-content.glossary-term-content .wp-block-image {
	margin: 24px 0;
	width: 100%;      /* match the text column, not the image's native size */
	max-width: 100%;
}

.blog-content.glossary-term-content img {
	display: block;
	width: 100%;      /* fill the content column edge-to-edge with the text */
	max-width: 100%;
	height: auto;
	border-radius: 12px;
}

.blog-content.glossary-term-content figure figcaption {
	margin-top: 8px;
	font-family: var(--font-body);
	font-size: 13px;
	color: var(--muted-foreground);
	text-align: left;
}
