@use "sass:color";
@use "../../scss/functions/rem";
@use "../../scss/calypso-colors";
@use "../../scss/calypso-mixins";
@use "../../scss/mixins/clear-fix";


// Multisite
.dops-foldable-card.dops-card {

	@include clear-fix.clear-fix;
	position: relative;
	transition: margin 0.15s linear;
	padding: 0;

	&.is-expanded {
		margin-bottom: 8px;
	}

	.is-clickable {
		cursor: pointer;
	}
}

.dops-foldable-card__header {
	min-height: 64px;
	width: 100%;
	padding: 16px;
	box-sizing: border-box;
	display: flex;
	align-items: center;
	justify-content: space-between;
	position: relative;

	&.has-border {

		.dops-foldable-card__summary,
		.dops-foldable-card__summary_expanded {
			margin-right: 48px;
		}

		.dops-foldable-card__expand {
			border-left: 1px calypso-colors.$gray-light solid;
		}
	}

	.dops-foldable-card.is-compact & {
		padding: 8px 16px;
		min-height: 40px;
	}

	.dops-foldable-card.is-expanded & {
		margin-bottom: 0;
		height: inherit;
		min-height: 64px;
	}

	.dops-foldable-card.is-expanded.is-compact & {
		min-height: 40px;
	}

	.dops-foldable-card.is-disabled & {
		opacity: 0.2;
	}
}

.dops-foldable-card__action {
	position: absolute;
	top: 0;
	right: 0;
	height: 100%;
	background: none;
	border: 0;

	.dops-foldable-card.is-expanded & {
		height: 100%;
	}

	.dops-foldable-card.is-disabled & {
		cursor: default;
	}

	.dops-accessible-focus &:focus {
		outline: thin dotted;
	}
}

button.dops-foldable-card__action {
	cursor: pointer;
	outline: 0;
}

.dops-foldable-card__main {
	max-width: calc(100% - 36px);
	display: block;
	align-items: center;
	width: 100%;
	margin-right: 5px;

	@include calypso-mixins.breakpoint( "<480px" ) {
		flex: 1 1;
	}
}

.dops-foldable-card__secondary {
	display: flex;
	align-items: center;
	flex: 1 1;
	justify-content: flex-end;
}

.dops-foldable-card__expand {
	width: 48px;

	.gridicon {
		fill: calypso-colors.$gray;
		display: flex;
		align-items: center;
		width: 100%;
		vertical-align: middle;

		transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.2s ease-in;

		.dops-foldable-card.is-expanded & {
			transform: rotate(180deg);
		}
	}

	.gridicon:hover {
		fill: calypso-colors.$gray;
	}

	&:focus,
	&:hover {

		.gridicon {
			fill: calypso-colors.$blue-medium;
		}
	}
}

.dops-foldable-card__header-text {
	font-size: rem.convert(18px);
	width: 100%;
}

.dops-foldable-card__subheader {
	margin-top: rem.convert(2px);
	margin-bottom: rem.convert(2px);
	font-size: rem.convert(14px);
	color: color.adjust(calypso-colors.$gray, $lightness: -20%);
}

.dops-foldable-card__content {
	display: none;

	.dops-foldable-card.is-expanded & {
		display: block;
		padding: 16px;
		border-top: 1px solid calypso-colors.$gray-light;


		.dops-foldable-card.is-compact & {
			padding: 8px;
		}

		p:first-child {
			margin-top: 0;
		}

		p:last-child {
			margin-bottom: 0;
		}
	}
}

.dops-foldable-card__summary,
.dops-foldable-card__summary_expanded {
	margin-right: 40px;
	color: calypso-colors.$gray;
	font-size: 12px;
	transition: opacity 0.2s linear;
	display: inline-block;

	.dops-foldable-card.has-expanded-summary & {
		transition: none;
		flex: 2;
		text-align: right;
	}

	@include calypso-mixins.breakpoint( "<480px" ) {
		display: none;
	}
}


.dops-foldable-card__summary {
	opacity: 1;
	display: inline-block;

	.dops-foldable-card.is-expanded & {
		display: none;

		.has-expanded-summary & {
			display: none;
		}
	}
}

.dops-foldable-card__summary_expanded {
	display: none;

	.dops-foldable-card.is-expanded & {
		display: inline-block;
	}
}
