// Global variables and styles, used in multiple pages.

// Variables
@import './variables';

@keyframes altis-bounce {
	0% {
		opacity: 0.5;
	}
}

// Scoped import for overriding WP component styles.
.accelerate-ui {
	@import "ui";
	visibility: visible !important;
    opacity: 1 !important;

	// Component styles (rendered inside .accelerate-ui in the DOM).
	@import "components/List";

	.wrap > .notice {
		margin-left: 5%;
		margin-right: 5%;
	}

	// Generic class names — scoped to prevent collisions.
	.App {
		line-height: 1.7;
		*,
		*::before,
		*::after {
			box-sizing: border-box;
		}

		header {
			display: flex;
		}

		&__blocks {
			display: grid;
			grid-template-columns: repeat( 2, 1fr );

			&--three {
				grid-template-columns: repeat( 3, 1fr );
			}
		}
	}

	.Header {
		background: $acc-gray-100;
		border-bottom: 1px solid $acc-gray-200;
		padding: 25px 5% 15px;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin: 0 0 30px;
	}

	.Header	.Logo {
		margin: 0;
		padding: 0;
		display: flex;
		line-height: 32px;
		align-items: center;
		gap: 8px;
	}

	.Header .Logo__mark {
		flex-shrink: 0;
	}

	.Header .Beta {
		font-size: 0.6rem;
		background-color: $acc-charcoal;
		color: $acc-white;
		border-radius: 10px;
		padding: 0 6px;
		height: 1.6em;
		line-height: 1.6;
		margin-left: 5px;
		margin-right: 15px;
	}

	.Header .Title {
	    font-size: 23px;
	    font-weight: 400;
	}

	.Header .Version {
	    color: #aaa;
	    font-size: 0.7rem;
	    letter-spacing: 0.05rem;
	}

	&.index-php .Header .Title {
	    visibility: hidden;
	}

	// Dashboard Global
	.score-pos {
		color: $acc-positive !important;
	}

	.score-neg {
		color: $acc-negative !important;
	}

	.dashboard-shadow {
		box-shadow: 0 5px 10px rgba( 0, 0, 0, 0.05 );
	}

	// Dashboard
	.Dashboard {
		width: 100%;

		a {
			color: $acc-brand;

			&:hover,
			&:focus,
			&:active {
				color: $acc-brand-hover;
			}
		}

		&__hero-row {
			display: flex;
			align-items: flex-start;
			gap: 16px;
			margin: 20px 0;

			&__checklist {
				flex-shrink: 0;
				width: 260px;
				margin-left: 5%;
			}

			&__chart {
				flex: 1;
				min-width: 0;

				.HeroChart {
					margin-top: 0;
					margin-bottom: 0;
				}
			}
		}
	}

	.HeroChart {
		position: relative;
		margin: 20px 0;

		&__tooltip {
			z-index: 10;
		}

		&__loader {
			margin-left: 5%;
			float: left;
			margin-bottom: -16px;
			opacity: 0;
			transition: opacity 1000ms ease-out 2000ms;
			display: flex;
			align-items: center;

			&--loading {
				transition: opacity 0ms linear;
				opacity: 1;
			}

			svg {
				display: inline-block;
				margin-right: 8px;
			}
		}

		&__realtime-indicator {
			margin-left: 5%;
			float: left;
			margin-bottom: -16px;
			display: flex;
			align-items: center;
			gap: 8px;
			font-size: 13px;
			color: #9332FF;
			font-weight: 500;
		}

		&__pulse {
			flex-shrink: 0;

			&--loading {
				opacity: 0.6;
			}
		}

		&__pulse-dot {
			animation: hero-pulse 1.5s ease-in-out infinite;
		}

		&__progress-ring {
			animation: hero-countdown 30s linear forwards;
		}

		&__controls {
			position: relative;
			z-index: 2;
			float: right;
			margin-bottom: -10px;
			margin-right: 5%;
			display: flex;
			align-items: center;

			> * {
				margin-left: 20px;
			}

			> p {
				padding: 7px 30px 7px 27px;
				height: 36px;
				line-height: 20px;
				border-color: $acc-brand-light;
				border-radius: 10px;
				box-shadow: inset 0 0 0 1px $acc-brand-light;
				background: transparent;
				display: inline-block;
			}

			.dashicons-info-outline {
				color: $acc-gray-400;
				font-size: 0.8rem;
				vertical-align: baseline;
			}
		}

		&__group {
			opacity: 1;
			transition: opacity 500ms ease-out;

			&--loading {
				opacity: 0.5;
			}

			* {
				transition: stroke 300ms ease-in-out, fill 300ms ease-in-out;
			}
		}

		&__waiting {
			opacity: 1;
			animation: altis-bounce 1500ms ease-in-out infinite alternate;
		}
	}

	.WelcomeIntro {
		padding: 0 5% 10px;

		h2 {
			font-size: 1.7em;
			margin-bottom: 0;
		}

		p {
			margin-top: 0;
			font-size: 1.2em;
			padding: 0;
			color: $acc-gray-400;

			a {
				color: $acc-charcoal;
			}
		}
	}

	.Welcome {
		position: relative;
		font-size: 16px;
		padding: 10px $sidebar-padding 40px;
		background: $acc-charcoal;
		color: $acc-white;

		h2 {
			color: $acc-white;
			font-size: 24px;
		}

		p {
			font-size: inherit;
		}

		.components-button {
			margin-right: 1em;
			font-size: inherit;

			span[role="img"] {
				margin-left: 0.5em;
			}
		}
	}
}

