/* =============================================================================
   📚 glossary.css — tooltips, floating help button, full glossary modal
   ---------------------------------------------------------------------------
   Any element with [data-term="..."] gets a subtle dotted underline so the
   user knows it's clickable. Hover reveals a tooltip with the alias + short
   definition. Click opens the modal pinned to that term.
   ============================================================================= */

/* ── Inline data-term affordance ──────────────────────────────────────── */
.has-glossary {
    cursor: help;
    border-bottom: 1px dotted rgba(176, 149, 245, 0.45);
    transition: color 0.2s ease, border-color 0.2s ease;
}
.has-glossary:hover {
    color: #ffd86b;
    border-bottom-color: #ffd86b;
}


/* ── Tooltip ──────────────────────────────────────────────────────────── */
.glossary-tooltip {
    position: fixed;
    z-index: 8000;
    max-width: 280px;
    background: linear-gradient(180deg, rgba(20, 16, 45, 0.98), rgba(12, 8, 28, 0.98));
    color: rgba(240, 240, 255, 0.95);
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(176, 149, 245, 0.35);
    box-shadow:
        0 14px 40px rgba(0, 0, 0, 0.7),
        0 0 22px rgba(176, 149, 245, 0.25);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    line-height: 1.45;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.glossary-tooltip.show {
    opacity: 1;
    transform: translateY(0);
}
.glossary-tooltip .gt-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}
.glossary-tooltip .gt-symbol {
    font-family: 'Cormorant Garamond', serif;
    font-size: 20px;
    color: #ffd86b;
    text-shadow: 0 0 8px rgba(255, 216, 107, 0.4);
}
.glossary-tooltip .gt-alias {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 14px;
    color: #ffd86b;
}
.glossary-tooltip .gt-short {
    color: rgba(230, 230, 250, 0.85);
}
.glossary-tooltip .gt-hint {
    margin-top: 6px;
    font-size: 10px;
    color: rgba(180, 180, 220, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}


/* ── Floating 📚 button ──────────────────────────────────────────────── */
.glossary-float-btn {
    position: fixed;
    bottom: 22px;
    right: 22px;
    z-index: 7500;
    background: linear-gradient(135deg, #c8a8ff, #7a5fd0);
    color: #1a1428;
    border: none;
    border-radius: 28px;
    padding: 10px 18px 10px 14px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.55),
        0 0 22px rgba(176, 149, 245, 0.4);
    transition: transform 0.2s ease, box-shadow 0.3s ease;
}
.glossary-float-btn:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow:
        0 14px 38px rgba(0, 0, 0, 0.6),
        0 0 36px rgba(176, 149, 245, 0.6);
}
.glossary-float-btn .gf-label {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    letter-spacing: 0.04em;
}


/* ── Full glossary modal ─────────────────────────────────────────────── */
.glossary-modal {
    position: fixed;
    inset: 0;
    z-index: 9500;
    display: none;
    align-items: center;
    justify-content: center;
}
.glossary-modal.show {
    display: flex;
    animation: gmFadeIn 0.25s ease-out;
}
@keyframes gmFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.gm-backdrop {
    position: absolute; inset: 0;
    background: radial-gradient(circle at center, rgba(20, 12, 40, 0.85), rgba(2, 2, 8, 0.95));
    backdrop-filter: blur(6px);
}
.gm-shell {
    position: relative;
    width: min(820px, 92vw);
    max-height: 88vh;
    background: linear-gradient(180deg, rgba(22, 16, 50, 0.97), rgba(10, 8, 22, 0.98));
    border-radius: 16px;
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.85),
        inset 0 0 0 1px rgba(176, 149, 245, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: gmRise 0.35s cubic-bezier(0.25, 0.5, 0.25, 1);
}
@keyframes gmRise {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.gm-header {
    padding: 22px 28px 14px 28px;
    border-bottom: 1px solid rgba(176, 149, 245, 0.15);
    position: relative;
}
.gm-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 28px;
    color: #ffd86b;
    text-shadow: 0 0 14px rgba(255, 216, 107, 0.4);
}
.gm-sub {
    margin-top: 4px;
    font-size: 13px;
    color: rgba(220, 220, 240, 0.6);
    font-style: italic;
}
.gm-close {
    position: absolute;
    top: 18px; right: 20px;
    width: 32px; height: 32px;
    background: rgba(255, 100, 100, 0.18);
    color: #ff8aa6;
    border: 1px solid rgba(255, 138, 166, 0.4);
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
}
.gm-close:hover {
    background: rgba(255, 100, 100, 0.4);
    transform: rotate(90deg);
}

