/* Brain graph page. Colors, fonts and sizes for the graph itself live in the
   SETTINGS block at the top of brain.js; brain.js copies them into the
   --brain-* variables below, which are only fallbacks. */

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

:root {
  --gold: #c9a84c;
  --gold-light: #e8d5a3;
  --gold-dim: #7a6330;
  --dark: #0a0906;
  --text: #d4cfc4;
  --text-dim: #7a756a;
  --nav-text: var(--text);  /* header menu links: bright so they stand out */
  --text-muted: #4a4640;

  --brain-bg: var(--dark);
  --brain-label-font: 'Cormorant Garamond', 'Frank Ruhl Libre', serif;
  --brain-ui-font: 'Josefin Sans', sans-serif;
}

html, body { height: 100%; }

body.brain-page {
  background: var(--brain-bg);
  color: var(--text);
  font-family: 'Cormorant Garamond', serif;
  font-weight: 300;
  overflow: hidden;
}

/* ── GRAPH ── */
.brain-graph { position: fixed; inset: 0; }
.brain-graph svg { display: block; width: 100%; height: 100%; cursor: grab; }
.brain-graph svg:active { cursor: grabbing; }
.brain-graph .node { cursor: pointer; }
.brain-graph .label {
  font-family: var(--brain-label-font);
  pointer-events: none;
  paint-order: stroke;
  stroke: var(--brain-bg);
  stroke-linejoin: round;
}
.brain-graph .node, .brain-graph .link, .brain-graph .label {
  transition: opacity 0.25s;
}

/* ── NAV ── */
.brain-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  padding: 1.2rem 3rem;
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(to bottom, rgba(10,9,6,0.95), transparent);
  border-bottom: 1px solid rgba(201,168,76,0.08);
  pointer-events: none;
}
.brain-nav > * { pointer-events: auto; }
.brain-back {
  font-family: var(--brain-ui-font);
  font-weight: 200; font-size: 0.65rem;
  letter-spacing: 0.2em; color: var(--nav-text);
  text-decoration: none; text-transform: uppercase;
  transition: color 0.3s;
  min-width: 14rem;
}
.brain-back:hover { color: var(--gold); }

/* ── SEARCH ── */
.brain-search { position: relative; width: 14rem; }
.brain-search input {
  width: 100%;
  padding: 0.45rem 0.8rem;
  background: rgba(17,16,9,0.85);
  border: 1px solid rgba(201,168,76,0.2);
  color: var(--text);
  font-family: var(--brain-label-font);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.3s;
}
.brain-search input::placeholder {
  font-family: var(--brain-ui-font); font-weight: 200;
  font-size: 0.6rem; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--text-muted);
}
.brain-search input:focus { border-color: var(--gold-dim); }
.brain-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.brain-search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  list-style: none;
  background: rgba(17,16,9,0.96);
  border: 1px solid rgba(201,168,76,0.2);
}
.brain-search-results[hidden] { display: none; }
.brain-search-results li,
.brain-panel-link {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.4rem 0.8rem;
  font-size: 0.95rem; color: var(--text);
  cursor: pointer;
  unicode-bidi: plaintext;
}
.brain-search-results li::before,
.brain-panel-link::before {
  content: ''; flex: none;
  width: 0.45rem; height: 0.45rem; border-radius: 50%;
  background: var(--dot, var(--gold));
}
.brain-search-results li:hover,
.brain-search-results li.active { background: rgba(201,168,76,0.1); color: var(--gold-light); }

