/* ============================================================
   浣花洗剑录 · 人物关系图 — Main Stylesheet
   ============================================================ */

/* ---- Reset ---- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  background: #0f0f1a;
  color: #d0d0d0;
  overflow: hidden;
  height: 100vh;
}

/* French typography: Latin-first font stack, tighter letter-spacing */
:lang(fr) body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
:lang(fr) #header h1 {
  letter-spacing: 1px;
}
:lang(fr) #header .subtitle {
  letter-spacing: 0.5px;
}

/* ---- Header ---- */
#header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 24px;
  background: linear-gradient(180deg, rgba(15,15,26,0.98) 60%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  height: 60px;
}

#header h1 {
  font-size: 20px; font-weight: 700;
  background: linear-gradient(90deg, #f1c40f, #e67e22);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  letter-spacing: 2px;
  white-space: nowrap;
}

#header .subtitle {
  font-size: 12px; color: #888; margin-left: 12px; letter-spacing: 1px;
  -webkit-text-fill-color: #888;
}

.author-badge {
  display: inline-block; font-size: 10px; padding: 1px 8px; margin-left: 8px;
  border-radius: 10px; background: rgba(241,196,15,0.15); color: #f1c40f;
  white-space: nowrap; letter-spacing: 1px;
  border: 1px solid rgba(241,196,15,0.2);
}
:lang(fr) .author-badge {
  letter-spacing: 0.5px;
}

/* ---- Back Button ---- */
.back-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  color: #888; text-decoration: none; font-size: 18px;
  margin-right: 8px; transition: 0.2s; flex-shrink: 0;
}
.back-btn:hover { background: rgba(255,255,255,0.08); color: #f1c40f; }

/* ---- Search Box ---- */
#search-box {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px; padding: 6px 14px; width: 280px; transition: 0.2s;
}

#search-box:focus-within { border-color: #f1c40f; background: rgba(255,255,255,0.1); }
#search-box input {
  background: none; border: none; outline: none; color: #eee;
  font-size: 14px; width: 100%;
}
#search-box input::placeholder { color: #666; }
#search-box .icon { color: #666; font-size: 16px; }
#result-count { font-size: 12px; color: #888; min-width: 36px; text-align: right; }

/* ---- Language Switcher ---- */
#lang-switcher { display: flex; align-items: center; gap: 2px; margin-right: 12px; }

.lang-btn {
  background: none; border: 1px solid transparent; color: #888;
  cursor: pointer; font-size: 16px; padding: 2px 5px;
  border-radius: 4px; transition: 0.2s; line-height: 1;
}
.lang-btn:hover { color: #ddd; }
.lang-btn.active { border-color: rgba(241,196,15,0.5); color: #f1c40f; }

/* ---- Graph Container ---- */
#graph-container {
  position: fixed; top: 60px; left: 0; right: 0; bottom: 52px;
}

/* ---- Legend (Bottom Bar) ---- */
#legend {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  height: 52px;
  display: flex; align-items: center; gap: 6px;
  padding: 0 16px;
  background: rgba(15,15,26,0.95);
  border-top: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(8px);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
#legend::-webkit-scrollbar { height: 2px; }
#legend::-webkit-scrollbar-thumb { background: #444; border-radius: 2px; }
#legend .legend-label {
  font-size: 11px; color: #666; white-space: nowrap; margin-right: 4px; letter-spacing: 1px;
}

.legend-item {
  display: flex; align-items: center; gap: 4px;
  white-space: nowrap; font-size: 11px; color: #aaa; padding: 4px 8px;
  border-radius: 4px; background: rgba(255,255,255,0.03);
  flex-shrink: 0; cursor: default; transition: 0.15s;
}
.legend-item:hover { background: rgba(255,255,255,0.08); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ---- Modal ---- */
#modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  justify-content: center; align-items: center;
}
#modal-overlay.active { display: flex; }

#modal {
  background: #1a1a2e; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px; max-width: 560px; width: 90%; max-height: 80vh;
  overflow-y: auto; position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: modalIn 0.25s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

#modal-close {
  position: sticky; top: 12px; float: right; margin: 12px 12px 0 0;
  background: rgba(255,255,255,0.08); border: none; color: #aaa;
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  font-size: 18px; display: flex; align-items: center; justify-content: center;
  transition: 0.2s; z-index: 1;
}
#modal-close:hover { background: rgba(255,255,255,0.15); color: #fff; }

