/*
 * GLOSSAIRE — Page /glossaire/
 * ========================================
 * Styles pour la liste alphabétique des définitions botaniques.
 * Mobile-first, police kraft, pas de JS.
 */

/* -------------------------------------------------------
   STRUCTURE GÉNÉRALE
   ------------------------------------------------------- */

.ps-glossaire-wrap {
    padding: 1rem 2rem 4rem;
    width: 100%;
}

.ps-glossaire-titre {
    font-family: "OldNewspaperTypesALM", serif;
    color: #7D2B0B;
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    text-align: center;
    margin: 1rem 0 1rem;
}

.ps-glossaire-intro {
    text-align: center;
    font-style: italic;
    color: #4f3821;
    width: 100%;
    margin: 0 auto 2.5rem;
    line-height: 1.7;
    font-size: 1.15rem;
}

/* -------------------------------------------------------
   INDEX A-Z
   ------------------------------------------------------- */

.ps-glossaire-index {
    position: sticky;
    top: 80px;
    background: rgba(220, 195, 155, 0.92);
    padding: 0.8rem 1rem;
    border-radius: 6px;
    z-index: 50;
    margin-bottom: 3rem;
    box-shadow: 0 2px 6px rgba(44, 24, 16, 0.15);
}

.ps-glossaire-index ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.3rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.ps-glossaire-index li {
    display: flex;
}

.ps-glossaire-index li a {
    display: inline-block;
    padding: 0.35em 0.65em;
    background: rgba(44, 24, 16, 0.08);
    border-radius: 4px;
    font-family: "OldNewspaperTypesALM", serif;
    font-size: 1.2rem;
    font-weight: bold;
    color: #2C1810;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.ps-glossaire-index li a:hover {
    background: #D4600A;
    color: #fff;
}

.ps-glossaire-index .ps-lettre-vide {
    display: inline-block;
    padding: 0.35em 0.65em;
    font-family: "OldNewspaperTypesALM", serif;
    font-size: 1.2rem;
    font-weight: bold;
    color: #8a6a4a;
    opacity: 0.7;
}

/* -------------------------------------------------------
   SECTIONS PAR LETTRE
   ------------------------------------------------------- */

.ps-glossaire-sections {
    margin-top: 1rem;
}

.ps-glossaire-lettre {
    margin-bottom: 3rem;
}

.ps-glossaire-lettre-titre {
    font-family: "OldNewspaperTypesALM", serif;
    font-size: 3rem;
    color: #D4600A;
    border-bottom: 2px solid #C8A882;
    padding-bottom: 0.3rem;
    margin-bottom: 1.5rem;
}

/* -------------------------------------------------------
   CHAQUE DÉFINITION
   ------------------------------------------------------- */

.ps-definition {
    margin-bottom: 2.5rem;
    padding: 1.5rem;
    background: rgba(220, 183, 143, 0.3);
    border-radius: 6px;
    border-left: 4px solid #D4600A;
    scroll-margin-top: 140px; /* compense l'index sticky */
}

.ps-definition-titre {
    font-family: "OldNewspaperTypesALM", serif;
    color: #7D2B0B;
    font-size: 2.2rem;
    margin-top: 0;
    margin-bottom: 1rem;
}

.ps-definition-texte p,
.ps-definition-texte li {
    color: #2C1810;
    line-height: 1.7;
    font-size: 1.2rem;
}

.ps-definition-texte h3,
.ps-definition-texte h4 {
    color: #7D2B0B;
    font-family: "OldNewspaperTypesALM", serif;
    margin-top: 1.2rem;
    font-size: 1.4rem;
}

.ps-definition-texte a {
    color: #D4600A;
    text-decoration: underline;
}

.ps-definition-texte a:hover {
    color: #7D2B0B;
}

.ps-definition-synonymes {
    margin-top: 1.2rem;
    padding-top: 0.8rem;
    border-top: 1px dotted #C8A882;
    color: #4f3821;
    font-size: 1.1rem;
}

.ps-definition-synonymes em {
    color: #7D2B0B;
    font-style: italic;
}