// Admin shell overrides — scoped to Accelerate screens only.
body.wp-admin.accelerate-admin {
    background: $acc-white;
}

.accelerate-admin {
	#wpcontent {
	    padding-left: 0;
	}

	#wpbody {
	    margin: 0;
	}

	#wpbody-content {
	    margin: 0;
	}

	#wpbody-content .wrap {
	    margin: 0 0 20px 0;
	}

	#wpbody-content .wrap .wp-heading-inline,
	#wpbody-content .wrap > h1 {
	    visibility: hidden;
	    position: absolute;
	    top: -100%;
	}

	#wpbody-content .wrap .wp-heading-inline + .notice,
	#wpbody-content .wrap > h1 + .notice {
		margin-left: 5%;
		margin-right: 5%;
	}

	#wpbody-content .wrap .wp-heading-inline + * {
	    margin-left: 5%;
	}

	#screen-meta-links {
	    margin-left: -100%;
	}

	#message {
		margin-left: 5%;
		margin-right: 5%;
	}
}

// Notice wrappers — unique IDs, safe at global scope.
#Altis_Dashboard__notices {
    background: $acc-gray-100;
    overflow: hidden;
}

#Altis_Dashboard__all_notices {
    overflow: hidden;
}

#Altis_Dashboard__all_notices > *,
#Altis_Dashboard__notices > * {
    margin: 15px 5% 5px 5%;
}

#Altis_Dashboard__all_notices > .altis-notice,
#Altis_Dashboard__notices > .altis-notice {
    margin: 0 0 35px 0;
}