.modal-avatar { text-align: center; padding: 28px 24px 8px; }
.modal-avatar svg { width: 90px; height: 90px; border-radius: 50%; box-shadow: 0 4px 24px rgba(0,0,0,0.5); }
.modal-name { text-align: center; font-size: 22px; font-weight: 700; margin-top: 12px; }
.modal-title { text-align: center; font-size: 13px; color: #aaa; margin-top: 4px; }
.modal-org-badge {
  display: inline-block; padding: 2px 12px; border-radius: 20px;
  font-size: 12px; margin-top: 8px;
}

.modal-body { padding: 16px 24px 24px; }
.modal-field { margin: 8px 0; display: flex; gap: 8px; font-size: 14px; line-height: 1.6; }
.modal-field .label { color: #888; min-width: 60px; flex-shrink: 0; }
.modal-field .value { color: #d0d0d0; }
.modal-quotes { margin-top: 12px; }
.modal-quotes h4 { color: #f1c40f; font-size: 13px; margin-bottom: 8px; }
.modal-quotes blockquote {
  border-left: 3px solid rgba(241,196,15,0.4);
  padding: 6px 12px; margin: 6px 0; font-size: 13px; color: #bbb;
  background: rgba(255,255,255,0.03); border-radius: 0 6px 6px 0;
  line-height: 1.6;
}
#modal::-webkit-scrollbar { width: 4px; }
#modal::-webkit-scrollbar-track { background: transparent; }
#modal::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }

/* ---- vis-network Tooltip ---- */
.vis-tooltip {
  background: rgba(20,20,35,0.95) !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  border-radius: 8px !important;
  color: #ddd !important;
  font-size: 13px !important;
  padding: 6px 12px !important;
  font-family: inherit !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3) !important;
}

/* ---- SEO / Accessibility ---- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.section-title {
  font-size: 14px; color: #666; letter-spacing: 2px; margin-bottom: 8px; white-space: nowrap;
}

.seo-description {
  display: none; /* hidden visually, indexed by search engines */
}

/* ---- Responsive ---- */

/* Large phones / small tablets */
@media (max-width: 640px) {
  #header { padding: 8px 12px; height: 52px; }
  #header h1 { font-size: 16px; }
  #header .subtitle { display: none; }
  #search-box { width: 180px; padding: 4px 10px; }
  #graph-container { top: 52px; bottom: 44px; }
  #legend { height: 44px; padding: 0 8px; gap: 4px; }
  #legend .legend-label { display: none; }
  #legend .legend-item:nth-child(n+6) { display: none; }
  #modal { max-width: 96%; max-height: 90vh; }
  .modal-body { padding: 12px 16px 20px; }
}

/* Mainstream phones — auto-wrap header to two rows */
@media (max-width: 480px) {
  #header { flex-wrap: wrap; height: auto; min-height: 48px; padding: 6px 8px; row-gap: 4px; }
  #header h1 { font-size: 14px; letter-spacing: 1px; }
  .author-badge { display: none; }
  #search-box { width: 120px; padding: 3px 8px; }
  #search-box input { font-size: 12px; }
  #search-box .icon { font-size: 13px; }
  #lang-switcher { gap: 1px; margin-right: 6px; }
  .lang-btn { font-size: 13px; padding: 2px 3px; }
  #graph-container { top: 56px; bottom: 40px; }
  #legend { height: 40px; padding: 0 6px; gap: 3px; }
  .legend-item { font-size: 10px; padding: 2px 5px; }
  #legend .legend-item:nth-child(n+4) { display: none; }
  .modal-name { font-size: 18px; }
  .modal-avatar svg { width: 70px; height: 70px; }
  .modal-field { font-size: 13px; }
  .modal-body { padding: 10px 12px 16px; }
}

/* Very small phones — compact header, fewer legend items */
@media (max-width: 380px) {
  #header { padding: 4px 6px; row-gap: 3px; }
  #header h1 { font-size: 12px; }
  #search-box { width: 100px; padding: 2px 6px; }
  #search-box input { font-size: 11px; }
  .lang-btn { font-size: 12px; padding: 1px 2px; }
  #graph-container { top: 52px; bottom: 36px; }
  #legend { height: 36px; padding: 0 4px; gap: 2px; }
  .legend-item { font-size: 9px; padding: 1px 4px; }
  #legend .legend-item:nth-child(n+3) { display: none; }
  #modal { max-width: 98%; }
  .modal-name { font-size: 16px; }
  .modal-avatar svg { width: 60px; height: 60px; }
}
