/* ────────────────────────────────────────────────────────────────────────────
   23F — Buscador Semántico · Enigmia Design System — Light Minimal
   Paleta: blanco #fff · azul Enigmia #3344ff · gris suave #f5f6fa
   ──────────────────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Fondos */
  --bg:       #f5f6fa;
  --surface:  #ffffff;
  --surface2: #eef0f7;
  --border:   #e2e5f0;
  --border2:  #d0d4e8;

  /* Brand Enigmia */
  --accent:       #3344ff;
  --accent-light: #5566ff;
  --accent-dim:   #1a2acc;
  --accent-glow:  rgba(51, 68, 255, 0.10);

  /* Texto */
  --text:   #111827;
  --muted:  #6b7280;
  --subtle: #9ca3af;

  /* Entidades — tono medio para fondo blanco */
  --per:     #c0392b;
  --per-bg:  #fdf0ee;
  --per-bdr: #f5c6c1;
  --org:     #0277bd;
  --org-bg:  #e8f4fd;
  --org-bdr: #b3d9f5;
  --loc:     #2e7d32;
  --loc-bg:  #edf7ee;
  --loc-bdr: #b5ddb7;

  --radius:    8px;
  --radius-sm: 5px;
  --font: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 12px rgba(0,0,0,.08);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

/* ── Scrollbar ── */
::-webkit-scrollbar              { width: 5px; height: 5px; }
::-webkit-scrollbar-track        { background: transparent; }
::-webkit-scrollbar-thumb        { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover  { background: var(--accent-dim); }

/* ── Header ── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .6rem 1.75rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 56px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.logo-wrap {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.logo-wrap img { height: 28px; width: auto; display: block; }

.header-title {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .09em;
  color: var(--subtle);
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ── Nav ── */
.nav-links { display: flex; gap: .25rem; }
.nav-links a {
  color: var(--muted); font-size: .82rem; font-weight: 500;
  text-decoration: none; padding: .3rem .8rem;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  transition: color .15s, border-color .15s, background .15s;
}
.nav-links a:hover  { color: var(--text); background: var(--surface2); }
.nav-links a.active { color: var(--accent); border-color: var(--accent-glow); background: var(--accent-glow); }

/* ── Stats bar ── */
.stats-bar {
  margin-left: auto; font-size: .73rem; color: var(--subtle);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 480px;
}

/* ── Buttons ── */
.btn-primary {
  background: var(--accent); color: #fff; border: none;
  padding: .65rem 1.4rem; border-radius: var(--radius);
  font-weight: 600; cursor: pointer; font-size: .92rem;
  transition: background .15s, box-shadow .15s; white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-light); box-shadow: 0 4px 14px var(--accent-glow); }

.btn-small {
  background: var(--accent); color: #fff; border: none;
  padding: .3rem .9rem; border-radius: var(--radius-sm);
  font-size: .8rem; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
.btn-small:hover { background: var(--accent-light); }

/* ── Inputs ── */
.input-text {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: .65rem 1rem; border-radius: var(--radius);
  font-size: .95rem; outline: none; width: 100%;
  transition: border .15s, box-shadow .15s;
  box-shadow: var(--shadow-sm);
}
.input-text:focus  { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.input-text::placeholder { color: var(--subtle); }

.input-small {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: .3rem .6rem; border-radius: var(--radius-sm);
  font-size: .82rem; outline: none; transition: border .15s;
}
.input-small:focus { border-color: var(--accent); }

select.input-small {
  cursor: pointer; appearance: none; padding-right: 1.8rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239ca3af' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .6rem center;
}

/* ── Filter row ── */
.filter-row {
  display: flex; gap: .5rem; align-items: center;
  flex-wrap: wrap; margin-top: .65rem;
}
.filter-row label { font-size: .78rem; color: var(--muted); white-space: nowrap; }

/* ── Search layout ── */
.search-wrap  { padding: 2rem 2rem 1rem; max-width: 860px; margin: 0 auto; }
.search-box   { display: flex; gap: .5rem; }
.results-wrap { max-width: 860px; margin: 0 auto; padding: 0 2rem 3rem; }
.result-count { font-size: .75rem; color: var(--subtle); margin-bottom: .85rem; }

/* ── Result card ── */
.result-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.25rem;
  margin-bottom: .5rem; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  box-shadow: var(--shadow-sm);
}
.result-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 18px var(--accent-glow);
}

.card-header { display: flex; align-items: flex-start; gap: .75rem; margin-bottom: .5rem; }
.score {
  background: var(--accent); color: #fff;
  font-size: .68rem; font-weight: 700; padding: .2rem .5rem;
  border-radius: var(--radius-sm); white-space: nowrap; flex-shrink: 0; margin-top: .15rem;
}
.card-title  { font-size: .9rem; font-weight: 600; color: var(--text); flex: 1; line-height: 1.35; }
.card-meta   { font-size: .73rem; color: var(--subtle); margin-bottom: .5rem; }
.excerpt     { font-size: .81rem; color: var(--muted); line-height: 1.65; margin-bottom: .6rem; }

/* ── Tags ── */
.tags { display: flex; flex-wrap: wrap; gap: .3rem; }
.tag  { font-size: .68rem; padding: .18rem .55rem; border-radius: 999px; font-weight: 500; border: 1px solid transparent; }
.tag-per   { background: var(--per-bg);  color: var(--per);  border-color: var(--per-bdr); }
.tag-org   { background: var(--org-bg);  color: var(--org);  border-color: var(--org-bdr); }
.tag-loc   { background: var(--loc-bg);  color: var(--loc);  border-color: var(--loc-bdr); }
.tag-other { background: var(--surface2); color: var(--muted); border-color: var(--border); }

