/* ===== 全局 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --font: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  --bg-1: #FFF6E6;
  --bg-2: #FFE9D6;
  --ink: #4A3B2A;
  --ink-soft: #7A6A55;
  --card: #ffffff;
  --shadow: 0 6px 18px rgba(120, 80, 40, 0.16);
  --radius: 20px;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.7;
  /* 入场淡入 */
  animation: pageIn 0.8s ease both;
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== 背景装饰 ===== */
.sky-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.cloud {
  position: absolute;
  font-size: 2.4rem;
  opacity: 0.85;
  animation: drift linear infinite;
}
.cloud-1 { top: 8%;  left: -10%; animation-duration: 38s; }
.cloud-2 { top: 22%; left: -20%; font-size: 1.8rem; animation-duration: 52s; animation-delay: -10s; }
.cloud-3 { top: 60%; left: -15%; font-size: 2rem;  animation-duration: 46s; animation-delay: -20s; }

@keyframes drift {
  from { transform: translateX(0); }
  to   { transform: translateX(120vw); }
}

.lantern {
  position: absolute;
  top: 10%;
  right: 6%;
  font-size: 2.6rem;
  animation: swing 4s ease-in-out infinite;
  transform-origin: top center;
}
@keyframes swing {
  0%, 100% { transform: rotate(-6deg); }
  50%      { transform: rotate(6deg); }
}

.star {
  position: absolute;
  font-size: 1.4rem;
  animation: twinkle 2.4s ease-in-out infinite;
}
.star-1 { top: 30%; left: 12%; animation-delay: 0s; }
.star-2 { top: 16%; left: 70%; animation-delay: 0.8s; }
.star-3 { top: 45%; left: 85%; animation-delay: 1.4s; }
@keyframes twinkle {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50%      { opacity: 1;   transform: scale(1.2); }
}

