/**
 * ss4y/contact-form — formulaire de contact / devis.
 *
 * Le formulaire est posé dans une carte blanche, quelle que soit sa source :
 * les styles de champs valent aussi bien pour le formulaire du thème que pour
 * un Contact Form 7, dont le gabarit reprend les mêmes classes.
 *
 * Les règles visant CF7 sont préfixées par `.ss4y-form-section` : la feuille
 * de l'extension utilise `.wpcf7 form .wpcf7-*`, qu'un sélecteur à deux
 * classes ne suffirait pas à dépasser.
 */

.ss4y-form-section,
.ss4y-form-section *,
.ss4y-form-section *::before,
.ss4y-form-section *::after {
	box-sizing: border-box;
}

.ss4y-form-section {
	padding-block: var(--wp--preset--spacing--section);
	scroll-margin-top: var(--wp--custom--header--height);
}

.ss4y-form-section--bg-surface {
	background: var(--wp--preset--color--surface);
}

.ss4y-form-section--bg-white {
	background: var(--wp--preset--color--white);
}

.ss4y-form-section__inner {
	max-width: 46rem;
	margin-inline: auto;
	padding-inline: var(--wp--custom--section--padding-inline);
}

/* ─── En-tête ────────────────────────────────────────────────────────────── */
.ss4y-form-section__header {
	margin-block-end: var(--wp--preset--spacing--lg);
	text-align: center;
}

.ss4y-form-section__title {
	margin: 0;
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--title-l);
	font-weight: 700;
	line-height: 1.18;
	letter-spacing: -0.01em;
	color: var(--wp--preset--color--text);
}

.ss4y-form-section__intro {
	margin: var(--wp--preset--spacing--sm) auto 0;
	max-width: 52ch;
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.7;
	color: var(--wp--preset--color--text-muted);
}

/* ─── La carte ───────────────────────────────────────────────────────────── */
.ss4y-form-section .ss4y-form {
	padding: var(--wp--preset--spacing--lg);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--lg);
	background: var(--wp--preset--color--white);
	box-shadow: var(--wp--custom--shadow--md);
}

/* ─── Messages de retour ─────────────────────────────────────────────────── */
.ss4y-form__notice {
	margin: 0 0 var(--wp--preset--spacing--md);
	padding: 0.9rem 1.1rem;
	border-inline-start: 4px solid;
	border-radius: var(--wp--custom--radius--sm);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
}

.ss4y-form__notice--success {
	background: #edf7ee;
	border-color: #2e7d32;
	color: #1b5e20;
}

.ss4y-form__notice--error {
	background: #fdecec;
	border-color: #c62828;
	color: #8e1c1c;
}

/* ─── Grille de champs ───────────────────────────────────────────────────── */
.ss4y-form__grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--wp--preset--spacing--sm);
}

.ss4y-form__field {
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
}

.ss4y-form__field--wide {
	grid-column: 1 / -1;
}

.ss4y-form-section label {
	font-size: 0.8rem;
	font-weight: 600;
	letter-spacing: 0.01em;
	color: var(--wp--preset--color--text);
}

.ss4y-form__required {
	margin-inline-start: 0.15em;
	color: var(--wp--preset--color--primary);
}

/* ─── Champs ─────────────────────────────────────────────────────────────── */
.ss4y-form-section input[type="text"],
.ss4y-form-section input[type="email"],
.ss4y-form-section input[type="tel"],
.ss4y-form-section select,
.ss4y-form-section textarea {
	width: 100%;
	padding: 0.85rem 1rem;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--md);
	background: var(--wp--preset--color--white);
	font-family: inherit;
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.4;
	color: var(--wp--preset--color--text);
	transition: border-color var(--wp--custom--transition), box-shadow var(--wp--custom--transition);
}

.ss4y-form-section input::placeholder,
.ss4y-form-section textarea::placeholder {
	color: var(--wp--preset--color--text-muted);
	opacity: 0.7;
}

