/*
Theme Name: Municipal Theme
Description: Thème commun des sites de communes de la plateforme. Identité institutionnelle, personnalisable par commune (couleurs, blason, coordonnées), conçu pour l'accessibilité (RGAA).
Version: 0.1.0
Requires at least: 6.8
Requires PHP: 8.3
Author: plateforme-communes
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: municipal-theme
*/

/* -------------------------------------------------------------------------
 * Accessibilité
 * ---------------------------------------------------------------------- */

/* Focus visible sur fond clair comme sur fond foncé : anneau blanc + anneau sombre. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
	outline: 3px solid #fff;
	outline-offset: 2px;
	box-shadow: 0 0 0 6px var(--wp--preset--color--ink);
}

.skip-link.screen-reader-text:focus {
	background: var(--wp--preset--color--primary);
	color: #fff;
	font-weight: 700;
	padding: 0.75rem 1.25rem;
	text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}

/* -------------------------------------------------------------------------
 * Typographie : échelle inspirée des sites de l'administration
 * (16/24 texte, 14/24 petit texte, 20/32 introduction).
 * ---------------------------------------------------------------------- */

.has-small-font-size {
	line-height: 1.715;
}

.has-large-font-size {
	line-height: 1.6;
}

/* -------------------------------------------------------------------------
 * Structure
 * ---------------------------------------------------------------------- */

/* En-tête, contenu et pied de page se touchent : chaque section gère ses marges. */
.wp-site-blocks > * + * {
	margin-block-start: 0;
}

/* -------------------------------------------------------------------------
 * En-tête
 * ---------------------------------------------------------------------- */

.mt-header__top {
	border-bottom: 4px solid var(--wp--preset--color--accent);
}

.mt-brand {
	display: inline-flex;
	gap: 1rem;
	align-items: center;
	text-decoration: none;
	color: inherit;
}

.mt-brand:hover {
	color: inherit;
}

.mt-brand__shield {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 64px;
	height: 76px;
	flex: 0 0 64px;
	background: var(--wp--preset--color--primary);
	color: #fff;
	font-family: var(--wp--preset--font-family--sans);
	font-weight: 700;
	font-size: 1.625rem;
	clip-path: polygon(0 0, 100% 0, 100% 62%, 50% 100%, 0 62%);
}

.mt-brand__logo {
	width: auto;
	max-height: 80px;
}

.mt-brand__text {
	display: flex;
	flex-direction: column;
}

.mt-brand__kicker {
	font-size: 0.875rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	line-height: 1.5;
	text-transform: uppercase;
}

.mt-brand__name {
	font-family: var(--wp--preset--font-family--sans);
	font-size: 1.625rem;
	font-weight: 700;
	line-height: 1.2;
}

.mt-navbar .wp-block-navigation {
	font-size: 1rem;
}

.mt-navbar .wp-block-navigation-item__content {
	padding: 0.875rem 0.75rem;
	text-decoration: none;
}

.mt-navbar .wp-block-navigation-item__content:hover {
	text-decoration: underline;
}

/* Menus déroulants (ouverts au clic), aux couleurs de la barre (contraste vérifié dans « Ma commune »). */
.mt-navbar .wp-block-navigation .wp-block-navigation-submenu__toggle {
	padding: 0.875rem 1.25rem 0.875rem 0.75rem;
	font-weight: inherit;
}

/* Le chevron se place dans la marge droite du bouton. */
.mt-navbar .wp-block-navigation .wp-block-navigation-submenu__toggle + .wp-block-navigation__submenu-icon {
	margin-left: -1.125rem;
	margin-right: 0.5rem;
	pointer-events: none;
}

/* Rubriques réparties sur toute la largeur de la barre. */
.mt-navbar .wp-block-navigation__responsive-container:not(.is-menu-open) .wp-block-navigation__container {
	flex: 1;
	justify-content: space-between;
}

.mt-navbar .wp-block-navigation-submenu__toggle[aria-expanded="true"],
.mt-navbar .wp-block-navigation__submenu-container .wp-block-navigation-item__content:hover,
.mt-navbar .wp-block-navigation__submenu-container .wp-block-navigation-item__content:focus {
	background: var(--wp--preset--color--primary-dark);
}

.mt-navbar .wp-block-navigation .wp-block-navigation__submenu-container {
	min-width: 280px;
	padding-block: 0.5rem;
	border: 0;
	border-top: 3px solid var(--wp--preset--color--accent);
	box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
	z-index: 20;
}

.mt-navbar .wp-block-navigation__submenu-container .wp-block-navigation-item__content {
	padding: 0.625rem 1.25rem;
}

