:root {
    --bg: #0e3040;
    --panel: #124054;
    --panel-2: #124054;
    --text: #e7f3f9;
    --muted: #8fb0c2;
    --accent: #7be3ff;
    --accent-2: #ffa117;
    --text-color-dark: #0e3040;
    --border: rgba(255, 255, 255, .12);
    --shadow-dark: 0 16px 32px rgba(0, 0, 0, .6);

    --radius-card: 12px;
    --font-size-small: 13px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.glossary-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
    padding-top: 4px;
    color: var(--text);
}

/* TOP BAR -------------------------------------------------- */
.glossary-nav {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.glossary__nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.glossary__nav__item {
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    padding: .4rem .7rem;
    border-radius: 6px;
    font-size: var(--font-size-small);
    cursor: pointer;
    transition: background .15s ease, color .15s ease, border .15s ease;
}

.glossary__nav__item:hover,
.glossary__nav__item.active {
    background: var(--accent);
    color: var(--text-color-dark);
    border-color: rgba(0, 0, 0, 0.1);
}

/* SEARCH (full-width, bottom border) ---------------------- */
.glossary__search {
    width: 100%;
}

.glossary__search__form {
    width: 100%;
}

.glossary__search__form .form-control {
    width: 100%;
    border: none;
    border-bottom: 2px solid rgba(231, 243, 249, .25);
    border-radius: 0;
    background: #124054;
    color: var(--text);
    padding: .7rem .75rem;
    font-size: .9rem;
    transition: border-color .2s ease;
}

.glossary__search__form .form-control::placeholder {
    color: rgba(231, 243, 249, .6);
}

.glossary__search__form .form-control:focus {
    outline: none;
    border-bottom-color: var(--accent);
    background: #124054;
    box-shadow: none;
}

/* RESULTS GRID --------------------------------------------- */
.glossary__results {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
}

.glossary__results__item {
    position: relative;
}

.card {
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, .03);
    border-radius: 5px;
    padding: .75rem .8rem 1rem;
    display: block;
    text-decoration: none;
    color: var(--text);
    transition: border .15s ease, box-shadow .15s ease, transform .15s ease;
    min-height: 110px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

/* header row: title + x ------------------------------------ */
.card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .4rem;
}

.card__title {
    font-size: .82rem;
    font-weight: 600;
    margin: 0;
    padding: 0;
    line-height: 1.1;
}

/* close 'x' — HIDDEN BY DEFAULT (no hover show) ------------ */
.card-close {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .25);
    background: rgba(14, 48, 64, .4);
    color: #fff;
    font-size: 12px;
    line-height: 19px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease, background .15s ease;
    flex-shrink: 0;
}

/* show ONLY when card is selected */
.card.selected .card-close {
    opacity: 1;
    pointer-events: auto;
}

.card-close:hover {
    background: rgba(255, 255, 255, .15);
}

.card:hover {
    border: 1px solid rgba(123, 227, 255, .35);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
    transform: translateY(-1px);
}

.card.selected {
    border: 1px solid rgba(123, 227, 255, .8);
    box-shadow: 0 0 0 1px rgba(123, 227, 255, .35), 0 10px 28px rgba(0, 0, 0, .4);
}

.card__text {
    font-size: .73rem;
    line-height: 1.35;
    color: var(--muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* MODAL ---------------------------------------------------- */
.glossary-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1.5rem;
}

.glossary-modal.show {
    display: flex;
}

.glossary-modal__content {
    background: var(--panel-2);
    border: 1px solid rgba(255, 255, 255, .06);
    border-radius: 5px;
    width: min(880px, 96vw);
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-dark);
    position: relative;
    padding: 1.25rem 1.5rem 1.25rem;
    cursor: pointer;
    /* per your ask: click anywhere in modal closes */
}

/* modal header matches card header ------------------------- */
.glossary-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .6rem;
}

.glossary-modal__title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.glossary-modal__close {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .3);
    background: rgba(14, 48, 64, .6);
    color: #fff;
    text-align: center;
    line-height: 23px;
    cursor: pointer;
    font-weight: 600;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    padding-left: 1.5px;
}

.glossary-modal__body {
    font-size: .8rem;
    line-height: 1.5;
    color: var(--text);
}

/* RESPONSIVE ----------------------------------------------- */
@media (max-width: 980px) {
    .glossary__results {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .glossary__results {
        grid-template-columns: 1fr;
    }

    .glossary-modal {
        padding: .8rem;
    }

    .glossary-modal__content {
        width: 100%;
        max-height: calc(100vh - 1.5rem);
    }
}

/* custom */
.page-template-tpl-glossary .sidebar-right {
    display: none;
}

.page-template-tpl-glossary .layout {
    grid-template-columns: 200px 1fr 0;
    padding-top: 100px;
}

.glossary-modal__content {
    margin-top: -50vh;
}

@media screen and (min-width: 1601px) {
  .page-template-tpl-glossary .layout {
    grid-template-columns: 0px 1fr 0;
  }
}

@media (max-width: 900px) {
    .page-template-tpl-glossary .layout {
        grid-template-columns: 1fr;
    }

    .glossary-modal__content {
        margin-top: 0;
    }
}