/**
 * Card
 *
 * Base surface for all card types. Specialised cards add a modifier class,
 * never a second implementation.
 */

.rc-card {
	position: relative;
	display: flex;
	flex-direction: column;
	background-color: var(--color-surface-raised);
	border: var(--border-default);
	border-radius: var(--radius-lg);
	overflow: hidden;
	transition:
		border-color var(--duration-base) var(--ease-standard),
		box-shadow var(--duration-base) var(--ease-standard);
}

/* --- Variants ------------------------------------------------------- */

.rc-card--variant-elevated {
	border-color: transparent;
	box-shadow: var(--shadow-sm);
}

.rc-card--variant-bordered {
	border-color: var(--color-border-strong);
	box-shadow: none;
}

.rc-card--variant-accent {
	background-color: var(--color-primary-50);
	border-color: var(--color-primary-100);
}

/* --- Orientation ---------------------------------------------------- */

@media (min-width: 640px) {
	.rc-card--orientation-horizontal {
		flex-direction: row;
		align-items: stretch;
	}

	.rc-card--orientation-horizontal .rc-card__media {
		flex: 0 0 40%;
		aspect-ratio: auto !important; /* Inline ratio applies to vertical only. */
	}
}

/* --- Media ---------------------------------------------------------- */

.rc-card__media {
	position: relative;
	overflow: hidden;
	background-color: var(--color-neutral-100);
}

.rc-card__media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.rc-card__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--space-7);
	height: var(--space-7);
	margin: var(--space-4) var(--space-4) 0;
	border-radius: var(--radius-md);
	background-color: var(--color-primary-50);
	color: var(--color-primary-700);
}

/* --- Body ----------------------------------------------------------- */

.rc-card__body {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	padding: var(--space-4);
	flex: 1 1 auto;
}

.rc-card__eyebrow {
	margin: 0;
	font-size: var(--text-caption);
	font-weight: var(--weight-semibold);
	letter-spacing: var(--tracking-wide);
	text-transform: uppercase;
	color: var(--color-text-muted);
}

.rc-card__title {
	margin: 0;
	font-family: var(--font-display);
	font-size: var(--text-h4);
	font-weight: var(--weight-semibold);
	line-height: var(--leading-snug);
	color: var(--color-text);
}

.rc-card__link {
	color: inherit;
	text-decoration: none;
}

.rc-card__link:hover {
	color: var(--color-link);
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

/*
 * Stretches the title link across the whole card so the entire surface is
 * clickable, while only the title text is announced as the link.
 */
.rc-card--linked .rc-card__link::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: var(--z-base);
}

.rc-card--linked:hover {
	border-color: var(--color-primary-200);
	box-shadow: var(--shadow-md);
}

/*
 * The focus ring must appear on the card, not on the invisible stretched
 * area, or keyboard users cannot see where they are.
 */
.rc-card--linked:focus-within {
	outline: var(--focus-ring);
	outline-offset: var(--focus-ring-offset);
}

.rc-card--linked .rc-card__link:focus-visible {
	outline: none;
}

.rc-card__text {
	margin: 0;
	font-size: var(--text-body);
	line-height: var(--leading-relaxed);
	color: var(--color-text-muted);
}

.rc-card__text > :last-child {
	margin-bottom: 0;
}

/* --- Meta ----------------------------------------------------------- */

.rc-card__meta {
	display: flex;
	flex-direction: column;
	gap: var(--space-1);
	margin: var(--space-1) 0 0;
	padding: 0;
	list-style: none;
}

.rc-card__meta-item {
	display: flex;
	align-items: flex-start;
	gap: var(--space-2);
	font-size: var(--text-small);
	line-height: var(--leading-normal);
	color: var(--color-text-muted);
}

.rc-card__meta-item .rc-icon {
	flex-shrink: 0;
	margin-top: 0.15em;
	color: var(--color-primary-600);
}

/* --- Actions and footer --------------------------------------------- */

/*
 * Actions sit above the stretched link so they remain independently
 * clickable inside a linked card.
 */
.rc-card__actions {
	position: relative;
	z-index: var(--z-dropdown);
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-2);
	margin-top: auto;
	padding-top: var(--space-3);
}

.rc-card__footer {
	position: relative;
	z-index: var(--z-dropdown);
	padding: var(--space-3) var(--space-4);
	border-top: var(--border-default);
	background-color: var(--color-surface-sunken);
	font-size: var(--text-small);
	color: var(--color-text-muted);
}

/* --- Grid ----------------------------------------------------------- */

/*
 * Shared layout for any collection of cards. Auto-fit means callers never
 * pick a column count — the grid adapts and every card row stays equal
 * height without a wrapper component per card type.
 */
.rc-card-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
	gap: var(--space-4);
}
