/* Glossary tooltip + bottom-sheet — uiux Phase 3 (2026-06-17)
 * mock from templates/_glossary_mock.html — 공통 추출.
 * Hybrid 패턴 A: hover tooltip (desktop) + tap-pin + bottom-sheet (mobile)
 */

/* ── TERM 마커 — 점선 밑줄 + ⓘ ──────────────────────────────── */
.term {
    position: relative;
    display: inline-flex; align-items: center; gap: 3px;
    color: var(--text-1);
    border-bottom: 1px dotted var(--text-3);
    cursor: help;
    padding: 0 1px;
}
.term:hover { border-bottom-color: var(--accent); }
.term .ti { color: var(--text-3); font-size: 11px; margin-left: 2px; }
.term:hover .ti, .term.pinned .ti { color: var(--accent); }
.term.pinned { background: var(--accent-bg); border-radius: 3px; border-bottom-color: var(--accent); }

/* ── TOOLTIP (데스크탑: hover, 모바일: tap pin) ──────────────── */
.term-tip {
    position: absolute;
    bottom: calc(100% + 8px); left: 50%;
    transform: translateX(-50%);
    background: #1a1a1a; color: #fff;
    padding: 10px 14px; border-radius: 8px;
    font-size: 12.5px; line-height: 1.55; font-weight: 400;
    width: 280px; max-width: 90vw;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    opacity: 0; visibility: hidden;
    pointer-events: none;
    transition: opacity 0.12s ease, visibility 0.12s ease;
    z-index: 50; text-align: left;
    white-space: normal;
}
.term-tip::after {
    content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    border: 6px solid transparent; border-top-color: #1a1a1a;
}
.term-tip .tt-head { font-weight: 700; font-size: 13px; margin-bottom: 4px;
                     display: flex; align-items: center; gap: 6px; }
.term-tip .tt-head .tt-sym { font-family: 'DM Mono', monospace; color: #ffb74d;
                              background: rgba(255,255,255,0.08); padding: 1px 6px;
                              border-radius: 4px; font-size: 11px; font-weight: 600; }
.term-tip .tt-body { color: #ddd; }
.term-tip .tt-more {
    display: inline-block; margin-top: 8px;
    background: rgba(255,255,255,0.12); color: #fff;
    padding: 4px 10px; border-radius: 4px;
    font-size: 11px; font-weight: 600; cursor: pointer;
    border: none; font-family: inherit;
}
.term-tip .tt-more:hover { background: rgba(255,255,255,0.22); }

/* 데스크탑: hover */
@media (hover: hover) {
    .term:hover .term-tip { opacity: 1; visibility: visible; pointer-events: auto; }
}
/* hover 가능하더라도 핀이면 표시 */
.term.pinned .term-tip { opacity: 1; visibility: visible; pointer-events: auto; }

/* 모바일 viewport 조정 — 화면 가장자리에서 잘림 방지 */
@media (max-width: 600px) {
    .term-tip { width: min(280px, calc(100vw - 32px)); font-size: 13px; }
    .term { padding: 2px 1px; } /* 터치 영역 확대 */
}

/* ── BOTTOM SHEET (모바일 + "더 보기") ──────────────────────── */
.term-sheet-bg {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45);
    opacity: 0; visibility: hidden; transition: opacity 0.18s ease, visibility 0.18s ease;
    z-index: 900;
}
.term-sheet-bg.open { opacity: 1; visibility: visible; }
.term-sheet {
    position: fixed; left: 0; right: 0; bottom: 0;
    background: var(--bg); border-radius: 16px 16px 0 0;
    padding: 18px 22px 32px;
    transform: translateY(100%);
    transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 901;
    max-height: 70vh; overflow-y: auto;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.16);
}
.term-sheet.open { transform: translateY(0); }
.term-sheet .ts-grab {
    width: 40px; height: 4px; border-radius: 2px;
    background: var(--border); margin: -6px auto 14px;
}
.term-sheet .ts-title {
    font-size: 17px; font-weight: 700; margin-bottom: 4px;
    display: flex; align-items: center; gap: 8px;
}
.term-sheet .ts-sym {
    font-family: 'DM Mono', monospace;
    background: var(--accent-bg); color: var(--accent);
    padding: 2px 8px; border-radius: 4px;
    font-size: 13px; font-weight: 600;
}
.term-sheet .ts-1line {
    font-size: 14px; color: var(--text-2); margin-bottom: 12px;
}
.term-sheet .ts-section {
    margin-top: 12px; padding: 12px 14px;
    background: var(--bg-2); border-radius: 8px;
    border: 1px solid var(--border);
}
.term-sheet .ts-section-label {
    font-size: 11px; font-weight: 700; color: var(--text-3);
    letter-spacing: 0.5px; text-transform: uppercase; margin-bottom: 5px;
}
.term-sheet .ts-section-body {
    font-size: 13.5px; color: var(--text-1); line-height: 1.7;
}
.term-sheet .ts-formula {
    font-family: 'DM Mono', monospace; font-size: 12.5px;
    color: var(--accent); background: var(--accent-bg);
    padding: 8px 12px; border-radius: 6px; margin-top: 4px;
    word-break: break-word;
}
.term-sheet .ts-close {
    position: absolute; top: 10px; right: 14px;
    background: none; border: none; font-size: 22px; line-height: 1;
    color: var(--text-3); cursor: pointer; padding: 6px;
}

/* 데모 viewport 토글 */
.viewport-toggle {
    position: fixed; bottom: 16px; right: 16px;
    background: var(--text-1); color: #fff; border: none;
    padding: 8px 14px; border-radius: 999px; cursor: pointer;
    font-size: 12px; font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18); z-index: 100;
}
body.mobile-sim .demo-wrap { max-width: 375px; }
body.mobile-sim { background: #ddd; }
body.mobile-sim .demo-wrap { background: var(--bg-2); padding: 16px 8px;
                              box-shadow: 0 0 24px rgba(0,0,0,0.15); }
