:root {
  --bg: #0f1216;
  --bg-alt: #161a20;
  --panel: #1b2027;
  --ink: #e9e4d8;
  --ink-dim: #a7a299;
  --gold: #d9b34d;
  --line: #2a313b;
  --greek: #5dd6c0;
  --trojan: #e3795b;
  --god: #d9b34d;
  --ithaca: #8d8bdb;
  --radius: 10px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: radial-gradient(circle at 20% 0%, #1a1f27, var(--bg) 60%);
  color: var(--ink);
  font-family: "Source Serif 4", Georgia, serif;
  scrollbar-color: var(--gold) var(--bg-alt);
}

h1, h2, h3, .brand-mark { font-family: "Cinzel", serif; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(15, 18, 22, 0.92);
  backdrop-filter: blur(6px);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  font-size: 28px;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(217,179,77,0.6);
}
.brand h1 { margin: 0; font-size: 22px; letter-spacing: 0.5px; color: var(--gold); }
.brand p { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-dim); }

.panel-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-family: "Source Serif 4", serif;
  font-size: 14px;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.panel-toggle:hover { background: #232a33; border-color: var(--gold); transform: translateY(-1px); }
.hamburger {
  width: 16px; height: 11px; position: relative; display: inline-block;
}
.hamburger::before, .hamburger::after, .hamburger {
  content: ""; }
.hamburger { background: transparent; }
.hamburger::before, .hamburger::after {
  position: absolute; left: 0; width: 100%; height: 2px; background: var(--gold);
}
.hamburger::before { top: 0; box-shadow: 0 5px 0 var(--gold); }
.hamburger::after { bottom: 0; }

/* ---------- Legend ---------- */
.legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  padding: 10px 28px;
  font-size: 12.5px;
  color: var(--ink-dim);
  border-bottom: 1px solid var(--line);
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ---------- Timeline ---------- */
.timeline-wrap {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 30px 0 50px;
}

.conn-svg {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 5;
}

.timeline {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 60px;
  width: max-content;
  min-width: 100%;
}

.era-rail {
  position: relative;
  height: 36px;
  margin-bottom: 6px;
}
.era-marker {
  position: absolute;
  top: 0;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold);
  border-left: 1px dashed rgba(217,179,77,0.4);
  padding-left: 8px;
  height: 100%;
  display: flex;
  align-items: center;
}

.lane {
  position: relative;
  height: 64px;
  display: flex;
  align-items: center;
  border-radius: var(--radius);
  transition: opacity 0.35s ease, background 0.3s ease;
  opacity: 0.32;
}
.lane.active { opacity: 1; background: rgba(255,255,255,0.02); }
.lane.dimmed { opacity: 0.12; }

.lane-label {
  position: sticky;
  left: 0;
  z-index: 8;
  width: 150px;
  flex: 0 0 150px;
  font-size: 13.5px;
  font-weight: 600;
  padding: 6px 12px 6px 0;
  background: linear-gradient(90deg, var(--bg) 70%, transparent);
  color: var(--ink);
}
.lane-label small { display: block; font-size: 10.5px; color: var(--ink-dim); font-weight: 400; }

.lane-track {
  position: relative;
  flex: 1;
  height: 100%;
}

.lane-line {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--line);
  transform: translateY(-50%);
}

.node {
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(1);
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.08);
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), box-shadow 0.25s;
  z-index: 6;
}
.node:hover { transform: translate(-50%, -50%) scale(1.35); }
.node.highlight {
  box-shadow: 0 0 0 4px rgba(217,179,77,0.55), 0 0 14px rgba(217,179,77,0.7);
}

.node-mover {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 8px var(--gold);
  z-index: 7;
  opacity: 0;
}
@keyframes travel {
  0%   { opacity: 0; }
  8%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- Character panel ---------- */
.char-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: 340px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(.25,.8,.25,1);
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 22px;
}
.char-panel.open { transform: translateX(0); }

.char-panel-head { display: flex; align-items: center; justify-content: space-between; }
.char-panel-head h2 { margin: 0; color: var(--gold); font-size: 19px; }
.char-panel-head button, .modal-close, .info-close {
  background: transparent; border: none; color: var(--ink-dim); font-size: 16px; cursor: pointer;
}
.char-panel-head button:hover { color: var(--ink); }

