/**
 * YOU JI France — global stylesheet (front + editor).
 * Only what theme.json cannot express: reset, focus, forms, header layout, utilities.
 * Design tokens come from theme.json (--wp--preset--* and --wp--custom--*).
 */

/* ---------------------------------------------------------------------------
 * Reset (targeted)
 * ------------------------------------------------------------------------- */

*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
	scroll-behavior: smooth;
	/* Anchors land below the sticky header (and the admin bar when logged in). */
	scroll-padding-top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--wp--custom--header--height-mobile) + 16px);
}

/* Desktop: the header is compact (72 px) at an anchor (header.js makes sure of it). */
@media (min-width: 782px) {
	html {
		scroll-padding-top: calc(var(--wp-admin--admin-bar--height, 0px) + 72px + 24px);
	}
}

body {
	margin: 0;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

img,
video {
	max-width: 100%;
	height: auto;
	vertical-align: middle;
}

svg {
	max-width: 100%;
	vertical-align: middle;
}

hr {
	border: 0;
}

button,
input,
select,
textarea {
	font: inherit;
	color: inherit;
}

/* Focus: 3px brand outline, keyboard only. */
:focus-visible {
	outline: var(--wp--custom--stroke--focus) solid var(--wp--preset--color--primary);
	outline-offset: 2px;
}

:focus:not(:focus-visible) {
	outline: none;
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}

	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}

/* ---------------------------------------------------------------------------
 * Headings: balanced wrapping, consistent spacing
 * ------------------------------------------------------------------------- */

h1,
h2,
h3,
h4,
h5,
h6 {
	text-wrap: balance;
	margin-top: 0;
}

p {
	text-wrap: pretty;
}

/* ---------------------------------------------------------------------------
 * Site header (parts/header.html)
 * ------------------------------------------------------------------------- */

.site-header {
	border-bottom: var(--wp--custom--stroke--thin) solid var(--wp--preset--color--border);
	background-color: var(--wp--preset--color--base);
	transition: box-shadow var(--wp--custom--transition);
}

/* Sticky: on the template-part wrapper, so it sticks for the whole page.
   The admin bar variable is only set when the admin bar is shown. */
.wp-site-blocks > header.wp-block-template-part {
	position: sticky;
	top: var(--wp-admin--admin-bar--height, 0px);
	z-index: 50;
}

.site-header.is-compact {
	box-shadow: 0 2px 12px rgb(16 31 48 / 0.08);
}

/* Set for one frame by header.js when going compact before an anchor jump. */
.site-header.is-instant,
.site-header.is-instant * {
	transition: none !important;
}

/* Thin graphite strip above the main bar (desktop only). Collapses once scrolled. */
.site-header__topbar {
	display: none;
	background-color: var(--wp--preset--color--graphite);
	color: var(--wp--preset--color--on-dark-soft);
	font-size: var(--wp--preset--font-size--caption);
	height: 30px;
	overflow: hidden;
	transition: height var(--wp--custom--transition), opacity var(--wp--custom--transition);
}

.site-header.is-compact .site-header__topbar {
	height: 0;
	opacity: 0;
}

.site-header__topbar p {
	margin: 0;
	color: inherit;
}

.site-header__inner {
	min-height: var(--wp--custom--header--height-mobile);
	transition: min-height var(--wp--custom--transition);
}

@media (min-width: 782px) {
	.site-header__topbar {
		display: flex;
	}

	/* 118 px total: 30 px strip + 88 px main bar; 72 px once scrolled. */
	.site-header__inner {
		min-height: calc(var(--wp--custom--header--height) - 30px);
	}

	.site-header.is-compact .site-header__inner {
		min-height: 72px;
	}

	.site-header.is-compact .site-brand img {
		height: 40px;
	}

	.site-header.is-compact .site-brand .site-brand__bars img {
		height: 16px;
	}
}

.site-header__brand {
	display: flex;
	align-items: center;
	gap: var(--wp--preset--spacing--sm);
}

/* Brand (patterns/brand.php): SVG badge + site title, both linked to home.
   The image is sized here, not in the block, so the mobile size wins. */
