@use "../utils/theme-variables" as *;

// The outer shadow supplies the remaining stroke width of the corner radius.
// Clamp the inner radius to zero for themes with square corners.
$border-radius: max(0px, calc(var(--wpds-border-radius-lg) - var(--wpds-border-width-xs)));

.card {
	box-shadow:
		0 0 0 var(--wpds-border-width-xs)
		var(--wpds-color-stroke-surface-neutral);
	outline: none;
}

.card-borderless {
	box-shadow: none;
}

.is-rounded {
	border-radius: $border-radius;
}

.content {
	height: 100%;
}

.header {
	border-bottom:
		var(--wpds-border-width-xs) solid
		var(--wpds-color-stroke-surface-neutral);
	border-color: var(--wpds-color-stroke-surface-neutral);
	box-sizing: border-box;

	&:last-child {
		border-bottom: none;
	}
}

.footer {
	border-top:
		var(--wpds-border-width-xs) solid
		var(--wpds-color-stroke-surface-neutral);
	border-color: var(--wpds-color-stroke-surface-neutral);
	box-sizing: border-box;

	&:first-of-type {
		border-top: none;
	}
}

.body {
	box-sizing: border-box;
	height: auto;
	max-height: 100%;
}

.is-scrollable {
	height: 100%;
}

.media {
	box-sizing: border-box;
	overflow: hidden;

	& > img,
	& > iframe {
		display: block;
		height: auto;
		max-width: 100%;
		width: 100%;
	}
}

.header,
.footer,
.body,
.media {
	&:first-of-type {
		border-start-start-radius: $border-radius;
		border-start-end-radius: $border-radius;
	}

	&:last-of-type {
		border-end-start-radius: $border-radius;
		border-end-end-radius: $border-radius;
	}
}

// Override Divider's border reset, orientation-specific display and inline-size
// regardless of stylesheet insertion order.
.divider.divider {
	--_wp-components-divider-border-width: var(--wpds-border-width-xs);
	box-sizing: border-box;
	display: block;
	width: 100%;
	border-color: var(--wpds-color-stroke-surface-neutral);
}

.section-borderless {
	border: none;
}

.is-shady {
	background-color: $components-color-gray-100;
}

@each $size, $padding in (
	none: 0,
	x-small: var(--wpds-dimension-padding-sm),
	small: var(--wpds-dimension-padding-lg),
	medium: var(--wpds-dimension-padding-lg) var(--wpds-dimension-padding-2xl),
	large: var(--wpds-dimension-padding-2xl) var(--wpds-dimension-padding-3xl)
) {
	.padding-#{$size} {
		padding: $padding;
	}
}

@each $side in block-start, block-end, inline-start, inline-end {
	@each $size, $padding in (
		none: 0,
		x-small: var(--wpds-dimension-padding-sm),
		small: var(--wpds-dimension-padding-lg),
		medium: var(--wpds-dimension-padding-2xl),
		large: var(--wpds-dimension-padding-3xl)
	) {
		.padding-#{$side}-#{$size} {
			padding-#{$side}: $padding;
		}
	}
}
