/* --- STYLES MAGNIFIQUES (CONDENSÉ) --- */
:root {
    --primary: #8E2183;
    --secondary: #FFD466;
    --text-dark: #1a0518;
    --text-grey: #4a4a4a;
    --bg-light: #f9f9f9;
}

html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
}

/* Hero Section */
.formation-hero {
    background: radial-gradient(circle at top right, #4a0e44 0%, #1a0518 100%);
    color: white;
    padding: 80px 0 60px;
    position: relative;
    overflow: hidden;
}

.formation-hero-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover;
    background-position: center;
    opacity: 0.2;
    z-index: 0;
    mix-blend-mode: overlay;
}

.formation-hero::before, .formation-hero::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: 1;
    opacity: 0.5;
}

.formation-hero::before {
    width: 500px; height: 500px;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    top: -150px; right: -50px;
}

.formation-hero::after {
    width: 300px; height: 300px;
    background: radial-gradient(circle, var(--secondary) 0%, transparent 70%);
    bottom: -50px; left: -50px;
}

.formation-hero .container {
    position: relative;
    z-index: 10;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Breadcrumbs */
.breadcrumbs {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.9);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.breadcrumbs a { color: white; text-decoration: none; font-weight: 600; }
.breadcrumbs a:hover { color: var(--secondary); }
.breadcrumbs span { margin: 0 10px; color: var(--secondary); }

/* Typography */
.formation-title {
    /* Le nom de la formation, pas la phrase entière : deux lignes au maximum */
    font-size: clamp(2rem, 3.4vw, 3rem);
    font-weight: 900;
    margin: 0 0 10px;
    line-height: 1.06;
    letter-spacing: -1px;
    color: #fff;
    max-width: 16ch;
}

/* La suite du titre : la promesse, lisible, sous le nom */
.formation-promesse {
    font-size: 1.22rem;
    line-height: 1.45;
    font-weight: 300;
    color: rgba(255,255,255,.92);
    max-width: 46ch;
    margin: 0 0 16px;
}

.formation-intro {
    font-size: 1.2rem;
    line-height: 1.5;
    max-width: 800px;
    color: rgba(255,255,255,0.9);
    margin-bottom: 30px;
}

/* Print Button */
.btn-print {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s;
    margin-top: 15px;
}

.btn-print:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

/* Meta Grid (Hero Stats) · GRID stable, hauteurs égales, anti-overflow */
.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
    margin-top: 30px;
}

.meta-card {
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 14px 18px;
    border-radius: 12px;
    border: 1px solid rgba(255,212,102,0.18);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
    min-height: 78px;
    transition: transform .25s, background .25s, border-color .25s;
}
.meta-card:hover {
    transform: translateY(-2px);
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,212,102,0.35);
}

.meta-number {
    font-size: 1.7rem;
    font-weight: 900;
    color: var(--secondary);
    line-height: 1.05;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
    /* Anti-overflow garanti */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.meta-label {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.85);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 800;
    line-height: 1.2;
}

.meta-detail {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.7);
    font-weight: 500;
    margin-top: 2px;
    line-height: 1.3;
}

/* Layout */
.formation-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 30px;
    padding: 40px 0;
    align-items: start;
    max-width: 1200px;
    margin: 0 auto;
}

/* Content Sections */
.content-section {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.03);
    margin-bottom: 30px;
}

/* Sidebar */
.sidebar-right {
    position: sticky;
    top: 110px;
}

.sidebar-card {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    margin-bottom: 20px;
    border: 1px solid rgba(0,0,0,0.04);
    transition: box-shadow 0.3s ease;
}

.sidebar-card:hover {
    box-shadow: 0 12px 35px rgba(0,0,0,0.12);
}