/* Menu mobile (plein écran) : entrées espacées, sous-menus dépliés sans cadre. */
.mt-navbar .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container {
	gap: 1rem;
}

.mt-navbar .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__submenu-icon {
	display: none;
}

.mt-navbar .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__submenu-container {
	border-top: 0;
	box-shadow: none;
}

/* Le premier lien s'aligne sur le contenu de la page. */
.mt-navbar .wp-block-navigation__container > li:first-child > .wp-block-navigation-item__content {
	padding-left: 0;
}

/*
 * Menu trop long pour la largeur de l'écran : assets/js/navigation.js le
 * replie derrière le bouton « Menu » (comme sur mobile) plutôt que sur deux lignes.
 */
.mt-navbar .mt-nav.mt-nav--measuring .wp-block-navigation__container {
	flex-wrap: nowrap;
	justify-content: flex-start;
}

.mt-navbar .mt-nav.mt-nav--measuring .wp-block-navigation__container > li {
	flex-shrink: 0;
}

/* Sous-menus des dernières rubriques : alignés à droite pour rester dans l'écran. */
.mt-navbar .wp-block-navigation__container > .has-child:nth-last-child(-n+2) > .wp-block-navigation__submenu-container {
	right: 0;
	left: auto;
}

/* Bouton du menu mobile : zone tactile d'au moins 44 × 44 px. */
.mt-navbar .wp-block-navigation__responsive-container-open,
.mt-navbar .wp-block-navigation__responsive-container-close {
	min-width: 44px;
	min-height: 44px;
	justify-content: center;
}

.mt-navbar .wp-block-navigation__responsive-container-open {
	gap: 0.5rem;
	margin-block: 0.25rem;
	padding-inline: 0;
	font-weight: 600;
}

/* Le mot « Menu » à côté de l'icône (le nom accessible reste « Ouvrir le menu »). */
.mt-navbar .wp-block-navigation__responsive-container-open::after {
	content: "Menu";
}

/* -------------------------------------------------------------------------
 * Page d'accueil
 * ---------------------------------------------------------------------- */

.mt-hero-media {
	position: relative;
	overflow: hidden;
	min-height: 420px;
	height: 100%;
	background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0 14px, rgba(255, 255, 255, 0.02) 14px 28px);
}

.mt-hero-illustration {
	display: block;
	width: 100%;
	height: 100%;
	min-height: 420px;
}

/* La photo remplit le bloc sans en fixer la hauteur : une photo en portrait ne l'étire pas. */
.mt-hero-media img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

@media (max-width: 781px) {
	.mt-hero-media,
	.mt-hero-illustration {
		min-height: 240px;
	}
}

.wp-block-municipal-theme-commune-links > h2 {
	margin-bottom: 1.5rem;
}

/* Accès rapides : pictogramme, intitulé, précision et flèche. */
.mt-tiles {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: 1rem;
	padding: 0;
	margin: 0;
	list-style: none;
}

