/* ── Silk Road Story Common CSS ── */
/* Shared by all story pages. Each page defines :root vars + --accent-r/g/b. */

* { margin:0; padding:0; box-sizing:border-box; }
body { background: #000; font-family: -apple-system, "PingFang SC", "Noto Serif SC", "Microsoft YaHei", serif; overflow: hidden; height: 100vh; }

#map { position: fixed; inset: 0; z-index: 1; }
.leaflet-container { background: var(--bg); }

/* ── Story Nav ── */
#story-nav {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  z-index: 10; display: flex; gap: 0; font-size: 0.7rem;
}
#story-nav a {
  padding: 4px 10px; text-decoration: none; color: var(--text-dim);
  border: 1px solid var(--border); background: rgba(0,0,0,0.3);
  transition: all 0.2s; white-space: nowrap; min-height: 40px;
  display: flex; align-items: center;
}
#story-nav a:first-child { border-radius: 14px 0 0 14px; }
#story-nav a:last-child { border-radius: 0 14px 14px 0; }
#story-nav a.active {
  color: var(--accent); border-color: var(--accent);
  background: rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.1);
}
#story-nav a:hover:not(.active) { color: #fff; background: rgba(255,255,255,0.06); }

/* ── Narrative Card ── */
#narrative {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%);
  z-index: 10; width: min(92vw, 620px);
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 20px; padding: 32px 36px 28px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 48px rgba(0,0,0,0.5);
  transition: opacity 0.5s, transform 0.5s;
  cursor: pointer; user-select: none;
}
#narrative.fading { opacity: 0; transform: translateX(-50%) translateY(20px); }
#narrative.collapsed { padding: 12px 24px; }
#narrative.collapsed p,
#narrative.collapsed #badges { display: none; }
#narrative.collapsed h2 { font-size: 0.95rem; margin-bottom: 0; }
#narrative.collapsed .chapter-num { margin-bottom: 0; }
#narrative.collapsed .hint { margin-top: 0; margin-left: 12px; display: inline-flex; }
#toggle-card {
  position: absolute; top: 10px; right: 16px;
  background: none; border: none; color: var(--text-dim);
  font-size: 1.1rem; cursor: pointer; z-index: 2; padding: 2px 8px;
  line-height: 1; transition: color 0.2s;
}
#toggle-card:hover { color: #fff; }
#narrative.collapsed #toggle-card { top: 50%; transform: translateY(-50%); }
#narrative .chapter-num {
  font-size: 0.7rem; letter-spacing: 0.2em; color: var(--accent);
  text-transform: uppercase; margin-bottom: 6px;
}
#narrative h2 {
  font-size: 1.5rem; font-weight: 700; color: #fff;
  margin-bottom: 12px; letter-spacing: 0.04em; line-height: 1.4;
}
#narrative p {
  font-size: 1rem; line-height: 1.85; color: var(--text);
  margin-bottom: 6px;
}
#narrative .hint {
  margin-top: 18px; font-size: 0.78rem; color: var(--text-dim);
  display: flex; align-items: center; gap: 8px;
}
#narrative .hint .arrow { animation: bounce 1.2s infinite; }
@keyframes bounce { 0%,100%{transform:translateX(0)} 50%{transform:translateX(6px)} }

/* ── Progress Dots ── */
#progress {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
  z-index: 10; display: flex; gap: 10px;
}
#progress .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: rgba(255,255,255,0.2); transition: all 0.4s;
}
#progress .dot.active { background: var(--accent); transform: scale(1.4); }
#progress .dot.done {
  background: rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.5);
}

