// 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 ) {
	border-left-color: $color;
	.jitm-banner__icon {
		color: $color;
	}
	.jitm-banner__icon-circle {
		background-color: $color;
	}
}

// New JITMS - modified calypso banner styles
$blue-grey-light:        #f6f7f7;
$blue-medium-dark:       #2271b1;

.jitm-button {
	background: $blue-grey-light;
	border-color: $blue-medium-dark;
	border-style: solid;
	border-width: 1px;
	color: $blue-medium-dark;
	cursor: pointer;
	display: inline-block;
	margin: 0;
	outline: 0;
	overflow: hidden;
	font-size: 14px;
	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;

	&:hover {
		background: #f0f0f1;
		border-color: $blue-grey-dark;
		color: $blue-grey-dark;
	}
	&[disabled],
	&:disabled {
		color: lighten( $gray, 30% );
		background: $white;
		border-color: lighten( $gray, 30% );
		cursor: default;
	}
	&:focus {
		background: $white;
		border-color: $blue-medium-dark;
		box-shadow: 0 0 0 1px $blue-medium-dark;
	}
	&.is-compact {
		padding: 7px;
		font-size: 11px;
		line-height: 1;
		text-transform: uppercase;
		white-space: nowrap;

		&:disabled {
			color: lighten( $gray, 30% );
		}
		.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;
	}
}

// Primary buttons
.jitm-button.is-primary {
	background: $blue-medium;
	border-color: $blue-medium;
	color: $white;

	&:hover,
	&:focus {
		border-color: $blue-medium-dark;
		background: $blue-medium-dark;
		color: $white;
	}
	&:focus {
		box-shadow:
			0 0 0 1px $white,
			0 0 0 3px $blue-medium-dark;
	}
	&[disabled],
	&:disabled {
		background: tint( $blue-light, 50% );
		border-color: tint( $blue-wordpress, 55% );
		color: $white;
	}
	&.is-compact {
		color: $white;
		white-space: nowrap;
	}
}


.jitm-card {
	display: block;
	clear: both;
	position: relative;
	margin: rem( 48px ) rem( 20px ) 0 auto;
	padding: rem( 16px );
	box-sizing: border-box;
	background: $white;
	box-shadow:
		0 0 0 1px $light-gray-700,
		0 1px 1px 1px  rgba(0,0,0,.04);


	@include clear-fix;

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

	// 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 {
	border-left: 4px solid;
	display: flex;
	padding: rem( 12px ) rem( 6px ) rem( 12px ) rem( 12px );
	position: relative;
	z-index: 2;

	@include breakpoint( "<480px" ) {
		display: flex;
		padding: rem( 12px );
		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( $alert-green );
	}
	&.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( 12px ) rem( 16px );

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

.jitm-banner__buttons_container {
	display: grid;
	height: 50%;
	margin-top: auto;
	margin-bottom: auto;

	@include breakpoint( ">480px" ) {
		display: flex;
	}
}

.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( 12px );
		}

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

		.jitm-jp-logo {
			height: inherit;
			width: 6rem;
			fill: inherit;
		}
	}

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

	@include breakpoint( "<960px" ) {
		margin-bottom: 10px;
	}
}

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

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

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

	@include breakpoint( "<960px" ) {
		display: grid;
		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 {
		color: $gray-dark;
	}

	.jitm-banner__title {
		font-size: 14px;
		font-weight: 500;
	}

	.jitm-banner__description {
		font-size: rem( 12px );
		line-height: 1.5;
		margin-top: rem( 6px );
	}

	.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 );
	margin: rem( 8px ) 0 0;
	text-align: left;
	width: 100%;

	.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" ) {
		margin: 0 rem( 4px ) 0 rem( 8px );
		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 16px/1 dashicons;
		content: '\f158';
	}

	@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;
}
