/* WP Glossary Tooltip – Public Styles */
/* -------------------------------------------------------
   CSS custom properties (overridable from settings JS)
------------------------------------------------------- */
:root {
    --wpgt-brand:          #2563eb;
    --wpgt-width:          280px;
    --wpgt-radius:         6px;
    --wpgt-shadow:         0 8px 24px rgba(0,0,0,.18);
    --wpgt-transition:     0.18s ease;
    /* dark theme */
    --wpgt-dark-bg:      #1e293b;
    --wpgt-dark-text:    #f1f5f9;
    --wpgt-dark-link:    #93c5fd;

    /* light theme */
    --wpgt-light-bg:     #ffffff;
    --wpgt-light-text:   #1e293b;
    --wpgt-light-border: #e2e8f0;
    --wpgt-light-link:   #2563eb;
}

/* -------------------------------------------------------
   Trigger word underline
------------------------------------------------------- */
.wpgt-tooltip-trigger {
    border-bottom: 1.5px dashed var(--wpgt-brand);
    cursor: help;
    position: relative;
    display: inline;
    transition: border-color var(--wpgt-transition), color var(--wpgt-transition);
}
.wpgt-tooltip-trigger:hover,
.wpgt-tooltip-trigger:focus {
    border-bottom-style: solid;
    color: var(--wpgt-brand);
    outline: none;
}

/* -------------------------------------------------------
   Font inheritance fix
   position:fixed breaks the font inheritance chain,
   so we explicitly re-inherit the site font on every
   plugin element so it never falls back to browser default.
------------------------------------------------------- */
.wpgt-tooltip-bubble,
.wpgt-tooltip-trigger,
.wpgt-glossary-index,
.wpgt-alphabet-bar,
.wpgt-term-item,
.wpgt-term-box,
.wpgt-search-widget,
.wpgt-search-input,
.wpgt-search-results {
    font-family: inherit;
}

/* -------------------------------------------------------
   Tooltip bubble — position:fixed so it escapes
   any Elementor stacking context. JS sets top/left.
------------------------------------------------------- */
.wpgt-tooltip-bubble {
    position: fixed;
    z-index: 999999;
    /* Auto-width: grows with content, but never narrower than 200px or wider than viewport */
    width: max-content;
    min-width: 200px;
    max-width: min(500px, calc(100vw - 24px));
    /* Always wrap long words / URLs so nothing bleeds off-screen on mobile */
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    border-radius: var(--wpgt-radius);
    box-shadow: var(--wpgt-shadow);
    padding: 12px 14px 10px;
    font-size: 0.875rem;
    line-height: 1.55;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--wpgt-transition), transform var(--wpgt-transition);
    font-style: normal;
    font-weight: 400;
    /* animation starts slightly offset */
    transform: translateY(4px);
}
.wpgt-tooltip-bubble.wpgt-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Arrow — direction controlled by JS adding wpgt-above or wpgt-below class */
.wpgt-tooltip-bubble::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border: 7px solid transparent;
    left: 50%;
    transform: translateX(-50%);
}
/* Arrow pointing DOWN (tooltip is above the word) */
.wpgt-tooltip-bubble.wpgt-above::after {
    top: 100%;
    left: var(--wpgt-arrow-left, 50%);
    transform: translateX(-50%);
    border-top-color: var(--wpgt-arrow-color, #1e293b);
}
/* Arrow pointing UP (tooltip is below the word) */
.wpgt-tooltip-bubble.wpgt-below::after {
    bottom: 100%;
    left: var(--wpgt-arrow-left, 50%);
    transform: translateX(-50%);
    border-bottom-color: var(--wpgt-arrow-color, #1e293b);
}

/* -------------------------------------------------------
   Dark theme
------------------------------------------------------- */
.wpgt-theme-dark {
    /* background + backdrop-filter set exclusively via JS inline style */
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--wpgt-dark-text);
}
.wpgt-theme-dark .wpgt-tooltip-title { color: #ffffff; font-weight: 600; }
.wpgt-theme-dark .wpgt-tooltip-see-more { color: var(--wpgt-dark-link); }

/* -------------------------------------------------------
   Light theme
------------------------------------------------------- */
.wpgt-theme-light {
    /* background + backdrop-filter set exclusively via JS inline style */
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: var(--wpgt-light-text);
}
.wpgt-theme-light .wpgt-tooltip-title { color: #0f172a; font-weight: 600; }
.wpgt-theme-light .wpgt-tooltip-see-more { color: var(--wpgt-light-link); }


/* -------------------------------------------------------
   Branded theme
------------------------------------------------------- */
.wpgt-theme-branded {
    /* background + backdrop-filter set exclusively via JS inline style */
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
}
.wpgt-theme-branded .wpgt-tooltip-title { color: #fff; font-weight: 600; }
.wpgt-theme-branded .wpgt-tooltip-see-more { color: rgba(255,255,255,0.85); text-decoration: underline; }


/* -------------------------------------------------------
   Tooltip inner elements
------------------------------------------------------- */
.wpgt-tooltip-title {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9375rem;
}
.wpgt-tooltip-text {
    display: block;
    margin-bottom: 6px;
}
.wpgt-tooltip-see-more {
    display: inline-block;
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    margin-top: 4px;
}
.wpgt-tooltip-see-more:hover { text-decoration: underline; }

/* -------------------------------------------------------
   Glossary index – [wpgt_glossary]
------------------------------------------------------- */
.wpgt-glossary-index { margin: 1.5em 0; }

.wpgt-alphabet-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 1.5em;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}
.wpgt-az-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    color: var(--wpgt-brand);
    background: transparent;
    transition: background 0.15s, color 0.15s;
}
.wpgt-az-link:hover,
.wpgt-az-link:focus {
    background: var(--wpgt-brand);
    color: #fff;
    outline: none;
}
/* Current letter — non-clickable, visually distinct.
   Class-only selector (specificity 0,1,0) so override CSS wins. */
.wpgt-az-current {
    background: transparent;
    color: #94a3b8;
    cursor: default;
    border-color: #e2e8f0;
    border-width: 1px;
    border-style: solid;
}

/* -------------------------------------------------------
   Mobile: keep tooltip fully inside viewport
------------------------------------------------------- */
@media ( max-width: 600px ) {
    .wpgt-tooltip-bubble {
        font-size: 0.8125rem;
        padding: 10px 12px 8px;
        max-width: calc(100vw - 24px);
    }
}

.wpgt-letter-group { margin-bottom: 2.25em; }
.wpgt-letter-heading {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--wpgt-brand);
    margin: 0 0 0.75em;
    padding-bottom: 4px;
    border-bottom: 2px solid var(--wpgt-brand);
    display: inline-block;
}

.wpgt-term-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 12px;
}

