/* ═══════════════════════════════════════════════════════════
   HISTORY VISUALIZER — Components
   ═══════════════════════════════════════════════════════════ */

/* ════════════════════════════════
   TOP BAR
   ════════════════════════════════ */
.topbar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.topbar-logo svg { color: var(--amber-mid); }

.topbar-logo h1 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--amber-bright);
  animation: glow-pulse 4s ease-in-out infinite;
  white-space: nowrap;
}

.topbar-search {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 6px var(--space-sm);
  flex: 1;
  max-width: 340px;
  transition: border-color var(--dur-fast);
}

.topbar-search:focus-within {
  border-color: var(--amber-mid);
  box-shadow: var(--glow-amber-sm);
}

.topbar-search svg { color: var(--sepia-mid); flex-shrink: 0; }

.topbar-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 0.9rem;
  width: 100%;
}

.topbar-search input::placeholder { color: var(--sepia-muted); }

.topbar-stats {
  display: flex;
  gap: var(--space-lg);
  margin-left: auto;
}

.stat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.stat-chip .stat-value {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--amber-bright);
  line-height: 1;
}

.stat-chip .stat-label {
  font-size: 0.65rem;
  letter-spacing: 0.10em;
  color: var(--sepia-muted);
  text-transform: uppercase;
}

.topbar-divider {
  width: 1px;
  height: 32px;
  background: var(--divider);
}

/* ── View toggle buttons ─────────────────────────────────── */
.view-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--sepia-mid);
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.10em;
  cursor: pointer;
  transition: all var(--dur-fast);
}

.view-tab:hover {
  background: var(--bg-hover);
  color: var(--amber-mid);
  border-color: var(--glass-border);
}

.view-tab.active {
  background: var(--bg-selected);
  color: var(--amber-bright);
  border-color: var(--amber-mid);
  box-shadow: var(--glow-amber-sm);
}

/* ════════════════════════════════
   SIDEBAR
   ════════════════════════════════ */
.sidebar-header {
  padding: var(--space-md);
  border-bottom: 1px solid var(--divider);
  flex-shrink: 0;
}

.sidebar-header h2 {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  color: var(--amber-mid);
  text-transform: uppercase;
}

.sidebar-section {
  border-bottom: 1px solid var(--divider);
  flex-shrink: 0;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  transition: background var(--dur-fast);
}

.sidebar-section-header:hover { background: var(--bg-hover); }

.sidebar-section-header h3 {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--sepia-light);
  text-transform: uppercase;
}

.sidebar-section-body {
  overflow: hidden;
  transition: max-height var(--dur-normal) var(--ease-out-expo);
}

.sidebar-body { flex: 1; overflow-y: auto; }

/* Era list */
.era-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 7px var(--space-md);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all var(--dur-fast);
}

.era-item:hover   { background: var(--bg-hover); }
.era-item.active  { background: var(--bg-selected); border-left-color: var(--amber-mid); }

.era-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.era-name {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  color: var(--sepia-light);
}

.era-years {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--sepia-muted);
}

/* Actor list */
.actor-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 6px var(--space-md);
  cursor: pointer;
  transition: background var(--dur-fast);
  border-radius: 0;
}

.actor-item:hover  { background: var(--bg-hover); }
.actor-item.active { background: var(--bg-selected); }

