/* ==========================================================================
   Bilingual Medical Articles — [bma_articles] "Pulse Card" grid
   Unique design: ECG heartbeat divider that animates on hover,
   floating language chip, soft clinical palette.
   ========================================================================== */

.bma-grid {
	--bmg-ink: #0f2233;
	--bmg-muted: #64748b;
	--bmg-line: #e2e8f0;
	--bmg-brand: #0b6ea8;
	--bmg-brand-dark: #084e76;
	--bmg-accent: #0fb5a6;      /* teal pulse */
	--bmg-mr: #b45309;          /* marathi chip amber */
	--bmg-radius: 18px;

	display: grid;
	gap: 26px;
	margin: 24px auto;
	max-width: 1180px;
	padding: 0 4px;
	box-sizing: border-box;
}
.bma-grid * { box-sizing: border-box; }

.bma-grid-cols-1 { grid-template-columns: 1fr; max-width: 640px; }
.bma-grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.bma-grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.bma-grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 980px) {
	.bma-grid-cols-3, .bma-grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px) {
	.bma-grid-cols-2, .bma-grid-cols-3, .bma-grid-cols-4 { grid-template-columns: 1fr; }
}

/* ---------- Card ---------- */
.bma-card {
	position: relative;
	display: flex;
	flex-direction: column;
	background: #fff;
	border: 1px solid var(--bmg-line);
	border-radius: var(--bmg-radius);
	overflow: hidden;
	box-shadow: 0 1px 2px rgba(15, 34, 51, .05);
	transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.bma-card:hover {
	transform: translateY(-6px);
	border-color: rgba(11, 110, 168, .35);
	box-shadow: 0 18px 40px -18px rgba(11, 110, 168, .35);
}

/* ---------- Media ---------- */
.bma-card-media {
	position: relative;
	display: block;
	aspect-ratio: 16 / 9;
	background: linear-gradient(135deg, #eef7fc 0%, #e6f6f4 100%);
	overflow: hidden;
}
.bma-card-media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform .5s ease;
}
.bma-card:hover .bma-card-media img { transform: scale(1.06); }

.bma-card-media-fallback {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--bmg-brand);
	opacity: .55;
}
.bma-card-media-fallback svg { width: 72px; height: 72px; }

/* Floating language chip */
.bma-card-lang {
	position: absolute;
	top: 12px;
	right: 12px;
	padding: 4px 12px;
	border-radius: 999px;
	font-size: .74rem;
	font-weight: 700;
	letter-spacing: .04em;
	color: #fff;
	background: var(--bmg-brand);
	box-shadow: 0 2px 10px rgba(8, 78, 118, .35);
	backdrop-filter: blur(2px);
}
.bma-card-mr .bma-card-lang { background: var(--bmg-mr); box-shadow: 0 2px 10px rgba(180, 83, 9, .35); }

/* ---------- ECG pulse divider (the signature) ---------- */
.bma-card-pulse {
	height: 24px;
	margin-top: -12px;
	position: relative;
	z-index: 2;
	color: var(--bmg-accent);
	background: linear-gradient(to bottom, transparent 0 45%, #fff 45%);
	pointer-events: none;
}
.bma-card-pulse svg { width: 100%; height: 100%; display: block; }

.bma-pulse-path {
	stroke-dasharray: 340;
	stroke-dashoffset: 0;
	filter: drop-shadow(0 0 3px rgba(15, 181, 166, .45));
}
.bma-card:hover .bma-pulse-path {
	animation: bma-heartbeat 1.1s ease-in-out;
}
@keyframes bma-heartbeat {
	from { stroke-dashoffset: 340; }
	to   { stroke-dashoffset: 0; }
}
@media (prefers-reduced-motion: reduce) {
	.bma-card:hover .bma-pulse-path { animation: none; }
	.bma-card, .bma-card-media img { transition: none; }
}

/* ---------- Body ---------- */
.bma-card-body {
	display: flex;
	flex-direction: column;
	flex: 1;
	padding: 6px 20px 20px;
}
.bma-card-title {
	margin: 6px 0 8px;
	font-size: 1.12rem;
	line-height: 1.35;
	font-weight: 800;
	letter-spacing: -.01em;
}
.bma-card-title a {
	color: var(--bmg-ink);
	text-decoration: none;
	transition: color .15s ease;
}
.bma-card-title a:hover { color: var(--bmg-brand); }

.bma-card-excerpt {
	margin: 0 0 16px;
	font-size: .93rem;
	line-height: 1.65;
	color: var(--bmg-muted);
}

/* ---------- Footer ---------- */
.bma-card-foot {
	margin-top: auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding-top: 14px;
	border-top: 1px dashed var(--bmg-line);
}
.bma-card-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.bma-card-chip {
	font-size: .74rem;
	color: var(--bmg-muted);
	background: #f1f5f9;
	border-radius: 999px;
	padding: 3px 10px;
	white-space: nowrap;
}

.bma-card-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: .86rem;
	font-weight: 700;
	color: var(--bmg-brand);
	text-decoration: none;
	white-space: nowrap;
	transition: gap .2s ease, color .15s ease;
}
.bma-card-btn svg { width: 16px; height: 16px; }
.bma-card-btn:hover { color: var(--bmg-brand-dark); gap: 10px; }