/* Column grid variants */
.wpgt-columns-1 { grid-template-columns: 1fr; }
.wpgt-columns-2 { grid-template-columns: repeat(2, 1fr); }
.wpgt-columns-3 { grid-template-columns: repeat(3, 1fr); }
.wpgt-columns-4 { grid-template-columns: repeat(4, 1fr); }

@media ( max-width: 768px ) {
    .wpgt-columns-3,
    .wpgt-columns-4 { grid-template-columns: repeat(2, 1fr); }
}
@media ( max-width: 480px ) {
    .wpgt-columns-2,
    .wpgt-columns-3,
    .wpgt-columns-4 { grid-template-columns: 1fr; }
}

.wpgt-term-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 12px 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.wpgt-term-item:hover {
    border-color: var(--wpgt-brand);
    box-shadow: 0 2px 8px rgba(37,99,235,.1);
}

.wpgt-term-link {
    display: block;
    font-weight: 600;
    font-size: 0.9375rem;
    text-decoration: none;
    color: var(--wpgt-brand);
    margin-bottom: 4px;
}
.wpgt-term-link:hover { text-decoration: underline; }

.wpgt-term-excerpt {
    margin: 0;
    font-size: 0.8125rem;
    color: #64748b;
    line-height: 1.45;
}

/* -------------------------------------------------------
   Single-term box – [wpgt_term]
------------------------------------------------------- */
.wpgt-term-box {
    border-left: 4px solid var(--wpgt-brand);
    padding: 14px 18px;
    background: #f8fafc;
    border-radius: 0 6px 6px 0;
    margin: 1.25em 0;
}
.wpgt-term-box__title {
    margin: 0 0 8px;
    font-size: 1.05rem;
}
.wpgt-term-box__title a { color: var(--wpgt-brand); text-decoration: none; }
.wpgt-term-box__title a:hover { text-decoration: underline; }
.wpgt-term-box__definition { margin: 0; color: #374151; }

/* -------------------------------------------------------
   Search widget – [wpgt_search]
------------------------------------------------------- */

/* Visually-hidden utility — for screen-reader-only elements.
   This is the standard pattern per WebAIM / WAI-ARIA. */
.wpgt-sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.wpgt-search-widget {
    position: relative;
    max-width: 480px;
}

/* ── Input row: icon + input + clear button ── */
.wpgt-search-combobox {
    position: relative;
    display: flex;
    align-items: center;
}

/* Magnifying glass — absolute-positioned left of input */
.wpgt-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    display: flex;
    align-items: center;
    pointer-events: none;
    transition: color 0.15s;
    z-index: 2;
    line-height: 0;
}
.wpgt-search-widget.wpgt-loading .wpgt-search-icon svg {
    animation: wpgt-spin 0.65s linear infinite;
}
@keyframes wpgt-spin { to { transform: rotate(360deg); } }