.actor-icon-wrap {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.actor-info { flex: 1; min-width: 0; }

.actor-name {
  font-size: 0.82rem;
  color: var(--parchment);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.actor-type {
  font-size: 0.68rem;
  color: var(--sepia-muted);
  font-family: var(--font-mono);
}

.actor-count {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  background: rgba(217,119,6,0.15);
  color: var(--amber-mid);
  border-radius: 10px;
  padding: 1px 7px;
}

/* Sidebar filters */
.filter-group { padding: var(--space-sm) var(--space-md); }

.filter-label {
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  color: var(--sepia-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
  display: block;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.filter-chip {
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--sepia-mid);
  font-size: 0.72rem;
  cursor: pointer;
  transition: all var(--dur-fast);
  font-family: var(--font-body);
}

.filter-chip:hover { border-color: var(--amber-mid); color: var(--amber-mid); }
.filter-chip.active { background: var(--amber-deep); border-color: var(--amber-mid); color: var(--amber-bright); }

/* Sidebar footer stats */
.sidebar-footer {
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid var(--divider);
  display: flex;
  gap: var(--space-md);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.sidebar-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-stat .s-num {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--amber-mid);
  font-weight: 700;
  line-height: 1;
}

.sidebar-stat .s-lbl {
  font-size: 0.62rem;
  color: var(--sepia-muted);
  text-transform: uppercase;
  letter-spacing: 0.10em;
}

/* ════════════════════════════════
   PANORAMA CONTROLS
   ════════════════════════════════ */
.panorama-controls {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}

/* ════════════════════════════════
   BUTTONS
   ════════════════════════════════ */
.btn-icon {
  width: 34px; height: 34px;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  background: var(--bg-panel);
  color: var(--sepia-light);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--dur-fast);
}

.btn-icon:hover {
  border-color: var(--amber-mid);
  color: var(--amber-bright);
  box-shadow: var(--glow-amber-sm);
}

.btn-icon svg { width: 16px; height: 16px; pointer-events: none; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--amber-mid);
  background: rgba(180, 83, 9, 0.25);
  color: var(--amber-bright);
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.10em;
  cursor: pointer;
  transition: all var(--dur-fast);
}

.btn-primary:hover {
  background: rgba(180, 83, 9, 0.50);
  box-shadow: var(--glow-amber-sm);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--sepia-mid);
  padding: 4px 10px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--dur-fast);
  font-family: var(--font-body);
}

.btn-ghost:hover { border-color: var(--amber-mid); color: var(--amber-mid); }

/* ════════════════════════════════
   DETAIL DRAWER
   ════════════════════════════════ */
.drawer-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  color: var(--sepia-muted);
  padding: var(--space-xl);
  text-align: center;
}

.drawer-empty-icon {
  width: 56px; height: 56px;
  opacity: 0.25;
  color: var(--amber-mid);
}

.drawer-empty p {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--sepia-muted);
}

/* Drawer header */
.drawer-header {
  padding: var(--space-md);
  border-bottom: 1px solid var(--divider);
  flex-shrink: 0;
}

.drawer-entity-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.drawer-entity-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
  border: 1px solid var(--glass-border);
}

.drawer-entity-name {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--parchment);
  line-height: 1.2;
}

.drawer-entity-type {
  font-size: 0.72rem;
  color: var(--sepia-mid);
  margin-top: 2px;
}

.drawer-era-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  background: rgba(217, 119, 6, 0.15);
  color: var(--amber-mid);
  border: 1px solid rgba(217, 119, 6, 0.30);
}

/* Drawer tabs */
.drawer-tabs {
  display: flex;
  border-bottom: 1px solid var(--divider);
  flex-shrink: 0;
}

.drawer-tab {
  flex: 1;
  padding: 9px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  color: var(--sepia-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--dur-fast);
  background: transparent;
  border-top: none;
  border-left: none;
  border-right: none;
}

.drawer-tab:hover { color: var(--amber-mid); }

.drawer-tab.active {
  color: var(--amber-bright);
  border-bottom-color: var(--amber-mid);
  background: rgba(217,119,6,0.06);
}

/* Drawer panes */
.drawer-pane {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
}

/* ── Narrative tab ────────────────────────────────────── */
.narrative-text {
  font-family: var(--font-body);
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--sepia-light);
  font-style: italic;
  margin-bottom: var(--space-md);
}

.info-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 4px var(--space-sm);
  margin-bottom: var(--space-md);
}

.info-key {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--sepia-muted);
  padding-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.info-val {
  font-size: 0.85rem;
  color: var(--parchment);
  word-break: break-word;
}

.info-val.amber { color: var(--amber-mid); }

/* ── Events tab ──────────────────────────────────────── */
.event-entry {
  display: flex;
  gap: var(--space-sm);
  padding: 8px 0;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: background var(--dur-fast);
  border-radius: var(--radius-sm);
  padding-left: 6px;
}

.event-entry:hover { background: var(--bg-hover); }

.event-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.event-entry-kind {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.event-entry-date {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--sepia-muted);
  margin-top: 2px;
}