.ss4y-form-section input:focus,
.ss4y-form-section select:focus,
.ss4y-form-section textarea:focus {
	border-color: var(--wp--preset--color--primary);
	box-shadow: 0 0 0 3px rgb(31 119 143 / 18%);
	outline: none;
}

.ss4y-form-section textarea {
	resize: vertical;
	min-height: 9.5rem;
}

/* La flèche native disparaît selon les navigateurs : on la redessine. */
.ss4y-form-section select {
	appearance: none;
	padding-inline-end: 2.4rem;
	background-image:
		linear-gradient(45deg, transparent 50%, currentcolor 50%),
		linear-gradient(135deg, currentcolor 50%, transparent 50%);
	background-position: calc(100% - 1.15rem) 55%, calc(100% - 0.8rem) 55%;
	background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
	background-repeat: no-repeat;
}

/* Piège à robots : hors écran mais lisible par les scripts automatisés. */
.ss4y-form__hp {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* ─── Consentement & envoi ───────────────────────────────────────────────── */
.ss4y-form__consent {
	display: flex;
	align-items: flex-start;
	gap: 0.6rem;
	margin-block: var(--wp--preset--spacing--md) 0;
}

.ss4y-form__consent input {
	margin-block-start: 0.2rem;
	flex-shrink: 0;
	accent-color: var(--wp--preset--color--primary);
}

.ss4y-form-section .ss4y-form__consent label {
	font-weight: 400;
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--text-muted);
	line-height: 1.55;
}

.ss4y-form__submit {
	margin-block: var(--wp--preset--spacing--md) 0;
}

.ss4y-form-section .ss4y-form__submit button,
.ss4y-form-section .wpcf7-submit {
	padding: 0.9rem 2rem;
	border: 0;
	border-radius: var(--wp--custom--radius--pill);
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--white);
	font-family: inherit;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	cursor: pointer;
	transition: background-color var(--wp--custom--transition);
}

.ss4y-form-section .ss4y-form__submit button:hover,
.ss4y-form-section .wpcf7-submit:hover,
.ss4y-form-section .wpcf7-submit:focus-visible {
	background: var(--wp--preset--color--primary-dark);
}

/* ─── Spécificités Contact Form 7 ────────────────────────────────────────── */
.ss4y-form-section .wpcf7-form-control-wrap {
	display: block;
}

.ss4y-form-section .wpcf7-acceptance .wpcf7-list-item {
	margin: 0;
}

.ss4y-form-section .wpcf7-acceptance label {
	display: flex;
	align-items: flex-start;
	gap: 0.6rem;
	font-weight: 400;
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.55;
	color: var(--wp--preset--color--text-muted);
}

.ss4y-form-section .wpcf7-not-valid {
	border-color: #c62828;
}

.ss4y-form-section .wpcf7-not-valid-tip {
	margin-block-start: 0.3rem;
	font-size: 0.78rem;
	font-weight: 500;
	color: #c62828;
}

.ss4y-form-section .wpcf7 form .wpcf7-response-output {
	margin: var(--wp--preset--spacing--md) 0 0;
	padding: 0.9rem 1.1rem;
	border: 0;
	border-inline-start: 4px solid var(--wp--preset--color--primary);
	border-radius: var(--wp--custom--radius--sm);
	background: var(--wp--preset--color--surface);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
	color: var(--wp--preset--color--text);
}

.ss4y-form-section .wpcf7 form.sent .wpcf7-response-output {
	border-color: #2e7d32;
	background: #edf7ee;
	color: #1b5e20;
}

.ss4y-form-section .wpcf7 form.invalid .wpcf7-response-output,
.ss4y-form-section .wpcf7 form.unaccepted .wpcf7-response-output,
.ss4y-form-section .wpcf7 form.spam .wpcf7-response-output,
.ss4y-form-section .wpcf7 form.failed .wpcf7-response-output {
	border-color: #c62828;
	background: #fdecec;
	color: #8e1c1c;
}

