// Just in Time Messaging - message prompts

// TODO: Switch to using the `@automattic/jetpack-base-styles` package when its ready.
@import '../../plugins/jetpack/_inc/client/scss/functions/rem';
@import '../../plugins/jetpack/_inc/client/scss/variables/colors';
@import '../../plugins/jetpack/_inc/client/scss/mixins/breakpoints';
@import '../../plugins/jetpack/_inc/client/scss/calypso-colors';

@mixin clear-fix {
	&::after {
		content: ".";
		display: block;
		height: 0;
		clear: both;
		visibility: hidden;
	}
}

@mixin jitm-banner-color( $color ) {
	&::before {
		background-color: $color;
	}

	.jitm-banner__icon {
		color: $color;
	}

	.jitm-banner__icon-circle {
		background-color: $color;
	}
}

// New JITMS - modified calypso banner styles
$blue-medium-dark:       #2271b1;
$jp-gray:                #dcdcde;
$jp-gray-20:             #a7aaad;

.jitm-button {
	border-style: solid;
	border-width: 1px;
	cursor: pointer;
	display: inline-block;
	margin: 0;
	outline: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	text-decoration: none;
	vertical-align: top;
	box-sizing: border-box;
	font-size: 14px;
	border-radius: 4px;
	padding: 7px 14px 9px;
	-webkit-appearance: none;
	appearance: none;
	text-align: center;
	min-width: 90px;
	font-weight: 600;
	border-color: black;
	background: $white;
	color: black;
	width: 100%;

	// Primary buttons
	&.is-primary {
		background: black;
		color: $white;
	}

	&:hover,
	&:focus {
		border-color: $gray-dark;
		background: $gray-dark;
		color: $white;
	}
	&:focus {
		box-shadow:
			0 0 0 1px $white,
			0 0 0 3px $blue-medium-dark;
	}

	&[disabled],
	&:disabled {
		color: $jp-gray-20;
		background: $jp-gray;
		border-color: $jp-gray;
		cursor: default;
	}
	&.is-compact {
		height: 32px;
		font-size: 14px;
		line-height: 1;
		white-space: nowrap;

		.gridicon {
			top: 4px;
			margin-top: -8px;
		}
		// Make the left margin of the small plus icon visually less huge
		.gridicons-plus-small {
			margin-left: -4px;
		}
		// Reset the left margin if the button contains only the plus icon
		.gridicons-plus-small:last-of-type {
			margin-left: 0;
		}
		// Make plus icon nudged closer to adjacent icons for add-people and add-plugin type buttons
		.gridicons-plus-small + .gridicon {
			margin-left: -4px;
		}
	}
	&.hidden {
		display: none;
	}
}

.jitm-card {
	display: block;
	clear: both;
	position: relative;
	margin: rem( 48px ) rem( 20px ) 0 auto;
	padding: rem( 16px );
	padding-left: rem( 20px );
	box-sizing: border-box;
	background-color: $white;
	background-image: url( "../images/background.png" );
	background-repeat: no-repeat;
	background-position: right center;
	border: 1px solid $white;
	border-radius: 2px;
	box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.16);

	@include clear-fix;

	// Compact Card
	&.is-compact {
		margin-bottom: rem( 1px );

		@include breakpoint( ">480px" ) {
			margin-bottom: 1px;
			padding: rem( 16px ) rem( 24px );
		}
	}

	&.is-card-link {
		padding-right: rem( 48px );
	}
}

// Minor adjustments for the display in My Jetpack.
.my-jetpack-jitm-card {
	.jitm-card {
		margin-right: 0;
		margin-bottom: 0;
	}
}

// if JITM appears directly below WordPress "help" menu adjust margins
#screen-meta-links+.jitm-card {
	margin: rem( 40px ) 1.5385em 0 auto;
}

// if JITM appears directly below WordPress hello dolly adjust margins
#dolly+.jitm-card {
  margin: 3rem 1rem 0 auto;
}

// remove right margin for jitms in the editor
.post-php .jitm-card {
	margin-right: 0;
}

 // if JITM appears inside of the jetpack dashboard adjust margins
 .jp-lower .jitm-card {
   margin: 0 0 rem( 24px );
 }

