/**
 * TNT Keywords
 *
 * The highlight must not be mistaken for a card link. .tnt-card-link is gold,
 * weight 600, dotted gold underline — so a keyword is body-coloured, normal
 * weight, dashed underline, with a faint highlighter wash behind it.
 * Gold and bold = a card to look at. Highlighted = a term to learn.
 */

.tnt-kw {
    display: inline;
}

.tnt-kw-term {
    /* Full reset: the theme ships Tailwind preflight, which normalises buttons. */
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    border-bottom: 1px dashed rgba(197, 160, 89, 0.55);
    box-shadow: inset 0 -0.4em 0 rgba(197, 160, 89, 0.13);
    font: inherit;
    color: inherit;
    line-height: inherit;
    text-align: inherit;
    cursor: help;
    touch-action: manipulation;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.tnt-kw-term:hover,
.tnt-kw-term[aria-expanded="true"] {
    box-shadow: inset 0 -0.4em 0 rgba(197, 160, 89, 0.24);
    border-bottom-color: var(--tnt-gold, #c5a059);
}

.tnt-kw-term:focus-visible {
    outline: 2px solid var(--tnt-gold-light, #e6c885);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Description text for assistive tech. [hidden] does the work; this is a backstop
   for stylesheets that reset [hidden]. */
.tnt-kw-d {
    display: none;
}

/* ── Popover ───────────────────────────────────────────────────────────────
   Lives at document.body, not inside the article. single.php wraps
   .entry-content in a `relative overflow-hidden` card that also carries an
   entrance animation, so anything positioned inside it is either clipped or
   measured against a transformed ancestor. */
#tnt-kw-popover {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9998; /* below tnt-tooltip's card previews at 9999 */
    max-width: 320px;
    padding: 0.85rem 1rem;
    background: var(--tnt-black, #0a0a0a);
    border: 1px solid var(--tnt-gold-dim, rgba(197, 160, 89, 0.35));
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65);
    font-family: var(--tnt-font-body, 'Merriweather', Georgia, serif);
    font-size: 0.82rem;
    line-height: 1.55;
    color: #ddd;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s;
}

#tnt-kw-popover.is-open {
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto; /* the rule link has to be clickable */
}

.tnt-kw-pop-title {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--tnt-gold, #c5a059);
    font-family: var(--tnt-font-display, 'Beleren', 'Cinzel', serif);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tnt-kw-pop-text {
    display: block;
}

.tnt-kw-pop-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.7rem;
    padding-top: 0.55rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.tnt-kw-pop-foot a {
    color: var(--tnt-gold, #c5a059);
    font-size: 0.7rem;
    text-decoration: none;
    border-bottom: 1px solid var(--tnt-gold-dim, rgba(197, 160, 89, 0.35));
}

.tnt-kw-pop-foot a:hover {
    color: var(--tnt-gold-light, #e6c885);
}

.tnt-kw-pop-attr {
    color: rgba(226, 232, 240, 0.38);
    font-size: 0.62rem;
    letter-spacing: 0.02em;
}

/* Mana symbols inside reminder text, rendered as chips rather than pulling the
   mana font onto every article for a handful of glyphs. */
.tnt-kw-sym {
    padding: 0 0.2em;
    border-radius: 2px;
    background: rgba(197, 160, 89, 0.12);
    color: var(--tnt-gold, #c5a059);
    font-family: 'Courier New', monospace;
    font-size: 0.95em;
}

.tnt-kw-pop-arrow {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--tnt-black, #0a0a0a);
    border-left: 1px solid var(--tnt-gold-dim, rgba(197, 160, 89, 0.35));
    border-top: 1px solid var(--tnt-gold-dim, rgba(197, 160, 89, 0.35));
    transform: rotate(45deg);
}

/* Dismiss layer, touch only. */
#tnt-kw-scrim {
    position: fixed;
    inset: 0;
    z-index: 9997;
    display: none;
    background: transparent;
}

#tnt-kw-scrim.is-open {
    display: block;
}

@media (hover: none), (pointer: coarse) {
    #tnt-kw-popover {
        max-width: min(360px, calc(100vw - 32px));
        font-size: 0.88rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tnt-kw-term,
    #tnt-kw-popover {
        transition: none;
    }
}

@media print {
    .tnt-kw-term {
        border: 0;
        box-shadow: none;
        cursor: auto;
    }
    #tnt-kw-popover,
    #tnt-kw-scrim {
        display: none !important;
    }
}