.wpgt-search-input {
    width: 100%;
    padding: 10px 38px 10px 52px;
    box-sizing: border-box;
    font-size: 0.9375rem;
    border: 1.5px solid #d1d5db !important;
    border-style: solid !important;   /* prevent theme from switching to dashed/dotted */
    border-radius: 6px;
    background: #fff;
    color: #1e293b;
    outline: none !important;         /* prevent theme outline overrides */
    transition: border-color 0.15s, box-shadow 0.15s;
    -webkit-appearance: none;
}
.wpgt-search-input::-webkit-search-cancel-button { display: none; }
.wpgt-search-input:focus {
    outline: none;
    border-color: var(--wpgt-brand);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
/* When results are open, square the bottom corners to visually connect to dropdown */
.wpgt-search-input[aria-expanded="true"] {
    border-bottom-left-radius:  0;
    border-bottom-right-radius: 0;
    border-bottom-color: transparent;
}

/* Clear (×) button — shown by JS when input has text */
.wpgt-search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px; height: 20px;
    border-radius: 50%;
    padding: 0;
    transition: color 0.12s, background 0.12s;
    z-index: 1;
}
.wpgt-search-clear:hover { color: #1e293b; background: #f1f5f9; }
.wpgt-search-clear:focus-visible { outline: 2px solid var(--wpgt-brand); outline-offset: 1px; }
.wpgt-search-clear[hidden] { display: none; }

/* ── Results dropdown ── */
.wpgt-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1.5px solid #d1d5db;
    border-top: none;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    max-height: 320px;
    overflow-y: auto;
    z-index: 9999;
    /* Subtle entrance animation */
    animation: wpgt-dropdown-in 0.12s ease;
}
@keyframes wpgt-dropdown-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Result items ── */
.wpgt-search-result-item {
    display: block;
    padding: 10px 14px;
    text-decoration: none;
    color: #1e293b;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.1s, color 0.1s;
    cursor: pointer;
}
.wpgt-search-result-item:last-child { border-bottom: none; }

/* Hover AND keyboard-active state (aria-activedescendant target gets .wpgt-active) */
.wpgt-search-result-item:hover,
.wpgt-search-result-item.wpgt-active {
    background: #f0f7ff;
    color: var(--wpgt-brand);
    outline: none;
}

.wpgt-search-result-title  {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
}
.wpgt-search-result-excerpt {
    display: block;
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 2px;
    /* Clamp excerpt to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
/* Match highlight — <mark> is semantically correct for search matches (HTML spec §4.5.23) */
.wpgt-search-match {
    background: transparent;
    color: inherit;
    font-weight: 700;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
}

.wpgt-search-no-results {
    display: block;
    padding: 14px 16px;
    color: #94a3b8;
    font-size: 0.875rem;
    text-align: center;
}
.wpgt-search-error {
    display: block;
    padding: 14px 16px;
    color: #ef4444;
    font-size: 0.875rem;
    text-align: center;
}

/* ── iOS Safari zoom prevention ─────────────────────────────────────
   Safari zooms in on any input with font-size < 16px. Force 16px on
   mobile, then reset to the designed size once the user starts typing
   (handled by setting font-size back via JS in public.js is complex,
   so simplest reliable fix: always use 16px on touch devices).
──────────────────────────────────────────────────────────────────── */
@media screen and (max-width: 768px) {
    .wpgt-search-input {
        font-size: 16px !important;  /* prevents iOS Safari auto-zoom */
    }
}