.jitm-banner.jitm-card {
	display: flex;
	position: relative;
	z-index: 2;

	&::before {
		content: '';
		width: 4px;
		position: absolute;
		top: 0;
		left: 0;
		height: 100%;
		border-top-left-radius: 1px;
		border-bottom-left-radius: 1px;
	}

	@include breakpoint( "<480px" ) {
		display: flex;
		flex-direction: column;
	}

	&.is-card-link {
		padding: rem( 12px ) rem( 48px ) rem( 12px ) rem( 16px );
	}
	&.is-dismissible {
		padding-right: rem( 48px );
	}

	@include jitm-banner-color( $alert-green );

	&.is-upgrade-personal {
		@include jitm-banner-color( $alert-yellow );
	}
	&.is-upgrade-premium {
		@include jitm-banner-color( #069e08 );
	}
	&.is-upgrade-business,
	&.woo-jitm {
		@include jitm-banner-color( $alert-purple );
	}

	.jitm-card__link-indicator {
		align-items: center;
		color: $blue-wordpress;
		display: flex;
	}

	&:hover {
		transition: all 100ms ease-in-out;
		&.is-card-link {
			box-shadow: 0 0 0 1px $gray, 0 2px 4px lighten( $gray, 20% );
		}
		.jitm-card__link-indicator {
			color: $blue-dark;
		}
	}

	@include breakpoint( ">480px" ) {
		padding: rem( 16px );
		padding-left: rem( 20px );

		&.is-dismissible {
			padding-right: rem( 16px );
		}
	}
}

.jitm-banner__buttons_container {
	display: flex;
	height: 50%;
	margin: auto rem( 16px ) auto 0;
	gap: rem( 16px );
	overflow: hidden;

	@include breakpoint( ">480px" ) {
		margin-left: rem( 16px );
	}
}

.jitm-banner__icons {
	display: flex;

	.jitm-banner__icon,
	.jitm-banner__icon-circle {
		border-radius: 50%;
		flex-shrink: 0;
		height: rem( 24px );
		width: rem( 24px );
		margin-right: rem( 16px );
		margin-top: rem( -2px );
		text-align: center;
		top: rem( 4px );
	}

	.jitm-banner__icon {
		align-self: center;
		color: $white;
		display: block;
	}

	.jitm-banner__icon-circle {
		color: white;
		display: none;
		padding: rem( 3px ) rem( 4px ) rem( 4px ) rem( 3px );
	}

	@include breakpoint( ">480px" ) {
		align-items: center;

		.jitm-banner__icon {
			display: none;
		}
		.jitm-banner__icon-circle {
			display: block;
		}
	}
}

.jitm-banner__icon-plan {
	display: flex;
	margin-right: rem( 16px );

	.dops-plan-icon {
		height: rem(  32px );
		width: rem( 32px );
	}

	.jp-emblem {
		position: relative;
		top: rem( 2px );

		@include breakpoint( "<480px" ) {
			margin-bottom: rem( 16px );
		}

		svg {
			height: rem(  32px );
			width: rem( 32px );
			fill: $green-primary;
		}

		.jitm-jp-logo {
			height: inherit;
			width: rem( 40px );
			fill: inherit;
		}
	}

	@include breakpoint( ">480px" ) {
		align-items: center;
	}
}

.jitm-banner__content {
	align-items: center;
	display: flex;
	flex-grow: 1;
	flex-wrap: wrap;
	flex-shrink: 100000;

	@include breakpoint( "<480px" ) {
		margin-right: 0;
	}

	@include breakpoint( ">480px" ) {
		flex-wrap: nowrap;
	}

	@include breakpoint( "<960px" ) {
		margin-right: 5px;
	}
}

.jitm-banner__info {
	flex-grow: 1;
	line-height: 1.4;

	@include breakpoint( ">480px" ) {
		flex-basis: 50%;
	}

	@include breakpoint( ">960px" ) {
		flex-basis: 70%;
	}

	.jitm-banner__title,
	.jitm-banner__description,
	.jitm-banner__description a {
		color: black;
	}

	.jitm-banner__title {
		font-size: rem( 15px );
		font-weight: 700;
		line-height: 136%;
	}

	.jitm-banner__description {
		font-size: rem( 13px );
		line-height: 150%;
		margin-top: rem( 2px );
	}

	.banner__list {
		font-size: 12px;
		list-style: none;
		margin: 10px 0;
		li {
			margin: 6px 0;
			.gridicon {
				fill: $gray;
				display: inline;
				margin-right: 12px;
				vertical-align: bottom;
			}
		}
	}
}

.jitm-banner__action {
	align-self: center;
	font-size: rem( 12px );
	text-align: left;
	overflow: hidden;

	.jitm-banner__prices {
		display: flex;
		justify-content: flex-start;

		.dops-plan-price {
			margin-bottom: 0;
		}

		.dops-plan-price.is-discounted,
		.dops-plan-price.is-discounted .dops-plan-price__currency-symbol {
			color: $gray-dark;
		}

		.has-call-to-action & .dops-plan-price {
			margin-bottom: rem( 8px );
		}
	}

	@include breakpoint( "<480px" ) {
		margin-top: 1rem;
	}

	@include breakpoint( ">480px" ) {
		text-align: center;
		width: auto;

		.is-dismissible {
			margin-top: rem( 40px );
		}

		.jitm-banner__prices {
			justify-content: flex-end;
			text-align: right;
		}
	}
}

.jitm-banner__dismiss {
	display: block;
	text-decoration: none;
	line-height: .5;
	margin-top: auto;
	margin-bottom: auto;

	&::before {
		color: darken($gray, 20%);
		font: 400 20px/1 dashicons;
		content: '\f335';
	}

	@include breakpoint( ">660px" ) {
		margin-right: rem( -8px );
	}

	@include breakpoint( "<480px" ) {
		position: absolute;
		top: 0;
		right: 0;

		display: flex;
		justify-content: center;
		align-items: center;
		margin: 0;

		// Minimum touch area
		width: 48px;
		height: 48px;
	}
}

.jitm-banner__action + .jitm-banner__dismiss {
	margin-left: rem( 10px );
}

#dolly + .jitm-card {
  margin: 3rem 1rem 0 auto;
}
