/**
 * Frontend styles.
 *
 * Every colour is a --wpte-cid-brand-* custom property with a literal fallback,
 * so the block still looks right if includes/BrandStyle.php never emits its
 * inline :root block (for instance when another plugin strips inline styles).
 *
 * @package WPTE_CID
 */

.wpte-cid {
	margin: 0 0 1.5em;
}

.wpte-cid__header {
	margin-bottom: 1em;
}

.wpte-cid__title {
	margin: 0 0 0.35em;
	font-size: 1.15em;
	line-height: 1.3;
	color: var( --wpte-cid-brand-primary, #054149 );
}

.wpte-cid__desc {
	margin: 0;
	font-size: 0.9em;
	line-height: 1.5;
	color: var( --wpte-cid-brand-muted, #507a80 );
}

.wpte-cid__list {
	display: grid;
	/* Track minimum matches the card's own min-width so the grid does not fight it. */
	grid-template-columns: repeat( auto-fill, minmax( 350px, 1fr ) );
	gap: 16px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.wpte-cid__list > li {
	/* !important: Flatsome sets its own list margins at higher specificity. */
	margin: 0 !important;
	padding: 0;
	list-style: none;
}

.wpte-cid-card__link {
	display: flex;
	flex-direction: row;
	align-items: stretch;
	min-width: 350px;
	/* Never exceed the container: min-width alone would overflow a narrow
	   column. The media query below drops the minimum entirely on small
	   screens and in the sidebar. */
	max-width: 100%;
	height: 100%;
	overflow: hidden;
	border: 1px solid var( --wpte-cid-brand-border, #cdd9db );
	border-radius: 8px;
	background: var( --wpte-cid-brand-surface-soft, #fff7f0 );
	color: inherit;
	text-decoration: none;
	transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.wpte-cid-card__link:hover,
.wpte-cid-card__link:focus-visible {
	border-color: var( --wpte-cid-brand-accent, #567329 );
	box-shadow: 0 2px 10px rgba( 5, 65, 73, 0.12 );
	transform: translateY( -2px );
}

.wpte-cid-card__thumb {
	display: flex;
	flex: 0 0 130px;
	align-items: center;
	justify-content: center;
	width: 130px;
	overflow: hidden;
	background: var( --wpte-cid-brand-surface, #ffebd9 );
}

.wpte-cid-card__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.wpte-cid-card__thumb-fallback {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 46%;
	color: var( --wpte-cid-brand-primary, #054149 );
	opacity: 0.65;
}

.wpte-cid-card__thumb-fallback svg {
	width: 100%;
	height: auto;
	display: block;
}

.wpte-cid-card__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	justify-content: center;
	gap: 2px;
	min-width: 0;
	padding: 14px 16px;
}

.wpte-cid-card__title {
	display: block;
	font-weight: 600;
	font-size: 0.92em;
	line-height: 1.35;
	color: var( --wpte-cid-brand-primary, #054149 );
}

.wpte-cid-card__meta {
	display: block;
	margin-top: 4px;
	font-size: 0.78em;
	color: var( --wpte-cid-brand-muted, #507a80 );
}

.wpte-cid-card__cta {
	display: inline-block;
	align-self: flex-start;
	margin-top: 10px;
	padding: 9px 16px;
	border-radius: 4px;
	background: var( --wpte-cid-brand-accent, #567329 );
	color: #fff;
	font-size: 0.85em;
	font-weight: 600;
	text-align: center;
}

.wpte-cid__noscript {
	margin-top: 0.75em;
	font-size: 0.85em;
	color: var( --wpte-cid-brand-danger, #db2a2a );
}

/*
 * A secondary, text-link treatment - deliberately smaller and lighter than
 * WP Travel Engine's own `.wpte-button` ("View Details") rather than
 * matching its size. The underline grows in from the left on hover and
 * shrinks back out the same way on hover-out, via a `background-size`
 * transition on the label only (not the icon) - the standard non-JS way to
 * animate an underline in both directions with one rule, no ::after
 * positioning needed.
 */
.wpte-cid-archive-btn {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 0;
	border: none;
	background: none;
	font-size: 0.85em;
	font-weight: 600;
	white-space: nowrap;
	text-decoration: none;
	color: var( --wpte-cid-brand-primary, #054149 );
}

.wpte-cid-archive-btn__label {
	background-image: linear-gradient( currentColor, currentColor );
	background-repeat: no-repeat;
	background-position: 0 100%;
	background-size: 0% 1px;
	padding-bottom: 1px;
	transition: background-size 0.25s ease;
}

.wpte-cid-archive-btn:hover .wpte-cid-archive-btn__label {
	background-size: 100% 1px;
}

.wpte-cid-archive-btn__icon {
	flex: 0 0 auto;
	display: block;
	width: 14px;
	height: 14px;
	color: var( --wpte-cid-brand-primary, #054149 );
}

/* The inline-glyph fallback nests an <svg>; the uploaded icon does not. */
.wpte-cid-archive-btn__icon svg {
	width: 100%;
	height: 100%;
	display: block;
}

/*
 * Narrow containers: the pricing-widget sidebar is typically ~300px, which is
 * less than the card's 350px minimum. Drop the minimum and return to the
 * stacked layout there rather than letting the card overflow its column.
 */
.widget .wpte-cid__list {
	grid-template-columns: 1fr;
}

.widget .wpte-cid-card__link {
	flex-direction: column;
	min-width: 0;
}

.widget .wpte-cid-card__thumb {
	flex: 0 0 auto;
	width: 100%;
	aspect-ratio: 4 / 5;
}

.widget .wpte-cid-card__cta {
	align-self: stretch;
}

@media ( max-width: 480px ) {
	.wpte-cid__list {
		grid-template-columns: 1fr;
	}

	.wpte-cid-card__link {
		flex-direction: column;
		min-width: 0;
	}

	.wpte-cid-card__thumb {
		flex: 0 0 auto;
		width: 100%;
		aspect-ratio: 4 / 5;
	}

	.wpte-cid-card__cta {
		align-self: stretch;
	}
}

/* --- Popup dialog --- */

.wpte-cid-modal[hidden] {
	display: none;
}

.wpte-cid-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.wpte-cid-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba( 5, 65, 73, 0.55 );
}

.wpte-cid-modal__panel {
	position: relative;
	width: 100%;
	max-width: 420px;
	max-height: 90vh;
	overflow-y: auto;
	padding: 28px 24px 24px;
	border-radius: 10px;
	background: var( --wpte-cid-brand-surface-soft, #fff7f0 );
	box-shadow: 0 18px 50px rgba( 0, 0, 0, 0.25 );
}

.wpte-cid-modal__close {
	position: absolute;
	top: 8px;
	right: 10px;
	padding: 4px 8px;
	border: 0;
	background: none;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	color: var( --wpte-cid-brand-muted, #507a80 );
}

.wpte-cid-modal__title {
	margin: 0 0 0.4em;
	font-size: 1.2em;
	color: var( --wpte-cid-brand-primary, #054149 );
}

.wpte-cid-modal__desc {
	margin: 0 0 1em;
	font-size: 0.9em;
	color: var( --wpte-cid-brand-muted, #507a80 );
}

.wpte-cid-modal__label {
	display: block;
	margin-bottom: 4px;
	font-size: 0.85em;
	font-weight: 600;
}

.wpte-cid-modal__input {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid var( --wpte-cid-brand-border, #cdd9db );
	border-radius: 4px;
	font-size: 1em;
	background: #fff;
}

.wpte-cid-modal__consent {
	display: flex;
	gap: 8px;
	align-items: flex-start;
	margin-top: 12px;
	font-size: 0.8em;
	line-height: 1.45;
	color: var( --wpte-cid-brand-muted, #507a80 );
}

/*
 * Positioned off-screen rather than display:none. Some bots specifically detect
 * display:none honeypots and skip them.
 */
.wpte-cid-modal__hp {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.wpte-cid-modal__submit {
	width: 100%;
	margin-top: 16px;
	padding: 11px 14px;
	border: 0;
	border-radius: 4px;
	background: var( --wpte-cid-brand-accent, #567329 );
	color: #fff;
	font-size: 0.95em;
	font-weight: 600;
	cursor: pointer;
}

.wpte-cid-modal__submit[disabled] {
	opacity: 0.6;
	cursor: default;
}

.wpte-cid-modal__status {
	margin: 12px 0 0;
	min-height: 1.2em;
	font-size: 0.85em;
	color: var( --wpte-cid-brand-muted, #507a80 );
}

.wpte-cid-modal__status.is-error {
	color: var( --wpte-cid-brand-danger, #db2a2a );
}

body.wpte-cid-modal-open {
	overflow: hidden;
}

/*
 * Completed state: the download has started, so the description and every form
 * control are hidden, leaving only the status line under the new heading. One
 * class toggle rather than per-element inline styles, so resetting is a single
 * classList.remove() in public.js.
 */
.wpte-cid-modal.is-complete .wpte-cid-modal__desc,
.wpte-cid-modal.is-complete .wpte-cid-modal__form > *:not( .wpte-cid-modal__status ) {
	display: none;
}

.wpte-cid-modal.is-complete .wpte-cid-modal__status {
	margin: 0;
	font-size: 0.95em;
	color: var( --wpte-cid-brand-primary, #054149 );
}

.wpte-cid-modal__recaptcha {
	margin: 12px 0 0;
	font-size: 0.72em;
	line-height: 1.45;
	color: var( --wpte-cid-brand-muted, #507a80 );
}

.wpte-cid-modal__recaptcha a {
	color: inherit;
	text-decoration: underline;
}

/*
 * Google's floating badge is suppressed. This is only permitted because the
 * attribution text above is shown instead - see the matching comment in
 * includes/Frontend/Popup.php. Do not remove one without restoring the other.
 */
.grecaptcha-badge {
	visibility: hidden;
}

/* --- Direct-mode PDF viewer: EmbedPDF inside the FancyBox lightbox --- */

.wpte-cid-viewer {
	padding: 0;
	width: 90vw;
	max-width: 900px;
	height: 85vh;
	overflow: hidden;
	border-radius: 8px;
	background: #fff;
}

.wpte-cid-viewer__bar {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	align-items: center;
	justify-content: space-between;
	padding: 12px 16px;
	background: var( --wpte-cid-brand-surface-soft, #fff7f0 );
	border-bottom: 1px solid var( --wpte-cid-brand-border, #cdd9db );
}

.wpte-cid-viewer__title {
	font-weight: 600;
	font-size: 0.95em;
	color: var( --wpte-cid-brand-primary, #054149 );
}

.wpte-cid-viewer__download {
	padding: 8px 16px;
	border-radius: 4px;
	background: var( --wpte-cid-brand-accent, #567329 );
	color: #fff;
	font-size: 0.85em;
	font-weight: 600;
	text-decoration: none;
}

.wpte-cid-viewer__download:hover,
.wpte-cid-viewer__download:focus-visible {
	color: #fff;
	opacity: 0.9;
}

.wpte-cid-viewer__frame {
	position: relative;
	height: 100%;
	width: 100%;
	overflow: hidden;
	border: 0;
	background: #f0f0f1;
}

/*
 * Shown while the EmbedPDF module and its WASM engine are downloading. The text
 * comes from strings.viewerLoading via a data-loading attribute, so it stays
 * translatable without JavaScript writing any markup.
 */
.wpte-cid-viewer__frame.is-loading::after {
	content: attr( data-loading );
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	font-size: 0.85em;
	text-align: center;
	color: var( --wpte-cid-brand-muted, #507a80 );
}

.wpte-cid-viewer__fallback {
	margin: 0;
	padding: 10px 16px;
	border-top: 1px solid var( --wpte-cid-brand-border, #cdd9db );
	font-size: 0.78em;
	text-align: center;
	color: var( --wpte-cid-brand-muted, #507a80 );
}

@media ( max-width: 640px ) {
	.wpte-cid-viewer {
		width: 96vw;
		height: 80vh;
	}

	.wpte-cid-viewer__bar {
		justify-content: center;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.wpte-cid-card__link {
		transition: none;
	}

	.wpte-cid-card__link:hover,
	.wpte-cid-card__link:focus-visible {
		transform: none;
	}
}

@media print {
	.wpte-cid,
	.wpte-cid-modal {
		display: none;
	}
}