.info-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.info-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.info-icon {
    font-size: 1.3rem;
    color: var(--primary);
    background: rgba(142, 33, 131, 0.1);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.info-content strong {
    display: block;
    color: var(--text-dark);
    font-size: 1rem;
    line-height: 1.3;
}

.info-content span {
    font-size: 0.85rem;
    color: #666;
}

.btn-primary {
    display: block;
    width: 100%;
    text-align: center;
    background: var(--primary);
    color: white;
    padding: 12px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 700;
    transition: all 0.3s;
    box-shadow: 0 5px 15px rgba(142, 33, 131, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(142, 33, 131, 0.4);
    background: #7a1c70;
}

.btn-secondary-outline {
    display: block;
    width: 100%;
    text-align: center;
    background: transparent;
    color: var(--primary);
    padding: 12px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 700;
    border: 2px solid var(--primary);
    transition: all 0.3s;
    margin-top: 10px;
}

.btn-secondary-outline:hover {
    background: var(--primary);
    color: white;
}

/* ===== SECTIONS API AUTO ===== */
.api-section {
    background: white;
    padding: 35px;
    border-radius: 18px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.04);
    margin-bottom: 25px;
    border: 1px solid rgba(0,0,0,0.04);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.api-section:hover {
    box-shadow: 0 10px 35px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.api-section-title {
    font-size: 1.6rem;
    color: var(--primary);
    font-weight: 900;
    margin: 0 0 20px;
    padding-bottom: 12px;
    border-bottom: 3px solid var(--secondary);
}

.api-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.api-list li {
    position: relative;
    padding: 8px 0 8px 32px;
    line-height: 1.7;
    color: var(--text-grey);
    font-size: 1.05rem;
}

.api-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    top: 10px;
    color: white;
    background: var(--primary);
    font-weight: 900;
    font-size: 0.7rem;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(142, 33, 131, 0.2);
}

/* Modules · Accordéons Premium */
.api-module {
    background: white;
    border-radius: 16px;
    margin-bottom: 14px;
    border: 1px solid #e9ecef;
    overflow: hidden;
    transition: all 0.3s ease;
}

.api-module:hover {
    box-shadow: 0 6px 20px rgba(142, 33, 131, 0.08);
    border-color: rgba(142, 33, 131, 0.15);
}

.api-module.is-open {
    border-color: rgba(142, 33, 131, 0.2);
    box-shadow: 0 8px 25px rgba(142, 33, 131, 0.1);
}

.api-module-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 22px;
    cursor: pointer;
    background: var(--bg-light);
    border: none;
    width: 100%;
    text-align: left;
    transition: all 0.25s ease;
    -webkit-appearance: none;
}

.api-module-header:hover {
    background: linear-gradient(135deg, #f8f4fb 0%, #f0f0f0 100%);
}

.api-module.is-open .api-module-header {
    background: linear-gradient(135deg, #f3e8f9 0%, #f8f4fb 100%);
}

.api-module-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: white;
    font-weight: 800;
    font-size: 0.85rem;
    border-radius: 50%;
    flex-shrink: 0;
    transition: transform 0.3s, box-shadow 0.3s;
}

.api-module.is-open .api-module-num {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(142, 33, 131, 0.3);
}

.api-module-titre {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
    flex: 1;
    transition: color 0.2s;
}

.api-module.is-open .api-module-titre {
    color: var(--primary);
}

.api-module-count {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    background: rgba(142, 33, 131, 0.08);
    padding: 4px 12px;
    border-radius: 50px;
    white-space: nowrap;
}

.api-module-chevron {
    font-size: 1rem;
    color: var(--text-grey);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s;
    flex-shrink: 0;
    margin-left: 8px;
}

.api-module.is-open .api-module-chevron {
    transform: rotate(180deg);
    color: var(--primary);
}

.api-module-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.api-module.is-open .api-module-body {
    max-height: 2000px;
}

.api-module-items {
    list-style: none;
    padding: 18px 22px 22px 22px;
    margin: 0;
    border-top: 1px solid #e9ecef;
}

.api-module-items li {
    padding: 8px 0 8px 28px;
    position: relative;
    color: var(--text-grey);
    font-size: 0.92rem;
    line-height: 1.7;
    opacity: 0;
    transform: translateX(-8px);
    animation: moduleItemIn 0.3s ease forwards;
}

.api-module-items li:nth-child(1) { animation-delay: 0.05s; }
.api-module-items li:nth-child(2) { animation-delay: 0.1s; }
.api-module-items li:nth-child(3) { animation-delay: 0.15s; }
.api-module-items li:nth-child(4) { animation-delay: 0.2s; }
.api-module-items li:nth-child(5) { animation-delay: 0.25s; }
.api-module-items li:nth-child(6) { animation-delay: 0.3s; }
.api-module-items li:nth-child(7) { animation-delay: 0.35s; }
.api-module-items li:nth-child(8) { animation-delay: 0.4s; }

@keyframes moduleItemIn {
    to { opacity: 1; transform: translateX(0); }
}

.api-module-items li::before {
    content: '✦';
    position: absolute;
    left: 0;
    color: var(--secondary);
    font-weight: 700;
    font-size: 0.7rem;
    top: 11px;
}

/* Sessions · Premium Design */
.api-session {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 18px 22px;
    background: white;
    border-radius: 14px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.api-session:hover {
    border-color: var(--primary);
    box-shadow: 0 6px 20px rgba(142, 33, 131, 0.08);
    transform: translateY(-2px);
}

.api-session::before {
    content: '📅';
    font-size: 1.3rem;
    flex-shrink: 0;
}

.api-session--complet {
    opacity: 0.55;
    background: #fef2f2;
    border-color: #fecaca;
}

.api-session--complet::before {
    content: '🚫';
}

.api-session--complet:hover {
    transform: none;
    box-shadow: none;
    border-color: #fecaca;
}

.api-session--complet .api-session-dates {
    text-decoration: line-through;
    color: #999;
}

/* Session urgence (≤ 3 places) · bordure rouge pulsante */
.api-session--urgence {
    border-color: #e74c3c;
    background: linear-gradient(135deg, #fff5f5 0%, #fff 100%);
    animation: border-pulse 2s ease-in-out infinite;
}

.api-session--urgence::before {
    content: '🔥';
}

@keyframes border-pulse {
    0%, 100% { border-color: #e74c3c; box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
    50% { border-color: #c0392b; box-shadow: 0 0 15px 0 rgba(231, 76, 60, 0.15); }
}

.api-session-dates {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-dark);
    flex: 1;
}

.api-session-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.api-session-cta {
    background: var(--primary);
    color: white !important;
    padding: 6px 16px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
    border-bottom: none !important;
    transition: all 0.3s;
    white-space: nowrap;
}

.api-session-cta:hover {
    background: #6b1563;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(142,33,131,0.3);
    color: white !important;
    border-bottom: none !important;
}

.api-badge {
    font-size: 0.75rem;
    font-weight: 800;
    padding: 6px 14px;
    border-radius: 50px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.api-badge--complet {
    background: #e74c3c;
    color: white;
}

.api-badge--places {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    color: #155724;
    border: 1px solid #b1dfbb;
}

/* 3-4 places · badge orange (attention) */
.api-badge--attention {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
    border: 1px solid rgba(245, 158, 11, 0.4);
    font-weight: 800;
}

/* Dernières places · badge urgence clignotant */
.api-badge--urgence {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    animation: pulse-urgence 1.5s ease-in-out infinite;
    font-weight: 900;
    font-size: 0.8rem;
    padding: 8px 16px;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
    border-radius: 8px;
    line-height: 1.3;
    text-align: center;
}

@keyframes pulse-urgence {
    0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3); }
    50% { opacity: 0.85; transform: scale(1.05); box-shadow: 0 6px 20px rgba(231, 76, 60, 0.5); }
}

/* Zone libre */
.zone-libre {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.03);
    margin-bottom: 30px;
}

/* Pédagogie */
.api-pedagogy-block {
    margin-bottom: 20px;
}

.api-pedagogy-block h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0 0 8px;
}

.api-pedagogy-block p {
    color: var(--text-grey);
    margin: 0;
    line-height: 1.8;
}

/* Responsive */
@media (max-width: 992px) {
    .formation-layout { grid-template-columns: 1fr; }
    .sidebar-right { position: static; }
    .formation-title { font-size: 2.4rem; max-width: none; }
    .hero-content { flex-direction: column; gap: 30px; align-items: stretch; }
    /* Sur petit écran, le titre passe avant le visuel : on doit savoir de
       quelle formation il s'agit avant de voir la prochaine date. */
    .hero-image { order: 0; width: 100%; max-width: 100% !important; }
}

@media (max-width: 768px) {
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        position: relative !important;
    }
    .container {
        width: 100% !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
        overflow-x: hidden !important;
    }
    .formation-layout {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 20px 0 !important;
        gap: 20px !important;
        overflow: hidden !important;
    }
    .content-section,
    .sidebar-card,
    .api-section,
    .zone-libre,
    .formation-hero {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    .content-section, .api-section, .zone-libre {
        padding: 20px 15px !important;
    }
    .content-section > *,
    .entry-content > * {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    img, video, iframe, object, embed {
        max-width: 100% !important;
        height: auto !important;
    }
    .formation-hero { padding: 40px 0; }
    .formation-title { font-size: 1.85rem; word-wrap: break-word; max-width: none; }
    .formation-promesse { font-size: 1.05rem; }
    .formation-intro { font-size: 1rem; }
    .meta-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .meta-card { padding: 12px 14px; min-height: 70px; }
    .meta-number { font-size: 1.4rem; }
    .meta-label { font-size: 0.68rem; }
    .meta-detail { font-size: 0.72rem; }
    .wp-block-columns { flex-direction: column; gap: 20px; }
    .wp-block-column { width: 100% !important; margin: 0 !important; }
    .formation-hero::before,
    .formation-hero::after { display: none !important; }
    .api-session { flex-direction: column; align-items: flex-start; }
}

/* --- GUTENBERG BLOCKS STYLING (MAGNIFICENT) --- */
h2.wp-block-heading {
    font-size: 2.2rem;
    color: var(--primary);
    margin-top: 60px;
    margin-bottom: 40px;
    font-weight: 900;
    position: relative;
    padding-bottom: 20px;
    text-align: center;
    letter-spacing: -0.5px;
}

h2.wp-block-heading::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 6px;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    border-radius: 3px;
}

h2.wp-block-heading.has-text-align-left::after {
    left: 0;
    transform: none;
}

h3.wp-block-heading {
    font-size: 1.6rem;
    color: var(--text-dark);
    margin-top: 40px;
    margin-bottom: 25px;
    font-weight: 800;
}

p {
    line-height: 1.8;
    color: #4a4a4a;
    margin-bottom: 20px;
    font-size: 1.05rem;
}

p.has-medium-font-size {
    font-size: 1.25rem !important;
    line-height: 1.6;
    color: var(--text-dark);
    font-weight: 500;
}

p.has-small-font-size {
    font-size: 0.95rem !important;
    color: #666;
}

.wp-block-group.section-grey {
    background: #f8f9fa;
    padding: 50px;
    border-radius: 20px;
    margin: 50px 0;
    border: 1px solid #e9ecef;
    box-shadow: 0 10px 30px rgba(0,0,0,0.03);
    transition: transform 0.3s ease;
}

.wp-block-group.section-grey:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.06);
}