.mt-tile a {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 0.375rem;
	height: 100%;
	min-height: 190px;
	box-sizing: border-box;
	padding: 1.5rem 1.25rem 2.75rem;
	background: #fff;
	border: 1px solid var(--wp--preset--color--border);
	border-bottom: 3px solid var(--wp--preset--color--accent);
	color: var(--wp--preset--color--ink);
	text-decoration: none;
	transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.mt-tile__badge {
	display: grid;
	place-items: center;
	width: 52px;
	height: 52px;
	margin-bottom: 0.625rem;
	border-radius: 50%;
	background: var(--wp--preset--color--surface);
	background: color-mix(in srgb, var(--wp--preset--color--primary) 10%, #fff);
	color: var(--wp--preset--color--primary);
	transition: background 0.15s ease, color 0.15s ease;
}

.mt-tile__label {
	color: var(--wp--preset--color--primary);
	font-size: 1.0625rem;
	font-weight: 700;
	line-height: 1.3;
}

.mt-tile__detail {
	color: var(--wp--preset--color--muted);
	font-size: 0.875rem;
	line-height: 1.45;
}

.mt-tile__arrow {
	position: absolute;
	right: 1.25rem;
	bottom: 0.875rem;
	color: var(--wp--preset--color--accent);
	font-size: 1.25rem;
	font-weight: 700;
	transition: transform 0.15s ease;
}

.mt-tile a:hover,
.mt-tile a:focus-visible {
	border-color: var(--wp--preset--color--primary);
	box-shadow: 0 10px 24px rgba(16, 24, 40, 0.12);
	transform: translateY(-2px);
}

.mt-tile a:hover .mt-tile__label,
.mt-tile a:focus-visible .mt-tile__label {
	text-decoration: underline;
}

.mt-tile a:hover .mt-tile__badge,
.mt-tile a:focus-visible .mt-tile__badge {
	background: var(--wp--preset--color--primary);
	color: #fff;
}

.mt-tile a:hover .mt-tile__arrow {
	transform: translateX(4px);
}

/* Mobile : une ligne compacte par accès (pictogramme à gauche). */
@media (max-width: 599px) {
	.mt-tiles {
		gap: 0.625rem;
	}

	.mt-tile a {
		display: grid;
		grid-template-columns: auto 1fr;
		column-gap: 1rem;
		row-gap: 0.125rem;
		align-items: center;
		min-height: 0;
		padding: 0.875rem 2.75rem 0.875rem 1rem;
	}

	.mt-tile__badge {
		grid-row: span 2;
		width: 44px;
		height: 44px;
		margin: 0;
	}

	.mt-tile__arrow {
		top: 50%;
		bottom: auto;
		transform: translateY(-50%);
	}

	.mt-tile a:hover .mt-tile__arrow {
		transform: translate(4px, -50%);
	}
}

@media (prefers-reduced-motion: reduce) {
	.mt-tile a,
	.mt-tile__arrow {
		transition: none;
	}

	.mt-tile a:hover,
	.mt-tile a:focus-visible,
	.mt-tile a:hover .mt-tile__arrow {
		transform: none;
	}
}

/* Cartes d'actualité : toute la carte est cliquable (lien du titre étendu). */
.mt-card {
	position: relative;
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow: hidden;
	background: #fff;
	border: 1px solid var(--wp--preset--color--border);
	border-bottom: 3px solid var(--wp--preset--color--primary);
	transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.mt-card:hover,
.mt-card:focus-within {
	box-shadow: 0 10px 24px rgba(16, 24, 40, 0.12);
	transform: translateY(-2px);
}

.mt-card > * {
	margin-block: 0 !important;
}

.mt-card .wp-block-post-featured-image img {
	display: block;
	width: 100%;
	object-fit: cover;
}

.mt-card__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 0.5rem;
	padding: 1.25rem 1.5rem 1.5rem;
}

.mt-card__body > * {
	margin: 0 !important;
}

.mt-card .wp-block-post-terms {
	font-size: 0.8125rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.mt-card .wp-block-post-terms a {
	position: relative;
	z-index: 2;
	color: var(--wp--preset--color--accent);
	text-decoration: none;
}

.mt-card .wp-block-post-title {
	font-size: 1.25rem;
	line-height: 1.35;
}

.mt-card .wp-block-post-title a {
	color: var(--wp--preset--color--primary);
	text-decoration: none;
}

.mt-card .wp-block-post-title a::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

.mt-card:hover .wp-block-post-title a,
.mt-card .wp-block-post-title a:focus {
	text-decoration: underline;
}

.mt-card .wp-block-post-title a:focus-visible {
	outline: none;
}

.mt-card:focus-within {
	outline: 3px solid var(--wp--preset--color--accent);
	outline-offset: 2px;
}

.mt-card .wp-block-post-date {
	color: var(--wp--preset--color--muted);
	font-size: 0.875rem;
}

.mt-card .wp-block-post-excerpt__excerpt {
	margin: 0;
	color: var(--wp--preset--color--ink);
}

.mt-card__more {
	margin-top: auto !important;
	padding-top: 0.5rem;
	color: var(--wp--preset--color--primary);
	font-size: 0.9375rem;
	font-weight: 700;
}

.mt-card__more::after,
.mt-section-link a::after {
	content: " →";
}

/* Plan d'accès (pied de page) */
.mt-map__figure {
	margin: 0;
}

.mt-map__link {
	position: relative;
	display: block;
	overflow: hidden;
	border: 2px solid rgba(255, 255, 255, 0.85);
	border-radius: 6px;
	line-height: 0;
}

.mt-map__link img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 16 / 9;
	object-fit: cover;
	transition: transform 0.3s ease;
}

.mt-map__link:hover img,
.mt-map__link:focus-visible img {
	transform: scale(1.04);
}

.mt-map__pin {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 28px;
	height: 38px;
	transform: translate(-50%, -100%);
	fill: var(--wp--preset--color--accent);
	filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35));
}

.mt-map__credit {
	margin-top: 0.375rem;
	font-size: 0.75rem;
	opacity: 0.85;
}

.mt-map__actions {
	margin: 0.75rem 0 0;
}