/* ── Nav buttons ── */
#restart {
  position: fixed; top: 24px; right: 24px; z-index: 10;
  background: rgba(255,255,255,0.06); border: 1px solid var(--border);
  color: var(--text-dim); padding: 8px 16px; border-radius: 20px;
  font-size: 0.78rem; cursor: pointer; transition: all 0.3s;
}
#restart:hover { background: rgba(255,255,255,0.12); color: #fff; }
#back {
  position: fixed; top: 24px; left: 24px; z-index: 10;
  background: rgba(255,255,255,0.06); border: 1px solid var(--border);
  color: var(--text-dim); padding: 8px 16px; border-radius: 20px;
  font-size: 0.78rem; cursor: pointer; transition: all 0.3s;
  text-decoration: none;
}
#back:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* ── Theme Toggle ── */
#theme-toggle {
  position: fixed; top: 24px; right: 110px; z-index: 10;
  background: rgba(255,255,255,0.06); border: 1px solid var(--border);
  color: var(--text-dim); padding: 8px 12px; border-radius: 20px;
  font-size: 0.9rem; cursor: pointer; transition: all 0.3s;
}
#theme-toggle:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* ── Sponsor Button ── */
#sponsor-btn {
  position: fixed; top: 24px; right: 185px; z-index: 10;
  background: linear-gradient(135deg, #d4a853, #c08830);
  color: #111; border: none; padding: 8px 14px; border-radius: 20px;
  font-size: 0.78rem; font-weight: 700; cursor: pointer;
  text-decoration: none; letter-spacing: 0.02em; transition: all 0.3s;
}
#sponsor-btn:hover { transform: scale(1.05); box-shadow: 0 4px 16px rgba(212,168,83,0.5); }

/* ── Mobile: 640px ── */
@media (max-width: 640px) {
  #narrative { bottom: 16px; padding: 24px 20px 20px; border-radius: 16px; }
  #narrative h2 { font-size: 1.2rem; }
  #narrative p { font-size: 0.9rem; }
  #story-nav a { padding: 3px 7px; font-size: 0.64rem; }
  #restart, #back, #theme-toggle, #sponsor-btn { top: 12px; padding: 6px 10px; font-size: 0.7rem; }
  #back { left: 8px; }
  #restart { right: 8px; }
  #theme-toggle { right: 80px; }
  #sponsor-btn { right: 155px; }
}

/* ── Mobile: 600px ── */
@media (max-width: 600px) {
  #story-nav {
    flex-wrap: wrap; justify-content: center; top: 12px; gap: 2px;
  }
  #story-nav a { padding: 4px 8px; font-size: 0.62rem; border-radius: 10px; }
  #story-nav a:first-child { border-radius: 10px; }
  #story-nav a:last-child { border-radius: 10px; }
  #progress { top: 72px; gap: 6px; }
  #progress .dot { width: 8px; height: 8px; }
}

/* ── Mobile: 480px ── */
@media (max-width: 480px) {
  #story-nav a { padding: 4px 6px; font-size: 0.55rem; min-height: 32px; }
  #narrative { bottom: 10px; padding: 18px 14px 14px; border-radius: 14px; }
  #narrative h2 { font-size: 1.05rem; }
  #narrative p { font-size: 0.82rem; }
}

/* ── Light Theme ── */
body.light {
  background: #f0ebe0;
  --bg: #f0ebe0;
  --card-bg: rgba(255,255,250,0.93);
  --text: #3d3427;
  --text-dim: #8c8070;
  --border: rgba(0,0,0,0.1);
}
body.light #narrative { box-shadow: 0 8px 48px rgba(0,0,0,0.1); }
body.light #story-nav a { background: rgba(0,0,0,0.03); }
body.light #story-nav a:hover:not(.active) { background: rgba(0,0,0,0.08); color: #333; }
body.light #restart, body.light #back, body.light #theme-toggle {
  background: rgba(0,0,0,0.03);
}
body.light #restart:hover, body.light #back:hover, body.light #theme-toggle:hover {
  background: rgba(0,0,0,0.08); color: #333;
}
body.light #narrative h2 { color: #222; }
body.light #narrative .hint { color: #8c8070; }
body.light #toggle-card:hover { color: #333; }
body.light .leaflet-container { background: var(--bg); }