.panel-hint { font-size: 12.5px; color: var(--ink-dim); line-height: 1.5; margin: 10px 0; }
.panel-actions { margin-bottom: 6px; }
.panel-actions button {
  background: transparent; border: 1px solid var(--line); color: var(--ink-dim);
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 12.5px;
}
.panel-actions button:hover { border-color: var(--gold); color: var(--gold); }

.char-list { overflow-y: auto; flex: 1; margin-top: 8px; padding-right: 4px; }
.char-group-title {
  font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--ink-dim);
  margin: 16px 0 8px;
}
.char-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}
.char-item:hover { background: rgba(255,255,255,0.04); }
.char-item input { margin-top: 3px; accent-color: var(--gold); }
.char-item .swatch { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex: 0 0 9px; }
.char-item-text strong { font-size: 13.5px; }
.char-item-text p { margin: 2px 0 0; font-size: 11.5px; color: var(--ink-dim); line-height: 1.4; }

/* ---------- Overlay / Modal ---------- */
.overlay-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  opacity: 0; pointer-events: none; transition: opacity 0.3s; z-index: 90;
}
.overlay-backdrop.show { opacity: 1; pointer-events: auto; }

.event-modal {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  z-index: 110; pointer-events: none; opacity: 0; transition: opacity 0.25s;
}
.event-modal.open { opacity: 1; pointer-events: auto; }
.event-modal-card {
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: 14px;
  max-width: 560px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
  transform: translateY(16px) scale(0.97);
  transition: transform 0.3s cubic-bezier(.25,.8,.25,1);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.event-modal.open .event-modal-card { transform: translateY(0) scale(1); }
.modal-close { position: absolute; top: 16px; right: 16px; font-size: 18px; }

#modalContent h3 { margin: 0 0 4px; color: var(--gold); font-size: 21px; }
#modalContent .meta { font-size: 12.5px; color: var(--ink-dim); margin-bottom: 14px; }
#modalContent .desc { line-height: 1.65; font-size: 15px; }
#modalContent .chars-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.char-chip {
  font-size: 11.5px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--ink-dim);
}
.info-btn {
  margin-top: 18px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(217,179,77,0.1);
  border: 1px solid rgba(217,179,77,0.4);
  color: var(--gold);
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
}
.info-btn:hover { background: rgba(217,179,77,0.22); }
.info-icon-circle {
  width: 17px; height: 17px; border-radius: 50%; border: 1.5px solid var(--gold);
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-style: italic; font-family: Georgia, serif;
}

/* ---------- Info popover (source citation) ---------- */
.info-popover {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 360px;
  max-height: 60vh;
  overflow-y: auto;
  background: #14181d;
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 18px 20px;
  z-index: 120;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.info-popover.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.info-close { position: absolute; top: 10px; right: 12px; }
#infoContent h4 { margin: 0 0 8px; color: var(--gold); font-size: 14px; letter-spacing: 0.3px; }
#infoContent .source-work { font-size: 12px; color: var(--ink-dim); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 1px; }
#infoContent .source-note { font-size: 13.5px; line-height: 1.6; font-style: italic; color: var(--ink); }
#infoContent .source-foot { margin-top: 12px; font-size: 11px; color: var(--ink-dim); }

/* ---------- Connection lines ---------- */
.conn-line {
  fill: none;
  stroke-width: 2;
  opacity: 0.85;
  stroke-linecap: round;
  filter: drop-shadow(0 0 3px rgba(217,179,77,0.5));
}

/* ---------- Footer ---------- */
.footer {
  padding: 18px 28px 40px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-dim);
  max-width: 900px;
}

/* scrollbars */
.timeline-wrap::-webkit-scrollbar, .char-list::-webkit-scrollbar, .event-modal-card::-webkit-scrollbar {
  height: 10px; width: 8px;
}
.timeline-wrap::-webkit-scrollbar-thumb, .char-list::-webkit-scrollbar-thumb {
  background: #333c47; border-radius: 6px;
}

@media (max-width: 720px) {
  .char-panel { width: 90%; }
  .lane-label { width: 110px; flex-basis: 110px; font-size: 12px; }
  .info-popover { right: 10px; left: 10px; width: auto; }
}