.site-brand .wp-block-image {
	margin: 0;
	flex-shrink: 0;
}

.site-brand .wp-block-image a {
	display: block;
	line-height: 0;
}

.site-brand img {
	display: block;
	height: 56px;
	width: auto;
	border-radius: 0;
	transition: height var(--wp--custom--transition);
}

/* Text block, bottom-aligned with the badge: bars top-right, title at the bottom. */
.site-brand .site-brand__text {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	justify-content: flex-end;
}

/* Beats the flow-layout block gap between the bars and the title. */
.site-brand .site-brand__text > * {
	margin-block-start: 0;
}

/* The three oblique bars of the YOU JI logo, above the title. */
.site-brand .site-brand__bars img {
	height: 20px;
	width: auto;
}

.site-brand .wp-block-site-title {
	white-space: nowrap;
}

@media (max-width: 781px) {
	.site-brand img {
		height: 40px;
	}

	.site-brand .site-brand__bars img {
		height: 13px;
	}

	.site-brand .site-brand__text {
	}

	.site-brand .wp-block-site-title {
		font-size: 1.25rem;
	}
}

/* Header CTA: hidden on small screens (the hero carries the call to action). */
.site-header__cta.site-header__cta {
	display: none;
}

@media (min-width: 782px) {
	.site-header__cta.site-header__cta {
		display: flex;
	}
}

.site-header__nav {
	min-width: 0;
}

.site-header__cta .wp-block-button__link {
	white-space: nowrap;
}

/* 1 100–1 199 px: tighter menu so five items and the CTA fit on one line. */
@media (min-width: 1100px) and (max-width: 1199px) {
	.site-header__nav,
	.site-header__nav .wp-block-navigation {
		gap: var(--wp--preset--spacing--sm);
	}
}

/* Reserved slot for the brand switcher (Cosmos, lot 2). */
.brand-switcher:empty {
	display: none;
}

/* ---------------------------------------------------------------------------
 * Page sections: full-width sections sit flush with each other, with the
 * header and with the footer (the root block gap only applies to text content).
 * ------------------------------------------------------------------------- */

.wp-site-blocks > main,
.wp-site-blocks > footer {
	margin-block-start: 0;
}

.wp-block-post-content > .alignfull + .alignfull {
	margin-block-start: 0;
}

/* Breadcrumb bar (Page template) sits flush with the first section. */
main.wp-block-group > .breadcrumb-bar + .wp-block-post-content {
	margin-block-start: 0;
}

/* No rule under the breadcrumb when the first section shares its grey background. */
main.wp-block-group > .breadcrumb-bar:has(+ .wp-block-post-content > .has-surface-background-color:first-child) {
	border-bottom: 0;
}

/* ---------------------------------------------------------------------------
 * Site footer (parts/footer.html)
 * ------------------------------------------------------------------------- */

.site-footer .site-brand {
	margin-bottom: var(--wp--preset--spacing--sm);
}

.site-footer .site-brand .wp-block-site-title a {
	color: var(--wp--preset--color--on-dark);
}

.site-footer .site-brand .wp-block-site-title a:hover {
	color: var(--wp--preset--color--on-dark-accent);
}

.site-footer__bottom {
	border-top: var(--wp--custom--stroke--thin) solid var(--wp--custom--color--on-dark-border);
	padding-top: var(--wp--preset--spacing--md);
	font-size: var(--wp--preset--font-size--caption);
	color: var(--wp--preset--color--on-dark-muted);
}

.site-footer__bottom a {
	color: var(--wp--preset--color--on-dark-muted);
}

.site-footer__bottom a:hover {
	color: var(--wp--preset--color--on-dark);
}

/* ---------------------------------------------------------------------------
 * Icons (inline SVG from youji_icon())
 * ------------------------------------------------------------------------- */

/* Size comes from the width/height attributes written by youji_icon(). */
.icon {
	display: inline-block;
	flex-shrink: 0;
	vertical-align: -0.15em;
	fill: none;
	stroke: currentColor;
}

