/* Correctif v1.0.2 : la page Charte doit toujours pouvoir défiler verticalement.
   Certains réglages Kadence peuvent limiter la hauteur ou le débordement des conteneurs. */
html:has(body.asa-charte-page),
body.asa-charte-page {
    height: auto !important;
    min-height: 100% !important;
    max-height: none !important;
    overflow-y: auto !important;
}

body.asa-charte-page #wrapper,
body.asa-charte-page #inner-wrap,
body.asa-charte-page .site,
body.asa-charte-page .site-container,
body.asa-charte-page .content-area,
body.asa-charte-page .site-main,
body.asa-charte-page .content-wrap,
body.asa-charte-page .entry-content-wrap,
body.asa-charte-page .entry-content.single-content {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
}

/* En plein écran, seul le lecteur devient sa propre zone de défilement. */
body.asa-charte-page .asa-charte-reader:fullscreen {
    overflow-y: auto !important;
    overscroll-behavior: contain;
}

/* Nettoyage de la page WordPress qui héberge la charte.
   Le titre reste présent dans l'administration mais l'en-tête de page Kadence
   est masqué uniquement sur le site public. */
body.asa-charte-page .entry-hero,
body.asa-charte-page .entry-hero-container,
body.asa-charte-page .page-hero-section,
body.asa-charte-page .entry-header.entry-hero {
    display: none !important;
}

body.asa-charte-page .content-area {
    margin-top: 0 !important;
}

body.asa-charte-page .site-main,
body.asa-charte-page .content-wrap,
body.asa-charte-page .entry-content-wrap {
    padding-top: 0 !important;
}

body.asa-charte-page .entry-content.single-content {
    margin-top: 0 !important;
}

body.asa-charte-page .asa-charte-reader {
    margin-top: 28px;
    margin-bottom: 44px;
}

@media (max-width: 760px) {
    body.asa-charte-page .asa-charte-reader {
        margin-top: 18px;
        margin-bottom: 30px;
    }
}

.asa-charte-reader {
    --asa-red: #b51f1f;
    --asa-red-dark: #8f1717;
    --asa-navy: #172033;
    --asa-muted: #67748a;
    --asa-line: #dfe4eb;
    --asa-soft: #f5f7fa;
    --asa-paper: #ffffff;
    --asa-shadow: 0 18px 45px rgba(21, 30, 49, .14);
    width: min(1220px, 100%);
    margin: 0 auto;
    color: var(--asa-navy);
    outline: none;
}

.asa-charte-reader *,
.asa-charte-reader *::before,
.asa-charte-reader *::after { box-sizing: border-box; }

.asa-charte-reader:focus-visible {
    outline: 3px solid rgba(181, 31, 31, .28);
    outline-offset: 6px;
    border-radius: 12px;
}

.asa-charte-heading {
    text-align: center;
    margin: 0 auto 28px;
    padding: 0 18px;
}

.asa-charte-kicker {
    color: var(--asa-red);
    font-size: 12px;
    line-height: 1.3;
    font-weight: 800;
    letter-spacing: .18em;
    margin-bottom: 8px;
}

.asa-charte-heading h1 {
    margin: 0;
    color: var(--asa-navy);
    font-size: clamp(30px, 4.6vw, 52px);
    line-height: 1.05;
    font-weight: 800;
}

.asa-charte-heading p {
    margin: 12px 0 0;
    color: var(--asa-muted);
    font-size: clamp(15px, 2vw, 18px);
}

.asa-charte-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 16px;
    flex-wrap: wrap;
}

.asa-charte-toc-wrap { min-width: min(100%, 260px); }

.asa-charte-toc {
    width: 100%;
    min-height: 46px;
    padding: 0 42px 0 14px;
    border: 1px solid var(--asa-line);
    border-radius: 12px;
    background: #fff;
    color: var(--asa-navy);
    font-size: 15px;
    font-weight: 650;
}

.asa-charte-toolbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.asa-charte-btn {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 15px;
    border: 1px solid var(--asa-line);
    border-radius: 12px;
    background: #fff;
    color: var(--asa-navy);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none !important;
    cursor: pointer;
    transition: border-color .2s ease, background .2s ease, color .2s ease, transform .2s ease;
}

.asa-charte-btn:hover {
    border-color: #c4cad3;
    background: #fafbfc;
}

.asa-charte-btn:focus-visible,
.asa-charte-toc:focus-visible,
.asa-charte-edge:focus-visible {
    outline: 3px solid rgba(181, 31, 31, .24);
    outline-offset: 2px;
}

.asa-charte-btn:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.asa-charte-download {
    background: var(--asa-red);
    border-color: var(--asa-red);
    color: #fff !important;
}

.asa-charte-download:hover {
    background: var(--asa-red-dark);
    border-color: var(--asa-red-dark);
}

.asa-charte-stage {
    position: relative;
    padding: 20px 64px 28px;
    border: 1px solid #e4e8ee;
    border-radius: 22px;
    background:
        radial-gradient(circle at 50% 35%, rgba(181,31,31,.045), transparent 42%),
        linear-gradient(180deg, #f8f9fb 0%, #eef1f5 100%);
    overflow: hidden;
}

.asa-charte-book {
    position: relative;
    width: min(970px, 100%);
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr);
    align-items: stretch;
    perspective: 1800px;
    transform-style: preserve-3d;
}

.asa-charte-book.is-cover {
    grid-template-columns: minmax(0, 1fr);
    width: min(485px, 100%);
}

.asa-charte-book.is-cover .asa-charte-page-left,
.asa-charte-book.is-cover .asa-charte-spine { display: none; }

