/*
 * Gravipack forms (Contact, Devis) and the international phone input.
 * The theme styles .gp-field, .gp-btn and the page; this file only makes the components
 * usable on their own (layout, error states, focus) with the design tokens and currentColor,
 * so they work on the light (paper) and dark views.
 */

.gp-form {
	display: grid;
	gap: 18px;
}

.gp-form__two {
	display: grid;
	gap: 18px;
}

@media (min-width: 640px) {
	.gp-form__two {
		grid-template-columns: 1fr 1fr;
		row-gap: 0; /* the rows are the fields' subgrid tracks (label, error, control, hint): no gap between them */
	}

	/* Side by side, the two fields share rows (label, error, control, hint), so their controls line up
	   even when one label wraps or only one field has an error. */
	.gp-form__two > .gp-field {
		grid-row: span 4;
		grid-template-rows: subgrid;
		row-gap: 0;
	}

	.gp-form__two > .gp-field > label {
		grid-row: 1;
		align-self: end;
		margin-bottom: 6px;
	}

	.gp-form__two > .gp-field > .gp-field__error {
		grid-row: 2;
		margin-bottom: 6px;
	}

	.gp-form__two > .gp-field > :not(label, .gp-field__error, .gp-field__hint) {
		grid-row: 3;
	}

	.gp-form__two > .gp-field > .gp-field__hint {
		grid-row: 4;
		margin-top: 6px;
	}
}

/* ---------- Devis form: billing and delivery addresses (forms.php gp_form_address_group(), checkout.js Address) ----------
   As in the client mock-up (p. 2): one field per address, its icon at the start (billing: contact card, delivery: map
   pin) and a circled-chevron button at the end; country, postcode and city sit in a panel under it.
   - The server prints the panel open: no JavaScript, an error or any value shows every part.
   - .gp-address--js (inline script of forms.php, then checkout.js): the chevron and « Saisir l’adresse manuellement »
     work; .gp-address--collapsed folds the panel (grid-template-rows 0fr, inert, visibility hidden once folded).
   - .gp-address--ready: transitions, never on the first state; .gp-address--instant: one change without transition.
   The form sits on the light paper card in both schemes and the fields are white: paper tokens only. */
.gp-address {
	display: grid;
	min-width: 0;
}

.gp-address__control {
	position: relative;
}

.gp-address .gp-address__input {
	padding-left: 46px;
	text-overflow: ellipsis; /* « Rechercher une adr… » in a 320 px screen, not a cut letter */
	background-repeat: no-repeat;
	background-position: 15px center;
	background-size: 20px 20px;
}

.gp-address--billing .gp-address__input {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23575a61' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='4.5' width='17' height='16' rx='3'/%3E%3Cpath d='M8.5 2.75v3.5M15.5 2.75v3.5'/%3E%3Ccircle cx='12' cy='11' r='2.75'/%3E%3Cpath d='M7.25 18.25c.85-1.9 2.6-3 4.75-3s3.9 1.1 4.75 3'/%3E%3C/svg%3E");
}

.gp-address--shipping .gp-address__input {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23575a61' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 18.5s-5.5-4.6-5.5-9.25a5.5 5.5 0 0 1 11 0c0 4.65-5.5 9.25-5.5 9.25z'/%3E%3Ccircle cx='12' cy='9.25' r='2'/%3E%3Cpath d='M8 16.4c-2.4.4-4 1.2-4 2.1 0 1.4 3.6 2.5 8 2.5s8-1.1 8-2.5c0-.9-1.6-1.7-4-2.1'/%3E%3C/svg%3E");
}

/* Circled chevron: a real button (aria-expanded, aria-controls), 44 × 44 px inside the field, text never under it. */
.gp-address__toggle {
	display: none;
}

.gp-address--js .gp-address__input {
	padding-right: 52px;
}

