/* ============================================================
   SHARED SOULS — Main Stylesheet
   Aesthetic: Dark editorial / manga panel energy
   Fonts: Cormorant Garamond (display) + DM Sans (body) + DM Mono
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400;1,600&family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

/* ── Design tokens ─────────────────────────────────────────── */
:root {
  --bg:           #0e0d0f;
  --bg-card:      #141217;
  --bg-hover:     #1c1a21;
  --border:       rgba(255,255,255,0.06);
  --border-hover: rgba(255,255,255,0.14);

  --text:         #f0ebe4;
  --text-muted:   #887e90;
  --text-faint:   #4a4352;

  --shinobu:  #9F7AEA;
  --natasha:  #F56565;
  --mha:      #48BB78;
  --mcu:      #E53E3E;
  --ds:       #9F7AEA;

  --radius: 10px;
  --transition: 0.22s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4 { font-family: 'Cormorant Garamond', serif; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: clamp(2.2rem, 5vw, 4rem); line-height: 1.05; }
h2 { font-size: clamp(1.5rem, 3vw, 2.2rem); line-height: 1.1; }
h3 { font-size: clamp(1.1rem, 2vw, 1.5rem); }
h4 { font-size: 1rem; }
p  { line-height: 1.65; font-size: 0.93rem; color: var(--text-muted); }
code { font-family: 'DM Mono', monospace; font-size: 0.82rem; }
a { color: inherit; text-decoration: none; }

/* ── Layout ──────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }

/* ── Card ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: var(--transition);
}
.card:hover { border-color: var(--border-hover); background: var(--bg-hover); }

/* ── Tags ───────────────────────────────────────────────────── */
.tag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tag-mha  { background: rgba(72,187,120,0.15);  color: #48BB78; }
.tag-ds   { background: rgba(159,122,234,0.15); color: #9F7AEA; }
.tag-mcu  { background: rgba(245,101,101,0.15); color: #F56565; }
.tag-oc   { background: rgba(45,55,72,0.4);     color: #A0AEC0; }

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

/* ══════════════════════════════════════════════════════════════
   HEADER / NAV
   ══════════════════════════════════════════════════════════════ */
#site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(14,13,15,0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  height: 60px;
  display: flex; align-items: center;
}
#site-header .inner {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
}
.brand {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.2rem; font-weight: 700; letter-spacing: 0.03em;
  color: var(--text); white-space: nowrap;
}
#site-header nav { display: flex; gap: 0.2rem; }
#site-header nav a {
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.83rem;
  transition: var(--transition);
}
#site-header nav a:hover { color: var(--text); background: rgba(255,255,255,0.05); }
#site-header nav a.active { color: var(--text); background: rgba(255,255,255,0.08); }

/* ══════════════════════════════════════════════════════════════
   PAGE WRAPPER
   ══════════════════════════════════════════════════════════════ */
.page-wrap { padding: 2.5rem 0 5rem; }

/* ── Page header ────────────────────────────────────────────── */
.page-header { margin-bottom: 2rem; }
.page-header .eyebrow {
  font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 0.5rem;
}
.page-header h1 { line-height: 1.05; }
.page-header p  { margin-top: 0.6rem; max-width: 60ch; }

/* ══════════════════════════════════════════════════════════════
   OVERVIEW (index.html)
   ══════════════════════════════════════════════════════════════ */
.hero-title {
  background: linear-gradient(135deg, #f0ebe4 30%, #9F7AEA 80%, #F56565 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.hero-glow {
  position: absolute; top: -100px; left: 50%; transform: translateX(-50%);
  width: 600px; height: 350px;
  background: radial-gradient(ellipse, rgba(159,122,234,0.08) 0%, transparent 70%);
  pointer-events: none;
}
.hero-meta { display: flex; gap: 2rem; flex-wrap: wrap; font-size: 0.8rem; color: var(--text-faint); margin-top: 1.5rem; }
.hero-meta strong { color: var(--text-muted); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 1rem; margin: 2rem 0; }
.stat-pill {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.2rem 1.4rem; border-left: 3px solid transparent;
}
.stat-pill .label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-faint); margin-bottom: 0.35rem; }
.stat-pill .value { font-family: 'Cormorant Garamond', serif; font-size: 1.45rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-pill .sub   { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.2rem; }

.saga-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 0.8rem; margin-top: 1.5rem; }
.saga-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.3rem; border-left: 3px solid transparent; }
.saga-card .saga-num { font-size: 0.63rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); margin-bottom: 0.2rem; }
.saga-card .saga-name { font-family: 'Cormorant Garamond', serif; font-size: 1.05rem; color: var(--text); }
.saga-card .saga-range { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ══════════════════════════════════════════════════════════════
   CHARACTERS (characters.html)
   ══════════════════════════════════════════════════════════════ */
.filter-bar { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.filter-bar button {
  padding: 0.3rem 0.85rem; border-radius: 20px; border: 1px solid var(--border);
  background: transparent; color: var(--text-muted); font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem; cursor: pointer; transition: var(--transition);
}
.filter-bar button:hover { border-color: var(--border-hover); color: var(--text); }
.filter-bar button.active { border-color: var(--shinobu); color: var(--shinobu); background: rgba(159,122,234,0.1); }

.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px,1fr)); gap: 1rem; }
.char-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; cursor: pointer; transition: var(--transition); position: relative; overflow: hidden;
}
.char-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--char-color, #9F7AEA), transparent);
}
.char-card:hover { border-color: var(--border-hover); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.char-card .char-name  { font-family: 'Cormorant Garamond', serif; font-size: 1.15rem; font-weight: 700; color: var(--text); }
.char-card .char-alias { font-size: 0.75rem; color: var(--text-muted); font-style: italic; margin: 0.1rem 0 0.5rem; }
.char-card .char-role  { font-size: 0.7rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.6rem; }
.char-card .char-desc  { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.char-card .char-tags  { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.8rem; }

/* Detail panel */
#char-detail {
  position: fixed; right: 0; top: 60px;
  width: min(430px, 100vw); height: calc(100vh - 60px);
  background: #0b0a0e; border-left: 1px solid var(--border);
  overflow-y: auto; z-index: 90;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  padding: 2rem 1.5rem;
}
#char-detail.open { transform: translateX(0); }
.detail-close {
  position: absolute; top: 1rem; right: 1rem;
  background: var(--bg-hover); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 1rem; width: 30px; height: 30px;
  border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.detail-close:hover { color: var(--text); }
.detail-section { margin-top: 1.4rem; }
.detail-section h4 { font-size: 0.63rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-faint); margin-bottom: 0.5rem; }
.moment-list { list-style: none; }
.moment-list li { font-size: 0.82rem; color: var(--text-muted); padding: 0.45rem 0; border-bottom: 1px solid var(--border); display: flex; gap: 0.6rem; }
.ch-badge { font-family: 'DM Mono', monospace; font-size: 0.68rem; color: var(--text-faint); white-space: nowrap; }

/* ══════════════════════════════════════════════════════════════
   ARCS (arcs.html)
   ══════════════════════════════════════════════════════════════ */
.arcs-layout { display: grid; grid-template-columns: 1fr 270px; gap: 2rem; align-items: start; }
.arc-timeline { position: relative; }
.arc-timeline::before {
  content: ''; position: absolute; left: 82px; top: 0; bottom: 0;
  width: 1px; background: var(--border);
}
.arc-item { display: grid; grid-template-columns: 82px 1fr; gap: 1.5rem; padding: 0.9rem 0; position: relative; }
.arc-item::before {
  content: ''; position: absolute; left: 78px; top: 1.5rem;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--arc-color, var(--text-faint)); border: 2px solid var(--bg); z-index: 1;
}
.arc-ch { font-family: 'DM Mono', monospace; font-size: 0.7rem; color: var(--text-faint); text-align: right; padding-top: 0.15rem; }
.arc-body { padding-left: 0.5rem; }
.arc-saga { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-faint); margin-bottom: 0.15rem; }
.arc-name { font-family: 'Cormorant Garamond', serif; font-size: 1.08rem; font-weight: 600; color: var(--text); margin-bottom: 0.35rem; }
.arc-summary { font-size: 0.81rem; color: var(--text-muted); line-height: 1.55; }
.arc-events { margin-top: 0.5rem; }
.arc-event { font-size: 0.74rem; color: var(--text-faint); padding: 0.1rem 0 0.1rem 0.8rem; position: relative; }
.arc-event::before { content: '—'; position: absolute; left: 0; }
.tension-bar-wrap { margin-top: 0.45rem; }
.tension-row { display: flex; justify-content: space-between; font-size: 0.6rem; color: var(--text-faint); margin-bottom: 0.15rem; }
.tension-bar { height: 3px; border-radius: 2px; background: var(--border); overflow: hidden; }
.tension-fill { height: 100%; border-radius: 2px; }