// Altis-prefixed notice styles — no collision risk.
.altis-notice {
	position: relative;
	background: #1d2327;
	box-shadow: 0 5px 10px 0 rgba(0,0,0,0.05);
	border-radius: 0;
	margin: 0 0 35px;
	overflow: hidden;
	color: #ffffff;
	border: 1px solid #333;

	h1 {
		font-size: 2rem;
		font-weight: 300;
		margin: 30px 0 30px;
		color: #ffffff;
	}

	h2 {
		color: #ffffff;
	}

	ul {
		list-style-type: circle;
		list-style-position: inside;
		font-size: 1rem;
		line-height: 1.6;
		color: #ffffff;
	}

	p {
		font-size: 1rem;
		line-height: 1.6;
		color: #ffffff;

		a {
			color: #ffffff;

			&:hover,
			&:focus {
				color: #ffffff;
			}
		}
	}

	&__top {
		background: #3c434a;
		color: $acc-white;
		padding: 1% 5%;
		border-radius: 0;
		display: flex;
		align-items: center;
		justify-content: space-between;
		position: relative;
	}

	&__dismiss {
		cursor: pointer;
		color: $acc-gray-200;
		background: none;
		border: 0;
		box-shadow: none;
		transform: scale(1.5);

		&:hover {
			opacity: 0.75;
		}
	}

	&__content {
		display: flex;
		flex-direction: row;
		align-items: stretch;
		padding-bottom: 25px;
		background: linear-gradient(90deg, #1d2327 0%, #1d2327 50%, rgba(29, 35, 39, 0.7) 75%, rgba(29, 35, 39, 0) 100%);
		background-size: auto 100%, 50% 100%;
		background-position: 0 0, 100% center;
		background-repeat: no-repeat;

		img {
			display: none;
		}
	}

	&__col {
		flex: 3;
		padding: 2% 5%;

		&:last-child {
			flex: 2;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}

	&__heading,
	&__subheading,
	&__body,
	&__cta {
		margin: 20px 0;
	}

	&__heading {
		margin-top: 0;
	}
	&__cta {
		margin-bottom: 0;

		.components-button.is-secondary {
			background-color: transparent;
			border: 2px solid #ffffff;
			color: #ffffff;
			padding: 10px 30px;
			height: auto;

			&:hover,
			&:hover:not(:disabled) {
				background-color: rgba(255, 255, 255, 0.1);
				color: #ffffff;
				border-color: #ffffff;
			}
		}
	}

	// Dynamic background images based on notice type
	&[data-notice="dashboard"] &__content {
		background-image: linear-gradient(90deg, #1d2327 0%, #1d2327 50%, rgba(29, 35, 39, 0.7) 75%, rgba(29, 35, 39, 0) 100%),
		                  url('../../assets/acc-bg.jpg');
	}

	&[data-notice="edit-broadcast"] &__content {
		background-image: linear-gradient(90deg, #1d2327 0%, #1d2327 50%, rgba(29, 35, 39, 0.7) 75%, rgba(29, 35, 39, 0) 100%),
		                  url('../../assets/acc-bg2.jpg');
	}

	&[data-notice="accelerate_page_altis-accelerate-settings"] &__content {
		background-image: linear-gradient(90deg, #1d2327 0%, #1d2327 50%, rgba(29, 35, 39, 0.7) 75%, rgba(29, 35, 39, 0) 100%),
		                  url('../../assets/acc-bg3.jpg');
	}

	// Mobile: Hide background images and gradients for full-width text
	@media (max-width: 768px) {
		&__content {
			background: #1d2327 !important;
			flex-direction: column;
		}

		&__col {
			flex: 1 !important;

			&:last-child {
				flex: 0 !important;
				display: none !important;
			}
		}

		&[data-notice="dashboard"] &__content,
		&[data-notice="edit-broadcast"] &__content,
		&[data-notice="accelerate_page_altis-accelerate-settings"] &__content {
			background: #1d2327 !important;
		}
	}
}

.accelerate-modal-notice {
	margin: 5px 0 2px;
	padding: 0 10px;

	&.is-dismissible {
		padding-right: 5px;
	}
}

// Remove gap when notices are present
.accelerate-ui.altis-notice {
	margin-top: -30px;
}

#altis-audience-manager > .loading {
    margin: 30px 5%;
}

@keyframes hero-pulse {
	0%, 100% {
		opacity: 1;
	}
	50% {
		opacity: 0.4;
	}
}

@keyframes hero-countdown {
	from {
		stroke-dashoffset: 0;
	}
	to {
		stroke-dashoffset: var(--circumference);
	}
}