.ss4y-form-section .wpcf7-spinner {
	margin-inline-start: 0.75rem;
}

/* ─── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 700px) {

	.ss4y-form-section .ss4y-form {
		padding: var(--wp--preset--spacing--md);
	}

	.ss4y-form__grid {
		grid-template-columns: minmax(0, 1fr);
	}

	.ss4y-form-section .ss4y-form__submit button,
	.ss4y-form-section .wpcf7-submit {
		width: 100%;
	}
}

@media (prefers-reduced-motion: reduce) {

	.ss4y-form-section input,
	.ss4y-form-section select,
	.ss4y-form-section textarea,
	.ss4y-form-section .wpcf7-submit {
		transition: none;
	}
}

/* ─── Disposition en deux colonnes ─────────────────────────────────────────
   Le formulaire à gauche, les autres moyens de contact à droite. La colonne
   de droite disparaît d'elle-même si aucun moyen n'est renseigné. */
.ss4y-form-section__inner--split {
	max-width: var(--wp--style--global--content-size, 1200px);
}

.ss4y-form-section__inner--split .ss4y-form-section__cols {
	display: grid;
	grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
	gap: var(--wp--preset--spacing--xl);
	align-items: start;
}

.ss4y-form-section__aside-title {
	margin: 0 0 var(--wp--preset--spacing--md);
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--title-s);
	font-weight: 700;
	color: var(--wp--preset--color--text);
}

.ss4y-form-section__aside-list {
	margin: 0;
	padding: 0;
	list-style: none;
	display: grid;
	gap: var(--wp--preset--spacing--md);
}

.ss4y-form-section__aside-item {
	display: flex;
	align-items: flex-start;
	gap: var(--wp--preset--spacing--sm);
}

.ss4y-form-section__aside-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.6rem;
	height: 2.6rem;
	flex-shrink: 0;
	border-radius: var(--wp--custom--radius--md);
	background: rgb(31 119 143 / 10%);
	color: var(--wp--preset--color--primary);
}

.ss4y-form-section__aside-icon {
	width: 1.2rem;
	height: 1.2rem;
}

.ss4y-form-section__aside-label {
	margin: 0;
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 700;
	color: var(--wp--preset--color--text);
}

.ss4y-form-section__aside-text {
	margin: 0.25rem 0 0;
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.6;
	color: var(--wp--preset--color--text-muted);
}

.ss4y-form-section__aside-text a {
	color: inherit;
	text-decoration: none;
}

.ss4y-form-section__aside-text a:hover,
.ss4y-form-section__aside-text a:focus-visible {
	color: var(--wp--preset--color--primary);
	text-decoration: underline;
}

/* En deux colonnes, l'en-tête s'aligne à gauche comme le formulaire. */
.ss4y-form-section__inner--split .ss4y-form-section__header {
	text-align: start;
}

.ss4y-form-section__inner--split .ss4y-form-section__intro {
	margin-inline: 0;
	max-width: 60ch;
}

@media (max-width: 900px) {

	.ss4y-form-section__inner--split .ss4y-form-section__cols {
		grid-template-columns: minmax(0, 1fr);
		gap: var(--wp--preset--spacing--lg);
	}
}

/* ─── Formulaire Tally ─────────────────────────────────────────────────────
   Le formulaire est servi par Tally dans une <iframe>. Sa hauteur est fixée
   par le bloc, puis ajustée au contenu par le script de Tally quand il se
   charge. */
.ss4y-form__tally {
	display: block;

	/*
	 * `width: 1px` + `min-width: 100%` plutôt que `width: 100%` : sur iOS, une
	 * iframe en largeur relative s'étire à la largeur de son contenu et déborde
	 * de la colonne. C'est la parade retenue par iframe-resizer, la brique que
	 * Tally utilise pour redimensionner le cadre.
	 */
	width: 1px;
	min-width: 100%;
	border: 0;
}