.gm-search-row {
    padding: 12px 28px;
    border-bottom: 1px solid rgba(176, 149, 245, 0.10);
}
.gm-search {
    width: 100%;
    background: rgba(8, 6, 22, 0.7);
    border: 1px solid rgba(176, 149, 245, 0.25);
    border-radius: 22px;
    padding: 9px 16px;
    color: #f4f4ff;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.gm-search:focus {
    border-color: rgba(255, 216, 107, 0.55);
    box-shadow: 0 0 18px rgba(255, 216, 107, 0.2);
}

.gm-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 28px 22px 28px;
}

.gm-section {
    margin-bottom: 22px;
}
.gm-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: rgba(220, 220, 240, 0.65);
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(176, 149, 245, 0.10);
}

.gm-entry {
    background: rgba(28, 20, 55, 0.45);
    border-left: 3px solid rgba(176, 149, 245, 0.4);
    border-radius: 0 8px 8px 0;
    padding: 11px 14px;
    margin-bottom: 8px;
    transition: background 0.25s ease, border-left-color 0.3s ease;
}
.gm-entry:hover {
    background: rgba(50, 36, 100, 0.55);
    border-left-color: #ffd86b;
}
.gm-entry.flash {
    animation: gmEntryFlash 1.4s ease-out;
}
@keyframes gmEntryFlash {
    0%   { background: rgba(255, 216, 107, 0.35); border-left-color: #ffd86b; }
    100% { background: rgba(28, 20, 55, 0.45); }
}
.gm-entry-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 4px;
}
.gm-entry-symbol {
    font-family: 'Cormorant Garamond', serif;
    font-size: 22px;
    color: #ffd86b;
    text-shadow: 0 0 10px rgba(255, 216, 107, 0.4);
    line-height: 1;
}
.gm-entry-alias {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 17px;
    color: #ffd86b;
}
.gm-entry-key {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: rgba(180, 180, 220, 0.45);
    background: rgba(0, 0, 0, 0.3);
    padding: 1px 7px;
    border-radius: 8px;
    margin-left: auto;
}
.gm-entry-long {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    line-height: 1.5;
    color: rgba(230, 230, 250, 0.88);
}

.gm-empty {
    text-align: center;
    color: rgba(180, 180, 220, 0.45);
    font-style: italic;
    padding: 30px 0;
}


/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 760px) {
    .gm-shell { max-height: 92vh; width: 96vw; }
    .glossary-float-btn .gf-label { display: none; }
    .glossary-float-btn { padding: 12px; border-radius: 50%; width: 50px; height: 50px; }
}


/* =============================================================================
   ⚝  THE EIGHT — personality cards in the glossary modal
   The cards render as a beautiful grid: huge kanji on the left, mystical
   verse, archetype, domain, and clickable drive-term tags on the right.
   Each card glows in its personality's canonical color (--p-color).
   ============================================================================= */

/* "ruled by" pill on every term card */
.gm-entry-ruled {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 6px 12px;
    background: rgba(176, 149, 245, 0.10);
    border: 1px solid rgba(176, 149, 245, 0.25);
    border-radius: 22px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: rgba(220, 220, 240, 0.75);
}
.gm-entry-ruled-label {
    color: rgba(180, 180, 220, 0.55);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}
