/**
 * OMI home: Popular Courses.
 * Figma: OMI Home Page → Popular Courses section (26:3), Course card (26:9),
 * Show more button (26:233).
 *
 * @author Sameer Ali
 */

.omi-home .omi-home-courses {
	padding-top: 21px;
}

.omi-home .omi-home-courses__panel {
	display: flex;
	flex-direction: column;
	gap: 40px;
	padding: 64px;
	border-radius: 60px;
	background: var(--omi-color-white);
}

.omi-home .omi-home-courses__title {
	margin: 0;
	padding: 0;
	font: 700 34px/1.15 var(--omi-font);
	letter-spacing: 0;
	text-transform: none;
	color: var(--omi-color-text);
}

.omi-home .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ---------- Grid (4 columns, gap 24) ---------- */

.omi-home .omi-home-courses__grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 24px;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* With JavaScript the later courses wait for "Show more". */
html.omi-js .omi-home .omi-home-courses__card.is-later:not(.is-shown) {
	display: none;
}

/* Smooth height change of the grid while cards are added / removed. */
.omi-home .omi-home-courses__grid.is-resizing {
	overflow: hidden;
	transition: height .6s cubic-bezier(.16, 1, .3, 1);
}

/* ---------- Card ---------- */

.omi-home .omi-home-courses__card {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 20px;
	min-width: 0;
	margin: 0;
	padding: 24px;
	border: 1px solid #e2e8f0;
	border-radius: 24px;
	background: var(--omi-color-white);
	list-style: none;
	transition: transform .45s var(--omi-ease), box-shadow .45s var(--omi-ease), border-color .45s var(--omi-ease);
}

.omi-home .omi-home-courses__card::before {
	content: none;
}

.omi-home .omi-home-courses__media {
	position: relative;
	display: block;
	aspect-ratio: 242 / 160;
	border-radius: 20px;
	overflow: hidden;
	background: var(--omi-color-surface);
	isolation: isolate;
}

.omi-home .omi-home-courses__img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	transition: transform 1.2s var(--omi-ease);
}

.omi-home .omi-home-courses__body {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 12px;
	flex: 1 1 auto;
}

.omi-home .omi-home-courses__name {
	flex: 1 1 auto;
	min-height: 88px;
	margin: 0;
	padding: 0;
	font: 600 16px/1.4 var(--omi-font);
	letter-spacing: 0;
	text-transform: none;
	color: var(--omi-color-text);
}

/* Small dark pill (Figma "Explore Now": h44, padding 16/8, gap 12, circle 28). */
.omi-home .omi-btn--sm {
	gap: 12px;
	height: 44px;
	padding: 0 8px 0 16px;
	font-size: 14px;
}

.omi-home .omi-btn--sm .omi-btn__icon {
	width: 28px;
	height: 28px;
}

.omi-home .omi-btn--sm .omi-btn__icon .omi-icon {
	width: 13px;
	height: 13px;
}

/* Whole card is clickable (the button link stretches over it). */
.omi-home .omi-home-courses__link::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 24px;
}

@media (hover: hover) and (pointer: fine) {
	.omi-home .omi-home-courses__card:hover {
		transform: translateY(-6px);
		border-color: #cfe2fb;
		box-shadow: 0 24px 40px -24px rgba(18, 50, 87, .35);
	}

	.omi-home .omi-home-courses__card:hover .omi-home-courses__img {
		transform: scale(1.2);
	}

	.omi-home .omi-home-courses__card:hover .omi-btn__icon {
		background: var(--omi-color-primary);
		color: var(--omi-color-white);
	}

	.omi-home .omi-home-courses__card:hover .omi-btn__icon .omi-icon {
		transform: rotate(45deg);
	}

}

/* The card lifts instead of the button (a transform on the link would also
   shrink its stretched click area to the button). */
.omi-home .omi-home-courses__card .omi-home-courses__link:hover,
.omi-home .omi-home-courses__card .omi-home-courses__link:focus-visible {
	transform: none;
	box-shadow: none;
}

.omi-home .omi-home-courses__link:focus-visible {
	outline: 2px solid var(--omi-color-primary);
	outline-offset: 3px;
}

/* ---------- Cards revealed by "Show more" ---------- */

.omi-home .omi-home-courses__card.is-entering {
	animation: omi-course-in .7s cubic-bezier(.16, 1, .3, 1) both;
	animation-delay: calc(var(--omi-i, 0) * 70ms);
}

.omi-home .omi-home-courses__card.is-leaving {
	animation: omi-course-out .3s ease both;
}

@keyframes omi-course-in {
	from { opacity: 0; transform: translate3d(0, 36px, 0) scale(.97); }
	to   { opacity: 1; transform: none; }
}

@keyframes omi-course-out {
	from { opacity: 1; transform: none; }
	to   { opacity: 0; transform: translate3d(0, 16px, 0); }
}

/* ---------- Show more (Figma: #D5F4FF pill, #1156A7 text + circle) ---------- */

.omi-home .omi-home-courses__more {
	display: flex;
	justify-content: flex-end;
}

.omi-home .omi-btn--soft {
	border: 0;
	background: #d5f4ff;
	color: #1156a7;
	cursor: pointer;
	box-shadow: none;
	font-family: var(--omi-font);
}

.omi-home .omi-btn--soft .omi-btn__icon {
	background: #1156a7;
	color: var(--omi-color-white);
}

.omi-home .omi-btn--soft:hover,
.omi-home .omi-btn--soft:focus-visible {
	background: #1156a7;
	color: var(--omi-color-white);
}

.omi-home .omi-btn--soft:hover .omi-btn__icon,
.omi-home .omi-btn--soft:focus-visible .omi-btn__icon {
	background: var(--omi-color-white);
	color: #1156a7;
}

/* Arrow as in Figma (up-right); turns 45° on hover like the other buttons. */

/* No JavaScript: everything is already shown, so the button is not needed. */
html:not(.omi-js) .omi-home .omi-home-courses__more {
	display: none;
}

/* ---------- Responsive ---------- */

@media (max-width: 1279px) {
	.omi-home .omi-home-courses__grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (max-width: 1099px) {
	.omi-home .omi-home-courses__panel {
		padding: 48px 0;
		border-radius: 0;
	}

	.omi-home .omi-home-courses__title {
		font-size: 30px;
	}
}

@media (max-width: 899px) {
	.omi-home .omi-home-courses__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 16px;
	}
}

@media (max-width: 767px) {
	.omi-home .omi-home-courses__panel {
		gap: 28px;
		padding: 40px 0 24px;
	}

	.omi-home .omi-home-courses__title {
		font-size: 26px;
	}

	.omi-home .omi-home-courses__card {
		gap: 14px;
		padding: 14px;
		border-radius: 20px;
	}

	.omi-home .omi-home-courses__media {
		border-radius: 14px;
	}

	.omi-home .omi-home-courses__name {
		min-height: 0;
		font-size: 14px;
	}

	.omi-home .omi-home-courses__more {
		justify-content: center;
	}
}

@media (max-width: 479px) {
	.omi-home .omi-home-courses__grid {
		grid-template-columns: minmax(0, 1fr);
	}
}

@media (prefers-reduced-motion: reduce) {
	.omi-home .omi-home-courses__card,
	.omi-home .omi-home-courses__img,
	.omi-home .omi-home-courses__grid.is-resizing {
		transition: none;
	}

	.omi-home .omi-home-courses__card.is-entering,
	.omi-home .omi-home-courses__card.is-leaving {
		animation: none;
	}

	.omi-home .omi-home-courses__card:hover .omi-home-courses__img {
		transform: none;
	}
}