/* ── Drawer ── */
.drawer {
  position: fixed; top: 0; right: -50vw; width: 46vw; height: 100vh;
  background: var(--surface); border-left: 1px solid var(--border);
  overflow-y: auto; padding: 1.5rem;
  transition: right .28s cubic-bezier(.4,0,.2,1);
  z-index: 100; display: flex; flex-direction: column; gap: .9rem;
  box-shadow: -6px 0 32px rgba(0,0,0,.08);
}
.drawer.open { right: 0; }

.drawer-close {
  position: absolute; top: 1rem; right: 1rem;
  background: none; border: none; color: var(--muted);
  font-size: 1.3rem; cursor: pointer; line-height: 1;
  padding: .25rem .4rem; border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
}
.drawer-close:hover { color: var(--text); background: var(--surface2); }

.drawer-title { font-size: .95rem; font-weight: 700; color: var(--text); padding-right: 2rem; line-height: 1.3; }
.drawer-meta  { font-size: .73rem; color: var(--subtle); }
.drawer-link  { font-size: .78rem; color: var(--accent); text-decoration: none; }
.drawer-link:hover { color: var(--accent-light); text-decoration: underline; }
.drawer-text  {
  font-size: .79rem; line-height: 1.75; color: var(--muted);
  white-space: pre-wrap; border-top: 1px solid var(--border); padding-top: .9rem;
}

.similar-section h3 {
  font-size: .72rem; color: var(--subtle); margin-bottom: .5rem;
  text-transform: uppercase; letter-spacing: .07em;
}
.similar-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .5rem .9rem; margin-bottom: .35rem;
  cursor: pointer; font-size: .8rem;
  display: flex; justify-content: space-between; align-items: center;
  transition: border-color .15s, background .15s;
  box-shadow: var(--shadow-sm);
}
.similar-item:hover    { border-color: var(--accent); background: var(--surface2); }
.similar-score         { font-size: .68rem; color: var(--accent); font-weight: 700; }

/* ── Overlay ── */
.overlay       { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 99; backdrop-filter: blur(2px); }
.overlay.show  { display: block; }

/* ── Spinner ── */
.spinner { display: inline-block; width: 17px; height: 17px; border: 2px solid var(--border2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-block         { text-align: center; padding: 2.5rem; color: var(--muted); font-size: .88rem; display: none; gap: .6rem; align-items: center; justify-content: center; }
.loading-block.visible { display: flex; }

/* ── Timeline layout ── */
.timeline-page     { height: 100vh; display: flex; flex-direction: column; }
.timeline-subheader {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: .5rem 1.75rem; display: flex; gap: .75rem;
  align-items: center; flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}
.timeline-wrap     { flex: 1; position: relative; overflow: hidden; }
#timeline-embed    { width: 100%; height: 100%; }
#tl-doc-count      { font-size: .75rem; color: var(--subtle); white-space: nowrap; }

/* TL overrides — adaptar TimelineJS3 a fondo claro */
.tl-timeline         { background: #f5f6fa !important; }
.tl-timemarker       { border-color: var(--accent) !important; }
.tl-timemarker-content-container { background: #fff !important; box-shadow: var(--shadow-sm) !important; }
.tl-headline         { color: var(--accent) !important; }
.tl-text             { color: var(--text) !important; }
.tl-slidenav-next,
.tl-slidenav-previous { color: var(--accent) !important; }
.tl-timegroup-message { color: var(--muted) !important; }
.tl-timenav          { background: #ffffff !important; border-top: 1px solid var(--border) !important; }
.tl-timeaxis         { background: var(--bg) !important; }
.tl-timeaxis-tick    { background: var(--border) !important; }
.tl-timeaxis-tick-text { color: var(--muted) !important; }

/* ── Utilities ── */
.msg-error { color: var(--per);   font-size: .88rem; }
.msg-muted { color: var(--muted); font-size: .88rem; }

/* ── Lectura Aumentada — entity inline marks ── */
.ent-mark {
  font-weight: 600; cursor: pointer; padding: 0 3px; border-radius: 3px;
  transition: filter .12s;
}
.ent-mark:hover      { filter: brightness(.84); }
.ent-mark.esp        { background: var(--per-bg);  color: var(--per);  border-bottom: 1px solid var(--per-bdr); }
.ent-mark.eso        { background: var(--org-bg);  color: var(--org);  border-bottom: 1px solid var(--org-bdr); }
.ent-mark.esl        { background: var(--loc-bg);  color: var(--loc);  border-bottom: 1px solid var(--loc-bdr); }
.ent-mark.esother    { background: var(--surface2); color: var(--muted); border-bottom: 1px solid var(--border); }
.ent-mark.highlighted { outline: 2px solid currentColor; outline-offset: 1px; }

/* ── Entity detail panel (inside drawer) ── */
.ent-detail {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .65rem .9rem;
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
}
.ent-detail-name { font-size: .85rem; font-weight: 700; color: var(--text); flex: 1; min-width: 0; }
.ent-detail-badge {
  font-size: .65rem; font-weight: 700; padding: .18rem .5rem;
  border-radius: 999px; color: #fff; flex-shrink: 0;
}
.ent-detail-badge.per { background: var(--per); }
.ent-detail-badge.org { background: var(--org); }
.ent-detail-badge.loc { background: var(--loc); }
.ent-detail-badge.other { background: var(--subtle); }
.ent-detail-wiki {
  font-size: .75rem; color: var(--accent); text-decoration: none;
  padding: .15rem .45rem; border-radius: var(--radius-sm);
  background: var(--accent-glow);
}
.ent-detail-wiki:hover { text-decoration: underline; }

.drawer-text.lectura {
  font-size: .82rem; line-height: 1.9; color: var(--text);
  white-space: pre-wrap; border-top: 1px solid var(--border); padding-top: .9rem;
}