/* ===== 标题横幅 ===== */
.banner {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 40px 16px 18px;
}
.title {
  font-size: clamp(1.8rem, 5vw, 3rem);
  color: #B5471F;
  text-shadow: 2px 2px 0 #fff, 4px 4px 0 rgba(181, 71, 31, 0.15);
  letter-spacing: 2px;
  animation: titlePop 0.9s cubic-bezier(0.18, 0.89, 0.32, 1.28) both;
}
@keyframes titlePop {
  0%   { opacity: 0; transform: scale(0.6) rotate(-6deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
.subtitle {
  margin-top: 12px;
  font-size: clamp(0.95rem, 2.2vw, 1.15rem);
  color: var(--ink-soft);
  animation: fadeUp 1s ease 0.3s both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== 布局:左侧导航 + 右侧详情 ===== */
.layout {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 20px;
  max-width: 1200px;
  margin: 10px auto 0;
  padding: 0 16px 40px;
}

/* ===== 时间轴(左侧竖向导航) ===== */
.timeline-section {
  flex: 0 0 210px;
  position: sticky;
  top: 12px;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  max-height: calc(100vh - 150px);
  padding: 8px 6px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  scroll-snap-type: y proximity;
}
.timeline::-webkit-scrollbar { width: 8px; }
.timeline::-webkit-scrollbar-thumb {
  background: #E0B080;
  border-radius: 8px;
}
.timeline::-webkit-scrollbar-track { background: transparent; }

.node {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  margin: 0;
  padding: 9px 8px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  scroll-snap-align: center;
  border: none;
  background: transparent;
  font-family: var(--font);
  text-align: left;
  border-radius: 12px;
  transition: background 0.2s ease;
}

/* 竖向连接线(用朝代主题色 --c) */
.node::before {
  content: "";
  position: absolute;
  left: 27px;            /* padding-left 8 + 圆点半径 21 = 29,线宽 4 居中 → 27 */
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--c, #E0B080);
  opacity: 0.3;
  z-index: 0;
}
.node:first-child::before { top: 50%; }
.node:last-child::before { bottom: 50%; }

.node .dot {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.95rem;
  font-weight: bold;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  border: 4px solid #fff;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  animation: breathe 2.6s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.07); }
}
.node:hover { background: rgba(0, 0, 0, 0.04); }
.node:hover .dot {
  transform: scale(1.14);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
}
.node.active { background: rgba(181, 71, 31, 0.08); }
.node.active .dot {
  transform: scale(1.16);
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.9), 0 6px 16px rgba(0, 0, 0, 0.3);
  animation: none;
}

.node .text {
  display: flex;
  flex-direction: column;
  z-index: 1;
}
.node .name {
  font-size: 0.95rem;
  font-weight: bold;
  color: var(--ink);
  line-height: 1.2;
}
.node .period {
  font-size: 0.66rem;
  color: var(--ink-soft);
  margin-top: 2px;
  line-height: 1.3;
}
.node.active .name { color: #B5471F; }

/* ===== 详情面板 ===== */
.detail {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-width: 0;          /* 防止 flex 子项撑爆容器 */
  margin: 0;
  padding: 0;
  min-height: 60vh;
}

.detail-card {
  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 30px 28px;
  border-top: 10px solid var(--dynasty-color, #E8B86D);
  animation: cardIn 0.5s ease both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dynasty-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px 18px;
  margin-bottom: 6px;
}
.dynasty-head h2 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  color: var(--dynasty-color, #B5471F);
}
.dynasty-head .period-tag {
  background: var(--dynasty-color, #E8B86D);
  color: #fff;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: bold;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin: 12px 0 18px;
  color: var(--ink-soft);
  font-size: 0.95rem;
}
.meta span b { color: var(--ink); }

.summary {
  background: linear-gradient(120deg, rgba(232, 184, 109, 0.15), rgba(255, 255, 255, 0));
  border-left: 5px solid var(--dynasty-color, #E8B86D);
  padding: 14px 18px;
  border-radius: 0 14px 14px 0;
  margin: 8px 0 24px;
  font-size: 1.05rem;
}

.section-title {
  font-size: 1.3rem;
  margin: 26px 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

/* 大事卡片网格 */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.event-card {
  background: #fff8ee;
  border-radius: 16px;
  padding: 18px 18px 16px;
  box-shadow: 0 3px 10px rgba(120, 80, 40, 0.1);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
  border: 2px solid transparent;
}
.event-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 22px rgba(120, 80, 40, 0.2);
  border-color: var(--dynasty-color, #E8B86D);
}
.event-card .ico {
  font-size: 1.8rem;
  display: inline-block;
  margin-bottom: 6px;
}
.event-card h3 {
  font-size: 1.1rem;
  margin-bottom: 6px;
  color: var(--ink);
}
.event-card p {
  font-size: 0.95rem;
  color: var(--ink-soft);
}

/* 文化科技卡(冷色调,区别于大事记) */
.event-card.cool {
  background: #EEF4FF;
}
.event-card.cool:hover {
  border-color: #5B8BC0;
}

/* 人物卡片 */
.figure-card {
  background: #fff;
  border-radius: 16px;
  padding: 18px 14px;
  text-align: center;
  box-shadow: 0 3px 10px rgba(120, 80, 40, 0.1);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}
.figure-card:hover {
  transform: translateY(-6px) rotate(-1deg);
  box-shadow: 0 12px 22px rgba(120, 80, 40, 0.22);
}
.figure-card .avatar {
  font-size: 2.6rem;
  width: 70px;
  height: 70px;
  line-height: 70px;
  margin: 0 auto 10px;
  background: #FFF1DC;
  border-radius: 50%;
  border: 3px solid var(--dynasty-color, #E8B86D);
}
.figure-card h3 {
  font-size: 1.1rem;
  color: var(--ink);
  margin-bottom: 4px;
}
.figure-card p {
  font-size: 0.88rem;
  color: var(--ink-soft);
}

/* 趣味小知识气泡 */
.funfacts {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.funfact {
  background: #FFF6E6;
  border: 2px dashed var(--dynasty-color, #E8B86D);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 0.95rem;
  color: var(--ink);
  line-height: 1.6;
  max-width: 100%;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.funfact:hover {
  transform: translateY(-3px) rotate(-0.5deg);
  box-shadow: 0 8px 16px rgba(120, 80, 40, 0.18);
}
.funfact .ico {
  margin-right: 6px;
}

/* 卡片依次入场 */
.stagger > * {
  opacity: 0;
  animation: itemIn 0.5s ease forwards;
}
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.13s; }
.stagger > *:nth-child(3) { animation-delay: 0.21s; }
.stagger > *:nth-child(4) { animation-delay: 0.29s; }
.stagger > *:nth-child(5) { animation-delay: 0.37s; }
.stagger > *:nth-child(6) { animation-delay: 0.45s; }
@keyframes itemIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 上一个 / 下一个 */
.nav-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
}
.nav-btn {
  flex: 1;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: bold;
  padding: 12px 16px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  background: #FFE9D6;
  color: var(--ink);
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 3px 8px rgba(120, 80, 40, 0.12);
}
.nav-btn:hover:not(:disabled) {
  transform: translateY(-3px);
  background: #FFD8B0;
  box-shadow: 0 8px 16px rgba(120, 80, 40, 0.22);
}
.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 占位(未选择时) */
.placeholder {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
  font-size: 1.1rem;
}
.placeholder .big-emoji {
  font-size: 3.4rem;
  display: block;
  margin-bottom: 12px;
  animation: bounce 2s ease-in-out infinite;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-12px); }
}

/* ===== 回到顶部 ===== */
.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 54px;
  height: 54px;
  border: none;
  border-radius: 50%;
  font-size: 1.4rem;
  background: #B5471F;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(181, 71, 31, 0.4);
  opacity: 0;
  visibility: hidden;
  transform: scale(0.6);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
  z-index: 50;
}
.back-to-top.show {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}
.back-to-top:hover {
  transform: scale(1.12) rotate(-8deg);
}

/* ===== 页脚 ===== */
.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 24px 16px 40px;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* ===== 响应式 ===== */
@media (max-width: 760px) {
  /* 窄屏:导航条回到顶部横向,详情堆在下方 */
  .layout { flex-direction: column; gap: 12px; }
  .timeline-section {
    position: static;
    flex: 1 1 auto;
    width: 100%;
  }
  .timeline {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
    gap: 14px;
    padding: 24px 12px 16px;
    scroll-snap-type: x proximity;
  }
  .timeline::-webkit-scrollbar { width: 0; height: 10px; }
  .node {
    flex-direction: column;
    width: 88px;
    align-items: center;
    text-align: center;
    padding: 4px 2px;
  }
  .node::before { display: none; }                  /* 隐藏竖线 */
  .node .text { align-items: center; }
  .node .name { margin-top: 6px; }
  /* 横向连接线 */
  .node:not(:last-child) .dot::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 100%;
    margin-left: 4px;
    width: 24px;
    height: 5px;
    background: var(--c, #E0B080);
    opacity: 0.4;
    border-radius: 3px;
    transform: translateY(-50%);
  }
}

@media (max-width: 600px) {
  .banner { padding: 28px 12px 12px; }
  .detail-card { padding: 22px 16px; }
  .nav-btn { font-size: 0.9rem; padding: 11px 10px; }
}