.ps-definition-retour {
    display: inline-block;
    margin-top: 1rem;
    color: #D4600A;
    text-decoration: none;
    font-size: 1rem;
}

.ps-definition-retour:hover {
    text-decoration: underline;
}

/* -------------------------------------------------------
   RESPONSIVE MOBILE (< 768px)
   ------------------------------------------------------- */

@media (max-width: 768px) {

    .ps-glossaire-wrap {
        padding: 0.5rem 1rem 3rem;
    }

    .ps-glossaire-index {
        position: static; /* pas de sticky sur mobile — trop gênant */
        top: auto;
    }

    .ps-glossaire-index li a,
    .ps-glossaire-index .ps-lettre-vide {
        font-size: 1rem;
        padding: 0.3em 0.5em;
    }

    .ps-glossaire-lettre-titre {
        font-size: 2rem;
    }

    .ps-definition-titre {
        font-size: 1.7rem;
    }

    .ps-definition {
        padding: 1rem;
        scroll-margin-top: 80px;
    }

}

/* -------------------------------------------------------
   LIENS CONTEXTUELS (termes du glossaire dans les textes)
   ------------------------------------------------------- */

.ps-def-link {
    color: #D4600A;
    text-decoration: none;
    border-bottom: 1px dotted #D4600A;
    cursor: help;
    transition: background-color 0.2s ease;
    padding: 0 2px;
    border-radius: 2px;
}

.ps-def-link:hover,
.ps-def-link:focus {
    background-color: rgba(212, 96, 10, 0.15);
    color: #7D2B0B;
    border-bottom-color: #7D2B0B;
    outline: none;
}

/* Flash sur la définition ciblée par une ancre interne :
   quand on clique sur un ps-def-link depuis une autre définition,
   la cible s'illumine brièvement pour guider le regard. */
.ps-definition:target {
    animation: ps-def-flash 1.2s ease-out;
}

@keyframes ps-def-flash {
    0% {
        background-color: rgba(212, 96, 10, 0.3);
        box-shadow: 0 0 0 4px rgba(212, 96, 10, 0.3);
    }
    100% {
        background-color: rgba(220, 183, 143, 0.3);
        box-shadow: 0 0 0 0 transparent;
    }
}

/* ========================================================
   POPUPS DÉFINITIONS
   ======================================================== */

/* Voile sombre */
.ps-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(44, 24, 16, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}
.ps-popup-overlay--visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease, visibility 0s linear 0s;
}

/* Conteneur positionné (pour le décalage en cascade) */
.ps-popup-wrap {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}
.ps-popup-wrap--visible {
    opacity: 1;
    pointer-events: auto;
}

/* Boîte kraft */
.ps-popup {
    position: relative;
    width: 680px;
    max-width: calc(100vw - 2rem);
    font-family: "OldNewspaperTypesALM", serif;
    color: #2C1810;
}

.ps-popup-cadre {
    position: relative;
    border: 3px solid #4C351C;
    border-image: url('../images/border.png') 30 30 / 20px 20px / 0.2rem stretch;
    box-shadow: 2px 3px 6px rgba(40, 15, 0, 0.8), 4px 8px 20px rgba(60, 20, 0, 0.5);
    padding: 1.8rem 2rem;
    max-height: 80vh;
    overflow: visible;
}

.ps-popup-cadre::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('../images/kraft-long.jpg') #DCB78F;
    background-size: 250px;
    border-radius: 8px;
    z-index: 0;
    pointer-events: none;
}

.ps-popup-inner {
    position: relative;
    z-index: 1;
    max-height: calc(80vh - 3.6rem);
    overflow-y: auto;
    overflow-x: hidden;
}

.ps-popup .ps-popup-titre-kraft {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    font-size: 1.4rem;
    padding: 8px 30px 10px;
    white-space: nowrap;
    pointer-events: none;
    clip-path: inset(1.5px round 6px);
}

