/* Entity Drawer - reusable contextual info panel (desktop right drawer / mobile bottom sheet).
   Relies on the color variables style.css already defines on :root (--bg, --panel, --border,
   --text, --muted, --accent, --accent-soft); load this alongside style.css, after it.
   All rules are scoped to .entity-* classes so nothing here touches any existing page styling. */

.entity-drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 200;
}
.entity-drawer-overlay.open { opacity: 1; pointer-events: auto; }

.entity-drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(420px, 92vw);
  background: var(--bg); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform .22s ease;
  z-index: 201; overflow-y: auto; box-shadow: -12px 0 30px rgba(0,0,0,.35);
  font-family: system-ui, sans-serif;
}
.entity-drawer.open { transform: translateX(0); }

.entity-drawer-close {
  position: sticky; top: 0; float: right; margin: 10px 14px 0 0;
  background: none; border: none; color: var(--muted); font-size: 1.5rem; line-height: 1;
  cursor: pointer; z-index: 1;
}
.entity-drawer-close:hover { color: var(--text); }

.entity-drawer-body { padding: 20px 24px 32px; clear: both; }

.entity-name { margin: 0 0 8px; font-size: 1.3rem; color: var(--text); font-family: Arial, Helvetica, sans-serif; }

.entity-type-badge {
  display: inline-block; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--accent); border: 1px solid var(--accent-soft); background: var(--accent-soft);
  border-radius: 20px; padding: 3px 10px; margin-bottom: 18px;
}

/* Each drawer section heading is a real <button> (click-to-expand/collapse), not a static h3 -
   Tab/Enter/Space all work for free since it's a native button, no custom key handling needed. */
.entity-section-toggle {
  display: flex; align-items: center; gap: 6px; width: 100%; background: none; border: none;
  font-family: system-ui, sans-serif; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin: 20px 0 8px; padding: 0 0 6px; border-bottom: 1px solid var(--border);
  cursor: pointer; text-align: left;
}
.entity-section-toggle:first-of-type { margin-top: 0; }
.entity-section-toggle:hover, .entity-section-toggle.open { color: var(--text); }
.entity-section-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.entity-section-caret { display: inline-block; flex-shrink: 0; font-size: .7rem; color: var(--accent); transition: transform .15s ease; }
.entity-section-toggle.open .entity-section-caret { transform: rotate(90deg); }
.entity-section-content { margin-bottom: 4px; }

.entity-block p { margin: 0; font-size: .92rem; line-height: 1.6; color: var(--text); }
.entity-block p + p { margin-top: 10px; }

/* Study-specific role/confidence line shown above the "why this matters" note for people_groups */
.entity-study-meta { font-size: .78rem; color: var(--muted); margin-top: -8px; margin-bottom: 4px; }

/* People Today / Religion Today rows */
.entity-demo-row { margin: 8px 0; font-size: .9rem; }
.entity-demo-headline { color: var(--text); }
.entity-demo-meta { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.entity-demo-unresearched { color: var(--muted); font-style: italic; font-size: .85rem; }

/* Prophecy Interpretation views - each attributed to a named teacher, never presented as settled */
.entity-view { margin: 10px 0; padding-left: 10px; border-left: 2px solid #4a3320; }
.entity-view-id { color: var(--text); font-size: .92rem; margin-bottom: 2px; }
.entity-view-meta { color: #c98d4b; font-size: .78rem; }
.entity-view-note { color: var(--muted); font-size: .78rem; font-style: italic; margin-top: 4px; }

.entity-sources { display: flex; flex-direction: column; gap: 10px; }

/* One citation line, used both inline under a specific claim and in the consolidated Sources list */
.entity-field-source { font-size: .78rem; color: var(--muted); margin-top: 6px; }
.entity-field-source a { color: var(--muted); text-decoration: underline; }
.entity-field-source a:hover { color: var(--accent); }
.entity-field-source-accessed { color: var(--muted); }
.entity-field-source-note { color: var(--muted); font-style: italic; margin-top: 2px; }

.entity-demo-note { color: var(--muted); font-size: .78rem; font-style: italic; margin-top: 2px; }

.entity-refs { display: flex; gap: 8px; flex-wrap: wrap; }

.entity-related { display: flex; flex-direction: column; gap: 6px; }
.entity-related-link { color: var(--accent); text-decoration: none; font-size: .88rem; }
.entity-related-link:hover { text-decoration: underline; }

.entity-full-article {
  display: inline-block; margin-top: 20px; color: var(--accent); text-decoration: none;
  border: 1px solid var(--border); border-radius: 20px; padding: 8px 16px; font-size: .85rem;
}
.entity-full-article:hover { border-color: var(--accent); }

.entity-loading, .entity-missing { color: var(--muted); font-size: .88rem; }

/* isolation:isolate contains Leaflet's own internal z-index values (its panes/controls use
   400-1000+) to this box, so they can't escape and cover the drawer's close button or overlay -
   same fix as the study page's main map. */
.entity-map { height: 220px; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 4px; isolation: isolate; }
.entity-map-note { color: var(--muted); font-size: .78rem; font-style: italic; margin: 0; }

/* Inline entity mention chip - click opens the drawer. Uses a solid blue underline (vs. the
   scripture chips' dotted gold underline) so the two click targets read as different things. */
.entity-chip { color: var(--text); border-bottom: 1px solid #7fb8d6; cursor: pointer; }
.entity-chip:hover { color: #7fb8d6; }

@media (max-width: 720px) {
  .entity-drawer {
    top: auto; bottom: 0; left: 0; right: 0; width: auto; height: auto; max-height: 82vh;
    border-left: none; border-top: 1px solid var(--border); border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }
  .entity-drawer.open { transform: translateY(0); }
}
