/*
 * SUN Engagement CTA — styled to match Heliotrope design system.
 *
 * Uses theme CSS custom properties with hardcoded fallbacks so the popup
 * renders correctly even if the theme stylesheet hasn't loaded yet.
 *
 * Layout: fixed bottom bar.
 *   [content: eyebrow + headline + body]  [form: email + zip + button]
 */

/* -------------------------------------------------------------------------
 * Popup container
 * ------------------------------------------------------------------------ */

.sun-cta {
	/* visibility + pointer-events (not display:none) so transform transitions work. */
	visibility: hidden;
	pointer-events: none;
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 99999;
	background: var(--primary-dark-blue, #201d53);
	color: #fff;
	font-family: var(--helio-f-primary, aktiv-grotesk, sans-serif);
	transform: translateY(100%);
	transition: transform 0.4s cubic-bezier(0.33, 1, 0.68, 1), visibility 0s 0.4s;
	overflow: hidden;
}

.sun-cta.sun-cta--visible {
	visibility: visible;
	pointer-events: auto;
	transform: translateY(0);
	transition: transform 0.4s cubic-bezier(0.33, 1, 0.68, 1), visibility 0s 0s;
}

.sun-cta.sun-cta--loading .sun-cta__content {
	opacity: 0;
	transition: opacity 0.1s ease;
}

.sun-cta.sun-cta--loading .sun-cta__ea-form {
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.1s ease;
}

.sun-cta:not(.sun-cta--loading) .sun-cta__content,
.sun-cta:not(.sun-cta--loading) .sun-cta__ea-form {
	transition: opacity 0.15s ease;
}

@media (prefers-reduced-motion: reduce) {
	.sun-cta {
		transition: none;
	}
	.sun-cta.sun-cta--visible {
		transition: none;
	}
}

/* -------------------------------------------------------------------------
 * Inner wrapper
 * ------------------------------------------------------------------------ */

.sun-cta__inner {
	max-width: 1200px;
	margin: 0 auto;
	padding: 16px 24px calc(12px + env(safe-area-inset-bottom, 0px));
	position: relative;
	padding-right: 48px; /* space for close button */
}

/* -------------------------------------------------------------------------
 * Row layout
 * ------------------------------------------------------------------------ */

.sun-cta__row--main {
	display: flex;
	align-items: center;
	gap: 24px;
}

.sun-cta__row--meta {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 16px;
	margin-top: 8px;
}

/* -------------------------------------------------------------------------
 * Image — circular eclipse (desktop only)
 * ------------------------------------------------------------------------ */

.sun-cta__image {
	display: none;
}

/* Desktop: show image and shift content right to clear it.
   Image is position:absolute so padding-left must exceed its width. */
@media (min-width: 1320px) {
	.sun-cta__image {
		display: block;
		position: absolute;
		left: -5px;
		top: 78%;
		transform: translateY(-50%);
		width: 160px;
		pointer-events: none;
	}

	.sun-cta__image::after {
		content: "";
		position: absolute;
		top: 0;
		left: 2px;
		width: 160px;
		height: 160px;
		border-radius: 100%;
		background: linear-gradient(122deg, #ffcc47 25.53%, #ea8123 86.89%);
		transform: translateX(6%) translateY(-2%);
		z-index: -1;
	}

	.sun-cta__image-img {
		display: block;
		width: 100%;
		aspect-ratio: 1;
		object-fit: cover;
		border-radius: 100%;
		opacity: 0;
		transition: opacity 0.4s ease;
	}

	.sun-cta__image-img.sun-cta__image-img--loaded {
		opacity: 1;
	}

	.sun-cta--has-image .sun-cta__inner {
		padding-left: 110px;
	}
}

/* Wide desktops: full-size image */
@media (min-width: 1500px) {
	.sun-cta__image {
		width: 240px;
	}

	.sun-cta__image::after {
		width: 240px;
		height: 240px;
	}

	.sun-cta--has-image .sun-cta__inner {
		padding-left: 160px;
	}
}

/* -------------------------------------------------------------------------
 * Content (eyebrow + headline + body)
 * ------------------------------------------------------------------------ */

.sun-cta__content {
	flex: 1;
	min-width: 0;
}

.sun-cta__eyebrow {
	display: block;
	font-family: var(--helio-f-primary, aktiv-grotesk, sans-serif);
	font-size: 0.6875rem;
	font-weight: 700;
	letter-spacing: 0.13em;
	text-transform: uppercase;
	color: var(--primary-sky-blue, #61e7ff);
	margin-bottom: 4px;
	line-height: 1.4;
}

.sun-cta__headline {
	font-family: var(--helio-f-headline, "Sharp Grotesk", sans-serif);
	font-size: clamp(1.125rem, 1.5vw, 1.375rem);
	font-weight: 700;
	margin: 0 0 4px;
	line-height: 1.3;
	color: #fff;
	max-height: calc(1.3em * 3);
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
}

.sun-cta__body {
	font-size: 0.875rem;
	margin: 0;
	line-height: 1.5;
	opacity: 0.9;
}

.sun-cta__learn-more {
	display: inline-block;
	font-size: 0.75rem;
	color: rgba(255, 255, 255, 0.78);
	text-decoration: underline;
	margin-top: 0.35rem;
}

.sun-cta__learn-more:hover,
.sun-cta__learn-more:focus-visible {
	color: var(--primary-sun-orange, #eb8124);
}

/* -------------------------------------------------------------------------
 * Form wrapper + EA ActionTag form
 * ------------------------------------------------------------------------ */

.sun-cta__form-wrap {
	flex: 0 0 auto;
	width: 550px;
}

.sun-cta__ea-form {
	min-width: 0;
}

/* Override EA ActionTag styles inside our dark popup.
   EA class structure: .at > .at-inner > .at-title, .at-markup, .at-fieldset > .at-row > .at-text/.at-select */

.sun-cta__ea-form .at {
	overflow: visible !important;
}

.sun-cta__ea-form .at .at-inner {
	background-color: transparent !important;
	padding: 0 !important;
	border: none !important;
	box-shadow: none !important;
}

.sun-cta__ea-form .at .at-inner * {
	font-family: var(--helio-f-primary, aktiv-grotesk, sans-serif) !important;
}

/* Hide title, legend, header markup, loading progress bar, and extra EA fields */
.sun-cta__ea-form .at .at-title,
.sun-cta__ea-form .at .at-legend,
.sun-cta__ea-form .at .at-markup.HeaderHtml,
.sun-cta__ea-form .at .at-progress,
.sun-cta__ea-form .at .at-row.PersonalUrl,
.sun-cta__ea-form .at label.PersonalUrl {
	display: none !important;
}

/* Single-row layout — inline styles do the heavy lifting (set by JS
   after at.js renders).  These are CSS fallbacks / supporting rules. */
.sun-cta__ea-form .at .at-fieldset {
	border: 0 !important;
	padding: 0 !important;
	margin: 15px -30px 0 0 !important;
	min-width: 0 !important;
}

/* Labels wrap the inputs in EA — keep visible but collapse label text height */
.sun-cta__ea-form .at .at-row label {
	width: 100% !important;
	font-size: 0 !important;
	line-height: 0 !important;
	margin: 0 !important;
	padding: 0 !important;
}

.sun-cta__ea-form .at .at-row .at-text,
.sun-cta__ea-form .at .at-row .at-select {
	margin: 0 !important;
	padding: 0 !important;
	min-width: 0 !important;
}

/* Zero out at-row internal spacing so inputs and button align */
.sun-cta__ea-form .at .at-row {
	margin: 0 !important;
	padding: 0 !important;
}

.sun-cta__ea-form .at .at-form-submit {
	margin: 0 !important;
	padding: 0 !important;
}

/* Input fields — dark theme */
.sun-cta__ea-form .at .at-row .at-text input,
.sun-cta__ea-form .at .at-row .at-select input,
.sun-cta__ea-form .at .at-row .at-text select,
.sun-cta__ea-form .at .at-row .at-select select {
	background: rgba(255, 255, 255, 0.08) !important;
	border: 2px solid rgba(255, 255, 255, 0.25) !important;
	color: #fff !important;
	border-radius: 6px !important;
	padding: 9px 12px !important;
	font-size: 0.875rem !important;
	height: 40px !important;
	line-height: 1 !important;
}

.sun-cta__ea-form .at .at-row .at-text input::placeholder,
.sun-cta__ea-form .at .at-row .at-select input::placeholder {
	color: rgba(255, 255, 255, 0.55) !important;
}

.sun-cta__ea-form .at .at-row .at-text input:focus,
.sun-cta__ea-form .at .at-row .at-select input:focus,
.sun-cta__ea-form .at .at-row .at-select select:focus {
	border-color: var(--primary-sky-blue, #61e7ff) !important;
	outline: none !important;
}

.sun-cta__ea-form .at .at-row .at-text input:focus-visible,
.sun-cta__ea-form .at .at-row .at-select input:focus-visible,
.sun-cta__ea-form .at .at-row .at-select select:focus-visible {
	outline: 2px solid var(--primary-sky-blue, #61e7ff) !important;
	outline-offset: 2px !important;
}

/* Labels — inline mode hides them, but just in case */
.sun-cta__ea-form .at label {
	color: rgba(255, 255, 255, 0.7) !important;
	font-size: 0.75rem !important;
}

/* Error + info messages — reset font-size/line-height since parent label collapses them */
.sun-cta__ea-form .at .at-row small.error,
.sun-cta__ea-form .at .at-row small.didYouMean.info {
	color: #ff8a8a !important;
	font-size: 0.75rem !important;
	line-height: 1.3 !important;
	display: block !important;
}

/* Submit button */
.sun-cta__ea-form .at .at-form-submit .at-submit {
	background-image:
		linear-gradient(77deg, #ffcc47 25.53%, #ea8123 86.89%),
		linear-gradient(var(--primary-sky-blue, #61e7ff), var(--primary-sky-blue, #61e7ff)) !important;
	background-repeat: no-repeat !important;
	background-size: 0 100%, 100% 100% !important;
	background-color: var(--primary-sky-blue, #61e7ff) !important;
	color: var(--primary-dark-blue, #201d53) !important;
	border: none !important;
	border-radius: 100px !important;
	font-weight: 700 !important;
	font-size: 0.875rem !important;
	cursor: pointer !important;
	transition: background-size 0.35s ease !important;
	padding: 10px 24px !important;
	width: auto !important;
	height: 40px !important;
}

.sun-cta__ea-form .at .at-form-submit .at-submit:hover {
	background-size: 100% 100%, 100% 100% !important;
}

.sun-cta__ea-form .at .at-form-submit .at-submit:focus-visible {
	outline: 2px solid var(--primary-sky-blue, #61e7ff) !important;
	outline-offset: 2px !important;
}

/* All text inside the EA form — white on dark popup */
.sun-cta__ea-form .at p,
.sun-cta__ea-form .at span,
.sun-cta__ea-form .at div,
.sun-cta__ea-form .at .at-markup,
.sun-cta__ea-form .at .at-markup p {
	color: #fff !important;
}

.sun-cta__ea-form .at .at-markup p {
	font-size: 0.875rem !important;
}

/* EA thank-you / confirmation state */
.sun-cta__ea-form .content.thankYou {
	text-align: center;
}

.sun-cta__ea-form .content.thankYou h1,
.sun-cta__ea-form .content.thankYou h2,
.sun-cta__ea-form .content.thankYou h3,
.sun-cta__ea-form .content.thankYou strong {
	color: #fff !important;
	font-family: var(--helio-f-headline, "Sharp Grotesk", aktiv-grotesk, sans-serif);
	font-size: 1.125rem;
}

.sun-cta__ea-form .content.thankYou a {
	color: var(--primary-sky-blue, #61e7ff) !important;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.sun-cta__ea-form .content.thankYou a:hover {
	color: #fff !important;
}

.sun-cta__ea-form .content.thankYou p {
	color: rgba(255, 255, 255, 0.85) !important;
	font-size: 0.9375rem;
	line-height: 1.5;
}

/* Hide the custom form when EA form is active */
.sun-cta__form[hidden] {
	display: none !important;
}

/* EA form loading skeleton */
.sun-cta__ea-skeleton {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 320px;
}

.sun-cta__ea-skeleton__field {
	flex: 1;
	height: 40px;
	border-radius: 6px;
	background: rgba(255, 255, 255, 0.08);
}

.sun-cta__ea-skeleton__btn {
	width: 120px;
	height: 40px;
	border-radius: 100px;
	background: rgba(97, 231, 255, 0.15);
}

.sun-cta__ea-skeleton__field,
.sun-cta__ea-skeleton__btn {
	animation: sun-cta-skeleton-pulse 1.5s ease-in-out infinite;
}

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

@media (prefers-reduced-motion: reduce) {
	.sun-cta__ea-skeleton__field,
	.sun-cta__ea-skeleton__btn {
		animation: none;
	}
}

@media (max-width: 768px) {
	.sun-cta__ea-skeleton {
		flex-direction: column;
		min-width: 0;
		width: 100%;
	}

	.sun-cta__ea-skeleton__field,
	.sun-cta__ea-skeleton__btn {
		width: 100%;
	}
}

/* -------------------------------------------------------------------------
 * Custom form (fallback when no EA form ID)
 * ------------------------------------------------------------------------ */

.sun-cta__form {
	display: flex;
	align-items: flex-end;
	gap: 10px;
	flex-shrink: 0;
}

.sun-cta__field {
	display: flex;
	flex-direction: column;
	gap: 3px;
}

.sun-cta__field label {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.sun-cta__field input {
	padding: 9px 12px;
	border: 2px solid rgba(255, 255, 255, 0.25);
	border-radius: 6px;
	background: rgba(255, 255, 255, 0.08);
	color: #fff;
	font-size: 0.875rem;
	font-family: inherit;
	width: 170px;
	height: 40px;
	box-sizing: border-box;
	transition: border-color 0.2s;
}

.sun-cta__field input:focus {
	border-color: var(--primary-sky-blue, #61e7ff);
	background: rgba(255, 255, 255, 0.12);
	outline: none;
}

.sun-cta__field input:focus-visible {
	outline: 2px solid var(--primary-sky-blue, #61e7ff);
	outline-offset: 2px;
}

.sun-cta__field input::placeholder {
	color: rgba(255, 255, 255, 0.55);
}

.sun-cta__field input[aria-invalid="true"] {
	border-color: #ff8a8a;
}

.sun-cta__field [role="alert"] {
	font-size: 0.75rem;
	color: #ff8a8a;
	min-height: 0;
}

/* Honeypot — visually hidden but not display:none. */
.sun-cta__honeypot {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* -------------------------------------------------------------------------
 * Submit button — pill-shaped like Heliotrope .btn
 * ------------------------------------------------------------------------ */

.sun-cta__submit {
	padding: 10px 24px;
	background-image:
		linear-gradient(77deg, #ffcc47 25.53%, #ea8123 86.89%),
		linear-gradient(var(--primary-sky-blue, #61e7ff), var(--primary-sky-blue, #61e7ff));
	background-repeat: no-repeat;
	background-size: 0 100%, 100% 100%;
	background-color: var(--primary-sky-blue, #61e7ff);
	color: var(--primary-dark-blue, #201d53);
	border: none;
	border-radius: 100px;
	font-size: 0.875rem;
	font-weight: 700;
	font-family: inherit;
	cursor: pointer;
	white-space: nowrap;
	height: 40px;
	min-width: 44px;
	transition: background-size 0.35s ease;
}

.sun-cta__submit:hover {
	background-size: 100% 100%, 100% 100%;
}

.sun-cta__submit:focus-visible {
	outline: 2px solid var(--primary-sky-blue, #61e7ff);
	outline-offset: 2px;
}

.sun-cta__submit:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* -------------------------------------------------------------------------
 * Success message (replaces form after submit)
 * ------------------------------------------------------------------------ */

.sun-cta__success {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 0.9375rem;
	font-weight: 600;
	color: #fff;
}

.sun-cta__success::before {
	content: "\2713";
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border-radius: 100%;
	background: rgba(97, 231, 255, 0.2);
	color: var(--primary-sky-blue, #61e7ff);
	font-size: 1rem;
	font-weight: 700;
	flex-shrink: 0;
}

/* -------------------------------------------------------------------------
 * Meta row: consent
 * ------------------------------------------------------------------------ */

.sun-cta__consent {
	font-size: 0.6875rem;
	color: rgba(255, 255, 255, 0.6);
	margin: 6px 0 0;
	line-height: 1.3;
	text-align: right;
}

.sun-cta__consent a {
	color: inherit;
	text-decoration: underline;
}

/* -------------------------------------------------------------------------
 * Form error banner
 * ------------------------------------------------------------------------ */

.sun-cta__form-error {
	font-size: 0.8125rem;
	color: #ff8a8a;
	margin: 0 0 8px;
	padding: 8px 12px;
	background: rgba(255, 107, 107, 0.1);
	border-radius: 4px;
}

/* -------------------------------------------------------------------------
 * Close button
 * ------------------------------------------------------------------------ */

.sun-cta__close {
	position: absolute;
	top: 8px;
	right: 8px;
	background: none;
	border: none;
	color: rgba(255, 255, 255, 0.7);
	font-size: 1.25rem;
	cursor: pointer;
	width: 44px;
	height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 100px;
	transition: color 0.2s, background 0.2s;
}

.sun-cta__close:hover {
	color: #fff;
	background: rgba(255, 255, 255, 0.1);
}

.sun-cta__close:focus-visible {
	outline: 2px solid var(--primary-sky-blue, #61e7ff);
	outline-offset: 2px;
}

/* -------------------------------------------------------------------------
 * Screen reader live region
 * ------------------------------------------------------------------------ */

.sun-cta__sr-announce {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* -------------------------------------------------------------------------
 * Body spacer — JS dynamically adjusts via popup.offsetHeight
 * ------------------------------------------------------------------------ */

body.sun-cta-visible {
	padding-bottom: 120px;
	/* Prevent the fixed popup from covering focused elements (WCAG 2.2 SC 2.4.11).
	   JS updates paddingBottom dynamically; scroll-padding ensures the browser
	   scrolls focused elements clear of the popup. */
	scroll-padding-bottom: 120px;
}

/* -------------------------------------------------------------------------
 * Geo state selector (manual override)
 * ------------------------------------------------------------------------ */

.sun-cta__geo-change {
	margin-top: 6px;
	text-align: right;
}

.sun-cta__geo-btn {
	background: none;
	border: none;
	padding: 0;
	font-family: inherit;
	font-size: 0.6875rem;
	color: rgba(255, 255, 255, 0.6);
	text-decoration: underline;
	cursor: pointer;
	line-height: 1.3;
}

.sun-cta__geo-btn:hover,
.sun-cta__geo-btn:focus-visible {
	color: #fff;
}

.sun-cta__geo-btn:focus-visible {
	outline: 2px solid var(--primary-sky-blue, #61e7ff);
	outline-offset: 2px;
}

.sun-cta__geo-select {
	font-family: inherit;
	font-size: 0.6875rem;
	color: #fff;
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid rgba(255, 255, 255, 0.25);
	border-radius: 4px;
	padding: 4px 8px;
	cursor: pointer;
	max-width: 200px;
}

.sun-cta__geo-select:focus-visible {
	outline: 2px solid var(--primary-sky-blue, #61e7ff);
	outline-offset: 2px;
}

.sun-cta__geo-select option {
	background: var(--primary-dark-blue, #201d53);
	color: #fff;
}

/* -------------------------------------------------------------------------
 * Mobile layout
 * ------------------------------------------------------------------------ */

@media (max-width: 768px) {
	.sun-cta {
		max-height: 85vh;
		max-height: 85dvh;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		overscroll-behavior: contain;
	}

	.sun-cta__inner {
		padding: 14px 16px calc(10px + env(safe-area-inset-bottom, 0px));
		padding-right: 48px;
	}

	.sun-cta__row--main {
		flex-direction: column;
		align-items: stretch;
		gap: 10px;
	}

	.sun-cta__consent {
		text-align: center;
	}

	.sun-cta__geo-change {
		text-align: center;
	}

	.sun-cta__eyebrow {
		font-size: 0.625rem;
	}

	.sun-cta__headline {
		font-size: 0.9375rem;
	}

	.sun-cta__body {
		font-size: 0.75rem;
	}

	.sun-cta__form {
		flex-wrap: wrap;
		gap: 8px;
	}

	.sun-cta__field {
		flex: 1;
		min-width: 100px;
	}

	.sun-cta__field input {
		width: 100%;
		height: 38px;
		font-size: 1rem; /* 16px — prevents iOS Safari auto-zoom */
	}

	.sun-cta__submit {
		width: 100%;
		height: 38px;
	}

	.sun-cta__form-wrap {
		width: auto;
	}

	/* EA form: remove min-width, stack fields vertically */
	.sun-cta__ea-form {
		min-width: 0;
		width: 100%;
	}

	.sun-cta__ea-form .at .at-fieldset,
	.sun-cta__ea-form .at .at-fields {
		display: block !important;
		flex-direction: column !important;
	}

	.sun-cta__ea-form .at .at-row {
		display: block !important;
		width: 100% !important;
		margin-bottom: 8px !important;
		text-align: center !important;
	}

	.sun-cta__ea-form .at .at-row.PersonalUrl,
	.sun-cta__ea-form .at label.PersonalUrl {
		display: none !important;
	}

	.sun-cta__ea-form .at .at-row .at-text,
	.sun-cta__ea-form .at .at-row .at-select {
		width: 100% !important;
		display: block !important;
	}

	.sun-cta__ea-form .at .at-row .at-text input,
	.sun-cta__ea-form .at .at-row .at-select input,
	.sun-cta__ea-form .at .at-row .at-text select,
	.sun-cta__ea-form .at .at-row .at-select select {
		width: 100% !important;
		font-size: 1rem !important; /* prevents iOS zoom */
	}

	.sun-cta__ea-form .at form {
		display: block !important;
	}

	.sun-cta__ea-form .at form {
		display: block !important;
	}

	.sun-cta__ea-form .at .at-fieldset {
		min-width: 0 !important;
		width: 100% !important;
	}

	.sun-cta__ea-form .at .at-form-submit {
		margin-top: 8px !important;
		width: 100% !important;
		text-align: center !important;
	}

	.sun-cta__ea-form .at .at-form-submit .at-submit {
		width: 100% !important;
		margin: 0 auto 10px auto !important;
		display: block !important;
	}

	body.sun-cta-visible {
		padding-bottom: 40px;
		scroll-padding-bottom: 40px;
	}
}

/* Short viewports — hide body text to save space */
@media (max-width: 768px) and (max-height: 600px) {
	.sun-cta__body {
		display: none;
	}
}