/* ---------------------------------------------------------------------------
 * Utilities
 * ------------------------------------------------------------------------- */

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

/* Brand rule: 56 × 3 px, primary. Works on <hr> (separator block) or any element. */
.brand-rule {
	display: block;
	width: var(--wp--custom--brand-rule--width);
	height: var(--wp--custom--brand-rule--height);
	margin: var(--wp--preset--spacing--md) 0;
	border: 0;
	background-color: var(--wp--preset--color--primary);
	opacity: 1;
}

/* ---------------------------------------------------------------------------
 * Forms (markup written by hand in the forms phase: CPT inquiry, nonce, honeypot)
 *
 * <form class="form">
 *   <div class="form__field">
 *     <label class="form__label" for="x">Nom <span class="form__required">*</span></label>
 *     <input class="form__control" id="x" name="x" type="text" required aria-describedby="x-hint">
 *     <p class="form__hint" id="x-hint">Aide</p>
 *     <p class="form__error" id="x-error" role="alert">Erreur</p>
 *   </div>
 * </form>
 * ------------------------------------------------------------------------- */

.form {
	display: grid;
	gap: var(--wp--preset--spacing--md);
}

.form__row {
	display: grid;
	gap: var(--wp--preset--spacing--md);
}

@media (min-width: 600px) {
	.form__row {
		grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	}
}

.form__field {
	display: grid;
	/* A row stretches its fields to one height: the extra space stays below, not in the control. */
	align-content: start;
	gap: 6px;
	margin: 0;
	padding: 0;
	border: 0;
	min-width: 0;
}

.form__legend,
.form__label {
	display: block;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	line-height: 1.4;
	color: var(--wp--preset--color--contrast);
}

.form__required {
	color: var(--wp--preset--color--cta);
	font-weight: 600;
}

.form__control,
.form input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="file"]),
.form select,
.form textarea {
	display: block;
	width: 100%;
	min-height: var(--wp--custom--control--height);
	padding: 0 14px;
	border: var(--wp--custom--stroke--thin) solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--sm);
	background-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	font-size: var(--wp--preset--font-size--body);
	line-height: 1.5;
	appearance: none;
	transition: border-color var(--wp--custom--transition), box-shadow var(--wp--custom--transition);
}

.form textarea,
textarea.form__control {
	min-height: 150px;
	padding: 14px;
	resize: vertical;
}

.form select,
select.form__control {
	padding-right: 44px;
	background-image: url("../icons/chevron-down.svg");
	background-repeat: no-repeat;
	background-position: right 14px center;
	background-size: 20px;
}

.form__control::placeholder,
.form input::placeholder,
.form textarea::placeholder {
	color: var(--wp--preset--color--muted);
	opacity: 1;
}

/* Focus: 2px primary (border + inner ring). */
.form__control:focus,
.form input:focus,
.form select:focus,
.form textarea:focus {
	outline: none;
	border-color: var(--wp--preset--color--primary);
	box-shadow: inset 0 0 0 1px var(--wp--preset--color--primary);
}

.form__control:focus-visible,
.form input:focus-visible,
.form select:focus-visible,
.form textarea:focus-visible {
	outline: none;
}

/* Error */
.form__control[aria-invalid="true"],
.form [aria-invalid="true"],
.form__field.has-error .form__control {
	border-color: var(--wp--preset--color--error);
}

.form__control[aria-invalid="true"]:focus,
.form [aria-invalid="true"]:focus {
	border-color: var(--wp--preset--color--error);
	box-shadow: inset 0 0 0 1px var(--wp--preset--color--error);
}

/* Valid */
.form__control.is-valid,
.form .is-valid,
.form__field.is-valid .form__control {
	border-color: var(--wp--preset--color--success);
}

/* Disabled */
.form__control:disabled,
.form input:disabled,
.form select:disabled,
.form textarea:disabled {
	background-color: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--muted);
	cursor: not-allowed;
}

/* Hint, error, success messages */
.form__hint,
.form__error,
.form__success {
	margin: 0;
	font-size: var(--wp--preset--font-size--caption);
	line-height: 1.5;
}

