/* CH Glossary – Frontend Styles */

/* ── Term highlight ─────────────────────────────── */
.ch-glossary-term {
    cursor: help;
    position: relative;
    display: inline;
}

/* Underline */
.ch-glossary-term[data-highlight="underline"],
body .ch-glossary-term {
    text-decoration: underline dotted var(--ch-glossary-highlight, #a8d8ea);
    text-underline-offset: 3px;
}
.ch-glossary-term[data-highlight="background"] {
    text-decoration: none;
    background-color: var(--ch-glossary-highlight, #a8d8ea);
    border-radius: 2px;
    padding: 0 2px;
}
.ch-glossary-term[data-highlight="both"] {
    text-decoration: underline dotted var(--ch-glossary-highlight, #a8d8ea);
    text-underline-offset: 3px;
    background-color: color-mix(in srgb, var(--ch-glossary-highlight, #a8d8ea) 30%, transparent);
    border-radius: 2px;
    padding: 0 2px;
}
.ch-glossary-term[data-highlight="none"] {
    text-decoration: none;
}

/* ── Tooltip container ──────────────────────────── */
.ch-glossary-tooltip {
    position: absolute;
    z-index: 99999;
    max-width: var(--ch-glossary-max-width, 320px);
    min-width: 180px;
    padding: 12px 15px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 4px 18px rgba(0,0,0,.15);
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s ease, transform .15s ease;
    transform: translateY(4px);
    white-space: normal;
    word-wrap: break-word;
}
.ch-glossary-tooltip.ch-tt-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Light theme (default) */
.ch-glossary-tooltip.ch-tt-light {
    background: #fff;
    color: #333;
    border: 1px solid #ddd;
}
/* Dark theme */
.ch-glossary-tooltip.ch-tt-dark {
    background: #222;
    color: #eee;
    border: 1px solid #444;
}

/* Arrow */
.ch-glossary-tooltip::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
}
.ch-glossary-tooltip.ch-tt-top::after {
    bottom: -12px;
    border-top-color: #ddd;
}
.ch-glossary-tooltip.ch-tt-top.ch-tt-dark::after {
    border-top-color: #444;
}
.ch-glossary-tooltip.ch-tt-bottom::after {
    top: -12px;
    border-bottom-color: #ddd;
}
.ch-glossary-tooltip.ch-tt-bottom.ch-tt-dark::after {
    border-bottom-color: #444;
}

/* Inner parts */
.ch-glossary-tooltip-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 6px;
}
.ch-glossary-tooltip-excerpt {
    margin: 0 0 8px;
    color: inherit;
}
.ch-glossary-read-more {
    font-size: 12px;
    text-decoration: underline;
    opacity: .75;
    display: inline-block;
}
.ch-glossary-read-more:hover {
    opacity: 1;
}
.ch-tt-dark .ch-glossary-read-more {
    color: #9dd;
}

/* ── Archive / Shortcode styles ─────────────────── */

/*
 * Some editors/themes may wrap a shortcode in <p><code>...</code></p>.
 * The shortcode still works, but inherited code styles can make the glossary
 * look broken. These resets keep the glossary layout clean in that case.
 */
.entry-content code:has(.ch-glossary-shortcode-wrap),
.entry-content p:has(.ch-glossary-shortcode-wrap) {
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    line-height: inherit;
    white-space: normal;
    box-shadow: none;
}

.ch-glossary-shortcode-wrap,
.ch-glossary-shortcode-wrap * {
    box-sizing: border-box;
}

.ch-glossary-shortcode-wrap {
    --ch-glossary-cd: #f07a00;
    --ch-glossary-cd-dark: #9b4400;
    --ch-glossary-cd-soft: #fff7ee;
    --ch-glossary-border: #e1e5eb;
    --ch-glossary-text: #1f2933;
    --ch-glossary-muted: #667085;
    width: 100%;
    max-width: 1080px;
    margin: 1.25rem 0 2rem;
    color: var(--ch-glossary-text);
    font-family: inherit;
    font-size: 16px;
    line-height: 1.55;
}

.ch-glossary-shortcode-wrap code,
.ch-glossary-shortcode-wrap pre {
    font: inherit;
    background: transparent;
    border: 0;
    padding: 0;
    color: inherit;
    white-space: normal;
}

.ch-glossary-search-wrap {
    position: relative;
    max-width: 520px;
    margin: 0 0 22px;
}

.ch-glossary-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    opacity: .62;
    pointer-events: none;
    font-size: 15px;
}

.ch-glossary-search-wrap input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 15px 12px 44px;
    font: inherit;
    font-size: 15px;
    line-height: 1.4;
    border: 1px solid #ccd2da;
    border-radius: 999px;
    background: #fff;
    color: var(--ch-glossary-text);
    box-shadow: 0 3px 10px rgba(16, 24, 40, .05);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.ch-glossary-search-wrap input:focus {
    outline: none;
    border-color: var(--ch-glossary-cd);
    box-shadow: 0 0 0 3px rgba(240, 122, 0, .14);
}

.ch-glossary-az-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 30px;
    padding: 10px 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.ch-glossary-az-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 11px;
    border: 1px solid #dde2e8;
    border-radius: 999px;
    background: #fff;
    color: var(--ch-glossary-cd-dark);
    font-weight: 700;
    text-decoration: none !important;
    font-size: 14px;
    line-height: 1;
    box-shadow: 0 2px 7px rgba(16, 24, 40, .04);
    transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.ch-glossary-az-link:hover,
.ch-glossary-az-link:focus {
    background: var(--ch-glossary-cd-soft);
    border-color: #f0b06c;
    color: var(--ch-glossary-cd-dark);
    transform: translateY(-1px);
}

.ch-glossary-az-list {
    display: grid;
    gap: 30px;
}

.ch-glossary-letter-section {
    scroll-margin-top: 90px;
}

.ch-glossary-letter-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 14px !important;
    padding: 0 !important;
    color: var(--ch-glossary-text) !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    text-align: left !important;
    font: inherit;
    font-size: 22px !important;
    font-weight: 800 !important;
    line-height: 1.2 !important;
}

.ch-glossary-letter-heading::before {
    content: '';
    width: 4px;
    height: 28px;
    border-radius: 999px;
    background: var(--ch-glossary-cd);
    flex: 0 0 auto;
}

.ch-glossary-letter-heading::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--ch-glossary-border);
}