.bma-grid-empty {
	text-align: center;
	color: #64748b;
	padding: 30px 0;
}

/* ==========================================================================
   Topic (subsection) cards + topic archive page
   ========================================================================== */

.bma-topic-card { text-decoration: none; }
.bma-topic-card .bma-card-body { padding-top: 4px; }
.bma-topic-name { display: block; }
.bma-topic-count { background: var(--bmg-accent); box-shadow: 0 2px 10px rgba(15,181,166,.35); }
.bma-topic-card .bma-card-foot { justify-content: flex-end; }

/* ---------- Creative auto-design (topics without an image) ----------
   Each topic gets a fixed gradient (term_id % 6), a soft medical
   plus-pattern, a large watermark initial and a heartbeat icon —
   so cards look intentional even with zero photos uploaded. */

.bma-palette-0 { --bma-g1: #0b6ea8; --bma-g2: #0fb5a6; }  /* ocean → teal   */
.bma-palette-1 { --bma-g1: #6d28d9; --bma-g2: #2563eb; }  /* violet → blue  */
.bma-palette-2 { --bma-g1: #0f766e; --bma-g2: #22c55e; }  /* teal → green   */
.bma-palette-3 { --bma-g1: #b45309; --bma-g2: #f59e0b; }  /* amber warmth   */
.bma-palette-4 { --bma-g1: #be123c; --bma-g2: #fb7185; }  /* rose care      */
.bma-palette-5 { --bma-g1: #1e3a8a; --bma-g2: #0ea5e9; }  /* navy → sky     */

.bma-media-auto {
	background: linear-gradient(130deg, var(--bma-g1) 0%, var(--bma-g2) 100%);
}
.bma-auto-pattern {
	position: absolute;
	inset: 0;
	color: #ffffff;
	opacity: .35;
	pointer-events: none;
}
.bma-auto-pattern svg { width: 100%; height: 100%; display: block; }

.bma-auto-initial {
	position: absolute;
	right: 10px;
	bottom: -22px;
	font-size: 118px;
	line-height: 1;
	font-weight: 900;
	letter-spacing: -.04em;
	color: #ffffff;
	opacity: .18;
	pointer-events: none;
	user-select: none;
	transition: transform .5s ease, opacity .3s ease;
}
.bma-card:hover .bma-auto-initial { transform: translateY(-8px) rotate(-3deg); opacity: .26; }

.bma-auto-icon {
	position: absolute;
	left: 18px;
	bottom: 14px;
	width: 46px;
	height: 46px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	background: rgba(255, 255, 255, .16);
	border: 1px solid rgba(255, 255, 255, .35);
	border-radius: 14px;
	backdrop-filter: blur(3px);
	transition: transform .3s ease, background .3s ease;
}
.bma-auto-icon svg { width: 26px; height: 26px; }
.bma-card:hover .bma-auto-icon { transform: scale(1.08); background: rgba(255, 255, 255, .26); }

/* ---------- Topic hero banner (topic archive page) ---------- */

.bma-topic-hero {
	position: relative;
	border-radius: 22px;
	overflow: hidden;
	margin-bottom: 26px;
	background: linear-gradient(130deg, var(--bma-g1, #0b6ea8) 0%, var(--bma-g2, #0fb5a6) 100%);
	background-size: cover;
	background-position: center;
}
.bma-topic-hero::before {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(100deg, rgba(8, 30, 48, .82) 0%, rgba(8, 30, 48, .55) 55%, rgba(8, 30, 48, .25) 100%);
}
.bma-topic-hero-inner {
	position: relative;
	z-index: 1;
	padding: 40px 36px 34px;
}
@media (max-width: 620px) {
	.bma-topic-hero-inner { padding: 28px 20px 24px; }
}
.bma-topic-hero .bma-topic-crumb,
.bma-topic-hero .bma-topic-crumb a { color: rgba(255, 255, 255, .85); }
.bma-topic-hero .bma-topic-title { color: #fff; text-shadow: 0 2px 14px rgba(0, 0, 0, .25); }
.bma-topic-hero .bma-topic-desc { color: rgba(255, 255, 255, .92); }
.bma-topic-hero .bma-lang-tabs { background: rgba(255, 255, 255, .14); backdrop-filter: blur(4px); }
.bma-topic-hero .bma-tab { color: rgba(255, 255, 255, .85); }
.bma-topic-hero a.bma-tab:hover { color: #084e76; background: #fff; }
.bma-topic-hero .bma-tab.is-active { background: #fff; color: #084e76; box-shadow: 0 2px 8px rgba(0, 0, 0, .18); }

.bma-topic-archive {
	max-width: 1180px;
	margin: 0 auto;
	padding: 32px 20px 70px;
	box-sizing: border-box;
}
.bma-topic-header { text-align: left; margin-bottom: 10px; }
.bma-topic-crumb {
	font-size: .85rem;
	color: #64748b;
	display: flex;
	gap: 8px;
	align-items: center;
	margin: 0 0 10px;
}
.bma-topic-crumb a { color: #0b6ea8; text-decoration: none; font-weight: 600; }
.bma-topic-crumb a:hover { text-decoration: underline; }
.bma-topic-title {
	font-size: clamp(1.7rem, 1.2rem + 2vw, 2.4rem);
	font-weight: 800;
	letter-spacing: -.015em;
	color: #0f2233;
	margin: 0 0 10px;
}
.bma-topic-desc {
	color: #64748b;
	max-width: 720px;
	line-height: 1.7;
	margin: 0 0 18px;
}

/* Language filter pills on topic pages (reuses tab look) */
.bma-topic-archive .bma-lang-tabs {
	display: inline-flex;
	gap: 4px;
	padding: 4px;
	background: #eef2f6;
	border-radius: 999px;
	margin-bottom: 8px;
}
.bma-topic-archive .bma-tab {
	display: inline-block;
	padding: 7px 20px;
	border-radius: 999px;
	font-size: .92rem;
	font-weight: 600;
	text-decoration: none;
	color: #64748b;
	line-height: 1.2;
	transition: all .15s ease;
}
.bma-topic-archive a.bma-tab:hover { color: #084e76; background: #fff; }
.bma-topic-archive .bma-tab.is-active {
	background: #0b6ea8;
	color: #fff;
	box-shadow: 0 2px 8px rgba(11,110,168,.28);
}

/* Pagination */
.bma-pagination { margin-top: 34px; text-align: center; }
.bma-pagination .page-numbers {
	display: inline-block;
	min-width: 38px;
	padding: 8px 12px;
	margin: 0 3px;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	color: #0b6ea8;
	font-weight: 600;
	text-decoration: none;
	transition: all .15s ease;
	box-sizing: border-box;
}
.bma-pagination .page-numbers:hover { border-color: #0b6ea8; background: #eef7fc; }
.bma-pagination .page-numbers.current {
	background: #0b6ea8;
	border-color: #0b6ea8;
	color: #fff;
}
.bma-pagination .page-numbers.dots { border: none; }