/* sidebar chart */
.chart-sidebar { position: sticky; top: 80px; }

/* ══════════════════════════════════════════════════════════════
   CONSTELLATION (constellation.html)
   ══════════════════════════════════════════════════════════════ */
#constellation-wrap {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  position: relative; overflow: hidden; height: 580px;
}
#constellation-canvas { width: 100%; height: 100%; display: block; cursor: grab; }
#constellation-canvas:active { cursor: grabbing; }
#node-tooltip {
  position: absolute; background: #0b0a0e;
  border: 1px solid var(--border-hover); border-radius: 8px;
  padding: 0.8rem 1rem; pointer-events: none; z-index: 10;
  max-width: 200px; display: none;
}
#node-tooltip .tt-name { font-family: 'Cormorant Garamond', serif; font-size: 1rem; font-weight: 700; color: var(--text); }
#node-tooltip .tt-role { font-size: 0.63rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); margin: 0.15rem 0 0.35rem; }
#node-tooltip .tt-desc { font-size: 0.78rem; color: var(--text-muted); line-height: 1.45; }
.legend { display: flex; gap: 1.5rem; flex-wrap: wrap; margin-top: 1rem; font-size: 0.78rem; color: var(--text-muted); }
.legend span { display: flex; align-items: center; gap: 0.4rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ══════════════════════════════════════════════════════════════
   ECHOES (echoes.html)
   ══════════════════════════════════════════════════════════════ */
.dialogue-list { display: flex; flex-direction: column; gap: 0.75rem; }
.dialogue-entry {
  background: var(--bg-card); border: 1px solid var(--border);
  border-left: 3px solid var(--speaker-color, var(--border));
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.2rem; transition: var(--transition);
}
.dialogue-entry:hover { background: var(--bg-hover); }
.d-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.35rem; flex-wrap: wrap; gap: 0.4rem; }
.d-speaker { font-family: 'Cormorant Garamond', serif; font-size: 0.95rem; font-weight: 700; }
.d-context { font-size: 0.68rem; color: var(--text-faint); font-style: italic; }
.d-text    { font-style: italic; color: var(--text-muted); font-size: 0.88rem; line-height: 1.55; }

/* ══════════════════════════════════════════════════════════════
   FOOTER
   ══════════════════════════════════════════════════════════════ */
footer {
  border-top: 1px solid var(--border); padding: 1.5rem 0; margin-top: 3rem;
}
footer .inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
footer span { font-size: 0.75rem; color: var(--text-faint); }

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeUp { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
.fade-up { animation: fadeUp 0.4s ease forwards; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .arcs-layout { grid-template-columns: 1fr; }
  .chart-sidebar { display: none; }
}
@media (max-width: 640px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .char-grid { grid-template-columns: 1fr; }
  .arc-timeline::before { left: 50px; }
  .arc-item { grid-template-columns: 50px 1fr; }
  .arc-item::before { left: 46px; }
  #char-detail { width: 100vw; }
}