.ch-glossary-entries {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: grid;
    gap: 12px;
}

.ch-glossary-entries li,
.ch-glossary-entry {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
}

.ch-glossary-entry::before,
.ch-glossary-entry::after {
    display: none !important;
    content: none !important;
}

.ch-glossary-entry-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 20px;
    border: 1px solid var(--ch-glossary-border);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 5px 18px rgba(16, 24, 40, .045);
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.ch-glossary-entry-card:hover {
    border-color: #f0b06c;
    box-shadow: 0 10px 26px rgba(16, 24, 40, .08);
    transform: translateY(-1px);
}

.ch-glossary-entry-main {
    min-width: 0;
    flex: 1 1 auto;
}

.ch-glossary-entry-title {
    margin: 0 0 6px !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    font-size: 18px !important;
    line-height: 1.3 !important;
    font-weight: 800 !important;
}

.ch-glossary-term-link {
    color: var(--ch-glossary-cd-dark);
    text-decoration: none !important;
    font-weight: 800;
}

.ch-glossary-term-link:hover,
.ch-glossary-term-link:focus {
    color: var(--ch-glossary-cd);
    text-decoration: underline !important;
    text-underline-offset: 3px;
}

.ch-glossary-variants {
    display: block;
    margin: 0 0 8px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--ch-glossary-muted);
}

.ch-glossary-variants span {
    font-weight: 700;
    color: #475467;
}

.ch-glossary-excerpt {
    margin: 0 !important;
    max-width: 820px;
    font-size: 14px;
    line-height: 1.65;
    color: #475467;
}

.ch-glossary-entry-more {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 999px;
    background: var(--ch-glossary-cd-soft);
    color: var(--ch-glossary-cd-dark);
    text-decoration: none !important;
    font-size: 20px;
    font-weight: 800;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}

.ch-glossary-entry-more:hover,
.ch-glossary-entry-more:focus {
    background: var(--ch-glossary-cd);
    color: #fff;
    transform: translateX(2px);
}

.ch-glossary-list {
    margin-top: 8px !important;
}

.ch-glossary-grid {
    display: grid;
    grid-template-columns: repeat(var(--ch-glossary-cols, 3), minmax(0, 1fr));
    gap: 16px;
    margin: 16px 0;
}

.ch-glossary-card {
    border: 1px solid var(--ch-glossary-border);
    border-radius: 14px;
    padding: 18px 20px;
    background: #fff;
    box-shadow: 0 5px 18px rgba(16, 24, 40, .045);
}

.ch-glossary-card h4 {
    margin: 0 0 8px !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    font-size: 18px !important;
    line-height: 1.3 !important;
}

.ch-glossary-card h4 a {
    color: var(--ch-glossary-cd-dark);
    text-decoration: none !important;
    font-weight: 800;
}

.ch-glossary-card h4 a:hover {
    color: var(--ch-glossary-cd);
    text-decoration: underline !important;
    text-underline-offset: 3px;
}

.ch-glossary-card p {
    margin: 0 !important;
    font-size: 14px;
    line-height: 1.65;
    color: #475467;
}

.ch-glossary-empty {
    padding: 16px 18px;
    border: 1px solid var(--ch-glossary-border, #e6e8ec);
    border-radius: 12px;
    background: #fff;
}

@media (max-width: 700px) {
    .ch-glossary-entry-card {
        align-items: flex-start;
        padding: 16px;
    }

    .ch-glossary-entry-more {
        width: 34px;
        height: 34px;
    }

    .ch-glossary-grid {
        grid-template-columns: 1fr;
    }
}

