.wagtail-glossary-popover {
    position: fixed;
    z-index: 1080;
    box-sizing: border-box;
    max-width: min(24rem, calc(100vw - 1rem));
    padding: 0.75rem 1rem;
    border: 1px solid rgb(0 0 0 / 20%);
    border-radius: 0.375rem;
    background: #fff;
    box-shadow: 0 0.5rem 1rem rgb(0 0 0 / 15%);
    color: #212529;
    font-size: 0.875rem;
    line-height: 1.4;
}

/* Highlighted phrases keep the colour of the surrounding text, so they stay legible on
   any background. The doubled class outranks site rules such as `.article a { color }`. */
a.wagtail-glossary-trigger.wagtail-glossary-trigger,
a.wagtail-glossary-trigger.wagtail-glossary-trigger:visited,
a.wagtail-glossary-trigger.wagtail-glossary-trigger:hover {
    color: inherit;
    text-decoration: none;
}

.wagtail-glossary-trigger {
    padding: 0 0.25rem;
    border: 1px solid currentColor;
    border-radius: 0.375rem;
    transition: background-color 0.2s ease;
}

/* Feedback uses only background and box-shadow, which never move the surrounding text. */
.wagtail-glossary-trigger:hover,
.wagtail-glossary-trigger:focus {
    background-color: color-mix(in srgb, currentColor 12%, transparent);
}

.wagtail-glossary-trigger--pulse {
    animation: wagtail-glossary-pulse 0.5s ease-out;
}

@keyframes wagtail-glossary-pulse {
    from {
        box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 45%, transparent);
    }

    to {
        box-shadow: 0 0 0 0.5rem color-mix(in srgb, currentColor 0%, transparent);
    }
}

@media (prefers-reduced-motion: reduce) {
    .wagtail-glossary-trigger {
        transition: none;
    }

    .wagtail-glossary-trigger--pulse {
        animation: none;
    }
}

.wagtail-glossary-popover[hidden] {
    display: none;
}

.wagtail-glossary-visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

[data-wagtail-glossary-compact] {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0.25rem;
}

/* The icon is a miniature of a highlighted phrase. */
.wagtail-glossary-toggle-icon {
    padding: 0 0.2rem;
    border: 1px solid currentColor;
    border-radius: 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    transition: opacity 0.2s ease, border-color 0.2s ease;
}

[data-wagtail-glossary-compact][aria-pressed="false"] .wagtail-glossary-toggle-icon {
    border-color: transparent;
    opacity: 0.55;
    text-decoration: line-through;
}

/* Position can be adjusted per site with the custom properties below. */
.wagtail-glossary-floating {
    position: fixed;
    bottom: var(--wagtail-glossary-floating-bottom, 1rem);
    left: var(--wagtail-glossary-floating-left, 1rem);
    z-index: 1030;
    width: 2.75rem;
    min-width: 2.75rem;
    height: 2.75rem;
    margin: 0;
    border: 1px solid rgb(0 0 0 / 15%);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0.25rem 0.75rem rgb(0 0 0 / 15%);
    color: #212529;
    cursor: pointer;
}

.wagtail-glossary-floating:hover {
    background: #f1f3f5;
}

@media print {
    .wagtail-glossary-floating {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .wagtail-glossary-toggle-icon {
        transition: none;
    }
}