/* Bouton fermer × */
.ps-popup-close {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 2.2rem;
    background: url('../images/kraft-long.jpg') #DCB78F;
    background-size: 250px;
    border: 2px solid #4C351C;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(40, 15, 0, 0.4);
    font-family: Arial, sans-serif;
    font-size: 1.2rem;
    font-weight: bold;
    line-height: 1;
    color: #2C1810;
    cursor: pointer;
    padding: 0 0 2px 0;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    z-index: 4;
}

.ps-popup-close:hover,
.ps-popup-close:focus {
    background: #D4600A;
    background-image: none;
    border-color: #4C351C;
    color: #fff;
    outline: none;
}

/* Bouton retour — mobile uniquement */
.ps-popup-back {
    display: none;
    background: rgba(212, 96, 10, 0.12);
    border: 1px solid #D4600A;
    color: #7D2B0B;
    font-family: inherit;
    font-size: 1rem;
    padding: 0.4em 0.8em;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 1rem;
    transition: background 0.2s;
}
.ps-popup-back:hover {
    background: #D4600A;
    color: #fff;
}

/* Contenu interne */
.ps-popup-body {
    margin-top: 0.5rem;
}

.ps-popup-titre {
    font-family: "OldNewspaperTypesALM", serif;
    color: #7D2B0B;
    font-size: 2.2rem;
    margin: 0 0 1.2rem 0;
    padding-right: 2.5rem; /* évite le chevauchement avec le × */
}

.ps-popup-texte {
    font-size: 1.2rem;
    line-height: 1.6;
    color: #2C1810;
}
.ps-popup-texte p { margin: 0.6rem 0; }
.ps-popup-texte h3,
.ps-popup-texte h4 {
    color: #7D2B0B;
    font-family: "OldNewspaperTypesALM", serif;
    margin-top: 1rem;
    font-size: 1.3rem;
}
.ps-popup-texte img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 0.6rem 0;
}
.ps-popup-texte figure { margin: 1rem 0; }
.ps-popup-texte ul,
.ps-popup-texte ol { padding-left: 1.5rem; }

.ps-popup-synonymes {
    margin-top: 1.2rem;
    padding-top: 0.8rem;
    border-top: 1px dotted #C8A882;
    color: #4f3821;
    font-size: 1rem;
}
.ps-popup-synonymes em { color: #7D2B0B; }

.ps-popup-lien-glossaire {
    margin-top: 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.ps-popup-lien-livre {
    display: inline-block;
    line-height: 0;
}

.ps-popup-lien-livre:hover .ps-popup-livre,
.ps-popup-lien-livre:focus .ps-popup-livre {
    filter: drop-shadow(0 0 6px rgba(212, 96, 10, 0.85)) drop-shadow(0 0 12px rgba(212, 96, 10, 0.5));
}

.ps-popup-lien-livre:focus {
    outline: none;
}

.ps-popup-livre {
    height: 40px;
    width: auto;
    display: block;
    transition: filter 0.2s ease;
}

.ps-popup-lien-texte {
    color: #2C1810;
    text-decoration: none;
    font-size: 0.95rem;
}

.ps-popup-loading,
.ps-popup-error {
    text-align: center;
    color: #4f3821;
    font-style: italic;
    padding: 2rem;
}

/* Mobile */
@media (max-width: 768px) {
    .ps-popup {
        width: 100%;
        max-width: calc(100vw - 1rem);
    }
    .ps-popup-cadre {
        max-height: 90vh;
        padding: 1.5rem 1.2rem;
        border-image-width: 14px 14px;
        border-image-outset: 0.15rem;
    }
    .ps-popup-inner {
        max-height: calc(90vh - 3rem);
    }
    .ps-popup-titre { font-size: 1.6rem; }
    .ps-popup-texte { font-size: 1rem; }
    .ps-popup-back { display: inline-block; }
    .ps-popup .ps-popup-titre-kraft {
        top: -1rem;
        font-size: 1.15rem;
        padding: 5px 20px 7px;
    }
    .ps-popup-livre { height: 36px; }
    /* Pas de décalage en cascade sur mobile */
    .ps-popup-wrap { transform: translate(-50%, -50%) !important; }
}