.event-entry-desc {
  font-size: 0.78rem;
  color: var(--sepia-light);
  margin-top: 2px;
  line-height: 1.4;
}

/* ── Media tab ───────────────────────────────────────── */
.media-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
}

.media-thumb {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: all var(--dur-fast);
  aspect-ratio: 4/3;
  position: relative;
  background: var(--bg-card);
}

.media-thumb:hover {
  border-color: var(--amber-mid);
  box-shadow: var(--glow-amber-sm);
  transform: scale(1.02);
}

.media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-thumb .media-type-badge {
  position: absolute;
  top: 5px; right: 5px;
  background: rgba(0,0,0,0.70);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.6rem;
  font-family: var(--font-mono);
  color: var(--amber-mid);
}

.media-thumb .media-caption {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  padding: 20px 8px 6px;
  font-size: 0.68rem;
  color: var(--sepia-light);
  line-height: 1.3;
}

.external-link-card {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--dur-fast);
  margin-bottom: 6px;
}

.external-link-card:hover {
  border-color: var(--amber-mid);
  background: var(--bg-hover);
}

.external-link-icon {
  width: 32px; height: 32px;
  border-radius: 6px;
  background: rgba(217,119,6,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--amber-mid);
}

.external-link-info .link-title {
  font-size: 0.80rem;
  color: var(--parchment);
  line-height: 1.2;
}

.external-link-info .link-source {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--sepia-muted);
  margin-top: 2px;
}

/* ════════════════════════════════
   TIMELINE BAR
   ════════════════════════════════ */
.timeline-bar-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 4px var(--space-md);
  border-bottom: 1px solid var(--divider);
  flex-shrink: 0;
}

.timeline-bar-header h3 {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--amber-mid);
  text-transform: uppercase;
}

.timeline-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

/* ════════════════════════════════
   CORRELATION PANEL
   ════════════════════════════════ */
.correlation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--divider);
}

.correlation-header h3 {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--amber-mid);
}

/* ════════════════════════════════
   MEDIA MODAL
   ════════════════════════════════ */
.modal-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--divider);
  flex-shrink: 0;
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--amber-bright);
  flex: 1;
}

.modal-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

.modal-body img {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.modal-body iframe {
  width: 100%;
  height: 55vh;
  border: none;
  border-radius: var(--radius-md);
  background: #fff;
}

.modal-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--divider);
  flex-shrink: 0;
}

.modal-footer p {
  font-size: 0.82rem;
  color: var(--sepia-light);
  font-style: italic;
}

.modal-footer .source {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--sepia-muted);
  margin-top: 4px;
}

/* ════════════════════════════════
   PANORAMA — Legend overlay
   ════════════════════════════════ */
.panorama-legend {
  position: absolute;
  bottom: var(--space-md);
  left: var(--space-md);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  z-index: 10;
  max-width: 300px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: rgba(0,0,0,0.55);
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  font-size: 0.65rem;
  color: var(--sepia-mid);
}

.legend-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ════════════════════════════════
   RELATIONS mini-graph in drawer
   ════════════════════════════════ */
#relations-canvas-wrapper {
  width: 100%;
  aspect-ratio: 1;
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--glass-border);
  margin-bottom: var(--space-md);
}

#relations-mini-canvas {
  width: 100%;
  height: 100%;
}

/* ════════════════════════════════
   LOADING SPINNER
   ════════════════════════════════ */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: var(--bg-void);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
}

.spinner {
  width: 48px; height: 48px;
  border: 3px solid var(--sepia-deep);
  border-top-color: var(--amber-mid);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: 0.20em;
  color: var(--amber-mid);
  animation: glow-pulse 2s ease-in-out infinite;
}

.loading-sub {
  font-size: 0.82rem;
  color: var(--sepia-muted);
  font-style: italic;
}

/* ── Narrative tab url link color ────────────────────────── */
#pane-narrativa a,
.drawer-pane a,
.drawer-pane .amber {
  color: var(--amber-bright) !important;
  text-decoration: underline;
  transition: color var(--dur-fast), opacity var(--dur-fast);
}

#pane-narrativa a:hover,
.drawer-pane a:hover,
.drawer-pane .amber:hover {
  color: #ffffff !important;
  opacity: 0.9;
}