.form__hint {
	color: var(--wp--preset--color--muted);
}

.form__error {
	display: flex;
	gap: 6px;
	align-items: flex-start;
	color: var(--wp--preset--color--error);
	font-weight: 500;
}

.form__success {
	color: var(--wp--preset--color--success);
	font-weight: 500;
}

/* Checkbox / radio (consent, options) */
.form__choice {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 400;
	line-height: 1.5;
	color: var(--wp--preset--color--contrast);
}

.form input[type="checkbox"],
.form input[type="radio"] {
	flex-shrink: 0;
	width: 18px;
	height: 18px;
	margin: 3px 0 0;
	accent-color: var(--wp--preset--color--primary);
}

/* File input */
.form input[type="file"] {
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--muted);
}

/* Honeypot: hidden from humans, present for bots. */
.form__honeypot {
	position: absolute !important;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
	opacity: 0;
}

/* Native submit button inherits the primary button look (markup outside the block editor). */
.form .button,
.form button[type="submit"],
.form input[type="submit"] {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: var(--wp--custom--control--height);
	padding: 14px 20px;
	border: var(--wp--custom--stroke--thin) solid var(--wp--preset--color--cta);
	border-radius: var(--wp--custom--radius--sm);
	background-color: var(--wp--preset--color--cta);
	color: var(--wp--preset--color--on-dark);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	line-height: 1.4;
	text-decoration: none;
	cursor: pointer;
	transition: background-color var(--wp--custom--transition), border-color var(--wp--custom--transition);
}

.form .button:hover,
.form button[type="submit"]:hover,
.form input[type="submit"]:hover {
	background-color: var(--wp--preset--color--cta-hover);
	border-color: var(--wp--preset--color--cta-hover);
}

.form .button:disabled,
.form button[type="submit"]:disabled,
.form input[type="submit"]:disabled {
	background-color: var(--wp--preset--color--disabled);
	border-color: var(--wp--preset--color--disabled);
	color: var(--wp--preset--color--muted);
	cursor: not-allowed;
}

/* Form groups (contact form): legend as a section title, short text, fields. */
.form__group {
	display: grid;
	gap: var(--wp--preset--spacing--md);
	margin: 0;
	padding: 0;
	border: 0;
	min-width: 0;
}

/* The legend is not a grid item: its own margin spaces it from the text. */
.form__group-title {
	padding: 0;
	margin-bottom: 12px;
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--heading-3);
	font-weight: 600;
	line-height: 1.15;
	letter-spacing: -0.01em;
	color: var(--wp--preset--color--contrast);
	text-wrap: balance;
}

.form__group-text {
	margin: 0;
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.6;
	color: var(--wp--preset--color--muted);
}

/* Rule between groups, on the bottom edge: a top border would run through the legend. */
.form__group:has(+ .form__group) {
	padding-bottom: var(--wp--preset--spacing--md);
	border-bottom: var(--wp--custom--stroke--thin) solid var(--wp--preset--color--border);
}

.form__fields {
	display: grid;
	gap: var(--wp--preset--spacing--md);
}

/* Request type: radios shown as chips (surface, selected = brand blue). */
.form__chips {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--xs);
}

.form__chip {
	position: relative;
	display: inline-flex;
	cursor: pointer;
}

.form .form__chip input[type="radio"] {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: 0;
	opacity: 0;
	pointer-events: none;
}

.form__chip span {
	padding: 14px 16px;
	border-radius: var(--wp--custom--radius--sm);
	background-color: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--contrast);
	font-size: 0.8125rem;
	line-height: 1.4;
	transition: background-color var(--wp--custom--transition), color var(--wp--custom--transition);
}

.form__chip:hover span {
	background-color: var(--wp--preset--color--primary-soft);
}

.form__chip input:checked + span {
	background-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--on-dark);
	font-weight: 600;
}

.form__chip input:focus-visible + span {
	outline: var(--wp--custom--stroke--focus) solid var(--wp--preset--color--primary);
	outline-offset: 2px;
}