.gp-address--js .gp-address__toggle {
	position: absolute;
	top: 50%;
	right: 3px;
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	margin: -22px 0 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: var(--paper-muted, #575a61);
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.gp-address__toggle::before {
	content: "";
	position: absolute;
	inset: 6px;
	border-radius: 50%;
	background: var(--paper-2, #e9e7e0);
	opacity: 0;
	transform: scale(.6);
}

.gp-address__chevron {
	position: relative;
	display: block;
}

.gp-address__toggle[aria-expanded="true"] .gp-address__chevron {
	transform: rotate(180deg);
}

.gp-address__toggle:focus-visible {
	outline: 2px solid var(--paper-ink, #121316);
	outline-offset: -2px;
}

@media (hover: hover) {
	.gp-address__toggle:hover {
		color: var(--paper-ink, #121316);
	}

	.gp-address__toggle:hover::before {
		opacity: 1;
		transform: none;
	}
}

/* « Saisir l’adresse manuellement (ou hors de France) »: under the folded field only. */
.gp-address__manual-row {
	display: none;
}

.gp-address--js .gp-address__manual-row {
	display: grid;
	grid-template-rows: 0fr;
	visibility: hidden;
}

.gp-address--js.gp-address--collapsed .gp-address__manual-row {
	grid-template-rows: 1fr;
	visibility: visible;
}

/* Clipped while it folds; the padding keeps room for the focus ring. */
.gp-address__manual-inner,
.gp-address__inner {
	min-height: 0;
	margin: 0 -4px -4px;
	padding: 0 4px 4px;
	overflow: hidden;
}

.gp-address__manual {
	display: inline-flex;
	align-items: center;
	min-height: 32px;
	margin: 4px 0 0;
	padding: 4px 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	font-size: .875rem;
	font-weight: 600;
	line-height: 1.3;
	text-align: left;
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
	text-decoration-color: rgba(18, 19, 22, .4);
	cursor: pointer;
}

.gp-address__manual-more {
	white-space: nowrap;
}

.gp-address--js:not(.gp-address--collapsed) .gp-address__manual {
	opacity: 0;
}

.gp-address__manual:focus-visible {
	outline: 2px solid var(--paper-ink, #121316);
	outline-offset: 2px;
	border-radius: 4px;
}

@media (hover: hover) {
	.gp-address__manual:hover {
		text-decoration-color: currentColor;
	}
}

/* The panel: country first (the search follows it), then postcode and city. */
.gp-address__parts {
	display: grid;
	grid-template-rows: 1fr;
}

.gp-address--collapsed .gp-address__parts {
	grid-template-rows: 0fr;
	visibility: hidden;
}

.gp-address__content {
	padding-top: 14px;
	container-type: inline-size;
}

.gp-address--collapsed .gp-address__content {
	opacity: 0;
	transform: translateY(-6px);
}

/* Narrow panels (phones, enlarged text): country, postcode and city one under the other, so an error message keeps
   the full width. From 24em: country on its own row, postcode and city side by side; from 36em: three columns.
   Fields of a row share rows (label, error, control: subgrid), so their controls line up when only one of them has
   an error or a label wraps. Equal columns leave room for the messages and for long country names. */
.gp-address__grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	column-gap: 12px;
}

.gp-address__grid > .gp-field {
	grid-row: span 3;
	grid-template-rows: subgrid;
	grid-template-columns: minmax(0, 1fr);
	row-gap: 0;
}

.gp-address__grid > .gp-field:not(:last-child) {
	margin-bottom: 16px;
}

.gp-address__grid > .gp-field > label {
	grid-row: 1;
	align-self: end;
	margin-bottom: 6px;
	font-size: .9em;
	font-weight: 500;
}

.gp-address__grid > .gp-field > .gp-field__error {
	grid-row: 2;
	margin-bottom: 6px;
}

.gp-address__grid > .gp-field > :not(label, .gp-field__error) {
	grid-row: 3;
}

@container (min-width: 24em) {
	.gp-address__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.gp-address__grid > .gp-address__country {
		grid-column: 1 / -1;
	}

	.gp-address__grid > .gp-field.gp-address__postcode,
	.gp-address__grid > .gp-field.gp-address__city {
		margin-bottom: 0;
	}

	/* No postcode in this country (United Arab Emirates…): the city takes the row. */
	.gp-address__postcode[hidden] + .gp-address__city {
		grid-column: 1 / -1;
	}
}

@container (min-width: 36em) {
	.gp-address__grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		column-gap: 16px;
	}

	.gp-address__grid > .gp-field.gp-address__country {
		grid-column: auto;
		margin-bottom: 0;
	}

	.gp-address__postcode[hidden] + .gp-address__city {
		grid-column: span 2;
	}
}

/* Motion: the panel unfolds (rows 0fr → 1fr) while its content fades in, the chevron turns, the manual link folds
   away; 220–280 ms with the theme easing. Nothing moves with reduced motion. */
@media (prefers-reduced-motion: no-preference) {
	.gp-address--ready:not(.gp-address--instant) .gp-address__parts {
		transition: grid-template-rows .28s var(--ease-out, cubic-bezier(.16, 1, .3, 1)), visibility 0s;
	}

	.gp-address--ready.gp-address--collapsed:not(.gp-address--instant) .gp-address__parts {
		transition: grid-template-rows .22s var(--ease-out, cubic-bezier(.16, 1, .3, 1)), visibility 0s linear .22s;
	}

	.gp-address--ready.gp-address--collapsed:not(.gp-address--instant) .gp-address__manual-row {
		transition: grid-template-rows .22s var(--ease-out, cubic-bezier(.16, 1, .3, 1)), visibility 0s;
	}

	.gp-address--ready:not(.gp-address--collapsed):not(.gp-address--instant) .gp-address__manual-row {
		transition: grid-template-rows .2s var(--ease-out, cubic-bezier(.16, 1, .3, 1)), visibility 0s linear .2s;
	}

	.gp-address--ready:not(.gp-address--instant) .gp-address__content {
		transition: opacity .24s ease, transform .28s var(--ease-out, cubic-bezier(.16, 1, .3, 1));
	}

	.gp-address--ready.gp-address--collapsed:not(.gp-address--instant) .gp-address__content {
		transition: opacity .16s ease, transform .22s var(--ease-out, cubic-bezier(.16, 1, .3, 1));
	}

	.gp-address--ready:not(.gp-address--instant) .gp-address__manual {
		transition: opacity .2s ease, text-decoration-color .15s ease;
	}

	.gp-address--ready:not(.gp-address--instant) .gp-address__chevron {
		transition: transform .28s var(--ease-out, cubic-bezier(.16, 1, .3, 1));
	}

	.gp-address__toggle::before {
		transition: opacity .15s ease, transform .2s var(--ease-out, cubic-bezier(.16, 1, .3, 1));
	}

	.gp-address .gp-address-hint__msg:not(:empty) {
		animation: gp-address-note-in .22s var(--ease-out, cubic-bezier(.16, 1, .3, 1));
	}
}

@keyframes gp-address-note-in {
	from {
		opacity: 0;
		transform: translateY(-3px);
	}
}

/* Long answers end with « … » instead of a cut letter (« Réseaux sociaux (Instagram, Faceb… »). */
.gp-form .gp-field select {
	text-overflow: ellipsis;
}

.gp-form__source {
	display: grid;
	gap: 12px;
}
.gp-fieldset {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.gp-fieldset > legend {
	margin-bottom: 8px;
	padding: 0;
	font-weight: 600;
}

.gp-field {
	display: grid;
	align-content: start;
	gap: 6px;
	min-width: 0;
}

.gp-form .gp-field {
	margin: 0; /* the form's grid gap spaces the fields */
}

.gp-field > label {
	font-weight: 600;
}

.gp-field input,
.gp-field select,
.gp-field textarea {
	box-sizing: border-box;
	width: 100%;
	min-height: var(--field-h, 44px);
	font: inherit;
}

.gp-field textarea {
	min-height: 160px;
	resize: vertical;
}

/* Optional box (optins.php: newsletter on the quote form): never ticked in advance; the label wraps the box, so the
   whole row (44 px or more) toggles it; the box stays on the first line of a long text. */
.gp-form__check {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	min-height: 44px;
	padding-block: 10px;
	font-size: 0.94rem;
	font-weight: 500;
	line-height: 1.45;
	cursor: pointer;
}

.gp-form__check input[type="checkbox"] {
	flex: none;
	width: 20px;
	height: 20px;
	margin: 1px 0 0;
	accent-color: currentColor;
	cursor: pointer;
}

.gp-form__check input[type="checkbox"]:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
}

.gp-form__check-hint {
	margin: -6px 0 0;
	padding-left: 32px;
	font-size: 0.875em;
}

.gp-field__hint,
.gp-form__required-note,
.gp-form__consent {
	margin: 0;
	font-size: 0.875em;
}

.gp-field__error {
	margin: 0;
	font-weight: 600;
	color: var(--danger, #b3261e);
}

.gp-field--error input,
.gp-field--error select,
.gp-field--error textarea {
	border-color: var(--danger, #b3261e);
	border-width: 2px;
}

.gp-form__summary,
.gp-form__success {
	padding: 16px 20px;
	border: 2px solid currentColor;
	border-radius: var(--radius-s, 12px);
}

.gp-form__summary {
	border-color: var(--danger, #b3261e);
}

.gp-form__summary-title,
.gp-form__success-title {
	margin: 0 0 8px;
	font-size: 1.05rem;
	line-height: 1.3;
}

.gp-form__summary-list {
	margin: 0;
	padding-left: 1.2em;
	line-height: 1.5; /* 24 px lines: each link stays a 24 px target */
}

.gp-form__summary-list li + li {
	margin-top: 4px;
}

/* No dead strip between the lines of a wrapped link: inline padding is part of its hit area, not of the layout. */
.gp-form__summary-list a {
	padding-block: 3px;
}

/* Phones: more room for the text, so fewer entries wrap. */
@media (max-width: 479px) {
	.gp-form__summary {
		padding: 14px 16px;
	}

	.gp-form__summary-list {
		padding-left: 1.1em;
	}
}

.gp-form__summary-list a,
.gp-form__consent a,
.gp-form__success a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.gp-form__summary:focus-visible,
.gp-form__success:focus-visible,
.gp-form a:focus-visible,
.gp-form__success a:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
}

.gp-form__success > :last-child {
	margin-bottom: 0;
}

.gp-form__hp {
	position: absolute !important;
	left: -10000px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.gp-form .screen-reader-text,
.gp-form-wrap .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* intl-tel-input: full width, readable list on both views, visible focus. */
.iti {
	display: block;
	width: 100%;
	--iti-border-color: var(--paper-line, #ccc);
	--iti-country-selector-bg: var(--paper, #fff);
	--iti-hover-color: var(--paper-2, rgba(0, 0, 0, 0.06));
	--iti-icon-color: currentColor;
}

.iti__dropdown-content,
.iti--fullscreen-popup .iti__dropdown-content {
	color: var(--paper-ink, #121316);
	background-color: var(--paper, #fff);
}

.iti__selected-country:focus-visible,
.iti__search-input:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.iti__country {
	min-height: 44px;
}