.mt-on-dark .mt-map__directions {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.5rem 1rem;
	border: 2px solid currentColor;
	border-radius: 4px;
	font-weight: 700;
	text-decoration: none;
}

.mt-map__directions::after {
	content: "→";
}

.mt-on-dark .mt-map__directions:hover,
.mt-on-dark .mt-map__directions:focus-visible {
	background: #fff;
	color: var(--wp--preset--color--primary-dark);
}

@media (prefers-reduced-motion: reduce) {
	.mt-map__link img {
		transition: none;
	}
}

/* Actualité sans image : illustration de village (inc/news-illustrations.php). */
.mt-card__placeholder {
	aspect-ratio: 16 / 9;
	margin: 0;
	overflow: hidden;
	background: #E6F2F9;
}

.mt-card__illustration {
	display: block;
	width: 100%;
	height: 100%;
}

.mt-section-link {
	margin: 0;
	font-weight: 700;
}

.mt-section-link a {
	color: var(--wp--preset--color--primary);
}

@media (prefers-reduced-motion: reduce) {
	.mt-card {
		transition: none;
	}

	.mt-card:hover,
	.mt-card:focus-within {
		transform: none;
	}
}

/* -------------------------------------------------------------------------
 * Informations de la commune (blocs du thème)
 * ---------------------------------------------------------------------- */

.mt-contact {
	font-style: normal;
}

.mt-contact p {
	margin: 0 0 0.5rem;
}

.mt-hours {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 0.375rem 1rem;
	margin: 0;
}

.mt-hours dt {
	font-weight: 600;
}

.mt-hours dd {
	margin: 0;
}

.mt-hours-slot {
	white-space: nowrap;
}

/* Pied de page : colonne étroite, jour au-dessus des horaires, en petit */
.mt-on-dark .mt-hours {
	grid-template-columns: 1fr;
	gap: 0;
	font-size: var(--wp--preset--font-size--small);
}

.mt-on-dark .mt-hours dd + dt {
	margin-top: 0.5rem;
}

/* Publication des actes (bloc du plugin) */
.mpc-actes-missing {
	padding: 1rem 1.25rem;
	border-left: 4px solid var(--wp--preset--color--accent);
	background: #fff;
}

.mpc-actes iframe {
	background: #fff;
	border: 1px solid var(--wp--preset--color--border) !important;
}

.mpc-actes__fallback {
	margin-top: 0.75rem;
	font-size: var(--wp--preset--font-size--small);
}

/* Liens sur fond foncé (pied de page, bandeaux) */
.mt-on-dark a:where(:not(.wp-element-button)) {
	color: inherit;
}

/* Bas de page : mentions légales à gauche, crédits à droite. */
.mt-credits {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 0.5rem;
	margin: 0;
	font-size: 0.875rem;
}

.mt-credits a {
	font-weight: 700;
}

.mt-credits__sep {
	opacity: 0.7;
}

.mt-legal {
	font-size: var(--wp--preset--font-size--small);
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Cadres intégrés (registre des actes, vidéos après consentement) : focus visible
 * au clavier, y compris quand le focus est à l'intérieur du cadre. */
iframe:focus,
iframe:focus-within,
iframe.mt-iframe-focused {
	outline: 3px solid var(--wp--preset--color--accent);
	outline-offset: 3px;
}

/* Encadré d'information dans les pages (« > » des modèles de pages). */
.mpc-note,
.mpc-fill-notice {
	box-sizing: border-box;
}

.mpc-note {
	background: var(--wp--preset--color--white);
	border-left: 4px solid var(--wp--preset--color--primary);
	border-radius: 0 6px 6px 0;
	padding: 0.875rem 1.125rem;
}

/* Tableaux des pages : lisibles et défilants sur mobile. */
.wp-block-table {
	overflow-x: auto;
}

.wp-block-table table {
	border-collapse: collapse;
	width: 100%;
}

.wp-block-table th {
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--white);
	text-align: left;
}

.wp-block-table th,
.wp-block-table td {
	border: 1px solid var(--wp--preset--color--border);
	padding: 0.5rem 0.75rem;
	vertical-align: top;
}

/* Informations à compléter : visibles uniquement par les agents connectés. */
.mpc-fill {
	background: #FFF1B8;
	color: #3D3000;
	outline: 1px dashed #8A6D00;
	border-radius: 2px;
	padding: 0 2px;
}

.mpc-fill-notice {
	background: #FFF8D6;
	border: 1px solid #8A6D00;
	border-radius: 6px;
	color: #3D3000;
	padding: 0.75rem 1rem;
}

.mpc-fill-notice a {
	color: inherit;
	font-weight: 700;
}
