/* Grafo do conhecimento (partials/_knowledge_graph_modal.php + js/knowledge-graph.js).
   CSS próprio (não Tailwind): o canvas e os painéis sobre ele precisam de
   posicionamento/vidro que não dependem da ordem de injeção do Tailwind CDN. */

.kg-modal { position: fixed; inset: 0; z-index: 95; }
.kg-modal[hidden] { display: none; }
.kg-backdrop { position: absolute; inset: 0; background: rgba(4, 7, 14, .6); backdrop-filter: blur(4px); animation: kgFade .2s ease both; }
.kg-card {
    position: absolute; inset: .6rem; display: flex; flex-direction: column; overflow: hidden;
    border-radius: 1.5rem; background: #ffffff; color: #0f172a;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .45); animation: kgRise .28s cubic-bezier(.16, 1, .3, 1) both;
}
.dark .kg-card { background: #0c1220; color: #e2e8f0; }
@media (min-width: 768px) { .kg-card { inset: 1.25rem; } }

.kg-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .75rem 1rem; border-bottom: 1px solid rgba(15, 23, 42, .08); flex-shrink: 0; }
.dark .kg-head { border-bottom-color: rgba(255, 255, 255, .08); }
.kg-head-main { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.kg-badge {
    width: 2.6rem; height: 2.6rem; border-radius: .9rem; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    color: #0c1220; background: linear-gradient(135deg, #dfc08a, #b78a3a); box-shadow: 0 8px 22px rgba(195, 154, 78, .35);
}
.kg-badge svg { width: 1.35rem; height: 1.35rem; }
.kg-head-text { min-width: 0; }
.kg-head h2 { margin: 0; font: 700 1.05rem/1.2 Literata, Georgia, serif; }
.kg-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem; margin-top: .15rem; font: 500 .78rem/1.3 Inter, system-ui, sans-serif; color: #64748b; }
.dark .kg-crumbs { color: #94a3b8; }
.kg-crumbs button { border: 0; background: none; padding: .1rem .3rem; border-radius: .4rem; color: inherit; font: inherit; cursor: pointer; }
.kg-crumbs button:hover { color: #b78a3a; background: rgba(195, 154, 78, .12); }
.kg-crumbs .is-current { color: #0f172a; font-weight: 700; cursor: default; background: none; }
.dark .kg-crumbs .is-current { color: #f8fafc; }
.kg-crumbs .sep { opacity: .5; }

.kg-head-actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.kg-seg { display: flex; padding: 3px; border-radius: .8rem; background: rgba(15, 23, 42, .06); }
.dark .kg-seg { background: rgba(255, 255, 255, .07); }
.kg-seg button { border: 0; background: none; cursor: pointer; padding: .4rem .75rem; border-radius: .6rem; font: 600 .8rem Inter, system-ui, sans-serif; color: #64748b; }
.dark .kg-seg button { color: #94a3b8; }
.kg-seg button[aria-pressed="true"] { background: #ffffff; color: #96702c; box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
.dark .kg-seg button[aria-pressed="true"] { background: #1a2539; color: #d5b06a; }
.kg-icon-btn { width: 2.4rem; height: 2.4rem; border: 0; border-radius: .8rem; cursor: pointer; display: flex; align-items: center; justify-content: center; background: rgba(15, 23, 42, .06); color: #475569; }
.dark .kg-icon-btn { background: rgba(255, 255, 255, .07); color: #cbd5e1; }
.kg-icon-btn svg { width: 1.2rem; height: 1.2rem; }

/* Palco: no escuro, azul-noite profundo com halo dourado suave ao centro. */
.kg-stage { position: relative; flex: 1; min-height: 0; overflow: hidden;
    background: radial-gradient(90% 70% at 50% 45%, rgba(195, 154, 78, .08), transparent 70%), #f8fafc; }
.dark .kg-stage { background: radial-gradient(90% 70% at 50% 45%, rgba(195, 154, 78, .10), transparent 72%), #070b16; }
.kg-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.kg-stage canvas:active { cursor: grabbing; }

.kg-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8rem; font: .8rem Inter, system-ui, sans-serif; color: #94a3b8; pointer-events: none; }
.kg-loading[hidden] { display: none; }
.kg-pulse { width: 3.2rem; height: 3.2rem; border-radius: 50%; background: rgba(195, 154, 78, .15); animation: kgPulse 1.5s ease-in-out infinite; }

.kg-tooltip {
    position: absolute; z-index: 20; pointer-events: none; max-width: 280px; padding: .45rem .7rem; border-radius: .7rem;
    background: rgba(12, 18, 32, .94); color: #f1f5f9; font: 600 .75rem/1.35 Inter, system-ui, sans-serif; box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
.kg-tooltip[hidden] { display: none; }
.kg-tooltip small { display: block; font-weight: 400; opacity: .7; margin-top: .1rem; }

/* Painéis de vidro fosco sobre o canvas */
.kg-panel {
    position: absolute; z-index: 15; padding: .8rem .95rem; border-radius: 1rem; max-width: min(19rem, 70vw);
    background: rgba(255, 255, 255, .84); border: 1px solid rgba(0, 0, 0, .06); backdrop-filter: blur(10px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .10); font: .75rem/1.45 Inter, system-ui, sans-serif; color: #475569;
}
.dark .kg-panel { background: rgba(12, 18, 32, .76); border-color: rgba(255, 255, 255, .10); box-shadow: 0 8px 28px rgba(0, 0, 0, .45); color: #cbd5e1; }
.kg-panel-tl { top: .8rem; left: .8rem; }
.kg-panel-br { bottom: .8rem; right: 4.2rem; }
.kg-panel-title { margin: 0 0 .45rem; font-weight: 700; font-size: .8rem; color: #0f172a; }
.dark .kg-panel-title { color: #f8fafc; }
.kg-legend-items { display: flex; flex-direction: column; gap: .15rem; max-height: 38vh; overflow-y: auto; }
.kg-legend-row { display: flex; align-items: center; gap: .5rem; white-space: nowrap; }
.kg-legend-row[hidden] { display: none; }
.kg-legend-sep { margin-top: .5rem; padding-top: .5rem; border-top: 1px solid rgba(0, 0, 0, .08); }
.dark .kg-legend-sep { border-top-color: rgba(255, 255, 255, .10); }
.kg-dot { width: .65rem; height: .65rem; border-radius: 50%; flex-shrink: 0; }
.kg-dot.diamond { border-radius: 2px; transform: rotate(45deg) scale(.85); }
.kg-dot.square { border-radius: 2px; }
.kg-legend-count { margin-left: auto; font-size: .68rem; font-weight: 700; padding: 0 .35rem; border-radius: .4rem; background: rgba(0, 0, 0, .05); }
.dark .kg-legend-count { background: rgba(255, 255, 255, .10); }
.kg-line, .kg-dash { width: 1.3rem; flex-shrink: 0; border-top: 2px solid #94a3b8; }
.kg-line-gold { border-top-color: #d5b06a; }
.kg-line-word { border-top-color: #c084fc; }
.kg-dash { border-top-style: dashed; border-top-color: #d5b06a; }
.kg-stats { margin: .55rem 0 0; font-size: .7rem; opacity: .75; }

.kg-legend-toggle { display: none; }
@media (max-width: 1024px) {
    .kg-legend-toggle { display: flex; position: absolute; z-index: 16; top: .8rem; left: .8rem;
        background: rgba(255, 255, 255, .84); border: 1px solid rgba(0, 0, 0, .06); backdrop-filter: blur(10px); box-shadow: 0 8px 28px rgba(0, 0, 0, .10); }
    .dark .kg-legend-toggle { background: rgba(12, 18, 32, .76); border-color: rgba(255, 255, 255, .10); }
    .kg-legend-toggle[aria-expanded="true"] { color: #b78a3a; }
    [data-kg-legend] { display: none; top: 3.6rem; }
    [data-kg-legend].is-open { display: block; }
}

.kg-toolbar {
    position: absolute; z-index: 15; right: .8rem; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: .15rem; padding: .3rem;
    border-radius: .9rem; background: rgba(255, 255, 255, .84); border: 1px solid rgba(0, 0, 0, .06); backdrop-filter: blur(10px); box-shadow: 0 8px 28px rgba(0, 0, 0, .10);
}
.dark .kg-toolbar { background: rgba(12, 18, 32, .76); border-color: rgba(255, 255, 255, .10); box-shadow: 0 8px 28px rgba(0, 0, 0, .45); }
.kg-tool { width: 2.2rem; height: 2.2rem; border: 0; border-radius: .65rem; cursor: pointer; display: flex; align-items: center; justify-content: center; background: transparent; color: #64748b; transition: color .15s, background-color .15s; }
.dark .kg-tool { color: #94a3b8; }
.kg-tool:hover { color: #b78a3a; background: rgba(195, 154, 78, .12); }
.kg-tool svg { width: 1.1rem; height: 1.1rem; }

.kg-search { display: flex; align-items: center; gap: .45rem; padding: .45rem .8rem; }
.kg-search svg { width: 1rem; height: 1rem; color: #94a3b8; flex-shrink: 0; }
.kg-search input { border: 0; outline: none; background: transparent; width: 11rem; max-width: 40vw; font: .8rem Inter, system-ui, sans-serif; color: inherit; }

.kg-details { top: .8rem; right: 4.2rem; width: 20rem; max-width: calc(100% - 6rem); max-height: calc(100% - 5.5rem); overflow-y: auto; }
.kg-details[hidden] { display: none; }
.kg-details-close { position: absolute; top: .45rem; right: .55rem; width: 1.8rem; height: 1.8rem; border: 0; border-radius: .5rem; background: rgba(0, 0, 0, .05); color: inherit; font-size: 1.15rem; line-height: 1; cursor: pointer; }
.dark .kg-details-close { background: rgba(255, 255, 255, .08); }
.kg-details-kind { margin: 0; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #b78a3a; }
.kg-details h3 { margin: .15rem 1.8rem .2rem 0; font: 700 1.05rem/1.3 Literata, Georgia, serif; color: #0f172a; }
.dark .kg-details h3 { color: #f8fafc; }
.kg-details-meta { margin: 0; font-size: .72rem; opacity: .75; }
.kg-details-text { margin: .55rem 0 0; font: .9rem/1.55 Literata, Georgia, serif; color: #1e293b; }
.dark .kg-details-text { color: #e2e8f0; }
.kg-details-text:empty, .kg-details-links:empty { display: none; }
.kg-details-links { margin: .55rem 0 0; font-size: .72rem; }
.kg-details-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .75rem; }
.kg-btn { display: inline-flex; align-items: center; height: 2.1rem; padding: 0 .8rem; border-radius: .65rem; border: 1px solid rgba(195, 154, 78, .5); background: transparent; color: #96702c; font: 600 .78rem Inter, system-ui, sans-serif; text-decoration: none; cursor: pointer; }
.dark .kg-btn { color: #d5b06a; }
.kg-btn[hidden] { display: none; }
.kg-btn-primary { background: #c39a4e; border-color: #c39a4e; color: #0c1220 !important; }

.kg-filters { top: 50%; right: 4.2rem; transform: translateY(-50%); width: 17rem; }
.kg-filters[hidden] { display: none; }
.kg-filters-head { display: flex; align-items: center; justify-content: space-between; }
.kg-filters-head .kg-details-close { position: static; }
.kg-filter { display: flex; align-items: center; gap: .55rem; padding: .45rem .3rem; border-radius: .55rem; cursor: pointer; font-size: .8rem; }
.kg-filter:hover { background: rgba(195, 154, 78, .10); }
.kg-filter input { width: 1.05rem; height: 1.05rem; accent-color: #c39a4e; flex-shrink: 0; margin: 0; }
.kg-filter-name { flex: 1; color: #0f172a; font-weight: 600; }
.dark .kg-filter-name { color: #f1f5f9; }
.kg-filters-note { margin: .4rem 0 0; font-size: .68rem; opacity: .65; }
.kg-tool[aria-expanded="true"] { color: #b78a3a; background: rgba(195, 154, 78, .16); }
@media (max-width: 900px) { .kg-filters { top: auto; bottom: .8rem; left: .8rem; right: .8rem; width: auto; transform: none; } }

.kg-hint { position: absolute; left: 50%; bottom: .9rem; transform: translateX(-50%); margin: 0; z-index: 10; font: .72rem Inter, system-ui, sans-serif; color: #94a3b8; white-space: nowrap; pointer-events: none; }

@media (max-width: 900px) {
    .kg-panel-br.kg-search { display: none; }
    .kg-hint { display: none; }
    .kg-details { left: .8rem; right: .8rem; top: auto; bottom: .8rem; width: auto; max-width: none; max-height: 55%; }
    .kg-seg button { padding: .4rem .55rem; }
    .kg-head { padding: .6rem .7rem; }
    .kg-badge { display: none; }
}

@keyframes kgFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes kgRise { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes kgPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(195, 154, 78, .35); } 50% { box-shadow: 0 0 0 18px rgba(195, 154, 78, 0); } }
@media (prefers-reduced-motion: reduce) { .kg-backdrop, .kg-card, .kg-pulse { animation: none !important; } }