/* Attachment drop zone: dashed surface box, native file input kept for the
   label and the keyboard; assets/js/form.js adds the file name and drag & drop. */
.form__dropzone {
	position: relative;
	display: grid;
	justify-items: center;
	gap: 12px;
	padding: var(--wp--preset--spacing--md);
	border: var(--wp--custom--stroke--thin) dashed var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--sm);
	background-color: var(--wp--preset--color--surface);
	text-align: center;
	transition: border-color var(--wp--custom--transition), background-color var(--wp--custom--transition);
}

.form__dropzone.is-dragover {
	border-color: var(--wp--preset--color--primary);
	background-color: var(--wp--preset--color--primary-soft);
}

.form__dropzone-icon {
	color: var(--wp--preset--color--primary);
}

.form__dropzone-title {
	margin: 0;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	color: var(--wp--preset--color--contrast);
}

.form__dropzone-meta {
	margin: 0;
	font-size: var(--wp--preset--font-size--caption);
	color: var(--wp--preset--color--muted);
}

/* Secondary button look for the file label (same values as the outline button). */
.form__dropzone-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: var(--wp--custom--control--height);
	padding: 14px 20px;
	border: var(--wp--custom--stroke--thin) solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--sm);
	background-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--primary);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	line-height: 1.4;
	cursor: pointer;
	transition: background-color var(--wp--custom--transition);
}

.form__dropzone-button:hover {
	background-color: var(--wp--preset--color--primary-soft);
}

.form .form__dropzone-input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
	overflow: hidden;
	pointer-events: none;
}

.form__dropzone:has(.form__dropzone-input:focus-visible) .form__dropzone-button {
	outline: var(--wp--custom--stroke--focus) solid var(--wp--preset--color--primary);
	outline-offset: 2px;
}

.form__dropzone-file {
	margin: 0;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
	color: var(--wp--preset--color--success);
	overflow-wrap: anywhere;
}

.form__dropzone-file:empty {
	display: none;
}

/* Catalogue choice (youji-contact documentation form): one card per PDF,
   checkbox first, ticked card in brand blue. */
.form__catalogues {
	gap: var(--wp--preset--spacing--xs);
}

.form__catalogues > .form__label .form__hint {
	font-weight: 400;
}

.form__catalogue-list {
	display: grid;
	gap: var(--wp--preset--spacing--xs);
}

@media (min-width: 900px) {
	.form__catalogue-list {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

.form__catalogue {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	padding: 16px;
	border: var(--wp--custom--stroke--thin) solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--sm);
	background-color: var(--wp--preset--color--base);
	cursor: pointer;
	transition: border-color var(--wp--custom--transition), background-color var(--wp--custom--transition);
}

.form__catalogue:hover {
	background-color: var(--wp--preset--color--surface);
}

.form__catalogue:has(input:checked) {
	border-color: var(--wp--preset--color--primary);
	background-color: var(--wp--preset--color--primary-soft);
}

.form__catalogue:has(input:focus-visible) {
	outline: var(--wp--custom--stroke--focus) solid var(--wp--preset--color--primary);
	outline-offset: 2px;
}

.form__catalogue .icon {
	flex-shrink: 0;
	color: var(--wp--preset--color--primary);
}

.form__catalogue-body {
	display: grid;
	gap: 2px;
	min-width: 0;
}

.form__catalogue-title {
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	line-height: 1.4;
	color: var(--wp--preset--color--contrast);
}

.form__catalogue-meta {
	font-size: var(--wp--preset--font-size--caption);
	color: var(--wp--preset--color--primary);
}

.form__catalogue-text {
	font-size: var(--wp--preset--font-size--caption);
	line-height: 1.5;
	color: var(--wp--preset--color--muted);
}

.form__field.has-error .form__catalogue {
	border-color: var(--wp--preset--color--error);
}

/* Consent: privacy link under the sentence. */
.form__choice-link {
	display: inline-block;
	margin-top: 6px;
	font-size: var(--wp--preset--font-size--caption);
	text-decoration: underline;
}

@media (max-width: 599px) {
	.form__actions button[type="submit"] {
		width: 100%;
	}
}