/* ── SIDE PANEL ── */
.brain-panel {
  position: fixed; z-index: 15;
  top: 5.5rem; right: 1.5rem; bottom: 5rem;
  width: 20rem;
  padding: 1.6rem 1.4rem;
  overflow-y: auto;
  background: rgba(17,16,9,0.92);
  border: 1px solid rgba(201,168,76,0.18);
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dim) transparent;
  animation: panelIn 0.4s ease;
}
.brain-panel[hidden] { display: none; }
.brain-panel-close {
  position: absolute; top: 0.6rem; right: 0.8rem;
  background: none; border: none; cursor: pointer;
  font-size: 1.4rem; line-height: 1; color: var(--text-dim);
  transition: color 0.3s;
}
.brain-panel-close:hover { color: var(--gold); }
.brain-panel-group,
.brain-panel-heading {
  font-family: var(--brain-ui-font);
  font-weight: 200; font-size: 0.55rem;
  letter-spacing: 0.25em; text-transform: uppercase;
  color: var(--text-dim);
}
.brain-panel-heading span { font-family: 'Frank Ruhl Libre', serif; letter-spacing: 0; }
.brain-panel-title {
  margin: 0.4rem 0 1.4rem;
  font-weight: 400; font-size: 1.5rem; line-height: 1.25;
  color: var(--gold-light);
  unicode-bidi: plaintext;
}
.brain-panel-source {
  display: flex; flex-direction: column; gap: 0.2rem;
  margin: -0.6rem 0 1.4rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid rgba(201,168,76,0.3);
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
}
.brain-panel-source[hidden] { display: none; }
.brain-panel-source:hover { background: rgba(201,168,76,0.08); border-color: var(--gold); }
.brain-panel-source-label {
  font-family: var(--brain-ui-font);
  font-weight: 300; font-size: 0.6rem;
  letter-spacing: 0.25em; text-transform: uppercase;
  color: var(--gold);
}
.brain-panel-source-label span { font-family: 'Frank Ruhl Libre', serif; letter-spacing: 0; }
.brain-panel-source-host { font-size: 0.95rem; color: var(--text-dim); }
.brain-panel-heading {
  padding-bottom: 0.5rem; margin-bottom: 0.4rem;
  border-bottom: 1px solid rgba(201,168,76,0.12);
}
.brain-panel-links { list-style: none; }
.brain-panel-link {
  width: 100%; text-align: start;
  background: none; border: none;
  font-family: var(--brain-label-font);
  transition: background 0.2s, color 0.2s;
}
.brain-panel-link:hover { background: rgba(201,168,76,0.08); color: var(--gold-light); }
.brain-panel-empty { font-style: italic; color: var(--text-muted); padding: 0.4rem 0; }

@keyframes panelIn {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}
.brain-heading { text-align: center; }
.brain-title {
  font-family: var(--brain-ui-font);
  font-weight: 200; font-size: 1rem;
  letter-spacing: 0.4em; text-transform: uppercase;
  color: var(--gold);
}
.brain-title-heb {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 0.85rem; color: var(--text-muted);
}

/* ── TOOLTIP ── */
.brain-tooltip {
  position: fixed; z-index: 20; pointer-events: none;
  padding: 0.6rem 0.9rem;
  background: rgba(17,16,9,0.92);
  border: 1px solid rgba(201,168,76,0.25);
  max-width: 22rem;
}
.brain-tooltip-title {
  font-size: 1.05rem; color: var(--gold-light);
  unicode-bidi: plaintext;
}
.brain-tooltip-meta {
  font-family: var(--brain-ui-font);
  font-size: 0.55rem; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--text-dim);
}

/* ── LEGEND ── */
.brain-legend {
  position: fixed; left: 3rem; bottom: 2rem; z-index: 10;
  list-style: none;
  display: flex; flex-direction: column; gap: 0.4rem;
}
.brain-legend li {
  display: flex; align-items: center; gap: 0.6rem;
  font-family: var(--brain-ui-font);
  font-weight: 200; font-size: 0.6rem;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--text-dim);
  cursor: pointer; transition: color 0.3s;
}
.brain-legend li:hover { color: var(--gold); }
.brain-legend-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; }

.brain-footer {
  position: fixed; right: 3rem; bottom: 2rem; z-index: 10;
  text-align: right; pointer-events: none;
}
.brain-count, .brain-hint {
  font-family: var(--brain-ui-font);
  font-weight: 200; font-size: 0.55rem;
  letter-spacing: 0.25em; text-transform: uppercase;
}
.brain-count { color: var(--text-dim); margin-bottom: 0.3rem; }
.brain-hint { color: var(--text-muted); }

.brain-message {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-style: italic; color: var(--text-dim);
  pointer-events: none;
}
.brain-message[hidden] { display: none; }

/* ── RESPONSIVE ── */
@media (prefers-reduced-motion: reduce) {
  .brain-panel { animation: none; }
}

@media (max-width: 768px) {
  .brain-nav { padding: 1rem 1.5rem; flex-wrap: wrap; gap: 0.6rem; }
  .brain-back { min-width: 0; font-size: 0.55rem; letter-spacing: 0.12em; }
  .brain-search { order: 3; width: 100%; }
  .brain-legend { left: 1.5rem; bottom: 1.2rem; }
  .brain-footer { display: none; }
  .brain-panel {
    top: auto; left: 0; right: 0; bottom: 0;
    width: auto; max-height: 45vh;
    animation-name: panelUp;
  }
  @keyframes panelUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
  }
}
