/**
 * Glossario in pagina: frase cliccabile + modal con overlay in blur.
 * Grafica ispirata a sviluppo-html/glossario-in-pagina/demo.html.
 */

/* Frase match cliccabile dentro al testo */
.glossario-term {
    display: inline;
    /* un <button> non spezza il testo su più righe finché white-space è normal:
       senza, l'intero termine va a capo dopo la parola che lo precede. */
    white-space: normal;
    word-break: normal;
    overflow-wrap: anywhere;
    margin: 0;
    padding: 0 .1em;
    border: 0;
    background: none;
    font: inherit;
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
    cursor: pointer;
    transition: color .2s ease, background-color .2s ease;
    text-align: inherit;
}
.glossario-term:hover,
.glossario-term:focus-visible {
    color: #fff;
    background-color: var(--icotea-brand-blue, #0d5bab);
    text-decoration: none;
    border-radius: 4px;
}

/* Overlay a tutta pagina con sfondo in blur */
.glossario-overlay {
    position: fixed;
    inset: 0;
    z-index: 100050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, .5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}
.glossario-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* Blocca lo scroll del body quando il modal è aperto */
body.glossario-modal-open {
    overflow: hidden;
}

/* Card del modal */
.glossario-modal {
    position: relative;
    width: 100%;
    max-width: 34rem;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #f1f5f9;
    border-radius: 1rem;
    padding: 1.75rem;
    box-shadow: 0 20px 45px rgba(15, 23, 42, .25);
    transform: scale(.95);
    transition: transform .2s ease;
}
.glossario-overlay.is-open .glossario-modal:not([hidden]) {
    transform: scale(1);
}

/* Pulsante X in alto a destra */
.glossario-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 0;
    border-radius: .5rem;
    background: none;
    color: #94a3b8;
    cursor: pointer;
    transition: color .2s ease, background-color .2s ease;
}
.glossario-close:hover,
.glossario-close:focus-visible {
    color: #475569;
    background: #f1f5f9;
}

/* Badge "Voce di glossario" */
.glossario-badge {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    margin-bottom: 1rem;
    padding: .25rem .75rem;
    border: 1px solid rgba(251, 191, 36, .4);
    border-radius: 999px;
    background: #fffbeb;
    color: #92400e;
    font-size: .8rem;
    font-weight: 600;
}
.glossario-badge svg {
    color: #d97706;
    flex: 0 0 auto;
}

.glossario-modal-title {
    margin: 0 2rem .25rem 0;
    font-family: var(--icotea-font-heading, inherit);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--icotea-dark-blue, #0f172a);
}
.glossario-modal-subtitle {
    margin: 0 0 1rem;
    font-size: 1rem;
    font-style: italic;
    color: #64748b;
}

/* Corpo scrollabile con contenuto WYSIWYG */
.glossario-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    border: 1px solid #f1f5f9;
    border-radius: .75rem;
    background: #f8fafc;
    color: #334155;
    font-size: 1rem;
    line-height: 1.6;
}
.glossario-modal-body :first-child { margin-top: 0; }
.glossario-modal-body :last-child { margin-bottom: 0; }
.glossario-modal-body img {
    max-width: 100%;
    height: auto;
    border-radius: .5rem;
}

.glossario-modal-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 1.5rem;
    flex: 0 0 auto;
}
.glossario-btn-close {
    padding: .625rem 1.25rem;
    border: 0;
    border-radius: .75rem;
    background: var(--icotea-brand-blue, #0f172a);
    color: #fff;
    font-family: var(--icotea-font-heading, inherit);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .2s ease;
}
.glossario-btn-close:hover,
.glossario-btn-close:focus-visible {
    background: var(--icotea-brand-blue-dark, #0b4d92);
}

@media (max-width: 480px) {
    .glossario-modal { padding: 1.25rem; }
    .glossario-btn-close { width: 100%; }
}