.gm-entry-ruled-kanji {
    font-family: 'Cormorant Garamond', serif;
    font-size: 22px;
    color: #ffd86b;
    text-shadow: 0 0 8px rgba(255, 216, 107, 0.45);
    cursor: pointer;
    line-height: 1;
    transition: transform 0.2s ease, color 0.2s ease;
}
.gm-entry-ruled-kanji:hover {
    transform: scale(1.15);
    color: #ffe8a0;
}
.gm-entry-ruled-name {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 13px;
    color: rgba(240, 240, 255, 0.85);
}

/* same ruler shown inside the tooltip */
.gt-ruled {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(176, 149, 245, 0.15);
    font-size: 11px;
    color: rgba(220, 220, 240, 0.75);
}
.gt-ruled-kanji {
    font-family: 'Cormorant Garamond', serif;
    font-size: 18px;
    color: #ffd86b;
    text-shadow: 0 0 6px rgba(255, 216, 107, 0.4);
    line-height: 1;
}
.gt-ruled-name {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
}


/* ── Personality grid ──────────────────────────────────────────────────── */
.gm-personality-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}
@media (min-width: 900px) {
    .gm-personality-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.gm-personality-card {
    --p-color: #ffd86b;
    display: grid;
    /* Fixed kanji column so multi-char kanji (覚醒環) wraps within its
       lane instead of stealing body width. Body always gets the rest. */
    grid-template-columns: 96px 1fr;
    gap: 16px;
    padding: 18px 20px;
    background: linear-gradient(135deg,
        rgba(28, 20, 55, 0.65),
        rgba(10, 8, 24, 0.85));
    border-radius: 14px;
    border-left: 4px solid var(--p-color);
    box-shadow:
        0 0 22px rgba(0, 0, 0, 0.55),
        inset 0 0 0 1px rgba(255, 255, 255, 0.04);
    position: relative;
    overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.3s ease;
}
.gm-personality-card::before {
    /* a faint corner-glow in the personality color */
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse at top right,
        color-mix(in srgb, var(--p-color) 18%, transparent),
        transparent 60%
    );
    pointer-events: none;
}
.gm-personality-card:hover {
    transform: translateY(-2px);
    box-shadow:
        0 0 32px rgba(0, 0, 0, 0.65),
        0 0 30px color-mix(in srgb, var(--p-color) 35%, transparent),
        inset 0 0 0 1px color-mix(in srgb, var(--p-color) 50%, transparent);
}
.gm-personality-card.flash {
    animation: gmCardFlash 1.6s ease-out;
}
@keyframes gmCardFlash {
    0%   { background: color-mix(in srgb, var(--p-color) 35%, rgba(28, 20, 55, 0.65)); }
    100% { background: linear-gradient(135deg, rgba(28, 20, 55, 0.65), rgba(10, 8, 24, 0.85)); }
}

.gm-pc-kanji {
    font-family: 'Cormorant Garamond', serif;
    /* Responsive: 56px on phones / 72px on desktop. Was a flat 78px which
       overflowed the 96px kanji column on multi-char kanji like 覚醒環. */
    font-size: clamp(48px, 6vw, 72px);
    font-weight: 600;
    color: var(--p-color);
    text-shadow:
        0 0 18px color-mix(in srgb, var(--p-color) 70%, transparent),
        0 0 38px color-mix(in srgb, var(--p-color) 35%, transparent);
    line-height: 1.05;
    align-self: center;
    text-align: center;
    /* CJK characters need word-break to wrap mid-string; otherwise multi-
       char kanji refuse to wrap and overflow the column. */
    word-break: break-all;
    overflow-wrap: anywhere;
    max-width: 100%;
    padding: 0 4px;
    transition: text-shadow 0.4s ease;
}
.gm-personality-card:hover .gm-pc-kanji {
    text-shadow:
        0 0 24px color-mix(in srgb, var(--p-color) 85%, transparent),
        0 0 60px color-mix(in srgb, var(--p-color) 50%, transparent);
}