.asa-charte-page {
    position: relative;
    min-width: 0;
    aspect-ratio: 1100 / 1556;
    background: var(--asa-paper);
    box-shadow: var(--asa-shadow);
    overflow: hidden;
}

.asa-charte-page-left {
    border-radius: 12px 4px 4px 12px;
    transform-origin: right center;
}

.asa-charte-page-right {
    border-radius: 4px 12px 12px 4px;
    transform-origin: left center;
}

.asa-charte-book.is-cover .asa-charte-page-right { border-radius: 12px; }

.asa-charte-page img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    background: #fff;
    user-select: none;
    -webkit-user-drag: none;
}

.asa-charte-page-number {
    position: absolute;
    bottom: 9px;
    right: 12px;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(23,32,51,.82);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    backdrop-filter: blur(6px);
}

.asa-charte-page-left .asa-charte-page-number { right: auto; left: 12px; }

.asa-charte-spine {
    position: relative;
    z-index: 3;
    margin: 3px 0;
    background: linear-gradient(90deg, rgba(23,32,51,.12), rgba(255,255,255,.8) 48%, rgba(23,32,51,.12));
    box-shadow: inset 0 0 9px rgba(23,32,51,.15);
}

.asa-charte-edge {
    position: absolute;
    z-index: 6;
    top: 50%;
    width: 48px;
    height: 64px;
    margin-top: -32px;
    border: 1px solid rgba(23,32,51,.11);
    border-radius: 14px;
    background: rgba(255,255,255,.94);
    color: var(--asa-navy);
    box-shadow: 0 8px 26px rgba(23,32,51,.12);
    font-size: 38px;
    line-height: 1;
    cursor: pointer;
}

.asa-charte-edge:disabled { opacity: .3; cursor: not-allowed; }
.asa-charte-edge-prev { left: 10px; }
.asa-charte-edge-next { right: 10px; }

.asa-charte-book.turn-next .asa-charte-page-right {
    animation: asaPageNext .36s ease both;
}
.asa-charte-book.turn-prev .asa-charte-page-left {
    animation: asaPagePrev .36s ease both;
}

@keyframes asaPageNext {
    0% { transform: rotateY(0deg); opacity: 1; }
    48% { transform: rotateY(-14deg); opacity: .72; }
    100% { transform: rotateY(0deg); opacity: 1; }
}
@keyframes asaPagePrev {
    0% { transform: rotateY(0deg); opacity: 1; }
    48% { transform: rotateY(14deg); opacity: .72; }
    100% { transform: rotateY(0deg); opacity: 1; }
}

.asa-charte-footerbar {
    display: grid;
    grid-template-columns: minmax(100px, 1fr) auto minmax(100px, 1fr);
    align-items: center;
    gap: 18px;
    margin-top: 14px;
    color: var(--asa-muted);
    font-size: 13px;
}

.asa-charte-progress {
    height: 5px;
    overflow: hidden;
    border-radius: 999px;
    background: #e4e8ee;
}
.asa-charte-progress span {
    display: block;
    width: 4%;
    height: 100%;
    border-radius: inherit;
    background: var(--asa-red);
    transition: width .25s ease;
}
.asa-charte-status { font-weight: 800; color: var(--asa-navy); text-align: center; }
.asa-charte-hint { text-align: right; }

.asa-charte-noscript {
    padding: 12px 16px;
    border-radius: 10px;
    background: #fff4f4;
    color: #7c1b1b;
}

.asa-charte-reader:fullscreen {
    width: 100%;
    max-width: none;
    overflow: auto;
    padding: 24px;
    background: #eef1f5;
}
.asa-charte-reader:fullscreen .asa-charte-stage { min-height: calc(100vh - 190px); display: flex; align-items: center; }

@media (max-width: 900px) {
    .asa-charte-stage { padding-left: 54px; padding-right: 54px; }
    .asa-charte-btn-label { display: none; }
    .asa-charte-btn { min-width: 46px; padding-left: 12px; padding-right: 12px; }
}

@media (max-width: 760px) {
    .asa-charte-toolbar { align-items: stretch; }
    .asa-charte-toc-wrap { width: 100%; }
    .asa-charte-toolbar-actions { width: 100%; justify-content: space-between; }
    .asa-charte-download { flex: 1; }
    .asa-charte-download .asa-charte-btn-label { display: inline; }

    .asa-charte-stage {
        padding: 14px 48px 18px;
        border-radius: 16px;
    }

    .asa-charte-book,
    .asa-charte-book.is-cover {
        width: min(520px, 100%);
        grid-template-columns: minmax(0,1fr);
    }

    .asa-charte-page-left,
    .asa-charte-spine { display: none !important; }
    .asa-charte-page-right { border-radius: 10px; }
    .asa-charte-page-right .asa-charte-page-number { display: inline-flex; }

    .asa-charte-edge { width: 40px; height: 58px; margin-top: -29px; border-radius: 12px; font-size: 32px; }
    .asa-charte-edge-prev { left: 4px; }
    .asa-charte-edge-next { right: 4px; }

    .asa-charte-footerbar {
        grid-template-columns: 1fr auto;
        gap: 10px;
    }
    .asa-charte-hint { display: none; }
}

@media (max-width: 420px) {
    .asa-charte-stage { padding-left: 38px; padding-right: 38px; }
    .asa-charte-toolbar-actions { gap: 6px; }
    .asa-charte-btn { min-width: 44px; min-height: 44px; }
    .asa-charte-download .asa-charte-btn-label { font-size: 12px; }
}

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