/**
 * HL Formations Core - Design System & UI Hierarchy
 *
 * Provides a modern, accessible, and structured directory layout for formations.
 */

:root {
	/* Site Color Palette Variables (with Astra global palette fallbacks) */
	--hl-bg-primary: var(--ast-global-color-4, #f7f4ee);
	--hl-bg-secondary: var(--ast-global-color-5, #efe9e0);
	--hl-color-brand: var(--ast-global-color-0, #0c71c3);
	--hl-color-brand-hover: var(--ast-global-color-1, #045cb4);
	--hl-color-featured: var(--ast-global-color-9, #7b471e);
	--hl-color-heading: var(--ast-global-color-2, #1f1d1a);
	--hl-color-text: var(--ast-global-color-3, #1f1d1a);
	--hl-color-text-muted: #6e6459;
	--hl-color-border: #ded7cb;
	--hl-color-border-hover: #cbbead;
	--hl-color-card-bg: #ffffff;
}

/* ==========================================================================
   1. Level Section & Container Hierarchy
   ========================================================================== */
.hl-formations-levels-container {
	display: flex;
	flex-direction: column;
	gap: 40px;
	margin: 32px 0 48px;
	width: 100%;
}

.hl-level-section {
	background: var(--hl-bg-secondary, #efe9e0);
	border: 1px solid var(--hl-color-border, #ded7cb);
	border-radius: 16px;
	padding: 24px 24px 28px;
	box-shadow: 0 1px 4px rgba(31, 29, 26, 0.03);
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.hl-level-section:hover {
	border-color: var(--hl-color-border-hover, #cbbead);
	box-shadow: 0 4px 14px rgba(31, 29, 26, 0.06);
}

.hl-level-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 20px;
	padding-bottom: 16px;
	border-bottom: 2px solid var(--hl-color-border, #ded7cb);
	flex-wrap: wrap;
}

.hl-level-heading {
	display: inline-flex;
	align-items: center;
	gap: 12px;
	margin: 0;
	font-size: 1.25rem;
	font-weight: 700;
	color: var(--hl-color-heading, #1f1d1a);
	line-height: 1.3;
	flex-wrap: wrap;
}

.hl-level-pill {
	background: var(--hl-color-featured, #7b471e);
	color: #ffffff !important;
	padding: 5px 14px;
	border-radius: 6px;
	font-size: 0.9rem;
	font-weight: 600;
	line-height: 1.3;
	letter-spacing: 0.01em;
	white-space: nowrap;
	display: inline-block;
}

.hl-level-subtitle {
	margin: 0;
	color: var(--hl-color-heading, #1f1d1a);
	font-weight: 700;
	font-size: 1.4rem;
	line-height: 1.25;
}

.hl-level-count {
	font-size: 0.82rem;
	font-weight: 600;
	color: var(--hl-color-text-muted, #6e6459);
	background: #ffffff;
	border: 1px solid var(--hl-color-border, #ded7cb);
	padding: 4px 12px;
	border-radius: 9999px;
	white-space: nowrap;
}

.hl-level-posts {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.hl-level-formation-item {
	width: 100%;
}

.hl-no-formations {
	padding: 32px 24px;
	background: var(--hl-bg-primary, #f7f4ee);
	border: 1px dashed var(--hl-color-border, #ded7cb);
	border-radius: 12px;
	text-align: center;
	color: var(--hl-color-text-muted, #6e6459);
	font-size: 1rem;
	font-style: italic;
}

/* Block editor only: the ServerSideRender wrapper stops the container margins from
   collapsing into the page spacing, so they stack and the block looks taller than on the site */
.editor-styles-wrapper .hl-formations-levels-container {
	margin: 24px 0 0;
}

/* ==========================================================================
   2. Formation Card & Accordion Component
   ========================================================================== */
.hl-formation-toggle-box,
details.wp-block-details {
	border: 1.5px solid var(--hl-color-border, #ded7cb);
	border-radius: 12px;
	background: var(--hl-color-card-bg, #ffffff);
	box-shadow: 0 1px 4px rgba(31, 29, 26, 0.03);
	transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
	overflow: hidden;
	margin: 0 !important;
	padding: 0 !important;
}

.hl-formation-toggle-box:hover,
details.wp-block-details:hover {
	border-color: var(--hl-color-brand, #0c71c3);
	box-shadow: 0 4px 14px rgba(12, 113, 195, 0.12);
}

.hl-formation-toggle-box[open],
details.wp-block-details[open] {
	border-color: var(--hl-color-brand, #0c71c3);
	box-shadow: 0 6px 20px rgba(12, 113, 195, 0.14);
}

/* ==========================================================================
   3. Summary Header Row
   ========================================================================== */
.hl-formation-toggle-box summary,
details.wp-block-details summary {
	display: flex !important;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 16px 20px !important;
	cursor: pointer;
	user-select: none;
	list-style: none !important;
	background-color: #ffffff;
	transition: background-color 0.2s ease, border-color 0.2s ease;
	border-bottom: 1px solid transparent;
}

.hl-formation-toggle-box summary::-webkit-details-marker,
details.wp-block-details summary::-webkit-details-marker {
	display: none !important;
}

.hl-formation-toggle-box summary::marker,
details.wp-block-details summary::marker {
	display: none !important;
	content: "" !important;
}

.hl-formation-toggle-box summary:hover,
details.wp-block-details summary:hover {
	background-color: var(--hl-bg-primary, #f7f4ee);
}

.hl-formation-toggle-box[open] summary,
details.wp-block-details[open] summary {
	background-color: #f7fbff;
	border-bottom-color: #e1effa;
}

/* Title on the Left */
.hl-summary-title {
	flex: 1;
	font-size: 1.05rem;
	font-weight: 600;
	color: var(--hl-color-heading, #1f1d1a);
	line-height: 1.45;
	padding-right: 8px;
}

.hl-formation-toggle-box[open] .hl-summary-title {
	color: var(--hl-color-brand, #0c71c3);
}

/* Actions (Badge + Toggle Icon) on the Right */
.hl-summary-actions {
	display: inline-flex;
	align-items: center;
	gap: 12px;
	flex-shrink: 0;
}

/* ==========================================================================
   4. Status Badges
   ========================================================================== */
.hl-status-badge-wrap {
	display: inline-flex;
	align-items: center;
	margin: 0 !important;
}

.hl-status-badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 3px 10px;
	border-radius: 9999px;
	font-size: 12px;
	font-weight: 600;
	line-height: 1.25;
	white-space: nowrap;
}

/* Status: Ouvertes (Green) */
.hl-status-badge.is-open {
	background-color: #ecfdf5;
	color: #065f46;
	border: 1px solid #a7f3d0;
}

.hl-status-pulse {
	width: 7px;
	height: 7px;
	background: #10b981;
	border-radius: 50%;
	box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
	animation: hlBadgePulseGreen 2s infinite;
	flex-shrink: 0;
}

/* Status: Prochainement (Amber) */
.hl-status-badge.is-soon {
	background-color: #fffbeb;
	color: #92400e;
	border: 1px solid #fde68a;
}

.hl-status-pulse-soon {
	width: 7px;
	height: 7px;
	background: #f59e0b;
	border-radius: 50%;
	box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
	animation: hlBadgePulseAmber 2s infinite;
	flex-shrink: 0;
}

/* Status: Pas encore ouvertes (Warm stone neutral) */
.hl-status-badge.is-not-open {
	background-color: var(--hl-bg-primary, #f7f4ee);
	color: var(--hl-color-text-muted, #5c5347);
	border: 1px solid var(--hl-color-border, #ded7cb);
}

.hl-status-dot-slate {
	width: 7px;
	height: 7px;
	background: var(--hl-color-text-muted, #8c7f70);
	border-radius: 50%;
	flex-shrink: 0;
}

/* Status: Closes (Red) */
.hl-status-badge.is-closed {
	background-color: #fef2f2;
	color: #991b1b;
	border: 1px solid #fecaca;
}

.hl-status-dot-closed {
	width: 7px;
	height: 7px;
	background: #ef4444;
	border-radius: 50%;
	flex-shrink: 0;
}

/* Pulse Animations */
@keyframes hlBadgePulseGreen {
	0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
	70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
	100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes hlBadgePulseAmber {
	0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
	70% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
	100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* ==========================================================================
   5. Pixel-Perfect Centered + / − Vector Marker
   ========================================================================== */
.hl-formation-toggle-box summary::after,
details.wp-block-details summary::after {
	content: "";
	display: inline-block;
	width: 30px;
	height: 30px;
	min-width: 30px;
	border-radius: 50%;
	background-color: var(--hl-bg-primary, #f7f4ee);
	border: 1px solid var(--hl-color-border, #ded7cb);
	background-image: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 width=%2214%22 height=%2214%22 fill=%22none%22 stroke=%22%237b471e%22 stroke-width=%222.5%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cline x1=%2212%22 y1=%225%22 x2=%2212%22 y2=%2219%22/%3E%3Cline x1=%225%22 y1=%2212%22 x2=%2219%22 y2=%2212%22/%3E%3C/svg%3E");
	background-position: center center;
	background-repeat: no-repeat;
	transform-origin: center center;
	transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
	flex-shrink: 0;
	box-sizing: border-box;
}

.hl-formation-toggle-box summary:hover::after,
details.wp-block-details summary:hover::after {
	border-color: var(--hl-color-brand, #0c71c3);
	background-color: #e7f3fd;
	background-image: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 width=%2214%22 height=%2214%22 fill=%22none%22 stroke=%22%230c71c3%22 stroke-width=%222.5%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cline x1=%2212%22 y1=%225%22 x2=%2212%22 y2=%2219%22/%3E%3Cline x1=%225%22 y1=%2212%22 x2=%2219%22 y2=%2212%22/%3E%3C/svg%3E");
}

.hl-formation-toggle-box[open] summary::after,
details.wp-block-details[open] summary::after {
	background-color: var(--hl-color-brand, #0c71c3);
	border-color: var(--hl-color-brand, #0c71c3);
	background-image: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 width=%2214%22 height=%2214%22 fill=%22none%22 stroke=%22%23ffffff%22 stroke-width=%222.5%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cline x1=%225%22 y1=%2212%22 x2=%2219%22 y2=%2212%22/%3E%3C/svg%3E");
	transform: rotate(180deg);
}

/* ==========================================================================
   6. Card Interior Content (Expanded Details)
   ========================================================================== */
.hl-formation-body {
	padding: 24px 26px;
	background: #ffffff;
	border-top: 1px solid var(--hl-bg-secondary, #efe9e0);
}

.hl-formation-body > *:first-child {
	margin-top: 0;
}

.hl-formation-body > *:last-child {
	margin-bottom: 0;
}

.hl-formation-body p {
	margin-bottom: 16px;
	line-height: 1.6;
	color: var(--hl-color-text, #1f1d1a);
}

.hl-formation-body .wp-block-buttons {
	margin-top: 20px;
}

.hl-formation-body .wp-block-button__link {
	background-color: var(--hl-color-brand, #0c71c3);
	color: #ffffff;
	border-radius: 8px;
	transition: background-color 0.2s ease;
}

.hl-formation-body .wp-block-button__link:hover {
	background-color: var(--hl-color-brand-hover, #045cb4);
}

/* ==========================================================================
   7. Responsive Layout (Mobile & Tablet)
   ========================================================================== */
@media (max-width: 680px) {
	.hl-level-section {
		padding: 16px;
		border-radius: 12px;
	}

	.hl-level-header {
		flex-direction: column;
		align-items: flex-start;
		gap: 8px;
	}

	.hl-formation-toggle-box summary,
	details.wp-block-details summary {
		padding: 14px 16px !important;
	}

	/* Title + badge stacked on the left, +/− marker in its own column on the right */
	.hl-formation-toggle-box summary {
		display: grid !important;
		grid-template-columns: minmax(0, 1fr) auto;
		grid-template-areas:
			"title   marker"
			"actions marker";
		align-items: start;
		column-gap: 12px;
		row-gap: 10px;
	}

	.hl-formation-toggle-box .hl-summary-title {
		grid-area: title;
		padding-right: 0;
	}

	.hl-formation-toggle-box .hl-summary-actions {
		grid-area: actions;
		justify-content: flex-start;
	}

	/* Larger touch target on mobile */
	.hl-formation-toggle-box summary::after,
	details.wp-block-details summary::after {
		grid-area: marker;
		align-self: center;
		width: 36px;
		height: 36px;
		min-width: 36px;
	}

	.hl-formation-body {
		padding: 18px 16px;
	}
}

/* ==========================================================================
   8. Place Tag
   ========================================================================== */
.hl-formation-place {
	display: flex;
	align-items: center;
	gap: 4px;
	margin-top: 2px;
	font-size: 0.85rem;
	font-weight: 500;
	color: var(--hl-color-text-muted, #6e6459);
}

.hl-formation-place-icon {
	flex-shrink: 0;
}

/* ==========================================================================
   9. Programme Overview
   Everything the hl-formations/programme block needs, wherever it is placed
   (its root carries .hl-programme.hl-programme--calendar). The manual
   « Programme des formations » pattern uses the same classes on core
   Group / Columns / Table blocks. One .hl-programme__level per level: left column = level +
   prerequisite, right column = a table with one row per session (or a
   .hl-programme__empty line).
   ========================================================================== */
.hl-programme {
	background-color: var(--ast-global-color-5);
	/* Same responsive padding Astra gives top-level Groups */
	padding-top: var(--wp--custom--ast-default-block-top-padding, 3em);
	padding-bottom: var(--wp--custom--ast-default-block-bottom-padding, 3em);
	padding-left: var(--wp--custom--ast-default-block-left-padding, 3em);
	padding-right: var(--wp--custom--ast-default-block-right-padding, 3em);
	color: var(--ast-global-color-3);
}

.hl-programme__intro {
	margin-bottom: 2.5rem;
}

.hl-programme .hl-programme__eyebrow,
.hl-programme .hl-programme__num {
	margin: 0 0 0.35em;
	font-size: 0.8rem;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--ast-global-color-9);
}

.hl-programme .hl-programme__num {
	font-size: 0.85rem;
	font-weight: 800;
}

.hl-programme .hl-programme__heading {
	margin: 0 0 0.4em;
}

.hl-programme .hl-programme__quote {
	margin: 0;
	font-style: italic;
}

/* Level row: one card per level */
.hl-programme .hl-programme__level {
	margin: 0;
	padding: 1.75rem 1.5rem;
	gap: 0.75rem 2.5rem;
	background-color: var(--ast-global-color-4);
	border: 1px solid var(--ast-global-color-7);
	border-radius: 6px;
}

.hl-programme .hl-programme__level + .hl-programme__level {
	margin-top: 1rem;
}

.hl-programme .hl-programme__level > .wp-block-column {
	margin: 0;
}

.hl-programme .hl-programme__title {
	margin: 0 0 0.35em;
	font-size: 1.25rem;
	line-height: 1.3;
}

.hl-programme .hl-programme__prereq,
.hl-programme .hl-programme__empty {
	margin: 0;
	font-size: 0.95rem;
}

.hl-programme .hl-programme__empty {
	font-style: italic;
	padding-top: 0.5rem;
}

/* Sessions table */
.hl-programme .hl-programme__sessions {
	margin: 0;
}

.hl-programme .hl-programme__sessions table {
	width: 100%;
	margin: 0;
	border: 0;
	border-collapse: collapse;
	/* Same column widths in every level so the rows line up down the page */
	table-layout: fixed;
}

.hl-programme .hl-programme__sessions td {
	padding: 0.6rem 0.75rem 0.6rem 0;
	border: 0;
	border-bottom: 1px solid var(--ast-global-color-7);
	vertical-align: top;
}

.hl-programme .hl-programme__sessions tr:last-child td {
	border-bottom: 0;
}

/* Column headers (Pays / Dates / Lieu) are for screen readers only */
.hl-programme .hl-programme__sessions thead {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

.hl-programme .hl-programme__sessions td:nth-child(1) {
	width: 18%;
}

.hl-programme .hl-programme__sessions td:nth-child(2) {
	width: 35%;
	font-weight: 700;
	color: var(--ast-global-color-2);
}

.hl-programme .hl-programme__sessions td:last-child {
	padding-right: 0;
}

.hl-programme .hl-programme__note {
	margin: 1.75rem 0 0;
	padding: 0 1.5rem;
	font-size: 0.95rem;
	font-style: italic;
}

/* Phones: each session becomes a small stacked block */
@media (max-width: 600px) {
	.hl-programme .hl-programme__level {
		padding: 1.25rem 1rem;
	}

	.hl-programme .hl-programme__note {
		padding: 0 1rem;
	}

	/* Sessions sit right under the prerequisite, set off by a thin rule */
	.hl-programme .hl-programme__sessions,
	.hl-programme .hl-programme__empty {
		padding-top: 0.25rem;
		border-top: 1px solid var(--ast-global-color-7);
	}

	.hl-programme .hl-programme__empty {
		padding-top: 0.75rem;
	}

	.hl-programme .hl-programme__sessions table,
	.hl-programme .hl-programme__sessions tbody,
	.hl-programme .hl-programme__sessions tr {
		display: block;
	}

	.hl-programme .hl-programme__sessions tr {
		display: grid;
		grid-template-columns: auto 1fr;
		gap: 0.15rem 0.75rem;
		padding: 0.75rem 0;
		border-bottom: 1px solid var(--ast-global-color-7);
	}

	.hl-programme .hl-programme__sessions tr:last-child {
		border-bottom: 0;
	}

	.hl-programme .hl-programme__sessions td,
	.hl-programme .hl-programme__sessions td:nth-child(n) {
		width: auto;
		padding: 0;
		border: 0;
	}

	.hl-programme .hl-programme__sessions td:nth-child(3) {
		grid-column: 1 / -1;
	}
}

/* Block only: no band of its own, and two-column level cards */
.hl-programme--calendar {
	background-color: transparent;
	padding: 0;
	margin-bottom: 1.5em;
}

.hl-programme__levels > .hl-programme__level {
	display: grid;
	grid-template-columns: minmax(0, 36fr) minmax(0, 64fr);
}

.hl-programme__levels .hl-programme__col {
	margin: 0;
	overflow-wrap: break-word;
}

@media (max-width: 781px) {
	.hl-programme__levels > .hl-programme__level {
		grid-template-columns: minmax(0, 1fr);
	}
}