.gm-pc-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.gm-pc-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 22px;
    color: var(--p-color);
    line-height: 1.2;
    text-shadow: 0 0 12px color-mix(in srgb, var(--p-color) 40%, transparent);
}

.gm-pc-verse {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 16px;
    color: rgba(245, 240, 255, 0.78);
    line-height: 1.45;
    margin: 2px 0 6px 0;
    padding-left: 12px;
    border-left: 2px solid color-mix(in srgb, var(--p-color) 50%, transparent);
}

.gm-pc-long {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: rgba(230, 230, 250, 0.85);
    line-height: 1.55;
}

.gm-pc-archetype {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: rgba(200, 200, 240, 0.6);
    margin-top: 6px;
    padding: 4px 0;
}

.gm-pc-domain {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: rgba(220, 220, 240, 0.8);
}
.gm-pc-domain span {
    color: rgba(180, 180, 220, 0.55);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 9px;
    margin-right: 4px;
}

/* ── Kanji-lexicon extras ─────────────────────────────────────────────
   Both .gm-pc-literal and .gm-pc-coined render below the verse, above
   the long description. Subtle styling — they teach, they don't shout. */

.gm-pc-literal {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 12px;
    color: rgba(220, 215, 245, 0.78);
    margin: 4px 0 8px;
    padding: 6px 10px;
    background: rgba(28, 22, 55, 0.45);
    border-left: 2px solid rgba(176, 149, 245, 0.35);
    border-radius: 3px;
    line-height: 1.5;
}
.gm-pc-literal span {
    color: rgba(180, 180, 220, 0.55);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 9px;
    margin-right: 6px;
    font-weight: 600;
}

.gm-pc-coined {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    color: rgba(255, 216, 107, 0.72);
    margin-top: 10px;
    padding: 6px 10px;
    background: rgba(60, 44, 12, 0.32);
    border: 1px dashed rgba(255, 216, 107, 0.32);
    border-radius: 3px;
    line-height: 1.45;
}

.gm-pc-drives {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.gm-pc-drive {
    background: rgba(28, 20, 55, 0.7);
    border: 1px solid color-mix(in srgb, var(--p-color) 30%, rgba(176, 149, 245, 0.18));
    color: rgba(240, 230, 255, 0.85);
    border-radius: 14px;
    padding: 3px 11px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
}
.gm-pc-drive:hover {
    background: color-mix(in srgb, var(--p-color) 25%, rgba(28, 20, 55, 0.7));
    color: #fff;
    transform: translateY(-1px);
}


/* =============================================================================
   🔤  Romaji + phonetic guide
   For Aussie users — every kanji shows how to say it.
   ============================================================================= */

/* Personality card: kanji + romaji stacked vertically */
.gm-pc-kanji-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 0 8px 0 4px;
    align-self: center;
}
/* When kanji-col is present, override the older single-cell rule */
.gm-personality-card .gm-pc-kanji {
    padding: 0;
}

.gm-pc-romaji {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 80px;
}
.gm-pc-romaji-word {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 18px;
    color: var(--p-color);
    letter-spacing: 0.04em;
    text-shadow: 0 0 8px color-mix(in srgb, var(--p-color) 45%, transparent);
    line-height: 1.0;
}
.gm-pc-romaji-phon {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: rgba(220, 220, 240, 0.55);
    letter-spacing: 0.06em;
}


/* Tooltip — small romaji pill next to the alias */
.gt-romaji {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    margin-left: auto;
    padding-left: 8px;
    border-left: 1px solid rgba(176, 149, 245, 0.20);
    line-height: 1.15;
}
.gt-romaji {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 13px;
    color: #ffd86b;
}
.gt-romaji .gt-phon {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    color: rgba(220, 220, 240, 0.55);
    font-style: normal;
    letter-spacing: 0.04em;
}