.wp-block-group.section-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #5e1456 100%);
    color: white;
    padding: 50px;
    border-radius: 20px;
    margin: 50px 0;
    box-shadow: 0 20px 50px rgba(142, 33, 131, 0.25);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
}

.wp-block-group.section-primary::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255, 212, 102, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.wp-block-group.section-primary h2,
.wp-block-group.section-primary h3,
.wp-block-group.section-primary p,
.wp-block-group.section-primary li,
.wp-block-group.section-primary strong {
    color: white !important;
}

.wp-block-group.section-primary h2::after {
    background: var(--secondary);
    box-shadow: 0 0 10px rgba(255, 212, 102, 0.5);
}

ul.wp-block-list {
    list-style: none;
    padding: 0;
    margin: 20px 0;
}

ul.wp-block-list li {
    position: relative;
    padding-left: 40px;
    margin-bottom: 15px;
    line-height: 1.6;
    font-size: 1.1rem;
    color: var(--text-dark);
}

ul.wp-block-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    top: 2px;
    color: white;
    background: var(--primary);
    font-weight: 900;
    font-size: 0.8rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 8px rgba(142, 33, 131, 0.2);
}

.section-primary ul.wp-block-list li::before {
    background: white;
    color: var(--primary);
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
}

.wp-block-columns { gap: 40px; margin-bottom: 40px; }
.wp-block-column { flex: 1; }

.wp-block-gallery { gap: 20px !important; }

.wp-block-image img,
.wp-block-gallery .wp-block-image img {
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.wp-block-image img:hover,
.wp-block-gallery .wp-block-image img:hover {
    transform: scale(1.02);
    box-shadow: 0 15px 35px rgba(0,0,0,0.15);
}

a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

a:hover {
    color: #7a1c70;
    border-bottom-color: var(--secondary);
}

.section-primary a { color: var(--secondary); text-decoration: none; border-bottom: 1px solid rgba(255,255,255,0.3); }
.section-primary a:hover { color: white; border-bottom-color: white; }

@media (max-width: 768px) {
    .wp-block-group.section-grey,
    .wp-block-group.section-primary {
        padding: 30px 20px !important;
        margin: 30px 0 !important;
        border-radius: 15px !important;
    }
    h2.wp-block-heading {
        font-size: 1.8rem !important;
        margin-top: 40px !important;
    }
    ul.wp-block-list li { font-size: 1rem !important; }
    .wp-block-gallery.columns-4 {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
}

.formation-hero-bg video {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    object-fit: cover;
    opacity: 0.9;
    z-index: 0;
}
